winscreen and helppage created

This commit is contained in:
Gongxter 2016-01-30 23:20:05 +01:00
parent 1b31b5cfe2
commit c4d2999680
10 changed files with 223 additions and 63 deletions

View file

@ -67,25 +67,28 @@
<sourceFolder url="file://$MODULE_DIR$/src/test/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/debug" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/coverage-instrumented-classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/23.1.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/design/23.1.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/recyclerview-v7/23.1.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/23.1.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jacoco" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaResources" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/libs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/lint" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/mockable-android-23.jar" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/ndk" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/proguard" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/tmp" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/transforms" />
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
</content>

View file

@ -36,6 +36,7 @@ public class SaveLoadStatistics implements ITimerListener, IHintListener {
public void setGameController(GameController gc) {
this.gc = gc;
gc.registerTimerListener(this);
gc.registerHintListener(this);
}
public HighscoreInfoContainer loadStats(GameType t, GameDifficulty gd){

View file

@ -21,7 +21,9 @@ import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Gravity;
import android.view.MenuItem;
import android.view.View;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.RatingBar;
import android.widget.TextView;
import android.widget.Toast;
@ -40,6 +42,7 @@ import org.secuso.privacyfriendlysudoku.game.listener.IGameSolvedListener;
import org.secuso.privacyfriendlysudoku.game.listener.ITimerListener;
import org.secuso.privacyfriendlysudoku.ui.listener.IHintDialogFragmentListener;
import org.secuso.privacyfriendlysudoku.ui.listener.IResetDialogFragmentListener;
import org.secuso.privacyfriendlysudoku.ui.view.DialogActivity;
import org.secuso.privacyfriendlysudoku.ui.view.DialogWinScreen;
import org.secuso.privacyfriendlysudoku.ui.view.R;
import org.secuso.privacyfriendlysudoku.ui.view.SudokuFieldLayout;
@ -57,6 +60,7 @@ public class GameActivity extends AppCompatActivity implements NavigationView.On
RatingBar ratingBar;
private boolean gameSolved = false;
SaveLoadStatistics statistics = new SaveLoadStatistics(this);
DialogActivity dialog = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -238,8 +242,10 @@ public class GameActivity extends AppCompatActivity implements NavigationView.On
case R.id.menu_help:
//open about page
//intent = new Intent(this,HelpActivity.class);
//startActivity(intent);
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:
}
@ -261,25 +267,48 @@ public class GameActivity extends AppCompatActivity implements NavigationView.On
statistics.saveGameStats();
Dialog dialog = new Dialog(this);
if (gameController.getUsedHints() == 0){
if (statistics.loadStats(gameController.getGameType(),gameController.getDifficulty()).getMinTime() >= gameController.getTime()) {
// ((TextView) dialog.findViewById(R.id.win_new_besttime)).setVisibility(View.VISIBLE);
dialog = new DialogActivity(this,R.style.WinDialog,timeToString(gameController.getTime()),String.valueOf(gameController.getUsedHints()),true);
}
}else dialog = new DialogActivity(this,R.style.WinDialog,timeToString(gameController.getTime()),String.valueOf(gameController.getUsedHints()),true);
dialog.getWindow().setContentView(R.layout.win_screen_layout);
//dialog.setContentView(getLayoutInflater().inflate(R.layout.win_screen_layout,null));
dialog.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.WRAP_CONTENT);
//dialog.setContentView(R.layout.win_screen_layout);
dialog.getWindow().setGravity(Gravity.CENTER_HORIZONTAL);
dialog.getWindow().setContentView(R.layout.win_screen_layout);
dialog.getWindow().setBackgroundDrawableResource(R.color.transparent);
//((TextView)dialog.findViewById(R.id.win_hints)).setText(gameController.getUsedHints());
//((TextView)dialog.findViewById(R.id.win_time)).setText(timeToString(gameController.getTime()));
dialog.show();
final Activity activity = this;
((Button)dialog.findViewById(R.id.win_button)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dialog.dismiss();
activity.finish();
startActivity(new Intent(activity,MainActivity.class));
}
});
((Button)dialog.findViewById(R.id.win_button2)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dialog.dismiss();
}
});
layout.setEnabled(false);
keyboard.setButtonsEnabled(false);
specialButtonLayout.setButtonsEnabled(false);
}
@Override
public void onTick(int time) {
if(gameSolved) return;
//do something not so awesome
public String timeToString(int time) {
int seconds = time % 60;
int minutes = ((time -seconds)/60)%60 ;
int hours = (time - minutes - seconds)/(3600);
@ -287,7 +316,15 @@ public class GameActivity extends AppCompatActivity implements NavigationView.On
s = (seconds< 10)? "0"+String.valueOf(seconds):String.valueOf(seconds);
m = (minutes< 10)? "0"+String.valueOf(minutes):String.valueOf(minutes);
h = (hours< 10)? "0"+String.valueOf(hours):String.valueOf(hours);
timerView.setText(h + ":" + m + ":" + s);
return h + ":" + m + ":" + s;
}
@Override
public void onTick(int time) {
if(gameSolved) return;
//do something not so awesome
timerView.setText(timeToString(time));
// save time
gameController.saveGame(this);

View file

@ -184,7 +184,7 @@ public class HelpActivity extends AppCompatPreferenceActivity {
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if (id == android.R.id.home) {
startActivity(new Intent(getActivity(), SettingsActivity.class));
getActivity().finish();
return true;
}
return super.onOptionsItemSelected(item);

View file

@ -244,8 +244,10 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
case R.id.menu_help_main:
//open about page
//intent = new Intent(this,HelpActivity.class);
//startActivity(intent);
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:
}

View file

@ -0,0 +1,48 @@
package org.secuso.privacyfriendlysudoku.ui.view;
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
/**
* Created by TMZ_LToP on 30.01.2016.
*/
public class DialogActivity extends Dialog {
private String time="";
private String hints="";
private boolean newBest=false;
public DialogActivity(Context context, int themeResId) {
super(context, themeResId);
}
public DialogActivity(Context context,int themeResId,String t,String h, boolean newB) {
super(context,themeResId);
setParam(t,h,newB);
}
public void setParam(String t,String h, boolean newB){
time = t;
hints=h;
newBest=newB;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
((TextView)findViewById(R.id.win_hints)).setText(hints);
((TextView)findViewById(R.id.win_time)).setText(time);
if(newBest){
((TextView)findViewById(R.id.win_new_besttime)).setVisibility(View.VISIBLE);
}
}
}

View file

@ -1,8 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="250dp" android:layout_height="350dp"
android:layout_width="fill_parent" android:layout_height="300dp"
android:orientation="vertical"
android:layout_gravity="center">
android:background="@color/white"
android:layout_gravity="center"
>
<LinearLayout
android:layout_width="250dp" android:layout_height="250dp"
@ -49,25 +51,50 @@
android:layout_height="0dp"
android:layout_weight="4"
android:layout_marginTop="50dp"
android:layout_gravity="center_horizontal"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/win_text"
android:textAlignment="center"
android:layout_gravity="center_horizontal"
android:textColor="@color/white"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="test2"
android:text="@string/win_time"
android:layout_gravity="center"
android:textColor="@color/white"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="test1"
android:id="@+id/win_time"
android:text=""
android:textColor="@color/white"
android:layout_gravity="center"/>
android:layout_gravity="center_horizontal"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/win_hint"
android:textColor="@color/white"
android:layout_gravity="center" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/win_hints"
android:text=""
android:textColor="@color/white"
android:layout_gravity="center_horizontal"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/win_best_time"
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal"
android:visibility="invisible"
android:id="@+id/win_new_besttime"
android:textColor="@color/white"/>
</LinearLayout>
<LinearLayout
@ -106,17 +133,29 @@
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="20dp">
android:layout_marginTop="20dp"
android:weightSum="2">
<Button
android:id="@+id/win_button"
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="@color/colorPrimaryDark"
android:textColor="@color/white"
android:text="@string/win_button_text"/>
android:layout_weight="1"
android:text="@string/win_button_text"
android:layout_marginRight="5dp"/>
<Button
android:id="@+id/win_button2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="@color/colorPrimaryDark"
android:textColor="@color/white"
android:layout_weight="1"
android:text="@string/win_show_game"
android:layout_marginLeft="5dp"/>
</LinearLayout>
</LinearLayout>

View file

@ -104,6 +104,10 @@
<string name="win_text">Congratulations!</string>
<string name="win_button_text">continue</string>
<string name="title_activity_help">Help</string>
<string name="win_time">needed time:</string>
<string name="win_hint">hints used:</string>
<string name="win_show_game">Show gamefield</string>
<string name="win_best_time">New best time !</string>
<!-- Strings related to Settings -->
@ -164,4 +168,26 @@
<string name="pref_title_vibrate">Vibrate</string>
<string name="header_help">Help</string>
<!-- ### HELP prefs ###-->
<string name="pref_help_keyboard">Keyboard</string>
<string name="pref_help_gamefield">Game field</string>
<string name="pref_help_statusbar">Statusbar</string>
<string name="pref_help_keyheighlited">Key Heighlighted with black border</string>
<string name="pref_help_keyheighlited_summary">Indicates that the number is selected and will be set in every clicked field</string>
<string name="pref_help_keyheighlited_yellow">Key Heighlighted with yellow border</string>
<string name="pref_help_keyheighlited_yellow_summary">Indicates that all numbers have been set</string>
<!-- ### Special buttons description ###-->
<string name="pref_help_do">Do button</string>
<string name="pref_help_do_summary">Redoes the last action</string>
<string name="pref_help_undo">Undo button</string>
<string name="pref_help_undo_summary">Undoes the last action</string>
<string name="pref_help_hint">Hint button</string>
<string name="pref_help_hint_summary">Unveals the selected field Warning:When used the game is not appear as best in the Statistics</string>
<string name="pref_help_delete">Delete button</string>
<string name="pref_help_delete_summary">deletes a selected cell</string>
<string name="pref_help_notes">Toggle notes button</string>
<string name="pref_help_notes_summary">toggles if numbers should be set as notes or as value in a cell</string>
</resources>

View file

@ -15,15 +15,18 @@
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
<style name="WinDialog" parent="@android:style/Theme.Dialog">
<style name="WinDialog">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">@color/transparent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_width">fill_parent</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:backgroundDimEnabled">false</item>
<item name="android:windowIsFloating">false</item>
<item name="android:backgroundDimEnabled">true</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item>
<item name="android:windowSoftInputMode">adjustPan|stateUnspecified</item>
</style>
<!-- <style name="FontStyle">

View file

@ -1,40 +1,41 @@
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory android:title="@string/pref_group_game">
<SwitchPreference android:id="@+id/pref_automatic_note_deletion"
android:key="pref_automatic_note_deletion"
android:title="@string/pref_automatic_note_deletion"
android:summary="@string/pref_automatic_note_deletion_summary"
android:defaultValue="true"/>
<PreferenceCategory android:title="@string/pref_help_keyboard">
<ListPreference android:title="@string/pref_help_keyheighlited"
android:selectable="false"
android:icon="@drawable/numpad_highlighted"
android:summary="@string/pref_help_keyheighlited_summary"/>
<ListPreference android:title="@string/pref_help_keyheighlited_yellow"
android:selectable="false"
android:icon="@drawable/numpad_highlighted_three"
android:summary="@string/pref_help_keyheighlited_yellow_summary"/>
<ListPreference
android:key="pref_symbols"
android:title="@string/pref_symbols"
android:defaultValue="Default"
android:entries="@array/pref_symbols_list_titles"
android:entryValues="@array/pref_symbols_list_values"
android:negativeButtonText="@null"
android:positiveButtonText="@null" />
<ListPreference android:title="@string/pref_help_do"
android:selectable="false"
android:icon="@drawable/ic_redo_black_48dp"
android:summary="@string/pref_help_do_summary"/>
<ListPreference android:title="@string/pref_help_undo"
android:selectable="false"
android:icon="@drawable/ic_undo_black_48dp"
android:summary="@string/pref_help_undo_summary"/>
<ListPreference android:title="@string/pref_help_hint"
android:selectable="false"
android:icon="@drawable/ic_lightbulb_outline_black_48dp"
android:summary="@string/pref_help_hint_summary"/>
<ListPreference android:title="@string/pref_help_delete"
android:selectable="false"
android:icon="@drawable/ic_delete_black_24dp"
android:summary="@string/pref_help_delete_summary"/>
<ListPreference android:title="@string/pref_help_notes"
android:selectable="false"
android:icon="@drawable/ic_create_black_48dp"
android:summary="@string/pref_help_notes_summary"/>
</PreferenceCategory>
<PreferenceCategory android:title="@string/pref_group_highlight_selection">
<SwitchPreference android:id="@+id/pref_highlight_connected"
android:key="pref_highlight_connected"
android:title="@string/pref_highlight_connected"
android:summary=""
android:defaultValue="true"/>
<PreferenceCategory android:title="@string/pref_help_gamefield">
</PreferenceCategory>
<PreferenceCategory android:title="@string/pref_group_highlight_value">
<SwitchPreference android:id="@+id/pref_highlight_vals"
android:key="pref_highlight_vals"
android:title="@string/pref_highlight_vals"
android:summary=""
android:defaultValue="true"/>
<SwitchPreference android:id="@+id/pref_highlight_notes"
android:key="pref_highlight_notes"
android:title="@string/pref_highlight_notes"
android:summary=""
android:defaultValue="true"/>
<PreferenceCategory android:title="@string/pref_help_statusbar">
</PreferenceCategory>
<!-- NOTE: EditTextPreference accepts EditText attributes. -->