diff --git a/.idea/.name b/.idea/.name index bb144c1..974ec58 100644 --- a/.idea/.name +++ b/.idea/.name @@ -1 +1 @@ -Sudoku \ No newline at end of file +privacy-friendly-sudoku \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml index 5f8ec24..7ac24c7 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -3,16 +3,15 @@ diff --git a/.idea/misc.xml b/.idea/misc.xml index 5d19981..50282c1 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -27,6 +27,22 @@ + + + + + + + + + + + Android + + + + + @@ -43,4 +59,30 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/app.iml b/app/app.iml index 7932f75..02dc78d 100644 --- a/app/app.iml +++ b/app/app.iml @@ -9,15 +9,11 @@ \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index d47f92c..72c4a6b 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,8 +1,8 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 23 - buildToolsVersion "23.0.2" + compileSdkVersion 24 + buildToolsVersion '24.0.1' testOptions { unitTests.returnDefaultValues = true @@ -11,9 +11,9 @@ android { defaultConfig { applicationId "org.secuso.privacyfriendlysudoku" minSdkVersion 16 - targetSdkVersion 23 + targetSdkVersion 24 versionCode 1 - versionName "1.0" + versionName "2.0" } buildTypes { release { @@ -21,12 +21,20 @@ android { proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_7 + targetCompatibility JavaVersion.VERSION_1_7 + } } dependencies { - compile fileTree(dir: 'libs', include: ['*.jar']) + compile fileTree(include: ['*.jar'], dir: 'libs') testCompile 'junit:junit:4.12' - compile 'com.android.support:appcompat-v7:23.1.0' - compile 'com.android.support:design:23.1.0' - compile 'com.android.support:support-v4:23.1.0' + compile 'com.android.support:support-compat:24.2.1' + compile 'com.android.support:support-v4:24.2.1' + compile 'com.android.support:support-v13:24.2.1' + compile 'com.android.support:appcompat-v7:24.2.1' + compile 'com.android.support:design:24.2.1' + compile 'com.android.support:support-core-ui:24.2.1' + compile 'com.android.support:support-core-utils:24.2.1' } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index c51ade1..592b7b8 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,45 +1,38 @@ + package="org.secuso.privacyfriendlysudoku.ui.view"> + android:theme="@style/AppTheme"> + android:theme="@style/AppTheme.NoActionBar"> - - + android:parentActivityName="org.secuso.privacyfriendlysudoku.ui.MainActivity" /> - - - - - + android:theme="@style/AppTheme.NoActionBar" /> + + - + android:theme="@style/AppTheme.NoActionBar" /> - + android:label="@string/title_activity_help" /> - + \ No newline at end of file diff --git a/app/src/main/java/org/secuso/privacyfriendlysudoku/controller/GameController.java b/app/src/main/java/org/secuso/privacyfriendlysudoku/controller/GameController.java index 024ae02..695dc06 100644 --- a/app/src/main/java/org/secuso/privacyfriendlysudoku/controller/GameController.java +++ b/app/src/main/java/org/secuso/privacyfriendlysudoku/controller/GameController.java @@ -320,6 +320,7 @@ public class GameController implements IModelChangedListener, Parcelable { if(settings.getBoolean("pref_timer_reset", true)) { time = 0; + notifyTimerListener(0); undoRedoManager = new UndoRedoManager(gameBoard); } else { undoRedoManager.addState(gameBoard); @@ -611,6 +612,11 @@ public class GameController implements IModelChangedListener, Parcelable { return usedHints; } + public void resetTime() { + time = 0; + notifyTimerListener(0); + } + public void initTimer() { deleteTimer(); @@ -621,7 +627,7 @@ public class GameController implements IModelChangedListener, Parcelable { @Override public void run() { if(timerRunning.get()) { - notifyTimerListener(time++); + notifyTimerListener(++time); //Log.d("Timer", "calling notifyTimerListener(" + time + ");"); } } diff --git a/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/AboutActivity.java b/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/AboutActivity.java index 3574c92..83d586b 100644 --- a/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/AboutActivity.java +++ b/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/AboutActivity.java @@ -4,17 +4,22 @@ import android.graphics.Color; import android.graphics.drawable.ColorDrawable; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; +import android.text.method.LinkMovementMethod; import android.view.MenuItem; +import android.widget.TextView; import org.secuso.privacyfriendlysudoku.ui.view.R; -public class AboutActivity extends AppCompatActivity { +public class AboutActivity extends BaseActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_about); + ((TextView)findViewById(R.id.secusoWebsite)).setMovementMethod(LinkMovementMethod.getInstance()); + ((TextView)findViewById(R.id.githubURL)).setMovementMethod(LinkMovementMethod.getInstance()); + android.support.v7.app.ActionBar actionBar = getSupportActionBar(); actionBar.setTitle(R.string.menu_about); actionBar.setDisplayHomeAsUpEnabled(true); diff --git a/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/BaseActivity.java b/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/BaseActivity.java new file mode 100644 index 0000000..02d9ea9 --- /dev/null +++ b/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/BaseActivity.java @@ -0,0 +1,52 @@ +package org.secuso.privacyfriendlysudoku.ui; + +import android.os.Bundle; +import android.os.Handler; +import android.preference.PreferenceManager; +import android.support.v7.app.AppCompatActivity; +import android.view.View; + +import org.secuso.privacyfriendlysudoku.ui.view.R; + +/** + * Created by Chris on 15.10.2016. + */ + +public class BaseActivity extends AppCompatActivity { + + static final int NAVDRAWER_LAUNCH_DELAY = 250; + static final int MAIN_CONTENT_FADEOUT_DURATION = 150; + static final int MAIN_CONTENT_FADEIN_DURATION = 250; + + protected Handler mHandler; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + mHandler = new Handler(); + + overridePendingTransition(0, 0); + } + + @Override + public void onResume() { + super.onResume(); + + View mainContent = findViewById(R.id.main_content); + if (mainContent != null) { + mainContent.animate().alpha(1).setDuration(MAIN_CONTENT_FADEIN_DURATION); + } + } + + @Override + protected void onPostCreate(Bundle savedInstanceState) { + super.onPostCreate(savedInstanceState); + + View mainContent = findViewById(R.id.main_content); + if (mainContent != null) { + mainContent.setAlpha(0); + mainContent.animate().alpha(1).setDuration(MAIN_CONTENT_FADEIN_DURATION); + } + } +} diff --git a/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/GameActivity.java b/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/GameActivity.java index b2931a9..4c8e125 100644 --- a/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/GameActivity.java +++ b/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/GameActivity.java @@ -47,8 +47,9 @@ import org.secuso.privacyfriendlysudoku.ui.view.WinDialog; import java.util.LinkedList; import java.util.List; +import java.util.concurrent.RunnableFuture; -public class GameActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener, IGameSolvedListener ,ITimerListener, IHintDialogFragmentListener, IResetDialogFragmentListener { +public class GameActivity extends BaseActivity implements NavigationView.OnNavigationItemSelectedListener, IGameSolvedListener ,ITimerListener, IHintDialogFragmentListener, IResetDialogFragmentListener { GameController gameController; SudokuFieldLayout layout; @@ -61,12 +62,30 @@ public class GameActivity extends AppCompatActivity implements NavigationView.On SaveLoadStatistics statistics = new SaveLoadStatistics(this); WinDialog dialog = null; + @Override + protected void onPostCreate(Bundle savedInstanceState) { + super.onPostCreate(savedInstanceState); + + if(gameSolved) { + gameController.pauseTimer(); + } else { + // start the game + mHandler.postDelayed(new Runnable() { + @Override + public void run() { + gameController.startTimer(); + } + }, MAIN_CONTENT_FADEIN_DURATION); + } + } + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); + SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this); GameType gameType = GameType.Unspecified; GameDifficulty gameDifficulty = GameDifficulty.Unspecified; @@ -103,8 +122,17 @@ public class GameActivity extends AppCompatActivity implements NavigationView.On gameController = savedInstanceState.getParcelable("gameController"); // in case we get the same object back // because parceling the Object does not always parcel it. Only if needed. - gameController.removeAllListeners(); - gameController.setContextAndSettings(getApplicationContext(), sharedPref); + if(gameController != null) { + gameController.removeAllListeners(); + gameController.setContextAndSettings(getApplicationContext(), sharedPref); + } else { + // Error: no game could be restored. Go back to main menu. + Intent intent = new Intent(this, MainActivity.class); + intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); + startActivity(intent); + finish(); + overridePendingTransition(0, 0); + } gameSolved = savedInstanceState.getInt("gameSolved") == 1; } @@ -177,17 +205,15 @@ public class GameActivity extends AppCompatActivity implements NavigationView.On layout.setEnabled(false); keyboard.setButtonsEnabled(false); specialButtonLayout.setButtonsEnabled(false); - gameController.pauseTimer(); - } else { - // start the game - gameController.startTimer(); } + gameController.notifyHighlightChangedListeners(); gameController.notifyTimerListener(gameController.getTime()); // run this so the error list gets build again. gameController.onModelChange(null); + overridePendingTransition(0, 0); } @Override @@ -201,10 +227,21 @@ public class GameActivity extends AppCompatActivity implements NavigationView.On @Override public void onResume(){ super.onResume(); + + View mainContent = findViewById(R.id.main_content); + if (mainContent != null) { + mainContent.animate().alpha(1).setDuration(MAIN_CONTENT_FADEOUT_DURATION); + } + gameController.initTimer(); if(!gameSolved) { - gameController.startTimer(); + mHandler.postDelayed(new Runnable() { + @Override + public void run() { + gameController.startTimer(); + } + }, MAIN_CONTENT_FADEIN_DURATION); } SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this); @@ -238,7 +275,7 @@ public class GameActivity extends AppCompatActivity implements NavigationView.On // Handle navigation view item clicks here. int id = item.getItemId(); - Intent intent; + Intent intent = null; switch(id) { case R.id.menu_reset: @@ -250,7 +287,6 @@ public class GameActivity extends AppCompatActivity implements NavigationView.On //create new game intent = new Intent(this, MainActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); - startActivity(intent); finish(); break; @@ -259,31 +295,44 @@ public class GameActivity extends AppCompatActivity implements NavigationView.On intent = new Intent(this,SettingsActivity.class); intent.putExtra( PreferenceActivity.EXTRA_SHOW_FRAGMENT, SettingsActivity.GamePreferenceFragment.class.getName() ); intent.putExtra( PreferenceActivity.EXTRA_NO_HEADERS, true ); - startActivity(intent); break; case R.id.nav_highscore: // see highscore list intent = new Intent(this, StatsActivity.class); - startActivity(intent); break; case R.id.menu_about: //open about page intent = new Intent(this,AboutActivity.class); - startActivity(intent); break; case R.id.menu_help: //open about page intent = new Intent(this,HelpActivity.class); - intent.putExtra( HelpActivity.EXTRA_SHOW_FRAGMENT, HelpActivity.HelpFragment.class.getName() ); - intent.putExtra( HelpActivity.EXTRA_NO_HEADERS, true ); - startActivity(intent); break; default: } + if(intent != null) { + + final Intent i = intent; + // fade out the active activity + View mainContent = findViewById(R.id.main_content); + if (mainContent != null) { + mainContent.animate().alpha(0).setDuration(MAIN_CONTENT_FADEOUT_DURATION); + } + + mHandler.postDelayed(new Runnable() { + @Override + public void run() { + startActivity(i); + overridePendingTransition(0, 0); + } + }, NAVDRAWER_LAUNCH_DELAY); + + } + DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); drawer.closeDrawer(GravityCompat.START); return true; @@ -326,6 +375,7 @@ public class GameActivity extends AppCompatActivity implements NavigationView.On Intent intent = new Intent(activity, MainActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); + overridePendingTransition(0, 0); activity.finish(); } }); diff --git a/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/HelpActivity.java b/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/HelpActivity.java index ea8db62..161005d 100644 --- a/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/HelpActivity.java +++ b/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/HelpActivity.java @@ -19,6 +19,7 @@ import android.preference.PreferenceManager; import android.preference.RingtonePreference; import android.text.TextUtils; import android.view.MenuItem; +import android.view.View; import org.secuso.privacyfriendlysudoku.ui.view.R; @@ -35,11 +36,13 @@ import java.util.List; * href="http://developer.android.com/guide/topics/ui/settings.html">Settings * API Guide for more information on developing a Settings UI. */ -public class HelpActivity extends AppCompatPreferenceActivity { +public class HelpActivity extends BaseActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setupActionBar(); + + setContentView(R.layout.activity_help); } /** @@ -53,33 +56,6 @@ public class HelpActivity extends AppCompatPreferenceActivity { } } - - /** - * {@inheritDoc} - */ - @Override - public boolean onIsMultiPane() { - return isXLargeTablet(this); - } - - /** - * Helper method to determine if the device has an extra-large screen. For - * example, 10" tablets are extra-large. - */ - private static boolean isXLargeTablet(Context context) { - return (context.getResources().getConfiguration().screenLayout - & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_XLARGE; - } - - /** - * {@inheritDoc} - */ - @Override - @TargetApi(Build.VERSION_CODES.HONEYCOMB) - public void onBuildHeaders(List
target) { - loadHeadersFromResource(R.xml.pref_help_headers, target); - } - /** * A preference value change listener that updates the preference's summary * to reflect its new value. diff --git a/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/LoadGameActivity.java b/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/LoadGameActivity.java index 80b50a9..8de62ad 100644 --- a/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/LoadGameActivity.java +++ b/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/LoadGameActivity.java @@ -10,7 +10,6 @@ import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; import android.preference.PreferenceManager; -import android.support.v7.app.AppCompatActivity; import android.view.LayoutInflater; import android.view.MenuItem; import android.view.View; @@ -34,7 +33,7 @@ import java.util.LinkedList; import java.util.List; import java.util.TimeZone; -public class LoadGameActivity extends AppCompatActivity implements IDeleteDialogFragmentListener { +public class LoadGameActivity extends BaseActivity implements IDeleteDialogFragmentListener { List loadableGameList; SharedPreferences settings; @@ -93,7 +92,7 @@ public class LoadGameActivity extends AppCompatActivity implements IDeleteDialog } }; - ListView listView = (ListView)findViewById(R.id.load_game_list); + ListView listView = (ListView)findViewById(R.id.main_content); loadGameAdapter = new LoadGameAdapter(this, loadableGameList); listView.setAdapter(loadGameAdapter); listView.setOnItemClickListener(clickListener); diff --git a/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/MainActivity.java b/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/MainActivity.java index 857350d..899d226 100644 --- a/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/MainActivity.java +++ b/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/MainActivity.java @@ -4,6 +4,7 @@ import android.app.Activity; import android.app.AlertDialog; import android.app.Dialog; import android.app.DialogFragment; +import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; @@ -40,12 +41,13 @@ import java.io.Serializable; import java.util.LinkedList; import java.util.List; -public class MainActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener{ +public class MainActivity extends BaseActivity implements NavigationView.OnNavigationItemSelectedListener{ RatingBar difficultyBar; TextView difficultyText; SharedPreferences settings; ImageView arrowLeft, arrowRight; + DrawerLayout drawer; /** * The {@link ViewPager} that will host the section contents. @@ -160,7 +162,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On // set Nav_Bar - DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout_main); + drawer = (DrawerLayout) findViewById(R.id.drawer_layout_main); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle( this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); drawer.setDrawerListener(toggle); @@ -169,7 +171,9 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view_main); navigationView.setNavigationItemSelectedListener(this); + overridePendingTransition(0, 0); } + public void callFragment(View view){ /*FragmentManager fm = getSupportFragmentManager(); DialogWinScreen winScreen = new DialogWinScreen(); @@ -219,8 +223,23 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On break; default: } - if(i != null) { - startActivity(i); + + final Intent intent = i; + + if(intent != null) { + + View mainContent = findViewById(R.id.main_content); + if (mainContent != null) { + mainContent.animate().alpha(0).setDuration(MAIN_CONTENT_FADEOUT_DURATION); + } + + mHandler.postDelayed(new Runnable() { + @Override + public void run() { + startActivity(intent); + } + }, MAIN_CONTENT_FADEOUT_DURATION); + } } @@ -248,8 +267,27 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On @Override public boolean onNavigationItemSelected(MenuItem item) { // Handle navigation view item clicks here. - int id = item.getItemId(); + final int id = item.getItemId(); + // delay transition so the drawer can close + mHandler.postDelayed(new Runnable() { + @Override + public void run() { + goToNavigationItem(id); + } + }, NAVDRAWER_LAUNCH_DELAY); + + drawer.closeDrawer(GravityCompat.START); + + // fade out the active activity + View mainContent = findViewById(R.id.main_content); + if (mainContent != null) { + mainContent.animate().alpha(0).setDuration(MAIN_CONTENT_FADEOUT_DURATION); + } + return true; + } + + private boolean goToNavigationItem(int id) { Intent intent; switch(id) { @@ -259,6 +297,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On intent.putExtra( PreferenceActivity.EXTRA_SHOW_FRAGMENT, SettingsActivity.GamePreferenceFragment.class.getName() ); intent.putExtra( PreferenceActivity.EXTRA_NO_HEADERS, true ); startActivity(intent); + overridePendingTransition(0, 0); break; case R.id.nav_highscore_main: @@ -266,26 +305,24 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On intent = new Intent(this, StatsActivity.class); startActivity(intent); + overridePendingTransition(0, 0); break; case R.id.menu_about_main: //open about page intent = new Intent(this,AboutActivity.class); startActivity(intent); + overridePendingTransition(0, 0); break; case R.id.menu_help_main: //open about page intent = new Intent(this,HelpActivity.class); - intent.putExtra( HelpActivity.EXTRA_SHOW_FRAGMENT, HelpActivity.HelpFragment.class.getName() ); - intent.putExtra( HelpActivity.EXTRA_NO_HEADERS, true ); startActivity(intent); + overridePendingTransition(0, 0); break; default: } - - DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout_main); - drawer.closeDrawer(GravityCompat.START); return true; } @@ -389,7 +426,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setView(i.inflate(R.layout.welcome_dialog, null)); - builder.setIcon(R.mipmap.ic_launcher); + builder.setIcon(R.mipmap.ic_launcher_nopfa); builder.setTitle(getActivity().getString(R.string.app_name_long)); builder.setPositiveButton(getActivity().getString(R.string.win_button_text), null); diff --git a/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/SettingsActivity.java b/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/SettingsActivity.java index 0cf60ea..e3a80c1 100644 --- a/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/SettingsActivity.java +++ b/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/SettingsActivity.java @@ -13,6 +13,7 @@ import android.support.v7.app.ActionBar; import android.preference.PreferenceFragment; import android.preference.PreferenceManager; import android.view.MenuItem; +import android.view.View; import org.secuso.privacyfriendlysudoku.ui.view.R; @@ -34,6 +35,14 @@ public class SettingsActivity extends AppCompatPreferenceActivity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setupActionBar(); + + overridePendingTransition(0, 0); + + View mainContent = findViewById(R.id.main_content); + if (mainContent != null) { + mainContent.setAlpha(0); + mainContent.animate().alpha(1).setDuration(BaseActivity.MAIN_CONTENT_FADEIN_DURATION); + } } /** diff --git a/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/StatsActivity.java b/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/StatsActivity.java index e41190e..93c0ef5 100644 --- a/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/StatsActivity.java +++ b/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/StatsActivity.java @@ -9,7 +9,6 @@ import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.view.ViewPager; -import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.view.LayoutInflater; import android.view.Menu; @@ -27,7 +26,7 @@ import org.secuso.privacyfriendlysudoku.ui.view.R; import java.util.List; -public class StatsActivity extends AppCompatActivity { +public class StatsActivity extends BaseActivity { /** * The {@link android.support.v4.view.PagerAdapter} that will provide @@ -62,12 +61,11 @@ public class StatsActivity extends AppCompatActivity { mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. - mViewPager = (ViewPager) findViewById(R.id.container); + mViewPager = (ViewPager) findViewById(R.id.main_content); mViewPager.setAdapter(mSectionsPagerAdapter); TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs); tabLayout.setupWithViewPager(mViewPager); - } diff --git a/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/view/WinDialog.java b/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/view/WinDialog.java index 923589f..e3645f7 100644 --- a/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/view/WinDialog.java +++ b/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/view/WinDialog.java @@ -1,11 +1,15 @@ package org.secuso.privacyfriendlysudoku.ui.view; +import android.app.AlertDialog; import android.app.Dialog; import android.content.Context; +import android.content.DialogInterface; import android.os.Bundle; import android.view.View; import android.widget.TextView; +import org.secuso.privacyfriendlysudoku.ui.listener.IResetDialogFragmentListener; + /** * Created by TMZ_LToP on 30.01.2016. */ @@ -41,8 +45,25 @@ public class WinDialog extends Dialog { if(isNewBestTime){ ((TextView)findViewById(R.id.win_new_besttime)).setVisibility(View.VISIBLE); } - } + @Override + public Bundle onSaveInstanceState() { + Bundle bundle = super.onSaveInstanceState(); + bundle.putString("hintString", hintString); + bundle.putString("timeString", timeString); + bundle.putBoolean("isNewBestTime", isNewBestTime); + return bundle; + } + @Override + public void onRestoreInstanceState(Bundle savedInstanceState) { + super.onRestoreInstanceState(savedInstanceState); + + if(savedInstanceState == null) return; + + hintString = savedInstanceState.getString("hintString"); + timeString = savedInstanceState.getString("timeString"); + isNewBestTime = savedInstanceState.getBoolean("isNewBestTime"); + } } diff --git a/app/src/main/res/drawable/nav_header.png b/app/src/main/res/drawable/nav_header.png new file mode 100644 index 0000000..1780dd4 Binary files /dev/null and b/app/src/main/res/drawable/nav_header.png differ diff --git a/app/src/main/res/layout-land/activity_about.xml b/app/src/main/res/layout-land/activity_about.xml index 37e892b..ea2259a 100644 --- a/app/src/main/res/layout-land/activity_about.xml +++ b/app/src/main/res/layout-land/activity_about.xml @@ -1,38 +1,45 @@ - + android:background="#FFFFFF"> - + android:paddingBottom="@dimen/activity_vertical_margin" + android:paddingLeft="@dimen/activity_horizontal_margin" + android:paddingRight="@dimen/activity_horizontal_margin" + android:paddingTop="@dimen/activity_vertical_margin" + android:weightSum="1" + tools:context=".AboutActivity"> - + android:layout_weight="0.36"> + + + + android:text="@string/about_author_names"/> - - - - + android:text="@string/about_author_contributors"/> @@ -100,19 +92,34 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" - android:layout_marginTop="20dp" - android:textSize="@dimen/text_size" - android:text="@string/more_info"/> + android:layout_marginTop="10dp" + android:gravity="center_horizontal" + android:text="@string/privacy_friendly" /> + android:layout_marginTop="15dp" + android:gravity="center" + android:text="@string/more_info" /> + + + + - - - - - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout-land/activity_main_menu.xml b/app/src/main/res/layout-land/activity_main_menu.xml index 354470a..34926fe 100644 --- a/app/src/main/res/layout-land/activity_main_menu.xml +++ b/app/src/main/res/layout-land/activity_main_menu.xml @@ -1,4 +1,13 @@ + + - - + android:id="@+id/main_content" + android:orientation="horizontal" + app:layout_behavior="@string/appbar_scrolling_view_behavior"> + + app:menu="@menu/menu_drawer_main" + app:headerLayout="@layout/nav_header" /> - - - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout-land/content_game_view.xml b/app/src/main/res/layout-land/content_game_view.xml index 2d6fea8..d9310a1 100644 --- a/app/src/main/res/layout-land/content_game_view.xml +++ b/app/src/main/res/layout-land/content_game_view.xml @@ -5,12 +5,12 @@ android:layoutDirection="ltr" android:layout_width="match_parent" android:layout_height="match_parent" + android:id="@+id/main_content" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" android:paddingBottom="@dimen/activity_vertical_margin" - app:layout_behavior="@string/appbar_scrolling_view_behavior" - tools:context="tu_darmstadt.sudoku.activity.GameActivity"> + app:layout_behavior="@string/appbar_scrolling_view_behavior"> + + - - + android:id="@+id/main_content" + style="?android:buttonBarStyle" + app:layout_behavior="@string/appbar_scrolling_view_behavior"> + + + app:menu="@menu/menu_drawer_main" + app:headerLayout="@layout/nav_header" /> - - - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout-xlarge-land/activity_about.xml b/app/src/main/res/layout-xlarge-land/activity_about.xml index b95f735..b0fa64b 100644 --- a/app/src/main/res/layout-xlarge-land/activity_about.xml +++ b/app/src/main/res/layout-xlarge-land/activity_about.xml @@ -1,39 +1,45 @@ - + android:background="#FFFFFF"> - + android:paddingBottom="@dimen/activity_vertical_margin" + android:paddingLeft="@dimen/activity_horizontal_margin" + android:paddingRight="@dimen/activity_horizontal_margin" + android:paddingTop="@dimen/activity_vertical_margin" + android:weightSum="1" + tools:context=".AboutActivity"> - + + + + + android:text="@string/about_author_names"/> - - - - + android:text="@string/about_author_contributors"/> @@ -102,21 +92,34 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" - android:textSize="@dimen/text_size" - android:layout_marginTop="20dp" - android:gravity="center" - android:text="@string/more_info"/> + android:layout_marginTop="10dp" + android:gravity="center_horizontal" + android:text="@string/privacy_friendly" /> + android:layout_marginTop="15dp" + android:gravity="center" + android:text="@string/more_info" /> + + + + - - - - - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout-xlarge/activity_about.xml b/app/src/main/res/layout-xlarge/activity_about.xml index 2f1bf3a..ea2259a 100644 --- a/app/src/main/res/layout-xlarge/activity_about.xml +++ b/app/src/main/res/layout-xlarge/activity_about.xml @@ -1,111 +1,142 @@ - + android:background="#FFFFFF"> - + android:background="#FFFFFF" + android:id="@+id/main_content" + android:fitsSystemWindows="true" + android:orientation="vertical" + android:paddingBottom="@dimen/activity_vertical_margin" + android:paddingLeft="@dimen/activity_horizontal_margin" + android:paddingRight="@dimen/activity_horizontal_margin" + android:paddingTop="@dimen/activity_vertical_margin" + android:weightSum="1" + tools:context=".AboutActivity"> - + - + - + - + - + - + - + - + - + - + - + - \ No newline at end of file + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout-xlarge/activity_main_menu.xml b/app/src/main/res/layout-xlarge/activity_main_menu.xml index d05adff..cb60e93 100644 --- a/app/src/main/res/layout-xlarge/activity_main_menu.xml +++ b/app/src/main/res/layout-xlarge/activity_main_menu.xml @@ -1,4 +1,13 @@ + + - - + android:id="@+id/main_content" + style="?android:buttonBarStyle" + app:layout_behavior="@string/appbar_scrolling_view_behavior"> + - -