Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pfa core integration #55

Open
wants to merge 39 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
f9a0fc9
[pfa-core] adds library.
coderPaddyS Oct 28, 2024
4ba49e9
[pfa-core] matches AGP and gradlew to match pfa-core.
coderPaddyS Oct 28, 2024
c5be5a7
[pfa-core] Adds PFApplicationData and adapts application class.
coderPaddyS Oct 28, 2024
524e83d
[pfa-core] Adds settings to PFApplicationData
coderPaddyS Oct 28, 2024
8474471
[pfa-core] Adds tutorial, help and about to PFApplicationData.
coderPaddyS Oct 28, 2024
3a2e193
[pfa-core] Removes old activities.
coderPaddyS Oct 28, 2024
5dd99f3
Rename .java to .kt
coderPaddyS Oct 28, 2024
4803191
[refactor] Converts BaseActivity to kotlin.
coderPaddyS Oct 28, 2024
99186fc
[pfa-core] Adapts BaseActivity to use PFA-Core.
coderPaddyS Oct 28, 2024
d6abe3b
Rename .java to .kt
coderPaddyS Oct 28, 2024
96bb840
[refactor] Converts MainActivity to kotlin.
coderPaddyS Oct 28, 2024
398bc30
[pfa-core] Refactors MainActivity to use PFA-Core. Adds additional pr…
coderPaddyS Oct 28, 2024
d8722de
Rename .java to .kt
coderPaddyS Oct 29, 2024
612a60d
[refactor] Converts StatsActivity to kotlin.
coderPaddyS Oct 29, 2024
dea188b
[pfa-core] Adapts StatsActivity to library. Refactors code.
coderPaddyS Oct 29, 2024
1d815fd
[pfa-core] Removes old layout files. Fixes tutorial images.
coderPaddyS Oct 29, 2024
009c462
[pfa-core] Updates PFA-Core and adds database backup config.
coderPaddyS Nov 7, 2024
11b2482
[pfa-core] Removes old backup.
coderPaddyS Nov 7, 2024
5bd95ef
[fix] fixes duplicate strings.
coderPaddyS Nov 7, 2024
50bccf9
[fix] strings consistent.
coderPaddyS Dec 20, 2024
ec28e17
[fix] fixes StatsActivity.kt
coderPaddyS Dec 20, 2024
a2afcd6
[refactor] improves stats.
coderPaddyS Dec 20, 2024
37c425c
[feat] adds preference. readds support for S-Pen.
coderPaddyS Dec 20, 2024
b95f204
[refactor] removes dead code.
coderPaddyS Dec 20, 2024
48e37c8
[fix] drawer name and icon.
coderPaddyS Dec 20, 2024
9433beb
[fix] sets workManagerConfiguration correctly.
coderPaddyS Dec 20, 2024
38c04f9
[update] updates to latest pfa-core.
coderPaddyS Jan 8, 2025
5f8559d
[chore] removes old backup-api submodule.
coderPaddyS Jan 8, 2025
722404c
[fix] reduces grid animation artifacts.
coderPaddyS Jan 8, 2025
27296c0
[fix] pager shows correct page.
coderPaddyS Jan 8, 2025
fc2e961
[fix] fixes saving/loading from empty game state.
coderPaddyS Jan 8, 2025
97ef499
[fix] fixes randomized fill test IndexOutOfBounds.
coderPaddyS Jan 8, 2025
1d8fe55
[fix] fixes animation to be smooth and as expected.
coderPaddyS Jan 8, 2025
843df04
[feat] adds option to enable multiple undos.
coderPaddyS Jan 8, 2025
87d03ad
[chore] updates to latest pfa-core
coderPaddyS Jan 9, 2025
f67f9c1
[fix] fixes animations
coderPaddyS Jan 9, 2025
a35a019
[fix] fixes reset button
coderPaddyS Jan 9, 2025
fe6face
[fix] loading game state from file.
coderPaddyS Jan 9, 2025
5ea3bdb
[fix] checkout correct pfa-core version.
coderPaddyS Jan 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "libs/privacy-friendly-backup-api"]
path = libs/privacy-friendly-backup-api
url = https://github.com/SecUSo/privacy-friendly-backup-api.git
[submodule "libs/pfa-core"]
path = libs/pfa-core
url = https://github.com/SecUSo/pfa-core.git
7 changes: 5 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,12 @@ dependencies {
annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'
implementation 'androidx.activity:activity-ktx:1.9.3'

// pfa-core library
implementation("org.secuso.pfa-core:ui-view")
implementation("org.secuso.pfa-core:model")

// Backup
implementation project(path: ':backup-api')
def work_version = "2.9.1"
def work_version = "2.9.0"
implementation "androidx.work:work-runtime:$work_version"
implementation "androidx.work:work-runtime-ktx:$work_version"
androidTestImplementation "androidx.work:work-testing:$work_version"
Expand Down
60 changes: 3 additions & 57 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,57 +16,14 @@
android:label="@string/app_name"
android:supportsRtl="true"
android:name=".PF2048"
android:theme="@style/AppTheme">
<activity
android:exported="true"
android:name=".activities.SplashActivity"
android:theme="@style/SplashTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".activities.TutorialActivity"
android:theme="@style/AppTheme.NoActionBar">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="org.secuso.privacyfriendly2048.activities.MainActivity" />
</activity>
android:theme="@style/PrivacyFriendlyCoreTheme">
<activity
android:name=".activities.MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar" />
<activity
android:name=".activities.AboutActivity"
android:label="@string/about"
android:parentActivityName=".activities.MainActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="org.secuso.privacyfriendly2048.activities.MainActivity" />
</activity>
<activity
android:name=".activities.HelpActivity"
android:label="@string/help"
android:parentActivityName=".activities.MainActivity"
android:theme="@style/AppTheme.NoActionBar">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="org.secuso.privacyfriendly2048.activities.MainActivity" />
</activity>
android:theme="@style/PrivacyFriendlyCoreTheme.NoActionBar" />
<activity
android:name="org.secuso.privacyfriendly2048.activities.StatsActivity"
android:theme="@style/AppTheme.NoActionBar">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="org.secuso.privacyfriendly2048.activities.MainActivity" />
</activity>
<activity
android:name=".activities.SettingsActivity"
android:label="@string/settings_name"
android:parentActivityName=".activities.MainActivity"
android:theme="@style/AppTheme.NoActionBar">
android:theme="@style/PrivacyFriendlyCoreTheme.NoActionBar">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="org.secuso.privacyfriendly2048.activities.MainActivity" />
Expand All @@ -87,17 +44,6 @@
android:value="org.secuso.privacyfriendly2048.activities.MainActivity" />
</activity>

<service
android:name="org.secuso.privacyfriendly2048.backup.PFABackupService"
android:enabled="true"
android:exported="true"
android:process=":backup"
tools:ignore="ExportedService">
<intent-filter>
<action android:name="org.secuso.privacyfriendlybackup.api.pfa.PFAAuthService" />
</intent-filter>
</service>

<provider
android:name="androidx.startup.InitializationProvider"
android:authorities="${applicationId}.androidx-startup"
Expand Down
49 changes: 19 additions & 30 deletions app/src/main/java/org/secuso/privacyfriendly2048/PF2048.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,36 +16,25 @@
*/
package org.secuso.privacyfriendly2048

import android.app.Application
import android.preference.PreferenceManager
import android.util.Log
import androidx.appcompat.app.AppCompatDelegate
import androidx.core.content.ContextCompat
import androidx.work.Configuration
import org.secuso.privacyfriendly2048.backup.BackupCreator
import org.secuso.privacyfriendly2048.backup.BackupRestorer
import org.secuso.privacyfriendlybackup.api.pfa.BackupManager

class PF2048 : Application(), Configuration.Provider {
override fun onCreate() {
super.onCreate()
BackupManager.backupCreator = BackupCreator()
BackupManager.backupRestorer = BackupRestorer()

when (PreferenceManager.getDefaultSharedPreferences(applicationContext)
.getString("currentTheme", "system")) {
"dark" -> {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES)
}

"light" -> {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO)
}

else -> {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM)
}
}
}

