-
-
Notifications
You must be signed in to change notification settings - Fork 446
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AppCleaner: Highlight settings that require "USAGE_STATS" permission …
…to function correctly.
- Loading branch information
Showing
10 changed files
with
271 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 14 additions & 9 deletions
23
app/src/main/java/eu/darken/sdmse/appcleaner/ui/settings/AppCleanerSettingsViewModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
app/src/main/java/eu/darken/sdmse/common/preferences/CaveatPreferenceGroup.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package eu.darken.sdmse.common.preferences | ||
|
||
import android.content.Context | ||
import android.util.AttributeSet | ||
import androidx.annotation.AttrRes | ||
import androidx.annotation.StyleRes | ||
import androidx.preference.PreferenceGroup | ||
import androidx.preference.children | ||
import eu.darken.sdmse.R | ||
import eu.darken.sdmse.common.debug.logging.logTag | ||
|
||
|
||
class CaveatPreferenceGroup @JvmOverloads constructor( | ||
context: Context, | ||
attrs: AttributeSet? = null, | ||
@AttrRes defStyleAttr: Int = androidx.preference.R.attr.preferenceStyle, | ||
@StyleRes defStyleRes: Int = 0, | ||
) : PreferenceGroup(context, attrs, defStyleAttr, defStyleRes) { | ||
|
||
init { | ||
layoutResource = R.layout.view_caveat_preference_group | ||
isPersistent = false | ||
} | ||
|
||
private val caveatEntry: CaveatPreferenceView | ||
get() = children.filterIsInstance<CaveatPreferenceView>().first() | ||
|
||
var caveatMessage: String? = null | ||
set(value) { | ||
field = value | ||
caveatEntry.caveatMessage = value | ||
} | ||
|
||
var caveatAction: String? = null | ||
set(value) { | ||
field = value | ||
caveatEntry.caveatAction = value | ||
} | ||
|
||
var showCaveat: Boolean = false | ||
set(value) { | ||
field = value | ||
caveatEntry.isVisible = value | ||
} | ||
|
||
var caveatClickListener: (() -> Boolean)? = null | ||
set(value) { | ||
field = value | ||
caveatEntry.apply { | ||
if (value != null) { | ||
this.setOnPreferenceClickListener { value.invoke() } | ||
} else { | ||
this.onPreferenceClickListener = null | ||
} | ||
} | ||
} | ||
|
||
companion object { | ||
private val TAG = logTag("CaveatPreferenceGroup") | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
app/src/main/java/eu/darken/sdmse/common/preferences/CaveatPreferenceView.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package eu.darken.sdmse.common.preferences | ||
|
||
import android.content.Context | ||
import android.util.AttributeSet | ||
import android.view.ViewGroup | ||
import androidx.annotation.AttrRes | ||
import androidx.annotation.StyleRes | ||
import androidx.core.view.children | ||
import androidx.preference.PreferenceGroup | ||
import androidx.preference.PreferenceViewHolder | ||
import eu.darken.sdmse.R | ||
import eu.darken.sdmse.common.MimeTypes.Json.value | ||
import eu.darken.sdmse.common.debug.logging.logTag | ||
import eu.darken.sdmse.databinding.ViewCaveatPreferenceViewBinding | ||
|
||
|
||
class CaveatPreferenceView @JvmOverloads constructor( | ||
context: Context, | ||
attrs: AttributeSet? = null, | ||
@AttrRes defStyleAttr: Int = androidx.preference.R.attr.preferenceStyle, | ||
@StyleRes defStyleRes: Int = 0, | ||
) : PreferenceGroup(context, attrs, defStyleAttr, defStyleRes) { | ||
|
||
init { | ||
layoutResource = R.layout.view_caveat_preference_view | ||
isVisible = false | ||
isPersistent = false | ||
} | ||
|
||
var caveatMessage: String? = summary?.toString() | ||
set(value) { | ||
field = value | ||
notifyChanged() | ||
} | ||
|
||
var caveatAction: String? = title?.toString() | ||
set(value) { | ||
field = value | ||
notifyChanged() | ||
} | ||
|
||
override fun onBindViewHolder(holder: PreferenceViewHolder) { | ||
super.onBindViewHolder(holder) | ||
ViewCaveatPreferenceViewBinding.bind(holder.itemView).apply { | ||
primary.text = caveatMessage | ||
positiveAction.text = caveatAction | ||
positiveAction.setOnClickListener { | ||
@Suppress("RestrictedApi") | ||
this@CaveatPreferenceView.performClick() | ||
} | ||
(holder.itemView as ViewGroup).children | ||
} | ||
} | ||
|
||
companion object { | ||
private val TAG = logTag("CaveatPreferenceView") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content"> | ||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginHorizontal="16dp" | ||
android:layout_marginBottom="16dp" | ||
android:background="@drawable/dashboard_progress_row_bg" | ||
android:foreground="?selectableItemBackgroundBorderless" | ||
android:paddingVertical="10dp" | ||
android:paddingStart="16dp" | ||
android:paddingEnd="0dp"> | ||
|
||
<com.google.android.material.textview.MaterialTextView | ||
android:id="@+id/primary" | ||
style="@style/TextAppearance.Material3.BodySmall" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:layout_marginEnd="16dp" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintEnd_toStartOf="@id/positive_action" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" | ||
tools:text="XYZ" /> | ||
|
||
<com.google.android.material.textview.MaterialTextView | ||
android:id="@+id/positive_action" | ||
style="@style/TextAppearance.Material3.LabelMedium" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:layout_marginHorizontal="16dp" | ||
android:layout_marginVertical="8dp" | ||
android:text="@string/general_fix_action" | ||
android:textColor="?colorPrimary" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" | ||
app:textAllCaps="true" /> | ||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.