Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class ActivitiesListActivity : BaseActivity() {
private val viewModel by viewModels<ActivitiesListViewModel>()

private lateinit var binding: ActivityActivitiesListBinding
private lateinit var adapter: ActivitiesListAdapter
private lateinit var appPackageName: String
private var application: ApplicationModel? = null

Expand All @@ -54,9 +55,10 @@ class ActivitiesListActivity : BaseActivity() {
setContentView(binding.root)
setupToolbar(isBackButtonEnabled = true)

val adapter = ActivitiesListAdapter(this).apply {
adapter = ActivitiesListAdapter(this).apply {
application = item
isCardLayoutEnabled = appPreferences.isCardLayoutEnabled
isHighlightDisabledActivities = appPreferences.isHighlightDisabledActivities
itemClickListener = object : ActivitiesListAdapter.ItemClickListener {
override fun onItemClick(item: ActivityModel) {
viewModel.launchActivity(item)
Expand Down Expand Up @@ -135,6 +137,8 @@ class ActivitiesListActivity : BaseActivity() {
menuInflater.inflate(R.menu.activities_list, menu)
configureSearchView(menu)
menu.findItem(R.id.show_not_exported).isChecked = viewModel.showNotExported
menu.findItem(R.id.highlight_disabled_activities).isChecked =
appPreferences.isHighlightDisabledActivities
return super.onCreateOptionsMenu(menu)
}

Expand All @@ -148,6 +152,13 @@ class ActivitiesListActivity : BaseActivity() {
true
}

R.id.highlight_disabled_activities -> {
item.isChecked = !item.isChecked
appPreferences.isHighlightDisabledActivities = item.isChecked
adapter.isHighlightDisabledActivities = item.isChecked
true
}

R.id.create_shortcut -> {
val activityPackageName = packageName
CreateShortcutActivity.start(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,22 @@ class ActivitiesListAdapter(
private val permissionColor = activity.resolveColorAttr(android.R.attr.textColorHint)
@ColorInt
private val notExportedColor = ContextCompat.getColor(activity, R.color.md_theme_error)
@ColorInt
private val disabledActivityColor =
ContextCompat.getColor(activity, R.color.disabled_activity)

var application: ApplicationModel? = null
var itemClickListener: ItemClickListener? = null

@SuppressLint("NotifyDataSetChanged")
var isHighlightDisabledActivities: Boolean = true
set(value) {
if (field != value) {
field = value
notifyDataSetChanged()
}
}

@SuppressLint("NotifyDataSetChanged")
var isCardLayoutEnabled: Boolean = false
set(value) {
Expand Down Expand Up @@ -71,6 +83,8 @@ class ActivitiesListAdapter(
exportedColor = exportedColor,
permissionColor = permissionColor,
notExportedColor = notExportedColor,
disabledActivityColor = disabledActivityColor,
highlightDisabledActivities = isHighlightDisabledActivities,
itemClickListener = itemClickListener,
)
}
Expand Down Expand Up @@ -98,11 +112,14 @@ class ActivitiesListAdapter(
@ColorInt exportedColor: Int,
@ColorInt permissionColor: Int,
@ColorInt notExportedColor: Int,
@ColorInt disabledActivityColor: Int,
highlightDisabledActivities: Boolean,
itemClickListener: ItemClickListener?,
) {
binding.name.text = item.name
binding.name.setTextColor(
when {
highlightDisabledActivities && !item.enabled -> disabledActivityColor
!item.exported -> notExportedColor
item.hasPermission -> permissionColor
else -> exportedColor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ interface AppPreferences {
var isShowSystemAppIndicator: Boolean
var isShowDisabledApps: Boolean
var isShowDisabledAppIndicator: Boolean
var isHighlightDisabledActivities: Boolean
var showNotExported: Boolean
var showLineNumbers: Boolean
var isShowLaunchToast: Boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,18 @@ class AppPreferencesImpl(context: Context) : AppPreferences {
}
}

override var isHighlightDisabledActivities: Boolean
get() = runBlocking {
dataStore.data.first()[KEY_HIGHLIGHT_DISABLED_ACTIVITIES] ?: true
}
set(value) {
coroutineScope.launch {
dataStore.edit { prefs ->
prefs[KEY_HIGHLIGHT_DISABLED_ACTIVITIES] = value
}
}
}

override var showNotExported: Boolean
get() = runBlocking { dataStore.data.first()[KEY_SHOW_NOT_EXPORTED] ?: false }
set(value) {
Expand Down Expand Up @@ -285,6 +297,8 @@ class AppPreferencesImpl(context: Context) : AppPreferences {
val KEY_SHOW_SYSTEM_APP_LABEL = booleanPreferencesKey("advanced_system_app")
val KEY_SHOW_DISABLED_APPS = booleanPreferencesKey("show_disabled_apps")
val KEY_SHOW_DISABLED_APP_LABEL = booleanPreferencesKey("advanced_disabled_app")
val KEY_HIGHLIGHT_DISABLED_ACTIVITIES =
booleanPreferencesKey("highlight_disabled_activities")
val KEY_THEME = stringPreferencesKey("appearance_theme")

val KEY_SORT_BY = stringPreferencesKey("sort_by")
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/res/menu/activities_list.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@
android:title="@string/activities_list_empty_action"
app:showAsAction="never" />

<item
android:id="@+id/highlight_disabled_activities"
android:checkable="true"
android:checked="true"
android:title="@string/highlight_disabled_activities"
app:showAsAction="never" />

<item
android:id="@+id/create_shortcut"
android:title="@string/activity_option_create_shortcut"
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
<color name="white">#fff</color>
<color name="red">#f44336</color>

<color name="disabled_activity">#F9A825</color>

<color name="icon_tint">#757575</color>
<color name="list_divider">#E0E0E0</color>
<color name="scrollbar_background">#28000000</color>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
<string name="activities_list_empty_action">Show non-exported</string>
<string name="activities_list_non_exported_show_once">Just once</string>
<string name="activities_list_non_exported_show_always">Always show</string>
<string name="highlight_disabled_activities">Highlight disabled activities</string>
<string name="activities_list_failed_loading">Failed to open \"%1$s\"</string>
<string name="action_about">About</string>
<string name="action_launch_intent">Intent launcher</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class FakeAppPreferences(
override var isShowSystemAppIndicator: Boolean = false
override var isShowDisabledApps: Boolean = true
override var isShowDisabledAppIndicator: Boolean = false
override var isHighlightDisabledActivities: Boolean = true
override var showLineNumbers: Boolean = true
override var isShowLaunchToast: Boolean = true
override var isInterceptIntents: Boolean = false
Expand Down