From 89093f6b9ed369339d22fb0683f28aea4ce0e9e3 Mon Sep 17 00:00:00 2001 From: Josia Pietsch Date: Wed, 11 Sep 2024 10:49:45 +0200 Subject: [PATCH] renamed preferences --- app/build.gradle | 9 +- app/src/main/AndroidManifest.xml | 18 +- .../de/jrpie/android/launcher/Application.kt | 8 +- .../de/jrpie/android/launcher/Functions.kt | 112 ++++----- .../java/de/jrpie/android/launcher/Gesture.kt | 214 +++++------------- .../de/jrpie/android/launcher/HomeActivity.kt | 76 +++---- .../de/jrpie/android/launcher/UIObject.kt | 6 +- .../android/launcher/list/ListActivity.kt | 12 +- .../launcher/list/apps/AppsRecyclerAdapter.kt | 72 ++---- .../launcher/list/apps/ListFragmentApps.kt | 5 +- .../launcher/list/other/LauncherAction.kt | 51 ++--- .../launcher/list/other/ListFragmentOther.kt | 1 + .../list/other/OtherRecyclerAdapter.kt | 10 +- .../LauncherPreferences$Config.java | 70 +++--- .../launcher/preferences/Preferences.kt | 161 +++++++++---- .../launcher/settings/SettingsActivity.kt | 35 ++- .../actions/SettingsFragmentActions.kt | 10 +- .../SettingsFragmentActionsRecycler.kt | 67 +++--- .../launcher/SettingsFragmentLauncher.kt | 12 +- .../settings/meta/SettingsFragmentMeta.kt | 10 +- .../launcher/tutorial/TutorialActivity.kt | 31 ++- .../tutorial/tabs/TutorialFragmentConcept.kt | 3 +- .../tutorial/tabs/TutorialFragmentFinish.kt | 9 +- .../tutorial/tabs/TutorialFragmentSetup.kt | 2 +- .../tutorial/tabs/TutorialFragmentStart.kt | 7 +- .../tutorial/tabs/TutorialFragmentUsage.kt | 2 +- app/src/main/res/anim/bottom_up.xml | 4 +- app/src/main/res/anim/left_right.xml | 4 +- app/src/main/res/anim/right_left.xml | 4 +- app/src/main/res/anim/top_down.xml | 4 +- .../main/res/drawable/baseline_close_24.xml | 11 +- .../main/res/drawable/baseline_menu_24.xml | 11 +- .../res/drawable/baseline_more_horiz_24.xml | 11 +- .../drawable/baseline_not_interested_24.xml | 11 +- .../drawable/baseline_notifications_24.xml | 11 +- .../main/res/drawable/baseline_search_24.xml | 11 +- .../res/drawable/baseline_settings_24.xml | 11 +- .../baseline_settings_applications_24.xml | 11 +- .../res/drawable/baseline_skip_next_24.xml | 11 +- .../drawable/baseline_skip_previous_24.xml | 11 +- .../res/drawable/baseline_volume_down_24.xml | 12 +- .../res/drawable/baseline_volume_up_24.xml | 12 +- .../res/drawable/tutorial_default_dot.xml | 2 +- .../res/drawable/tutorial_selected_dot.xml | 2 +- .../res/drawable/tutorial_tab_selector.xml | 5 +- app/src/main/res/layout/home.xml | 4 +- app/src/main/res/layout/list.xml | 7 +- app/src/main/res/layout/list_apps.xml | 1 + app/src/main/res/layout/list_apps_row.xml | 3 +- app/src/main/res/layout/list_other.xml | 3 +- app/src/main/res/layout/list_other_row.xml | 3 +- app/src/main/res/layout/settings.xml | 9 +- app/src/main/res/layout/settings_actions.xml | 2 +- .../main/res/layout/settings_actions_row.xml | 6 +- app/src/main/res/layout/settings_meta.xml | 4 +- app/src/main/res/layout/tutorial.xml | 12 +- app/src/main/res/layout/tutorial_concept.xml | 9 +- app/src/main/res/layout/tutorial_finish.xml | 8 +- app/src/main/res/layout/tutorial_setup.xml | 3 +- app/src/main/res/layout/tutorial_start.xml | 7 +- app/src/main/res/menu/menu_app.xml | 6 +- .../res/mipmap-anydpi-v26/ic_launcher.xml | 4 +- .../mipmap-anydpi-v26/ic_launcher_round.xml | 4 +- app/src/main/res/values-de/strings.xml | 3 +- app/src/main/res/values-es/strings.xml | 5 +- app/src/main/res/values-fr/strings.xml | 3 +- app/src/main/res/values-zh-rCN/strings.xml | 3 +- app/src/main/res/values/donottranslate.xml | 201 ++++++++-------- app/src/main/res/values/strings.xml | 11 +- app/src/main/res/values/styles.xml | 4 +- app/src/main/res/xml/preferences.xml | 63 +++--- 71 files changed, 676 insertions(+), 884 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 6b6df2f..6cf0a85 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -41,10 +41,12 @@ android { } + + buildTypes { release { - minifyEnabled true - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + // minifyEnabled true + // proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } namespace 'de.jrpie.android.launcher' @@ -62,9 +64,8 @@ dependencies { implementation 'androidx.constraintlayout:constraintlayout:2.1.4' implementation 'androidx.legacy:legacy-support-v4:1.0.0' implementation "eu.jonahbauer:android-preference-annotations:1.1.2" + annotationProcessor "eu.jonahbauer:android-preference-annotations:1.1.2" implementation 'androidx.preference:preference-ktx:1.2.1' - //kapt "eu.jonahbauer:android-preference-annotations:1.1.2" - //annotationProcessor "eu.jonahbauer:android-preference-annotations:1.1.2" testImplementation 'junit:junit:4.13.2' androidTestImplementation 'androidx.test.ext:junit:1.2.1' androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1' diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index dfa90e2..6b4cbae 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -3,8 +3,7 @@ xmlns:tools="http://schemas.android.com/tools"> - @@ -21,15 +20,14 @@ - @@ -38,20 +36,22 @@ + tools:ignore="LockedOrientationActivity"> + + tools:ignore="LockedOrientationActivity"> + - - + + diff --git a/app/src/main/java/de/jrpie/android/launcher/Application.kt b/app/src/main/java/de/jrpie/android/launcher/Application.kt index 50c41a3..49a9014 100644 --- a/app/src/main/java/de/jrpie/android/launcher/Application.kt +++ b/app/src/main/java/de/jrpie/android/launcher/Application.kt @@ -1,16 +1,14 @@ package de.jrpie.android.launcher import android.content.Context +import androidx.preference.PreferenceManager import de.jrpie.android.launcher.preferences.LauncherPreferences -class Application : android.app.Application() { +class Application: android.app.Application() { override fun onCreate() { super.onCreate() - val preferences = getSharedPreferences( - this.getString(R.string.preference_file_key), - Context.MODE_PRIVATE - ) + val preferences = PreferenceManager.getDefaultSharedPreferences(this) LauncherPreferences.init(preferences, this.resources) } } \ No newline at end of file diff --git a/app/src/main/java/de/jrpie/android/launcher/Functions.kt b/app/src/main/java/de/jrpie/android/launcher/Functions.kt index 76e78db..13023d7 100644 --- a/app/src/main/java/de/jrpie/android/launcher/Functions.kt +++ b/app/src/main/java/de/jrpie/android/launcher/Functions.kt @@ -10,8 +10,12 @@ import android.content.pm.ApplicationInfo import android.content.pm.LauncherActivityInfo import android.content.pm.LauncherApps import android.content.pm.PackageManager +import android.graphics.BlendMode +import android.graphics.BlendModeColorFilter import android.graphics.ColorMatrix import android.graphics.ColorMatrixColorFilter +import android.graphics.PorterDuff +import android.graphics.PorterDuffColorFilter import android.graphics.Rect import android.graphics.drawable.Drawable import android.media.AudioManager @@ -26,11 +30,16 @@ import android.util.DisplayMetrics import android.util.Log import android.view.KeyEvent import android.view.View +import android.view.Window +import android.view.WindowManager import android.view.animation.AlphaAnimation import android.view.animation.Animation import android.view.inputmethod.InputMethodManager +import android.widget.Button import android.widget.ImageView +import android.widget.Switch import android.widget.Toast +import androidx.annotation.RequiresApi import de.jrpie.android.launcher.list.ListActivity import de.jrpie.android.launcher.list.apps.AppInfo import de.jrpie.android.launcher.list.apps.AppsRecyclerAdapter @@ -78,23 +87,19 @@ fun setDefaultHomeScreen(context: Context, checkDefault: Boolean = false) { if (checkDefault && Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q - && context is Activity - ) { + && context is Activity) { val roleManager = context.getSystemService(RoleManager::class.java) - if (!roleManager.isRoleHeld(RoleManager.ROLE_HOME)) { - context.startActivityForResult( - roleManager.createRequestRoleIntent(RoleManager.ROLE_HOME), - REQUEST_SET_DEFAULT_HOME - ) + if(!roleManager.isRoleHeld(RoleManager.ROLE_HOME)) { + context.startActivityForResult(roleManager.createRequestRoleIntent(RoleManager.ROLE_HOME), REQUEST_SET_DEFAULT_HOME) } return } - if (checkDefault) { + if(checkDefault) { val testIntent = Intent(Intent.ACTION_MAIN) testIntent.addCategory(Intent.CATEGORY_HOME) val defaultHome = testIntent.resolveActivity(context.packageManager)?.packageName - if (defaultHome == context.packageName) { + if(defaultHome == context.packageName){ // Launcher is already the default home app return } @@ -111,8 +116,7 @@ fun isInstalled(uri: String, context: Context): Boolean { try { context.packageManager.getPackageInfo(uri, PackageManager.GET_ACTIVITIES) return true - } catch (_: PackageManager.NameNotFoundException) { - } + } catch (_: PackageManager.NameNotFoundException) { } return false } @@ -129,8 +133,9 @@ fun launch( ) { if (LauncherAction.isOtherAction(data)) { // [type]:[info] - LauncherAction.byId(data)?.let { it.launch(activity) } - } else launchApp(data, user, activity) // app + LauncherAction.byId(data)?.let {it.launch(activity) } + } + else launchApp(data, user, activity) // app activity.overridePendingTransition(animationIn, animationOut) } @@ -143,8 +148,7 @@ fun audioNextTrack(activity: Activity) { val eventTime: Long = SystemClock.uptimeMillis() - val downEvent = - KeyEvent(eventTime, eventTime, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MEDIA_NEXT, 0) + val downEvent = KeyEvent(eventTime, eventTime, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MEDIA_NEXT, 0) mAudioManager.dispatchMediaKeyEvent(downEvent) val upEvent = KeyEvent(eventTime, eventTime, KeyEvent.ACTION_UP, KeyEvent.KEYCODE_MEDIA_NEXT, 0) @@ -160,8 +164,7 @@ fun audioPreviousTrack(activity: Activity) { KeyEvent(eventTime, eventTime, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MEDIA_PREVIOUS, 0) mAudioManager.dispatchMediaKeyEvent(downEvent) - val upEvent = - KeyEvent(eventTime, eventTime, KeyEvent.ACTION_UP, KeyEvent.KEYCODE_MEDIA_PREVIOUS, 0) + val upEvent = KeyEvent(eventTime, eventTime, KeyEvent.ACTION_UP, KeyEvent.KEYCODE_MEDIA_PREVIOUS, 0) mAudioManager.dispatchMediaKeyEvent(upEvent) } @@ -196,11 +199,7 @@ fun expandNotificationsPanel(context: Context) { val showStatusBar = statusBarManager.getMethod("expandNotificationsPanel") showStatusBar.invoke(statusBarService) } catch (e: Exception) { - Toast.makeText( - context, - context.getString(R.string.alert_cant_expand_notifications_panel), - Toast.LENGTH_LONG - ).show() + Toast.makeText(context, context.getString(R.string.alert_cant_expand_notifications_panel), Toast.LENGTH_LONG).show() } } @@ -210,39 +209,32 @@ fun getUserFromId(user: Int?, context: Context): UserHandle? { val userManager = context.getSystemService(Service.USER_SERVICE) as UserManager return userManager.userProfiles.firstOrNull { it.hashCode() == user } } - -fun getLauncherActivityInfo( - packageName: String, - user: Int?, - context: Context -): LauncherActivityInfo? { +fun getLauncherActivityInfo(packageName: String, user: Int?, context: Context): LauncherActivityInfo? { val launcherApps = context.getSystemService(Service.LAUNCHER_APPS_SERVICE) as LauncherApps - return getUserFromId(user, context)?.let { userHandle -> - launcherApps.getActivityList(packageName, userHandle).firstOrNull() + return getUserFromId(user,context)?.let { + userHandle -> launcherApps.getActivityList(packageName, userHandle).firstOrNull() } } - fun uninstallApp(packageName: String, user: Int?, activity: Activity) { Log.i("Launcher", "uninstalling $packageName ($user)") val intent = Intent(Intent.ACTION_UNINSTALL_PACKAGE) intent.data = Uri.parse("package:$packageName") - getUserFromId(user, activity)?.let { user -> - intent.putExtra(Intent.EXTRA_USER, user) + getUserFromId(user, activity)?.let { + user -> intent.putExtra(Intent.EXTRA_USER, user) } intent.putExtra(Intent.EXTRA_RETURN_RESULT, true) - activity.startActivityForResult( - intent, + activity.startActivityForResult(intent, REQUEST_UNINSTALL ) } fun launchApp(packageName: String, user: Int?, context: Context, rect: Rect? = null) { - Log.i("Launcher", "Starting: " + packageName + " (user " + user.toString() + ")") - if (user != null) { + Log.i("Launcher", "Starting: " + packageName + " (user " +user.toString()+ ")") + if (user != null && user != INVALID_USER) { val launcherApps = context.getSystemService(Service.LAUNCHER_APPS_SERVICE) as LauncherApps - getLauncherActivityInfo(packageName, user, context)?.let { app -> - launcherApps.startMainActivity(app.componentName, app.user, rect, null) + getLauncherActivityInfo(packageName,user,context)?.let { + app -> launcherApps.startMainActivity(app.componentName, app.user, rect, null) return } } @@ -252,7 +244,7 @@ fun launchApp(packageName: String, user: Int?, context: Context, rect: Rect? = n if (intent != null) { context.startActivity(intent) } else { - if (isInstalled(packageName, context)) { + if (isInstalled(packageName, context)){ AlertDialog.Builder( context, @@ -260,8 +252,7 @@ fun launchApp(packageName: String, user: Int?, context: Context, rect: Rect? = n ) .setTitle(context.getString(R.string.alert_cant_open_title)) .setMessage(context.getString(R.string.alert_cant_open_message)) - .setPositiveButton( - android.R.string.ok + .setPositiveButton(android.R.string.ok ) { _, _ -> openAppSettings( packageName, @@ -292,16 +283,10 @@ fun openNewTabWindow(urls: String, context: Context) { } -fun openAppSettings( - packageName: String, - user: Int?, - context: Context, - sourceBounds: Rect? = null, - opts: Bundle? = null -) { +fun openAppSettings(packageName: String, user: Int?, context: Context, sourceBounds: Rect? = null, opts: Bundle? = null) { val launcherApps = context.getSystemService(Service.LAUNCHER_APPS_SERVICE) as LauncherApps - getLauncherActivityInfo(packageName, user, context)?.let { app -> - launcherApps.startAppDetailsActivity(app.componentName, app.user, sourceBounds, opts) + getLauncherActivityInfo(packageName, user, context)?.let { + app -> launcherApps.startAppDetailsActivity(app.componentName, app.user, sourceBounds, opts) } } @@ -309,11 +294,11 @@ fun openSettings(activity: Activity) { activity.startActivity(Intent(activity, SettingsActivity::class.java)) } -fun openTutorial(activity: Activity) { +fun openTutorial(activity: Activity){ activity.startActivity(Intent(activity, TutorialActivity::class.java)) } -fun openAppsList(activity: Activity) { +fun openAppsList(activity: Activity){ val intent = Intent(activity, ListActivity::class.java) intent.putExtra("intention", ListActivity.ListActivityIntention.VIEW.toString()) activity.startActivity(intent) @@ -322,9 +307,9 @@ fun openAppsList(activity: Activity) { fun getAppIcon(context: Context, packageName: String, user: Int?): Drawable { if (user != null) { val launcherApps = context.getSystemService(Service.LAUNCHER_APPS_SERVICE) as LauncherApps - getUserFromId(user, context)?.let { userHandle -> - launcherApps.getActivityList(packageName, userHandle).firstOrNull()?.let { app -> - return app.getBadgedIcon(0) + getUserFromId(user,context)?.let { + userHandle -> launcherApps.getActivityList(packageName, userHandle).firstOrNull()?.let { + app -> return app.getBadgedIcon(0) } } } @@ -343,22 +328,21 @@ fun loadApps(packageManager: PackageManager, context: Context) { // TODO: shortcuts - launcherApps.getShortcuts() val users = userManager.userProfiles - for (user in users) { - for (activityInfo in launcherApps.getActivityList(null, user)) { + for(user in users) { + for (activityInfo in launcherApps.getActivityList(null,user)) { val app = AppInfo() app.label = activityInfo.label app.packageName = activityInfo.applicationInfo.packageName app.icon = activityInfo.getBadgedIcon(0) app.user = user.hashCode() - app.isSystemApp = - activityInfo.applicationInfo.flags.and(ApplicationInfo.FLAG_SYSTEM) != 0 + app.isSystemApp = activityInfo.applicationInfo.flags.and(ApplicationInfo.FLAG_SYSTEM) != 0 loadList.add(app) } } // fallback option - if (loadList.isEmpty()) { + if(loadList.isEmpty()){ Log.i("Launcher", "using fallback option to load packages") val i = Intent(Intent.ACTION_MAIN, null) i.addCategory(Intent.CATEGORY_LAUNCHER) @@ -380,8 +364,8 @@ fun loadApps(packageManager: PackageManager, context: Context) { // Used in Tutorial and Settings `ActivityOnResult` fun saveListActivityChoice(context: Context, data: Intent?) { val value = data?.getStringExtra("value") - var user = data?.getIntExtra("user", INVALID_USER) - user = user?.let { if (it == INVALID_USER) null else it } + var user = data?.getIntExtra("user", INVALID_USER) + user = user?.let{ if(it == INVALID_USER) null else it } val forGesture = data?.getStringExtra("forGesture") ?: return @@ -397,7 +381,7 @@ fun openSoftKeyboard(context: Context, view: View) { } // Taken from: https://stackoverflow.com/a/30340794/12787264 -fun transformGrayscale(imageView: ImageView) { +fun transformGrayscale(imageView: ImageView){ val matrix = ColorMatrix() matrix.setSaturation(0f) diff --git a/app/src/main/java/de/jrpie/android/launcher/Gesture.kt b/app/src/main/java/de/jrpie/android/launcher/Gesture.kt index 7fcd95b..9d9f9b0 100644 --- a/app/src/main/java/de/jrpie/android/launcher/Gesture.kt +++ b/app/src/main/java/de/jrpie/android/launcher/Gesture.kt @@ -2,6 +2,7 @@ package de.jrpie.android.launcher import android.app.Activity import android.content.Context +import android.util.Log import de.jrpie.android.launcher.preferences.LauncherPreferences /** @@ -11,160 +12,59 @@ import de.jrpie.android.launcher.preferences.LauncherPreferences * @param animationIn res id of transition animation (in) when using the gesture to launch an app. * @param animationOut res id of transition animation (out) when using the gesture to launch an app. */ -enum class Gesture( - val id: String, private val labelResource: Int, - private val defaultsResource: Int, - private val animationIn: Int = android.R.anim.fade_in, - private val animationOut: Int = android.R.anim.fade_out -) { - VOLUME_UP( - "action_volumeUpApp", - R.string.settings_gesture_vol_up, - R.array.default_volume_up, - 0, - 0 - ), - VOLUME_DOWN( - "action_volumeDownApp", - R.string.settings_gesture_vol_down, - R.array.default_volume_down, - 0, - 0 - ), - TIME("action_timeApp", R.string.settings_gesture_time, R.array.default_time), - DATE("action_dateApp", R.string.settings_gesture_date, R.array.default_date), - LONG_CLICK( - "action_longClickApp", - R.string.settings_gesture_long_click, - R.array.default_long_click, - 0, - 0 - ), - DOUBLE_CLICK( - "action_doubleClickApp", - R.string.settings_gesture_double_click, - R.array.default_double_click, - 0, - 0 - ), - SWIPE_UP("action_upApp", R.string.settings_gesture_up, R.array.default_up, R.anim.bottom_up), - SWIPE_UP_LEFT_EDGE( - "action_up_leftApp", - R.string.settings_gesture_up_left_edge, - R.array.default_up_left, - R.anim.bottom_up - ), - SWIPE_UP_RIGHT_EDGE( - "action_up_rightApp", - R.string.settings_gesture_up_right_edge, - R.array.default_up_right, - R.anim.bottom_up - ), - SWIPE_UP_DOUBLE( - "action_doubleUpApp", - R.string.settings_gesture_double_up, - R.array.default_double_up, - R.anim.bottom_up - ), - SWIPE_DOWN( - "action_downApp", - R.string.settings_gesture_down, - R.array.default_down, - R.anim.top_down - ), - SWIPE_DOWN_LEFT_EDGE( - "action_down_leftApp", - R.string.settings_gesture_down_left_edge, - R.array.default_down_left, - R.anim.top_down - ), - SWIPE_DOWN_RIGHT_EDGE( - "action_down_rightApp", - R.string.settings_gesture_down_right_edge, - R.array.default_down_right, - R.anim.top_down - ), - SWIPE_DOWN_DOUBLE( - "action_doubleDownApp", - R.string.settings_gesture_double_down, - R.array.default_double_down, - R.anim.top_down - ), - SWIPE_LEFT( - "action_leftApp", - R.string.settings_gesture_left, - R.array.default_left, - R.anim.right_left - ), - SWIPE_LEFT_TOP_EDGE( - "action_left_topApp", - R.string.settings_gesture_left_top_edge, - R.array.default_left_top, - R.anim.right_left - ), - SWIPE_LEFT_BOTTOM_EDGE( - "action_left_bottomApp", - R.string.settings_gesture_left_bottom_edge, - R.array.default_left_bottom, - R.anim.right_left - ), - SWIPE_LEFT_DOUBLE( - "action_doubleLeftApp", - R.string.settings_gesture_double_left, - R.array.default_double_left, - R.anim.right_left - ), - SWIPE_RIGHT( - "action_rightApp", - R.string.settings_gesture_right, - R.array.default_right, - R.anim.left_right - ), - SWIPE_RIGHT_TOP_EDGE( - "action_right_topApp", - R.string.settings_gesture_right_top_edge, - R.array.default_right_top, - R.anim.left_right - ), - SWIPE_RIGHT_BOTTOM_EDGE( - "action_right_bottomApp", - R.string.settings_gesture_right_bottom_edge, - R.array.default_right_bottom, - R.anim.left_right - ), - SWIPE_RIGHT_DOUBLE( - "action_doubleRightApp", - R.string.settings_gesture_double_right, - R.array.default_double_right, - R.anim.left_right - ); +enum class Gesture (val id: String, private val labelResource: Int, + private val defaultsResource: Int, + private val animationIn: Int = android.R.anim.fade_in, + private val animationOut: Int = android.R.anim.fade_out){ + VOLUME_UP("action.volume_up", R.string.settings_gesture_vol_up, R.array.default_volume_up, 0,0), + VOLUME_DOWN("action.volume_down", R.string.settings_gesture_vol_down, R.array.default_volume_down,0,0), + TIME("action.time", R.string.settings_gesture_time, R.array.default_time), + DATE("action.date", R.string.settings_gesture_date, R.array.default_date), + LONG_CLICK("action.long_click", R.string.settings_gesture_long_click, R.array.default_long_click, 0,0), + DOUBLE_CLICK("action.double_click", R.string.settings_gesture_double_click, R.array.default_double_click,0,0), + SWIPE_UP("action.up", R.string.settings_gesture_up, R.array.default_up, R.anim.bottom_up), + SWIPE_UP_LEFT_EDGE("action.up_left", R.string.settings_gesture_up_left_edge, R.array.default_up_left, R.anim.bottom_up), + SWIPE_UP_RIGHT_EDGE("action.up_right", R.string.settings_gesture_up_right_edge, R.array.default_up_right, R.anim.bottom_up), + SWIPE_UP_DOUBLE( "action.double_up", R.string.settings_gesture_double_up, R.array.default_double_up, R.anim.bottom_up), + SWIPE_DOWN("action.down", R.string.settings_gesture_down, R.array.default_down, R.anim.top_down), + SWIPE_DOWN_LEFT_EDGE("action.down_left", R.string.settings_gesture_down_left_edge, R.array.default_down_left, R.anim.top_down), + SWIPE_DOWN_RIGHT_EDGE("action.down_right", R.string.settings_gesture_down_right_edge, R.array.default_down_right, R.anim.top_down), + SWIPE_DOWN_DOUBLE("action.double_down", R.string.settings_gesture_double_down, R.array.default_double_down, R.anim.top_down), + SWIPE_LEFT("action.left", R.string.settings_gesture_left, R.array.default_left, R.anim.right_left), + SWIPE_LEFT_TOP_EDGE("action.left_top", R.string.settings_gesture_left_top_edge, R.array.default_left_top, R.anim.right_left), + SWIPE_LEFT_BOTTOM_EDGE("action.left_bottom", R.string.settings_gesture_left_bottom_edge, R.array.default_left_bottom, R.anim.right_left), + SWIPE_LEFT_DOUBLE("action.double_left", R.string.settings_gesture_double_left, R.array.default_double_left, R.anim.right_left), + SWIPE_RIGHT("action.right", R.string.settings_gesture_right, R.array.default_right, R.anim.left_right), + SWIPE_RIGHT_TOP_EDGE("action.right_top", R.string.settings_gesture_right_top_edge, R.array.default_right_top, R.anim.left_right), + SWIPE_RIGHT_BOTTOM_EDGE("action.right_bottom", R.string.settings_gesture_right_bottom_edge, R.array.default_right_bottom, R.anim.left_right), + SWIPE_RIGHT_DOUBLE("action.double_right", R.string.settings_gesture_double_right, R.array.default_double_right, R.anim.left_right); - enum class Edge { - TOP, BOTTOM, LEFT, RIGHT + enum class Edge{ + TOP, BOTTOM, LEFT, RIGHT } fun getApp(context: Context): Pair { val preferences = LauncherPreferences.getSharedPreferences() - var packageName = preferences.getString(this.id, "")!! - var u: Int? = preferences.getInt(this.id + "_user", INVALID_USER) - u = if (u == INVALID_USER) null else u - return Pair(packageName, u) + var packageName = preferences.getString(this.id + ".app", "")!! + var u: Int? = preferences.getInt(this.id + ".user", INVALID_USER) + u = if(u == INVALID_USER) null else u + return Pair(packageName,u) } fun removeApp(context: Context) { LauncherPreferences.getSharedPreferences().edit() - .putString(this.id, "") // clear it + .putString(this.id + ".app", "") // clear it .apply() } fun setApp(context: Context, app: String, user: Int?) { LauncherPreferences.getSharedPreferences().edit() - .putString(this.id, app) + .putString(this.id + ".app", app) .apply() - val u = user ?: INVALID_USER + val u = user?: INVALID_USER LauncherPreferences.getSharedPreferences().edit() - .putInt(this.id + "_user", u) + .putInt(this.id + ".user", u) .apply() } @@ -172,7 +72,7 @@ enum class Gesture( return context.resources.getString(this.labelResource) } - fun pickDefaultApp(context: Context): String { + fun pickDefaultApp(context: Context) : String { return context.resources .getStringArray(this.defaultsResource) .firstOrNull { isInstalled(it, context) } @@ -180,7 +80,7 @@ enum class Gesture( } fun getDoubleVariant(): Gesture { - return when (this) { + return when(this) { SWIPE_UP -> SWIPE_UP_DOUBLE SWIPE_DOWN -> SWIPE_DOWN_DOUBLE SWIPE_LEFT -> SWIPE_LEFT_DOUBLE @@ -190,30 +90,27 @@ enum class Gesture( } fun getEdgeVariant(edge: Edge): Gesture { - return when (edge) { + return when(edge) { Edge.TOP -> - when (this) { + when(this) { SWIPE_LEFT -> SWIPE_LEFT_TOP_EDGE SWIPE_RIGHT -> SWIPE_RIGHT_TOP_EDGE else -> this } - Edge.BOTTOM -> - when (this) { + when(this) { SWIPE_LEFT -> SWIPE_LEFT_BOTTOM_EDGE SWIPE_RIGHT -> SWIPE_RIGHT_BOTTOM_EDGE else -> this } - Edge.LEFT -> - when (this) { + when(this) { SWIPE_UP -> SWIPE_UP_LEFT_EDGE SWIPE_DOWN -> SWIPE_DOWN_LEFT_EDGE else -> this } - Edge.RIGHT -> - when (this) { + when(this) { SWIPE_UP -> SWIPE_UP_RIGHT_EDGE SWIPE_DOWN -> SWIPE_DOWN_RIGHT_EDGE else -> this @@ -222,39 +119,38 @@ enum class Gesture( } fun isDoubleVariant(): Boolean { - return when (this) { + return when(this){ SWIPE_UP_DOUBLE, SWIPE_DOWN_DOUBLE, SWIPE_LEFT_DOUBLE, SWIPE_RIGHT_DOUBLE -> true - else -> false } } fun isEdgeVariant(): Boolean { - return when (this) { + return when(this){ SWIPE_UP_RIGHT_EDGE, - SWIPE_UP_LEFT_EDGE, - SWIPE_DOWN_LEFT_EDGE, - SWIPE_DOWN_RIGHT_EDGE, - SWIPE_LEFT_TOP_EDGE, - SWIPE_LEFT_BOTTOM_EDGE, - SWIPE_RIGHT_TOP_EDGE, - SWIPE_RIGHT_BOTTOM_EDGE -> true - + SWIPE_UP_LEFT_EDGE, + SWIPE_DOWN_LEFT_EDGE, + SWIPE_DOWN_RIGHT_EDGE, + SWIPE_LEFT_TOP_EDGE, + SWIPE_LEFT_BOTTOM_EDGE, + SWIPE_RIGHT_TOP_EDGE, + SWIPE_RIGHT_BOTTOM_EDGE -> true else -> false } } operator fun invoke(activity: Activity) { val app = this.getApp(activity) + Log.d("LAUNCHER", "Launching ${app.first} (user: ${app.second}) ${this.toString()}") launch(app.first, app.second, activity, this.animationIn, this.animationOut) } companion object { fun byId(id: String): Gesture? { - return Gesture.values().firstOrNull { it.id == id } + return Gesture.values().firstOrNull {it.id == id } } } diff --git a/app/src/main/java/de/jrpie/android/launcher/HomeActivity.kt b/app/src/main/java/de/jrpie/android/launcher/HomeActivity.kt index 5f4c157..9e6f568 100644 --- a/app/src/main/java/de/jrpie/android/launcher/HomeActivity.kt +++ b/app/src/main/java/de/jrpie/android/launcher/HomeActivity.kt @@ -4,6 +4,7 @@ import android.content.Intent import android.content.res.Resources import android.os.AsyncTask import android.os.Bundle +import android.util.Log import android.view.GestureDetector import android.view.KeyEvent import android.view.MotionEvent @@ -13,7 +14,6 @@ import androidx.core.view.isVisible import de.jrpie.android.launcher.databinding.HomeBinding import de.jrpie.android.launcher.list.other.LauncherAction import de.jrpie.android.launcher.preferences.LauncherPreferences -import de.jrpie.android.launcher.preferences.migrateToNewVersion import de.jrpie.android.launcher.tutorial.TutorialActivity import java.text.SimpleDateFormat import java.util.* @@ -21,6 +21,9 @@ import kotlin.concurrent.fixedRateTimer import kotlin.math.abs import kotlin.math.max import kotlin.math.min +import android.util.DisplayMetrics +import de.jrpie.android.launcher.preferences.migratePreferencesToNewVersion +import de.jrpie.android.launcher.preferences.resetPreferences /** @@ -35,7 +38,7 @@ import kotlin.math.min * - Setting global variables (preferences etc.) * - Opening the [TutorialActivity] on new installations */ -class HomeActivity : UIObject, AppCompatActivity(), +class HomeActivity: UIObject, AppCompatActivity(), GestureDetector.OnGestureListener, GestureDetector.OnDoubleTapListener { private lateinit var binding: HomeBinding @@ -52,14 +55,15 @@ class HomeActivity : UIObject, AppCompatActivity(), override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) + // Try to restore old preferences + migratePreferencesToNewVersion(this) - // First time opening the app: show Tutorial, else: check versions + // First time opening the app: set defaults and start tutorial if (!LauncherPreferences.internal().started()) { + resetPreferences(this) LauncherPreferences.internal().started(true) startActivity(Intent(this, TutorialActivity::class.java)) - } else { - migrateToNewVersion(this) } // Preload apps to speed up the Apps Recycler @@ -70,7 +74,7 @@ class HomeActivity : UIObject, AppCompatActivity(), setContentView(binding.root) } - override fun onStart() { + override fun onStart(){ super.onStart() mDetector = GestureDetectorCompat(this, this) @@ -97,7 +101,7 @@ class HomeActivity : UIObject, AppCompatActivity(), var upperVisible = dateVisible var lowerVisible = timeVisible - if (LauncherPreferences.clock().flipDateTime()) { + if(LauncherPreferences.clock().flipDateTime()) { upperFormat = lowerFormat.also { lowerFormat = upperFormat } upperVisible = lowerVisible.also { lowerVisible = upperVisible } } @@ -151,8 +155,15 @@ class HomeActivity : UIObject, AppCompatActivity(), if (e1 == null) return false - val width = displayMetrics.widthPixels - val height = displayMetrics.heightPixels + + + val displayMetrics: DisplayMetrics? = DisplayMetrics() + windowManager.defaultDisplay.getMetrics(displayMetrics) + + val width = displayMetrics!!.widthPixels + val height = displayMetrics!!.heightPixels + + Log.i("LAUNCHER", "width: $width, height: $height, ${e1.x}, ${e1.y}, ${e2.x}, ${e2.y}") val diffX = e1.x - e2.x val diffY = e1.y - e2.y @@ -161,7 +172,7 @@ class HomeActivity : UIObject, AppCompatActivity(), val edgeActions = LauncherPreferences.enabled_gestures().edgeSwipe() val edgeStrictness = 0.15 - var gesture = if (abs(diffX) > abs(diffY)) { // horizontal swipe + var gesture = if(abs(diffX) > abs(diffY)) { // horizontal swipe if (diffX > width / 4) Gesture.SWIPE_LEFT else if (diffX < -width / 4) @@ -181,16 +192,16 @@ class HomeActivity : UIObject, AppCompatActivity(), } if (edgeActions) { - if (max(e1.x, e2.x) < edgeStrictness * width) { - gesture = gesture?.let { it.getEdgeVariant(Gesture.Edge.LEFT) } - } else if (min(e1.x, e2.x) > (1 - edgeStrictness) * width) { - gesture = gesture?.let { it.getEdgeVariant(Gesture.Edge.RIGHT) } + if(max(e1.x, e2.x) < edgeStrictness * width){ + gesture = gesture?.let{it.getEdgeVariant(Gesture.Edge.LEFT)} + } else if (min(e1.x, e2.x) > (1-edgeStrictness) * width){ + gesture = gesture?.let{it.getEdgeVariant(Gesture.Edge.RIGHT)} } - if (max(e1.y, e2.y) < edgeStrictness * height) { - gesture = gesture?.let { it.getEdgeVariant(Gesture.Edge.TOP) } - } else if (min(e1.y, e2.y) > (1 - edgeStrictness) * height) { - gesture = gesture?.let { it.getEdgeVariant(Gesture.Edge.BOTTOM) } + if(max(e1.y, e2.y) < edgeStrictness * height){ + gesture = gesture?.let{it.getEdgeVariant(Gesture.Edge.TOP)} + } else if (min(e1.y, e2.y) > (1-edgeStrictness) * height){ + gesture = gesture?.let{it.getEdgeVariant(Gesture.Edge.BOTTOM)} } } gesture?.invoke(this) @@ -224,17 +235,13 @@ class HomeActivity : UIObject, AppCompatActivity(), } } - return if (mDetector.onTouchEvent(event)) { - false - } else { - super.onTouchEvent(event) - } + return if (mDetector.onTouchEvent(event)) { false } else { super.onTouchEvent(event) } } override fun setOnClicks() { binding.homeUpperView.setOnClickListener { - if (LauncherPreferences.clock().flipDateTime()) { + if(LauncherPreferences.clock().flipDateTime()) { Gesture.TIME(this) } else { Gesture.DATE(this) @@ -242,7 +249,7 @@ class HomeActivity : UIObject, AppCompatActivity(), } binding.homeLowerView.setOnClickListener { - if (LauncherPreferences.clock().flipDateTime()) { + if(LauncherPreferences.clock().flipDateTime()) { Gesture.DATE(this) } else { Gesture.TIME(this) @@ -252,22 +259,11 @@ class HomeActivity : UIObject, AppCompatActivity(), /* TODO: Remove those. For now they are necessary * because this inherits from GestureDetector.OnGestureListener */ - override fun onDoubleTapEvent(event: MotionEvent): Boolean { - return false - } - - override fun onDown(event: MotionEvent): Boolean { - return false - } - - override fun onScroll(e1: MotionEvent?, e2: MotionEvent, dX: Float, dY: Float): Boolean { - return false - } - + override fun onDoubleTapEvent(event: MotionEvent): Boolean { return false } + override fun onDown(event: MotionEvent): Boolean { return false } + override fun onScroll(e1: MotionEvent?, e2: MotionEvent, dX: Float, dY: Float): Boolean { return false } override fun onShowPress(event: MotionEvent) {} - override fun onSingleTapUp(event: MotionEvent): Boolean { - return false - } + override fun onSingleTapUp(event: MotionEvent): Boolean { return false } override fun isHomeScreen(): Boolean { return true diff --git a/app/src/main/java/de/jrpie/android/launcher/UIObject.kt b/app/src/main/java/de/jrpie/android/launcher/UIObject.kt index bc55345..7bf0fd7 100644 --- a/app/src/main/java/de/jrpie/android/launcher/UIObject.kt +++ b/app/src/main/java/de/jrpie/android/launcher/UIObject.kt @@ -2,6 +2,7 @@ package de.jrpie.android.launcher import android.app.Activity import android.content.res.Resources +import android.os.Build import android.view.Window import android.view.WindowManager import de.jrpie.android.launcher.preferences.LauncherPreferences @@ -42,7 +43,6 @@ interface UIObject { setOnClicks() adjustLayout() } - fun modifyTheme(theme: Resources.Theme): Resources.Theme { LauncherPreferences.theme().colorTheme().applyToTheme(theme) LauncherPreferences.theme().background().applyToTheme(theme) @@ -52,8 +52,8 @@ interface UIObject { } // fun applyTheme() { } - fun setOnClicks() {} - fun adjustLayout() {} + fun setOnClicks() { } + fun adjustLayout() { } fun isHomeScreen(): Boolean { return false diff --git a/app/src/main/java/de/jrpie/android/launcher/list/ListActivity.kt b/app/src/main/java/de/jrpie/android/launcher/list/ListActivity.kt index f3d58df..1bc304e 100644 --- a/app/src/main/java/de/jrpie/android/launcher/list/ListActivity.kt +++ b/app/src/main/java/de/jrpie/android/launcher/list/ListActivity.kt @@ -44,7 +44,6 @@ class ListActivity : AppCompatActivity(), UIObject { VIEW(R.string.list_title_view), /* view list of apps */ PICK(R.string.list_title_pick) /* choose app or action to associate to a gesture */ } - override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -67,8 +66,7 @@ class ListActivity : AppCompatActivity(), UIObject { binding.listContainer.context.resources.displayMetrics.heightPixels val diff = height - r.bottom if (diff != 0 && - LauncherPreferences.display().fullScreen() - ) { + LauncherPreferences.display().fullScreen()) { if (binding.listContainer.paddingBottom !== diff) { binding.listContainer.setPadding(0, 0, 0, diff) } @@ -82,7 +80,7 @@ class ListActivity : AppCompatActivity(), UIObject { } - override fun onStart() { + override fun onStart(){ super.onStart() super.onStart() } @@ -148,11 +146,11 @@ private val TAB_TITLES = arrayOf( * The [ListSectionsPagerAdapter] returns the fragment, * which corresponds to the selected tab in [ListActivity]. */ -class ListSectionsPagerAdapter(private val context: Context, fm: FragmentManager) : - FragmentPagerAdapter(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) { +class ListSectionsPagerAdapter(private val context: Context, fm: FragmentManager) + : FragmentPagerAdapter(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) { override fun getItem(position: Int): Fragment { - return when (position) { + return when (position){ 0 -> ListFragmentApps() 1 -> ListFragmentOther() else -> Fragment() diff --git a/app/src/main/java/de/jrpie/android/launcher/list/apps/AppsRecyclerAdapter.kt b/app/src/main/java/de/jrpie/android/launcher/list/apps/AppsRecyclerAdapter.kt index 1fb5c31..86fdb6f 100644 --- a/app/src/main/java/de/jrpie/android/launcher/list/apps/AppsRecyclerAdapter.kt +++ b/app/src/main/java/de/jrpie/android/launcher/list/apps/AppsRecyclerAdapter.kt @@ -34,12 +34,10 @@ import kotlin.text.Regex.Companion.escapeReplacement * @param intention - why the list is displayed ("view", "pick") * @param forGesture - the action which an app is chosen for (when the intention is "pick") */ -class AppsRecyclerAdapter( - val activity: Activity, - private val intention: ListActivity.ListActivityIntention - = ListActivity.ListActivityIntention.VIEW, - private val forGesture: String? = "" -) : +class AppsRecyclerAdapter(val activity: Activity, + private val intention: ListActivity.ListActivityIntention + = ListActivity.ListActivityIntention.VIEW, + private val forGesture: String? = ""): RecyclerView.Adapter() { private val appsListDisplayed: MutableList @@ -55,9 +53,7 @@ class AppsRecyclerAdapter( selectItem(adapterPosition, rect) } - init { - itemView.setOnClickListener(this) - } + init { itemView.setOnClickListener(this) } } override fun onBindViewHolder(viewHolder: ViewHolder, i: Int) { @@ -76,35 +72,16 @@ class AppsRecyclerAdapter( // decide when to show the options popup menu about if (intention == ListActivity.ListActivityIntention.VIEW) { - viewHolder.textView.setOnLongClickListener { - showOptionsPopup( - viewHolder, - appPackageName, - appUser, - isSystemApp - ) - } - viewHolder.img.setOnLongClickListener { - showOptionsPopup( - viewHolder, - appPackageName, - appUser, - isSystemApp - ) - } + viewHolder.textView.setOnLongClickListener{ showOptionsPopup(viewHolder, appPackageName, appUser, isSystemApp) } + viewHolder.img.setOnLongClickListener{ showOptionsPopup(viewHolder, appPackageName, appUser, isSystemApp) } // ensure onClicks are actually caught - viewHolder.textView.setOnClickListener { viewHolder.onClick(viewHolder.textView) } - viewHolder.img.setOnClickListener { viewHolder.onClick(viewHolder.img) } + viewHolder.textView.setOnClickListener{ viewHolder.onClick(viewHolder.textView) } + viewHolder.img.setOnClickListener{ viewHolder.onClick(viewHolder.img) } } } @Suppress("SameReturnValue") - private fun showOptionsPopup( - viewHolder: ViewHolder, - appPackageName: String, - user: Int?, - isSystemApp: Boolean - ): Boolean { + private fun showOptionsPopup(viewHolder: ViewHolder, appPackageName: String, user: Int?, isSystemApp: Boolean): Boolean { //create the popup menu val popup = PopupMenu(activity, viewHolder.img) @@ -120,12 +97,10 @@ class AppsRecyclerAdapter( uninstallApp(appPackageName, user, activity) true } - R.id.app_menu_info -> { openAppSettings(appPackageName, user, activity) true } - else -> false } } @@ -134,9 +109,7 @@ class AppsRecyclerAdapter( return true } - override fun getItemCount(): Int { - return appsListDisplayed.size - } + override fun getItemCount(): Int { return appsListDisplayed.size } override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { val inflater = LayoutInflater.from(parent.context) @@ -158,20 +131,19 @@ class AppsRecyclerAdapter( } fun selectItem(pos: Int, rect: Rect = Rect()) { - if (pos >= appsListDisplayed.size) { + if(pos >= appsListDisplayed.size) { return } val appPackageName = appsListDisplayed[pos].packageName.toString() val appUser = appsListDisplayed[pos].user - when (intention) { + when (intention){ ListActivity.ListActivityIntention.VIEW -> { launchApp(appPackageName, appUser, activity, rect) } - ListActivity.ListActivityIntention.PICK -> { val returnIntent = Intent() returnIntent.putExtra("value", appPackageName) - appUser?.let { returnIntent.putExtra("user", it) } + appUser?.let{ returnIntent.putExtra("user", it) } returnIntent.putExtra("forGesture", forGesture) activity.setResult(REQUEST_CHOOSE_APP, returnIntent) activity.finish() @@ -188,12 +160,12 @@ class AppsRecyclerAdapter( .lowercase(Locale.ROOT) .toCharArray() .distinct() - .filter { c -> !((c in 'a'..'z') || (c in '0'..'9')) } - .map { c -> escapeReplacement(c.toString()) } - .fold("") { x, y -> x + y } + .filter { c -> ! ((c in 'a'..'z') || (c in '0'..'9')) } + .map { c -> escapeReplacement(c.toString())} + .fold("") { x,y -> x+y } var disallowedCharsRegex = "[^a-z0-9$allowedSpecialCharacters]".toRegex() - fun normalize(text: String): String { + fun normalize(text: String): String{ return text.lowercase(Locale.ROOT).replace(disallowedCharsRegex, "") } appsListDisplayed.clear() @@ -207,7 +179,7 @@ class AppsRecyclerAdapter( if (itemLabel.startsWith(normalizedText)) { appsListDisplayed.add(item) - } else if (itemLabel.contains(normalizedText)) { + }else if(itemLabel.contains(normalizedText)){ appsSecondary.add(item) } } @@ -215,13 +187,11 @@ class AppsRecyclerAdapter( } if (appsListDisplayed.size == 1 && intention == ListActivity.ListActivityIntention.VIEW - && LauncherPreferences.functionality().searchAutoLaunch() - ) { + && LauncherPreferences.functionality().searchAutoLaunch()) { val info = appsListDisplayed[0] launch(info.packageName.toString(), info.user, activity) - val inputMethodManager = - activity.getSystemService(Activity.INPUT_METHOD_SERVICE) as InputMethodManager + val inputMethodManager = activity.getSystemService(Activity.INPUT_METHOD_SERVICE) as InputMethodManager inputMethodManager.hideSoftInputFromWindow(View(activity).windowToken, 0) } diff --git a/app/src/main/java/de/jrpie/android/launcher/list/apps/ListFragmentApps.kt b/app/src/main/java/de/jrpie/android/launcher/list/apps/ListFragmentApps.kt index 2a13c2e..72f3f48 100644 --- a/app/src/main/java/de/jrpie/android/launcher/list/apps/ListFragmentApps.kt +++ b/app/src/main/java/de/jrpie/android/launcher/list/apps/ListFragmentApps.kt @@ -36,7 +36,7 @@ class ListFragmentApps : Fragment(), UIObject { super.onStart() } - override fun setOnClicks() {} + override fun setOnClicks() { } override fun adjustLayout() { @@ -66,8 +66,7 @@ class ListFragmentApps : Fragment(), UIObject { }) if (intention == ListActivity.ListActivityIntention.VIEW - && LauncherPreferences.functionality().searchAutoOpenKeyboard() - ) { + && LauncherPreferences.functionality().searchAutoOpenKeyboard()){ openSoftKeyboard(requireContext(), binding.listAppsSearchview) } } diff --git a/app/src/main/java/de/jrpie/android/launcher/list/other/LauncherAction.kt b/app/src/main/java/de/jrpie/android/launcher/list/other/LauncherAction.kt index 54daceb..b1137f3 100644 --- a/app/src/main/java/de/jrpie/android/launcher/list/other/LauncherAction.kt +++ b/app/src/main/java/de/jrpie/android/launcher/list/other/LauncherAction.kt @@ -10,50 +10,25 @@ import de.jrpie.android.launcher.expandNotificationsPanel import de.jrpie.android.launcher.openAppsList import de.jrpie.android.launcher.openSettings -enum class LauncherAction( - val id: String, - val label: Int, - val icon: Int, - val launch: (Activity) -> Unit -) { - SETTINGS( - "launcher:settings", - R.string.list_other_settings, - R.drawable.baseline_settings_24, - ::openSettings - ), - CHOOSE( - "launcher:choose", - R.string.list_other_list, - R.drawable.baseline_menu_24, - ::openAppsList - ), - VOLUME_UP( - "launcher:volumeUp", +enum class LauncherAction(val id: String, val label: Int, val icon: Int, val launch: (Activity) -> Unit) { + SETTINGS("launcher:settings", R.string.list_other_settings, R.drawable.baseline_settings_24, ::openSettings), + CHOOSE("launcher:choose", R.string.list_other_list, R.drawable.baseline_menu_24, ::openAppsList), + VOLUME_UP("launcher:volumeUp", R.string.list_other_volume_up, - R.drawable.baseline_volume_up_24, ::audioVolumeUp - ), - VOLUME_DOWN( - "launcher:volumeDown", + R.drawable.baseline_volume_up_24, ::audioVolumeUp), + VOLUME_DOWN("launcher:volumeDown", R.string.list_other_volume_down, - R.drawable.baseline_volume_down_24, ::audioVolumeDown - ), - TRACK_NEXT( - "launcher:nextTrack", + R.drawable.baseline_volume_down_24, ::audioVolumeDown), + TRACK_NEXT("launcher:nextTrack", R.string.list_other_track_next, - R.drawable.baseline_skip_next_24, ::audioNextTrack - ), - TRACK_PREV( - "launcher:previousTrack", + R.drawable.baseline_skip_next_24, ::audioNextTrack), + TRACK_PREV("launcher:previousTrack", R.string.list_other_track_previous, - R.drawable.baseline_skip_previous_24, ::audioPreviousTrack - ), - EXPAND_NOTIFICATIONS_PANEL( - "launcher:expandNotificationsPanel", + R.drawable.baseline_skip_previous_24, ::audioPreviousTrack), + EXPAND_NOTIFICATIONS_PANEL("launcher:expandNotificationsPanel", R.string.list_other_expand_notifications_panel, R.drawable.baseline_notifications_24, - ::expandNotificationsPanel - ), + ::expandNotificationsPanel), NOP("launcher:nop", R.string.list_other_nop, R.drawable.baseline_not_interested_24, {}); companion object { diff --git a/app/src/main/java/de/jrpie/android/launcher/list/other/ListFragmentOther.kt b/app/src/main/java/de/jrpie/android/launcher/list/other/ListFragmentOther.kt index b1cd93f..2c73aea 100644 --- a/app/src/main/java/de/jrpie/android/launcher/list/other/ListFragmentOther.kt +++ b/app/src/main/java/de/jrpie/android/launcher/list/other/ListFragmentOther.kt @@ -6,6 +6,7 @@ import android.view.View import android.view.ViewGroup import androidx.fragment.app.Fragment import androidx.recyclerview.widget.LinearLayoutManager +import de.jrpie.android.launcher.R import de.jrpie.android.launcher.databinding.ListOtherBinding /** diff --git a/app/src/main/java/de/jrpie/android/launcher/list/other/OtherRecyclerAdapter.kt b/app/src/main/java/de/jrpie/android/launcher/list/other/OtherRecyclerAdapter.kt index e9bee8d..0b54fa6 100644 --- a/app/src/main/java/de/jrpie/android/launcher/list/other/OtherRecyclerAdapter.kt +++ b/app/src/main/java/de/jrpie/android/launcher/list/other/OtherRecyclerAdapter.kt @@ -20,7 +20,7 @@ import de.jrpie.android.launcher.list.forGesture * It lists `other` things to be launched that are not really represented by a URI, * rather by Launcher- internal conventions. */ -class OtherRecyclerAdapter(val activity: Activity) : +class OtherRecyclerAdapter(val activity: Activity): RecyclerView.Adapter() { private val othersList: Array = LauncherAction.values() @@ -38,9 +38,7 @@ class OtherRecyclerAdapter(val activity: Activity) : forGesture?.let { returnChoiceIntent(it, content.id) } } - init { - itemView.setOnClickListener(this) - } + init { itemView.setOnClickListener(this) } } override fun onBindViewHolder(viewHolder: ViewHolder, i: Int) { @@ -51,9 +49,7 @@ class OtherRecyclerAdapter(val activity: Activity) : viewHolder.iconView.setImageResource(icon) } - override fun getItemCount(): Int { - return othersList.size - } + override fun getItemCount(): Int { return othersList.size } override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { val inflater = LayoutInflater.from(parent.context) diff --git a/app/src/main/java/de/jrpie/android/launcher/preferences/LauncherPreferences$Config.java b/app/src/main/java/de/jrpie/android/launcher/preferences/LauncherPreferences$Config.java index c224b84..10c4b4d 100644 --- a/app/src/main/java/de/jrpie/android/launcher/preferences/LauncherPreferences$Config.java +++ b/app/src/main/java/de/jrpie/android/launcher/preferences/LauncherPreferences$Config.java @@ -13,41 +13,41 @@ import eu.jonahbauer.android.preference.annotations.Preferences; makeFile = true, r = R.class, value = { - @PreferenceGroup(name = "internal", prefix = "settings_internal_", suffix = "_key", value = { - @Preference(name = "started", type = boolean.class, defaultValue = "false"), - @Preference(name = "started_time", type = long.class), - @Preference(name = "version_code", type = int.class, defaultValue = "-1"), - }), - @PreferenceGroup(name = "gestures", prefix = "settings_gesture_", suffix = "_key", value = { - }), - @PreferenceGroup(name = "general", prefix = "settings_general_", suffix = "_key", value = { - @Preference(name = "choose_home_screen", type = void.class) - }), - @PreferenceGroup(name = "theme", prefix = "settings_theme_", suffix = "_key", value = { - @Preference(name = "wallpaper", type = void.class), - @Preference(name = "color_theme", type = ColorTheme.class, defaultValue = "DEFAULT"), - @Preference(name = "background", type = Background.class, defaultValue = "BLUR"), - @Preference(name = "font", type = Font.class, defaultValue = "HACK"), - @Preference(name = "monochrome_icons", type = boolean.class, defaultValue = "false"), - }), - @PreferenceGroup(name = "clock", prefix = "settings_clock_", suffix = "_key", value = { - @Preference(name = "date_visible", type = boolean.class, defaultValue = "true"), - @Preference(name = "time_visible", type = boolean.class, defaultValue = "true"), - @Preference(name = "flip_date_time", type = boolean.class, defaultValue = "false"), - @Preference(name = "localized", type = boolean.class, defaultValue = "false"), - }), - @PreferenceGroup(name = "display", prefix = "settings_display_", suffix = "_key", value = { - @Preference(name = "screen_timeout_disabled", type = boolean.class, defaultValue = "false"), - @Preference(name = "full_screen", type = boolean.class, defaultValue = "true"), - }), - @PreferenceGroup(name = "functionality", prefix = "settings_functionality_", suffix = "_key", value = { - @Preference(name = "search_auto_launch", type = boolean.class, defaultValue = "true"), - @Preference(name = "search_auto_open_keyboard", type = boolean.class, defaultValue = "true"), - }), - @PreferenceGroup(name = "enabled_gestures", prefix = "settings_enabled_gestures_", suffix = "_key", value = { - @Preference(name = "double_swipe", type = boolean.class, defaultValue = "true"), - @Preference(name = "edge_swipe", type = boolean.class, defaultValue = "true"), - }), + @PreferenceGroup(name = "internal", prefix = "settings_internal_", suffix = "_key", value = { + @Preference(name = "started", type = boolean.class, defaultValue = "false"), + @Preference(name = "started_time", type = long.class), + @Preference(name = "version_code", type = int.class, defaultValue = "-1"), + }), + @PreferenceGroup( name = "gestures", prefix = "settings_gesture_", suffix = "_key", value = { + }), + @PreferenceGroup(name = "general", prefix = "settings_general_", suffix = "_key", value = { + @Preference(name = "choose_home_screen", type = void.class) + }), + @PreferenceGroup(name = "theme", prefix = "settings_theme_", suffix = "_key", value = { + @Preference(name = "wallpaper", type = void.class), + @Preference(name = "color_theme", type = ColorTheme.class, defaultValue = "DEFAULT"), + @Preference(name = "background", type = Background.class, defaultValue = "BLUR"), + @Preference(name = "font", type = Font.class, defaultValue = "HACK"), + @Preference(name = "monochrome_icons", type = boolean.class, defaultValue = "false"), + }), + @PreferenceGroup(name = "clock", prefix = "settings_clock_", suffix = "_key", value = { + @Preference(name = "date_visible", type = boolean.class, defaultValue = "true"), + @Preference(name = "time_visible", type = boolean.class, defaultValue = "true"), + @Preference(name = "flip_date_time", type = boolean.class, defaultValue = "false"), + @Preference(name = "localized", type = boolean.class, defaultValue = "false"), + }), + @PreferenceGroup(name = "display", prefix = "settings_display_", suffix = "_key", value = { + @Preference(name = "screen_timeout_disabled", type = boolean.class, defaultValue = "false"), + @Preference(name = "full_screen", type = boolean.class, defaultValue = "true"), + }), + @PreferenceGroup( name = "functionality", prefix = "settings_functionality_", suffix = "_key", value = { + @Preference(name = "search_auto_launch", type = boolean.class, defaultValue = "true"), + @Preference(name = "search_auto_open_keyboard", type = boolean.class, defaultValue = "true"), + }), + @PreferenceGroup(name = "enabled_gestures", prefix = "settings_enabled_gestures_", suffix = "_key", value = { + @Preference(name = "double_swipe", type = boolean.class, defaultValue = "true"), + @Preference(name = "edge_swipe", type = boolean.class, defaultValue = "true"), + }), }) public final class LauncherPreferences$Config { } diff --git a/app/src/main/java/de/jrpie/android/launcher/preferences/Preferences.kt b/app/src/main/java/de/jrpie/android/launcher/preferences/Preferences.kt index 357cd6d..47382d6 100644 --- a/app/src/main/java/de/jrpie/android/launcher/preferences/Preferences.kt +++ b/app/src/main/java/de/jrpie/android/launcher/preferences/Preferences.kt @@ -1,58 +1,141 @@ package de.jrpie.android.launcher.preferences -import android.app.Activity import android.content.Context -import android.content.Intent -import de.jrpie.android.launcher.BuildConfig.VERSION_CODE +import android.content.SharedPreferences +import android.util.Log +import android.widget.Toast import de.jrpie.android.launcher.Gesture -import de.jrpie.android.launcher.R -import de.jrpie.android.launcher.tutorial.TutorialActivity +import de.jrpie.android.launcher.preferences.theme.Background +import de.jrpie.android.launcher.preferences.theme.ColorTheme + +/* Current version of the structure of preferences. + * Increase when breaking changes are introduced and write an appropriate case in + * `migratePreferencesToNewVersion` + */ +const val PREFERENCE_VERSION = 1 +const val UNKNOWN_PREFERENCE_VERSION = -1 -fun migrateToNewVersion(activity: Activity) { +private fun migrateStringPreference(oldPrefs: SharedPreferences, newPreferences: SharedPreferences.Editor, oldKey: String, newKey: String, default: String) { + val s = oldPrefs.getString(oldKey, default) + newPreferences.putString(newKey, s) +} +private fun migrateIntPreference(oldPrefs: SharedPreferences, newPreferences: SharedPreferences.Editor, oldKey: String, newKey: String, default: Int) { + val s = oldPrefs.getInt(oldKey, default) + newPreferences.putInt(newKey, s) +} +private fun migrateBooleanPreference(oldPrefs: SharedPreferences, newPreferences: SharedPreferences.Editor, oldKey: String, newKey: String, default: Boolean) { + val s = oldPrefs.getBoolean(oldKey, default) + newPreferences.putBoolean(newKey, s) +} + +fun migratePreferencesToNewVersion(context: Context) { when (LauncherPreferences.internal().versionCode()) { // Check versions, make sure transitions between versions go well + PREFERENCE_VERSION -> { /* the version installed and used previously are the same */ } + UNKNOWN_PREFERENCE_VERSION -> { /* still using the old preferences file */ + Log.i("Launcher", "Unknown preference version, trying to restore preferences from old version.") - VERSION_CODE -> { /* the version installed and used previously are the same */ - } - 21, 22, 23 -> { - // TODO - } + val oldPrefs = context.getSharedPreferences( + "V3RYR4ND0MK3YCR4P", + Context.MODE_PRIVATE + ) + if(!oldPrefs.contains("startedBefore")) { + Log.i("Launcher", "No old preferences found.") + return + } + val newPrefs = LauncherPreferences.getSharedPreferences().edit() - else -> { /* The version used before was pre- v1.3.0, - as version tracking started then */ + migrateBooleanPreference(oldPrefs, newPrefs, "startedBefore", "internal.started_before", false) + + migrateStringPreference(oldPrefs, newPrefs, "action_volumeUpApp", "action.volume_up.app", "") + migrateIntPreference(oldPrefs, newPrefs, "action_volumeUpApp_user", "action.volume_up.user", -1) + migrateStringPreference(oldPrefs, newPrefs, "action_volumeDownApp", "action.volume_down.app", "") + migrateIntPreference(oldPrefs, newPrefs, "action_volumeDownApp_user", "action.volume_down.user", -1) + migrateStringPreference(oldPrefs, newPrefs, "action_timeApp", "action.time.app", "") + migrateIntPreference(oldPrefs, newPrefs, "action_timeApp_user", "action.time.user", -1) + migrateStringPreference(oldPrefs, newPrefs, "action_dateApp", "action.date.app", "") + migrateIntPreference(oldPrefs, newPrefs, "action_dateApp_user", "action.date.user", -1) + migrateStringPreference(oldPrefs, newPrefs, "action_longClickApp", "action.long_click.app", "") + migrateIntPreference(oldPrefs, newPrefs, "action_longClickApp_user", "action.long_click.user", -1) + migrateStringPreference(oldPrefs, newPrefs, "action_doubleClickApp", "action.double_click.app", "") + migrateIntPreference(oldPrefs, newPrefs, "action_doubleClickApp_user", "action.double_click.user", -1) + migrateStringPreference(oldPrefs, newPrefs, "action_upApp", "action.up.app", "") + migrateIntPreference(oldPrefs, newPrefs, "action_upApp_user", "action.up.user", -1) + migrateStringPreference(oldPrefs, newPrefs, "action_up_leftApp", "action.up_left.app", "") + migrateIntPreference(oldPrefs, newPrefs, "action_up_leftApp_user", "action.up_left.user", -1) + migrateStringPreference(oldPrefs, newPrefs, "action_up_rightApp", "action.up_right.app", "") + migrateIntPreference(oldPrefs, newPrefs, "action_up_rightApp_user", "action.up_right.user", -1) + migrateStringPreference(oldPrefs, newPrefs, "action_doubleUpApp", "action.double_up.app", "") + migrateIntPreference(oldPrefs, newPrefs, "action_doubleUpApp_user", "action.double_up.user", -1) + migrateStringPreference(oldPrefs, newPrefs, "action_downApp", "action.down.app", "") + migrateIntPreference(oldPrefs, newPrefs, "action_downApp_user", "action.down.user", -1) + migrateStringPreference(oldPrefs, newPrefs, "action_down_leftApp", "action.down_left.app", "") + migrateIntPreference(oldPrefs, newPrefs, "action_down_leftApp_user", "action.down_left.user", -1) + migrateStringPreference(oldPrefs, newPrefs, "action_down_rightApp", "action.down_right.app", "") + migrateIntPreference(oldPrefs, newPrefs, "action_down_rightApp_user", "action.down_right.user", -1) + migrateStringPreference(oldPrefs, newPrefs, "action_doubleDownApp", "action.double_down.app", "") + migrateIntPreference(oldPrefs, newPrefs, "action_doubleDownApp_user", "action.double_down.user", -1) + migrateStringPreference(oldPrefs, newPrefs, "action_leftApp", "action.left.app", "") + migrateIntPreference(oldPrefs, newPrefs, "action_leftApp_user", "action.left.user", -1) + migrateStringPreference(oldPrefs, newPrefs, "action_left_topApp", "action.left_top.app", "") + migrateIntPreference(oldPrefs, newPrefs, "action_left_topApp_user", "action.left_top.user", -1) + migrateStringPreference(oldPrefs, newPrefs, "action_left_bottomApp", "action.left_bottom.app", "") + migrateIntPreference(oldPrefs, newPrefs, "action_left_bottomApp_user", "action.left_bottom.user", -1) + migrateStringPreference(oldPrefs, newPrefs, "action_doubleLeftApp", "action.double_left.app", "") + migrateIntPreference(oldPrefs, newPrefs, "action_doubleLeftApp_user", "action.double_left.user", -1) + migrateStringPreference(oldPrefs, newPrefs, "action_rightApp", "action.right.app", "") + migrateIntPreference(oldPrefs, newPrefs, "action_rightApp_user", "action.right.user", -1) + migrateStringPreference(oldPrefs, newPrefs, "action_right_topApp", "action.right_top.app", "") + migrateIntPreference(oldPrefs, newPrefs, "action_right_topApp_user", "action.right_top.user", -1) + migrateStringPreference(oldPrefs, newPrefs, "action_right_bottomApp", "action.right_bottom.app", "") + migrateIntPreference(oldPrefs, newPrefs, "action_right_bottomApp_user", "action.right_bottom.user", -1) + migrateStringPreference(oldPrefs, newPrefs, "action_doubleRightApp", "action.double_right.app", "") + migrateIntPreference(oldPrefs, newPrefs, "action_doubleRightApp_user", "action.double_right.user", -1) + migrateBooleanPreference(oldPrefs, newPrefs, "timeVisible", "clock.time_visible", true) + migrateBooleanPreference(oldPrefs, newPrefs, "dateVisible", "clock.date_visible", true) + migrateBooleanPreference(oldPrefs, newPrefs, "dateLocalized", "clock.date_localized", false) + migrateBooleanPreference(oldPrefs, newPrefs, "dateTimeFlip", "clock.date_time_flip", false) + migrateBooleanPreference(oldPrefs, newPrefs, "disableTimeout", "display.disable_timeout", false) + migrateBooleanPreference(oldPrefs, newPrefs, "useFullScreen", "display.use_full_screen", true) + migrateBooleanPreference(oldPrefs, newPrefs, "enableDoubleActions", "enabled_gestures.double_actions", true) + migrateBooleanPreference(oldPrefs, newPrefs, "enableEdgeActions", "enabled_gestures.edge_actions", true) + migrateBooleanPreference(oldPrefs, newPrefs, "searchAutoLaunch", "functionality.search_auto_launch", true) + migrateBooleanPreference(oldPrefs, newPrefs, "searchAutoKeyboard", "functionality.search_auto_keyboard", true) + + newPrefs.apply() + + when(oldPrefs.getString("theme", "finn")) { + "finn" -> { + LauncherPreferences.theme().colorTheme(ColorTheme.DEFAULT) + LauncherPreferences.theme().monochromeIcons(false) + LauncherPreferences.theme().background(Background.BLUR) + } + "dark" -> { + LauncherPreferences.theme().colorTheme(ColorTheme.DARK) + LauncherPreferences.theme().monochromeIcons(true) + LauncherPreferences.theme().background(Background.BLUR) + } + } + + + LauncherPreferences.internal().versionCode(PREFERENCE_VERSION) + Log.i("Launcher", "migration of preferences complete.") - /* - * before, the dominant and vibrant color of the `finn` and `dark` theme - * were not stored anywhere. Now they have to be stored: - * -> we just reset them using newly implemented functions - */ - /*when (LauncherPreferences.theme().colorTheme()) { - "finn" -> resetToDefaultTheme(activity) - "dark" -> resetToDarkTheme(activity) - } */ - LauncherPreferences.internal().versionCode(VERSION_CODE) // show the new tutorial - activity.startActivity(Intent(activity, TutorialActivity::class.java)) + // context.startActivity(Intent(context, TutorialActivity::class.java)) } + else -> {} } } -fun resetSettings(context: Context) { - +fun resetPreferences(context: Context) { + Log.i("Launcher", "resetting preferences") + LauncherPreferences.clear() + LauncherPreferences.internal().versionCode(PREFERENCE_VERSION) val editor = LauncherPreferences.getSharedPreferences().edit() - Gesture.values().forEach { editor.putString(it.id, it.pickDefaultApp(context)) } + Gesture.values().forEach { editor.putString(it.id + ".app", it.pickDefaultApp(context)) } + Gesture.values().forEach { editor.putInt(it.id + ".user", -1) } editor.apply() - - // set default theme - val dominantColor = context.resources.getColor(R.color.finnmglasTheme_background_color) - val vibrantColor = context.resources.getColor(R.color.finnmglasTheme_accent_color) - - - LauncherPreferences.theme().dominant(dominantColor) - LauncherPreferences.theme().vibrant(vibrantColor) -} - - - +} \ No newline at end of file diff --git a/app/src/main/java/de/jrpie/android/launcher/settings/SettingsActivity.kt b/app/src/main/java/de/jrpie/android/launcher/settings/SettingsActivity.kt index 9f4278b..c021f34 100644 --- a/app/src/main/java/de/jrpie/android/launcher/settings/SettingsActivity.kt +++ b/app/src/main/java/de/jrpie/android/launcher/settings/SettingsActivity.kt @@ -7,17 +7,14 @@ import android.content.res.Resources import android.os.Bundle import android.provider.Settings import androidx.appcompat.app.AppCompatActivity +import androidx.viewpager.widget.ViewPager +import de.jrpie.android.launcher.* +import com.google.android.material.tabs.TabLayout +import de.jrpie.android.launcher.databinding.SettingsBinding import androidx.fragment.app.Fragment import androidx.fragment.app.FragmentManager import androidx.fragment.app.FragmentPagerAdapter -import androidx.viewpager.widget.ViewPager -import com.google.android.material.tabs.TabLayout -import de.jrpie.android.launcher.R -import de.jrpie.android.launcher.REQUEST_CHOOSE_APP -import de.jrpie.android.launcher.UIObject -import de.jrpie.android.launcher.databinding.SettingsBinding import de.jrpie.android.launcher.preferences.LauncherPreferences -import de.jrpie.android.launcher.saveListActivityChoice import de.jrpie.android.launcher.settings.actions.SettingsFragmentActions import de.jrpie.android.launcher.settings.launcher.SettingsFragmentLauncher import de.jrpie.android.launcher.settings.meta.SettingsFragmentMeta @@ -31,11 +28,11 @@ import de.jrpie.android.launcher.settings.meta.SettingsFragmentMeta * * Settings are closed automatically if the activity goes `onPause` unexpectedly. */ -class SettingsActivity : AppCompatActivity(), UIObject { +class SettingsActivity: AppCompatActivity(), UIObject { private var sharedPreferencesListener = - SharedPreferences.OnSharedPreferenceChangeListener { _, prefKey -> - if (prefKey?.startsWith("theme.") == true) { + SharedPreferences.OnSharedPreferenceChangeListener { _,prefKey -> + if(prefKey?.startsWith("theme.") == true) { recreate() } } @@ -59,13 +56,11 @@ class SettingsActivity : AppCompatActivity(), UIObject { override fun onStart() { super.onStart() super.onStart() - LauncherPreferences.getSharedPreferences() - .registerOnSharedPreferenceChangeListener(sharedPreferencesListener) + LauncherPreferences.getSharedPreferences().registerOnSharedPreferenceChangeListener(sharedPreferencesListener) } override fun onPause() { - LauncherPreferences.getSharedPreferences() - .unregisterOnSharedPreferenceChangeListener(sharedPreferencesListener) + LauncherPreferences.getSharedPreferences().unregisterOnSharedPreferenceChangeListener(sharedPreferencesListener) super.onPause() } @@ -73,7 +68,7 @@ class SettingsActivity : AppCompatActivity(), UIObject { return modifyTheme(super.getTheme()) } - override fun setOnClicks() { + override fun setOnClicks(){ // As older APIs somehow do not recognize the xml defined onClick binding.settingsClose.setOnClickListener { finish() } // open device settings (see https://stackoverflow.com/a/62092663/12787264) @@ -96,11 +91,11 @@ private val TAB_TITLES = arrayOf( R.string.settings_tab_meta ) -class SettingsSectionsPagerAdapter(private val context: Context, fm: FragmentManager) : - FragmentPagerAdapter(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) { +class SettingsSectionsPagerAdapter(private val context: Context, fm: FragmentManager) + : FragmentPagerAdapter(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) { override fun getItem(position: Int): Fragment { - return when (position) { + return when (position){ 0 -> SettingsFragmentActions() 1 -> SettingsFragmentLauncher() 2 -> SettingsFragmentMeta() @@ -112,7 +107,5 @@ class SettingsSectionsPagerAdapter(private val context: Context, fm: FragmentMan return context.resources.getString(TAB_TITLES[position]) } - override fun getCount(): Int { - return 3 - } + override fun getCount(): Int { return 3 } } diff --git a/app/src/main/java/de/jrpie/android/launcher/settings/actions/SettingsFragmentActions.kt b/app/src/main/java/de/jrpie/android/launcher/settings/actions/SettingsFragmentActions.kt index e03f610..bd0fa19 100644 --- a/app/src/main/java/de/jrpie/android/launcher/settings/actions/SettingsFragmentActions.kt +++ b/app/src/main/java/de/jrpie/android/launcher/settings/actions/SettingsFragmentActions.kt @@ -44,22 +44,18 @@ SettingsFragmentActions : Fragment(), UIObject { override fun setOnClicks() { // App management buttons - binding!!.settingsActionsButtonViewApps.setOnClickListener { + binding!!.settingsActionsButtonViewApps.setOnClickListener{ val intent = Intent(this.context, ListActivity::class.java) intent.putExtra("intention", ListActivity.ListActivityIntention.VIEW.toString()) startActivity(intent) } - binding!!.settingsActionsButtonInstallApps.setOnClickListener { + binding!!.settingsActionsButtonInstallApps.setOnClickListener{ try { val intent = Intent(Intent.ACTION_MAIN) intent.addCategory(Intent.CATEGORY_APP_MARKET) startActivity(intent) } catch (e: ActivityNotFoundException) { - Toast.makeText( - context, - getString(R.string.settings_apps_toast_store_not_found), - Toast.LENGTH_SHORT - ).show() + Toast.makeText(context, getString(R.string.settings_apps_toast_store_not_found), Toast.LENGTH_SHORT).show() } } } diff --git a/app/src/main/java/de/jrpie/android/launcher/settings/actions/SettingsFragmentActionsRecycler.kt b/app/src/main/java/de/jrpie/android/launcher/settings/actions/SettingsFragmentActionsRecycler.kt index d87c10c..50bfa6c 100644 --- a/app/src/main/java/de/jrpie/android/launcher/settings/actions/SettingsFragmentActionsRecycler.kt +++ b/app/src/main/java/de/jrpie/android/launcher/settings/actions/SettingsFragmentActionsRecycler.kt @@ -1,28 +1,25 @@ package de.jrpie.android.launcher.settings.actions -import android.app.Activity -import android.content.Intent -import android.content.SharedPreferences import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import androidx.fragment.app.Fragment +import androidx.recyclerview.widget.LinearLayoutManager +import de.jrpie.android.launcher.* +import de.jrpie.android.launcher.list.ListActivity +import android.app.Activity +import android.content.Intent +import android.content.SharedPreferences +import android.util.Log import android.widget.Button import android.widget.ImageView import android.widget.TextView -import androidx.fragment.app.Fragment -import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView -import de.jrpie.android.launcher.Gesture -import de.jrpie.android.launcher.R -import de.jrpie.android.launcher.REQUEST_CHOOSE_APP -import de.jrpie.android.launcher.UIObject -import de.jrpie.android.launcher.databinding.SettingsActionsRecyclerBinding -import de.jrpie.android.launcher.getAppIcon -import de.jrpie.android.launcher.list.ListActivity import de.jrpie.android.launcher.list.other.LauncherAction +import de.jrpie.android.launcher.databinding.SettingsActionsRecyclerBinding import de.jrpie.android.launcher.preferences.LauncherPreferences -import de.jrpie.android.launcher.transformGrayscale +import java.lang.Exception /** * The [SettingsFragmentActionsRecycler] is a fragment containing the [ActionsRecyclerAdapter], @@ -52,7 +49,7 @@ class SettingsFragmentActionsRecycler : Fragment(), UIObject { // set up the list / recycler val actionViewManager = LinearLayoutManager(context) - actionViewAdapter = ActionsRecyclerAdapter(requireActivity()) + actionViewAdapter = ActionsRecyclerAdapter( requireActivity() ) binding.settingsActionsRview.apply { // improve performance (since content changes don't change the layout size) @@ -60,21 +57,19 @@ class SettingsFragmentActionsRecycler : Fragment(), UIObject { layoutManager = actionViewManager adapter = actionViewAdapter } - LauncherPreferences.getSharedPreferences() - .registerOnSharedPreferenceChangeListener(sharedPreferencesListener) + LauncherPreferences.getSharedPreferences().registerOnSharedPreferenceChangeListener(sharedPreferencesListener) super.onStart() } override fun onDestroy() { - LauncherPreferences.getSharedPreferences() - .unregisterOnSharedPreferenceChangeListener(sharedPreferencesListener) + LauncherPreferences.getSharedPreferences().unregisterOnSharedPreferenceChangeListener(sharedPreferencesListener) super.onDestroy() } } -class ActionsRecyclerAdapter(val activity: Activity) : +class ActionsRecyclerAdapter(val activity: Activity): RecyclerView.Adapter() { private val gesturesList: ArrayList @@ -86,11 +81,9 @@ class ActionsRecyclerAdapter(val activity: Activity) : var chooseButton: Button = itemView.findViewById(R.id.settings_actions_row_button_choose) var removeAction: ImageView = itemView.findViewById(R.id.settings_actions_row_remove) - override fun onClick(v: View) {} + override fun onClick(v: View) { } - init { - itemView.setOnClickListener(this) - } + init { itemView.setOnClickListener(this) } } private fun updateViewHolder(gesture: Gesture, viewHolder: ViewHolder) { @@ -99,11 +92,12 @@ class ActionsRecyclerAdapter(val activity: Activity) : viewHolder.img.visibility = View.VISIBLE viewHolder.removeAction.visibility = View.VISIBLE viewHolder.chooseButton.visibility = View.INVISIBLE - if (content.isEmpty()) { + if (content.isEmpty()){ viewHolder.img.visibility = View.INVISIBLE viewHolder.removeAction.visibility = View.GONE viewHolder.chooseButton.visibility = View.VISIBLE - } else if (LauncherAction.isOtherAction(content)) { + } + else if (LauncherAction.isOtherAction(content)) { LauncherAction.byId(content)?.let { viewHolder.img.setImageResource(it.icon) } @@ -111,7 +105,7 @@ class ActionsRecyclerAdapter(val activity: Activity) : // Set image icon (by packageName) try { viewHolder.img.setImageDrawable(getAppIcon(activity, content, app.second)) - } catch (e: Exception) { + } catch (e : Exception) { // Probably the app was uninstalled // the button is shown, user asked to select an action viewHolder.img.visibility = View.INVISIBLE @@ -125,16 +119,14 @@ class ActionsRecyclerAdapter(val activity: Activity) : val gesture = gesturesList[i] viewHolder.textView.text = gesture.getLabel(activity) if (LauncherPreferences.theme().monochromeIcons()) - transformGrayscale(viewHolder.img) + transformGrayscale( viewHolder.img ) updateViewHolder(gesture, viewHolder) - viewHolder.img.setOnClickListener { chooseApp(gesture) } - viewHolder.chooseButton.setOnClickListener { chooseApp(gesture) } - viewHolder.removeAction.setOnClickListener { gesture.removeApp(activity) } + viewHolder.img.setOnClickListener{ chooseApp(gesture) } + viewHolder.chooseButton.setOnClickListener{ chooseApp(gesture) } + viewHolder.removeAction.setOnClickListener{ gesture.removeApp(activity) } } - override fun getItemCount(): Int { - return gesturesList.size - } + override fun getItemCount(): Int { return gesturesList.size } override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { val inflater = LayoutInflater.from(parent.context) @@ -147,8 +139,7 @@ class ActionsRecyclerAdapter(val activity: Activity) : val edgeActions = LauncherPreferences.enabled_gestures().edgeSwipe() gesturesList = Gesture.values().filter { (doubleActions || !it.isDoubleVariant()) - && (edgeActions || !it.isEdgeVariant()) - } as ArrayList + && (edgeActions || !it.isEdgeVariant())} as ArrayList } fun updateActions() { @@ -157,8 +148,7 @@ class ActionsRecyclerAdapter(val activity: Activity) : this.gesturesList.clear() gesturesList.addAll(Gesture.values().filter { (doubleActions || !it.isDoubleVariant()) - && (edgeActions || !it.isEdgeVariant()) - }) + && (edgeActions || !it.isEdgeVariant())}) notifyDataSetChanged() } @@ -168,8 +158,7 @@ class ActionsRecyclerAdapter(val activity: Activity) : val intent = Intent(activity, ListActivity::class.java) intent.putExtra("intention", ListActivity.ListActivityIntention.PICK.toString()) intent.putExtra("forGesture", gesture.id) // for which action we choose the app - activity.startActivityForResult( - intent, + activity.startActivityForResult(intent, REQUEST_CHOOSE_APP ) } diff --git a/app/src/main/java/de/jrpie/android/launcher/settings/launcher/SettingsFragmentLauncher.kt b/app/src/main/java/de/jrpie/android/launcher/settings/launcher/SettingsFragmentLauncher.kt index 94d1e10..10fdc44 100644 --- a/app/src/main/java/de/jrpie/android/launcher/settings/launcher/SettingsFragmentLauncher.kt +++ b/app/src/main/java/de/jrpie/android/launcher/settings/launcher/SettingsFragmentLauncher.kt @@ -4,8 +4,8 @@ import android.content.Context import android.content.Intent import android.os.Bundle import androidx.preference.PreferenceFragmentCompat -import de.jrpie.android.launcher.R import de.jrpie.android.launcher.preferences.LauncherPreferences +import de.jrpie.android.launcher.R import de.jrpie.android.launcher.setDefaultHomeScreen @@ -17,13 +17,9 @@ import de.jrpie.android.launcher.setDefaultHomeScreen class SettingsFragmentLauncher : PreferenceFragmentCompat() { override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { - preferenceManager.sharedPreferencesName = getString(R.string.preference_file_key) - preferenceManager.sharedPreferencesMode = Context.MODE_PRIVATE setPreferencesFromResource(R.xml.preferences, rootKey) - val selectWallpaper = findPreference( - LauncherPreferences.theme().keys().wallpaper() - ) + val selectWallpaper = findPreference(LauncherPreferences.theme().keys().wallpaper()) selectWallpaper?.setOnPreferenceClickListener { // https://github.com/LineageOS/android_packages_apps_Trebuchet/blob/6caab89b21b2b91f0a439e1fd8c4510dcb255819/src/com/android/launcher3/views/OptionsPopupView.java#L271 val intent = Intent(Intent.ACTION_SET_WALLPAPER) @@ -32,9 +28,7 @@ class SettingsFragmentLauncher : PreferenceFragmentCompat() { startActivity(intent) true } - val chooseHomeScreen = findPreference( - LauncherPreferences.general().keys().chooseHomeScreen() - ) + val chooseHomeScreen = findPreference(LauncherPreferences.general().keys().chooseHomeScreen()) chooseHomeScreen?.setOnPreferenceClickListener { setDefaultHomeScreen(requireContext(), checkDefault = false) true diff --git a/app/src/main/java/de/jrpie/android/launcher/settings/meta/SettingsFragmentMeta.kt b/app/src/main/java/de/jrpie/android/launcher/settings/meta/SettingsFragmentMeta.kt index bcec08f..2a19c13 100644 --- a/app/src/main/java/de/jrpie/android/launcher/settings/meta/SettingsFragmentMeta.kt +++ b/app/src/main/java/de/jrpie/android/launcher/settings/meta/SettingsFragmentMeta.kt @@ -10,10 +10,10 @@ import android.view.ViewGroup import androidx.fragment.app.Fragment import de.jrpie.android.launcher.R import de.jrpie.android.launcher.UIObject -import de.jrpie.android.launcher.databinding.SettingsMetaBinding import de.jrpie.android.launcher.openNewTabWindow -import de.jrpie.android.launcher.preferences.resetSettings import de.jrpie.android.launcher.tutorial.TutorialActivity +import de.jrpie.android.launcher.databinding.SettingsMetaBinding +import de.jrpie.android.launcher.preferences.resetPreferences /** * The [SettingsFragmentMeta] is a used as a tab in the SettingsActivity. @@ -65,10 +65,9 @@ class SettingsFragmentMeta : Fragment(), UIObject { AlertDialog.Builder(this.requireContext(), R.style.AlertDialogCustom) .setTitle(getString(R.string.settings_meta_reset)) .setMessage(getString(R.string.settings_meta_reset_confirm)) - .setPositiveButton( - android.R.string.ok + .setPositiveButton(android.R.string.ok ) { _, _ -> - resetSettings(this.requireContext()) + resetPreferences(this.requireContext()) requireActivity().finish() } .setNegativeButton(android.R.string.cancel, null) @@ -86,6 +85,7 @@ class SettingsFragmentMeta : Fragment(), UIObject { } + // contact developer binding.settingsMetaButtonContact.setOnClickListener { openNewTabWindow( diff --git a/app/src/main/java/de/jrpie/android/launcher/tutorial/TutorialActivity.kt b/app/src/main/java/de/jrpie/android/launcher/tutorial/TutorialActivity.kt index 0c0e75b..a9e0478 100644 --- a/app/src/main/java/de/jrpie/android/launcher/tutorial/TutorialActivity.kt +++ b/app/src/main/java/de/jrpie/android/launcher/tutorial/TutorialActivity.kt @@ -1,6 +1,7 @@ package de.jrpie.android.launcher.tutorial import android.content.Intent +import android.content.res.Resources import android.os.Bundle import androidx.appcompat.app.AppCompatActivity import androidx.fragment.app.Fragment @@ -8,11 +9,10 @@ import androidx.fragment.app.FragmentManager import androidx.fragment.app.FragmentPagerAdapter import androidx.viewpager.widget.ViewPager import com.google.android.material.tabs.TabLayout +import de.jrpie.android.launcher.preferences.LauncherPreferences import de.jrpie.android.launcher.R import de.jrpie.android.launcher.REQUEST_CHOOSE_APP import de.jrpie.android.launcher.UIObject -import de.jrpie.android.launcher.preferences.LauncherPreferences -import de.jrpie.android.launcher.preferences.resetSettings import de.jrpie.android.launcher.saveListActivityChoice import de.jrpie.android.launcher.tutorial.tabs.TutorialFragmentConcept import de.jrpie.android.launcher.tutorial.tabs.TutorialFragmentFinish @@ -27,7 +27,7 @@ import de.jrpie.android.launcher.tutorial.tabs.TutorialFragmentUsage * It tells the user about the concept behind launcher * and helps with the setup process (on new installations) */ -class TutorialActivity : AppCompatActivity(), UIObject { +class TutorialActivity: AppCompatActivity(), UIObject { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -35,10 +35,6 @@ class TutorialActivity : AppCompatActivity(), UIObject { // Initialise layout setContentView(R.layout.tutorial) - // Check if the app was started before - if (!LauncherPreferences.internal().started()) - resetSettings(this) - // set up tabs and swiping in settings val sectionsPagerAdapter = TutorialSectionsPagerAdapter(supportFragmentManager) val viewPager: ViewPager = findViewById(R.id.tutorial_viewpager) @@ -47,6 +43,10 @@ class TutorialActivity : AppCompatActivity(), UIObject { tabs.setupWithViewPager(viewPager) } + override fun getTheme(): Resources.Theme { + return modifyTheme(super.getTheme()) + } + override fun onStart() { super.onStart() super.onStart() @@ -54,7 +54,7 @@ class TutorialActivity : AppCompatActivity(), UIObject { override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { when (requestCode) { - REQUEST_CHOOSE_APP -> saveListActivityChoice(this, data) + REQUEST_CHOOSE_APP -> saveListActivityChoice(this,data) else -> super.onActivityResult(requestCode, resultCode, data) } } @@ -73,11 +73,11 @@ class TutorialActivity : AppCompatActivity(), UIObject { * * Tabs: (Start | Concept | Usage | Setup | Finish) */ -class TutorialSectionsPagerAdapter(fm: FragmentManager) : - FragmentPagerAdapter(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) { +class TutorialSectionsPagerAdapter(fm: FragmentManager) + : FragmentPagerAdapter(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) { override fun getItem(position: Int): Fragment { - return when (position) { + return when (position){ 0 -> TutorialFragmentStart() 1 -> TutorialFragmentConcept() 2 -> TutorialFragmentUsage() @@ -88,11 +88,6 @@ class TutorialSectionsPagerAdapter(fm: FragmentManager) : } /* We don't use titles here, as we have the dots */ - override fun getPageTitle(position: Int): CharSequence { - return "" - } - - override fun getCount(): Int { - return 5 - } + override fun getPageTitle(position: Int): CharSequence { return "" } + override fun getCount(): Int { return 5 } } diff --git a/app/src/main/java/de/jrpie/android/launcher/tutorial/tabs/TutorialFragmentConcept.kt b/app/src/main/java/de/jrpie/android/launcher/tutorial/tabs/TutorialFragmentConcept.kt index 4296e3d..ffeb464 100644 --- a/app/src/main/java/de/jrpie/android/launcher/tutorial/tabs/TutorialFragmentConcept.kt +++ b/app/src/main/java/de/jrpie/android/launcher/tutorial/tabs/TutorialFragmentConcept.kt @@ -8,7 +8,6 @@ import androidx.fragment.app.Fragment import de.jrpie.android.launcher.BuildConfig import de.jrpie.android.launcher.UIObject import de.jrpie.android.launcher.databinding.TutorialConceptBinding - /** * The [TutorialFragmentConcept] is a used as a tab in the TutorialActivity. * @@ -26,7 +25,7 @@ class TutorialFragmentConcept : Fragment(), UIObject { return binding.root } - override fun onStart() { + override fun onStart(){ super.onStart() super.onStart() } diff --git a/app/src/main/java/de/jrpie/android/launcher/tutorial/tabs/TutorialFragmentFinish.kt b/app/src/main/java/de/jrpie/android/launcher/tutorial/tabs/TutorialFragmentFinish.kt index 94940f5..f4598b1 100644 --- a/app/src/main/java/de/jrpie/android/launcher/tutorial/tabs/TutorialFragmentFinish.kt +++ b/app/src/main/java/de/jrpie/android/launcher/tutorial/tabs/TutorialFragmentFinish.kt @@ -1,15 +1,14 @@ package de.jrpie.android.launcher.tutorial.tabs import android.os.Bundle +import androidx.fragment.app.Fragment import android.view.LayoutInflater import android.view.View import android.view.ViewGroup -import androidx.fragment.app.Fragment +import de.jrpie.android.launcher.* import de.jrpie.android.launcher.BuildConfig.VERSION_CODE -import de.jrpie.android.launcher.UIObject import de.jrpie.android.launcher.databinding.TutorialFinishBinding import de.jrpie.android.launcher.preferences.LauncherPreferences -import de.jrpie.android.launcher.setDefaultHomeScreen /** * The [TutorialFragmentFinish] is a used as a tab in the TutorialActivity. @@ -35,11 +34,11 @@ class TutorialFragmentFinish : Fragment(), UIObject { override fun setOnClicks() { super.setOnClicks() - binding.tutorialFinishButtonStart.setOnClickListener { finishTutorial() } + binding.tutorialFinishButtonStart.setOnClickListener{ finishTutorial() } } private fun finishTutorial() { - if (!LauncherPreferences.internal().started()) { + if(!LauncherPreferences.internal().started()) { LauncherPreferences.internal().started(true) LauncherPreferences.internal().startedTime(System.currentTimeMillis() / 1000L) LauncherPreferences.internal().versionCode(VERSION_CODE) diff --git a/app/src/main/java/de/jrpie/android/launcher/tutorial/tabs/TutorialFragmentSetup.kt b/app/src/main/java/de/jrpie/android/launcher/tutorial/tabs/TutorialFragmentSetup.kt index 2aab7c9..a71088d 100644 --- a/app/src/main/java/de/jrpie/android/launcher/tutorial/tabs/TutorialFragmentSetup.kt +++ b/app/src/main/java/de/jrpie/android/launcher/tutorial/tabs/TutorialFragmentSetup.kt @@ -22,7 +22,7 @@ class TutorialFragmentSetup : Fragment(), UIObject { return inflater.inflate(R.layout.tutorial_setup, container, false) } - override fun onStart() { + override fun onStart(){ super.onStart() super.onStart() } diff --git a/app/src/main/java/de/jrpie/android/launcher/tutorial/tabs/TutorialFragmentStart.kt b/app/src/main/java/de/jrpie/android/launcher/tutorial/tabs/TutorialFragmentStart.kt index 40b5e7c..433da9b 100644 --- a/app/src/main/java/de/jrpie/android/launcher/tutorial/tabs/TutorialFragmentStart.kt +++ b/app/src/main/java/de/jrpie/android/launcher/tutorial/tabs/TutorialFragmentStart.kt @@ -1,12 +1,11 @@ package de.jrpie.android.launcher.tutorial.tabs import android.os.Bundle +import androidx.fragment.app.Fragment import android.view.LayoutInflater import android.view.View import android.view.ViewGroup -import androidx.fragment.app.Fragment -import de.jrpie.android.launcher.UIObject -import de.jrpie.android.launcher.blink +import de.jrpie.android.launcher.* import de.jrpie.android.launcher.databinding.TutorialStartBinding /** @@ -26,7 +25,7 @@ class TutorialFragmentStart : Fragment(), UIObject { return binding.root } - override fun onStart() { + override fun onStart(){ super.onStart() super.onStart() } diff --git a/app/src/main/java/de/jrpie/android/launcher/tutorial/tabs/TutorialFragmentUsage.kt b/app/src/main/java/de/jrpie/android/launcher/tutorial/tabs/TutorialFragmentUsage.kt index 8cd7f9d..00cd9d3 100644 --- a/app/src/main/java/de/jrpie/android/launcher/tutorial/tabs/TutorialFragmentUsage.kt +++ b/app/src/main/java/de/jrpie/android/launcher/tutorial/tabs/TutorialFragmentUsage.kt @@ -22,7 +22,7 @@ class TutorialFragmentUsage : Fragment(), UIObject { return inflater.inflate(R.layout.tutorial_usage, container, false) } - override fun onStart() { + override fun onStart(){ super.onStart() super.onStart() } diff --git a/app/src/main/res/anim/bottom_up.xml b/app/src/main/res/anim/bottom_up.xml index 50889e5..1a128eb 100644 --- a/app/src/main/res/anim/bottom_up.xml +++ b/app/src/main/res/anim/bottom_up.xml @@ -2,9 +2,9 @@ + android:duration="100"/> \ No newline at end of file diff --git a/app/src/main/res/anim/left_right.xml b/app/src/main/res/anim/left_right.xml index 7b5eb38..1dd2cb4 100644 --- a/app/src/main/res/anim/left_right.xml +++ b/app/src/main/res/anim/left_right.xml @@ -2,9 +2,9 @@ + android:duration="100"/> \ No newline at end of file diff --git a/app/src/main/res/anim/right_left.xml b/app/src/main/res/anim/right_left.xml index ecccc1f..58e2060 100644 --- a/app/src/main/res/anim/right_left.xml +++ b/app/src/main/res/anim/right_left.xml @@ -2,9 +2,9 @@ + android:duration="100"/> \ No newline at end of file diff --git a/app/src/main/res/anim/top_down.xml b/app/src/main/res/anim/top_down.xml index 84798ce..239c475 100644 --- a/app/src/main/res/anim/top_down.xml +++ b/app/src/main/res/anim/top_down.xml @@ -2,9 +2,9 @@ + android:duration="100"/> \ No newline at end of file diff --git a/app/src/main/res/drawable/baseline_close_24.xml b/app/src/main/res/drawable/baseline_close_24.xml index fcfb043..a6a4319 100644 --- a/app/src/main/res/drawable/baseline_close_24.xml +++ b/app/src/main/res/drawable/baseline_close_24.xml @@ -1,12 +1,5 @@ - + - + diff --git a/app/src/main/res/drawable/baseline_menu_24.xml b/app/src/main/res/drawable/baseline_menu_24.xml index 4802bd8..69b6549 100644 --- a/app/src/main/res/drawable/baseline_menu_24.xml +++ b/app/src/main/res/drawable/baseline_menu_24.xml @@ -1,12 +1,5 @@ - + - + diff --git a/app/src/main/res/drawable/baseline_more_horiz_24.xml b/app/src/main/res/drawable/baseline_more_horiz_24.xml index c9007c6..a370298 100644 --- a/app/src/main/res/drawable/baseline_more_horiz_24.xml +++ b/app/src/main/res/drawable/baseline_more_horiz_24.xml @@ -1,12 +1,5 @@ - + - + diff --git a/app/src/main/res/drawable/baseline_not_interested_24.xml b/app/src/main/res/drawable/baseline_not_interested_24.xml index 6cc4b8c..8666b2e 100644 --- a/app/src/main/res/drawable/baseline_not_interested_24.xml +++ b/app/src/main/res/drawable/baseline_not_interested_24.xml @@ -1,12 +1,5 @@ - + - + diff --git a/app/src/main/res/drawable/baseline_notifications_24.xml b/app/src/main/res/drawable/baseline_notifications_24.xml index fd97353..c80cfc4 100644 --- a/app/src/main/res/drawable/baseline_notifications_24.xml +++ b/app/src/main/res/drawable/baseline_notifications_24.xml @@ -1,12 +1,5 @@ - + - + diff --git a/app/src/main/res/drawable/baseline_search_24.xml b/app/src/main/res/drawable/baseline_search_24.xml index c599843..2fd74fb 100644 --- a/app/src/main/res/drawable/baseline_search_24.xml +++ b/app/src/main/res/drawable/baseline_search_24.xml @@ -1,12 +1,5 @@ - + - + diff --git a/app/src/main/res/drawable/baseline_settings_24.xml b/app/src/main/res/drawable/baseline_settings_24.xml index 5f1bc1c..1a56e8f 100644 --- a/app/src/main/res/drawable/baseline_settings_24.xml +++ b/app/src/main/res/drawable/baseline_settings_24.xml @@ -1,12 +1,5 @@ - + - + diff --git a/app/src/main/res/drawable/baseline_settings_applications_24.xml b/app/src/main/res/drawable/baseline_settings_applications_24.xml index 0f3525c..9fb4bf4 100644 --- a/app/src/main/res/drawable/baseline_settings_applications_24.xml +++ b/app/src/main/res/drawable/baseline_settings_applications_24.xml @@ -1,12 +1,5 @@ - + - + diff --git a/app/src/main/res/drawable/baseline_skip_next_24.xml b/app/src/main/res/drawable/baseline_skip_next_24.xml index 164be15..dd1ec32 100644 --- a/app/src/main/res/drawable/baseline_skip_next_24.xml +++ b/app/src/main/res/drawable/baseline_skip_next_24.xml @@ -1,12 +1,5 @@ - + - + diff --git a/app/src/main/res/drawable/baseline_skip_previous_24.xml b/app/src/main/res/drawable/baseline_skip_previous_24.xml index ef93ccf..678e831 100644 --- a/app/src/main/res/drawable/baseline_skip_previous_24.xml +++ b/app/src/main/res/drawable/baseline_skip_previous_24.xml @@ -1,12 +1,5 @@ - + - + diff --git a/app/src/main/res/drawable/baseline_volume_down_24.xml b/app/src/main/res/drawable/baseline_volume_down_24.xml index 15840c2..fa9f447 100644 --- a/app/src/main/res/drawable/baseline_volume_down_24.xml +++ b/app/src/main/res/drawable/baseline_volume_down_24.xml @@ -1,13 +1,5 @@ - + - + diff --git a/app/src/main/res/drawable/baseline_volume_up_24.xml b/app/src/main/res/drawable/baseline_volume_up_24.xml index 95b0f36..f9555f0 100644 --- a/app/src/main/res/drawable/baseline_volume_up_24.xml +++ b/app/src/main/res/drawable/baseline_volume_up_24.xml @@ -1,13 +1,5 @@ - + - + diff --git a/app/src/main/res/drawable/tutorial_default_dot.xml b/app/src/main/res/drawable/tutorial_default_dot.xml index d870a0f..29ebcd3 100644 --- a/app/src/main/res/drawable/tutorial_default_dot.xml +++ b/app/src/main/res/drawable/tutorial_default_dot.xml @@ -6,7 +6,7 @@ android:shape="ring" android:thickness="5dp" android:useLevel="false"> - + \ No newline at end of file diff --git a/app/src/main/res/drawable/tutorial_selected_dot.xml b/app/src/main/res/drawable/tutorial_selected_dot.xml index 68a3299..1adc83c 100644 --- a/app/src/main/res/drawable/tutorial_selected_dot.xml +++ b/app/src/main/res/drawable/tutorial_selected_dot.xml @@ -6,7 +6,7 @@ android:shape="ring" android:thickness="5dp" android:useLevel="false"> - + \ No newline at end of file diff --git a/app/src/main/res/drawable/tutorial_tab_selector.xml b/app/src/main/res/drawable/tutorial_tab_selector.xml index 2171911..67dbf34 100644 --- a/app/src/main/res/drawable/tutorial_tab_selector.xml +++ b/app/src/main/res/drawable/tutorial_tab_selector.xml @@ -1,7 +1,8 @@ - + - + \ No newline at end of file diff --git a/app/src/main/res/layout/home.xml b/app/src/main/res/layout/home.xml index 598c57b..b213078 100644 --- a/app/src/main/res/layout/home.xml +++ b/app/src/main/res/layout/home.xml @@ -1,6 +1,8 @@ - - - - - - + custom:type="solid" + android:layout_marginStart="8dp" /> + app:layout_constraintTop_toTopOf="parent"/> - + app:layout_constraintTop_toTopOf="parent" + /> - - + app:tabIndicatorHeight="0dp" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" /> \ No newline at end of file diff --git a/app/src/main/res/layout/tutorial_concept.xml b/app/src/main/res/layout/tutorial_concept.xml index 93fb3e1..c04f7c9 100644 --- a/app/src/main/res/layout/tutorial_concept.xml +++ b/app/src/main/res/layout/tutorial_concept.xml @@ -1,12 +1,13 @@ - - - - - - diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml index c9ad5f9..036d09b 100644 --- a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -1,5 +1,5 @@ - - + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml index c9ad5f9..036d09b 100644 --- a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -1,5 +1,5 @@ - - + + \ No newline at end of file diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 95210ee..22b0866 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -80,7 +80,7 @@ Bildschirm Bildschirm nicht ausschalten - Vollbild + Vollbild Funktionen @@ -110,7 +110,6 @@ Unserem Discord beitreten Entwickler kontaktieren - https://www.finnmglas.com/de/kontakt/ Entwickler des Fork kontaktieren Datenschutzerklärung diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index db4c077..6ebb81a 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -1,6 +1,6 @@ - - V3RYR4ND0MK3YCR4P - startedBefore - firstStartup - version_code - settings.general.select_launcher - - Swipe Up - Double Up - Swipe Down - Double Down - Swipe Left - Double Left - Swipe Right - Double Right - Swipe Right (Top) - Swipe Right (Bottom) - Swipe Left (Bottom) - Swipe Left (Top) - Swipe Up (Left Edge) - Swipe Up (Right Edge) - Swipe Down (Left Edge) - Swipe Down (Right Edge) - Volume Up - Volume Down - Double Click - Long Click - Click on Date - Click on Time + μLauncher + + internal.started_before + internal.first_startup + internal.version_code + general.select_launcher + + Swipe Up + Double Up + Swipe Down + Double Down + Swipe Left + Double Left + Swipe Right + Double Right + Swipe Right (Top) + Swipe Right (Bottom) + Swipe Left (Bottom) + Swipe Left (Top) + Swipe Up (Left Edge) + Swipe Up (Right Edge) + Swipe Down (Left Edge) + Swipe Down (Right Edge) + Volume Up + Volume Down + Double Click + Long Click + Click on Date + Click on Time - - theme.color_theme - - DEFAULT - DARK - - - theme.background - - TRANSPARENT - DIM - BLUR - SOLID - - theme.wallpaper - theme.font - - HACK - SYSTEM_DEFAULT - - theme.monochrome_icons - - timeVisible - dateVisible - dateLocalized - dateTimeFlip + + theme.color_theme + + DEFAULT + DARK + + + theme.background + + TRANSPARENT + DIM + BLUR + SOLID + + theme.wallpaper + theme.font + + HACK + SYSTEM_DEFAULT + + theme.monochrome_icons + + + clock.time_visible + clock.date_visible + clock.date_localized + clock.date_time_flip - - disableTimeout - useFullScreen + + display.disable_timeout + display.use_full_screen - enableDoubleActions - enableEdgeActions - searchAutoLaunch - searchAutoKeyboard + enabled_gestures.double_actions + enabled_gestures.edge_actions + functionality.search_auto_launch + functionality.search_auto_keyboard - - https://github.com/jrpie/Launcher - https://github.com/jrpie/Launcher/issues/new - https://s.jrpie.de/contact - https://s.jrpie.de/android-legal - https://www.finnmglas.com/contact/ - https://discord.com/invite/jV2AhF8 + + + https://github.com/jrpie/Launcher + https://github.com/jrpie/Launcher/issues/new + https://s.jrpie.de/contact + https://s.jrpie.de/android-legal + https://www.finnmglas.com/contact/ + https://discord.com/invite/jV2AhF8 - - >>>>>]]> + + >>>>>]]> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 9c3218b..2f4bd22 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,9 +1,9 @@ - + Can\'t open app Want to change its settings? @@ -185,6 +185,7 @@ Start + Settings More options Error: Can\'t expand status bar.\nThis action is using functionality that is not part of the published Android API. Unfortunately, it does not seem to work on your device. diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index ea7d1f7..db2f80f 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -28,7 +28,6 @@ @color/darkTheme_background_color @color/darkTheme_text_color - - + + diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index 14334d3..7a32795 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -1,65 +1,66 @@ - + + android:title="@string/settings_general_choose_home_screen"/> + app:allowDividerAbove="false" + android:title="@string/settings_launcher_section_appearance"> + android:title="@string/settings_theme_wallpaper"/> + android:defaultValue="DEFAULT" + android:key="@string/settings_theme_color_theme_key" + android:title="@string/settings_theme_color_theme"/> + android:defaultValue="HACK"/> + android:defaultValue="BLUR"/> + android:title="@string/settings_theme_monochrome_icons" + android:defaultValue="false" /> - + @@ -68,21 +69,21 @@ app:allowDividerAbove="false"> - + + android:defaultValue="true" + android:title="@string/settings_enabled_gestures_edge_swipe"/> @@ -91,10 +92,10 @@ app:allowDividerAbove="false"> + android:title="@string/settings_display_full_screen"/> + android:title="@string/settings_display_screen_timeout_disabled"/>