Compare commits

...

4 commits

11 changed files with 67 additions and 51 deletions

View file

@ -23,8 +23,8 @@ android {
minSdkVersion 21
targetSdkVersion 35
compileSdk 35
versionCode 39
versionName "0.0.23"
versionCode 40
versionName "0.1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

View file

@ -194,7 +194,7 @@ fun getApps(
loadList.add(detailedAppInfo)
}
}
loadList.sortBy { it.getCustomLabel(context).toString() }
loadList.sortBy { it.getCustomLabel(context) }
var end = System.currentTimeMillis()
Log.i(LOG_TAG, "${loadList.size} apps loaded (${end - start}ms)")

View file

@ -91,6 +91,7 @@ fun isPrivateSpaceLocked(context: Context): Boolean {
val privateSpaceUser = getPrivateSpaceUser(context) ?: return false
return userManager.isQuietModeEnabled(privateSpaceUser)
}
fun lockPrivateSpace(context: Context, lock: Boolean) {
if (!isPrivateSpaceSupported()) {
return
@ -123,10 +124,16 @@ fun togglePrivateSpaceLock(context: Context) {
}
fun hidePrivateSpaceWhenLocked(context: Context): Boolean {
// TODO: perhaps this should be cached
// Trying to access the setting as a 3rd party launcher raises a security exception.
// This is an Android bug: https://issuetracker.google.com/issues/352276244#comment5
// The logic for this is implemented.
// TODO: replace this once the Android bug is fixed
return false
// TODO: perhaps this should be cached
// https://cs.android.com/android/platform/superproject/main/+/main:packages/apps/Launcher3/src/com/android/launcher3/util/SettingsCache.java;l=61;drc=56bf7ad33bc9d5ed3c18e7abefeec5c177ec75d7
val key = "hide_privatespace_entry_point"
return Settings.Secure.getInt(context.contentResolver, key, 0) == 1
// val key = "hide_privatespace_entry_point"
// return Settings.Secure.getInt(context.contentResolver, key, 0) == 1
}

View file

@ -27,10 +27,14 @@ fun View.blink(
}
// Taken from: https://stackoverflow.com/a/30340794/12787264
fun ImageView.transformGrayscale() {
this.colorFilter = ColorMatrixColorFilter(ColorMatrix().apply {
setSaturation(0f)
})
fun ImageView.transformGrayscale(grayscale: Boolean) {
this.colorFilter = if (grayscale) {
ColorMatrixColorFilter(ColorMatrix().apply {
setSaturation(0f)
})
} else {
null
}
}

View file

@ -1,7 +1,6 @@
package de.jrpie.android.launcher.ui.list
import android.app.Activity
import android.content.Context
import android.content.Intent
import android.content.res.Resources
import android.graphics.Rect
@ -33,16 +32,6 @@ import de.jrpie.android.launcher.ui.list.apps.ListFragmentApps
import de.jrpie.android.launcher.ui.list.other.ListFragmentOther
// TODO: Better solution for this intercommunication functionality (used in list-fragments)
var intention = ListActivity.ListActivityIntention.VIEW
var favoritesVisibility: AppFilter.Companion.AppSetVisibility =
AppFilter.Companion.AppSetVisibility.VISIBLE
var privateSpaceVisibility: AppFilter.Companion.AppSetVisibility =
AppFilter.Companion.AppSetVisibility.VISIBLE
var hiddenVisibility: AppFilter.Companion.AppSetVisibility =
AppFilter.Companion.AppSetVisibility.HIDDEN
var forGesture: String? = null
/**
* The [ListActivity] is the most general purpose activity in Launcher:
* - used to view all apps and edit their settings
@ -52,11 +41,19 @@ var forGesture: String? = null
*/
class ListActivity : AppCompatActivity(), UIObject {
private lateinit var binding: ListBinding
var intention = ListActivityIntention.VIEW
var favoritesVisibility: AppFilter.Companion.AppSetVisibility =
AppFilter.Companion.AppSetVisibility.VISIBLE
var privateSpaceVisibility: AppFilter.Companion.AppSetVisibility =
AppFilter.Companion.AppSetVisibility.VISIBLE
var hiddenVisibility: AppFilter.Companion.AppSetVisibility =
AppFilter.Companion.AppSetVisibility.HIDDEN
var forGesture: String? = null
private fun updateLockIcon(locked: Boolean) {
if (
// only show lock for VIEW intention
// only show lock for VIEW intention
(intention != ListActivityIntention.VIEW)
// hide lock when private space does not exist
|| !isPrivateSpaceSetUp(this)
@ -261,7 +258,7 @@ 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) :
class ListSectionsPagerAdapter(private val activity: ListActivity, fm: FragmentManager) :
FragmentPagerAdapter(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) {
override fun getItem(position: Int): Fragment {
@ -273,11 +270,11 @@ class ListSectionsPagerAdapter(private val context: Context, fm: FragmentManager
}
override fun getPageTitle(position: Int): CharSequence {
return context.resources.getString(TAB_TITLES[position])
return activity.resources.getString(TAB_TITLES[position])
}
override fun getCount(): Int {
return when (intention) {
return when (activity.intention) {
ListActivity.ListActivityIntention.VIEW -> 1
else -> 2
}

View file

@ -47,6 +47,7 @@ class AppsRecyclerAdapter(
private val apps = (activity.applicationContext as Application).apps
private val appsListDisplayed: MutableList<AbstractDetailedAppInfo> = mutableListOf()
private val grayscale = LauncherPreferences.theme().monochromeIcons()
// temporarily disable auto launch
var disableAutoLaunch: Boolean = false
@ -79,20 +80,19 @@ class AppsRecyclerAdapter(
override fun onBindViewHolder(viewHolder: ViewHolder, i: Int) {
var appLabel = appsListDisplayed[i].getCustomLabel(activity)
val appIcon = appsListDisplayed[i].getIcon(activity)
viewHolder.img.transformGrayscale(grayscale)
viewHolder.img.setImageDrawable(appIcon.constantState?.newDrawable() ?: appIcon)
if (layout.useBadgedText) {
appLabel = activity.packageManager.getUserBadgedLabel(
appLabel,
appsListDisplayed[i].getUser(activity)
).toString()
}
val appIcon = appsListDisplayed[i].getIcon(activity)
viewHolder.textView.text = appLabel
viewHolder.img.setImageDrawable(appIcon)
if (LauncherPreferences.theme().monochromeIcons())
viewHolder.img.transformGrayscale()
// decide when to show the options popup menu about
if (intention == ListActivity.ListActivityIntention.VIEW) {

View file

@ -17,11 +17,6 @@ import de.jrpie.android.launcher.databinding.ListAppsBinding
import de.jrpie.android.launcher.preferences.LauncherPreferences
import de.jrpie.android.launcher.ui.UIObject
import de.jrpie.android.launcher.ui.list.ListActivity
import de.jrpie.android.launcher.ui.list.favoritesVisibility
import de.jrpie.android.launcher.ui.list.forGesture
import de.jrpie.android.launcher.ui.list.hiddenVisibility
import de.jrpie.android.launcher.ui.list.intention
import de.jrpie.android.launcher.ui.list.privateSpaceVisibility
import de.jrpie.android.launcher.ui.openSoftKeyboard
@ -54,7 +49,7 @@ class ListFragmentApps : Fragment(), UIObject {
.registerOnSharedPreferenceChangeListener(sharedPreferencesListener)
binding.listAppsCheckBoxFavorites.isChecked =
(favoritesVisibility == AppFilter.Companion.AppSetVisibility.EXCLUSIVE)
((activity as? ListActivity)?.favoritesVisibility == AppFilter.Companion.AppSetVisibility.EXCLUSIVE)
}
override fun onStop() {
@ -67,16 +62,17 @@ class ListFragmentApps : Fragment(), UIObject {
override fun setOnClicks() {}
override fun adjustLayout() {
val listActivity = activity as? ListActivity ?: return
appsRecyclerAdapter =
AppsRecyclerAdapter(
requireActivity(), binding.root, intention, forGesture,
listActivity, binding.root, listActivity.intention, listActivity.forGesture,
appFilter = AppFilter(
requireContext(),
"",
favoritesVisibility = favoritesVisibility,
privateSpaceVisibility = privateSpaceVisibility,
hiddenVisibility = hiddenVisibility
favoritesVisibility = listActivity.favoritesVisibility,
privateSpaceVisibility = listActivity.privateSpaceVisibility,
hiddenVisibility = listActivity.hiddenVisibility
),
layout = LauncherPreferences.list().layout()
)
@ -124,7 +120,8 @@ class ListFragmentApps : Fragment(), UIObject {
if (newText == " " &&
!appsRecyclerAdapter.disableAutoLaunch &&
intention == ListActivity.ListActivityIntention.VIEW &&
(activity as? ListActivity)?.intention
== ListActivity.ListActivityIntention.VIEW &&
LauncherPreferences.functionality().searchAutoLaunch()
) {
appsRecyclerAdapter.disableAutoLaunch = true
@ -141,17 +138,17 @@ class ListFragmentApps : Fragment(), UIObject {
})
binding.listAppsCheckBoxFavorites.setOnClickListener {
favoritesVisibility =
listActivity.favoritesVisibility =
if (binding.listAppsCheckBoxFavorites.isChecked) {
AppFilter.Companion.AppSetVisibility.EXCLUSIVE
} else {
AppFilter.Companion.AppSetVisibility.VISIBLE
}
appsRecyclerAdapter.setFavoritesVisibility(favoritesVisibility)
appsRecyclerAdapter.setFavoritesVisibility(listActivity.favoritesVisibility)
(activity as? ListActivity)?.updateTitle()
}
if (intention == ListActivity.ListActivityIntention.VIEW
if (listActivity.intention == ListActivity.ListActivityIntention.VIEW
&& LauncherPreferences.functionality().searchAutoOpenKeyboard()
) {
binding.listAppsSearchview.openSoftKeyboard(requireContext())

View file

@ -11,7 +11,7 @@ import androidx.recyclerview.widget.RecyclerView
import de.jrpie.android.launcher.R
import de.jrpie.android.launcher.REQUEST_CHOOSE_APP
import de.jrpie.android.launcher.actions.LauncherAction
import de.jrpie.android.launcher.ui.list.forGesture
import de.jrpie.android.launcher.ui.list.ListActivity
/**
* The [OtherRecyclerAdapter] will only be displayed in the ListActivity,
@ -36,7 +36,7 @@ class OtherRecyclerAdapter(val activity: Activity) :
val pos = bindingAdapterPosition
val content = othersList[pos]
forGesture?.let { returnChoiceIntent(it, content) }
(activity as? ListActivity)?.forGesture?.let { returnChoiceIntent(it, content) }
}
init {

View file

@ -143,9 +143,7 @@ class ActionsRecyclerAdapter(val activity: Activity) :
val description = gesture.getDescription(activity)
viewHolder.descriptionTextView.text = description
if (LauncherPreferences.theme().monochromeIcons())
viewHolder.img.transformGrayscale()
viewHolder.img.transformGrayscale(LauncherPreferences.theme().monochromeIcons())
updateViewHolder(gesture, viewHolder)
viewHolder.img.setOnClickListener { chooseApp(gesture) }

View file

@ -179,7 +179,7 @@
<string name="settings_apps_hide_paused_apps">Hide paused apps</string>
<string name="settings_apps_hide_private_space_apps">Hide private space from app list</string>
<string name="settings_list_layout">Layout of app list</string>
<string name="settings_list_reverse_layout">Reverse app list</string>
<string name="settings_list_reverse_layout">Reverse the app list</string>
<string name="settings_list_layout_item_default">Default</string>
<string name="settings_list_layout_item_text">Text</string>

View file

@ -0,0 +1,13 @@
* Pinned shortcuts can now be added to app list
* New action: adjust volume (thank you, zabrinu!)
* Added option to hide navigation bar (thank you, acanoe!)
* Added option to reverse the app list (thank you, spacefrogg!)
* Show question mark icon when an unknown app is bound to a gesture
* Improved German translation
* Improved Portuguese translation (thank you, "Vossa Excelencia"!)
* Fixed detection of long click gesture
* Fixed blurred text in dialogs
* Fixed a crash when private space is locked after app restarts (thank you, alexytomi!)
* Fixed some additional bugs