Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arrumando activity que já está aberta #42

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ apply plugin: 'com.android.application'

android {
compileSdkVersion 29

buildToolsVersion "29.0.3"
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
Expand Down Expand Up @@ -39,4 +40,6 @@ dependencies {
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation fileTree(dir: 'libs', include: ['*.aar', '*.jar'], exclude: [])
implementation 'com.android.support:multidex:+'
implementation 'com.github.iammert:MaterialIntroView:1.6.0'
implementation 'com.github.mreram:showcaseview:1.2.0'
}
63 changes: 63 additions & 0 deletions app/src/main/java/org/cordova/quasar/corona/app/AboutActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,53 @@

import com.google.android.material.bottomnavigation.BottomNavigationView;

import smartdevelop.ir.eram.showcaseviewlib.GuideView;
import smartdevelop.ir.eram.showcaseviewlib.config.DismissType;
import smartdevelop.ir.eram.showcaseviewlib.config.Gravity;
import smartdevelop.ir.eram.showcaseviewlib.listener.GuideListener;

import android.content.SharedPreferences;

public class AboutActivity extends AppCompatActivity {
private String about_tutorial = "Esta aba serve para acessar informações do aplicativo.\n\nAqui se encontram alguns links importantes, caso tenha dúvidas de como acessar o ambiente de sala de aula, basta clicar no link 'Como acessar o Google Sala de Aula', caso tenha dúvida de como utilizar o aplicativo, clique no botão 'Tutorial interativo'";

private void checkFirstRun() {
final String PREFS_NAME = "about_first_run";
final String PREF_VERSION_CODE_KEY = "1.0";
final int DOESNT_EXIST = -1;

// Get current version code
int currentVersionCode = BuildConfig.VERSION_CODE;

// Get saved version code
SharedPreferences prefs = getSharedPreferences(PREFS_NAME, MODE_PRIVATE);
int savedVersionCode = prefs.getInt(PREF_VERSION_CODE_KEY, DOESNT_EXIST);

// Check for first run or upgrade
if (currentVersionCode == savedVersionCode) {

// This is just a normal run
return;

} else if (savedVersionCode == DOESNT_EXIST) {
new GuideView.Builder(this)
.setTitle("Sobre")
.setContentText(about_tutorial)
.setDismissType(DismissType.anywhere)
.setTargetView(findViewById(R.id.about))
.setContentTextSize(14)
.setTitleTextSize(16)
.build()
.show();
} else if (currentVersionCode > savedVersionCode) {

// TODO This is an upgrade
}

// Update the shared preferences with the current version code
prefs.edit().putInt(PREF_VERSION_CODE_KEY, currentVersionCode).apply();
}

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand All @@ -34,11 +80,17 @@ protected void onCreate(Bundle savedInstanceState) {
navigationView.getMenu().getItem(1).setChecked(true);
return true;
case R.id.questions:
if (navigationView.getSelectedItemId() == R.id.questions) {
return true;
}
startActivity(new Intent(getApplicationContext(), QuestionsActivity.class));
overridePendingTransition(0, 0);
navigationView.getMenu().getItem(2).setChecked(true);
return true;
case R.id.about:
if (navigationView.getSelectedItemId() == R.id.about) {
return true;
}
startActivity(new Intent(getApplicationContext(), AboutActivity.class));
overridePendingTransition(0, 0);
navigationView.getMenu().getItem(3).setChecked(true);
Expand All @@ -47,6 +99,8 @@ protected void onCreate(Bundle savedInstanceState) {
return false;
}
);

checkFirstRun();
}

public void myOnClick(View view) {
Expand All @@ -69,6 +123,15 @@ public void myOnClick(View view) {
.putExtra("url", "http://www.se.df.gov.br/"));
overridePendingTransition(0, 0);
break;
case "tutorial_btn":
getSharedPreferences("classroom_first_run", MODE_PRIVATE).edit().clear().apply();
getSharedPreferences("wikipedia_first_run", MODE_PRIVATE).edit().clear().apply();
getSharedPreferences("questions_first_run", MODE_PRIVATE).edit().clear().apply();
getSharedPreferences("about_first_run", MODE_PRIVATE).edit().clear().apply();
startActivity(new Intent(getApplicationContext(), WebviewActivity.class)
.putExtra("url", "https://classroom.google.com/a/estudante.se.df.gov.br"));
overridePendingTransition(0, 0);
break;
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,52 @@

import com.google.android.material.bottomnavigation.BottomNavigationView;

import smartdevelop.ir.eram.showcaseviewlib.GuideView;
import smartdevelop.ir.eram.showcaseviewlib.config.DismissType;
import smartdevelop.ir.eram.showcaseviewlib.config.Gravity;

import android.content.SharedPreferences;

public class QuestionsActivity extends AppCompatActivity {
private String question_tutorial = "Esta aba serve para acessar as dúvidas frequentes.\n\nCaso não consiga solucionar sua dúvida, verifique a aba 'sobre', no link, 'Escola em Casa DF (site)'.";

private void checkFirstRun() {
final String PREFS_NAME = "questions_first_run";
final String PREF_VERSION_CODE_KEY = "1.0";
final int DOESNT_EXIST = -1;

// Get current version code
int currentVersionCode = BuildConfig.VERSION_CODE;

// Get saved version code
SharedPreferences prefs = getSharedPreferences(PREFS_NAME, MODE_PRIVATE);
int savedVersionCode = prefs.getInt(PREF_VERSION_CODE_KEY, DOESNT_EXIST);

// Check for first run or upgrade
if (currentVersionCode == savedVersionCode) {

// This is just a normal run
return;

} else if (savedVersionCode == DOESNT_EXIST) {
new GuideView.Builder(this)
.setTitle("Dúvidas Frequentes")
.setContentText(question_tutorial)
.setDismissType(DismissType.anywhere)
.setTargetView(findViewById(R.id.questions))
.setContentTextSize(14)
.setTitleTextSize(16)
.build()
.show();
} else if (currentVersionCode > savedVersionCode) {

// TODO This is an upgrade
}

// Update the shared preferences with the current version code
prefs.edit().putInt(PREF_VERSION_CODE_KEY, currentVersionCode).apply();
}

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand All @@ -33,13 +78,19 @@ protected void onCreate(Bundle savedInstanceState) {
navigationView.getMenu().getItem(1).setChecked(true);
return true;
case R.id.questions:
if (navigationView.getSelectedItemId() == R.id.questions) {
return true;
}
startActivity(new Intent(getApplicationContext(), QuestionsActivity.class));
overridePendingTransition(0, 0);

navigationView.getMenu().getItem(2).setChecked(true);

return true;
case R.id.about:
if (navigationView.getSelectedItemId() == R.id.about) {
return true;
}
startActivity(new Intent(getApplicationContext(), AboutActivity.class));
overridePendingTransition(0, 0);
navigationView.getMenu().getItem(3).setChecked(true);
Expand All @@ -48,6 +99,8 @@ protected void onCreate(Bundle savedInstanceState) {
return false;
}
);

checkFirstRun();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import smartdevelop.ir.eram.showcaseviewlib.GuideView;
import smartdevelop.ir.eram.showcaseviewlib.config.DismissType;
import smartdevelop.ir.eram.showcaseviewlib.config.Gravity;

import android.content.SharedPreferences;

public class WebviewActivity extends AppCompatActivity {
private WebView myWebView;
private String url;
Expand All @@ -61,6 +67,8 @@ public class WebviewActivity extends AppCompatActivity {
private String mCameraPhotoPath;
private static final int INPUT_FILE_REQUEST_CODE = 1;
private static final int FILECHOOSER_RESULTCODE = 1;
private String classrom_tutorial = "Esta aba serve para acessar sua conta do Google Sala de Aula.\n\nSeu email de acesso é composto pelo primeiro nome junto com o código de estudante, acrescido de @estudante.se.df.gov.br\n\nPara saber como obter o primeiro acesso, verifique a aba 'sobre', no link, 'como acessar o Google Sala de Aula'.";
private String wikipedia_tutorial = "Esta aba serve para acessar a wikipédia.\n\nUtilizando o ícone da lupa é possivel fazer buscas dentro da wikipédia";

private File createImageFile() throws IOException {
// Create an image file name
Expand All @@ -75,6 +83,79 @@ private File createImageFile() throws IOException {
return imageFile;
}

private void checkClassroomFirstRun() {
final String PREFS_NAME = "classroom_first_run";
final String PREF_VERSION_CODE_KEY = "1.0";
final int DOESNT_EXIST = -1;

// Get current version code
int currentVersionCode = BuildConfig.VERSION_CODE;

// Get saved version code
SharedPreferences prefs = getSharedPreferences(PREFS_NAME, MODE_PRIVATE);
int savedVersionCode = prefs.getInt(PREF_VERSION_CODE_KEY, DOESNT_EXIST);

// Check for first run or upgrade
if (currentVersionCode == savedVersionCode) {

// This is just a normal run
return;

} else if (savedVersionCode == DOESNT_EXIST) {
new GuideView.Builder(this)
.setTitle("Google Sala de Aula")
.setContentText(classrom_tutorial)
.setDismissType(DismissType.targetView)
.setTargetView(findViewById(R.id.classroom))
.setContentTextSize(14)
.setTitleTextSize(16)
.build()
.show();
} else if (currentVersionCode > savedVersionCode) {
// TODO This is an upgrade
}

// Update the shared preferences with the current version code
prefs.edit().putInt(PREF_VERSION_CODE_KEY, currentVersionCode).apply();
}

private void checkWikipediaFirstRun() {
final String PREFS_NAME = "wikipedia_first_run";
final String PREF_VERSION_CODE_KEY = "1.0";
final int DOESNT_EXIST = -1;

// Get current version code
int currentVersionCode = BuildConfig.VERSION_CODE;

// Get saved version code
SharedPreferences prefs = getSharedPreferences(PREFS_NAME, MODE_PRIVATE);
int savedVersionCode = prefs.getInt(PREF_VERSION_CODE_KEY, DOESNT_EXIST);

// Check for first run or upgrade
if (currentVersionCode == savedVersionCode) {

// This is just a normal run
return;

} else if (savedVersionCode == DOESNT_EXIST) {
new GuideView.Builder(this)
.setTitle("Wikipédia")
.setContentText(wikipedia_tutorial)
.setDismissType(DismissType.anywhere)
.setTargetView(findViewById(R.id.wikipedia))
.setContentTextSize(14)
.setTitleTextSize(16)
.build()
.show();
} else if (currentVersionCode > savedVersionCode) {

// TODO This is an upgrade
}

// Update the shared preferences with the current version code
prefs.edit().putInt(PREF_VERSION_CODE_KEY, currentVersionCode).apply();
}

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand Down Expand Up @@ -120,6 +201,9 @@ protected void onCreate(Bundle savedInstanceState) {
return true;
}
case R.id.questions: {
if (navigationView.getSelectedItemId() == R.id.questions) {
return true;
}
startActivity(new Intent(getApplicationContext(), QuestionsActivity.class));
overridePendingTransition(0, 0);

Expand All @@ -128,6 +212,9 @@ protected void onCreate(Bundle savedInstanceState) {
return true;
}
case R.id.about: {
if (navigationView.getSelectedItemId() == R.id.about) {
return true;
}
startActivity(new Intent(getApplicationContext(), AboutActivity.class));
overridePendingTransition(0, 0);
navigationView.getMenu().getItem(3).setChecked(true);
Expand Down Expand Up @@ -159,6 +246,12 @@ protected void onCreate(Bundle savedInstanceState) {

url = getIntent().getStringExtra("url");
myWebView.loadUrl(url);

if (url.equals("https://classroom.google.com/a/estudante.se.df.gov.br")) {
checkClassroomFirstRun();
} else if (url.equals("https://pt.wikipedia.org/")) {
checkWikipediaFirstRun();
}
}

@Override
Expand Down
Loading