diff --git a/app/app.iml b/app/app.iml index 7932f75..0bf93b8 100644 --- a/app/app.iml +++ b/app/app.iml @@ -68,19 +68,28 @@ + + + + + + + + + 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 0000000..872e2b3 Binary files /dev/null and b/app/src/main/res/drawable/ic_star_blue_48dp.png differ diff --git a/app/src/main/res/drawable/ic_star_grey_48dp.png b/app/src/main/res/drawable/ic_star_grey_48dp.png new file mode 100644 index 0000000..991abe1 Binary files /dev/null and b/app/src/main/res/drawable/ic_star_grey_48dp.png differ diff --git a/app/src/main/res/drawable/ratingbar.xml b/app/src/main/res/drawable/ratingbar.xml index 5c66e0e..3f204ef 100644 --- a/app/src/main/res/drawable/ratingbar.xml +++ b/app/src/main/res/drawable/ratingbar.xml @@ -17,8 +17,7 @@ + android:src="@drawable/ic_star_grey_48dp"/> + android: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"/> -