override val workManagerConfiguration = Configuration.Builder().setMinimumLoggingLevel(Log.INFO).build()
import org.secuso.pfacore.application.BackupDatabaseConfig
import org.secuso.pfacore.application.SQLiteHelperConfig
import org.secuso.pfacore.ui.PFApplication
import org.secuso.pfacore.ui.PFData
import org.secuso.privacyfriendly2048.activities.MainActivity
import org.secuso.privacyfriendly2048.database.PFASQLiteHelper

class PF2048 : PFApplication() {
override val name: String
get() = ContextCompat.getString(this, R.string.app_name_long)
override val data: PFData
get() = PFApplicationData.instance(this).data
override val mainActivity = MainActivity::class.java
override val database: BackupDatabaseConfig
get() = SQLiteHelperConfig(this, PFASQLiteHelper.DATABASE_NAME)

override val workManagerConfiguration: Configuration
get() = Configuration.Builder().setMinimumLoggingLevel(Log.INFO).build()
}
162 changes: 162 additions & 0 deletions app/src/main/java/org/secuso/privacyfriendly2048/PFApplicationData.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
package org.secuso.privacyfriendly2048

import android.content.Context
import androidx.core.content.ContextCompat
import androidx.lifecycle.map
import org.secuso.pfacore.model.Theme
import org.secuso.pfacore.model.about.About
import org.secuso.pfacore.model.preferences.Preferable
import org.secuso.pfacore.model.preferences.settings.ISettingData
import org.secuso.pfacore.ui.PFData
import org.secuso.pfacore.ui.help.Help
import org.secuso.pfacore.ui.preferences.appPreferences
import org.secuso.pfacore.ui.preferences.settings.appearance
import org.secuso.pfacore.ui.preferences.settings.general
import org.secuso.pfacore.ui.preferences.settings.preferenceFirstTimeLaunch
import org.secuso.pfacore.ui.preferences.settings.settingDeviceInformationOnErrorReport
import org.secuso.pfacore.ui.preferences.settings.settingThemeSelector
import org.secuso.pfacore.ui.tutorial.buildTutorial

class PFApplicationData private constructor(context: Context) {

lateinit var theme: ISettingData<String>
private set
lateinit var firstTimeLaunch: Preferable<Boolean>
private set
lateinit var includeDeviceDataInReport: Preferable<Boolean>
private set
lateinit var animationActivated: Preferable<Boolean>
private set
lateinit var currentPage: Preferable<Int>
private set
lateinit var prefColorScheme: Preferable<String>
private set
lateinit var prefDisplayLock: Preferable<Boolean>
private set
lateinit var multipleUndo: Preferable<Boolean>
private set

private val preferences = appPreferences(context) {
preferences {
firstTimeLaunch = preferenceFirstTimeLaunch
currentPage = preference {
key = "currentPage"
default = 0
backup = true
}
}
settings {
general {
multipleUndo = switch {
key = "multiple_undo"
title { resource(R.string.settings_multiple_undo_title) }
summary { resource(R.string.settings_multiple_undo_summary) }
default = false
backup = true
}
prefDisplayLock = switch {
key = "settings_display"
title { resource(R.string.settings_display) }
summary { literal("") }
default = true
backup = true
}
includeDeviceDataInReport = settingDeviceInformationOnErrorReport
}
appearance {
theme = settingThemeSelector
animationActivated = switch {
key = "pref_animationActivated"
title { resource(R.string.settings_animation_title) }
summary { resource(R.string.settings_animation_summary) }
default = true
backup = true
}
prefColorScheme = radio {
key = "pref_color"
default = "1"
backup = true
entries {
entries(R.array.color_list)
values(resources.getStringArray(R.array.color_list_values).toList())
}
title { resource(R.string.settings_color) }
summary { transform { state, value -> state.entries.find { it.value == value }!!.entry } }
}
}
}
}

private val help = Help.build(context) {
listOf(
R.string.help_whatis to R.string.help_whatis_answer,
R.string.help_privacy to R.string.help_privacy_answer,
R.string.help_permission to R.string.help_permission_answer,
R.string.help_play to R.string.help_play_answer,
R.string.help_play_how to R.string.help_play_how_answer,
R.string.help_play_add to R.string.help_play_add_answer,
R.string.help_tip to R.string.help_tip_answer,
R.string.help_undo to R.string.help_undo_answer,
R.string.help_color to R.string.help_color_answer,
).forEach { (q, a) ->
item {
title { resource(q) }
description { resource(a) }
}
}

}

private val about = About(
name = context.resources.getString(R.string.app_name),
version = BuildConfig.VERSION_NAME,
authors = context.resources.getString(R.string.about_author_names),
repo = context.resources.getString(R.string.github)
)

private val tutorial = buildTutorial {
stage {
title = ContextCompat.getString(context, R.string.Tutorial_Titel)
images = listOf(R.mipmap.ic_splash)
description = ContextCompat.getString(context, R.string.Tutorial_Instruction)
}
stage {
title = ContextCompat.getString(context, R.string.Tutorial_Titel_Move)
images = if (prefColorScheme.value == "1") { listOf(R.drawable.tutorial_move_s) } else { listOf(R.drawable.tutorial_move_o) }
description = ContextCompat.getString(context, R.string.Tutorial_Move)
}
stage {
title = ContextCompat.getString(context, R.string.Tutorial_Titel_Move)
images = if (prefColorScheme.value == "1") { listOf(R.drawable.tutorial_swipe_s) } else { listOf(R.drawable.tutorial_swipe_o) }
description = ContextCompat.getString(context, R.string.Tutorial_Move)
}
stage {
title = ContextCompat.getString(context, R.string.Tutorial_Titel_Add)
images = if (prefColorScheme.value == "1") { listOf(R.drawable.tutorial_add_s) } else { listOf(R.drawable.tutorial_add_o) }
description = ContextCompat.getString(context, R.string.Tutorial_Add)
}
}

val data = PFData(
about = about,
help = help,
settings = preferences.settings,
tutorial = tutorial,
theme = theme.state.map { Theme.valueOf(it) },
firstLaunch = firstTimeLaunch,
includeDeviceDataInReport = includeDeviceDataInReport,
)

companion object {
private var _instance: PFApplicationData? = null
fun instance(context: Context): PFApplicationData {
if (_instance == null) {
_instance = PFApplicationData(context)
}
return _instance!!
}

}
}


This file was deleted.

Loading
Loading