From 10945da15694bd05ba729288d0b9ae3a45ed1d53 Mon Sep 17 00:00:00 2001 From: Christopher Beckmann Date: Thu, 29 Jun 2017 17:49:39 +0200 Subject: [PATCH] Added the Tutorial to the NavigationDrawer --- .../ui/baseactivity/BaseActivity.java | 6 ++++++ .../ui/tutorial/TutorialActivity.java | 14 +++++++++++--- app/src/main/res/drawable/ic_school_black_24dp.xml | 10 ++++++++++ app/src/main/res/layouts/about/values/strings.xml | 4 ++++ app/src/main/res/menu/activity_main_drawer.xml | 6 ++++++ 5 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 app/src/main/res/drawable/ic_school_black_24dp.xml create mode 100644 app/src/main/res/layouts/about/values/strings.xml diff --git a/app/src/main/java/privacyfriendlyshoppinglist/secuso/org/privacyfriendlyshoppinglist/ui/baseactivity/BaseActivity.java b/app/src/main/java/privacyfriendlyshoppinglist/secuso/org/privacyfriendlyshoppinglist/ui/baseactivity/BaseActivity.java index 38a42ca8..bdc17f2e 100644 --- a/app/src/main/java/privacyfriendlyshoppinglist/secuso/org/privacyfriendlyshoppinglist/ui/baseactivity/BaseActivity.java +++ b/app/src/main/java/privacyfriendlyshoppinglist/secuso/org/privacyfriendlyshoppinglist/ui/baseactivity/BaseActivity.java @@ -23,6 +23,7 @@ import privacyfriendlyshoppinglist.secuso.org.privacyfriendlyshoppinglist.ui.main.MainActivity; import privacyfriendlyshoppinglist.secuso.org.privacyfriendlyshoppinglist.ui.settings.SettingsActivity; import privacyfriendlyshoppinglist.secuso.org.privacyfriendlyshoppinglist.ui.statistics.StatisticsActivity; +import privacyfriendlyshoppinglist.secuso.org.privacyfriendlyshoppinglist.ui.tutorial.TutorialActivity; /** * Created by Chris on 04.07.2016. @@ -179,6 +180,11 @@ private void callDrawerItem(final int itemId) intent = new Intent(this, HelpActivity.class); createBackStack(intent); break; + case R.id.nav_tutorial: + intent = new Intent(this, TutorialActivity.class); + intent.setAction(TutorialActivity.ACTION_SHOW_ANYWAYS); + createBackStack(intent); + break; case R.id.nav_settings: intent = new Intent(this, SettingsActivity.class); intent.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT, SettingsActivity.GeneralPreferenceFragment.class.getName()); diff --git a/app/src/main/java/privacyfriendlyshoppinglist/secuso/org/privacyfriendlyshoppinglist/ui/tutorial/TutorialActivity.java b/app/src/main/java/privacyfriendlyshoppinglist/secuso/org/privacyfriendlyshoppinglist/ui/tutorial/TutorialActivity.java index 4da7fa58..5b2cefb7 100644 --- a/app/src/main/java/privacyfriendlyshoppinglist/secuso/org/privacyfriendlyshoppinglist/ui/tutorial/TutorialActivity.java +++ b/app/src/main/java/privacyfriendlyshoppinglist/secuso/org/privacyfriendlyshoppinglist/ui/tutorial/TutorialActivity.java @@ -24,6 +24,9 @@ public class TutorialActivity extends AppCompatActivity { + private static final String TAG = TutorialActivity.class.getSimpleName(); + public static final String ACTION_SHOW_ANYWAYS = TAG + ".ACTION_SHOW_ANYWAYS"; + private ViewPager viewPager; private MyViewPagerAdapter myViewPagerAdapter; private LinearLayout dotsLayout; @@ -38,9 +41,12 @@ protected void onCreate(Bundle savedInstanceState) { // Checking for first time launch - before calling setContentView() prefManager = new PrefManager(this); - if (!prefManager.isFirstTimeLaunch()) { + + Intent i = getIntent(); + + if (!prefManager.isFirstTimeLaunch() && (i == null || !ACTION_SHOW_ANYWAYS.equals(i.getAction()))) { launchHomeScreen(); - finish(); + return; } // Making notification bar transparent @@ -122,7 +128,9 @@ private int getItem(int i) { private void launchHomeScreen() { prefManager.setFirstTimeLaunch(false); - startActivity(new Intent(TutorialActivity.this, MainActivity.class)); + Intent intent = new Intent(TutorialActivity.this, MainActivity.class); + intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); + startActivity(intent); finish(); } diff --git a/app/src/main/res/drawable/ic_school_black_24dp.xml b/app/src/main/res/drawable/ic_school_black_24dp.xml new file mode 100644 index 00000000..f8d18b28 --- /dev/null +++ b/app/src/main/res/drawable/ic_school_black_24dp.xml @@ -0,0 +1,10 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layouts/about/values/strings.xml b/app/src/main/res/layouts/about/values/strings.xml new file mode 100644 index 00000000..7d60b8de --- /dev/null +++ b/app/src/main/res/layouts/about/values/strings.xml @@ -0,0 +1,4 @@ + + + Tutorial + \ No newline at end of file diff --git a/app/src/main/res/menu/activity_main_drawer.xml b/app/src/main/res/menu/activity_main_drawer.xml index 13983597..b4f4f5c9 100644 --- a/app/src/main/res/menu/activity_main_drawer.xml +++ b/app/src/main/res/menu/activity_main_drawer.xml @@ -11,6 +11,11 @@ android:id="@+id/nav_statistics" android:icon="@drawable/ic_insert_chart_white_24sp" android:title="@string/statistics"/> + + +