Skip to content

Commit

Permalink
Added the Tutorial to the NavigationDrawer
Browse files Browse the repository at this point in the history
  • Loading branch information
Kamuno committed Jun 29, 2017
1 parent 4346004 commit 10945da
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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();
}

Expand Down
10 changes: 10 additions & 0 deletions app/src/main/res/drawable/ic_school_black_24dp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M5,13.18v4L12,21l7,-3.82v-4L12,17l-7,-3.82zM12,3L1,9l11,6 9,-4.91V17h2V9L12,3z"/>
</vector>
4 changes: 4 additions & 0 deletions app/src/main/res/layouts/about/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="action_tutorial">Tutorial</string>
</resources>
6 changes: 6 additions & 0 deletions app/src/main/res/menu/activity_main_drawer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
android:id="@+id/nav_statistics"
android:icon="@drawable/ic_insert_chart_white_24sp"
android:title="@string/statistics"/>
<item
android:id="@+id/nav_tutorial"
android:icon="@drawable/ic_school_black_24dp"
android:title="@string/action_tutorial"/>

</group>

<group android:id="@+id/nav_group_add"
Expand All @@ -19,6 +24,7 @@
android:id="@+id/nav_settings"
android:icon="@drawable/ic_menu_settings"
android:title="@string/action_settings"/>

<item
android:id="@+id/nav_help"
android:icon="@drawable/ic_menu_help"
Expand Down

0 comments on commit 10945da

Please sign in to comment.