Add tint to preference icons

Closes #6540
// FREEBIE
This commit is contained in:
Mateo Hernandez 2017-04-17 14:23:17 -05:00 committed by Moxie Marlinspike
parent a697fcea04
commit a353ebd834
46 changed files with 80 additions and 31 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 209 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 265 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 217 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 159 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 255 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 472 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 184 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 170 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 228 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 146 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 130 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 188 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 315 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 136 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 263 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 359 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 220 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 191 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 309 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 553 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 221 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 318 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 485 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 307 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 278 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 449 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 769 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 297 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 476 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 687 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 414 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 368 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 584 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1013 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 390 B

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/ic_advanced_white_24dp"
android:tint="?attr/pref_icon_tint"/>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/ic_brightness_6_white_24dp"
android:tint="?attr/pref_icon_tint"/>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/ic_forum_white_24dp"
android:tint="?attr/pref_icon_tint"/>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/ic_laptop_white_24dp"
android:tint="?attr/pref_icon_tint"/>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/ic_notifications_white_24dp"
android:tint="?attr/pref_icon_tint"/>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/ic_security_white_24dp"
android:tint="?attr/pref_icon_tint"/>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/ic_textsms_white_24dp"
android:tint="?attr/pref_icon_tint"/>

View File

@ -116,14 +116,7 @@
<attr name="menu_forward_icon" format="reference" />
<attr name="menu_save_icon" format="reference" />
<attr name="pref_ic_sms_mms" format="reference" />
<attr name="pref_ic_notifications" format="reference" />
<attr name="pref_ic_app_protection" format="reference" />
<attr name="pref_ic_appearance" format="reference" />
<attr name="pref_ic_storage" format="reference" />
<attr name="pref_ic_chats" format="reference" />
<attr name="pref_ic_devices" format="reference" />
<attr name="pref_ic_advanced" format="reference" />
<attr name="pref_icon_tint" format="color"/>
<attr name="pref_divider" format="reference" />

View File

@ -208,13 +208,7 @@
<item name="reminder_header_background">#ff1d85d7</item>
<item name="pref_ic_sms_mms">@drawable/ic_textsms_black_24dp</item>
<item name="pref_ic_notifications">@drawable/ic_notifications_black_24dp</item>
<item name="pref_ic_app_protection">@drawable/ic_security_black_24dp</item>
<item name="pref_ic_appearance">@drawable/ic_brightness_6_black_24dp</item>
<item name="pref_ic_chats">@drawable/ic_forum_black_24dp</item>
<item name="pref_ic_devices">@drawable/ic_laptop_black_24dp</item>
<item name="pref_ic_advanced">@drawable/ic_advanced_black_24dp</item>
<item name="pref_icon_tint">@color/textsecure_primary_dark</item>
<item name="pref_divider">@drawable/preference_divider_light</item>
@ -340,13 +334,7 @@
<item name="reminder_header_background">@color/textsecure_primary_dark</item>
<item name="pref_ic_sms_mms">@drawable/ic_textsms_white_24dp</item>
<item name="pref_ic_notifications">@drawable/ic_notifications_white_24dp</item>
<item name="pref_ic_app_protection">@drawable/ic_security_white_24dp</item>
<item name="pref_ic_appearance">@drawable/ic_brightness_6_white_24dp</item>
<item name="pref_ic_chats">@drawable/ic_forum_white_24dp</item>
<item name="pref_ic_devices">@drawable/ic_laptop_white_24dp</item>
<item name="pref_ic_advanced">@drawable/ic_advanced_white_24dp</item>
<item name="pref_icon_tint">#FFFFFF</item>
<item name="pref_divider">@drawable/preference_divider_dark</item>

View File

