From 4475d610b78cff32615b0b2d1a44e9f4e0a0d49b Mon Sep 17 00:00:00 2001 From: Gongxter Date: Thu, 18 Feb 2016 14:46:39 +0100 Subject: [PATCH] fixed some issues --- app/app.iml | 6 --- .../ui/MainActivity.java | 40 +++++++++++++++++- .../ui/view/SudokuCellView.java | 2 +- .../ui/view/SudokuFieldLayout.java | 25 +++++++---- app/src/main/res/drawable-v21/ratingbar.xml | 34 +++++++++++++++ .../main/res/drawable/ic_star_blue_48dp.png | Bin 0 -> 1218 bytes .../main/res/drawable/ic_star_grey_48dp.png | Bin 0 -> 1164 bytes app/src/main/res/drawable/ratingbar.xml | 6 +-- .../main/res/layout/activity_main_menu.xml | 8 ++-- app/src/main/res/layout/win_screen_layout.xml | 9 ++-- app/src/main/res/values-fr/strings.xml | 2 +- app/src/main/res/values/strings.xml | 6 +-- app/src/main/res/values/styles.xml | 14 ++++++ 13 files changed, 119 insertions(+), 33 deletions(-) create mode 100644 app/src/main/res/drawable-v21/ratingbar.xml create mode 100644 app/src/main/res/drawable/ic_star_blue_48dp.png create mode 100644 app/src/main/res/drawable/ic_star_grey_48dp.png diff --git a/app/app.iml b/app/app.iml index 0bf93b8..74d7e06 100644 --- a/app/app.iml +++ b/app/app.iml @@ -67,11 +67,9 @@ - - @@ -82,19 +80,15 @@ - - - - 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 ae7a9fb..96d42dc 100644 --- a/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/MainActivity.java +++ b/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/MainActivity.java @@ -1,5 +1,6 @@ package org.secuso.privacyfriendlysudoku.ui; +import android.app.Dialog; import android.content.Intent; import android.content.SharedPreferences; import android.graphics.PorterDuff; @@ -45,6 +46,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On RatingBar difficultyBar; TextView difficultyText; SharedPreferences settings; + ImageView arrowLeft, arrowRight; /** * The {@link ViewPager} that will host the section contents. @@ -88,7 +90,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On may be best to switch to a {@link android.support.v4.app.FragmentStatePagerAdapter}. */ - SectionsPagerAdapter mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); + final SectionsPagerAdapter mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. @@ -100,6 +102,31 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On String lastChosenGameType = settings.getString("lastChosenGameType", GameType.Default_9x9.name()); int index = validGameTypes.indexOf(Enum.valueOf(GameType.class, lastChosenGameType)); mViewPager.setCurrentItem(index); + arrowLeft = (ImageView)findViewById(R.id.arrow_left); + arrowRight = (ImageView) findViewById(R.id.arrow_right); + + //care for initial postiton of the ViewPager + arrowLeft.setVisibility((index==0)?View.INVISIBLE:View.VISIBLE); + arrowRight.setVisibility((index==mSectionsPagerAdapter.getCount()-1)?View.INVISIBLE:View.VISIBLE); + + //Update ViewPager on change + mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { + @Override + public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { + + } + + @Override + public void onPageSelected(int position) { + arrowLeft.setVisibility((position==0)?View.INVISIBLE:View.VISIBLE); + arrowRight.setVisibility((position==mSectionsPagerAdapter.getCount()-1)?View.INVISIBLE:View.VISIBLE); + } + + @Override + public void onPageScrollStateChanged(int state) { + } + }); + // Set the difficulty Slider to whatever was chosen the last time difficultyBar = (RatingBar)findViewById(R.id.difficultyBar); @@ -116,7 +143,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On difficultyText.setText(getString(difficultyList.get((int) ratingBar.getRating() - 1).getStringResID())); } }); - GameDifficulty lastChosenDifficulty = GameDifficulty.valueOf(settings.getString("lastChosenDifficulty", "Easy")); + GameDifficulty lastChosenDifficulty = GameDifficulty.valueOf(settings.getString("lastChosenDifficulty", "Moderate")); difficultyBar.setRating(GameDifficulty.getValidDifficultyList().indexOf(lastChosenDifficulty) + 1); /*LayerDrawable stars = (LayerDrawable)difficultyBar.getProgressDrawable(); stars.getDrawable(2).setColorFilter(getResources().getColor(R.color.colorPrimary), PorterDuff.Mode.SRC_ATOP);//Color for Stars fully selected @@ -149,6 +176,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On } + public void onClick(View view) { Intent i = null; @@ -280,6 +308,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On super(fm); } + @Override public Fragment getItem(int position) { // getItem is called to instantiate the fragment for the given page. @@ -287,6 +316,8 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On return GameTypeFragment.newInstance(position); } + + @Override public int getCount() { // Show 3 total pages. @@ -294,6 +325,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On } } + /** * A placeholder fragment containing a simple view. */ @@ -302,6 +334,8 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On * The fragment argument representing the section number for this * fragment. */ + + private static final String ARG_SECTION_NUMBER = "section_number"; /** @@ -317,8 +351,10 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On } public GameTypeFragment() { + } + @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { diff --git a/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/view/SudokuCellView.java b/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/view/SudokuCellView.java index 5558a3d..c22df6e 100644 --- a/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/view/SudokuCellView.java +++ b/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/view/SudokuCellView.java @@ -94,7 +94,7 @@ public class SudokuCellView extends View { p.setColor(Color.WHITE); break; case Error: - p.setColor(Color.RED); + p.setColor(Color.LTGRAY); break; case Selected: p.setColor(Color.GREEN); diff --git a/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/view/SudokuFieldLayout.java b/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/view/SudokuFieldLayout.java index c51c7b4..17e07ca 100644 --- a/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/view/SudokuFieldLayout.java +++ b/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/view/SudokuFieldLayout.java @@ -211,22 +211,29 @@ public class SudokuFieldLayout extends RelativeLayout implements IHighlightChang p.setStrokeWidth(4); p.setColor(Color.RED); + float offset1=0; + float offset2= 0; + int row; + int col; + int row2; + int col2; + float radius; for(CellConflict conflict : gameController.getErrorList()) { //gamecells[conflict.getRowCell1()][conflict.getColCell1()]. - int row = conflict.getRowCell1(); - int col = conflict.getColCell1(); - canvas.drawCircle(gameCellWidth * col + gameCellWidth / 2, gameCellHeight * row + gameCellHeight / 2, gameCellWidth/2 - gameCellWidth / 8, p); + row = conflict.getRowCell1(); + col = conflict.getColCell1(); + radius = gameCellWidth/2 - gameCellWidth / 8; + canvas.drawCircle(gameCellWidth * col + gameCellWidth / 2, gameCellHeight * row + gameCellHeight / 2, radius, p); + + row2 = conflict.getRowCell2(); + col2 = conflict.getColCell2(); + canvas.drawCircle(gameCellWidth * col2 + gameCellWidth / 2, gameCellHeight * row2 + gameCellHeight / 2, radius, p); + - int row2 = conflict.getRowCell2(); - int col2 = conflict.getColCell2(); - canvas.drawCircle(gameCellWidth * col2 + gameCellWidth / 2, gameCellHeight * row2 + gameCellHeight / 2, gameCellWidth / 2 - gameCellWidth / 8, p); - float offset1=0; - float offset2= 0; - float radius = gameCellWidth/2 - gameCellWidth / 8; if (col == col2 || row == row2) { offset1 = (col > col2)? 0-radius:radius; offset2 = (row > row2)? 0-radius:radius; diff --git a/app/src/main/res/drawable-v21/ratingbar.xml b/app/src/main/res/drawable-v21/ratingbar.xml new file mode 100644 index 0000000..5c66e0e --- /dev/null +++ b/app/src/main/res/drawable-v21/ratingbar.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_star_blue_48dp.png b/app/src/main/res/drawable/ic_star_blue_48dp.png new file mode 100644 index 0000000000000000000000000000000000000000..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:src="@drawable/ic_star_blue_48dp" /> diff --git a/app/src/main/res/layout/activity_main_menu.xml b/app/src/main/res/layout/activity_main_menu.xml index 900f538..175c70f 100644 --- a/app/src/main/res/layout/activity_main_menu.xml +++ b/app/src/main/res/layout/activity_main_menu.xml @@ -147,12 +147,12 @@ android:clickable="false" android:background="@drawable/standalone_button"/> -