color destructive panic prefs with red background

This commit is contained in:
Hans-Christoph Steiner 2019-05-29 23:20:16 +02:00
parent 3b53af0657
commit 4c352aeadc
5 changed files with 83 additions and 4 deletions

View File

@ -0,0 +1,41 @@
package org.fdroid.fdroid.views.panic;
import android.content.Context;
import android.content.res.Resources;
import android.support.v7.preference.CheckBoxPreference;
import android.support.v7.preference.PreferenceViewHolder;
import android.util.AttributeSet;
import org.fdroid.fdroid.FDroidApp;
import org.fdroid.fdroid.R;
public class DestructiveCheckBoxPreference extends CheckBoxPreference {
public DestructiveCheckBoxPreference(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
public DestructiveCheckBoxPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
}
public DestructiveCheckBoxPreference(Context context, AttributeSet attrs) {
super(context, attrs);
}
public DestructiveCheckBoxPreference(Context context) {
super(context);
}
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
super.onBindViewHolder(holder);
if (!holder.itemView.isEnabled()) {
return;
}
Resources resources = getContext().getResources();
if (FDroidApp.isAppThemeLight()) {
holder.itemView.setBackgroundColor(resources.getColor(R.color.panic_destructive_light));
} else {
holder.itemView.setBackgroundColor(resources.getColor(R.color.panic_destructive_dark));
}
}
}

View File

@ -0,0 +1,36 @@
package org.fdroid.fdroid.views.panic;
import android.content.Context;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceViewHolder;
import android.util.AttributeSet;
import org.fdroid.fdroid.FDroidApp;
import org.fdroid.fdroid.R;
public class DestructivePreference extends Preference {
public DestructivePreference(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
public DestructivePreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
}
public DestructivePreference(Context context, AttributeSet attrs) {
super(context, attrs);
}
public DestructivePreference(Context context) {
super(context);
}
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
super.onBindViewHolder(holder);
if (FDroidApp.isAppThemeLight()) {
holder.itemView.setBackgroundColor(getContext().getResources().getColor(R.color.panic_destructive_light));
} else {
holder.itemView.setBackgroundColor(getContext().getResources().getColor(R.color.panic_destructive_dark));
}
}
}

View File

@ -117,7 +117,7 @@ public class PanicPreferencesFragment extends PreferenceFragment
categoryAppsToUninstall.setEnabled(true); categoryAppsToUninstall.setEnabled(true);
if (wipeSet.size() > 0) { if (wipeSet.size() > 0) {
for (String packageName : wipeSet) { for (String packageName : wipeSet) {
Preference preference = new Preference(getActivity()); Preference preference = new DestructivePreference(getActivity());
preference.setSingleLineTitle(true); preference.setSingleLineTitle(true);
preference.setIntent(intent); preference.setIntent(intent);
categoryAppsToUninstall.addPreference(preference); categoryAppsToUninstall.addPreference(preference);

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools"> <resources>
<color name="swap_incompatible">#ff7900</color> <color name="swap_incompatible">#ff7900</color>
<color name="swap_light_blue">#27aae1</color> <color name="swap_light_blue">#27aae1</color>
@ -10,4 +10,6 @@
<color name="swap_grey_icon">#4a4a4a</color> <color name="swap_grey_icon">#4a4a4a</color>
<color name="swap_light_grey_icon">#bbbbbb</color> <color name="swap_light_grey_icon">#bbbbbb</color>
<color name="panic_destructive_light">#fff0f0</color>
<color name="panic_destructive_dark">#330000</color>
</resources> </resources>

View File

@ -19,14 +19,14 @@
android:title="@string/panic_app_setting_title" android:title="@string/panic_app_setting_title"
tools:icon="@drawable/ic_cancel"/> tools:icon="@drawable/ic_cancel"/>
<android.support.v7.preference.CheckBoxPreference <org.fdroid.fdroid.views.panic.DestructiveCheckBoxPreference
android:defaultValue="false" android:defaultValue="false"
android:enabled="false" android:enabled="false"
android:key="pref_panic_hide" android:key="pref_panic_hide"
android:summary="@string/panic_hide_summary" android:summary="@string/panic_hide_summary"
android:title="@string/panic_hide_title"/> android:title="@string/panic_hide_title"/>
<android.support.v7.preference.CheckBoxPreference <org.fdroid.fdroid.views.panic.DestructiveCheckBoxPreference
android:defaultValue="false" android:defaultValue="false"
android:enabled="false" android:enabled="false"
android:key="pref_panic_reset_repos" android:key="pref_panic_reset_repos"