Skip to content

Commit

Permalink
Merge pull request #124 from SecUSo/development
Browse files Browse the repository at this point in the history
Updates SDK 34
  • Loading branch information
coderPaddyS authored Jan 3, 2025
2 parents 35aaab3 + 45cbf3f commit 233f432
Show file tree
Hide file tree
Showing 46 changed files with 589 additions and 958 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
uses: actions/setup-java@v3
with:
distribution: "zulu"
java-version: 11
java-version: 17

- name: Make gradlew executable
run: chmod +x ./gradlew
Expand All @@ -37,7 +37,7 @@ jobs:
uses: actions/setup-java@v3
with:
distribution: "zulu"
java-version: 11
java-version: 17

- name: Make gradlew executable
run: chmod +x ./gradlew
Expand Down
43 changes: 37 additions & 6 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'com.google.devtools.ksp'

android {
compileSdkVersion 33
compileSdk 34
namespace "org.secuso.privacyfriendlysudoku"

testOptions {
unitTests.returnDefaultValues = true
Expand All @@ -11,25 +14,50 @@ android {
defaultConfig {
applicationId "org.secuso.privacyfriendlysudoku"
minSdkVersion 17
targetSdkVersion 33
versionCode 14
versionName "3.1.1"
targetSdkVersion 34
versionCode 15
versionName "3.1.2"
vectorDrawables.useSupportLibrary = true
multiDexEnabled = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

buildFeatures {
buildConfig true
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}

kotlinOptions {
jvmTarget = JavaVersion.VERSION_17.toString()
}

kotlin {
jvmToolchain(17)
}

android.applicationVariants.configureEach { variant ->
variant.outputs.configureEach {
def appName = "pfa-sudoku"
outputFileName = appName + "-${variant.name}-v${variant.versionName}.apk"
}
}

dataBinding {
enabled = true
}

lint {
lintConfig = file("lint.xml")
}
}

dependencies {
Expand All @@ -53,6 +81,9 @@ dependencies {
androidTestImplementation "androidx.work:work-testing:$work_version"
implementation 'androidx.sqlite:sqlite-ktx:2.3.1'

def multidexVersion = "2.0.1"
implementation("androidx.multidex:multidex:$multidexVersion")

constraints {
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.8.0") {
because("kotlin-stdlib-jdk7 is now a part of kotlin-stdlib")
Expand Down
6 changes: 6 additions & 0 deletions app/lint.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<lint>
<!-- Set the severity of missing translations to warning instead of error -->
<issue id="MissingTranslation" severity="warning" />
<issue id="MissingQuantity" severity="warning" />
</lint>
4 changes: 2 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="org.secuso.privacyfriendlysudoku.ui.view">
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
Expand Down Expand Up @@ -78,6 +77,7 @@
android:name="org.secuso.privacyfriendlysudoku.controller.GeneratorService"
android:enabled="true"
android:permission="android.permission.BIND_JOB_SERVICE"
android:foregroundServiceType="shortService"
android:exported="false" />

<service
Expand Down
11 changes: 9 additions & 2 deletions app/src/main/java/org/secuso/privacyfriendlysudoku/PFSudoku.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ package org.secuso.privacyfriendlysudoku
import android.app.Application
import android.app.NotificationChannel
import android.app.NotificationManager
import android.content.Context
import android.os.Build
import android.util.Log
import androidx.appcompat.app.AppCompatDelegate
import androidx.multidex.MultiDex
import androidx.work.Configuration
import org.secuso.privacyfriendlysudoku.backup.BackupCreator
import org.secuso.privacyfriendlysudoku.backup.BackupRestorer
Expand All @@ -41,8 +43,13 @@ class PFSudoku : Application(), Configuration.Provider {
}
}

override fun getWorkManagerConfiguration(): Configuration {
return Configuration.Builder().setMinimumLoggingLevel(Log.INFO).build()
override val workManagerConfiguration by lazy {
Configuration.Builder().setMinimumLoggingLevel(Log.INFO).build()
}

override fun attachBaseContext(base: Context) {
super.attachBaseContext(base)
MultiDex.install(this)
}

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ class BackupRestorer : IBackupRestorer {
"pref_highlight_connected",
"pref_keep_screen_on",
"pref_automatic_note_deletion",
"pref_deactivate_timer",
"pref_dark_mode_automatically_by_system" -> preferences.putBoolean(name, reader.nextBoolean())
"lastChosenDifficulty",
"pref_symbols",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@
import androidx.annotation.Nullable;
import androidx.core.app.JobIntentService;
import androidx.core.app.NotificationCompat;
import androidx.core.app.ServiceCompat;
import androidx.core.content.ContextCompat;

import android.content.pm.ServiceInfo;
import android.os.Build;
import android.util.Log;
import android.util.Pair;

Expand All @@ -36,7 +40,7 @@
import org.secuso.privacyfriendlysudoku.game.GameDifficulty;
import org.secuso.privacyfriendlysudoku.game.GameType;
import org.secuso.privacyfriendlysudoku.ui.MainActivity;
import org.secuso.privacyfriendlysudoku.ui.view.R;
import org.secuso.privacyfriendlysudoku.R;

import java.util.LinkedList;
import java.util.List;
Expand Down Expand Up @@ -273,7 +277,11 @@ private void showNotification(GameType gameType, GameDifficulty gameDifficulty)
builder.setPriority(NotificationCompat.PRIORITY_HIGH);
builder.setWhen(0);
builder.setSmallIcon(R.drawable.splash_icon);
startForeground(50, builder.build());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
ServiceCompat.startForeground(this, 50, builder.build(), ServiceInfo.FOREGROUND_SERVICE_TYPE_SHORT_SERVICE);
} else {
startForeground(50, builder.build());
}
}

static void enqueueWork(Context context, Intent intent) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,8 @@ public void add(GameController gc){
numberOfGames++;
// min time is only minTime of games without hints used
minTime = (gc.getUsedHints() == 0 && gc.getTime()< minTime) ? gc.getTime() : minTime;
numberOfGamesNoHints = (gc.getUsedHints() == 0) ? numberOfGamesNoHints + 1 : numberOfGamesNoHints;
timeNoHints = (gc.getUsedHints() == 0) ? timeNoHints + gc.getTime() : timeNoHints;

numberOfGamesNoHints = (gc.getUsedHints() == 0) ? numberOfGamesNoHints + 1 : numberOfGamesNoHints;
}
public void incHints(){
numberOfHintsUsed++;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

import java.util.LinkedList;

import org.secuso.privacyfriendlysudoku.ui.view.R;
import org.secuso.privacyfriendlysudoku.R;

/**
* Created by Chris on 18.11.2015.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

import java.util.LinkedList;

import org.secuso.privacyfriendlysudoku.ui.view.R;
import org.secuso.privacyfriendlysudoku.R;

/**
* Created by Chris on 09.11.2015.
Expand All @@ -30,6 +30,7 @@ public enum GameType implements Parcelable{
Unspecified(1,1,1,R.string.gametype_unspecified,R.drawable.icon_default_6x6),
Default_9x9(9,3,3,R.string.gametype_default_9x9,R.drawable.icon_default_9x9),
Default_12x12(12,3,4,R.string.gametype_default_12x12,R.drawable.icon_default_12x12),
Default_16x16(16,4,4,R.string.gametype_default_16x16,R.drawable.icon_default_16x16),
Default_6x6(6,2,3,R.string.gametype_default_6x6,R.drawable.icon_default_6x6),
X_9x9(9,3,3,R.string.gametype_x_9x9,R.drawable.icon_default_9x9),
Hyper_9x9(9,3,3,R.string.gametype_hyper_9x9,R.drawable.icon_default_9x9);
Expand All @@ -54,6 +55,7 @@ public static LinkedList<GameType> getValidGameTypes() {
result.add(Default_6x6);
result.add(Default_9x9);
result.add(Default_12x12);
result.add(Default_16x16);
return result;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
import android.view.MenuItem;
import android.widget.TextView;

import org.secuso.privacyfriendlysudoku.ui.view.BuildConfig;
import org.secuso.privacyfriendlysudoku.ui.view.R;
import org.secuso.privacyfriendlysudoku.BuildConfig;
import org.secuso.privacyfriendlysudoku.R;

/**
* The AboutActivity is extended by the BaseActivity and is responsible for the content of the AboutActivity.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import androidx.appcompat.app.AppCompatActivity;
import android.view.View;

import org.secuso.privacyfriendlysudoku.ui.view.R;
import org.secuso.privacyfriendlysudoku.R;

/**
* Created by Chris on 15.10.2016.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
import org.secuso.privacyfriendlysudoku.ui.listener.IFinalizeDialogFragmentListener;
import org.secuso.privacyfriendlysudoku.ui.listener.IImportDialogFragmentListener;
import org.secuso.privacyfriendlysudoku.ui.view.CreateSudokuSpecialButtonLayout;
import org.secuso.privacyfriendlysudoku.ui.view.R;
import org.secuso.privacyfriendlysudoku.R;
import org.secuso.privacyfriendlysudoku.ui.view.SudokuFieldLayout;
import org.secuso.privacyfriendlysudoku.ui.view.SudokuKeyboardLayout;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
import org.secuso.privacyfriendlysudoku.controller.qqwing.QQWing;
import org.secuso.privacyfriendlysudoku.game.GameDifficulty;
import org.secuso.privacyfriendlysudoku.game.GameType;
import org.secuso.privacyfriendlysudoku.ui.view.R;
import org.secuso.privacyfriendlysudoku.R;

import java.text.DateFormat;
import java.util.Calendar;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@
import org.secuso.privacyfriendlysudoku.ui.listener.IHintDialogFragmentListener;
import org.secuso.privacyfriendlysudoku.ui.listener.IResetDialogFragmentListener;
import org.secuso.privacyfriendlysudoku.ui.listener.IShareDialogFragmentListener;
import org.secuso.privacyfriendlysudoku.ui.view.R;
import org.secuso.privacyfriendlysudoku.R;
import org.secuso.privacyfriendlysudoku.ui.view.SudokuFieldLayout;
import org.secuso.privacyfriendlysudoku.ui.view.SudokuKeyboardLayout;
import org.secuso.privacyfriendlysudoku.ui.view.SudokuSpecialButtonLayout;
import org.secuso.privacyfriendlysudoku.ui.view.WinDialog;
import org.secuso.privacyfriendlysudoku.ui.view.databinding.DialogFragmentShareBoardBinding;
import org.secuso.privacyfriendlysudoku.databinding.DialogFragmentShareBoardBinding;


import java.util.Arrays;
Expand Down Expand Up @@ -113,6 +113,7 @@ public static String timeToString(int time) {
@Override
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);

if(gameSolved || !startGame) {
gameController.pauseTimer();
Expand All @@ -121,7 +122,9 @@ protected void onPostCreate(Bundle savedInstanceState) {
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
gameController.startTimer();
if (!sharedPref.getBoolean("pref_deactivate_timer", false)) {
gameController.startTimer();
}
}
}, MAIN_CONTENT_FADEIN_DURATION);
}
Expand Down Expand Up @@ -349,6 +352,9 @@ public void onClick(DialogInterface dialog, int id) {

//set TimerView
timerView = (TextView)findViewById(R.id.timerView);
if (sharedPref.getBoolean("pref_deactivate_timer", false)) {
timerView.setVisibility(View.GONE);
}


//set GameName
Expand Down Expand Up @@ -417,18 +423,20 @@ public void onResume(){
mainContent.animate().alpha(1).setDuration(MAIN_CONTENT_FADEOUT_DURATION);
}

SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
gameController.initTimer();

if(!gameSolved && startGame) {
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
gameController.startTimer();
if (!sharedPref.getBoolean("pref_deactivate_timer", false)) {
gameController.startTimer();
}
}
}, MAIN_CONTENT_FADEIN_DURATION);
}

SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
Symbol s;
try {
s = Symbol.valueOf(sharedPref.getString("pref_symbols", Symbol.Default.name()));
Expand Down Expand Up @@ -578,10 +586,11 @@ public void onSolved() {
editor.apply();
}

//Don't save statistics if game is custom
//Don't save statistics if game is custom or timer is deactivated
boolean isNewBestTime;
boolean saveTime = PreferenceManager.getDefaultSharedPreferences(this).getBoolean("pref_deactivate_timer", false);

if (!gameController.gameIsCustom()) {
if (!gameController.gameIsCustom() && !saveTime) {
//Show time hints new plus old best time
statistics.saveGameStats();
isNewBestTime = gameController.getUsedHints() == 0
Expand All @@ -605,9 +614,14 @@ public void onSolved() {

private WinDialog buildWinDialog(String usedTime, String usedHints, boolean isNewBestTime) {
Bundle dialogArguments = new Bundle();
dialogArguments.putString(WinDialog.ARG_TIME, usedTime);
boolean showTime = !PreferenceManager.getDefaultSharedPreferences(this).getBoolean("pref_deactivate_timer", false);
if (showTime) {
dialogArguments.putString(WinDialog.ARG_TIME, usedTime);
}
dialogArguments.putString(WinDialog.ARG_HINT, usedHints);
dialogArguments.putBoolean(WinDialog.ARG_BEST, isNewBestTime);
if (showTime) {
dialogArguments.putBoolean(WinDialog.ARG_BEST, isNewBestTime);
}

dialog = new WinDialog();
dialog.setArguments(dialogArguments);
Expand All @@ -623,7 +637,9 @@ private void disableReset(){
public void onTick(int time) {

// display the time
timerView.setText(timeToString(time));
if (!PreferenceManager.getDefaultSharedPreferences(this).getBoolean("pref_deactivate_timer", false)) {
timerView.setText(timeToString(time));
}

if(gameSolved || !startGame) return;
// save time
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import android.preference.PreferenceManager;
import android.view.MenuItem;

import org.secuso.privacyfriendlysudoku.ui.view.R;
import org.secuso.privacyfriendlysudoku.R;

/**
* A {@link PreferenceActivity} that presents a set of application settings. On
Expand Down
Loading

0 comments on commit 233f432

Please sign in to comment.