@ -3,30 +3,30 @@
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<Preference android:key="preference_category_sms_mms"
android:title="@string/preferences__sms_mms"
android:icon="?pref_ic_sms_mms"/>
android:icon="@drawable/ic_textsms_24dp"/>
<Preference android:key="preference_category_notifications"
android:title="@string/preferences__notifications"
android:icon="?pref_ic_notifications"/>
android:icon="@drawable/ic_notifications_24dp"/>
<Preference android:key="preference_category_app_protection"
android:title="@string/preferences__privacy"
android:icon="?pref_ic_app_protection"/>
android:icon="@drawable/ic_security_24dp"/>
<Preference android:key="preference_category_appearance"
android:title="@string/preferences__appearance"
android:icon="?pref_ic_appearance"/>
android:icon="@drawable/ic_brightness_6_24dp"/>
<Preference android:key="preference_category_chats"
android:title="@string/preferences__chats"
android:icon="?pref_ic_chats"/>
android:icon="@drawable/ic_forum_24dp"/>
<Preference android:key="preference_category_devices"
android:title="@string/preferences__linked_devices"
android:icon="?pref_ic_devices"/>
android:icon="@drawable/ic_laptop_24dp"/>
<Preference android:key="preference_category_advanced"
android:title="@string/preferences__advanced"
android:icon="?pref_ic_advanced"/>
android:icon="@drawable/ic_advanced_24dp"/>
</PreferenceScreen>

View File

@ -16,17 +16,24 @@
*/
package org.thoughtcrime.securesms;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Build.VERSION;
import android.os.Bundle;
import android.preference.Preference;
import android.support.annotation.ColorInt;
import android.support.annotation.DrawableRes;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.preference.PreferenceFragment;
import android.view.View;
import android.support.v4.content.ContextCompat;
import android.support.v4.graphics.drawable.DrawableCompat;
import org.thoughtcrime.securesms.crypto.MasterSecret;
import org.thoughtcrime.securesms.preferences.AdvancedPreferenceFragment;
@ -145,6 +152,10 @@ public class ApplicationPreferencesActivity extends PassphraseRequiredActionBarA
.setOnPreferenceClickListener(new CategoryClickListener(masterSecret, PREFERENCE_CATEGORY_DEVICES));
this.findPreference(PREFERENCE_CATEGORY_ADVANCED)
.setOnPreferenceClickListener(new CategoryClickListener(masterSecret, PREFERENCE_CATEGORY_ADVANCED));
if (VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP && VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
tintIcons(getActivity());
}
}
@Override
@ -175,6 +186,35 @@ public class ApplicationPreferencesActivity extends PassphraseRequiredActionBarA
}
}
@TargetApi(11)
private void tintIcons(Context context) {
Drawable sms = DrawableCompat.wrap(ContextCompat.getDrawable(context, R.drawable.ic_textsms_white_24dp));
Drawable notifications = DrawableCompat.wrap(ContextCompat.getDrawable(context, R.drawable.ic_notifications_white_24dp));
Drawable privacy = DrawableCompat.wrap(ContextCompat.getDrawable(context, R.drawable.ic_security_white_24dp));
Drawable appearance = DrawableCompat.wrap(ContextCompat.getDrawable(context, R.drawable.ic_brightness_6_white_24dp));
Drawable chats = DrawableCompat.wrap(ContextCompat.getDrawable(context, R.drawable.ic_forum_white_24dp));
Drawable advanced = DrawableCompat.wrap(ContextCompat.getDrawable(context, R.drawable.ic_advanced_white_24dp));
int[] tintAttr = new int[]{R.attr.pref_icon_tint};
TypedArray typedArray = context.obtainStyledAttributes(tintAttr);
int color = typedArray.getColor(0, 0x0);
typedArray.recycle();
DrawableCompat.setTint(sms, color);
DrawableCompat.setTint(notifications, color);
DrawableCompat.setTint(privacy, color);
DrawableCompat.setTint(appearance, color);
DrawableCompat.setTint(chats, color);
DrawableCompat.setTint(advanced, color);
this.findPreference(PREFERENCE_CATEGORY_SMS_MMS).setIcon(sms);
this.findPreference(PREFERENCE_CATEGORY_NOTIFICATIONS).setIcon(notifications);
this.findPreference(PREFERENCE_CATEGORY_APP_PROTECTION).setIcon(privacy);
this.findPreference(PREFERENCE_CATEGORY_APPEARANCE).setIcon(appearance);
this.findPreference(PREFERENCE_CATEGORY_CHATS).setIcon(chats);
this.findPreference(PREFERENCE_CATEGORY_ADVANCED).setIcon(appearance);
}
private class CategoryClickListener implements Preference.OnPreferenceClickListener {
private MasterSecret masterSecret;
private String category;