Skip to content

Commit

Permalink
Fixed compatibility issues with API Level <21
Browse files Browse the repository at this point in the history
  • Loading branch information
Kamuno committed Oct 6, 2020
1 parent 075da4a commit 5703e73
Show file tree
Hide file tree
Showing 53 changed files with 202 additions and 398 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,8 @@ public void onClick(DialogInterface dialog, int id) {
ratingBar.setMax(numberOfStarts);
ratingBar.setNumStars(numberOfStarts);
ratingBar.setRating(difficutyList.indexOf(gameController.getDifficulty()) + 1);
((TextView)findViewById(R.id.difficultyText)).setText(getString(gameController.getDifficulty().getStringResID()));
TextView diffText = ((TextView)findViewById(R.id.difficultyText));
diffText.setText(getString(gameController.getDifficulty().getStringResID()));


DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ public void onPageScrollStateChanged(int state) {
difficultyBar.setNumStars(difficultyList.size());
difficultyBar.setMax(difficultyList.size());
CheckBox createGameBar = (CheckBox) findViewById(R.id.circleButton);
createGameBar.setButtonDrawable(R.drawable.create_game_src);
difficultyBar.setOnRatingBarChangeListener(new RatingBar.OnRatingBarChangeListener() {
@Override
public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) {
Expand All @@ -177,16 +178,14 @@ public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser)
}
});

createGameBar.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
createGameBar.setOnClickListener(new View.OnClickListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {

difficultyBar.setRating(0);
((Button)findViewById(R.id.playButton)).setText(R.string.create_game);
}
createGameBar.setChecked(isChecked);
}});
public void onClick(View v) {
difficultyBar.setRating(0);
((Button)findViewById(R.id.playButton)).setText(R.string.create_game);
createGameBar.setChecked(true);
}
});

