From ea23fafd9fff637dc0b60ec645856fa0e7e3a06d Mon Sep 17 00:00:00 2001 From: Patrick Schneider Date: Sun, 16 Apr 2023 10:13:23 +0200 Subject: [PATCH 1/6] Bumps SDK-Version to 33 --- app/build.gradle | 4 ++-- app/src/main/AndroidManifest.xml | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 24fad99..47e1abf 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,12 +1,12 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 28 + compileSdkVersion 33 defaultConfig { applicationId "org.secuso.aktivpause" minSdkVersion 21 - targetSdkVersion 28 + targetSdkVersion 33 versionCode 9 versionName "1.1.2" vectorDrawables.useSupportLibrary = true diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 5548c61..573db45 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -27,7 +27,8 @@ + android:theme="@style/SplashTheme" + android:exported="true"> @@ -114,7 +115,8 @@ android:enabled="true" android:exported="false" /> - + From c7501312c131ca77f592c199a665d6f5973939ba Mon Sep 17 00:00:00 2001 From: Patrick Schneider Date: Sun, 16 Apr 2023 10:51:09 +0200 Subject: [PATCH 2/6] Updates dependencies, AGP and gradle wrapper. Migrates to AndroidX --- app/build.gradle | 30 +++++++++--------- app/src/main/AndroidManifest.xml | 3 +- .../aktivpause/activities/AboutActivity.java | 4 +-- .../activities/ChooseExerciseActivity.java | 18 +++++------ .../activities/EditExerciseSetActivity.java | 20 ++++++------ .../activities/ExerciseActivity.java | 19 ++++++------ .../ManageExerciseSetsActivity.java | 31 ++++++++++--------- .../aktivpause/activities/SplashActivity.java | 2 +- .../aktivpause/activities/TimerActivity.java | 18 +++++------ .../activities/adapter/ExerciseAdapter.java | 13 ++++---- .../adapter/ExerciseSetListAdapter.java | 4 +-- .../adapter/ExerciseSetSpinnerAdapter.java | 6 ++-- .../helper/AppCompatPreferenceActivity.java | 10 +++--- .../activities/helper/BaseActivity.java | 16 +++++----- .../tutorial/FirstLaunchManager.java | 7 +---- .../activities/tutorial/TutorialActivity.java | 8 ++--- .../aktivpause/database/SQLiteHelper.java | 2 +- .../aktivpause/database/data/Exercise.java | 2 +- .../aktivpause/dialog/ExerciseDialog.java | 6 ++-- .../exercises/ExerciseSections.java | 2 +- .../receivers/TimerSchedulerReceiver.java | 4 +-- .../aktivpause/service/TimerService.java | 4 +-- .../res/layout/activity_choose_exercise.xml | 8 ++--- .../res/layout/activity_edit_exercise_set.xml | 28 ++++++++--------- app/src/main/res/layout/activity_exercise.xml | 20 ++++++------ app/src/main/res/layout/activity_help.xml | 10 +++--- .../layout/activity_manage_exercise_set.xml | 20 ++++++------ app/src/main/res/layout/activity_settings.xml | 14 ++++----- app/src/main/res/layout/activity_timer.xml | 16 +++++----- app/src/main/res/layout/activity_tutorial.xml | 2 +- .../res/layout/dialog_add_exercise_set.xml | 10 +++--- app/src/main/res/layout/dialog_exercise.xml | 8 ++--- .../res/layout/layout_exercise_grid_item.xml | 4 +-- .../main/res/layout/layout_exercise_set.xml | 12 +++---- .../layout/layout_section_filter_button.xml | 2 +- app/src/main/res/layout/layout_toolbar.xml | 6 ++-- build.gradle | 2 +- gradle.properties | 4 ++- gradle/wrapper/gradle-wrapper.properties | 2 +- 39 files changed, 198 insertions(+), 199 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 47e1abf..d00c581 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -11,12 +11,6 @@ android { versionName "1.1.2" vectorDrawables.useSupportLibrary = true } - lintOptions { - checkReleaseBuilds false - // Or, if you prefer, you can continue to check for errors in release builds, - // but continue the build even when errors are found: - abortOnError false - } buildTypes { release { minifyEnabled false @@ -24,8 +18,13 @@ android { } } compileOptions { - sourceCompatibility JavaVersion.VERSION_1_7 - targetCompatibility JavaVersion.VERSION_1_7 + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + namespace 'org.secuso.aktivpause' + lint { + abortOnError false + checkReleaseBuilds false } } @@ -37,15 +36,16 @@ repositories { dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') - implementation 'com.android.support:appcompat-v7:28.0.0' - implementation 'com.android.support:design:28.0.0' + implementation 'androidx.appcompat:appcompat:1.4.1' + implementation 'com.google.android.material:material:1.6.0' implementation 'com.github.bumptech.glide:glide:4.9.0' - implementation 'com.android.support:support-v4:28.0.0' - implementation 'com.android.support:support-annotations:28.0.0' - implementation 'com.android.support:cardview-v7:28.0.0' - implementation 'com.android.support.constraint:constraint-layout:1.1.3' + implementation 'androidx.legacy:legacy-support-v4:1.0.0' + implementation 'androidx.annotation:annotation:1.6.0' + implementation 'androidx.cardview:cardview:1.0.0' + implementation 'androidx.constraintlayout:constraintlayout:2.1.4' implementation 'com.nex3z:flow-layout:1.0.0' implementation 'com.readystatesoftware.sqliteasset:sqliteassethelper:2.0.1' testImplementation 'junit:junit:4.12' - implementation 'com.shawnlin:number-picker:2.4.4' // https://github.com/ShawnLin013/NumberPicker + // https://github.com/ShawnLin013/NumberPicker + implementation 'com.shawnlin:number-picker:2.4.4' } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 573db45..04ecff3 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,6 +1,5 @@ - + diff --git a/app/src/main/java/org/secuso/aktivpause/activities/AboutActivity.java b/app/src/main/java/org/secuso/aktivpause/activities/AboutActivity.java index 8bff426..cea9e8b 100644 --- a/app/src/main/java/org/secuso/aktivpause/activities/AboutActivity.java +++ b/app/src/main/java/org/secuso/aktivpause/activities/AboutActivity.java @@ -2,8 +2,8 @@ import android.os.Bundle; import android.os.Handler; -import android.support.v7.app.ActionBar; -import android.support.v7.app.AppCompatActivity; +import androidx.appcompat.app.ActionBar; +import androidx.appcompat.app.AppCompatActivity; import android.text.method.LinkMovementMethod; import android.view.MenuItem; import android.view.View; diff --git a/app/src/main/java/org/secuso/aktivpause/activities/ChooseExerciseActivity.java b/app/src/main/java/org/secuso/aktivpause/activities/ChooseExerciseActivity.java index b35e59a..ba9c52f 100644 --- a/app/src/main/java/org/secuso/aktivpause/activities/ChooseExerciseActivity.java +++ b/app/src/main/java/org/secuso/aktivpause/activities/ChooseExerciseActivity.java @@ -2,16 +2,16 @@ import android.content.Intent; import android.os.PersistableBundle; -import android.support.annotation.Nullable; -import android.support.design.chip.Chip; -import android.support.design.chip.ChipGroup; -import android.support.v4.content.ContextCompat; -import android.support.v7.app.ActionBar; -import android.support.v7.app.AppCompatActivity; +import androidx.annotation.Nullable; +import com.google.android.material.chip.Chip; +import com.google.android.material.chip.ChipGroup; +import androidx.core.content.ContextCompat; +import androidx.appcompat.app.ActionBar; +import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; -import android.support.v7.widget.CardView; -import android.support.v7.widget.GridLayoutManager; -import android.support.v7.widget.RecyclerView; +import androidx.cardview.widget.CardView; +import androidx.recyclerview.widget.GridLayoutManager; +import androidx.recyclerview.widget.RecyclerView; import android.view.MenuItem; import android.view.View; import android.widget.TextView; diff --git a/app/src/main/java/org/secuso/aktivpause/activities/EditExerciseSetActivity.java b/app/src/main/java/org/secuso/aktivpause/activities/EditExerciseSetActivity.java index dd3504a..e1ac051 100644 --- a/app/src/main/java/org/secuso/aktivpause/activities/EditExerciseSetActivity.java +++ b/app/src/main/java/org/secuso/aktivpause/activities/EditExerciseSetActivity.java @@ -4,15 +4,17 @@ import android.animation.AnimatorListenerAdapter; import android.content.DialogInterface; import android.content.Intent; -import android.support.v4.content.AsyncTaskLoader; -import android.support.v4.content.Loader; -import android.support.v7.app.ActionBar; -import android.support.v7.app.AlertDialog; -import android.support.v7.app.AppCompatActivity; + +import androidx.loader.app.LoaderManager; +import androidx.loader.content.AsyncTaskLoader; +import androidx.loader.content.Loader; +import androidx.appcompat.app.ActionBar; +import androidx.appcompat.app.AlertDialog; +import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; -import android.support.v7.widget.GridLayoutManager; -import android.support.v7.widget.RecyclerView; -import android.support.v7.widget.Toolbar; +import androidx.recyclerview.widget.GridLayoutManager; +import androidx.recyclerview.widget.RecyclerView; +import androidx.appcompat.widget.Toolbar; import android.text.Editable; import android.text.TextUtils; import android.text.TextWatcher; @@ -44,7 +46,7 @@ * @version 2.0 * @see ChooseExerciseActivity */ -public class EditExerciseSetActivity extends AppCompatActivity implements android.support.v4.app.LoaderManager.LoaderCallbacks { +public class EditExerciseSetActivity extends AppCompatActivity implements LoaderManager.LoaderCallbacks { private static final String TAG = EditExerciseSetActivity.class.getSimpleName(); diff --git a/app/src/main/java/org/secuso/aktivpause/activities/ExerciseActivity.java b/app/src/main/java/org/secuso/aktivpause/activities/ExerciseActivity.java index 431f89e..f15ce1e 100644 --- a/app/src/main/java/org/secuso/aktivpause/activities/ExerciseActivity.java +++ b/app/src/main/java/org/secuso/aktivpause/activities/ExerciseActivity.java @@ -15,14 +15,15 @@ import android.os.VibrationEffect; import android.os.Vibrator; import android.preference.PreferenceManager; -import android.support.constraint.ConstraintLayout; -import android.support.v4.app.ActivityCompat; -import android.support.v4.content.AsyncTaskLoader; -import android.support.v4.content.Loader; -import android.support.v4.view.MenuItemCompat; -import android.support.v7.app.ActionBar; -import android.support.v7.app.AlertDialog; -import android.support.v7.app.AppCompatActivity; +import androidx.constraintlayout.widget.ConstraintLayout; +import androidx.core.app.ActivityCompat; +import androidx.loader.app.LoaderManager; +import androidx.loader.content.AsyncTaskLoader; +import androidx.loader.content.Loader; +import androidx.core.view.MenuItemCompat; +import androidx.appcompat.app.ActionBar; +import androidx.appcompat.app.AlertDialog; +import androidx.appcompat.app.AppCompatActivity; import android.view.Menu; import android.view.MenuItem; import android.view.View; @@ -58,7 +59,7 @@ * @author Christopher Beckmann * @version 2.0 */ -public class ExerciseActivity extends AppCompatActivity implements android.support.v4.app.LoaderManager.LoaderCallbacks { +public class ExerciseActivity extends AppCompatActivity implements LoaderManager.LoaderCallbacks { private static final String TAG = ExerciseActivity.class.getSimpleName(); private static boolean confirmationDialogShown = false; diff --git a/app/src/main/java/org/secuso/aktivpause/activities/ManageExerciseSetsActivity.java b/app/src/main/java/org/secuso/aktivpause/activities/ManageExerciseSetsActivity.java index 446d93d..1ab162a 100644 --- a/app/src/main/java/org/secuso/aktivpause/activities/ManageExerciseSetsActivity.java +++ b/app/src/main/java/org/secuso/aktivpause/activities/ManageExerciseSetsActivity.java @@ -8,21 +8,22 @@ import android.content.Intent; import android.content.res.ColorStateList; import android.graphics.drawable.ColorDrawable; -import android.support.annotation.NonNull; -import android.support.design.widget.FloatingActionButton; -import android.support.design.widget.TextInputEditText; -import android.support.v4.app.ActivityCompat; -import android.support.v4.app.DialogFragment; -import android.support.v4.app.FragmentActivity; -import android.support.v4.content.AsyncTaskLoader; -import android.support.v4.content.ContextCompat; -import android.support.v4.content.Loader; -import android.support.v4.widget.DrawerLayout; -import android.support.v7.app.ActionBar; -import android.support.v7.app.AlertDialog; +import androidx.annotation.NonNull; +import com.google.android.material.floatingactionbutton.FloatingActionButton; +import com.google.android.material.textfield.TextInputEditText; +import androidx.core.app.ActivityCompat; +import androidx.fragment.app.DialogFragment; +import androidx.fragment.app.FragmentActivity; +import androidx.loader.app.LoaderManager; +import androidx.loader.content.AsyncTaskLoader; +import androidx.core.content.ContextCompat; +import androidx.loader.content.Loader; +import androidx.drawerlayout.widget.DrawerLayout; +import androidx.appcompat.app.ActionBar; +import androidx.appcompat.app.AlertDialog; import android.os.Bundle; -import android.support.v7.widget.LinearLayoutManager; -import android.support.v7.widget.RecyclerView; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; import android.text.TextUtils; import android.util.Log; import android.view.LayoutInflater; @@ -54,7 +55,7 @@ * @version 2.0 * @see EditExerciseSetActivity */ -public class ManageExerciseSetsActivity extends BaseActivity implements android.support.v4.app.LoaderManager.LoaderCallbacks> { +public class ManageExerciseSetsActivity extends BaseActivity implements LoaderManager.LoaderCallbacks> { private static final String TAG = ManageExerciseSetsActivity.class.getSimpleName(); private RecyclerView exerciseSetList; diff --git a/app/src/main/java/org/secuso/aktivpause/activities/SplashActivity.java b/app/src/main/java/org/secuso/aktivpause/activities/SplashActivity.java index 9b20d6f..d3b6dce 100644 --- a/app/src/main/java/org/secuso/aktivpause/activities/SplashActivity.java +++ b/app/src/main/java/org/secuso/aktivpause/activities/SplashActivity.java @@ -2,7 +2,7 @@ import android.content.Intent; import android.os.Bundle; -import android.support.v7.app.AppCompatActivity; +import androidx.appcompat.app.AppCompatActivity; import org.secuso.aktivpause.activities.tutorial.FirstLaunchManager; import org.secuso.aktivpause.activities.tutorial.TutorialActivity; diff --git a/app/src/main/java/org/secuso/aktivpause/activities/TimerActivity.java b/app/src/main/java/org/secuso/aktivpause/activities/TimerActivity.java index 88c8718..6d28457 100644 --- a/app/src/main/java/org/secuso/aktivpause/activities/TimerActivity.java +++ b/app/src/main/java/org/secuso/aktivpause/activities/TimerActivity.java @@ -12,17 +12,17 @@ import android.net.Uri; import android.os.IBinder; import android.preference.PreferenceManager; -import android.support.annotation.NonNull; -import android.support.constraint.ConstraintLayout; -import android.support.constraint.ConstraintSet; -import android.support.v4.app.ActivityCompat; -import android.support.v4.content.AsyncTaskLoader; -import android.support.v4.content.Loader; +import androidx.annotation.NonNull; +import androidx.constraintlayout.widget.ConstraintLayout; +import androidx.constraintlayout.widget.ConstraintSet; +import androidx.core.app.ActivityCompat; +import androidx.loader.app.LoaderManager; +import androidx.loader.content.AsyncTaskLoader; +import androidx.loader.content.Loader; import android.os.Bundle; -import android.support.v7.app.AlertDialog; +import androidx.appcompat.app.AlertDialog; import android.transition.TransitionManager; import android.view.Menu; -import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; import android.widget.AdapterView; @@ -58,7 +58,7 @@ * @version 2.0 * @see TimerService */ -public class TimerActivity extends BaseActivity implements android.support.v4.app.LoaderManager.LoaderCallbacks> { +public class TimerActivity extends BaseActivity implements LoaderManager.LoaderCallbacks> { private static final String TAG = TimerActivity.class.getSimpleName(); // UI diff --git a/app/src/main/java/org/secuso/aktivpause/activities/adapter/ExerciseAdapter.java b/app/src/main/java/org/secuso/aktivpause/activities/adapter/ExerciseAdapter.java index 755f5ca..44a40f5 100644 --- a/app/src/main/java/org/secuso/aktivpause/activities/adapter/ExerciseAdapter.java +++ b/app/src/main/java/org/secuso/aktivpause/activities/adapter/ExerciseAdapter.java @@ -2,12 +2,12 @@ import android.content.Context; import android.graphics.drawable.Drawable; -import android.preference.PreferenceManager; -import android.support.annotation.NonNull; -import android.support.constraint.ConstraintLayout; -import android.support.v4.app.ActivityCompat; -import android.support.v7.util.SortedList; -import android.support.v7.widget.RecyclerView; + +import androidx.annotation.NonNull; +import androidx.constraintlayout.widget.ConstraintLayout; +import androidx.core.app.ActivityCompat; +import androidx.recyclerview.widget.SortedList; +import androidx.recyclerview.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -20,7 +20,6 @@ import org.secuso.aktivpause.R; import org.secuso.aktivpause.activities.helper.IExerciseTimeUpdateable; -import org.secuso.aktivpause.activities.tutorial.FirstLaunchManager; import org.secuso.aktivpause.database.data.Exercise; import org.secuso.aktivpause.dialog.ExerciseDialog; diff --git a/app/src/main/java/org/secuso/aktivpause/activities/adapter/ExerciseSetListAdapter.java b/app/src/main/java/org/secuso/aktivpause/activities/adapter/ExerciseSetListAdapter.java index 345fa95..fc496b9 100644 --- a/app/src/main/java/org/secuso/aktivpause/activities/adapter/ExerciseSetListAdapter.java +++ b/app/src/main/java/org/secuso/aktivpause/activities/adapter/ExerciseSetListAdapter.java @@ -2,8 +2,8 @@ import android.content.Intent; import android.preference.PreferenceManager; -import android.support.v7.widget.CardView; -import android.support.v7.widget.RecyclerView; +import androidx.cardview.widget.CardView; +import androidx.recyclerview.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; diff --git a/app/src/main/java/org/secuso/aktivpause/activities/adapter/ExerciseSetSpinnerAdapter.java b/app/src/main/java/org/secuso/aktivpause/activities/adapter/ExerciseSetSpinnerAdapter.java index aca1836..ea7a14b 100644 --- a/app/src/main/java/org/secuso/aktivpause/activities/adapter/ExerciseSetSpinnerAdapter.java +++ b/app/src/main/java/org/secuso/aktivpause/activities/adapter/ExerciseSetSpinnerAdapter.java @@ -2,9 +2,9 @@ import android.content.Context; import android.preference.PreferenceManager; -import android.support.annotation.LayoutRes; -import android.support.annotation.NonNull; -import android.support.v7.widget.CardView; +import androidx.annotation.LayoutRes; +import androidx.annotation.NonNull; +import androidx.cardview.widget.CardView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; diff --git a/app/src/main/java/org/secuso/aktivpause/activities/helper/AppCompatPreferenceActivity.java b/app/src/main/java/org/secuso/aktivpause/activities/helper/AppCompatPreferenceActivity.java index 2e7a68c..944171f 100644 --- a/app/src/main/java/org/secuso/aktivpause/activities/helper/AppCompatPreferenceActivity.java +++ b/app/src/main/java/org/secuso/aktivpause/activities/helper/AppCompatPreferenceActivity.java @@ -3,11 +3,11 @@ import android.content.res.Configuration; import android.os.Bundle; import android.preference.PreferenceActivity; -import android.support.annotation.LayoutRes; -import android.support.annotation.Nullable; -import android.support.v7.app.ActionBar; -import android.support.v7.app.AppCompatDelegate; -import android.support.v7.widget.Toolbar; +import androidx.annotation.LayoutRes; +import androidx.annotation.Nullable; +import androidx.appcompat.app.ActionBar; +import androidx.appcompat.app.AppCompatDelegate; +import androidx.appcompat.widget.Toolbar; import android.view.MenuInflater; import android.view.View; import android.view.ViewGroup; diff --git a/app/src/main/java/org/secuso/aktivpause/activities/helper/BaseActivity.java b/app/src/main/java/org/secuso/aktivpause/activities/helper/BaseActivity.java index 4177693..8dc07e6 100644 --- a/app/src/main/java/org/secuso/aktivpause/activities/helper/BaseActivity.java +++ b/app/src/main/java/org/secuso/aktivpause/activities/helper/BaseActivity.java @@ -5,14 +5,14 @@ import android.os.Bundle; import android.os.Handler; import android.preference.PreferenceManager; -import android.support.design.widget.NavigationView; -import android.support.design.widget.NavigationView.OnNavigationItemSelectedListener; -import android.support.v4.app.TaskStackBuilder; -import android.support.v4.view.GravityCompat; -import android.support.v4.widget.DrawerLayout; -import android.support.v7.app.ActionBarDrawerToggle; -import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.Toolbar; +import com.google.android.material.navigation.NavigationView; +import com.google.android.material.navigation.NavigationView.OnNavigationItemSelectedListener; +import androidx.core.app.TaskStackBuilder; +import androidx.core.view.GravityCompat; +import androidx.drawerlayout.widget.DrawerLayout; +import androidx.appcompat.app.ActionBarDrawerToggle; +import androidx.appcompat.app.AppCompatActivity; +import androidx.appcompat.widget.Toolbar; import android.view.MenuItem; import android.view.View; diff --git a/app/src/main/java/org/secuso/aktivpause/activities/tutorial/FirstLaunchManager.java b/app/src/main/java/org/secuso/aktivpause/activities/tutorial/FirstLaunchManager.java index c5e770e..17f29ea 100644 --- a/app/src/main/java/org/secuso/aktivpause/activities/tutorial/FirstLaunchManager.java +++ b/app/src/main/java/org/secuso/aktivpause/activities/tutorial/FirstLaunchManager.java @@ -5,19 +5,14 @@ import android.app.NotificationManager; import android.content.Context; import android.content.SharedPreferences; -import android.database.Cursor; import android.os.Build; import android.preference.PreferenceManager; -import android.support.annotation.RequiresApi; +import androidx.annotation.RequiresApi; -import org.secuso.aktivpause.R; import org.secuso.aktivpause.database.SQLiteHelper; -import org.secuso.aktivpause.database.columns.ExerciseSetColumns; -import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; -import java.util.List; /** * Class structure taken from tutorial at http://www.androidhive.info/2016/05/android-build-intro-slider-app/ diff --git a/app/src/main/java/org/secuso/aktivpause/activities/tutorial/TutorialActivity.java b/app/src/main/java/org/secuso/aktivpause/activities/tutorial/TutorialActivity.java index c0451b5..6cad83f 100644 --- a/app/src/main/java/org/secuso/aktivpause/activities/tutorial/TutorialActivity.java +++ b/app/src/main/java/org/secuso/aktivpause/activities/tutorial/TutorialActivity.java @@ -5,10 +5,10 @@ import android.graphics.Color; import android.os.Build; import android.os.Bundle; -import android.support.v4.content.ContextCompat; -import android.support.v4.view.PagerAdapter; -import android.support.v4.view.ViewPager; -import android.support.v7.app.AppCompatActivity; +import androidx.core.content.ContextCompat; +import androidx.viewpager.widget.PagerAdapter; +import androidx.viewpager.widget.ViewPager; +import androidx.appcompat.app.AppCompatActivity; import android.text.Html; import android.view.LayoutInflater; import android.view.View; diff --git a/app/src/main/java/org/secuso/aktivpause/database/SQLiteHelper.java b/app/src/main/java/org/secuso/aktivpause/database/SQLiteHelper.java index d5e45e6..2073690 100644 --- a/app/src/main/java/org/secuso/aktivpause/database/SQLiteHelper.java +++ b/app/src/main/java/org/secuso/aktivpause/database/SQLiteHelper.java @@ -5,7 +5,7 @@ import android.content.Context; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; -import android.support.annotation.NonNull; +import androidx.annotation.NonNull; import com.readystatesoftware.sqliteasset.SQLiteAssetHelper; diff --git a/app/src/main/java/org/secuso/aktivpause/database/data/Exercise.java b/app/src/main/java/org/secuso/aktivpause/database/data/Exercise.java index 3c48425..236c24d 100644 --- a/app/src/main/java/org/secuso/aktivpause/database/data/Exercise.java +++ b/app/src/main/java/org/secuso/aktivpause/database/data/Exercise.java @@ -2,7 +2,7 @@ import android.content.Context; -import android.support.annotation.DrawableRes; +import androidx.annotation.DrawableRes; import org.secuso.aktivpause.exercises.ExerciseSections; diff --git a/app/src/main/java/org/secuso/aktivpause/dialog/ExerciseDialog.java b/app/src/main/java/org/secuso/aktivpause/dialog/ExerciseDialog.java index 8251a8b..0c06d75 100644 --- a/app/src/main/java/org/secuso/aktivpause/dialog/ExerciseDialog.java +++ b/app/src/main/java/org/secuso/aktivpause/dialog/ExerciseDialog.java @@ -2,9 +2,9 @@ import android.content.Context; import android.content.DialogInterface; -import android.support.annotation.NonNull; -import android.support.v4.app.FragmentActivity; -import android.support.v7.app.AlertDialog; +import androidx.annotation.NonNull; +import androidx.fragment.app.FragmentActivity; +import androidx.appcompat.app.AlertDialog; import android.view.LayoutInflater; import android.view.View; import android.widget.ImageView; diff --git a/app/src/main/java/org/secuso/aktivpause/exercises/ExerciseSections.java b/app/src/main/java/org/secuso/aktivpause/exercises/ExerciseSections.java index 7cec142..ac1fe34 100644 --- a/app/src/main/java/org/secuso/aktivpause/exercises/ExerciseSections.java +++ b/app/src/main/java/org/secuso/aktivpause/exercises/ExerciseSections.java @@ -1,7 +1,7 @@ package org.secuso.aktivpause.exercises; import android.content.Context; -import android.support.annotation.StringRes; +import androidx.annotation.StringRes; import org.secuso.aktivpause.R; diff --git a/app/src/main/java/org/secuso/aktivpause/receivers/TimerSchedulerReceiver.java b/app/src/main/java/org/secuso/aktivpause/receivers/TimerSchedulerReceiver.java index 4ce3279..2ec053d 100644 --- a/app/src/main/java/org/secuso/aktivpause/receivers/TimerSchedulerReceiver.java +++ b/app/src/main/java/org/secuso/aktivpause/receivers/TimerSchedulerReceiver.java @@ -10,8 +10,8 @@ import android.os.Build; import android.os.IBinder; import android.preference.PreferenceManager; -import android.support.annotation.NonNull; -import android.support.v4.content.WakefulBroadcastReceiver; +import androidx.annotation.NonNull; +import androidx.legacy.content.WakefulBroadcastReceiver; import org.secuso.aktivpause.service.TimerService; diff --git a/app/src/main/java/org/secuso/aktivpause/service/TimerService.java b/app/src/main/java/org/secuso/aktivpause/service/TimerService.java index fff70b7..f502325 100644 --- a/app/src/main/java/org/secuso/aktivpause/service/TimerService.java +++ b/app/src/main/java/org/secuso/aktivpause/service/TimerService.java @@ -14,8 +14,8 @@ import android.os.IBinder; import android.preference.PreferenceManager; import android.provider.Settings; -import android.support.v4.app.NotificationCompat; -import android.support.v4.content.ContextCompat; +import androidx.core.app.NotificationCompat; +import androidx.core.content.ContextCompat; import org.secuso.aktivpause.R; import org.secuso.aktivpause.activities.ExerciseActivity; diff --git a/app/src/main/res/layout/activity_choose_exercise.xml b/app/src/main/res/layout/activity_choose_exercise.xml index 466943d..46f2c68 100644 --- a/app/src/main/res/layout/activity_choose_exercise.xml +++ b/app/src/main/res/layout/activity_choose_exercise.xml @@ -1,5 +1,5 @@ - - - - + diff --git a/app/src/main/res/layout/activity_edit_exercise_set.xml b/app/src/main/res/layout/activity_edit_exercise_set.xml index 4ab2d4a..009b6a8 100644 --- a/app/src/main/res/layout/activity_edit_exercise_set.xml +++ b/app/src/main/res/layout/activity_edit_exercise_set.xml @@ -1,28 +1,28 @@ - - - - - @@ -63,17 +63,17 @@ app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toTopOf="parent" /> - + - + - - - + - + - - + - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_exercise.xml b/app/src/main/res/layout/activity_exercise.xml index 157adf9..56344ed 100644 --- a/app/src/main/res/layout/activity_exercise.xml +++ b/app/src/main/res/layout/activity_exercise.xml @@ -1,5 +1,5 @@ - - - - + - - + - + - - + - + diff --git a/app/src/main/res/layout/activity_help.xml b/app/src/main/res/layout/activity_help.xml index 985f85a..55aa23d 100644 --- a/app/src/main/res/layout/activity_help.xml +++ b/app/src/main/res/layout/activity_help.xml @@ -1,5 +1,5 @@ - - - + - - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_manage_exercise_set.xml b/app/src/main/res/layout/activity_manage_exercise_set.xml index c8d4530..050a5af 100644 --- a/app/src/main/res/layout/activity_manage_exercise_set.xml +++ b/app/src/main/res/layout/activity_manage_exercise_set.xml @@ -1,5 +1,5 @@ - - - - - + - + - - + - - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml index 006b4d0..41235bd 100644 --- a/app/src/main/res/layout/activity_settings.xml +++ b/app/src/main/res/layout/activity_settings.xml @@ -1,5 +1,5 @@ - - - - + - + - - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_timer.xml b/app/src/main/res/layout/activity_timer.xml index d2ba8e8..c0aa811 100644 --- a/app/src/main/res/layout/activity_timer.xml +++ b/app/src/main/res/layout/activity_timer.xml @@ -1,5 +1,5 @@ - - - - - + - + - - + diff --git a/app/src/main/res/layout/activity_tutorial.xml b/app/src/main/res/layout/activity_tutorial.xml index 6a58d17..a5b4c85 100644 --- a/app/src/main/res/layout/activity_tutorial.xml +++ b/app/src/main/res/layout/activity_tutorial.xml @@ -6,7 +6,7 @@ android:layout_height="match_parent" tools:showIn="@layout/activity_tutorial"> - diff --git a/app/src/main/res/layout/dialog_add_exercise_set.xml b/app/src/main/res/layout/dialog_add_exercise_set.xml index 2b2366e..9c12f22 100644 --- a/app/src/main/res/layout/dialog_add_exercise_set.xml +++ b/app/src/main/res/layout/dialog_add_exercise_set.xml @@ -1,5 +1,5 @@ - - - - + - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_exercise.xml b/app/src/main/res/layout/dialog_exercise.xml index 747b5dd..761df08 100644 --- a/app/src/main/res/layout/dialog_exercise.xml +++ b/app/src/main/res/layout/dialog_exercise.xml @@ -1,5 +1,5 @@ - - - + - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout/layout_exercise_grid_item.xml b/app/src/main/res/layout/layout_exercise_grid_item.xml index d03b7be..9629a18 100644 --- a/app/src/main/res/layout/layout_exercise_grid_item.xml +++ b/app/src/main/res/layout/layout_exercise_grid_item.xml @@ -1,5 +1,5 @@ - - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout/layout_exercise_set.xml b/app/src/main/res/layout/layout_exercise_set.xml index a92bac8..9c5671e 100644 --- a/app/src/main/res/layout/layout_exercise_set.xml +++ b/app/src/main/res/layout/layout_exercise_set.xml @@ -1,5 +1,5 @@ - - - @@ -117,7 +117,7 @@ - - + + - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout/layout_section_filter_button.xml b/app/src/main/res/layout/layout_section_filter_button.xml index 9d29f88..96b849f 100644 --- a/app/src/main/res/layout/layout_section_filter_button.xml +++ b/app/src/main/res/layout/layout_section_filter_button.xml @@ -1,5 +1,5 @@ - - - - \ No newline at end of file + \ No newline at end of file diff --git a/build.gradle b/build.gradle index 3cd0732..05020b3 100644 --- a/build.gradle +++ b/build.gradle @@ -10,7 +10,7 @@ buildscript { google() } dependencies { - classpath 'com.android.tools.build:gradle:3.5.1' + classpath 'com.android.tools.build:gradle:7.4.2' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/gradle.properties b/gradle.properties index 1d3591c..915f0e6 100644 --- a/gradle.properties +++ b/gradle.properties @@ -15,4 +15,6 @@ # When configured, Gradle will run in incubating parallel mode. # This option should only be used with decoupled projects. More details, visit # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects -# org.gradle.parallel=true \ No newline at end of file +# org.gradle.parallel=true +android.enableJetifier=true +android.useAndroidX=true \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 41e4c54..9f48037 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip From 8da8afed49f10958f458abd114af5f3fff1b911e Mon Sep 17 00:00:00 2001 From: Patrick Schneider Date: Sun, 16 Apr 2023 10:59:30 +0200 Subject: [PATCH 3/6] Fixes app due to dependency upgrades --- app/src/main/AndroidManifest.xml | 4 ++++ .../aktivpause/service/TimerService.java | 18 +++++++-------- .../res/drawable-v21/ic_sync_black_24dp.xml | 2 +- .../main/res/drawable/ic_sync_black_24dp.xml | 2 +- app/src/main/res/layout/activity_exercise.xml | 22 +++++++++---------- app/src/main/res/layout/activity_timer.xml | 8 +++---- .../res/layout/layout_exercise_grid_item.xml | 2 +- .../main/res/layout/layout_exercise_set.xml | 4 ++-- 8 files changed, 33 insertions(+), 29 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 04ecff3..897603e 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,6 +1,10 @@ + + + + diff --git a/app/src/main/java/org/secuso/aktivpause/service/TimerService.java b/app/src/main/java/org/secuso/aktivpause/service/TimerService.java index f502325..f42aa08 100644 --- a/app/src/main/java/org/secuso/aktivpause/service/TimerService.java +++ b/app/src/main/java/org/secuso/aktivpause/service/TimerService.java @@ -105,8 +105,8 @@ private void onTimerDone() { Intent exerciseIntent = new Intent(this, ExerciseActivity.class); exerciseIntent.putExtra("SCHEDULED", scheduled); - PendingIntent startExercises = PendingIntent.getActivity(this, 0, exerciseIntent, FLAG_CANCEL_CURRENT); - PendingIntent snoozeExercise = PendingIntent.getService(this, 0, snoozeIntent, FLAG_UPDATE_CURRENT); + PendingIntent startExercises = PendingIntent.getActivity(this, 0, exerciseIntent, FLAG_CANCEL_CURRENT | PendingIntent.FLAG_IMMUTABLE); + PendingIntent snoozeExercise = PendingIntent.getService(this, 0, snoozeIntent, FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE); NotificationCompat.Builder builder = new NotificationCompat.Builder(this, "timer_done"); builder.setContentTitle(getString(R.string.app_name)) @@ -122,11 +122,11 @@ private void onTimerDone() { .setVibrate(new long[] { 0, 1000, 1000, 1000, 1000, 1000, 1000 }) .setSound(Settings.System.DEFAULT_NOTIFICATION_URI) .setOnlyAlertOnce(false) - .setDeleteIntent(PendingIntent.getBroadcast(getApplicationContext(), 0, new Intent(ACTION_NOTIFICATION_DELETED), FLAG_UPDATE_CURRENT)); + .setDeleteIntent(PendingIntent.getBroadcast(getApplicationContext(), 0, new Intent(ACTION_NOTIFICATION_DELETED), FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE)); SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this); if(pref.getBoolean(PREF_EXERCISE_CONTINUOUS, false)) { - builder.addAction(0, getString(R.string.dismiss_and_dont_repeat), PendingIntent.getBroadcast(getApplicationContext(), 0, new Intent(ACTION_NOTIFICATION_CANCELED), FLAG_UPDATE_CURRENT)); + builder.addAction(0, getString(R.string.dismiss_and_dont_repeat), PendingIntent.getBroadcast(getApplicationContext(), 0, new Intent(ACTION_NOTIFICATION_CANCELED), FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE)); } builder.addAction(R.drawable.ic_replay_black_48dp, getString(R.string.snooze), snoozeExercise); @@ -327,7 +327,7 @@ private Notification buildNotification() { Intent exerciseIntent = new Intent(this, ExerciseActivity.class); exerciseIntent.putExtra("SCHEDULED", scheduled); - PendingIntent startExercises = PendingIntent.getActivity(this, 0, exerciseIntent, FLAG_CANCEL_CURRENT); + PendingIntent startExercises = PendingIntent.getActivity(this, 0, exerciseIntent, FLAG_CANCEL_CURRENT | PendingIntent.FLAG_IMMUTABLE); builder.setContentText(time); builder.setColor(ContextCompat.getColor(this, R.color.colorAccent)); @@ -341,21 +341,21 @@ private Notification buildNotification() { Intent intent = new Intent(this, TimerActivity.class); intent.addFlags(FLAG_ACTIVITY_CLEAR_TOP); - builder.setContentIntent(PendingIntent.getActivity(this, 0, intent, FLAG_UPDATE_CURRENT)); + builder.setContentIntent(PendingIntent.getActivity(this, 0, intent, FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE)); builder.addAction(R.drawable.ic_play_arrow_black, getString(R.string.start_break), startExercises); Intent stopIntent = new Intent(this, TimerService.class); stopIntent.setAction(ACTION_STOP_TIMER); - builder.addAction(R.drawable.ic_replay_black_48dp, getString(R.string.stop), PendingIntent.getService(this, 0, stopIntent, FLAG_UPDATE_CURRENT)); + builder.addAction(R.drawable.ic_replay_black_48dp, getString(R.string.stop), PendingIntent.getService(this, 0, stopIntent, FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE)); Intent pauseIntent = new Intent(this, TimerService.class); if(!isPaused()) { pauseIntent.setAction(ACTION_PAUSE_TIMER); - builder.addAction(R.drawable.ic_pause_black_48dp, getString(R.string.pause), PendingIntent.getService(this, 0, pauseIntent, FLAG_UPDATE_CURRENT)); + builder.addAction(R.drawable.ic_pause_black_48dp, getString(R.string.pause), PendingIntent.getService(this, 0, pauseIntent, FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE)); } else { pauseIntent.setAction(ACTION_RESUME_TIMER); - builder.addAction(R.drawable.ic_play_arrow_black, getString(R.string.resume), PendingIntent.getService(this, 0, pauseIntent, FLAG_UPDATE_CURRENT)); + builder.addAction(R.drawable.ic_play_arrow_black, getString(R.string.resume), PendingIntent.getService(this, 0, pauseIntent, FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE)); } return builder.build(); diff --git a/app/src/main/res/drawable-v21/ic_sync_black_24dp.xml b/app/src/main/res/drawable-v21/ic_sync_black_24dp.xml index 5a283aa..2aef437 100644 --- a/app/src/main/res/drawable-v21/ic_sync_black_24dp.xml +++ b/app/src/main/res/drawable-v21/ic_sync_black_24dp.xml @@ -5,5 +5,5 @@ android:viewportWidth="24.0"> + android:pathData="M12 4V1L8 5l4 4V6c3.31 0 6 2.69 6 6 0 1.01,-0.25 1.97,-0.7 2.8l1.46 1.46C19.54 15.03 20 13.57 20 12c0,-4.42,-3.58,-8,-8,-8zm0 14c-3.31 0,-6,-2.69,-6,-6 0,-1.01 0.25,-1.97 0.7,-2.8L5.24 7.74C4.46 8.97 4 10.43 4 12c0 4.42 3.58 8 8 8v3l4,-4,-4,-4v3z" /> \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_sync_black_24dp.xml b/app/src/main/res/drawable/ic_sync_black_24dp.xml index 5a283aa..2aef437 100644 --- a/app/src/main/res/drawable/ic_sync_black_24dp.xml +++ b/app/src/main/res/drawable/ic_sync_black_24dp.xml @@ -5,5 +5,5 @@ android:viewportWidth="24.0"> + android:pathData="M12 4V1L8 5l4 4V6c3.31 0 6 2.69 6 6 0 1.01,-0.25 1.97,-0.7 2.8l1.46 1.46C19.54 15.03 20 13.57 20 12c0,-4.42,-3.58,-8,-8,-8zm0 14c-3.31 0,-6,-2.69,-6,-6 0,-1.01 0.25,-1.97 0.7,-2.8L5.24 7.74C4.46 8.97 4 10.43 4 12c0 4.42 3.58 8 8 8v3l4,-4,-4,-4v3z" /> \ No newline at end of file diff --git a/app/src/main/res/layout/activity_exercise.xml b/app/src/main/res/layout/activity_exercise.xml index 56344ed..c9a3337 100644 --- a/app/src/main/res/layout/activity_exercise.xml +++ b/app/src/main/res/layout/activity_exercise.xml @@ -20,11 +20,11 @@ android:hapticFeedbackEnabled="true" android:onClick="onClick" android:scaleType="fitXY" - android:tint="@color/colorPrimary" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" - app:srcCompat="@drawable/ic_play_arrow_black" /> + app:srcCompat="@drawable/ic_play_arrow_black" + app:tint="@color/colorPrimary" /> + app:layout_constraintHorizontal_bias="0.6666" + app:tint="@color/colorPrimary" /> + app:layout_constraintHorizontal_bias="0.3333" + app:tint="@color/colorPrimary" /> + app:srcCompat="@drawable/ic_repeat_black_48dp" + app:tint="@color/middlegrey" /> + app:srcCompat="@drawable/ic_update_black_40dp" + app:tint="@color/middlegrey" /> + app:tint="@color/black" /> diff --git a/app/src/main/res/layout/activity_timer.xml b/app/src/main/res/layout/activity_timer.xml index c0aa811..88259b4 100644 --- a/app/src/main/res/layout/activity_timer.xml +++ b/app/src/main/res/layout/activity_timer.xml @@ -288,11 +288,11 @@ android:background="?android:selectableItemBackgroundBorderless" android:hapticFeedbackEnabled="true" android:onClick="onClick" - android:tint="@color/darkblue" android:visibility="invisible" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintHorizontal_bias="0.5" - app:srcCompat="@drawable/ic_replay_black_48dp" /> + app:srcCompat="@drawable/ic_replay_black_48dp" + app:tint="@color/darkblue" /> + app:srcCompat="@drawable/ic_play_arrow_black" + app:tint="@color/darkblue" /> diff --git a/app/src/main/res/layout/layout_exercise_grid_item.xml b/app/src/main/res/layout/layout_exercise_grid_item.xml index 9629a18..d2e118f 100644 --- a/app/src/main/res/layout/layout_exercise_grid_item.xml +++ b/app/src/main/res/layout/layout_exercise_grid_item.xml @@ -35,7 +35,7 @@ app:layout_constraintRight_toRightOf="@+id/exercise_image" app:layout_constraintTop_toTopOf="@+id/exercise_image" app:srcCompat="@drawable/ic_about" - android:tint="@color/black"/> + app:tint="@color/black" /> + app:srcCompat="@drawable/ic_mode_edit_black_24dp" + app:tint="@color/colorAccent" /> Date: Mon, 17 Apr 2023 22:19:33 +0200 Subject: [PATCH 4/6] Adds backup nearly functional --- .gitmodules | 3 + app/build.gradle | 19 +++ app/src/main/AndroidManifest.xml | 20 ++- .../org/secuso/aktivpause/PFAktivpause.kt | 21 +++ .../secuso/aktivpause/backup/BackupCreator.kt | 55 +++++++ .../aktivpause/backup/BackupRestorer.kt | 142 ++++++++++++++++++ .../aktivpause/backup/PFABackupService.kt | 5 + .../aktivpause/database/SQLiteHelper.java | 2 +- app/src/main/res/layout/activity_settings.xml | 2 +- build.gradle | 3 + gradlew | 0 libs/privacy-friendly-backup-api | 1 + settings.gradle | 2 + 13 files changed, 272 insertions(+), 3 deletions(-) create mode 100644 .gitmodules create mode 100644 app/src/main/java/org/secuso/aktivpause/PFAktivpause.kt create mode 100644 app/src/main/java/org/secuso/aktivpause/backup/BackupCreator.kt create mode 100644 app/src/main/java/org/secuso/aktivpause/backup/BackupRestorer.kt create mode 100644 app/src/main/java/org/secuso/aktivpause/backup/PFABackupService.kt mode change 100644 => 100755 gradlew create mode 160000 libs/privacy-friendly-backup-api diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..5fb4a5c --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "libs/privacy-friendly-backup-api"] + path = libs/privacy-friendly-backup-api + url = https://github.com/SecUSo/privacy-friendly-backup-api.git diff --git a/app/build.gradle b/app/build.gradle index d00c581..24ca532 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,4 +1,6 @@ apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' + android { compileSdkVersion 33 @@ -48,4 +50,21 @@ dependencies { testImplementation 'junit:junit:4.12' // https://github.com/ShawnLin013/NumberPicker implementation 'com.shawnlin:number-picker:2.4.4' + + // Backup + implementation project(path: ':backup-api') + def work_version = "2.4.0" + implementation "androidx.work:work-runtime:$work_version" + implementation "androidx.work:work-runtime-ktx:$work_version" + androidTestImplementation "androidx.work:work-testing:$work_version" + implementation 'androidx.sqlite:sqlite-ktx:2.3.1' + + constraints { + implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.8.0") { + because("kotlin-stdlib-jdk7 is now a part of kotlin-stdlib") + } + implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.0") { + because("kotlin-stdlib-jdk8 is now a part of kotlin-stdlib") + } + } } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 897603e..9707c46 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,5 +1,7 @@ - + @@ -11,6 +13,7 @@ + + + + + @@ -127,6 +140,11 @@ + + \ No newline at end of file diff --git a/app/src/main/java/org/secuso/aktivpause/PFAktivpause.kt b/app/src/main/java/org/secuso/aktivpause/PFAktivpause.kt new file mode 100644 index 0000000..05b7dd9 --- /dev/null +++ b/app/src/main/java/org/secuso/aktivpause/PFAktivpause.kt @@ -0,0 +1,21 @@ +package org.secuso.aktivpause + +import android.app.Application +import android.util.Log +import androidx.work.Configuration +import org.secuso.privacyfriendlybackup.api.pfa.BackupManager +import org.secuso.aktivpause.backup.BackupCreator +import org.secuso.aktivpause.backup.BackupRestorer + +class PFAktivpause : Application(), Configuration.Provider { + + override fun onCreate() { + super.onCreate() + BackupManager.backupCreator = BackupCreator() + BackupManager.backupRestorer = BackupRestorer() + } + + override fun getWorkManagerConfiguration(): Configuration { + return Configuration.Builder().setMinimumLoggingLevel(Log.INFO).build() + } +} \ No newline at end of file diff --git a/app/src/main/java/org/secuso/aktivpause/backup/BackupCreator.kt b/app/src/main/java/org/secuso/aktivpause/backup/BackupCreator.kt new file mode 100644 index 0000000..d97a765 --- /dev/null +++ b/app/src/main/java/org/secuso/aktivpause/backup/BackupCreator.kt @@ -0,0 +1,55 @@ +package org.secuso.aktivpause.backup + + +import android.content.Context +import android.preference.PreferenceManager +import android.util.JsonWriter +import android.util.Log +import org.secuso.privacyfriendlybackup.api.backup.DatabaseUtil.getSupportSQLiteOpenHelper +import org.secuso.privacyfriendlybackup.api.backup.DatabaseUtil.writeDatabase +import org.secuso.privacyfriendlybackup.api.backup.PreferenceUtil.writePreferences +import org.secuso.privacyfriendlybackup.api.pfa.IBackupCreator +import org.secuso.aktivpause.database.SQLiteHelper +import java.io.OutputStream +import java.io.OutputStreamWriter + +class BackupCreator : IBackupCreator { + override fun writeBackup(context: Context, outputStream: OutputStream): Boolean { + Log.d(TAG, "createBackup() started") + val outputStreamWriter = OutputStreamWriter(outputStream, Charsets.UTF_8) + val writer = JsonWriter(outputStreamWriter) + writer.setIndent("") + + try { + writer.beginObject() + + Log.d(TAG, "Writing database") + writer.name("database") + + val database = getSupportSQLiteOpenHelper(context, SQLiteHelper.DATABASE_NAME).readableDatabase + + writeDatabase(writer, database) + database.close() + + Log.d(TAG, "Writing preferences") + writer.name("preferences") + + val pref = PreferenceManager.getDefaultSharedPreferences(context.applicationContext) + writePreferences(writer, pref) + + writer.endObject() + writer.close() + } catch (e: Exception) { + Log.e(TAG, "Error occurred", e) + e.printStackTrace() + return false + } + + Log.d(TAG, "Backup created successfully") + return true + } + + companion object { + const val TAG = "PFABackupCreator" + } +} \ No newline at end of file diff --git a/app/src/main/java/org/secuso/aktivpause/backup/BackupRestorer.kt b/app/src/main/java/org/secuso/aktivpause/backup/BackupRestorer.kt new file mode 100644 index 0000000..1a950b6 --- /dev/null +++ b/app/src/main/java/org/secuso/aktivpause/backup/BackupRestorer.kt @@ -0,0 +1,142 @@ +package org.secuso.aktivpause.backup + +import android.content.Context +import android.content.SharedPreferences +import android.preference.PreferenceManager +import android.util.JsonReader +import android.util.Log +import androidx.annotation.NonNull +import org.secuso.privacyfriendlybackup.api.backup.DatabaseUtil +import org.secuso.privacyfriendlybackup.api.backup.FileUtil +import org.secuso.privacyfriendlybackup.api.pfa.IBackupRestorer +import org.secuso.aktivpause.database.SQLiteHelper +import java.io.IOException +import java.io.InputStream +import java.io.InputStreamReader +import kotlin.system.exitProcess + + +class BackupRestorer : IBackupRestorer { + @Throws(IOException::class) + private fun readDatabase(reader: JsonReader, context: Context) { + reader.beginObject() + val n1: String = reader.nextName() + if (n1 != "version") { + throw RuntimeException("Unknown value $n1") + } + val version: Int = reader.nextInt() + val n2: String = reader.nextName() + if (n2 != "content") { + throw RuntimeException("Unknown value $n2") + } + + Log.d(TAG, "Restoring database...") + val restoreDatabaseName = "restoreDatabase" + + // delete if file already exists + val restoreDatabaseFile = context.getDatabasePath(restoreDatabaseName) + if (restoreDatabaseFile.exists()) { + DatabaseUtil.deleteRoomDatabase(context, restoreDatabaseName) + } + + // create new restore database + val db = DatabaseUtil.getSupportSQLiteOpenHelper(context, restoreDatabaseName, version).writableDatabase + + db.beginTransaction() + db.version = version + + Log.d(TAG, "Copying database contents...") + DatabaseUtil.readDatabaseContent(reader, db) + Log.d(TAG, "succesfully read database") + db.setTransactionSuccessful() + db.endTransaction() + db.close() + + reader.endObject() + + // copy file to correct location + val actualDatabaseFile = context.getDatabasePath(SQLiteHelper.DATABASE_NAME) + + DatabaseUtil.deleteRoomDatabase(context, SQLiteHelper.DATABASE_NAME) + + FileUtil.copyFile(restoreDatabaseFile, actualDatabaseFile) + Log.d(TAG, "Database Restored") + + // delete restore database + DatabaseUtil.deleteRoomDatabase(context, restoreDatabaseName) + } + + @Throws(IOException::class) + private fun readPreferences(reader: JsonReader, preferences: SharedPreferences.Editor) { + reader.beginObject() + while (reader.hasNext()) { + val name: String = reader.nextName() + Log.d("preference", name) + when (name) { + "pref_schedule_exercise", + "pref_keep_screen_on_during_exercise", + "REPEAT_STATUS", + "pref_hide_default_exercise_sets", + "pref_schedule_exercise_daystrigger", + "pref_exercise_continuous", + "IsFirstTimeLaunch", + "pref_schedule_random_exercise", + "REPEAT_EXERCISES" -> preferences.putBoolean(name, reader.nextBoolean()) + "pref_exercise_time" -> preferences.putString(name, reader.nextString()) + "FirstLaunchManager.PREF_PICKER_SECONDS", + "FirstLaunchManager.PREF_PICKER_Minutes", + "FirstLaunchManager.PREF_BREAK_PICKER_SECONDS", + "FirstLaunchManager.PREF_PICKER_HOURS", + "FirstLaunchManager.PREF_BREAK_PICKER_MINUTES" -> preferences.putInt(name, reader.nextInt()) + "pref_schedule_exercise_days" -> preferences.putStringSet(name, readPreferenceSet(reader)) + "WORK_TIME", + "PAUSE TIME", + "pref_schedule_exercise_time", + "DEFAULT_EXERCISE_SET" -> preferences.putLong(name, reader.nextLong()) + else -> throw RuntimeException("Unknown preference $name") + } + } + reader.endObject() + } + + private fun readPreferenceSet(reader: JsonReader): Set { + val preferenceSet = mutableSetOf() + + reader.beginArray() + while (reader.hasNext()) { + preferenceSet.add(reader.nextString()); + } + reader.endArray() + return preferenceSet + } + + override fun restoreBackup(context: Context, restoreData: InputStream): Boolean { + return try { + val isReader = InputStreamReader(restoreData) + val reader = JsonReader(isReader) + val preferences = PreferenceManager.getDefaultSharedPreferences(context).edit() + + // START + reader.beginObject() + while (reader.hasNext()) { + val type: String = reader.nextName() + when (type) { + "database" -> readDatabase(reader, context) + "preferences" -> readPreferences(reader, preferences) + else -> throw RuntimeException("Can not parse type $type") + } + } + reader.endObject() + preferences.commit() + + exitProcess(0) + } catch (e: Exception) { + e.printStackTrace() + false + } + } + + companion object { + const val TAG = "PFABackupRestorer" + } +} \ No newline at end of file diff --git a/app/src/main/java/org/secuso/aktivpause/backup/PFABackupService.kt b/app/src/main/java/org/secuso/aktivpause/backup/PFABackupService.kt new file mode 100644 index 0000000..7d9a17f --- /dev/null +++ b/app/src/main/java/org/secuso/aktivpause/backup/PFABackupService.kt @@ -0,0 +1,5 @@ +package org.secuso.aktivpause.backup + +import org.secuso.privacyfriendlybackup.api.pfa.PFAAuthService + +class PFABackupService : PFAAuthService() \ No newline at end of file diff --git a/app/src/main/java/org/secuso/aktivpause/database/SQLiteHelper.java b/app/src/main/java/org/secuso/aktivpause/database/SQLiteHelper.java index 2073690..ac61554 100644 --- a/app/src/main/java/org/secuso/aktivpause/database/SQLiteHelper.java +++ b/app/src/main/java/org/secuso/aktivpause/database/SQLiteHelper.java @@ -27,7 +27,7 @@ public class SQLiteHelper extends SQLiteAssetHelper { private static final String TAG = SQLiteHelper.class.getSimpleName(); - private static final String DATABASE_NAME = "exercises.sqlite"; + public static final String DATABASE_NAME = "exercises.sqlite"; private static final int DATABASE_VERSION = 1; private static final String[] deleteQueryList = { diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml index 41235bd..e2cc9ab 100644 --- a/app/src/main/res/layout/activity_settings.xml +++ b/app/src/main/res/layout/activity_settings.xml @@ -1,4 +1,4 @@ - +?xml version="1.0" encoding="utf-8"?> Date: Wed, 3 May 2023 21:58:28 +0200 Subject: [PATCH 5/6] bugfixes --- .../main/java/org/secuso/aktivpause/backup/BackupRestorer.kt | 2 +- app/src/main/res/layout/activity_settings.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/secuso/aktivpause/backup/BackupRestorer.kt b/app/src/main/java/org/secuso/aktivpause/backup/BackupRestorer.kt index 1a950b6..9723526 100644 --- a/app/src/main/java/org/secuso/aktivpause/backup/BackupRestorer.kt +++ b/app/src/main/java/org/secuso/aktivpause/backup/BackupRestorer.kt @@ -84,7 +84,7 @@ class BackupRestorer : IBackupRestorer { "REPEAT_EXERCISES" -> preferences.putBoolean(name, reader.nextBoolean()) "pref_exercise_time" -> preferences.putString(name, reader.nextString()) "FirstLaunchManager.PREF_PICKER_SECONDS", - "FirstLaunchManager.PREF_PICKER_Minutes", + "FirstLaunchManager.PREF_PICKER_MINUTES", "FirstLaunchManager.PREF_BREAK_PICKER_SECONDS", "FirstLaunchManager.PREF_PICKER_HOURS", "FirstLaunchManager.PREF_BREAK_PICKER_MINUTES" -> preferences.putInt(name, reader.nextInt()) diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml index e2cc9ab..41235bd 100644 --- a/app/src/main/res/layout/activity_settings.xml +++ b/app/src/main/res/layout/activity_settings.xml @@ -1,4 +1,4 @@ -?xml version="1.0" encoding="utf-8"?> + Date: Wed, 24 May 2023 23:34:38 +0200 Subject: [PATCH 6/6] Update gradle --- gradle/wrapper/gradle-wrapper.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 9f48037..b32f7f6 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Sat Sep 28 18:54:52 CEST 2019 +#Wed May 24 23:28:16 CEST 2023 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip