From 670e6afedb133a8651334622ec7cd7fca7b75e57 Mon Sep 17 00:00:00 2001 From: Patrick Schneider Date: Wed, 27 Mar 2024 13:03:44 +0100 Subject: [PATCH 1/6] [feat] Adds pfa-core library and update to API 34. --- .gitmodules | 3 +++ app/build.gradle | 11 ++++++----- app/src/main/AndroidManifest.xml | 3 ++- gradle.properties | 3 ++- libs/pfa-core | 1 + settings.gradle | 3 ++- 6 files changed, 16 insertions(+), 8 deletions(-) create mode 100644 .gitmodules create mode 160000 libs/pfa-core diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..5467b30 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "libs/pfa-core"] + path = libs/pfa-core + url = https://github.com/SecUSo/pfa-core diff --git a/app/build.gradle b/app/build.gradle index 23631a5..f0f19b2 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -3,13 +3,13 @@ apply plugin: 'kotlin-android' apply plugin: 'kotlin-kapt' android { - compileSdkVersion 30 + compileSdk 34 namespace "org.secuso.privacyfriendlyexample" defaultConfig { applicationId "org.secuso.privacyfriendlyexample" - minSdkVersion 19 - targetSdkVersion 30 + minSdkVersion 21 + targetSdkVersion 34 versionCode 7 versionName "4.0" } @@ -43,13 +43,14 @@ dependencies { implementation 'androidx.appcompat:appcompat:1.2.0' implementation 'androidx.legacy:legacy-support-v4:1.0.0' - implementation 'androidx.room:room-runtime:2.2.6' - kapt 'androidx.room:room-compiler:2.2.6' + implementation 'androidx.room:room-runtime:2.5.0' + kapt 'androidx.room:room-compiler:2.5.0' implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.2" implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.1" implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' + implementation "org.secuso:pfa-core" } repositories { mavenCentral() diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 7b9f40e..a732c76 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -18,7 +18,8 @@ android:fullBackupContent="@xml/backup_descriptor"> + android:theme="@style/SplashTheme" + android:exported="true"> diff --git a/gradle.properties b/gradle.properties index 915f0e6..ba40810 100644 --- a/gradle.properties +++ b/gradle.properties @@ -17,4 +17,5 @@ # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # org.gradle.parallel=true android.enableJetifier=true -android.useAndroidX=true \ No newline at end of file +android.useAndroidX=true +org.gradle.jvmargs=-Xmx1024m \ No newline at end of file diff --git a/libs/pfa-core b/libs/pfa-core new file mode 160000 index 0000000..87a6183 --- /dev/null +++ b/libs/pfa-core @@ -0,0 +1 @@ +Subproject commit 87a6183d0f94813f476a7436acd78b3be87d0f25 diff --git a/settings.gradle b/settings.gradle index e7b4def..3e6d220 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1 +1,2 @@ -include ':app' +include(":app") +includeBuild("libs/pfa-core") From 49129a0e63c4b322abd448689cb2e841c21827ca Mon Sep 17 00:00:00 2001 From: Patrick Schneider Date: Wed, 27 Mar 2024 16:41:36 +0100 Subject: [PATCH 2/6] [feat] Working pfa-core integration with backup. --- app/build.gradle | 19 +- app/src/main/AndroidManifest.xml | 27 ++- .../privacyfriendlyexample/PFExample.kt | 47 ++++ .../privacyfriendlyexample/PFSettings.kt | 38 ++++ .../database/AppDatabase.kt | 4 +- .../ui/AboutActivity.kt | 51 ----- .../privacyfriendlyexample/ui/BaseActivity.kt | 5 +- .../privacyfriendlyexample/ui/HelpActivity.kt | 64 ------ .../ui/SettingsActivity.java | 212 ------------------ build.gradle | 2 +- libs/pfa-core | 2 +- 11 files changed, 132 insertions(+), 339 deletions(-) create mode 100644 app/src/main/java/org/secuso/privacyfriendlyexample/PFExample.kt create mode 100644 app/src/main/java/org/secuso/privacyfriendlyexample/PFSettings.kt delete mode 100644 app/src/main/java/org/secuso/privacyfriendlyexample/ui/AboutActivity.kt delete mode 100644 app/src/main/java/org/secuso/privacyfriendlyexample/ui/HelpActivity.kt delete mode 100644 app/src/main/java/org/secuso/privacyfriendlyexample/ui/SettingsActivity.java diff --git a/app/build.gradle b/app/build.gradle index f0f19b2..1fe20e3 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,5 +1,5 @@ apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' +apply plugin: 'org.jetbrains.kotlin.android' apply plugin: 'kotlin-kapt' android { @@ -22,6 +22,10 @@ android { buildFeatures { viewBinding true buildConfig true + compose true + } + composeOptions { + kotlinCompilerExtensionVersion = "1.5.0" } compileOptions { sourceCompatibility = JavaVersion.VERSION_17 @@ -43,14 +47,23 @@ dependencies { implementation 'androidx.appcompat:appcompat:1.2.0' implementation 'androidx.legacy:legacy-support-v4:1.0.0' - implementation 'androidx.room:room-runtime:2.5.0' - kapt 'androidx.room:room-compiler:2.5.0' + def roomVersion = "2.5.2" + implementation("androidx.room:room-runtime:$roomVersion") + kapt("androidx.room:room-compiler:$roomVersion") + implementation("androidx.room:room-ktx:$roomVersion") + + def workVersion = "2.8.1" + implementation("androidx.work:work-runtime:$workVersion") + implementation("androidx.work:work-runtime-ktx:$workVersion") + androidTestImplementation("androidx.work:work-testing:$workVersion") implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.2" implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.1" implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' implementation "org.secuso:pfa-core" + implementation("androidx.compose.runtime:runtime:1.6.4") + } repositories { mavenCentral() diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index a732c76..30cac54 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,5 +1,6 @@ - + @@ -51,7 +53,7 @@ android:value="org.secuso.privacyfriendlyexample.ui.MainActivity" /> @@ -68,6 +70,23 @@ android:name="android.support.PARENT_ACTIVITY" android:value="org.secuso.privacyfriendlyexample.ui.MainActivity" /> + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/org/secuso/privacyfriendlyexample/PFExample.kt b/app/src/main/java/org/secuso/privacyfriendlyexample/PFExample.kt new file mode 100644 index 0000000..cf8a95b --- /dev/null +++ b/app/src/main/java/org/secuso/privacyfriendlyexample/PFExample.kt @@ -0,0 +1,47 @@ +package org.secuso.privacyfriendlyexample + +import org.secuso.pfacore.model.PFApplication +import org.secuso.pfacore.model.PFDatabase +import org.secuso.pfacore.ui.AboutData +import org.secuso.pfacore.ui.help.HelpData +import org.secuso.pfacore.ui.settings.ISettings +import org.secuso.privacyfriendlyexample.database.AppDatabase + +class PFExample: PFApplication() { + override val ApplicationName: String + get() = getString(R.string.app_name) + override val LightMode: Boolean + get() = PFSettings(applicationContext).lightMode + override val Database: PFDatabase + get() = AppDatabase.getInstance(applicationContext) + + override val About: AboutData + get() = AboutData( + name = getString(R.string.app_name), + version = BuildConfig.VERSION_NAME, + authors = getString(R.string.about_author_names), + repo = getString(org.secuso.pfacore.R.string.about_github) + ) + + override val Help + get() = HelpData.build(applicationContext) { + item { + title { resource(R.string.help_whatis) } + description { resource(R.string.help_whatis_answer) } + } + item { + title { resource(R.string.help_feature_one) } + description { resource(R.string.help_feature_one_answer) } + } + item { + title { resource(R.string.help_privacy) } + description { resource(R.string.help_privacy_answer) } + } + item { + title { resource(R.string.help_permission) } + description { resource(R.string.help_permission_answer) } + } + } + override val Settings: ISettings + get() = PFSettings(applicationContext).settings +} \ No newline at end of file diff --git a/app/src/main/java/org/secuso/privacyfriendlyexample/PFSettings.kt b/app/src/main/java/org/secuso/privacyfriendlyexample/PFSettings.kt new file mode 100644 index 0000000..8fc25d8 --- /dev/null +++ b/app/src/main/java/org/secuso/privacyfriendlyexample/PFSettings.kt @@ -0,0 +1,38 @@ +package org.secuso.privacyfriendlyexample + +import android.content.Context +import androidx.appcompat.app.AppCompatDelegate +import org.secuso.pfacore.ui.settings.CommonSettings +import org.secuso.pfacore.ui.settings.ISettings +import org.secuso.pfacore.ui.settings.Settings +class PFSettings(context: Context) { + + companion object { + private var _settings: ISettings? = null + } + + init { + if (_settings == null) { + _settings = Settings.build(context) { + category("Example Category") { + switch { + key = "pref_example_switch" + title { resource(R.string.pref_example_switch) } + summary { resource(R.string.pref_example_summary) } + default = false + backup = true + } + } + category("Design") { + CommonSettings.themeSelector(context).invoke(this) + } + } + } + } + + val settings + get() = _settings!! + + val lightMode + get() = settings.all.map { it.data }.find { it.key === CommonSettings.themeSelectorKey }!!.state.value.toString().toInt() == AppCompatDelegate.MODE_NIGHT_NO +} \ No newline at end of file diff --git a/app/src/main/java/org/secuso/privacyfriendlyexample/database/AppDatabase.kt b/app/src/main/java/org/secuso/privacyfriendlyexample/database/AppDatabase.kt index c160e30..dea129b 100644 --- a/app/src/main/java/org/secuso/privacyfriendlyexample/database/AppDatabase.kt +++ b/app/src/main/java/org/secuso/privacyfriendlyexample/database/AppDatabase.kt @@ -20,6 +20,7 @@ import android.content.Context import androidx.room.Database import androidx.room.Room import androidx.room.RoomDatabase +import org.secuso.pfacore.model.PFDatabase import org.secuso.privacyfriendlyexample.database.dao.SampleDataDao import org.secuso.privacyfriendlyexample.database.model.SampleData @@ -28,7 +29,8 @@ import org.secuso.privacyfriendlyexample.database.model.SampleData * @author Christopher Beckmann (Kamuno) */ @Database(entities = arrayOf(SampleData::class), version = 1, exportSchema = false) -abstract class AppDatabase : RoomDatabase() { +abstract class AppDatabase : PFDatabase() { + override val name: String = DB_NAME abstract fun sampleDataDao(): SampleDataDao diff --git a/app/src/main/java/org/secuso/privacyfriendlyexample/ui/AboutActivity.kt b/app/src/main/java/org/secuso/privacyfriendlyexample/ui/AboutActivity.kt deleted file mode 100644 index fffb34e..0000000 --- a/app/src/main/java/org/secuso/privacyfriendlyexample/ui/AboutActivity.kt +++ /dev/null @@ -1,51 +0,0 @@ -/* - This file is part of Privacy Friendly App Example. - - Privacy Friendly App Example is free software: - you can redistribute it and/or modify it under the terms of the - GNU General Public License as published by the Free Software Foundation, - either version 3 of the License, or any later version. - - Privacy Friendly App Example is distributed in the hope - that it will be useful, but WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with Privacy Friendly App Example. If not, see . - */ -package org.secuso.privacyfriendlyexample.ui - -import android.os.Bundle -import androidx.appcompat.app.AppCompatActivity -import android.text.method.LinkMovementMethod - -import org.secuso.privacyfriendlyexample.BuildConfig -import org.secuso.privacyfriendlyexample.R -import org.secuso.privacyfriendlyexample.databinding.ActivityAboutBinding - -/** - * This activity manages the AboutPage. - * @author Christopher Beckmann (Kamuno), Karola Marky (yonjuni) - * Created on 15.06.16. - */ -class AboutActivity : AppCompatActivity() { - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - val binding = ActivityAboutBinding.inflate(layoutInflater) - setContentView(binding.root) - - supportActionBar?.setDisplayHomeAsUpEnabled(true) - - binding.mainContent.alpha = 0f - binding.mainContent.animate().alpha(1f).duration = BaseActivity.MAIN_CONTENT_FADEIN_DURATION.toLong() - - overridePendingTransition(0, 0) - - binding.secusoWebsite.movementMethod = LinkMovementMethod.getInstance() - binding.githubURL.movementMethod = LinkMovementMethod.getInstance() - binding.textFieldVersion.text = getString(R.string.version_number, BuildConfig.VERSION_NAME) - } -} - diff --git a/app/src/main/java/org/secuso/privacyfriendlyexample/ui/BaseActivity.kt b/app/src/main/java/org/secuso/privacyfriendlyexample/ui/BaseActivity.kt index 35a4947..33c05c8 100644 --- a/app/src/main/java/org/secuso/privacyfriendlyexample/ui/BaseActivity.kt +++ b/app/src/main/java/org/secuso/privacyfriendlyexample/ui/BaseActivity.kt @@ -33,6 +33,9 @@ import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.widget.Toolbar import android.view.MenuItem import android.view.View +import org.secuso.pfacore.ui.activities.AboutActivity +import org.secuso.pfacore.ui.activities.HelpActivity +import org.secuso.pfacore.ui.activities.SettingsActivity import org.secuso.privacyfriendlyexample.R @@ -168,8 +171,6 @@ abstract class BaseActivity : AppCompatActivity(), OnNavigationItemSelectedListe } R.id.nav_settings -> { intent = Intent(this, SettingsActivity::class.java) - intent.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT, SettingsActivity.GeneralPreferenceFragment::class.java.name) - intent.putExtra(PreferenceActivity.EXTRA_NO_HEADERS, true) createBackStack(intent) } } diff --git a/app/src/main/java/org/secuso/privacyfriendlyexample/ui/HelpActivity.kt b/app/src/main/java/org/secuso/privacyfriendlyexample/ui/HelpActivity.kt deleted file mode 100644 index c1c4136..0000000 --- a/app/src/main/java/org/secuso/privacyfriendlyexample/ui/HelpActivity.kt +++ /dev/null @@ -1,64 +0,0 @@ -/* - This file is part of Privacy Friendly App Example. - - Privacy Friendly App Example is free software: - you can redistribute it and/or modify it under the terms of the - GNU General Public License as published by the Free Software Foundation, - either version 3 of the License, or any later version. - - Privacy Friendly App Example is distributed in the hope - that it will be useful, but WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with Privacy Friendly App Example. If not, see . - */ -package org.secuso.privacyfriendlyexample.ui - -import android.os.Bundle - -import org.secuso.privacyfriendlyexample.R -import org.secuso.privacyfriendlyexample.databinding.ActivityHelpBinding - -import org.secuso.privacyfriendlyexample.ui.adapter.ExpandableListAdapter -import java.util.* -import kotlin.collections.LinkedHashMap - - -/** - * Class structure taken from tutorial at http://www.journaldev.com/9942/android-expandablelistview-example-tutorial - * last access 27th October 2016 - * @author Christopher Beckmann (Kamuno), Karola Marky (yonjuni) - */ -class HelpActivity : BaseActivity() { - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - val binding = ActivityHelpBinding.inflate(layoutInflater) - setContentView(binding.root) - - val expandableListDetail = buildData() - val expandableListTitleGeneral = expandableListDetail.keys.toList() - - binding.generalExpandableListView.setAdapter(ExpandableListAdapter(this, expandableListTitleGeneral, expandableListDetail)) - - overridePendingTransition(0, 0) - } - - /** - * ID of the menu item it belongs to - */ - override val navigationDrawerID: Int = R.id.nav_help - - private fun buildData(): LinkedHashMap> { - val expandableListDetail = LinkedHashMap>() - - expandableListDetail[getString(R.string.help_whatis)] = Collections.singletonList(getString(R.string.help_whatis_answer)) - expandableListDetail[getString(R.string.help_feature_one)] = Collections.singletonList(getString(R.string.help_feature_one_answer)) - expandableListDetail[getString(R.string.help_privacy)] = Collections.singletonList(getString(R.string.help_privacy_answer)) - expandableListDetail[getString(R.string.help_permission)] = Collections.singletonList(getString(R.string.help_permission_answer)) - - return expandableListDetail - } -} diff --git a/app/src/main/java/org/secuso/privacyfriendlyexample/ui/SettingsActivity.java b/app/src/main/java/org/secuso/privacyfriendlyexample/ui/SettingsActivity.java deleted file mode 100644 index 6f088a4..0000000 --- a/app/src/main/java/org/secuso/privacyfriendlyexample/ui/SettingsActivity.java +++ /dev/null @@ -1,212 +0,0 @@ -/* - This file is part of Privacy Friendly App Example. - - Privacy Friendly App Example is free software: - you can redistribute it and/or modify it under the terms of the - GNU General Public License as published by the Free Software Foundation, - either version 3 of the License, or any later version. - - Privacy Friendly App Example is distributed in the hope - that it will be useful, but WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with Privacy Friendly App Example. If not, see . - */ -package org.secuso.privacyfriendlyexample.ui; - - -import android.annotation.TargetApi; -import android.content.Context; -import android.content.Intent; -import android.content.res.Configuration; -import android.os.Build; -import android.os.Bundle; -import android.preference.ListPreference; -import android.preference.Preference; -import android.preference.PreferenceActivity; -import android.preference.PreferenceFragment; -import android.preference.PreferenceManager; -import android.view.MenuItem; - -import org.secuso.privacyfriendlyexample.R; - -/** - * A {@link PreferenceActivity} that presents a set of application settings. On - * handset devices, settings are presented as a single list. On tablets, - * settings are split by category, with category headers shown to the left of - * the list of settings. - *

- * See - * Android Design: Settings for design guidelines and the Settings - * API Guide for more information on developing a Settings UI. - */ -public class SettingsActivity extends BaseActivity { - /** - * A preference value change listener that updates the preference's summary - * to reflect its new value. - */ - private static Preference.OnPreferenceChangeListener sBindPreferenceSummaryToValueListener = new Preference.OnPreferenceChangeListener() { - @Override - public boolean onPreferenceChange(Preference preference, Object value) { - String stringValue = value.toString(); - - if (preference instanceof ListPreference) { - // For list preferences, look up the correct display value in - // the preference's 'entries' list. - ListPreference listPreference = (ListPreference) preference; - int index = listPreference.findIndexOfValue(stringValue); - - // Set the summary to reflect the new value. - preference.setSummary( - index >= 0 - ? listPreference.getEntries()[index] - : null); - } else { - // For all other preferences, set the summary to the value's - // simple string representation. - preference.setSummary(stringValue); - } - return true; - } - }; - - /** - * Helper method to determine if the device has an extra-large screen. For - * example, 10" tablets are extra-large. - */ - private static boolean isXLargeTablet(Context context) { - return (context.getResources().getConfiguration().screenLayout - & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_XLARGE; - } - - /** - * Binds a preference's summary to its value. More specifically, when the - * preference's value is changed, its summary (line of text below the - * preference title) is updated to reflect the value. The summary is also - * immediately updated upon calling this method. The exact display format is - * dependent on the type of preference. - * - * @see #sBindPreferenceSummaryToValueListener - */ - private static void bindPreferenceSummaryToValue(Preference preference) { - // Set the listener to watch for value changes. - preference.setOnPreferenceChangeListener(sBindPreferenceSummaryToValueListener); - - // Trigger the listener immediately with the preference's - // current value. - sBindPreferenceSummaryToValueListener.onPreferenceChange(preference, - PreferenceManager - .getDefaultSharedPreferences(preference.getContext()) - .getString(preference.getKey(), "")); - } - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - setContentView(R.layout.activity_settings); - - //setupActionBar(); - - - overridePendingTransition(0, 0); - } - - @Override - protected int getNavigationDrawerID() { - return R.id.nav_settings; - } - - /** - * Set up the {@link android.app.ActionBar}, if the API is available. - */ - /*private void setupActionBar() { - ActionBar actionBar = getSupportActionBar(); - if (actionBar != null) { - // Show the Up button in the action bar. - actionBar.setDisplayHomeAsUpEnabled(true); - } - }*/ - - /*@Override - public boolean onMenuItemSelected(int featureId, MenuItem item) { - int id = item.getItemId(); - if (id == android.R.id.home) { - //finish(); - Intent intent = new Intent(this, MainActivity.class); - intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); - startActivity(intent); - finish(); - return true; - - // (!super.onMenuItemSelected(featureId, item)) { - // NavUtils.navigateUpFromSameTask(this); - //} - //return true; - } - return super.onMenuItemSelected(featureId, item); - }*/ - - /** - * {@inheritDoc} - */ - /*@Override - public boolean onIsMultiPane() { - return isXLargeTablet(this); - }*/ - - /** - * {@inheritDoc} - */ - /*@Override - @TargetApi(Build.VERSION_CODES.HONEYCOMB) - public void onBuildHeaders(List

target) { - loadHeadersFromResource(R.xml.pref_headers, target); - }*/ - - /** - * This method stops fragment injection in malicious applications. - * Make sure to deny any unknown fragments here. - */ - protected boolean isValidFragment(String fragmentName) { - return PreferenceFragment.class.getName().equals(fragmentName) - || GeneralPreferenceFragment.class.getName().equals(fragmentName); - } - - /** - * This fragment shows general preferences only. It is used when the - * activity is showing a two-pane settings UI. - * The commented method bindPrefenceSummaryToValue should be added for all preferences - * with a summary that is depended from the current value of the preference - */ - @TargetApi(Build.VERSION_CODES.HONEYCOMB) - public static class GeneralPreferenceFragment extends PreferenceFragment { - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - addPreferencesFromResource(R.xml.pref_general); - //setHasOptionsMenu(true); - - // Bind the summaries of EditText/List/Dialog/Ringtone preferences - // to their values. When their values change, their summaries are - // updated to reflect the new value, per the Android Design - // guidelines. - //bindPreferenceSummaryToValue(findPreference("example_text")); - //bindPreferenceSummaryToValue(findPreference("example_list")); - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - int id = item.getItemId(); - if (id == android.R.id.home) { - //getActivity().finish(); - startActivity(new Intent(getActivity(), SettingsActivity.class)); - return true; - } - return super.onOptionsItemSelected(item); - } - } -} diff --git a/build.gradle b/build.gradle index 7028c8d..d36c37b 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,7 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = "1.8.22" + ext.kotlin_version = "1.9.0" repositories { jcenter() diff --git a/libs/pfa-core b/libs/pfa-core index 87a6183..685b950 160000 --- a/libs/pfa-core +++ b/libs/pfa-core @@ -1 +1 @@ -Subproject commit 87a6183d0f94813f476a7436acd78b3be87d0f25 +Subproject commit 685b950b783b4300f91088d38b73812b9e218d1b From 32a42e36de5840f133a9e637423676b1b1792bb9 Mon Sep 17 00:00:00 2001 From: Patrick Schneider Date: Fri, 5 Apr 2024 20:25:21 +0200 Subject: [PATCH 3/6] [feat] Finishes the initial pfa-core compose integration. --- app/build.gradle | 8 ++++- app/src/main/AndroidManifest.xml | 6 ++-- .../privacyfriendlyexample/PFExample.kt | 27 +++++++++-------- .../privacyfriendlyexample/PFSettings.kt | 30 ++++++++++++++----- .../database/AppDatabase.kt | 3 +- .../privacyfriendlyexample/ui/BaseActivity.kt | 7 +++-- libs/pfa-core | 2 +- 7 files changed, 53 insertions(+), 30 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 1fe20e3..82fb399 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,7 +1,12 @@ +plugins { + id "org.jetbrains.kotlin.plugin.serialization" version "$kotlin_version" +} + apply plugin: 'com.android.application' apply plugin: 'org.jetbrains.kotlin.android' apply plugin: 'kotlin-kapt' + android { compileSdk 34 namespace "org.secuso.privacyfriendlyexample" @@ -61,7 +66,8 @@ dependencies { implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.1" implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' - implementation "org.secuso:pfa-core" + implementation("org.secuso.pfa-core:ui-compose") + implementation("org.secuso.pfa-core:model") implementation("androidx.compose.runtime:runtime:1.6.4") } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 30cac54..ad5ff6f 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -36,7 +36,7 @@ android:theme="@style/AppTheme.NoActionBar"> @@ -53,7 +53,7 @@ android:value="org.secuso.privacyfriendlyexample.ui.MainActivity" /> diff --git a/app/src/main/java/org/secuso/privacyfriendlyexample/PFExample.kt b/app/src/main/java/org/secuso/privacyfriendlyexample/PFExample.kt index cf8a95b..559057d 100644 --- a/app/src/main/java/org/secuso/privacyfriendlyexample/PFExample.kt +++ b/app/src/main/java/org/secuso/privacyfriendlyexample/PFExample.kt @@ -1,30 +1,31 @@ package org.secuso.privacyfriendlyexample -import org.secuso.pfacore.model.PFApplication -import org.secuso.pfacore.model.PFDatabase -import org.secuso.pfacore.ui.AboutData -import org.secuso.pfacore.ui.help.HelpData -import org.secuso.pfacore.ui.settings.ISettings +import androidx.lifecycle.LiveData +import org.secuso.pfacore.application.PFApplication +import org.secuso.pfacore.application.PFDatabase +import org.secuso.pfacore.model.about.About +import org.secuso.pfacore.model.settings.ISettings +import org.secuso.pfacore.ui.compose.help.Help import org.secuso.privacyfriendlyexample.database.AppDatabase class PFExample: PFApplication() { - override val ApplicationName: String + override val applicationName: String get() = getString(R.string.app_name) - override val LightMode: Boolean + override val lightMode: LiveData get() = PFSettings(applicationContext).lightMode - override val Database: PFDatabase + override val database: PFDatabase get() = AppDatabase.getInstance(applicationContext) - override val About: AboutData - get() = AboutData( + override val about: About + get() = About( name = getString(R.string.app_name), version = BuildConfig.VERSION_NAME, authors = getString(R.string.about_author_names), repo = getString(org.secuso.pfacore.R.string.about_github) ) - override val Help - get() = HelpData.build(applicationContext) { + override val help + get() = Help.build(applicationContext) { item { title { resource(R.string.help_whatis) } description { resource(R.string.help_whatis_answer) } @@ -42,6 +43,6 @@ class PFExample: PFApplication() { description { resource(R.string.help_permission_answer) } } } - override val Settings: ISettings + override val settings: ISettings<*> get() = PFSettings(applicationContext).settings } \ No newline at end of file diff --git a/app/src/main/java/org/secuso/privacyfriendlyexample/PFSettings.kt b/app/src/main/java/org/secuso/privacyfriendlyexample/PFSettings.kt index 8fc25d8..6cd36c8 100644 --- a/app/src/main/java/org/secuso/privacyfriendlyexample/PFSettings.kt +++ b/app/src/main/java/org/secuso/privacyfriendlyexample/PFSettings.kt @@ -1,14 +1,15 @@ package org.secuso.privacyfriendlyexample import android.content.Context -import androidx.appcompat.app.AppCompatDelegate -import org.secuso.pfacore.ui.settings.CommonSettings -import org.secuso.pfacore.ui.settings.ISettings -import org.secuso.pfacore.ui.settings.Settings +import androidx.lifecycle.map +import org.secuso.pfacore.model.settings.ISettings +import org.secuso.pfacore.ui.compose.settings.Settings +import org.secuso.pfacore.ui.compose.settings.SettingThemeSelector + class PFSettings(context: Context) { companion object { - private var _settings: ISettings? = null + private var _settings: ISettings<*>? = null } init { @@ -24,7 +25,22 @@ class PFSettings(context: Context) { } } category("Design") { - CommonSettings.themeSelector(context).invoke(this) + SettingThemeSelector().build().invoke(this) + } + category("Legal") { + menu("Legal") { + setting { + menu { + key = "" + title { literal("Legal") } + summary { literal("") } + default = Unit + } + } + content { + + } + } } } } @@ -34,5 +50,5 @@ class PFSettings(context: Context) { get() = _settings!! val lightMode - get() = settings.all.map { it.data }.find { it.key === CommonSettings.themeSelectorKey }!!.state.value.toString().toInt() == AppCompatDelegate.MODE_NIGHT_NO + get() = settings.all.map { it.data }.find { it.key === SettingThemeSelector.themeSelectorKey }!!.state.map { SettingThemeSelector.Mode.valueOf(it as String) === SettingThemeSelector.Mode.LIGHT } } \ No newline at end of file diff --git a/app/src/main/java/org/secuso/privacyfriendlyexample/database/AppDatabase.kt b/app/src/main/java/org/secuso/privacyfriendlyexample/database/AppDatabase.kt index dea129b..01f4b07 100644 --- a/app/src/main/java/org/secuso/privacyfriendlyexample/database/AppDatabase.kt +++ b/app/src/main/java/org/secuso/privacyfriendlyexample/database/AppDatabase.kt @@ -19,8 +19,7 @@ package org.secuso.privacyfriendlyexample.database import android.content.Context import androidx.room.Database import androidx.room.Room -import androidx.room.RoomDatabase -import org.secuso.pfacore.model.PFDatabase +import org.secuso.pfacore.application.PFDatabase import org.secuso.privacyfriendlyexample.database.dao.SampleDataDao import org.secuso.privacyfriendlyexample.database.model.SampleData diff --git a/app/src/main/java/org/secuso/privacyfriendlyexample/ui/BaseActivity.kt b/app/src/main/java/org/secuso/privacyfriendlyexample/ui/BaseActivity.kt index 33c05c8..e1f0248 100644 --- a/app/src/main/java/org/secuso/privacyfriendlyexample/ui/BaseActivity.kt +++ b/app/src/main/java/org/secuso/privacyfriendlyexample/ui/BaseActivity.kt @@ -33,9 +33,10 @@ import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.widget.Toolbar import android.view.MenuItem import android.view.View -import org.secuso.pfacore.ui.activities.AboutActivity -import org.secuso.pfacore.ui.activities.HelpActivity -import org.secuso.pfacore.ui.activities.SettingsActivity +import org.secuso.pfacore.ui.compose.activities.AboutActivity +import org.secuso.pfacore.ui.compose.activities.HelpActivity +//import org.secuso.pfacore.ui.compose.activities.HelpActivity +import org.secuso.pfacore.ui.compose.activities.SettingsActivity import org.secuso.privacyfriendlyexample.R diff --git a/libs/pfa-core b/libs/pfa-core index 685b950..484eabb 160000 --- a/libs/pfa-core +++ b/libs/pfa-core @@ -1 +1 @@ -Subproject commit 685b950b783b4300f91088d38b73812b9e218d1b +Subproject commit 484eabb41b7b191ce7eedf29a69c20ff286ceaff From 239908cdeb994b72e3980d8b6ae707599eb38669 Mon Sep 17 00:00:00 2001 From: Patrick Schneider Date: Fri, 5 Apr 2024 20:30:09 +0200 Subject: [PATCH 4/6] [cleanup] renames app module to compose. The compose module uses pfa-core:ui-compose and is suitable for minSdk >= 21. --- app/src/main/res/layout/activity_about.xml | 145 --------------- .../activity_about_with_navigationdrawer.xml | 166 ------------------ app/src/main/res/layout/activity_help.xml | 47 ----- app/src/main/res/layout/activity_settings.xml | 49 ------ app/src/main/res/xml/pref_general.xml | 39 ---- app/src/main/res/xml/pref_headers.xml | 10 -- {app => compose}/.gitignore | 0 {app => compose}/build.gradle | 0 {app => compose}/proguard-rules.pro | 0 .../ApplicationTest.java | 0 {app => compose}/src/main/AndroidManifest.xml | 0 .../privacyfriendlyexample/PFExample.kt | 0 .../privacyfriendlyexample/PFSettings.kt | 0 .../database/AppDatabase.kt | 0 .../database/DatabaseExporter.java | 0 .../database/DatabaseImporter.java | 0 .../database/dao/SampleDataDao.kt | 0 .../database/model/SampleData.kt | 0 .../ui/AppCompatPreferenceActivity.java | 0 .../privacyfriendlyexample/ui/BaseActivity.kt | 0 .../privacyfriendlyexample/ui/GameActivity.kt | 0 .../privacyfriendlyexample/ui/MainActivity.kt | 0 .../ui/SplashActivity.kt | 0 .../ui/TutorialActivity.java | 0 .../ui/adapter/ExpandableListAdapter.java | 0 .../ui/helper/FirstLaunchManager.java | 0 .../ui/viewmodel/MainExampleViewModel.kt | 0 .../src/main/res/drawable/button_disabled.xml | 0 .../main/res/drawable/button_fullwidth.xml | 0 .../main/res/drawable/button_highlighted.xml | 0 .../res/drawable/button_highlighted_2.xml | 0 .../res/drawable/button_highlighted_3.xml | 0 .../res/drawable/button_highlighted_4.xml | 0 .../main/res/drawable/button_middleblue.xml | 0 .../src/main/res/drawable/button_normal.xml | 0 .../ic_keyboard_arrow_left_black_24dp.xml | 0 .../ic_keyboard_arrow_right_black_24dp.xml | 0 .../src/main/res/drawable/ic_menu_game.xml | 0 .../src/main/res/drawable/ic_menu_help.xml | 0 .../src/main/res/drawable/ic_menu_home.xml | 0 .../src/main/res/drawable/ic_menu_info.xml | 0 .../main/res/drawable/ic_menu_settings.xml | 0 .../main/res/drawable/ic_menu_tutorial.xml | 0 .../res/drawable/privacyfriendlyappslogo.png | Bin .../res/drawable/secuso_logo_blau_blau.png | Bin .../src/main/res/drawable/splash_screen.xml | 0 .../src/main/res/layout/activity_game.xml | 0 .../src/main/res/layout/activity_main.xml | 0 .../src/main/res/layout/activity_tutorial.xml | 0 .../src/main/res/layout/app_bar_main.xml | 0 .../src/main/res/layout/content_main.xml | 0 .../main/res/layout/fragment_game_mode.xml | 0 .../src/main/res/layout/list_group.xml | 0 .../src/main/res/layout/list_item.xml | 0 .../src/main/res/layout/nav_header_main.xml | 0 .../src/main/res/layout/toolbar.xml | 0 .../src/main/res/layout/tutorial_slide1.xml | 0 .../src/main/res/layout/tutorial_slide2.xml | 0 .../src/main/res/layout/tutorial_slide3.xml | 0 {app => compose}/src/main/res/menu/main.xml | 0 .../src/main/res/menu/main_drawer.xml | 0 .../src/main/res/mipmap-hdpi/ic_launcher.png | Bin .../src/main/res/mipmap-hdpi/ic_splash.png | Bin .../src/main/res/mipmap-mdpi/ic_launcher.png | Bin .../src/main/res/mipmap-mdpi/ic_splash.png | Bin .../src/main/res/mipmap-xhdpi/ic_launcher.png | Bin .../src/main/res/mipmap-xhdpi/ic_splash.png | Bin .../main/res/mipmap-xxhdpi/ic_launcher.png | Bin .../src/main/res/mipmap-xxhdpi/ic_splash.png | Bin .../main/res/mipmap-xxxhdpi/ic_launcher.png | Bin .../src/main/res/mipmap-xxxhdpi/ic_splash.png | Bin .../src/main/res/values-de/strings.xml | 0 .../src/main/res/values-v21/styles.xml | 0 .../src/main/res/values-w820dp/dimens.xml | 0 .../src/main/res/values/colors.xml | 0 .../src/main/res/values/dimens.xml | 0 .../src/main/res/values/drawables.xml | 0 .../src/main/res/values/strings.xml | 0 .../src/main/res/values/styles.xml | 0 .../src/main/res/xml/backup_descriptor.xml | 0 .../ExampleUnitTest.java | 0 settings.gradle | 2 +- 82 files changed, 1 insertion(+), 457 deletions(-) delete mode 100644 app/src/main/res/layout/activity_about.xml delete mode 100644 app/src/main/res/layout/activity_about_with_navigationdrawer.xml delete mode 100644 app/src/main/res/layout/activity_help.xml delete mode 100644 app/src/main/res/layout/activity_settings.xml delete mode 100644 app/src/main/res/xml/pref_general.xml delete mode 100644 app/src/main/res/xml/pref_headers.xml rename {app => compose}/.gitignore (100%) rename {app => compose}/build.gradle (100%) rename {app => compose}/proguard-rules.pro (100%) rename {app => compose}/src/androidTest/java/org/secuso/privacyfriendlyexample/ApplicationTest.java (100%) rename {app => compose}/src/main/AndroidManifest.xml (100%) rename {app => compose}/src/main/java/org/secuso/privacyfriendlyexample/PFExample.kt (100%) rename {app => compose}/src/main/java/org/secuso/privacyfriendlyexample/PFSettings.kt (100%) rename {app => compose}/src/main/java/org/secuso/privacyfriendlyexample/database/AppDatabase.kt (100%) rename {app => compose}/src/main/java/org/secuso/privacyfriendlyexample/database/DatabaseExporter.java (100%) rename {app => compose}/src/main/java/org/secuso/privacyfriendlyexample/database/DatabaseImporter.java (100%) rename {app => compose}/src/main/java/org/secuso/privacyfriendlyexample/database/dao/SampleDataDao.kt (100%) rename {app => compose}/src/main/java/org/secuso/privacyfriendlyexample/database/model/SampleData.kt (100%) rename {app => compose}/src/main/java/org/secuso/privacyfriendlyexample/ui/AppCompatPreferenceActivity.java (100%) rename {app => compose}/src/main/java/org/secuso/privacyfriendlyexample/ui/BaseActivity.kt (100%) rename {app => compose}/src/main/java/org/secuso/privacyfriendlyexample/ui/GameActivity.kt (100%) rename {app => compose}/src/main/java/org/secuso/privacyfriendlyexample/ui/MainActivity.kt (100%) rename {app => compose}/src/main/java/org/secuso/privacyfriendlyexample/ui/SplashActivity.kt (100%) rename {app => compose}/src/main/java/org/secuso/privacyfriendlyexample/ui/TutorialActivity.java (100%) rename {app => compose}/src/main/java/org/secuso/privacyfriendlyexample/ui/adapter/ExpandableListAdapter.java (100%) rename {app => compose}/src/main/java/org/secuso/privacyfriendlyexample/ui/helper/FirstLaunchManager.java (100%) rename {app => compose}/src/main/java/org/secuso/privacyfriendlyexample/ui/viewmodel/MainExampleViewModel.kt (100%) rename {app => compose}/src/main/res/drawable/button_disabled.xml (100%) rename {app => compose}/src/main/res/drawable/button_fullwidth.xml (100%) rename {app => compose}/src/main/res/drawable/button_highlighted.xml (100%) rename {app => compose}/src/main/res/drawable/button_highlighted_2.xml (100%) rename {app => compose}/src/main/res/drawable/button_highlighted_3.xml (100%) rename {app => compose}/src/main/res/drawable/button_highlighted_4.xml (100%) rename {app => compose}/src/main/res/drawable/button_middleblue.xml (100%) rename {app => compose}/src/main/res/drawable/button_normal.xml (100%) rename {app => compose}/src/main/res/drawable/ic_keyboard_arrow_left_black_24dp.xml (100%) rename {app => compose}/src/main/res/drawable/ic_keyboard_arrow_right_black_24dp.xml (100%) rename {app => compose}/src/main/res/drawable/ic_menu_game.xml (100%) rename {app => compose}/src/main/res/drawable/ic_menu_help.xml (100%) rename {app => compose}/src/main/res/drawable/ic_menu_home.xml (100%) rename {app => compose}/src/main/res/drawable/ic_menu_info.xml (100%) rename {app => compose}/src/main/res/drawable/ic_menu_settings.xml (100%) rename {app => compose}/src/main/res/drawable/ic_menu_tutorial.xml (100%) rename {app => compose}/src/main/res/drawable/privacyfriendlyappslogo.png (100%) rename {app => compose}/src/main/res/drawable/secuso_logo_blau_blau.png (100%) rename {app => compose}/src/main/res/drawable/splash_screen.xml (100%) rename {app => compose}/src/main/res/layout/activity_game.xml (100%) rename {app => compose}/src/main/res/layout/activity_main.xml (100%) rename {app => compose}/src/main/res/layout/activity_tutorial.xml (100%) rename {app => compose}/src/main/res/layout/app_bar_main.xml (100%) rename {app => compose}/src/main/res/layout/content_main.xml (100%) rename {app => compose}/src/main/res/layout/fragment_game_mode.xml (100%) rename {app => compose}/src/main/res/layout/list_group.xml (100%) rename {app => compose}/src/main/res/layout/list_item.xml (100%) rename {app => compose}/src/main/res/layout/nav_header_main.xml (100%) rename {app => compose}/src/main/res/layout/toolbar.xml (100%) rename {app => compose}/src/main/res/layout/tutorial_slide1.xml (100%) rename {app => compose}/src/main/res/layout/tutorial_slide2.xml (100%) rename {app => compose}/src/main/res/layout/tutorial_slide3.xml (100%) rename {app => compose}/src/main/res/menu/main.xml (100%) rename {app => compose}/src/main/res/menu/main_drawer.xml (100%) rename {app => compose}/src/main/res/mipmap-hdpi/ic_launcher.png (100%) rename {app => compose}/src/main/res/mipmap-hdpi/ic_splash.png (100%) rename {app => compose}/src/main/res/mipmap-mdpi/ic_launcher.png (100%) rename {app => compose}/src/main/res/mipmap-mdpi/ic_splash.png (100%) rename {app => compose}/src/main/res/mipmap-xhdpi/ic_launcher.png (100%) rename {app => compose}/src/main/res/mipmap-xhdpi/ic_splash.png (100%) rename {app => compose}/src/main/res/mipmap-xxhdpi/ic_launcher.png (100%) rename {app => compose}/src/main/res/mipmap-xxhdpi/ic_splash.png (100%) rename {app => compose}/src/main/res/mipmap-xxxhdpi/ic_launcher.png (100%) rename {app => compose}/src/main/res/mipmap-xxxhdpi/ic_splash.png (100%) rename {app => compose}/src/main/res/values-de/strings.xml (100%) rename {app => compose}/src/main/res/values-v21/styles.xml (100%) rename {app => compose}/src/main/res/values-w820dp/dimens.xml (100%) rename {app => compose}/src/main/res/values/colors.xml (100%) rename {app => compose}/src/main/res/values/dimens.xml (100%) rename {app => compose}/src/main/res/values/drawables.xml (100%) rename {app => compose}/src/main/res/values/strings.xml (100%) rename {app => compose}/src/main/res/values/styles.xml (100%) rename {app => compose}/src/main/res/xml/backup_descriptor.xml (100%) rename {app => compose}/src/test/java/org/secuso/privacyfriendlyexample/ExampleUnitTest.java (100%) diff --git a/app/src/main/res/layout/activity_about.xml b/app/src/main/res/layout/activity_about.xml deleted file mode 100644 index 88fbf26..0000000 --- a/app/src/main/res/layout/activity_about.xml +++ /dev/null @@ -1,145 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/activity_about_with_navigationdrawer.xml b/app/src/main/res/layout/activity_about_with_navigationdrawer.xml deleted file mode 100644 index 4794c53..0000000 --- a/app/src/main/res/layout/activity_about_with_navigationdrawer.xml +++ /dev/null @@ -1,166 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/activity_help.xml b/app/src/main/res/layout/activity_help.xml deleted file mode 100644 index 6ae29e2..0000000 --- a/app/src/main/res/layout/activity_help.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - - - - - - - - - - - \ 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 deleted file mode 100644 index ff2fb40..0000000 --- a/app/src/main/res/layout/activity_settings.xml +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/xml/pref_general.xml b/app/src/main/res/xml/pref_general.xml deleted file mode 100644 index fd40b78..0000000 --- a/app/src/main/res/xml/pref_general.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - - diff --git a/app/src/main/res/xml/pref_headers.xml b/app/src/main/res/xml/pref_headers.xml deleted file mode 100644 index b8a6e96..0000000 --- a/app/src/main/res/xml/pref_headers.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - -
- - diff --git a/app/.gitignore b/compose/.gitignore similarity index 100% rename from app/.gitignore rename to compose/.gitignore diff --git a/app/build.gradle b/compose/build.gradle similarity index 100% rename from app/build.gradle rename to compose/build.gradle diff --git a/app/proguard-rules.pro b/compose/proguard-rules.pro similarity index 100% rename from app/proguard-rules.pro rename to compose/proguard-rules.pro diff --git a/app/src/androidTest/java/org/secuso/privacyfriendlyexample/ApplicationTest.java b/compose/src/androidTest/java/org/secuso/privacyfriendlyexample/ApplicationTest.java similarity index 100% rename from app/src/androidTest/java/org/secuso/privacyfriendlyexample/ApplicationTest.java rename to compose/src/androidTest/java/org/secuso/privacyfriendlyexample/ApplicationTest.java diff --git a/app/src/main/AndroidManifest.xml b/compose/src/main/AndroidManifest.xml similarity index 100% rename from app/src/main/AndroidManifest.xml rename to compose/src/main/AndroidManifest.xml diff --git a/app/src/main/java/org/secuso/privacyfriendlyexample/PFExample.kt b/compose/src/main/java/org/secuso/privacyfriendlyexample/PFExample.kt similarity index 100% rename from app/src/main/java/org/secuso/privacyfriendlyexample/PFExample.kt rename to compose/src/main/java/org/secuso/privacyfriendlyexample/PFExample.kt diff --git a/app/src/main/java/org/secuso/privacyfriendlyexample/PFSettings.kt b/compose/src/main/java/org/secuso/privacyfriendlyexample/PFSettings.kt similarity index 100% rename from app/src/main/java/org/secuso/privacyfriendlyexample/PFSettings.kt rename to compose/src/main/java/org/secuso/privacyfriendlyexample/PFSettings.kt diff --git a/app/src/main/java/org/secuso/privacyfriendlyexample/database/AppDatabase.kt b/compose/src/main/java/org/secuso/privacyfriendlyexample/database/AppDatabase.kt similarity index 100% rename from app/src/main/java/org/secuso/privacyfriendlyexample/database/AppDatabase.kt rename to compose/src/main/java/org/secuso/privacyfriendlyexample/database/AppDatabase.kt diff --git a/app/src/main/java/org/secuso/privacyfriendlyexample/database/DatabaseExporter.java b/compose/src/main/java/org/secuso/privacyfriendlyexample/database/DatabaseExporter.java similarity index 100% rename from app/src/main/java/org/secuso/privacyfriendlyexample/database/DatabaseExporter.java rename to compose/src/main/java/org/secuso/privacyfriendlyexample/database/DatabaseExporter.java diff --git a/app/src/main/java/org/secuso/privacyfriendlyexample/database/DatabaseImporter.java b/compose/src/main/java/org/secuso/privacyfriendlyexample/database/DatabaseImporter.java similarity index 100% rename from app/src/main/java/org/secuso/privacyfriendlyexample/database/DatabaseImporter.java rename to compose/src/main/java/org/secuso/privacyfriendlyexample/database/DatabaseImporter.java diff --git a/app/src/main/java/org/secuso/privacyfriendlyexample/database/dao/SampleDataDao.kt b/compose/src/main/java/org/secuso/privacyfriendlyexample/database/dao/SampleDataDao.kt similarity index 100% rename from app/src/main/java/org/secuso/privacyfriendlyexample/database/dao/SampleDataDao.kt rename to compose/src/main/java/org/secuso/privacyfriendlyexample/database/dao/SampleDataDao.kt diff --git a/app/src/main/java/org/secuso/privacyfriendlyexample/database/model/SampleData.kt b/compose/src/main/java/org/secuso/privacyfriendlyexample/database/model/SampleData.kt similarity index 100% rename from app/src/main/java/org/secuso/privacyfriendlyexample/database/model/SampleData.kt rename to compose/src/main/java/org/secuso/privacyfriendlyexample/database/model/SampleData.kt diff --git a/app/src/main/java/org/secuso/privacyfriendlyexample/ui/AppCompatPreferenceActivity.java b/compose/src/main/java/org/secuso/privacyfriendlyexample/ui/AppCompatPreferenceActivity.java similarity index 100% rename from app/src/main/java/org/secuso/privacyfriendlyexample/ui/AppCompatPreferenceActivity.java rename to compose/src/main/java/org/secuso/privacyfriendlyexample/ui/AppCompatPreferenceActivity.java diff --git a/app/src/main/java/org/secuso/privacyfriendlyexample/ui/BaseActivity.kt b/compose/src/main/java/org/secuso/privacyfriendlyexample/ui/BaseActivity.kt similarity index 100% rename from app/src/main/java/org/secuso/privacyfriendlyexample/ui/BaseActivity.kt rename to compose/src/main/java/org/secuso/privacyfriendlyexample/ui/BaseActivity.kt diff --git a/app/src/main/java/org/secuso/privacyfriendlyexample/ui/GameActivity.kt b/compose/src/main/java/org/secuso/privacyfriendlyexample/ui/GameActivity.kt similarity index 100% rename from app/src/main/java/org/secuso/privacyfriendlyexample/ui/GameActivity.kt rename to compose/src/main/java/org/secuso/privacyfriendlyexample/ui/GameActivity.kt diff --git a/app/src/main/java/org/secuso/privacyfriendlyexample/ui/MainActivity.kt b/compose/src/main/java/org/secuso/privacyfriendlyexample/ui/MainActivity.kt similarity index 100% rename from app/src/main/java/org/secuso/privacyfriendlyexample/ui/MainActivity.kt rename to compose/src/main/java/org/secuso/privacyfriendlyexample/ui/MainActivity.kt diff --git a/app/src/main/java/org/secuso/privacyfriendlyexample/ui/SplashActivity.kt b/compose/src/main/java/org/secuso/privacyfriendlyexample/ui/SplashActivity.kt similarity index 100% rename from app/src/main/java/org/secuso/privacyfriendlyexample/ui/SplashActivity.kt rename to compose/src/main/java/org/secuso/privacyfriendlyexample/ui/SplashActivity.kt diff --git a/app/src/main/java/org/secuso/privacyfriendlyexample/ui/TutorialActivity.java b/compose/src/main/java/org/secuso/privacyfriendlyexample/ui/TutorialActivity.java similarity index 100% rename from app/src/main/java/org/secuso/privacyfriendlyexample/ui/TutorialActivity.java rename to compose/src/main/java/org/secuso/privacyfriendlyexample/ui/TutorialActivity.java diff --git a/app/src/main/java/org/secuso/privacyfriendlyexample/ui/adapter/ExpandableListAdapter.java b/compose/src/main/java/org/secuso/privacyfriendlyexample/ui/adapter/ExpandableListAdapter.java similarity index 100% rename from app/src/main/java/org/secuso/privacyfriendlyexample/ui/adapter/ExpandableListAdapter.java rename to compose/src/main/java/org/secuso/privacyfriendlyexample/ui/adapter/ExpandableListAdapter.java diff --git a/app/src/main/java/org/secuso/privacyfriendlyexample/ui/helper/FirstLaunchManager.java b/compose/src/main/java/org/secuso/privacyfriendlyexample/ui/helper/FirstLaunchManager.java similarity index 100% rename from app/src/main/java/org/secuso/privacyfriendlyexample/ui/helper/FirstLaunchManager.java rename to compose/src/main/java/org/secuso/privacyfriendlyexample/ui/helper/FirstLaunchManager.java diff --git a/app/src/main/java/org/secuso/privacyfriendlyexample/ui/viewmodel/MainExampleViewModel.kt b/compose/src/main/java/org/secuso/privacyfriendlyexample/ui/viewmodel/MainExampleViewModel.kt similarity index 100% rename from app/src/main/java/org/secuso/privacyfriendlyexample/ui/viewmodel/MainExampleViewModel.kt rename to compose/src/main/java/org/secuso/privacyfriendlyexample/ui/viewmodel/MainExampleViewModel.kt diff --git a/app/src/main/res/drawable/button_disabled.xml b/compose/src/main/res/drawable/button_disabled.xml similarity index 100% rename from app/src/main/res/drawable/button_disabled.xml rename to compose/src/main/res/drawable/button_disabled.xml diff --git a/app/src/main/res/drawable/button_fullwidth.xml b/compose/src/main/res/drawable/button_fullwidth.xml similarity index 100% rename from app/src/main/res/drawable/button_fullwidth.xml rename to compose/src/main/res/drawable/button_fullwidth.xml diff --git a/app/src/main/res/drawable/button_highlighted.xml b/compose/src/main/res/drawable/button_highlighted.xml similarity index 100% rename from app/src/main/res/drawable/button_highlighted.xml rename to compose/src/main/res/drawable/button_highlighted.xml diff --git a/app/src/main/res/drawable/button_highlighted_2.xml b/compose/src/main/res/drawable/button_highlighted_2.xml similarity index 100% rename from app/src/main/res/drawable/button_highlighted_2.xml rename to compose/src/main/res/drawable/button_highlighted_2.xml diff --git a/app/src/main/res/drawable/button_highlighted_3.xml b/compose/src/main/res/drawable/button_highlighted_3.xml similarity index 100% rename from app/src/main/res/drawable/button_highlighted_3.xml rename to compose/src/main/res/drawable/button_highlighted_3.xml diff --git a/app/src/main/res/drawable/button_highlighted_4.xml b/compose/src/main/res/drawable/button_highlighted_4.xml similarity index 100% rename from app/src/main/res/drawable/button_highlighted_4.xml rename to compose/src/main/res/drawable/button_highlighted_4.xml diff --git a/app/src/main/res/drawable/button_middleblue.xml b/compose/src/main/res/drawable/button_middleblue.xml similarity index 100% rename from app/src/main/res/drawable/button_middleblue.xml rename to compose/src/main/res/drawable/button_middleblue.xml diff --git a/app/src/main/res/drawable/button_normal.xml b/compose/src/main/res/drawable/button_normal.xml similarity index 100% rename from app/src/main/res/drawable/button_normal.xml rename to compose/src/main/res/drawable/button_normal.xml diff --git a/app/src/main/res/drawable/ic_keyboard_arrow_left_black_24dp.xml b/compose/src/main/res/drawable/ic_keyboard_arrow_left_black_24dp.xml similarity index 100% rename from app/src/main/res/drawable/ic_keyboard_arrow_left_black_24dp.xml rename to compose/src/main/res/drawable/ic_keyboard_arrow_left_black_24dp.xml diff --git a/app/src/main/res/drawable/ic_keyboard_arrow_right_black_24dp.xml b/compose/src/main/res/drawable/ic_keyboard_arrow_right_black_24dp.xml similarity index 100% rename from app/src/main/res/drawable/ic_keyboard_arrow_right_black_24dp.xml rename to compose/src/main/res/drawable/ic_keyboard_arrow_right_black_24dp.xml diff --git a/app/src/main/res/drawable/ic_menu_game.xml b/compose/src/main/res/drawable/ic_menu_game.xml similarity index 100% rename from app/src/main/res/drawable/ic_menu_game.xml rename to compose/src/main/res/drawable/ic_menu_game.xml diff --git a/app/src/main/res/drawable/ic_menu_help.xml b/compose/src/main/res/drawable/ic_menu_help.xml similarity index 100% rename from app/src/main/res/drawable/ic_menu_help.xml rename to compose/src/main/res/drawable/ic_menu_help.xml diff --git a/app/src/main/res/drawable/ic_menu_home.xml b/compose/src/main/res/drawable/ic_menu_home.xml similarity index 100% rename from app/src/main/res/drawable/ic_menu_home.xml rename to compose/src/main/res/drawable/ic_menu_home.xml diff --git a/app/src/main/res/drawable/ic_menu_info.xml b/compose/src/main/res/drawable/ic_menu_info.xml similarity index 100% rename from app/src/main/res/drawable/ic_menu_info.xml rename to compose/src/main/res/drawable/ic_menu_info.xml diff --git a/app/src/main/res/drawable/ic_menu_settings.xml b/compose/src/main/res/drawable/ic_menu_settings.xml similarity index 100% rename from app/src/main/res/drawable/ic_menu_settings.xml rename to compose/src/main/res/drawable/ic_menu_settings.xml diff --git a/app/src/main/res/drawable/ic_menu_tutorial.xml b/compose/src/main/res/drawable/ic_menu_tutorial.xml similarity index 100% rename from app/src/main/res/drawable/ic_menu_tutorial.xml rename to compose/src/main/res/drawable/ic_menu_tutorial.xml diff --git a/app/src/main/res/drawable/privacyfriendlyappslogo.png b/compose/src/main/res/drawable/privacyfriendlyappslogo.png similarity index 100% rename from app/src/main/res/drawable/privacyfriendlyappslogo.png rename to compose/src/main/res/drawable/privacyfriendlyappslogo.png diff --git a/app/src/main/res/drawable/secuso_logo_blau_blau.png b/compose/src/main/res/drawable/secuso_logo_blau_blau.png similarity index 100% rename from app/src/main/res/drawable/secuso_logo_blau_blau.png rename to compose/src/main/res/drawable/secuso_logo_blau_blau.png diff --git a/app/src/main/res/drawable/splash_screen.xml b/compose/src/main/res/drawable/splash_screen.xml similarity index 100% rename from app/src/main/res/drawable/splash_screen.xml rename to compose/src/main/res/drawable/splash_screen.xml diff --git a/app/src/main/res/layout/activity_game.xml b/compose/src/main/res/layout/activity_game.xml similarity index 100% rename from app/src/main/res/layout/activity_game.xml rename to compose/src/main/res/layout/activity_game.xml diff --git a/app/src/main/res/layout/activity_main.xml b/compose/src/main/res/layout/activity_main.xml similarity index 100% rename from app/src/main/res/layout/activity_main.xml rename to compose/src/main/res/layout/activity_main.xml diff --git a/app/src/main/res/layout/activity_tutorial.xml b/compose/src/main/res/layout/activity_tutorial.xml similarity index 100% rename from app/src/main/res/layout/activity_tutorial.xml rename to compose/src/main/res/layout/activity_tutorial.xml diff --git a/app/src/main/res/layout/app_bar_main.xml b/compose/src/main/res/layout/app_bar_main.xml similarity index 100% rename from app/src/main/res/layout/app_bar_main.xml rename to compose/src/main/res/layout/app_bar_main.xml diff --git a/app/src/main/res/layout/content_main.xml b/compose/src/main/res/layout/content_main.xml similarity index 100% rename from app/src/main/res/layout/content_main.xml rename to compose/src/main/res/layout/content_main.xml diff --git a/app/src/main/res/layout/fragment_game_mode.xml b/compose/src/main/res/layout/fragment_game_mode.xml similarity index 100% rename from app/src/main/res/layout/fragment_game_mode.xml rename to compose/src/main/res/layout/fragment_game_mode.xml diff --git a/app/src/main/res/layout/list_group.xml b/compose/src/main/res/layout/list_group.xml similarity index 100% rename from app/src/main/res/layout/list_group.xml rename to compose/src/main/res/layout/list_group.xml diff --git a/app/src/main/res/layout/list_item.xml b/compose/src/main/res/layout/list_item.xml similarity index 100% rename from app/src/main/res/layout/list_item.xml rename to compose/src/main/res/layout/list_item.xml diff --git a/app/src/main/res/layout/nav_header_main.xml b/compose/src/main/res/layout/nav_header_main.xml similarity index 100% rename from app/src/main/res/layout/nav_header_main.xml rename to compose/src/main/res/layout/nav_header_main.xml diff --git a/app/src/main/res/layout/toolbar.xml b/compose/src/main/res/layout/toolbar.xml similarity index 100% rename from app/src/main/res/layout/toolbar.xml rename to compose/src/main/res/layout/toolbar.xml diff --git a/app/src/main/res/layout/tutorial_slide1.xml b/compose/src/main/res/layout/tutorial_slide1.xml similarity index 100% rename from app/src/main/res/layout/tutorial_slide1.xml rename to compose/src/main/res/layout/tutorial_slide1.xml diff --git a/app/src/main/res/layout/tutorial_slide2.xml b/compose/src/main/res/layout/tutorial_slide2.xml similarity index 100% rename from app/src/main/res/layout/tutorial_slide2.xml rename to compose/src/main/res/layout/tutorial_slide2.xml diff --git a/app/src/main/res/layout/tutorial_slide3.xml b/compose/src/main/res/layout/tutorial_slide3.xml similarity index 100% rename from app/src/main/res/layout/tutorial_slide3.xml rename to compose/src/main/res/layout/tutorial_slide3.xml diff --git a/app/src/main/res/menu/main.xml b/compose/src/main/res/menu/main.xml similarity index 100% rename from app/src/main/res/menu/main.xml rename to compose/src/main/res/menu/main.xml diff --git a/app/src/main/res/menu/main_drawer.xml b/compose/src/main/res/menu/main_drawer.xml similarity index 100% rename from app/src/main/res/menu/main_drawer.xml rename to compose/src/main/res/menu/main_drawer.xml diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/compose/src/main/res/mipmap-hdpi/ic_launcher.png similarity index 100% rename from app/src/main/res/mipmap-hdpi/ic_launcher.png rename to compose/src/main/res/mipmap-hdpi/ic_launcher.png diff --git a/app/src/main/res/mipmap-hdpi/ic_splash.png b/compose/src/main/res/mipmap-hdpi/ic_splash.png similarity index 100% rename from app/src/main/res/mipmap-hdpi/ic_splash.png rename to compose/src/main/res/mipmap-hdpi/ic_splash.png diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/compose/src/main/res/mipmap-mdpi/ic_launcher.png similarity index 100% rename from app/src/main/res/mipmap-mdpi/ic_launcher.png rename to compose/src/main/res/mipmap-mdpi/ic_launcher.png diff --git a/app/src/main/res/mipmap-mdpi/ic_splash.png b/compose/src/main/res/mipmap-mdpi/ic_splash.png similarity index 100% rename from app/src/main/res/mipmap-mdpi/ic_splash.png rename to compose/src/main/res/mipmap-mdpi/ic_splash.png diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/compose/src/main/res/mipmap-xhdpi/ic_launcher.png similarity index 100% rename from app/src/main/res/mipmap-xhdpi/ic_launcher.png rename to compose/src/main/res/mipmap-xhdpi/ic_launcher.png diff --git a/app/src/main/res/mipmap-xhdpi/ic_splash.png b/compose/src/main/res/mipmap-xhdpi/ic_splash.png similarity index 100% rename from app/src/main/res/mipmap-xhdpi/ic_splash.png rename to compose/src/main/res/mipmap-xhdpi/ic_splash.png diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/compose/src/main/res/mipmap-xxhdpi/ic_launcher.png similarity index 100% rename from app/src/main/res/mipmap-xxhdpi/ic_launcher.png rename to compose/src/main/res/mipmap-xxhdpi/ic_launcher.png diff --git a/app/src/main/res/mipmap-xxhdpi/ic_splash.png b/compose/src/main/res/mipmap-xxhdpi/ic_splash.png similarity index 100% rename from app/src/main/res/mipmap-xxhdpi/ic_splash.png rename to compose/src/main/res/mipmap-xxhdpi/ic_splash.png diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/compose/src/main/res/mipmap-xxxhdpi/ic_launcher.png similarity index 100% rename from app/src/main/res/mipmap-xxxhdpi/ic_launcher.png rename to compose/src/main/res/mipmap-xxxhdpi/ic_launcher.png diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_splash.png b/compose/src/main/res/mipmap-xxxhdpi/ic_splash.png similarity index 100% rename from app/src/main/res/mipmap-xxxhdpi/ic_splash.png rename to compose/src/main/res/mipmap-xxxhdpi/ic_splash.png diff --git a/app/src/main/res/values-de/strings.xml b/compose/src/main/res/values-de/strings.xml similarity index 100% rename from app/src/main/res/values-de/strings.xml rename to compose/src/main/res/values-de/strings.xml diff --git a/app/src/main/res/values-v21/styles.xml b/compose/src/main/res/values-v21/styles.xml similarity index 100% rename from app/src/main/res/values-v21/styles.xml rename to compose/src/main/res/values-v21/styles.xml diff --git a/app/src/main/res/values-w820dp/dimens.xml b/compose/src/main/res/values-w820dp/dimens.xml similarity index 100% rename from app/src/main/res/values-w820dp/dimens.xml rename to compose/src/main/res/values-w820dp/dimens.xml diff --git a/app/src/main/res/values/colors.xml b/compose/src/main/res/values/colors.xml similarity index 100% rename from app/src/main/res/values/colors.xml rename to compose/src/main/res/values/colors.xml diff --git a/app/src/main/res/values/dimens.xml b/compose/src/main/res/values/dimens.xml similarity index 100% rename from app/src/main/res/values/dimens.xml rename to compose/src/main/res/values/dimens.xml diff --git a/app/src/main/res/values/drawables.xml b/compose/src/main/res/values/drawables.xml similarity index 100% rename from app/src/main/res/values/drawables.xml rename to compose/src/main/res/values/drawables.xml diff --git a/app/src/main/res/values/strings.xml b/compose/src/main/res/values/strings.xml similarity index 100% rename from app/src/main/res/values/strings.xml rename to compose/src/main/res/values/strings.xml diff --git a/app/src/main/res/values/styles.xml b/compose/src/main/res/values/styles.xml similarity index 100% rename from app/src/main/res/values/styles.xml rename to compose/src/main/res/values/styles.xml diff --git a/app/src/main/res/xml/backup_descriptor.xml b/compose/src/main/res/xml/backup_descriptor.xml similarity index 100% rename from app/src/main/res/xml/backup_descriptor.xml rename to compose/src/main/res/xml/backup_descriptor.xml diff --git a/app/src/test/java/org/secuso/privacyfriendlyexample/ExampleUnitTest.java b/compose/src/test/java/org/secuso/privacyfriendlyexample/ExampleUnitTest.java similarity index 100% rename from app/src/test/java/org/secuso/privacyfriendlyexample/ExampleUnitTest.java rename to compose/src/test/java/org/secuso/privacyfriendlyexample/ExampleUnitTest.java diff --git a/settings.gradle b/settings.gradle index 3e6d220..daff0d3 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,2 +1,2 @@ -include(":app") +include(':compose') includeBuild("libs/pfa-core") From 98bf17f83694e2e56115e1fadfcca8707f5fb8aa Mon Sep 17 00:00:00 2001 From: Patrick Schneider Date: Fri, 21 Jun 2024 10:30:50 +0200 Subject: [PATCH 5/6] [refactor] introduces pfa-core library. splits example app into two modules, one using jetpack-compose, the other the common view approach. Introduces somewhat usage of the correct PFATheme. --- compose/build.gradle | 2 + compose/src/main/AndroidManifest.xml | 5 +- .../PFApplicationData.kt | 122 +++++++++++++++ .../privacyfriendlyexample/PFExample.kt | 48 ++---- .../privacyfriendlyexample/PFSettings.kt | 54 ------- .../database/AppDatabase.kt | 5 +- .../privacyfriendlyexample/ui/BaseActivity.kt | 128 +++------------ .../privacyfriendlyexample/ui/GameActivity.kt | 79 +++++----- .../privacyfriendlyexample/ui/MainActivity.kt | 26 +-- compose/src/main/res/layout/activity_game.xml | 2 - compose/src/main/res/layout/activity_main.xml | 73 +++------ compose/src/main/res/menu/main_drawer.xml | 2 +- settings.gradle | 1 + view/.gitignore | 1 + view/build.gradle | 75 +++++++++ view/proguard-rules.pro | 21 +++ view/src/main/AndroidManifest.xml | 90 +++++++++++ .../PFApplicationData.kt | 122 +++++++++++++++ .../privacyfriendlyexample/PFExample.kt | 17 ++ .../database/AppDatabase.kt | 59 +++++++ .../database/DatabaseExporter.java | 142 +++++++++++++++++ .../database/DatabaseImporter.java | 35 +++++ .../database/dao/SampleDataDao.kt | 68 ++++++++ .../database/model/SampleData.kt | 59 +++++++ .../privacyfriendlyexample/ui/BaseActivity.kt | 114 ++++++++++++++ .../privacyfriendlyexample/ui/GameActivity.kt | 148 ++++++++++++++++++ .../privacyfriendlyexample/ui/MainActivity.kt | 65 ++++++++ .../ui/adapter/ExpandableListAdapter.java | 116 ++++++++++++++ .../ui/helper/FirstLaunchManager.java | 45 ++++++ .../ui/viewmodel/MainExampleViewModel.kt | 69 ++++++++ .../src/main/res/drawable/button_disabled.xml | 9 ++ .../main/res/drawable/button_fullwidth.xml | 9 ++ .../main/res/drawable/button_highlighted.xml | 11 ++ .../res/drawable/button_highlighted_2.xml | 10 ++ .../res/drawable/button_highlighted_3.xml | 10 ++ .../res/drawable/button_highlighted_4.xml | 10 ++ .../main/res/drawable/button_middleblue.xml | 9 ++ view/src/main/res/drawable/button_normal.xml | 9 ++ .../ic_keyboard_arrow_left_black_24dp.xml | 9 ++ .../ic_keyboard_arrow_right_black_24dp.xml | 9 ++ view/src/main/res/drawable/ic_menu_game.xml | 9 ++ view/src/main/res/drawable/ic_menu_help.xml | 9 ++ view/src/main/res/drawable/ic_menu_home.xml | 9 ++ view/src/main/res/drawable/ic_menu_info.xml | 9 ++ .../main/res/drawable/ic_menu_settings.xml | 10 ++ .../res/drawable/privacyfriendlyappslogo.png | Bin 0 -> 17496 bytes .../res/drawable/secuso_logo_blau_blau.png | Bin 0 -> 57185 bytes view/src/main/res/drawable/splash_screen.xml | 10 ++ view/src/main/res/layout/activity_game.xml | 101 ++++++++++++ view/src/main/res/layout/activity_main.xml | 36 +++++ .../src/main/res/layout/activity_tutorial.xml | 52 ++++++ view/src/main/res/layout/app_bar_main.xml | 21 +++ view/src/main/res/layout/content_main.xml | 117 ++++++++++++++ .../main/res/layout/fragment_game_mode.xml | 16 ++ view/src/main/res/layout/list_group.xml | 15 ++ view/src/main/res/layout/list_item.xml | 16 ++ view/src/main/res/layout/nav_header_main.xml | 40 +++++ view/src/main/res/layout/toolbar.xml | 11 ++ view/src/main/res/layout/tutorial_slide1.xml | 42 +++++ view/src/main/res/layout/tutorial_slide2.xml | 43 +++++ view/src/main/res/layout/tutorial_slide3.xml | 42 +++++ view/src/main/res/menu/main.xml | 9 ++ view/src/main/res/menu/main_drawer.xml | 37 +++++ view/src/main/res/mipmap-hdpi/ic_launcher.png | Bin 0 -> 3632 bytes view/src/main/res/mipmap-hdpi/ic_splash.png | Bin 0 -> 3110 bytes view/src/main/res/mipmap-mdpi/ic_launcher.png | Bin 0 -> 2344 bytes view/src/main/res/mipmap-mdpi/ic_splash.png | Bin 0 -> 2250 bytes .../src/main/res/mipmap-xhdpi/ic_launcher.png | Bin 0 -> 4692 bytes view/src/main/res/mipmap-xhdpi/ic_splash.png | Bin 0 -> 3995 bytes .../main/res/mipmap-xxhdpi/ic_launcher.png | Bin 0 -> 7270 bytes view/src/main/res/mipmap-xxhdpi/ic_splash.png | Bin 0 -> 6378 bytes .../main/res/mipmap-xxxhdpi/ic_launcher.png | Bin 0 -> 9904 bytes .../src/main/res/mipmap-xxxhdpi/ic_splash.png | Bin 0 -> 8556 bytes view/src/main/res/values-de/strings.xml | 82 ++++++++++ view/src/main/res/values-v21/styles.xml | 3 + view/src/main/res/values-w820dp/dimens.xml | 6 + view/src/main/res/values/colors.xml | 35 +++++ view/src/main/res/values/dimens.xml | 18 +++ view/src/main/res/values/drawables.xml | 8 + view/src/main/res/values/strings.xml | 83 ++++++++++ view/src/main/res/values/styles.xml | 7 + view/src/main/res/xml/backup_descriptor.xml | 7 + 82 files changed, 2492 insertions(+), 299 deletions(-) create mode 100644 compose/src/main/java/org/secuso/privacyfriendlyexample/PFApplicationData.kt delete mode 100644 compose/src/main/java/org/secuso/privacyfriendlyexample/PFSettings.kt create mode 100644 view/.gitignore create mode 100644 view/build.gradle create mode 100644 view/proguard-rules.pro create mode 100644 view/src/main/AndroidManifest.xml create mode 100644 view/src/main/java/org/secuso/privacyfriendlyexample/PFApplicationData.kt create mode 100644 view/src/main/java/org/secuso/privacyfriendlyexample/PFExample.kt create mode 100644 view/src/main/java/org/secuso/privacyfriendlyexample/database/AppDatabase.kt create mode 100644 view/src/main/java/org/secuso/privacyfriendlyexample/database/DatabaseExporter.java create mode 100644 view/src/main/java/org/secuso/privacyfriendlyexample/database/DatabaseImporter.java create mode 100644 view/src/main/java/org/secuso/privacyfriendlyexample/database/dao/SampleDataDao.kt create mode 100644 view/src/main/java/org/secuso/privacyfriendlyexample/database/model/SampleData.kt create mode 100644 view/src/main/java/org/secuso/privacyfriendlyexample/ui/BaseActivity.kt create mode 100644 view/src/main/java/org/secuso/privacyfriendlyexample/ui/GameActivity.kt create mode 100644 view/src/main/java/org/secuso/privacyfriendlyexample/ui/MainActivity.kt create mode 100644 view/src/main/java/org/secuso/privacyfriendlyexample/ui/adapter/ExpandableListAdapter.java create mode 100644 view/src/main/java/org/secuso/privacyfriendlyexample/ui/helper/FirstLaunchManager.java create mode 100644 view/src/main/java/org/secuso/privacyfriendlyexample/ui/viewmodel/MainExampleViewModel.kt create mode 100644 view/src/main/res/drawable/button_disabled.xml create mode 100644 view/src/main/res/drawable/button_fullwidth.xml create mode 100644 view/src/main/res/drawable/button_highlighted.xml create mode 100644 view/src/main/res/drawable/button_highlighted_2.xml create mode 100644 view/src/main/res/drawable/button_highlighted_3.xml create mode 100644 view/src/main/res/drawable/button_highlighted_4.xml create mode 100644 view/src/main/res/drawable/button_middleblue.xml create mode 100644 view/src/main/res/drawable/button_normal.xml create mode 100644 view/src/main/res/drawable/ic_keyboard_arrow_left_black_24dp.xml create mode 100644 view/src/main/res/drawable/ic_keyboard_arrow_right_black_24dp.xml create mode 100644 view/src/main/res/drawable/ic_menu_game.xml create mode 100644 view/src/main/res/drawable/ic_menu_help.xml create mode 100644 view/src/main/res/drawable/ic_menu_home.xml create mode 100644 view/src/main/res/drawable/ic_menu_info.xml create mode 100644 view/src/main/res/drawable/ic_menu_settings.xml create mode 100644 view/src/main/res/drawable/privacyfriendlyappslogo.png create mode 100644 view/src/main/res/drawable/secuso_logo_blau_blau.png create mode 100644 view/src/main/res/drawable/splash_screen.xml create mode 100644 view/src/main/res/layout/activity_game.xml create mode 100644 view/src/main/res/layout/activity_main.xml create mode 100644 view/src/main/res/layout/activity_tutorial.xml create mode 100644 view/src/main/res/layout/app_bar_main.xml create mode 100644 view/src/main/res/layout/content_main.xml create mode 100644 view/src/main/res/layout/fragment_game_mode.xml create mode 100644 view/src/main/res/layout/list_group.xml create mode 100644 view/src/main/res/layout/list_item.xml create mode 100644 view/src/main/res/layout/nav_header_main.xml create mode 100644 view/src/main/res/layout/toolbar.xml create mode 100644 view/src/main/res/layout/tutorial_slide1.xml create mode 100644 view/src/main/res/layout/tutorial_slide2.xml create mode 100644 view/src/main/res/layout/tutorial_slide3.xml create mode 100644 view/src/main/res/menu/main.xml create mode 100644 view/src/main/res/menu/main_drawer.xml create mode 100644 view/src/main/res/mipmap-hdpi/ic_launcher.png create mode 100644 view/src/main/res/mipmap-hdpi/ic_splash.png create mode 100644 view/src/main/res/mipmap-mdpi/ic_launcher.png create mode 100644 view/src/main/res/mipmap-mdpi/ic_splash.png create mode 100644 view/src/main/res/mipmap-xhdpi/ic_launcher.png create mode 100644 view/src/main/res/mipmap-xhdpi/ic_splash.png create mode 100644 view/src/main/res/mipmap-xxhdpi/ic_launcher.png create mode 100644 view/src/main/res/mipmap-xxhdpi/ic_splash.png create mode 100644 view/src/main/res/mipmap-xxxhdpi/ic_launcher.png create mode 100644 view/src/main/res/mipmap-xxxhdpi/ic_splash.png create mode 100644 view/src/main/res/values-de/strings.xml create mode 100644 view/src/main/res/values-v21/styles.xml create mode 100644 view/src/main/res/values-w820dp/dimens.xml create mode 100644 view/src/main/res/values/colors.xml create mode 100644 view/src/main/res/values/dimens.xml create mode 100644 view/src/main/res/values/drawables.xml create mode 100644 view/src/main/res/values/strings.xml create mode 100644 view/src/main/res/values/styles.xml create mode 100644 view/src/main/res/xml/backup_descriptor.xml diff --git a/compose/build.gradle b/compose/build.gradle index 82fb399..318a6e0 100644 --- a/compose/build.gradle +++ b/compose/build.gradle @@ -69,6 +69,8 @@ dependencies { implementation("org.secuso.pfa-core:ui-compose") implementation("org.secuso.pfa-core:model") implementation("androidx.compose.runtime:runtime:1.6.4") + implementation("androidx.compose.ui:ui-viewbinding:1.6.7") + implementation 'androidx.activity:activity-compose:1.9.0' } repositories { diff --git a/compose/src/main/AndroidManifest.xml b/compose/src/main/AndroidManifest.xml index ad5ff6f..82ecadb 100644 --- a/compose/src/main/AndroidManifest.xml +++ b/compose/src/main/AndroidManifest.xml @@ -19,7 +19,7 @@ android:theme="@style/AppTheme" android:fullBackupContent="@xml/backup_descriptor"> @@ -27,7 +27,8 @@ - + private set + lateinit var exampleSwitch: Preferable + private set + lateinit var firstTimeLaunch: Preferable + private set + + private val preferences = appPreferences(context) { + preferences { + firstTimeLaunch = PreferenceFirstTimeLaunch().build().invoke(this) + } + settings { + category("Example Category") { + exampleSwitch = switch { + key = "pref_example_switch" + title { resource(R.string.pref_example_switch) } + summary { resource(R.string.pref_example_summary) } + default = false + backup = true + } + } + category("Design") { + theme = SettingThemeSelector().build().invoke(this) + } + category("Legal") { + menu("Legal") { + setting { + menu { + title { literal("Legal") } + } + } + content { + + } + } + } + } + } + + private val help = Help.build(context) { + item { + title { resource(R.string.help_whatis) } + description { resource(R.string.help_whatis_answer) } + } + item { + title { resource(R.string.help_feature_one) } + description { resource(R.string.help_feature_one_answer) } + } + item { + title { resource(R.string.help_privacy) } + description { resource(R.string.help_privacy_answer) } + } + item { + title { resource(R.string.help_permission) } + description { resource(R.string.help_permission_answer) } + } + } + + 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(org.secuso.pfacore.R.string.about_github) + ) + + private val tutorial = buildTutorial { + stage { + title = context.getString(R.string.slide1_heading) + images = listOf(R.mipmap.ic_splash) + description = context.getString(R.string.slide1_text) + } + stage { + title = context.getString(R.string.slide2_heading) + images = listOf(R.mipmap.ic_splash) + description = context.getString(R.string.slide2_text) + } + stage { + title = context.getString(R.string.slide3_heading) + images = listOf(R.mipmap.ic_splash) + description = context.getString(R.string.slide3_text) + } + } + + val data = PFData( + about = about, + help = help, + settings = preferences.settings, + tutorial = tutorial, + theme = theme.state.map { Theme.valueOf(it) }, + firstLaunch = firstTimeLaunch + ) + + companion object { + private var _instance: PFApplicationData? = null + fun instance(context: Context): PFApplicationData { + if (_instance == null) { + _instance = PFApplicationData(context) + } + return _instance!! + } + + } +} + + diff --git a/compose/src/main/java/org/secuso/privacyfriendlyexample/PFExample.kt b/compose/src/main/java/org/secuso/privacyfriendlyexample/PFExample.kt index 559057d..ec94548 100644 --- a/compose/src/main/java/org/secuso/privacyfriendlyexample/PFExample.kt +++ b/compose/src/main/java/org/secuso/privacyfriendlyexample/PFExample.kt @@ -1,48 +1,18 @@ package org.secuso.privacyfriendlyexample -import androidx.lifecycle.LiveData +import android.app.Activity import org.secuso.pfacore.application.PFApplication -import org.secuso.pfacore.application.PFDatabase -import org.secuso.pfacore.model.about.About -import org.secuso.pfacore.model.settings.ISettings -import org.secuso.pfacore.ui.compose.help.Help +import org.secuso.pfacore.application.PFData import org.secuso.privacyfriendlyexample.database.AppDatabase +import org.secuso.privacyfriendlyexample.ui.MainActivity class PFExample: PFApplication() { - override val applicationName: String + override val name: String get() = getString(R.string.app_name) - override val lightMode: LiveData - get() = PFSettings(applicationContext).lightMode - override val database: PFDatabase - get() = AppDatabase.getInstance(applicationContext) - override val about: About - get() = About( - name = getString(R.string.app_name), - version = BuildConfig.VERSION_NAME, - authors = getString(R.string.about_author_names), - repo = getString(org.secuso.pfacore.R.string.about_github) - ) - - override val help - get() = Help.build(applicationContext) { - item { - title { resource(R.string.help_whatis) } - description { resource(R.string.help_whatis_answer) } - } - item { - title { resource(R.string.help_feature_one) } - description { resource(R.string.help_feature_one_answer) } - } - item { - title { resource(R.string.help_privacy) } - description { resource(R.string.help_privacy_answer) } - } - item { - title { resource(R.string.help_permission) } - description { resource(R.string.help_permission_answer) } - } - } - override val settings: ISettings<*> - get() = PFSettings(applicationContext).settings + override val databaseName = AppDatabase.DB_NAME + override val database = AppDatabase::class.java + override val data: PFData + get() = PFApplicationData.instance(applicationContext).data + override val mainActivity: Class = MainActivity::class.java } \ No newline at end of file diff --git a/compose/src/main/java/org/secuso/privacyfriendlyexample/PFSettings.kt b/compose/src/main/java/org/secuso/privacyfriendlyexample/PFSettings.kt deleted file mode 100644 index 6cd36c8..0000000 --- a/compose/src/main/java/org/secuso/privacyfriendlyexample/PFSettings.kt +++ /dev/null @@ -1,54 +0,0 @@ -package org.secuso.privacyfriendlyexample - -import android.content.Context -import androidx.lifecycle.map -import org.secuso.pfacore.model.settings.ISettings -import org.secuso.pfacore.ui.compose.settings.Settings -import org.secuso.pfacore.ui.compose.settings.SettingThemeSelector - -class PFSettings(context: Context) { - - companion object { - private var _settings: ISettings<*>? = null - } - - init { - if (_settings == null) { - _settings = Settings.build(context) { - category("Example Category") { - switch { - key = "pref_example_switch" - title { resource(R.string.pref_example_switch) } - summary { resource(R.string.pref_example_summary) } - default = false - backup = true - } - } - category("Design") { - SettingThemeSelector().build().invoke(this) - } - category("Legal") { - menu("Legal") { - setting { - menu { - key = "" - title { literal("Legal") } - summary { literal("") } - default = Unit - } - } - content { - - } - } - } - } - } - } - - val settings - get() = _settings!! - - val lightMode - get() = settings.all.map { it.data }.find { it.key === SettingThemeSelector.themeSelectorKey }!!.state.map { SettingThemeSelector.Mode.valueOf(it as String) === SettingThemeSelector.Mode.LIGHT } -} \ No newline at end of file diff --git a/compose/src/main/java/org/secuso/privacyfriendlyexample/database/AppDatabase.kt b/compose/src/main/java/org/secuso/privacyfriendlyexample/database/AppDatabase.kt index 01f4b07..c160e30 100644 --- a/compose/src/main/java/org/secuso/privacyfriendlyexample/database/AppDatabase.kt +++ b/compose/src/main/java/org/secuso/privacyfriendlyexample/database/AppDatabase.kt @@ -19,7 +19,7 @@ package org.secuso.privacyfriendlyexample.database import android.content.Context import androidx.room.Database import androidx.room.Room -import org.secuso.pfacore.application.PFDatabase +import androidx.room.RoomDatabase import org.secuso.privacyfriendlyexample.database.dao.SampleDataDao import org.secuso.privacyfriendlyexample.database.model.SampleData @@ -28,8 +28,7 @@ import org.secuso.privacyfriendlyexample.database.model.SampleData * @author Christopher Beckmann (Kamuno) */ @Database(entities = arrayOf(SampleData::class), version = 1, exportSchema = false) -abstract class AppDatabase : PFDatabase() { - override val name: String = DB_NAME +abstract class AppDatabase : RoomDatabase() { abstract fun sampleDataDao(): SampleDataDao diff --git a/compose/src/main/java/org/secuso/privacyfriendlyexample/ui/BaseActivity.kt b/compose/src/main/java/org/secuso/privacyfriendlyexample/ui/BaseActivity.kt index e1f0248..7eb1963 100644 --- a/compose/src/main/java/org/secuso/privacyfriendlyexample/ui/BaseActivity.kt +++ b/compose/src/main/java/org/secuso/privacyfriendlyexample/ui/BaseActivity.kt @@ -16,28 +16,21 @@ */ package org.secuso.privacyfriendlyexample.ui +//import org.secuso.pfacore.ui.compose.activities.HelpActivity + import android.content.Intent import android.content.SharedPreferences import android.os.Build import android.os.Bundle import android.os.Handler -import android.preference.PreferenceActivity import android.preference.PreferenceManager -import com.google.android.material.navigation.NavigationView -import com.google.android.material.navigation.NavigationView.OnNavigationItemSelectedListener +import android.view.View 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 -import org.secuso.pfacore.ui.compose.activities.AboutActivity -import org.secuso.pfacore.ui.compose.activities.HelpActivity -//import org.secuso.pfacore.ui.compose.activities.HelpActivity -import org.secuso.pfacore.ui.compose.activities.SettingsActivity - +import com.google.android.material.navigation.NavigationView +import org.secuso.pfacore.model.DrawerMenu +import org.secuso.pfacore.ui.compose.activities.DrawerActivity import org.secuso.privacyfriendlyexample.R /** @@ -54,7 +47,7 @@ import org.secuso.privacyfriendlyexample.R * @author Christopher Beckmann (Kamuno), Karola Marky (yonjuni) * @version 20161225 */ -abstract class BaseActivity : AppCompatActivity(), OnNavigationItemSelectedListener { +abstract class BaseActivity : DrawerActivity() { companion object { // delay to launch nav drawer item, to allow close animation to play internal const val NAVDRAWER_LAUNCH_DELAY = 250 @@ -80,6 +73,25 @@ abstract class BaseActivity : AppCompatActivity(), OnNavigationItemSelectedListe overridePendingTransition(0, 0) } + override fun drawer(): DrawerMenu = DrawerMenu.build { + name = getString(R.string.app_name) + icon = R.mipmap.ic_launcher + section { + activity { + name = getString(R.string.action_main) + icon = R.drawable.ic_menu_home + clazz = MainActivity::class.java + extras = { it.apply { flags = Intent.FLAG_ACTIVITY_CLEAR_TOP } } + } + activity { + name = getString(R.string.action_game) + icon = R.drawable.ic_menu_game + clazz = GameActivity::class.java + } + } + defaultDrawerSection(this) + } + override fun onBackPressed() { val drawer = findViewById(R.id.drawer_layout) as DrawerLayout if (drawer.isDrawerOpen(GravityCompat.START)) { @@ -89,38 +101,6 @@ abstract class BaseActivity : AppCompatActivity(), OnNavigationItemSelectedListe } } - override fun onNavigationItemSelected(item: MenuItem): Boolean = goToNavigationItem(item.itemId) - - protected fun goToNavigationItem(itemId: Int): Boolean { - if (itemId == navigationDrawerID) { - // just close drawer because we are already in this activity - mDrawerLayout?.closeDrawer(GravityCompat.START) - return true - } - - // delay transition so the drawer can close - mHandler.postDelayed({ callDrawerItem(itemId) }, NAVDRAWER_LAUNCH_DELAY.toLong()) - - mDrawerLayout?.closeDrawer(GravityCompat.START) - - selectNavigationItem(itemId) - - // fade out the active activity - val mainContent = findViewById(R.id.main_content) - mainContent?.animate()!!.alpha(0f).duration = MAIN_CONTENT_FADEOUT_DURATION.toLong() - return true - } - - // set active navigation item - private fun selectNavigationItem(itemId: Int) { - mNavigationView ?: return - - for (i in 0 until mNavigationView!!.menu.size()) { - val b = itemId == mNavigationView!!.menu.getItem(i).itemId - mNavigationView!!.menu.getItem(i).isChecked = b - } - } - /** * Enables back navigation for activities that are launched from the NavBar. See * `AndroidManifest.xml` to find out the parent activity names for each activity. @@ -137,65 +117,9 @@ abstract class BaseActivity : AppCompatActivity(), OnNavigationItemSelectedListe } } - /** - * This method manages the behaviour of the navigation drawer - * Add your menu items (ids) to res/menu/main_drawer.xmlparam itemId Item that has been clicked by the user - */ - private fun callDrawerItem(itemId: Int) { - - val intent: Intent - - when (itemId) { - R.id.nav_example -> { - intent = Intent(this, MainActivity::class.java).apply { - flags = Intent.FLAG_ACTIVITY_CLEAR_TOP - } - startActivity(intent) - } - R.id.nav_game -> { - intent = Intent(this, GameActivity::class.java) - createBackStack(intent) - } - R.id.nav_about -> { - intent = Intent(this, AboutActivity::class.java) - createBackStack(intent) - } - R.id.nav_help -> { - intent = Intent(this, HelpActivity::class.java) - createBackStack(intent) - } - R.id.nav_tutorial -> { - intent = Intent(this, TutorialActivity::class.java).apply { - flags = Intent.FLAG_ACTIVITY_CLEAR_TOP - } - startActivity(intent) - } - R.id.nav_settings -> { - intent = Intent(this, SettingsActivity::class.java) - createBackStack(intent) - } - } - } - override fun onPostCreate(savedInstanceState: Bundle?) { super.onPostCreate(savedInstanceState) - val toolbar = findViewById(R.id.toolbar) as Toolbar - if (supportActionBar == null) { - setSupportActionBar(toolbar) - } - - mDrawerLayout = findViewById(R.id.drawer_layout) as DrawerLayout - val toggle = ActionBarDrawerToggle( - this, mDrawerLayout, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close) - mDrawerLayout!!.addDrawerListener(toggle) - toggle.syncState() - - mNavigationView = findViewById(R.id.nav_view) as NavigationView - mNavigationView!!.setNavigationItemSelectedListener(this) - - selectNavigationItem(navigationDrawerID) - val mainContent = findViewById(R.id.main_content) if (mainContent != null) { mainContent.alpha = 0f diff --git a/compose/src/main/java/org/secuso/privacyfriendlyexample/ui/GameActivity.kt b/compose/src/main/java/org/secuso/privacyfriendlyexample/ui/GameActivity.kt index fc27312..d3eb138 100644 --- a/compose/src/main/java/org/secuso/privacyfriendlyexample/ui/GameActivity.kt +++ b/compose/src/main/java/org/secuso/privacyfriendlyexample/ui/GameActivity.kt @@ -17,15 +17,20 @@ package org.secuso.privacyfriendlyexample.ui import android.os.Bundle -import androidx.fragment.app.Fragment -import androidx.fragment.app.FragmentManager -import androidx.fragment.app.FragmentPagerAdapter -import androidx.viewpager.widget.ViewPager import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.TextView - +import androidx.compose.runtime.Composable +import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.viewinterop.AndroidViewBinding +import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentActivity +import androidx.fragment.app.FragmentManager +import androidx.fragment.app.FragmentPagerAdapter +import androidx.viewpager.widget.ViewPager +import org.secuso.pfacore.application.PFApplication +import org.secuso.pfacore.model.DrawerElement import org.secuso.privacyfriendlyexample.R import org.secuso.privacyfriendlyexample.databinding.ActivityGameBinding @@ -40,51 +45,47 @@ class GameActivity : BaseActivity() { * ID of the menu item it belongs to */ override val navigationDrawerID: Int = R.id.nav_game - private lateinit var binding: ActivityGameBinding - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - binding = ActivityGameBinding.inflate(layoutInflater) - setContentView(binding.root) - val mSectionsPagerAdapter = SectionsPagerAdapter(supportFragmentManager) - // Set up the ViewPager with the sections adapter. - binding.chooseGameTypeViewPager.adapter = mSectionsPagerAdapter + @Composable + override fun Content(application: PFApplication) { + val context = LocalContext.current as FragmentActivity + AndroidViewBinding(ActivityGameBinding::inflate) { + val adapter = SectionsPagerAdapter(context.supportFragmentManager) + chooseGameTypeViewPager.adapter = adapter + val index = mSharedPreferences.getInt("lastChosenPage", 0) - val index = mSharedPreferences.getInt("lastChosenPage", 0) + chooseGameTypeViewPager.currentItem = index - binding.chooseGameTypeViewPager.currentItem = index + //care for initial postiton of the ViewPager + arrowLeft.visibility = if (index == 0) View.INVISIBLE else View.VISIBLE + arrowRight.visibility = if (index == adapter.count - 1) View.INVISIBLE else View.VISIBLE - //care for initial postiton of the ViewPager - binding.arrowLeft.visibility = if (index == 0) View.INVISIBLE else View.VISIBLE - binding.arrowRight.visibility = if (index == mSectionsPagerAdapter.count - 1) View.INVISIBLE else View.VISIBLE + arrowLeft.setOnClickListener { chooseGameTypeViewPager.arrowScroll(View.FOCUS_LEFT) } + arrowRight.setOnClickListener { chooseGameTypeViewPager.arrowScroll(View.FOCUS_RIGHT) } - //Update ViewPager on change - binding.chooseGameTypeViewPager.addOnPageChangeListener(object : ViewPager.OnPageChangeListener { - override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) { + //Update ViewPager on change + chooseGameTypeViewPager.addOnPageChangeListener(object : ViewPager.OnPageChangeListener { + override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) { - } + } - override fun onPageSelected(position: Int) { - binding.arrowLeft.visibility = if (position == 0) View.INVISIBLE else View.VISIBLE - binding.arrowRight.visibility = if (position == mSectionsPagerAdapter.count - 1) View.INVISIBLE else View.VISIBLE + override fun onPageSelected(position: Int) { + arrowLeft.visibility = if (position == 0) View.INVISIBLE else View.VISIBLE + arrowRight.visibility = if (position == adapter.count - 1) View.INVISIBLE else View.VISIBLE - //save position in settings - val editor = mSharedPreferences.edit() - editor.putInt("lastChosenPage", position) - editor.apply() - } - - override fun onPageScrollStateChanged(state: Int) {} - }) + //save position in settings + val editor = mSharedPreferences.edit() + editor.putInt("lastChosenPage", position) + editor.apply() + } + override fun onPageScrollStateChanged(state: Int) {} + }) + } } - fun onClick(view: View) { - when (view.id) { - R.id.arrow_left -> binding.chooseGameTypeViewPager.arrowScroll(View.FOCUS_LEFT) - R.id.arrow_right -> binding.chooseGameTypeViewPager.arrowScroll(View.FOCUS_RIGHT) - } + override fun isActiveDrawerElement(element: DrawerElement): Boolean { + return element.name == getString(R.string.action_game) } inner class SectionsPagerAdapter(fm: FragmentManager) : FragmentPagerAdapter(fm) { diff --git a/compose/src/main/java/org/secuso/privacyfriendlyexample/ui/MainActivity.kt b/compose/src/main/java/org/secuso/privacyfriendlyexample/ui/MainActivity.kt index 74cfd82..a6a01b8 100644 --- a/compose/src/main/java/org/secuso/privacyfriendlyexample/ui/MainActivity.kt +++ b/compose/src/main/java/org/secuso/privacyfriendlyexample/ui/MainActivity.kt @@ -17,11 +17,14 @@ package org.secuso.privacyfriendlyexample.ui import android.os.Bundle -import android.view.View +import androidx.compose.runtime.Composable +import androidx.compose.ui.viewinterop.AndroidViewBinding import androidx.lifecycle.Observer -import androidx.lifecycle.ViewModelProviders - +import androidx.lifecycle.ViewModelProvider +import org.secuso.pfacore.application.PFApplication +import org.secuso.pfacore.model.DrawerElement import org.secuso.privacyfriendlyexample.R +import org.secuso.privacyfriendlyexample.databinding.ActivityMainBinding import org.secuso.privacyfriendlyexample.ui.viewmodel.MainExampleViewModel /** @@ -36,11 +39,17 @@ class MainActivity : BaseActivity() { private lateinit var exampleViewModel: MainExampleViewModel + @Composable + override fun Content(application: PFApplication) { + AndroidViewBinding(ActivityMainBinding::inflate) { + // Access all UI-Elements here + } + } + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) - exampleViewModel = ViewModelProviders.of(this).get(MainExampleViewModel::class.java) + exampleViewModel = ViewModelProvider(this)[MainExampleViewModel::class.java] exampleViewModel.sampleData.observe(this, Observer { data -> // TODO do something with the data here - e.g. update an adapter, trigger some event, etc. }) @@ -48,10 +57,7 @@ class MainActivity : BaseActivity() { overridePendingTransition(0, 0) } - fun onClick(view: View) { - // do something with all these buttons? - when (view.id) { - else -> {} - } + override fun isActiveDrawerElement(element: DrawerElement): Boolean { + return element.name == getString(R.string.action_main) } } diff --git a/compose/src/main/res/layout/activity_game.xml b/compose/src/main/res/layout/activity_game.xml index e39ae14..850a0d8 100644 --- a/compose/src/main/res/layout/activity_game.xml +++ b/compose/src/main/res/layout/activity_game.xml @@ -16,8 +16,6 @@ android:fitsSystemWindows="true" tools:context="org.secuso.privacyfriendlyexample.ui.GameActivity"> - - - + tools:context="org.secuso.privacyfriendlyexample.ui.MainActivity"> - + - - - - - - -