Fixed #32 and added the Tutorial to the NavigationDrawer. Some string files still need to be translated.

This commit is contained in:
Christopher Beckmann 2017-06-29 16:57:29 +02:00
parent 7a00ba4aaf
commit 84995affe5
8 changed files with 48 additions and 7 deletions

View file

@ -27,6 +27,7 @@ import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.RatingBar;
import android.widget.TextView;
import android.widget.Toast;
import org.secuso.privacyfriendlysudoku.controller.GameController;
import org.secuso.privacyfriendlysudoku.controller.GameStateManager;
@ -45,6 +46,7 @@ import org.secuso.privacyfriendlysudoku.ui.view.SudokuKeyboardLayout;
import org.secuso.privacyfriendlysudoku.ui.view.SudokuSpecialButtonLayout;
import org.secuso.privacyfriendlysudoku.ui.view.WinDialog;
import java.util.IllegalFormatCodePointException;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.RunnableFuture;
@ -244,7 +246,12 @@ public class GameActivity extends BaseActivity implements NavigationView.OnNavig
}
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
Symbol s = Symbol.valueOf(Symbol.class, sharedPref.getString("pref_symbols", "Default"));
Symbol s;
try {
s = Symbol.valueOf(sharedPref.getString("pref_symbols", Symbol.Default.name()));
} catch(IllegalArgumentException e) {
s = Symbol.Default;
}
layout.setSymbols(s);
keyboard.setSymbols(s);
}

View file

@ -41,6 +41,8 @@ import java.io.Serializable;
import java.util.LinkedList;
import java.util.List;
import static org.secuso.privacyfriendlysudoku.ui.TutorialActivity.ACTION_SHOW_ANYWAYS;
public class MainActivity extends BaseActivity implements NavigationView.OnNavigationItemSelectedListener{
RatingBar difficultyBar;
@ -326,6 +328,14 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
startActivity(intent);
overridePendingTransition(0, 0);
break;
case R.id.menu_tutorial_main:
intent = new Intent(this, TutorialActivity.class);
intent.setAction(ACTION_SHOW_ANYWAYS);
startActivity(intent);
overridePendingTransition(0, 0);
break;
default:
}
return true;

View file

@ -29,6 +29,9 @@ import org.secuso.privacyfriendlysudoku.ui.view.R;
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;
@ -41,11 +44,15 @@ public class TutorialActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Checking for first time launch - before calling setContentView()
prefManager = new PrefManager(this);
Intent i = getIntent();
if(i == null || !ACTION_SHOW_ANYWAYS.equals(i.getAction())) {
// Checking for first time launch - before calling setContentView()
if (!prefManager.isFirstTimeLaunch()) {
launchHomeScreen();
finish();
return;
}
}
// Making notification bar transparent
@ -126,7 +133,10 @@ public class TutorialActivity extends AppCompatActivity {
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);
//intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
startActivity(intent);
finish();
}

View file

@ -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>

View file

@ -4,7 +4,7 @@
android:title="@string/menu_reset" />
<group android:id="@+id/group4">
<item android:id="@+id/nav_newgame" android:icon="@android:drawable/ic_menu_today"
<item android:id="@+id/nav_newgame" android:icon="@drawable/ic_menu_home"
android:title="@string/menu_main" />
<item android:id="@+id/nav_highscore" android:icon="@android:drawable/ic_menu_myplaces"
android:title="@string/menu_highscore" />

View file

@ -13,6 +13,8 @@
android:checkableBehavior="all">
<item android:id="@+id/menu_settings_main" android:icon="@drawable/ic_menu_settings"
android:title="@string/menu_settings" />
<item android:id="@+id/menu_tutorial_main" android:icon="@drawable/ic_school_black_24dp"
android:title="@string/menu_tutorial"/>
<item android:id="@+id/menu_help_main" android:icon="@drawable/ic_menu_help"
android:title="@string/menu_help" />
<item android:id="@+id/menu_about_main" android:icon="@drawable/ic_menu_about"

View file

@ -95,5 +95,6 @@
<string name="next">Weiter</string>
<string name="skip">Skip</string>
<string name="menu_tutorial">Tutorial</string>
</resources>

View file

@ -145,4 +145,5 @@
<string name="next">Next</string>
<string name="skip">Skip</string>
<string name="menu_tutorial">Tutorial</string>
</resources>