String retrievedDifficulty = settings.getString("lastChosenDifficulty", "Moderate");
GameDifficulty lastChosenDifficulty = GameDifficulty.valueOf(
Expand Down Expand Up @@ -320,10 +319,10 @@ private void refreshContinueButton() {
List<GameInfoContainer> gic = fm.loadGameStateInfo();
if(gic.size() > 0 && !(gic.size() == 1 && gic.get(0).getID() == GameController.DAILY_SUDOKU_ID)) {
continueButton.setEnabled(true);
continueButton.setBackgroundResource(R.drawable.standalone_button);
continueButton.setBackgroundResource(R.drawable.button_standalone);
} else {
continueButton.setEnabled(false);
continueButton.setBackgroundResource(R.drawable.inactive_button);
continueButton.setBackgroundResource(R.drawable.button_inactive);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.LinearLayout;
import android.widget.TextView;

Expand Down Expand Up @@ -212,6 +213,11 @@ public Object instantiateItem(ViewGroup container, int position) {
View view = layoutInflater.inflate(layouts[position], container, false);
container.addView(view);

CheckBox createGameBar = (CheckBox) findViewById(R.id.circleButton);
if(createGameBar != null) {
createGameBar.setButtonDrawable(R.drawable.create_game_src);
}

return view;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
Expand All @@ -33,16 +32,13 @@
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.Toast;

import androidx.core.content.ContextCompat;

import org.secuso.privacyfriendlysudoku.controller.GameController;
import org.secuso.privacyfriendlysudoku.game.listener.IHighlightChangedListener;
import org.secuso.privacyfriendlysudoku.ui.GameActivity;
import org.secuso.privacyfriendlysudoku.ui.MainActivity;
import org.secuso.privacyfriendlysudoku.ui.listener.IFinalizeDialogFragmentListener;
import org.secuso.privacyfriendlysudoku.ui.listener.IHintDialogFragmentListener;
import org.secuso.privacyfriendlysudoku.ui.listener.IImportDialogFragmentListener;

import java.util.LinkedList;
Expand Down Expand Up @@ -173,11 +169,11 @@ public void onHighlightChanged() {
switch(fixedButtons[i].getType()) {
case Undo:
fixedButtons[i].setBackgroundResource(gameController.isUndoAvailable() ?
R.drawable.numpad_highlighted_four : R.drawable.inactive_button);
R.drawable.numpad_highlighted_four : R.drawable.button_inactive);
break;
case Do:
fixedButtons[i].setBackgroundResource(gameController.isRedoAvailable() ?
R.drawable.numpad_highlighted_four : R.drawable.inactive_button);
R.drawable.numpad_highlighted_four : R.drawable.button_inactive);
break;
default:
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
Expand All @@ -39,7 +38,6 @@

import org.secuso.privacyfriendlysudoku.controller.GameController;
import org.secuso.privacyfriendlysudoku.game.listener.IHighlightChangedListener;
import org.secuso.privacyfriendlysudoku.ui.GameActivity;
import org.secuso.privacyfriendlysudoku.ui.listener.IHintDialogFragmentListener;

import java.util.LinkedList;
Expand Down Expand Up @@ -183,11 +181,11 @@ public void onHighlightChanged() {
switch(fixedButtons[i].getType()) {
case Undo:
fixedButtons[i].setBackgroundResource(gameController.isUndoAvailable() ?
R.drawable.numpad_highlighted_four : R.drawable.inactive_button);
R.drawable.numpad_highlighted_four : R.drawable.button_inactive);
break;
case Do:
fixedButtons[i].setBackgroundResource(gameController.isRedoAvailable() ?
R.drawable.numpad_highlighted_four : R.drawable.inactive_button);
R.drawable.numpad_highlighted_four : R.drawable.button_inactive);
break;
case NoteToggle:
Drawable drawable = ContextCompat.getDrawable(context, fixedButtons[i].getType().getResID());
Expand Down
11 changes: 11 additions & 0 deletions app/src/main/res/drawable-night-v21/numpad_highlighted_four.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:endColor="?attr/activeButtonColor"
android:startColor="?attr/activeButtonColor" />
<corners android:radius="6dp" />
<stroke
android:width="10px"
android:color="?attr/standardVectorGraphic" />
</shape>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions app/src/main/res/drawable-night/numpad_highlighted_four.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:endColor="@color/lightblue"
android:startColor="@color/lightblue" />
<corners android:radius="6dp" />
<stroke
android:width="10px"
android:color="@color/white" />
</shape>
10 changes: 10 additions & 0 deletions app/src/main/res/drawable-v21/ic_trophy_award_black_48dp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="192dp"
android:height="192dp"
android:viewportWidth="192"
android:viewportHeight="192">
<path
android:fillColor="?attr/standardVectorGraphic"
android:name="Color Fill 1"
android:pathData="m96 18 -15 38 -42 3 32 27 -11 41 36 -29 36 29 -11 -41 32 -27 -42 -3 -15 -38zm0 103 -8 7v25h-11l-3 1l-2 1l-2 1l-1 1l-1 1l-1 1l-1 2l-1 2l-1 4v10h64v-10l-1 -4l-1 -2l-1 -2l-1 -1l-1 -1l-1 -1l-2 -1l-2 -1l-3 -1h-11v-25l-8 -7z" />
</vector>
10 changes: 10 additions & 0 deletions app/src/main/res/drawable-v21/ic_trophy_black_48dp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="192dp"
android:height="192dp"
android:viewportWidth="192"
android:viewportHeight="192">
<path
android:fillColor="?attr/standardVectorGraphic"
android:name="Shape 1"
android:pathData="m48 32v56h-16v-56zm112 0v56h-16v-56zm-144 -16c0 0 0 1.52 0 4.13c0 15.29 0 67.88 0 67.88c0.06 0.25 0.13 0.25 0.13 0.25c0 7.53 8.9 13.72 14.75 15.45c0.1 0.03 0.2 0.06 0.3 0.09c0.11 0.03 0.22 0.06 0.32 0.08l0.5 0.12l18.22 0.02c0.01 0.07 0.02 0.14 0.03 0.21c2.48 19.1 19.25 29.53 37.76 31.8c0 4.69 0 15.96 0 16.91h-0c-12.93 2.24 -24 9.94 -24 23.06h64c-0 -13.22 -11.07 -20.9 -24 -23.09h-0v-16.92c0.05 -0.01 0.1 -0.01 0.14 -0.02c18.93 -2.45 35.9 -13.31 37.45 -32.03c0.01 -0.08 3.5 -0.1 7.48 -0.1c5.28 0 11.42 0.04 11.42 0.04c0.11 -0.03 0.21 -0.05 0.32 -0.08c5.84 -1.6 15.05 -7.88 15.05 -15.54l0.13 0.75c0 0 0 -63.25 0 -72c0 -0.65 0 -1 0 -1l-32.5 0.13c-0.11 0.03 -0.21 0.05 -0.32 0.08c-0.12 0.03 -0.25 0.07 -0.37 0.11c-5.85 1.76 -14.68 7.93 -14.68 15.43h-64.25c0 -7.66 -9.21 -13.94 -15.05 -15.54c-0.11 -0.03 -0.22 -0.06 -0.32 -0.08l-32.5 -0.13z" />
</vector>
5 changes: 5 additions & 0 deletions app/src/main/res/drawable-v21/mnenomic_numpad_button.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<gradient android:endColor="?attr/activeButtonColor" android:startColor="?attr/activeButtonColor" />
<corners android:radius="6dp" />
</shape>
11 changes: 11 additions & 0 deletions app/src/main/res/drawable-v21/numpad_highlighted.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:endColor="?attr/activeButtonColor"
android:startColor="?attr/activeButtonColor" />
<corners android:radius="6dp" />
<stroke
android:width="10px"
android:color="?attr/colorPrimaryDark" />
</shape>
11 changes: 11 additions & 0 deletions app/src/main/res/drawable-v21/numpad_highlighted_four.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:endColor="?attr/activeButtonColor"
android:startColor="?attr/activeButtonColor" />
<corners android:radius="6dp" />
<stroke
android:width="10px"
android:color="?attr/standardVectorGraphic" />
</shape>
11 changes: 11 additions & 0 deletions app/src/main/res/drawable-v21/numpad_highlighted_three.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:endColor="?attr/activeButtonColor"
android:startColor="?attr/activeButtonColor" />
<corners android:radius="6dp" />
<stroke
android:width="10px"
android:color="?attr/highlightedButtonBorder" />
</shape>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions app/src/main/res/drawable/button_inactive.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- default -->
<item>
<shape >
<solid
android:color="@color/middlegrey" />
<corners android:radius="6dp" />
</shape>
</item>
</selector>
11 changes: 11 additions & 0 deletions app/src/main/res/drawable/button_standalone.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- default -->
<item>
<shape >
<solid
android:color="@color/colorPrimary" />
<corners android:radius="6dp" />
</shape>
</item>
</selector>
10 changes: 0 additions & 10 deletions app/src/main/res/drawable/ic_star_grey_36dp.xml

This file was deleted.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion app/src/main/res/drawable/mnenomic_numpad_button.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<gradient android:endColor="?attr/activeButtonColor" android:startColor="?attr/activeButtonColor" />
<gradient android:endColor="@color/lightblue" android:startColor="@color/lightblue" />
<corners android:radius="6dp" />
</shape>
6 changes: 3 additions & 3 deletions app/src/main/res/drawable/numpad_highlighted.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:endColor="?attr/activeButtonColor"
android:startColor="?attr/activeButtonColor" />
android:endColor="@color/lightblue"
android:startColor="@color/lightblue" />
<corners android:radius="6dp" />
<stroke
android:width="10px"
android:color="?attr/colorPrimaryDark" />
android:color="@color/colorPrimaryDark" />
</shape>
6 changes: 3 additions & 3 deletions app/src/main/res/drawable/numpad_highlighted_four.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:endColor="?attr/activeButtonColor"
android:startColor="?attr/activeButtonColor" />
android:endColor="@color/lightblue"
android:startColor="@color/lightblue" />
<corners android:radius="6dp" />
<stroke
android:width="10px"
android:color="?attr/standardVectorGraphic" />
android:color="@color/black" />
</shape>
6 changes: 3 additions & 3 deletions app/src/main/res/drawable/numpad_highlighted_three.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:endColor="?attr/activeButtonColor"
android:startColor="?attr/activeButtonColor" />
android:endColor="@color/lightblue"
android:startColor="@color/lightblue" />
<corners android:radius="6dp" />
<stroke
android:width="10px"
android:color="?attr/highlightedButtonBorder" />
android:color="@color/yellow" />
</shape>
35 changes: 10 additions & 25 deletions app/src/main/res/drawable/ratingbar.xml
Original file line number Diff line number Diff line change
@@ -1,27 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2011 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background">
<bitmap
android:src="@drawable/ic_star_grey_36dp" />
</item>
<item android:id="@android:id/progress">
<bitmap
android:src="@drawable/ic_star_blue_36dp" />
</item>
</layer-list>

<item
android:id="@android:id/background"
android:drawable="@drawable/ic_star_grey_48dp" />
<item
android:id="@android:id/secondaryProgress"
android:drawable="@drawable/ic_star_half_black_48dp" />
<item
android:id="@android:id/progress"
android:drawable="@drawable/ic_star_accent_48dp" />
</layer-list>
3 changes: 2 additions & 1 deletion app/src/main/res/layout-land/activity_about.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
Expand Down Expand Up @@ -116,7 +117,7 @@
android:adjustViewBounds="true"
android:paddingEnd="50dp"
android:paddingStart="50dp"
android:src="@drawable/secuso_logo_blau_blau" />
app:srcCompat="@drawable/secuso_logo_blau_blau" />

<TextView
android:layout_width="wrap_content"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout-land/activity_daily_sudoku.xml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
android:layout_marginStart="16dp"
android:layout_marginLeft="16dp"
android:adjustViewBounds="true"
android:src="@drawable/icon_default_9x9"
app:srcCompat="@drawable/icon_default_9x9"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/view"
app:layout_constraintHorizontal_bias="0.0"
Expand Down
Loading

0 comments on commit 5703e73

Please sign in to comment.