Add tint to preference icons

Closes #6540
// FREEBIE
fork-5.53.8
Mateo Hernandez 2017-04-17 14:23:17 -05:00 zatwierdzone przez Moxie Marlinspike
rodzic a697fcea04
commit a353ebd834
46 zmienionych plików z 80 dodań i 31 usunięć

Plik binarny nie jest wyświetlany.

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 209 B

Plik binarny nie jest wyświetlany.

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 265 B

Plik binarny nie jest wyświetlany.

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 217 B

Plik binarny nie jest wyświetlany.

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 159 B

Plik binarny nie jest wyświetlany.

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 255 B

Plik binarny nie jest wyświetlany.

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 472 B

Plik binarny nie jest wyświetlany.

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 184 B

Plik binarny nie jest wyświetlany.

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 170 B

Plik binarny nie jest wyświetlany.

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 228 B

Plik binarny nie jest wyświetlany.

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 146 B

Plik binarny nie jest wyświetlany.

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 130 B

Plik binarny nie jest wyświetlany.

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 188 B

Plik binarny nie jest wyświetlany.

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 315 B

Plik binarny nie jest wyświetlany.

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 136 B

Plik binarny nie jest wyświetlany.

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 263 B

Plik binarny nie jest wyświetlany.

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 359 B

Plik binarny nie jest wyświetlany.

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 220 B

Plik binarny nie jest wyświetlany.

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 191 B

Plik binarny nie jest wyświetlany.

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 309 B

Plik binarny nie jest wyświetlany.

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 553 B

Plik binarny nie jest wyświetlany.

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 221 B

Plik binarny nie jest wyświetlany.

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 318 B

Plik binarny nie jest wyświetlany.

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 485 B

Plik binarny nie jest wyświetlany.

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 307 B

Plik binarny nie jest wyświetlany.

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 278 B

Plik binarny nie jest wyświetlany.

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 449 B

Plik binarny nie jest wyświetlany.

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 769 B

Plik binarny nie jest wyświetlany.

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 297 B

Plik binarny nie jest wyświetlany.

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 476 B

Plik binarny nie jest wyświetlany.

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 687 B

Plik binarny nie jest wyświetlany.

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 414 B

Plik binarny nie jest wyświetlany.

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 368 B

Plik binarny nie jest wyświetlany.

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 584 B

Plik binarny nie jest wyświetlany.

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 1013 B

Plik binarny nie jest wyświetlany.

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 390 B

Wyświetl plik

@ -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"/>

Wyświetl plik

@ -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"/>

Wyświetl plik

@ -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"/>

Wyświetl plik

@ -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"/>

Wyświetl plik

@ -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"/>

Wyświetl plik

@ -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"/>

Wyświetl plik

@ -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"/>

Wyświetl plik

@ -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" />

Wyświetl plik

@ -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>

Wyświetl plik

@ -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>

Wyświetl plik

@ -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;