small changes
This commit is contained in:
parent
29028c39f5
commit
48535eedd6
7 changed files with 156 additions and 74 deletions
|
@ -1,5 +1,6 @@
|
||||||
package tu_darmstadt.sudoku.ui;
|
package tu_darmstadt.sudoku.ui;
|
||||||
|
|
||||||
|
import android.app.Dialog;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
|
@ -15,11 +16,13 @@ import android.support.v4.app.FragmentManager;
|
||||||
import android.support.v4.app.FragmentPagerAdapter;
|
import android.support.v4.app.FragmentPagerAdapter;
|
||||||
import android.support.v4.view.ViewPager;
|
import android.support.v4.view.ViewPager;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.view.Gravity;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
import android.view.WindowManager;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.RatingBar;
|
import android.widget.RatingBar;
|
||||||
|
@ -124,9 +127,18 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
|
||||||
|
|
||||||
}
|
}
|
||||||
public void callFragment(View view){
|
public void callFragment(View view){
|
||||||
FragmentManager fm = getSupportFragmentManager();
|
/*FragmentManager fm = getSupportFragmentManager();
|
||||||
DialogWinScreen winScreen = new DialogWinScreen();
|
DialogWinScreen winScreen = new DialogWinScreen();
|
||||||
winScreen.show(fm,"win_screen_layout");
|
|
||||||
|
winScreen.show(fm,"win_screen_layout");*/
|
||||||
|
Dialog dialog = new Dialog(this);
|
||||||
|
//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);
|
||||||
|
dialog.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
|
|
|
@ -145,6 +145,7 @@ public class StatsActivity extends AppCompatActivity {
|
||||||
private TextView difficultyView,averageTimeView,minTimeView;
|
private TextView difficultyView,averageTimeView,minTimeView;
|
||||||
private RatingBar difficultyBarView;
|
private RatingBar difficultyBarView;
|
||||||
private String s;
|
private String s;
|
||||||
|
private int t;
|
||||||
private int totalTime =0;
|
private int totalTime =0;
|
||||||
private int totalGames =0;
|
private int totalGames =0;
|
||||||
private int totalHints =0;
|
private int totalHints =0;
|
||||||
|
@ -185,6 +186,7 @@ public class StatsActivity extends AppCompatActivity {
|
||||||
|
|
||||||
|
|
||||||
private String formatTime(int totalTime){
|
private String formatTime(int totalTime){
|
||||||
|
if (totalTime==0) return "/";
|
||||||
int seconds = totalTime % 60;
|
int seconds = totalTime % 60;
|
||||||
int minutes = ((totalTime -seconds)/60)%60 ;
|
int minutes = ((totalTime -seconds)/60)%60 ;
|
||||||
int hours = (totalTime - minutes - seconds)/(3600);
|
int hours = (totalTime - minutes - seconds)/(3600);
|
||||||
|
@ -196,9 +198,9 @@ public class StatsActivity extends AppCompatActivity {
|
||||||
|
|
||||||
}
|
}
|
||||||
private void updateGeneralIfo(int time, int games, int hints){
|
private void updateGeneralIfo(int time, int games, int hints){
|
||||||
totalHints +=hints;
|
totalHints =hints;
|
||||||
totalGames +=games;
|
totalGames =games;
|
||||||
totalTime +=time;
|
totalTime =time;
|
||||||
}
|
}
|
||||||
private void setGeneralInfo(){
|
private void setGeneralInfo(){
|
||||||
TextView generalInfoView;
|
TextView generalInfoView;
|
||||||
|
@ -237,10 +239,10 @@ public class StatsActivity extends AppCompatActivity {
|
||||||
}
|
}
|
||||||
difficultyBarView.setRating(pos+1);
|
difficultyBarView.setRating(pos+1);
|
||||||
difficultyView.setText(rootView.getResources().getString(infos.getDifficulty().getStringResID()));
|
difficultyView.setText(rootView.getResources().getString(infos.getDifficulty().getStringResID()));
|
||||||
s= (infos.getTimeNoHints() == 0)?"/":String.valueOf(infos.getTimeNoHints() / infos.getNumberOfGamesNoHints());
|
t= (infos.getTimeNoHints() == 0)?0:(infos.getTimeNoHints() / infos.getNumberOfGamesNoHints());
|
||||||
averageTimeView.setText(s);
|
averageTimeView.setText(formatTime(t));
|
||||||
s = (infos.getMinTime()==Integer.MAX_VALUE)? "/":String.valueOf(infos.getMinTime());
|
t = (infos.getMinTime()==Integer.MAX_VALUE)? 0:(infos.getMinTime());
|
||||||
minTimeView.setText(s);
|
minTimeView.setText(formatTime(t));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -6,11 +6,13 @@ import android.support.annotation.Nullable;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.view.WindowManager;
|
||||||
import android.view.animation.Animation;
|
import android.view.animation.Animation;
|
||||||
import android.view.animation.AnimationSet;
|
import android.view.animation.AnimationSet;
|
||||||
import android.view.animation.AnimationUtils;
|
import android.view.animation.AnimationUtils;
|
||||||
import android.view.animation.LinearInterpolator;
|
import android.view.animation.LinearInterpolator;
|
||||||
import android.view.animation.RotateAnimation;
|
import android.view.animation.RotateAnimation;
|
||||||
|
import android.widget.GridLayout;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
|
||||||
import tu_darmstadt.sudoku.controller.GameController;
|
import tu_darmstadt.sudoku.controller.GameController;
|
||||||
|
@ -47,8 +49,12 @@ public class DialogWinScreen extends android.support.v4.app.DialogFragment {
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
|
||||||
@Nullable Bundle savedInstanceState) {
|
@Nullable Bundle savedInstanceState) {
|
||||||
View view = inflater.inflate(R.layout.win_screen_layout,container);
|
View view = inflater.inflate(R.layout.win_screen_layout,null);
|
||||||
getDialog().getWindow().setBackgroundDrawableResource(R.drawable.ic_trophy_black_48dp);
|
|
||||||
|
// set background for the dialog window maybe just set the background to the drawable or to transparent
|
||||||
|
|
||||||
|
//getDialog().getWindow().setWindowAnimations();
|
||||||
|
//getDialog().getWindow().setAttributes(new WindowManager.LayoutParams(250,250,getDialog().getWindow().getAttributes().type,getDialog().getWindow().getAttributes().flags,getDialog().getWindow().getAttributes().format ));
|
||||||
//getDialog().getWindow().setLayout(200,250);
|
//getDialog().getWindow().setLayout(200,250);
|
||||||
//Maybe creat real animation
|
//Maybe creat real animation
|
||||||
//Animation ani = AnimationUtils.loadAnimation(this,R.anim...);
|
//Animation ani = AnimationUtils.loadAnimation(this,R.anim...);
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
<android.support.v7.widget.Toolbar android:id="@+id/toolbar"
|
<android.support.v7.widget.Toolbar android:id="@+id/toolbar"
|
||||||
android:layout_width="match_parent" android:layout_height="?attr/actionBarSize"
|
android:layout_width="match_parent" android:layout_height="?attr/actionBarSize"
|
||||||
android:background="?attr/colorPrimary" app:popupTheme="@style/AppTheme.PopupOverlay"
|
android:background="?attr/colorPrimary" app:popupTheme="@style/AppTheme.PopupOverlay"
|
||||||
app:layout_scrollFlags="scroll|enterAlways">
|
app:layout_scrollFlags="enterAlways">
|
||||||
|
|
||||||
</android.support.v7.widget.Toolbar>
|
</android.support.v7.widget.Toolbar>
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@
|
||||||
</android.support.design.widget.AppBarLayout>
|
</android.support.design.widget.AppBarLayout>
|
||||||
|
|
||||||
<android.support.v4.view.ViewPager android:id="@+id/container"
|
<android.support.v4.view.ViewPager android:id="@+id/container"
|
||||||
android:layout_width="match_parent" android:layout_height="match_parent"
|
android:layout_width="fill_parent" android:layout_height="fill_parent"
|
||||||
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
|
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,69 +1,121 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="200dp" android:layout_height="250dp"
|
android:layout_width="250dp" android:layout_height="350dp"
|
||||||
android:background="@drawable/ic_trophy_black_48dp"
|
android:orientation="vertical"
|
||||||
android:weightSum="5"
|
android:layout_gravity="center">
|
||||||
android:orientation="horizontal">
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="fill_parent"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:background="@color/transparent"
|
|
||||||
android:gravity="center">
|
|
||||||
<ImageView
|
|
||||||
android:layout_width="40dp"
|
|
||||||
android:layout_height="40dp"
|
|
||||||
android:layout_gravity="bottom"
|
|
||||||
android:background="@color/transparent"
|
|
||||||
android:src="@drawable/ic_trophy_award_black_48dp" />
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="0dp"
|
android:layout_width="250dp" android:layout_height="250dp"
|
||||||
android:layout_height="fill_parent"
|
android:background="@drawable/ic_trophy_black_48dp"
|
||||||
android:layout_weight="3"
|
android:weightSum="5"
|
||||||
android:gravity="center"
|
android:orientation="horizontal"
|
||||||
android:background="@color/transparent"
|
android:layout_gravity="center"
|
||||||
android:orientation="vertical"
|
|
||||||
>
|
>
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
<LinearLayout
|
||||||
android:layout_height="wrap_content"
|
android:layout_width="0dp"
|
||||||
android:text="@string/win_text"
|
android:layout_height="fill_parent"
|
||||||
android:textAlignment="center"
|
android:layout_weight="1"
|
||||||
android:paddingLeft="5dp"
|
android:background="@color/transparent"
|
||||||
android:paddingRight="5dp"
|
android:gravity="bottom"
|
||||||
android:textColor="@color/lightblue"/>
|
android:orientation="vertical"
|
||||||
<TextView
|
android:layout_gravity="bottom">
|
||||||
android:layout_width="wrap_content"
|
<ImageView
|
||||||
android:layout_height="wrap_content"
|
android:layout_width="40dp"
|
||||||
android:text="test2"
|
android:layout_height="40dp"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="bottom"
|
||||||
android:textColor="@color/lightblue"/>
|
android:background="@color/transparent"
|
||||||
<TextView
|
android:src="@drawable/ic_trophy_award_black_48dp" />
|
||||||
android:layout_width="wrap_content"
|
<View
|
||||||
android:layout_height="wrap_content"
|
android:layout_width="fill_parent"
|
||||||
android:text="test1"
|
android:layout_height="10dp"
|
||||||
android:textColor="@color/lightblue"
|
android:background="@color/middleblue"
|
||||||
android:layout_gravity="center"/>
|
android:layout_gravity="bottom"
|
||||||
<View
|
android:foregroundGravity="bottom"/>
|
||||||
android:layout_width="fill_parent"
|
</LinearLayout>
|
||||||
android:layout_height="10dp"
|
|
||||||
android:background="@color/middleblue"
|
<LinearLayout
|
||||||
android:layout_gravity="bottom" />
|
android:id="@+id/win_middle_linear"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="fill_parent"
|
||||||
|
android:layout_weight="3"
|
||||||
|
android:gravity="center"
|
||||||
|
android:background="@color/transparent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:weightSum="5"
|
||||||
|
>
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="100dp"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:layout_weight="4"
|
||||||
|
android:layout_marginTop="50dp"
|
||||||
|
android:orientation="vertical">
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/win_text"
|
||||||
|
android:textAlignment="center"
|
||||||
|
android:textColor="@color/white"/>
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="test2"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:textColor="@color/white"/>
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="test1"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
android:layout_gravity="center"/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:layout_weight="1">
|
||||||
|
<View
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="20dp"
|
||||||
|
android:background="@color/middleblue"
|
||||||
|
android:layout_gravity="bottom"
|
||||||
|
android:foregroundGravity="bottom"/>
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="fill_parent"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:background="@color/transparent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:gravity="bottom">
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="40dp"
|
||||||
|
android:layout_height="40dp"
|
||||||
|
android:layout_gravity="bottom"
|
||||||
|
android:src="@drawable/ic_trophy_award_black_48dp"
|
||||||
|
android:background="@color/transparent" />
|
||||||
|
<View
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="10dp"
|
||||||
|
android:background="@color/middleblue"
|
||||||
|
android:layout_gravity="bottom"
|
||||||
|
android:foregroundGravity="bottom"/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="0dp"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="fill_parent"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_gravity="center"
|
||||||
android:background="@color/transparent"
|
android:layout_marginTop="20dp">
|
||||||
android:gravity="center">
|
<Button
|
||||||
<ImageView
|
android:id="@+id/win_button"
|
||||||
android:layout_width="40dp"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="40dp"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="bottom"
|
android:background="@color/colorPrimaryDark"
|
||||||
android:src="@drawable/ic_trophy_award_black_48dp"
|
android:text="@string/win_button_text"/>
|
||||||
android:background="@color/transparent" />
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
|
@ -99,5 +99,6 @@
|
||||||
|
|
||||||
<!--### Win Strings -->
|
<!--### Win Strings -->
|
||||||
<string name="win_text">Congratulations, you have solved the puzzle.</string>
|
<string name="win_text">Congratulations, you have solved the puzzle.</string>
|
||||||
|
<string name="win_button_text">OK!</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -13,5 +13,14 @@
|
||||||
</style>
|
</style>
|
||||||
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
|
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
|
||||||
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
|
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
|
||||||
|
<style name="WinDialog" parent="@android:style/Theme.Dialog">
|
||||||
|
<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:windowContentOverlay">@null</item>
|
||||||
|
<item name="android:windowNoTitle">true</item>
|
||||||
|
<item name="android:backgroundDimEnabled">false</item>
|
||||||
|
<item name="android:windowIsFloating">false</item>
|
||||||
|
</style>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Reference in a new issue