Skip to content

Commit

Permalink
Added guided tour struct at questions activity (Escola-em-Casa#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
markinlimac committed Oct 14, 2020
1 parent c1c17b2 commit e112d51
Showing 1 changed file with 47 additions and 0 deletions.
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 smartdevelop.ir.eram.showcaseviewlib.listener.GuideListener;

import android.content.SharedPreferences;

public class QuestionsActivity extends AppCompatActivity {
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("Esta aba serve para acessar as dúvidas frequentes")
.setGravity(Gravity.auto) //optional
.setDismissType(DismissType.anywhere) //optional - default DismissType.targetView
.setTargetView(findViewById(R.id.questions))
.setContentTextSize(12)//optional
.setTitleTextSize(14)//optional
.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 @@ -48,6 +93,8 @@ protected void onCreate(Bundle savedInstanceState) {
return false;
}
);

checkFirstRun();
}

@Override
Expand Down

0 comments on commit e112d51

Please sign in to comment.