mirror of
https://github.com/oxen-io/session-android.git
synced 2025-02-19 19:18:27 +00:00
Switch to enum and theme type for MaterialColor.
// FREEBIE
This commit is contained in:
parent
9bf7562d49
commit
4ea40b30a2
@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<attr name="theme_type" format="string"/>
|
||||
<attr name="conversation_list_item_background_selected" format="reference"/>
|
||||
<attr name="conversation_list_item_background_read" format="reference"/>
|
||||
<attr name="conversation_list_item_background_unread" format="reference"/>
|
||||
@ -22,10 +23,6 @@
|
||||
<attr name="centered_app_title_color" format="reference|color" />
|
||||
<attr name="ic_arrow_forward" format="reference" />
|
||||
|
||||
<attr name="conversation_color_material_weight" format="string"/>
|
||||
<attr name="actionbar_color_material_weight" format="string"/>
|
||||
<attr name="statusbar_color_material_weight" format="string"/>
|
||||
|
||||
<attr name="conversation_background" format="reference|color"/>
|
||||
<attr name="conversation_editor_background" format="reference|color"/>
|
||||
<attr name="conversation_editor_text_color" format="reference|color"/>
|
||||
|
276
res/values/material_colors.xml
Normal file
276
res/values/material_colors.xml
Normal file
@ -0,0 +1,276 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="red_50">#FFEBEE</color>
|
||||
<color name="red_100">#FFCDD2</color>
|
||||
<color name="red_200">#EF9A9A</color>
|
||||
<color name="red_300">#E57373</color>
|
||||
<color name="red_400">#EF5350</color>
|
||||
<color name="red_500">#F44336</color>
|
||||
<color name="red_600">#E53935</color>
|
||||
<color name="red_700">#D32F2F</color>
|
||||
<color name="red_800">#C62828</color>
|
||||
<color name="red_900">#B71C1C</color>
|
||||
<color name="red_A100">#FF8A80</color>
|
||||
<color name="red_A200">#FF5252</color>
|
||||
<color name="red_A400">#FF1744</color>
|
||||
<color name="red_A700">#D50000</color>
|
||||
|
||||
<color name="deep_purple_50">#EDE7F6</color>
|
||||
<color name="deep_purple_100">#D1C4E9</color>
|
||||
<color name="deep_purple_200">#B39DDB</color>
|
||||
<color name="deep_purple_300">#9575CD</color>
|
||||
<color name="deep_purple_400">#7E57C2</color>
|
||||
<color name="deep_purple_500">#673AB7</color>
|
||||
<color name="deep_purple_600">#5E35B1</color>
|
||||
<color name="deep_purple_700">#512DA8</color>
|
||||
<color name="deep_purple_800">#4527A0</color>
|
||||
<color name="deep_purple_900">#311B92</color>
|
||||
<color name="deep_purple_A100">#B388FF</color>
|
||||
<color name="deep_purple_A200">#7C4DFF</color>
|
||||
<color name="deep_purple_A400">#651FFF</color>
|
||||
<color name="deep_purple_A700">#6200EA</color>
|
||||
|
||||
<color name="light_blue_50">#E1F5FE</color>
|
||||
<color name="light_blue_100">#B3E5FC</color>
|
||||
<color name="light_blue_200">#81D4FA</color>
|
||||
<color name="light_blue_300">#4FC3F7</color>
|
||||
<color name="light_blue_400">#29B6F6</color>
|
||||
<color name="light_blue_500">#03A9F4</color>
|
||||
<color name="light_blue_600">#039BE5</color>
|
||||
<color name="light_blue_700">#0288D1</color>
|
||||
<color name="light_blue_800">#0277BD</color>
|
||||
<color name="light_blue_900">#01579B</color>
|
||||
<color name="light_blue_A100">#80D8FF</color>
|
||||
<color name="light_blue_A200">#40C4FF</color>
|
||||
<color name="light_blue_A400">#00B0FF</color>
|
||||
<color name="light_blue_A700">#0091EA</color>
|
||||
|
||||
<color name="green_50">#E8F5E9</color>
|
||||
<color name="green_100">#C8E6C9</color>
|
||||
<color name="green_200">#A5D6A7</color>
|
||||
<color name="green_300">#81C784</color>
|
||||
<color name="green_400">#66BB6A</color>
|
||||
<color name="green_500">#4CAF50</color>
|
||||
<color name="green_600">#43A047</color>
|
||||
<color name="green_700">#388E3C</color>
|
||||
<color name="green_800">#2E7D32</color>
|
||||
<color name="green_900">#1B5E20</color>
|
||||
<color name="green_A100">#B9F6CA</color>
|
||||
<color name="green_A200">#69F0AE</color>
|
||||
<color name="green_A400">#00E676</color>
|
||||
<color name="green_A700">#00C853</color>
|
||||
|
||||
<color name="yellow_50">#FFFDE7</color>
|
||||
<color name="yellow_100">#FFF9C4</color>
|
||||
<color name="yellow_200">#FFF59D</color>
|
||||
<color name="yellow_300">#FFF176</color>
|
||||
<color name="yellow_400">#FFEE58</color>
|
||||
<color name="yellow_500">#FFEB3B</color>
|
||||
<color name="yellow_600">#FDD835</color>
|
||||
<color name="yellow_700">#FBC02D</color>
|
||||
<color name="yellow_800">#F9A825</color>
|
||||
<color name="yellow_900">#F57F17</color>
|
||||
<color name="yellow_A100">#FFFF8D</color>
|
||||
<color name="yellow_A200">#FFFF00</color>
|
||||
<color name="yellow_A400">#FFEA00</color>
|
||||
<color name="yellow_A700">#FFD600</color>
|
||||
|
||||
<color name="deep_orange_50">#FBE9E7</color>
|
||||
<color name="deep_orange_100">#FFCCBC</color>
|
||||
<color name="deep_orange_200">#FFAB91</color>
|
||||
<color name="deep_orange_300">#FF8A65</color>
|
||||
<color name="deep_orange_400">#FF7043</color>
|
||||
<color name="deep_orange_500">#FF5722</color>
|
||||
<color name="deep_orange_600">#F4511E</color>
|
||||
<color name="deep_orange_700">#E64A19</color>
|
||||
<color name="deep_orange_800">#D84315</color>
|
||||
<color name="deep_orange_900">#BF360C</color>
|
||||
<color name="deep_orange_A100">#FF9E80</color>
|
||||
<color name="deep_orange_A200">#FF6E40</color>
|
||||
<color name="deep_orange_A400">#FF3D00</color>
|
||||
<color name="deep_orange_A700">#DD2C00</color>
|
||||
|
||||
<color name="blue_grey_50">#ECEFF1</color>
|
||||
<color name="blue_grey_100">#CFD8DC</color>
|
||||
<color name="blue_grey_200">#B0BEC5</color>
|
||||
<color name="blue_grey_300">#90A4AE</color>
|
||||
<color name="blue_grey_400">#78909C</color>
|
||||
<color name="blue_grey_500">#607D8B</color>
|
||||
<color name="blue_grey_600">#546E7A</color>
|
||||
<color name="blue_grey_700">#455A64</color>
|
||||
<color name="blue_grey_800">#37474F</color>
|
||||
<color name="blue_grey_900">#263238</color>
|
||||
|
||||
<color name="pink_50">#FCE4EC</color>
|
||||
<color name="pink_100">#F8BBD0</color>
|
||||
<color name="pink_200">#F48FB1</color>
|
||||
<color name="pink_300">#F06292</color>
|
||||
<color name="pink_400">#EC407A</color>
|
||||
<color name="pink_500">#E91E63</color>
|
||||
<color name="pink_600">#D81B60</color>
|
||||
<color name="pink_700">#C2185B</color>
|
||||
<color name="pink_800">#AD1457</color>
|
||||
<color name="pink_900">#880E4F</color>
|
||||
<color name="pink_A100">#FF80AB</color>
|
||||
<color name="pink_A200">#FF4081</color>
|
||||
<color name="pink_A400">#F50057</color>
|
||||
<color name="pink_A700">#C51162</color>
|
||||
|
||||
<color name="indigo_50">#E8EAF6</color>
|
||||
<color name="indigo_100">#C5CAE9</color>
|
||||
<color name="indigo_200">#9FA8DA</color>
|
||||
<color name="indigo_300">#7986CB</color>
|
||||
<color name="indigo_400">#5C6BC0</color>
|
||||
<color name="indigo_500">#3F51B5</color>
|
||||
<color name="indigo_600">#3949AB</color>
|
||||
<color name="indigo_700">#303F9F</color>
|
||||
<color name="indigo_800">#283593</color>
|
||||
<color name="indigo_900">#1A237E</color>
|
||||
<color name="indigo_A100">#8C9EFF</color>
|
||||
<color name="indigo_A200">#536DFE</color>
|
||||
<color name="indigo_A400">#3D5AFE</color>
|
||||
<color name="indigo_A700">#304FFE</color>
|
||||
|
||||
<color name="cyan_50">#E0F7FA</color>
|
||||
<color name="cyan_100">#B2EBF2</color>
|
||||
<color name="cyan_200">#80DEEA</color>
|
||||
<color name="cyan_300">#4DD0E1</color>
|
||||
<color name="cyan_400">#26C6DA</color>
|
||||
<color name="cyan_500">#00BCD4</color>
|
||||
<color name="cyan_600">#00ACC1</color>
|
||||
<color name="cyan_700">#0097A7</color>
|
||||
<color name="cyan_800">#00838F</color>
|
||||
<color name="cyan_900">#006064</color>
|
||||
<color name="cyan_A100">#84FFFF</color>
|
||||
<color name="cyan_A200">#18FFFF</color>
|
||||
<color name="cyan_A400">#00E5FF</color>
|
||||
<color name="cyan_A700">#00B8D4</color>
|
||||
|
||||
<color name="light_green_50">#F1F8E9</color>
|
||||
<color name="light_green_100">#DCEDC8</color>
|
||||
<color name="light_green_200">#C5E1A5</color>
|
||||
<color name="light_green_300">#AED581</color>
|
||||
<color name="light_green_400">#9CCC65</color>
|
||||
<color name="light_green_500">#8BC34A</color>
|
||||
<color name="light_green_600">#7CB342</color>
|
||||
<color name="light_green_700">#689F38</color>
|
||||
<color name="light_green_800">#558B2F</color>
|
||||
<color name="light_green_900">#33691E</color>
|
||||
<color name="light_green_A100">#CCFF90</color>
|
||||
<color name="light_green_A200">#B2FF59</color>
|
||||
<color name="light_green_A400">#76FF03</color>
|
||||
<color name="light_green_A700">#64DD17</color>
|
||||
|
||||
<color name="amber_50">#FFF8E1</color>
|
||||
<color name="amber_100">#FFECB3</color>
|
||||
<color name="amber_200">#FFE082</color>
|
||||
<color name="amber_300">#FFD54F</color>
|
||||
<color name="amber_400">#FFCA28</color>
|
||||
<color name="amber_500">#FFC107</color>
|
||||
<color name="amber_600">#FFB300</color>
|
||||
<color name="amber_700">#FFA000</color>
|
||||
<color name="amber_800">#FF8F00</color>
|
||||
<color name="amber_900">#FF6F00</color>
|
||||
<color name="amber_A100">#FFE57F</color>
|
||||
<color name="amber_A200">#FFD740</color>
|
||||
<color name="amber_A400">#FFC400</color>
|
||||
<color name="amber_A700">#FFAB00</color>
|
||||
|
||||
<color name="brown_50">#EFEBE9</color>
|
||||
<color name="brown_100">#D7CCC8</color>
|
||||
<color name="brown_200">#BCAAA4</color>
|
||||
<color name="brown_300">#A1887F</color>
|
||||
<color name="brown_400">#8D6E63</color>
|
||||
<color name="brown_500">#795548</color>
|
||||
<color name="brown_600">#6D4C41</color>
|
||||
<color name="brown_700">#5D4037</color>
|
||||
<color name="brown_800">#4E342E</color>
|
||||
<color name="brown_900">#3E2723</color>
|
||||
|
||||
<color name="purple_50">#F3E5F5</color>
|
||||
<color name="purple_100">#E1BEE7</color>
|
||||
<color name="purple_200">#CE93D8</color>
|
||||
<color name="purple_300">#BA68C8</color>
|
||||
<color name="purple_400">#AB47BC</color>
|
||||
<color name="purple_500">#9C27B0</color>
|
||||
<color name="purple_600">#8E24AA</color>
|
||||
<color name="purple_700">#7B1FA2</color>
|
||||
<color name="purple_800">#6A1B9A</color>
|
||||
<color name="purple_900">#4A148C</color>
|
||||
<color name="purple_A100">#EA80FC</color>
|
||||
<color name="purple_A200">#E040FB</color>
|
||||
<color name="purple_A400">#D500F9</color>
|
||||
<color name="purple_A700">#AA00FF</color>
|
||||
|
||||
<color name="blue_50">#E3F2FD</color>
|
||||
<color name="blue_100">#BBDEFB</color>
|
||||
<color name="blue_200">#90CAF9</color>
|
||||
<color name="blue_300">#64B5F6</color>
|
||||
<color name="blue_400">#42A5F5</color>
|
||||
<color name="blue_500">#2196F3</color>
|
||||
<color name="blue_600">#1E88E5</color>
|
||||
<color name="blue_700">#1976D2</color>
|
||||
<color name="blue_800">#1565C0</color>
|
||||
<color name="blue_900">#0D47A1</color>
|
||||
<color name="blue_A100">#82B1FF</color>
|
||||
<color name="blue_A200">#448AFF</color>
|
||||
<color name="blue_A400">#2979FF</color>
|
||||
<color name="blue_A700">#2962FF</color>
|
||||
|
||||
<color name="teal_50">#E0F2F1</color>
|
||||
<color name="teal_100">#B2DFDB</color>
|
||||
<color name="teal_200">#80CBC4</color>
|
||||
<color name="teal_300">#4DB6AC</color>
|
||||
<color name="teal_400">#26A69A</color>
|
||||
<color name="teal_500">#009688</color>
|
||||
<color name="teal_600">#00897B</color>
|
||||
<color name="teal_700">#00796B</color>
|
||||
<color name="teal_800">#00695C</color>
|
||||
<color name="teal_900">#004D40</color>
|
||||
<color name="teal_A100">#A7FFEB</color>
|
||||
<color name="teal_A200">#64FFDA</color>
|
||||
<color name="teal_A400">#1DE9B6</color>
|
||||
<color name="teal_A700">#00BFA5</color>
|
||||
|
||||
<color name="lime_50">#F9FBE7</color>
|
||||
<color name="lime_100">#F0F4C3</color>
|
||||
<color name="lime_200">#E6EE9C</color>
|
||||
<color name="lime_300">#DCE775</color>
|
||||
<color name="lime_400">#D4E157</color>
|
||||
<color name="lime_500">#CDDC39</color>
|
||||
<color name="lime_600">#C0CA33</color>
|
||||
<color name="lime_700">#AFB42B</color>
|
||||
<color name="lime_800">#9E9D24</color>
|
||||
<color name="lime_900">#827717</color>
|
||||
<color name="lime_A100">#F4FF81</color>
|
||||
<color name="lime_A200">#EEFF41</color>
|
||||
<color name="lime_A400">#C6FF00</color>
|
||||
<color name="lime_A700">#AEEA00</color>
|
||||
|
||||
<color name="orange_50">#FFF3E0</color>
|
||||
<color name="orange_100">#FFE0B2</color>
|
||||
<color name="orange_200">#FFCC80</color>
|
||||
<color name="orange_300">#FFB74D</color>
|
||||
<color name="orange_400">#FFA726</color>
|
||||
<color name="orange_500">#FF9800</color>
|
||||
<color name="orange_600">#FB8C00</color>
|
||||
<color name="orange_700">#F57C00</color>
|
||||
<color name="orange_800">#EF6C00</color>
|
||||
<color name="orange_900">#E65100</color>
|
||||
<color name="orange_A100">#FFD180</color>
|
||||
<color name="orange_A200">#FFAB40</color>
|
||||
<color name="orange_A400">#FF9100</color>
|
||||
<color name="orange_A700">#FF6D00</color>
|
||||
|
||||
<color name="grey_50">#FAFAFA</color>
|
||||
<color name="grey_100">#F5F5F5</color>
|
||||
<color name="grey_200">#EEEEEE</color>
|
||||
<color name="grey_300">#E0E0E0</color>
|
||||
<color name="grey_400">#BDBDBD</color>
|
||||
<color name="grey_500">#9E9E9E</color>
|
||||
<color name="grey_600">#757575</color>
|
||||
<color name="grey_700">#616161</color>
|
||||
<color name="grey_800">#424242</color>
|
||||
<color name="grey_900">#212121</color>
|
||||
|
||||
</resources>
|
@ -3,10 +3,7 @@
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<style name="TextSecure.LightNoActionBar" parent="@style/Theme.AppCompat.Light.NoActionBar">
|
||||
<item name="conversation_color_material_weight">500</item>
|
||||
<item name="actionbar_color_material_weight">500</item>
|
||||
<item name="statusbar_color_material_weight">700</item>
|
||||
|
||||
<item name="theme_type">light</item>
|
||||
<item name="actionBarStyle">@style/TextSecure.LightActionBar</item>
|
||||
<item name="actionBarTabBarStyle">@style/TextSecure.LightActionBar.TabBar</item>
|
||||
<item name="colorPrimary">@color/textsecure_primary</item>
|
||||
@ -16,10 +13,7 @@
|
||||
</style>
|
||||
|
||||
<style name="TextSecure.DarkNoActionBar" parent="@style/Theme.AppCompat.NoActionBar">
|
||||
<item name="conversation_color_material_weight">900</item>
|
||||
<item name="actionbar_color_material_weight">900</item>
|
||||
<item name="statusbar_color_material_weight">700</item>
|
||||
|
||||
<item name="theme_type">dark</item>
|
||||
<item name="actionBarStyle">@style/TextSecure.DarkActionBar</item>
|
||||
<item name="actionBarTabBarStyle">@style/TextSecure.DarkActionBar.TabBar</item>
|
||||
<item name="actionBarPopupTheme">@style/ThemeOverlay.AppCompat.Dark</item>
|
||||
@ -66,10 +60,7 @@
|
||||
</style>
|
||||
|
||||
<style name="TextSecure.LightTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
|
||||
<item name="conversation_color_material_weight">500</item>
|
||||
<item name="actionbar_color_material_weight">500</item>
|
||||
<item name="statusbar_color_material_weight">700</item>
|
||||
|
||||
<item name="theme_type">light</item>
|
||||
<item name="actionBarStyle">@style/TextSecure.LightActionBar</item>
|
||||
<item name="actionBarTabBarStyle">@style/TextSecure.LightActionBar.TabBar</item>
|
||||
<item name="colorPrimary">@color/textsecure_primary</item>
|
||||
@ -183,10 +174,7 @@
|
||||
</style>
|
||||
|
||||
<style name="TextSecure.DarkTheme" parent="@style/Theme.AppCompat">
|
||||
<item name="conversation_color_material_weight">900</item>
|
||||
<item name="actionbar_color_material_weight">900</item>
|
||||
<item name="statusbar_color_material_weight">700</item>
|
||||
|
||||
<item name="theme_type">light</item>
|
||||
<item name="actionBarStyle">@style/TextSecure.DarkActionBar</item>
|
||||
<item name="actionBarTabBarStyle">@style/TextSecure.DarkActionBar.TabBar</item>
|
||||
<item name="actionBarPopupTheme">@style/ThemeOverlay.AppCompat.Dark</item>
|
||||
|
@ -225,7 +225,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
initializeIme();
|
||||
|
||||
titleView.setTitle(recipients);
|
||||
setActionBarColor(recipients.getColor(this));
|
||||
setActionBarColor(recipients.getColor());
|
||||
setBlockedUserState(recipients);
|
||||
calculateCharactersRemaining();
|
||||
|
||||
@ -809,7 +809,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
public void run() {
|
||||
titleView.setTitle(recipients);
|
||||
setBlockedUserState(recipients);
|
||||
setActionBarColor(recipients.getColor(ConversationActivity.this));
|
||||
setActionBarColor(recipients.getColor());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -119,10 +119,10 @@ public class RecipientPreferenceActivity extends PassphraseRequiredActionBarActi
|
||||
private void setHeader(Recipients recipients) {
|
||||
this.avatar.setAvatar(recipients, true);
|
||||
this.title.setText(recipients.toShortString());
|
||||
this.toolbar.setBackgroundColor(recipients.getColor(this).toActionBarColor(this));
|
||||
this.toolbar.setBackgroundColor(recipients.getColor().toActionBarColor(this));
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
getWindow().setStatusBarColor(recipients.getColor(this).toStatusBarColor(this));
|
||||
getWindow().setStatusBarColor(recipients.getColor().toStatusBarColor(this));
|
||||
}
|
||||
|
||||
if (recipients.isBlocked()) this.blockedIndicator.setVisibility(View.VISIBLE);
|
||||
@ -186,7 +186,7 @@ public class RecipientPreferenceActivity extends PassphraseRequiredActionBarActi
|
||||
private void setSummaries(Recipients recipients) {
|
||||
CheckBoxPreference mutePreference = (CheckBoxPreference) this.findPreference(PREFERENCE_MUTED);
|
||||
RingtonePreference ringtonePreference = (RingtonePreference) this.findPreference(PREFERENCE_TONE);
|
||||
ListPreference vibratePreference = (ListPreference) this.findPreference(PREFERENCE_VIBRATE);
|
||||
ListPreference vibratePreference = (ListPreference) this.findPreference(PREFERENCE_VIBRATE);
|
||||
ColorPreference colorPreference = (ColorPreference) this.findPreference(PREFERENCE_COLOR);
|
||||
Preference blockPreference = this.findPreference(PREFERENCE_BLOCK);
|
||||
|
||||
@ -215,7 +215,7 @@ public class RecipientPreferenceActivity extends PassphraseRequiredActionBarActi
|
||||
|
||||
colorPreference.setEnabled(recipients.isSingleRecipient() && !recipients.isGroupRecipient());
|
||||
colorPreference.setChoices(MaterialColors.CONVERSATION_PALETTE.asConversationColorArray(getActivity()));
|
||||
colorPreference.setValue(recipients.getColor(getActivity()).toActionBarColor(getActivity()));
|
||||
colorPreference.setValue(recipients.getColor().toActionBarColor(getActivity()));
|
||||
|
||||
if (!recipients.isSingleRecipient() || recipients.isGroupRecipient()) {
|
||||
blockPreference.setEnabled(false);
|
||||
@ -290,10 +290,10 @@ public class RecipientPreferenceActivity extends PassphraseRequiredActionBarActi
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
final int value = (Integer) newValue;
|
||||
final MaterialColor selectedColor = MaterialColors.CONVERSATION_PALETTE.getByColor(value);
|
||||
final MaterialColor currentColor = recipients.getColor(getActivity());
|
||||
final MaterialColor selectedColor = MaterialColors.CONVERSATION_PALETTE.getByColor(getActivity(), value);
|
||||
final MaterialColor currentColor = recipients.getColor();
|
||||
|
||||
if (selectedColor == null) return false;
|
||||
if (selectedColor == null) return true;
|
||||
|
||||
if (preference.isEnabled() && !currentColor.equals(selectedColor)) {
|
||||
recipients.setColor(selectedColor);
|
||||
|
@ -1,28 +0,0 @@
|
||||
package org.thoughtcrime.securesms.color;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
class BlueGreyMaterialColor extends MaterialColor {
|
||||
|
||||
static final String SERIALIZED_NAME = "blue_grey";
|
||||
|
||||
BlueGreyMaterialColor() {
|
||||
super(new HashMap<String, Integer>() {{
|
||||
put("50", 0xFFECEFF1);
|
||||
put("100", 0xFFCFD8DC);
|
||||
put("200", 0xFFB0BEC5);
|
||||
put("300", 0xFF90A4AE);
|
||||
put("400", 0xFF78909C);
|
||||
put("500", 0xFF607D8B);
|
||||
put("600", 0xFF546E7A);
|
||||
put("700", 0xFF455A64);
|
||||
put("800", 0xFF37474F);
|
||||
put("900", 0xFF263238);
|
||||
}});
|
||||
}
|
||||
|
||||
@Override
|
||||
public String serialize() {
|
||||
return SERIALIZED_NAME;
|
||||
}
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
package org.thoughtcrime.securesms.color;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
class BlueMaterialColor extends MaterialColor {
|
||||
|
||||
static final String SERIALIZED_NAME = "blue";
|
||||
|
||||
BlueMaterialColor() {
|
||||
super(new HashMap<String, Integer>() {{
|
||||
put("50", 0xFFE3F2FD);
|
||||
put("100", 0xFFBBDEFB);
|
||||
put("200", 0xFF90CAF9);
|
||||
put("300", 0xFF64B5F6);
|
||||
put("400", 0xFF42A5F5);
|
||||
put("500", 0xFF2196F3);
|
||||
put("600", 0xFF1E88E5);
|
||||
put("700", 0xFF1976D2);
|
||||
put("800", 0xFF1565C0);
|
||||
put("900", 0xFF0D47A1);
|
||||
put("A100", 0xFF82B1FF);
|
||||
put("A200", 0xFF448AFF);
|
||||
put("A400", 0xFF2979FF);
|
||||
put("A700", 0xFF2962FF);
|
||||
}});
|
||||
}
|
||||
|
||||
@Override
|
||||
public String serialize() {
|
||||
return SERIALIZED_NAME;
|
||||
}
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
package org.thoughtcrime.securesms.color;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
class BrownMaterialColor extends MaterialColor {
|
||||
|
||||
static final String SERIALIZED_NAME = "brown";
|
||||
|
||||
BrownMaterialColor() {
|
||||
super(new HashMap<String, Integer>() {{
|
||||
put("50", 0xFFEFEBE9);
|
||||
put("100", 0xFFD7CCC8);
|
||||
put("200", 0xFFBCAAA4);
|
||||
put("300", 0xFFA1887F);
|
||||
put("400", 0xFF8D6E63);
|
||||
put("500", 0xFF795548);
|
||||
put("600", 0xFF6D4C41);
|
||||
put("700", 0xFF5D4037);
|
||||
put("800", 0xFF4E342E);
|
||||
put("900", 0xFF3E2723);
|
||||
}});
|
||||
}
|
||||
|
||||
@Override
|
||||
public String serialize() {
|
||||
return SERIALIZED_NAME;
|
||||
}
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
package org.thoughtcrime.securesms.color;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
class CyanMaterialColor extends MaterialColor {
|
||||
|
||||
static final String SERIALIZED_NAME = "cyan";
|
||||
|
||||
CyanMaterialColor() {
|
||||
super(new HashMap<String, Integer>() {{
|
||||
put("50", 0xFFE0F7FA);
|
||||
put("100", 0xFFB2EBF2);
|
||||
put("200", 0xFF80DEEA);
|
||||
put("300", 0xFF4DD0E1);
|
||||
put("400", 0xFF26C6DA);
|
||||
put("500", 0xFF00BCD4);
|
||||
put("600", 0xFF00ACC1);
|
||||
put("700", 0xFF0097A7);
|
||||
put("800", 0xFF00838F);
|
||||
put("900", 0xFF006064);
|
||||
put("A100", 0xFF84FFFF);
|
||||
put("A200", 0xFF18FFFF);
|
||||
put("A400", 0xFF00E5FF);
|
||||
put("A700", 0xFF00B8D4);
|
||||
}});
|
||||
}
|
||||
|
||||
@Override
|
||||
public String serialize() {
|
||||
return SERIALIZED_NAME;
|
||||
}
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
package org.thoughtcrime.securesms.color;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
class DeepOrangeMaterialColor extends MaterialColor {
|
||||
|
||||
static final String SERIALIZED_NAME = "deep_orange";
|
||||
|
||||
DeepOrangeMaterialColor() {
|
||||
super(new HashMap<String, Integer>() {{
|
||||
put("50", 0xFFFBE9E7);
|
||||
put("100", 0xFFFFCCBC);
|
||||
put("200", 0xFFFFAB91);
|
||||
put("300", 0xFFFF8A65);
|
||||
put("400", 0xFFFF7043);
|
||||
put("500", 0xFFFF5722);
|
||||
put("600", 0xFFF4511E);
|
||||
put("700", 0xFFE64A19);
|
||||
put("800", 0xFFD84315);
|
||||
put("900", 0xFFBF360C);
|
||||
put("A100", 0xFFFF9E80);
|
||||
put("A200", 0xFFFF6E40);
|
||||
put("A400", 0xFFFF3D00);
|
||||
put("A700", 0xFFDD2C00);
|
||||
}});
|
||||
}
|
||||
|
||||
@Override
|
||||
public String serialize() {
|
||||
return SERIALIZED_NAME;
|
||||
}
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
package org.thoughtcrime.securesms.color;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
class DeepPurpleMaterialColor extends MaterialColor {
|
||||
|
||||
static final String SERIALIZED_NAME = "deep_purple";
|
||||
|
||||
DeepPurpleMaterialColor() {
|
||||
super(new HashMap<String, Integer>() {{
|
||||
put("50",0xFFEDE7F6);
|
||||
put("100", 0xFFD1C4E9);
|
||||
put("200", 0xFFB39DDB);
|
||||
put("300", 0xFF9575CD);
|
||||
put("400", 0xFF7E57C2);
|
||||
put("500", 0xFF673AB7);
|
||||
put("600", 0xFF5E35B1);
|
||||
put("700", 0xFF512DA8);
|
||||
put("800", 0xFF4527A0);
|
||||
put("900", 0xFF311B92);
|
||||
put("A100", 0xFFB388FF);
|
||||
put("A200", 0xFF7C4DFF);
|
||||
put("A400", 0xFF651FFF);
|
||||
put("A700", 0xFF6200EA);
|
||||
}});
|
||||
}
|
||||
|
||||
@Override
|
||||
public String serialize() {
|
||||
return SERIALIZED_NAME;
|
||||
}
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
package org.thoughtcrime.securesms.color;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
class GreenMaterialColor extends MaterialColor {
|
||||
|
||||
static final String SERIALIZED_NAME = "green";
|
||||
|
||||
GreenMaterialColor() {
|
||||
super(new HashMap<String, Integer>() {{
|
||||
put("50", 0xFFE8F5E9);
|
||||
put("100", 0xFFC8E6C9);
|
||||
put("200", 0xFFA5D6A7);
|
||||
put("300", 0xFF81C784);
|
||||
put("400", 0xFF66BB6A);
|
||||
put("500", 0xFF4CAF50);
|
||||
put("600", 0xFF43A047);
|
||||
put("700", 0xFF388E3C);
|
||||
put("800", 0xFF2E7D32);
|
||||
put("900", 0xFF1B5E20);
|
||||
put("A100", 0xFFB9F6CA);
|
||||
put("A200", 0xFF69F0AE);
|
||||
put("A400", 0xFF00E676);
|
||||
put("A700", 0xFF00C853);
|
||||
}});
|
||||
}
|
||||
|
||||
@Override
|
||||
public String serialize() {
|
||||
return SERIALIZED_NAME;
|
||||
}
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
package org.thoughtcrime.securesms.color;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class GreyMaterialColor extends MaterialColor {
|
||||
|
||||
static final String SERIALIZED_NAME = "grey";
|
||||
|
||||
GreyMaterialColor() {
|
||||
super(new HashMap<String, Integer>(){{
|
||||
put("50", 0xFFFAFAFA);
|
||||
put("100", 0xFFF5F5F5);
|
||||
put("200", 0xFFEEEEEE);
|
||||
put("300", 0xFFE0E0E0);
|
||||
put("400", 0xFFBDBDBD);
|
||||
put("500", 0xFF9E9E9E);
|
||||
put("600", 0xFF757575);
|
||||
put("700", 0xFF616161);
|
||||
put("800", 0xFF424242);
|
||||
put("900", 0xFF212121);
|
||||
}});
|
||||
}
|
||||
@Override
|
||||
public String serialize() {
|
||||
return SERIALIZED_NAME;
|
||||
}
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
package org.thoughtcrime.securesms.color;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
class IndigoMaterialColor extends MaterialColor {
|
||||
|
||||
static final String SERIALIZED_NAME = "indigo";
|
||||
|
||||
IndigoMaterialColor() {
|
||||
super(new HashMap<String, Integer>(){{
|
||||
put("50", 0xFFE8EAF6);
|
||||
put("100", 0xFFC5CAE9);
|
||||
put("200", 0xFF9FA8DA);
|
||||
put("300", 0xFF7986CB);
|
||||
put("400", 0xFF5C6BC0);
|
||||
put("500", 0xFF3F51B5);
|
||||
put("600", 0xFF3949AB);
|
||||
put("700", 0xFF303F9F);
|
||||
put("800", 0xFF283593);
|
||||
put("900", 0xFF1A237E);
|
||||
put("A100", 0xFF8C9EFF);
|
||||
put("A200", 0xFF536DFE);
|
||||
put("A400", 0xFF3D5AFE);
|
||||
put("A700", 0xFF304FFE);
|
||||
}});
|
||||
}
|
||||
|
||||
@Override
|
||||
public String serialize() {
|
||||
return SERIALIZED_NAME;
|
||||
}
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
package org.thoughtcrime.securesms.color;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
class LightBlueMaterialColor extends MaterialColor {
|
||||
|
||||
static final String SERIALIZED_NAME = "light_blue";
|
||||
|
||||
LightBlueMaterialColor() {
|
||||
super(new HashMap<String, Integer>() {{
|
||||
put("50", 0xFFE1F5FE);
|
||||
put("100", 0xFFB3E5FC);
|
||||
put("200", 0xFF81D4FA);
|
||||
put("300", 0xFF4FC3F7);
|
||||
put("400", 0xFF29B6F6);
|
||||
put("500", 0xFF03A9F4);
|
||||
put("600", 0xFF039BE5);
|
||||
put("700", 0xFF0288D1);
|
||||
put("800", 0xFF0277BD);
|
||||
put("900", 0xFF01579B);
|
||||
put("A100", 0xFF80D8FF);
|
||||
put("A200", 0xFF40C4FF);
|
||||
put("A400", 0xFF00B0FF);
|
||||
put("A700", 0xFF0091EA);
|
||||
}});
|
||||
}
|
||||
|
||||
@Override
|
||||
public String serialize() {
|
||||
return SERIALIZED_NAME;
|
||||
}
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
package org.thoughtcrime.securesms.color;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
class LightGreenMaterialColor extends MaterialColor {
|
||||
|
||||
static final String SERIALIZED_NAME = "light_green";
|
||||
|
||||
LightGreenMaterialColor() {
|
||||
super(new HashMap<String, Integer>() {{
|
||||
put("50", 0xFFF1F8E9);
|
||||
put("100", 0xFFDCEDC8);
|
||||
put("200", 0xFFC5E1A5);
|
||||
put("300", 0xFFAED581);
|
||||
put("400", 0xFF9CCC65);
|
||||
put("500", 0xFF8BC34A);
|
||||
put("600", 0xFF7CB342);
|
||||
put("700", 0xFF689F38);
|
||||
put("800", 0xFF558B2F);
|
||||
put("900", 0xFF33691E);
|
||||
put("A100", 0xFFCCFF90);
|
||||
put("A200", 0xFFB2FF59);
|
||||
put("A400", 0xFF76FF03);
|
||||
put("A700", 0xFF64DD17);
|
||||
}});
|
||||
}
|
||||
|
||||
@Override
|
||||
public String serialize() {
|
||||
return SERIALIZED_NAME;
|
||||
}
|
||||
}
|
@ -2,82 +2,116 @@ package org.thoughtcrime.securesms.color;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.util.Log;
|
||||
import android.util.TypedValue;
|
||||
|
||||
import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.util.Util;
|
||||
|
||||
import java.util.Map;
|
||||
public enum MaterialColor {
|
||||
|
||||
public abstract class MaterialColor {
|
||||
RED (R.color.red_500, R.color.red_900, R.color.red_700, "red"),
|
||||
PINK (R.color.pink_500, R.color.pink_900, R.color.pink_700, "pink"),
|
||||
PURPLE (R.color.purple_500, R.color.purple_900, R.color.purple_700, "purple"),
|
||||
DEEP_PURPLE(R.color.deep_purple_500, R.color.deep_purple_900, R.color.deep_purple_700, "deep_purple"),
|
||||
INDIGO (R.color.indigo_500, R.color.indigo_900, R.color.indigo_700, "indigo"),
|
||||
BLUE (R.color.blue_500, R.color.blue_900, R.color.blue_700, "blue"),
|
||||
LIGHT_BLUE (R.color.light_blue_500, R.color.light_blue_900, R.color.light_blue_700, "light_blue"),
|
||||
CYAN (R.color.cyan_500, R.color.cyan_900, R.color.cyan_700, "cyan"),
|
||||
TEAL (R.color.teal_500, R.color.teal_900, R.color.teal_700, "teal"),
|
||||
GREEN (R.color.green_500, R.color.green_900, R.color.green_700, "green"),
|
||||
LIGHT_GREEN(R.color.light_green_500, R.color.light_green_900, R.color.light_green_700, "light_green"),
|
||||
LIME (R.color.lime_500, R.color.lime_900, R.color.lime_700, "lime"),
|
||||
YELLOW (R.color.yellow_500, R.color.yellow_900, R.color.yellow_700, "yellow"),
|
||||
AMBER (R.color.amber_500, R.color.amber_900, R.color.amber_700, "amber"),
|
||||
ORANGE (R.color.orange_500, R.color.orange_900, R.color.orange_700, "orange"),
|
||||
DEEP_ORANGE(R.color.deep_orange_500, R.color.deep_orange_900, R.color.deep_orange_700, "deep_orange"),
|
||||
BROWN (R.color.brown_500, R.color.brown_900, R.color.brown_700, "brown"),
|
||||
GREY (R.color.grey_500, R.color.grey_900, R.color.grey_700, "grey"),
|
||||
BLUE_GREY (R.color.blue_grey_500, R.color.blue_grey_900, R.color.blue_grey_700, "blue_grey"),
|
||||
|
||||
private final Map<String, Integer> colorWeightMap;
|
||||
GROUP (GREY.conversationColorLight, R.color.textsecure_primary, R.color.textsecure_primary_dark,
|
||||
GREY.conversationColorDark, R.color.textsecure_primary, R.color.textsecure_primary_dark,
|
||||
"group_color");
|
||||
|
||||
protected MaterialColor(@NonNull Map<String, Integer> colorWeightMap) {
|
||||
this.colorWeightMap = colorWeightMap;
|
||||
private final int conversationColorLight;
|
||||
private final int actionBarColorLight;
|
||||
private final int statusBarColorLight;
|
||||
private final int conversationColorDark;
|
||||
private final int actionBarColorDark;
|
||||
private final int statusBarColorDark;
|
||||
private final String serialized;
|
||||
|
||||
MaterialColor(int conversationColorLight, int actionBarColorLight,
|
||||
int statusBarColorLight, int conversationColorDark,
|
||||
int actionBarColorDark, int statusBarColorDark,
|
||||
String serialized)
|
||||
{
|
||||
this.conversationColorLight = conversationColorLight;
|
||||
this.actionBarColorLight = actionBarColorLight;
|
||||
this.statusBarColorLight = statusBarColorLight;
|
||||
this.conversationColorDark = conversationColorDark;
|
||||
this.actionBarColorDark = actionBarColorDark;
|
||||
this.statusBarColorDark = statusBarColorDark;
|
||||
this.serialized = serialized;
|
||||
}
|
||||
|
||||
MaterialColor(int lightColor, int darkColor, int statusBarColor, String serialized) {
|
||||
this(lightColor, lightColor, statusBarColor, darkColor, darkColor, statusBarColor, serialized);
|
||||
}
|
||||
|
||||
public int toConversationColor(@NonNull Context context) {
|
||||
return colorWeightMap.get(getWeight(context, R.attr.conversation_color_material_weight, "500"));
|
||||
if (getAttribute(context, R.attr.theme_type, "light").equals("dark")) {
|
||||
return context.getResources().getColor(conversationColorDark);
|
||||
} else {
|
||||
return context.getResources().getColor(conversationColorLight);
|
||||
}
|
||||
}
|
||||
|
||||
public int toActionBarColor(@NonNull Context context) {
|
||||
return colorWeightMap.get(getWeight(context, R.attr.actionbar_color_material_weight, "500"));
|
||||
if (getAttribute(context, R.attr.theme_type, "light").equals("dark")) {
|
||||
return context.getResources().getColor(actionBarColorDark);
|
||||
} else {
|
||||
return context.getResources().getColor(actionBarColorLight);
|
||||
}
|
||||
}
|
||||
|
||||
public int toStatusBarColor(@NonNull Context context) {
|
||||
return colorWeightMap.get(getWeight(context, R.attr.statusbar_color_material_weight, "700"));
|
||||
if (getAttribute(context, R.attr.theme_type, "light").equals("dark")) {
|
||||
return context.getResources().getColor(statusBarColorDark);
|
||||
} else {
|
||||
return context.getResources().getColor(statusBarColorLight);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean represents(int colorValue) {
|
||||
return colorWeightMap.values().contains(colorValue);
|
||||
public boolean represents(Context context, int colorValue) {
|
||||
return context.getResources().getColor(conversationColorDark) == colorValue ||
|
||||
context.getResources().getColor(conversationColorLight) == colorValue ||
|
||||
context.getResources().getColor(actionBarColorDark) == colorValue ||
|
||||
context.getResources().getColor(actionBarColorLight) == colorValue ||
|
||||
context.getResources().getColor(statusBarColorLight) == colorValue ||
|
||||
context.getResources().getColor(statusBarColorDark) == colorValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (other == null || !(other instanceof MaterialColor)) return false;
|
||||
return serialize().equals(((MaterialColor)other).serialize());
|
||||
public String serialize() {
|
||||
return serialized;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Util.hashCode(serialize());
|
||||
}
|
||||
|
||||
public abstract String serialize();
|
||||
|
||||
private String getWeight(Context context, int attribute, String defaultWeight) {
|
||||
private String getAttribute(Context context, int attribute, String defaultValue) {
|
||||
TypedValue outValue = new TypedValue();
|
||||
|
||||
if (context.getTheme().resolveAttribute(attribute, outValue, true)) {
|
||||
return outValue.coerceToString().toString();
|
||||
} else {
|
||||
return defaultWeight;
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
public static MaterialColor fromSerialized(String serialized) throws UnknownColorException {
|
||||
switch (serialized) {
|
||||
case RedMaterialColor.SERIALIZED_NAME: return new RedMaterialColor();
|
||||
case PinkMaterialColor.SERIALIZED_NAME: return new PinkMaterialColor();
|
||||
case PurpleMaterialColor.SERIALIZED_NAME: return new PurpleMaterialColor();
|
||||
case DeepPurpleMaterialColor.SERIALIZED_NAME: return new DeepPurpleMaterialColor();
|
||||
case IndigoMaterialColor.SERIALIZED_NAME: return new IndigoMaterialColor();
|
||||
case BlueMaterialColor.SERIALIZED_NAME: return new BlueMaterialColor();
|
||||
case LightBlueMaterialColor.SERIALIZED_NAME: return new LightBlueMaterialColor();
|
||||
case CyanMaterialColor.SERIALIZED_NAME: return new CyanMaterialColor();
|
||||
case TealMaterialColor.SERIALIZED_NAME: return new TealMaterialColor();
|
||||
case GreenMaterialColor.SERIALIZED_NAME: return new GreenMaterialColor();
|
||||
case LightGreenMaterialColor.SERIALIZED_NAME: return new LightGreenMaterialColor();
|
||||
case OrangeMaterialColor.SERIALIZED_NAME: return new OrangeMaterialColor();
|
||||
case DeepOrangeMaterialColor.SERIALIZED_NAME: return new DeepOrangeMaterialColor();
|
||||
case BrownMaterialColor.SERIALIZED_NAME: return new BrownMaterialColor();
|
||||
case GreyMaterialColor.SERIALIZED_NAME: return new GreyMaterialColor();
|
||||
case BlueGreyMaterialColor.SERIALIZED_NAME: return new BlueGreyMaterialColor();
|
||||
|
||||
default: throw new UnknownColorException("Unknown color: " + serialized);
|
||||
public static MaterialColor fromSerialized(String serialized) throws UnknownColorException {
|
||||
for (MaterialColor color : MaterialColor.values()) {
|
||||
if (color.serialized.equals(serialized)) return color;
|
||||
}
|
||||
|
||||
throw new UnknownColorException("Unknown color: " + serialized);
|
||||
}
|
||||
|
||||
public static class UnknownColorException extends Exception {
|
||||
@ -85,4 +119,5 @@ public abstract class MaterialColor {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -10,28 +10,28 @@ import java.util.List;
|
||||
|
||||
public class MaterialColors {
|
||||
|
||||
public static final MaterialColor GREY = new GreyMaterialColor();
|
||||
|
||||
public static final MaterialColorList CONVERSATION_PALETTE = new MaterialColorList(new ArrayList<>(Arrays.asList(
|
||||
new RedMaterialColor(),
|
||||
new PinkMaterialColor(),
|
||||
new PurpleMaterialColor(),
|
||||
new DeepPurpleMaterialColor(),
|
||||
new IndigoMaterialColor(),
|
||||
new BlueMaterialColor(),
|
||||
new LightBlueMaterialColor(),
|
||||
new CyanMaterialColor(),
|
||||
new TealMaterialColor(),
|
||||
new GreenMaterialColor(),
|
||||
new LightGreenMaterialColor(),
|
||||
MaterialColor.RED,
|
||||
MaterialColor.PINK,
|
||||
MaterialColor.PURPLE,
|
||||
|
||||
MaterialColor.DEEP_PURPLE,
|
||||
MaterialColor.INDIGO,
|
||||
MaterialColor.BLUE,
|
||||
|
||||
MaterialColor.LIGHT_BLUE,
|
||||
MaterialColor.CYAN,
|
||||
MaterialColor.TEAL,
|
||||
MaterialColor.GREEN,
|
||||
MaterialColor.LIGHT_GREEN,
|
||||
// Lime
|
||||
// Yellow
|
||||
// Amber
|
||||
new OrangeMaterialColor(),
|
||||
new DeepOrangeMaterialColor(),
|
||||
new BrownMaterialColor(),
|
||||
MaterialColor.ORANGE,
|
||||
MaterialColor.DEEP_ORANGE,
|
||||
MaterialColor.BROWN,
|
||||
// Grey
|
||||
new BlueGreyMaterialColor()
|
||||
MaterialColor.BLUE_GREY
|
||||
)));
|
||||
|
||||
public static class MaterialColorList {
|
||||
@ -50,9 +50,9 @@ public class MaterialColors {
|
||||
return colors.size();
|
||||
}
|
||||
|
||||
public @Nullable MaterialColor getByColor(int colorValue) {
|
||||
public @Nullable MaterialColor getByColor(Context context, int colorValue) {
|
||||
for (MaterialColor color : colors) {
|
||||
if (color.represents(colorValue)) {
|
||||
if (color.represents(context, colorValue)) {
|
||||
return color;
|
||||
}
|
||||
}
|
||||
|
@ -1,32 +0,0 @@
|
||||
package org.thoughtcrime.securesms.color;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
class OrangeMaterialColor extends MaterialColor {
|
||||
|
||||
static final String SERIALIZED_NAME = "orange";
|
||||
|
||||
OrangeMaterialColor() {
|
||||
super(new HashMap<String, Integer>() {{
|
||||
put("50", 0xFFFFF3E0);
|
||||
put("100", 0xFFFFE0B2);
|
||||
put("200", 0xFFFFCC80);
|
||||
put("300", 0xFFFFB74D);
|
||||
put("400", 0xFFFFA726);
|
||||
put("500", 0xFFFF9800);
|
||||
put("600", 0xFFFB8C00);
|
||||
put("700", 0xFFF57C00);
|
||||
put("800", 0xFFEF6C00);
|
||||
put("900", 0xFFE65100);
|
||||
put("A100", 0xFFFFD180);
|
||||
put("A200", 0xFFFFAB40);
|
||||
put("A400", 0xFFFF9100);
|
||||
put("A700", 0xFFFF6D00);
|
||||
}});
|
||||
}
|
||||
|
||||
@Override
|
||||
public String serialize() {
|
||||
return SERIALIZED_NAME;
|
||||
}
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
package org.thoughtcrime.securesms.color;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class PinkMaterialColor extends MaterialColor {
|
||||
|
||||
static final String SERIALIZED_NAME = "pink";
|
||||
|
||||
PinkMaterialColor() {
|
||||
super(new HashMap<String, Integer>() {{
|
||||
put("50", 0xFFFCE4EC);
|
||||
put("100", 0xFFF8BBD0);
|
||||
put("200", 0xFFF48FB1);
|
||||
put("300", 0xFFF06292);
|
||||
put("400", 0xFFEC407A);
|
||||
put("500", 0xFFE91E63);
|
||||
put("600", 0xFFD81B60);
|
||||
put("700", 0xFFC2185B);
|
||||
put("800", 0xFFAD1457);
|
||||
put("900", 0xFF880E4F);
|
||||
put("A100", 0xFFFF80AB);
|
||||
put("A200", 0xFFFF4081);
|
||||
put("A400", 0xFFF50057);
|
||||
put("A700", 0xFFC51162);
|
||||
}});
|
||||
}
|
||||
|
||||
@Override
|
||||
public String serialize() {
|
||||
return SERIALIZED_NAME;
|
||||
}
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
package org.thoughtcrime.securesms.color;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
class PurpleMaterialColor extends MaterialColor {
|
||||
|
||||
static final String SERIALIZED_NAME = "purple";
|
||||
|
||||
PurpleMaterialColor() {
|
||||
super(new HashMap<String, Integer>() {{
|
||||
put("50", 0xFFF3E5F5);
|
||||
put("100", 0xFFE1BEE7);
|
||||
put("200", 0xFFCE93D8);
|
||||
put("300", 0xFFBA68C8);
|
||||
put("400", 0xFFAB47BC);
|
||||
put("500", 0xFF9C27B0);
|
||||
put("600", 0xFF8E24AA);
|
||||
put("700", 0xFF7B1FA2);
|
||||
put("800", 0xFF6A1B9A);
|
||||
put("900", 0xFF4A148C);
|
||||
put("A100", 0xFFEA80FC);
|
||||
put("A200", 0xFFE040FB);
|
||||
put("A400", 0xFFD500F9);
|
||||
put("A700", 0xFFAA00FF);
|
||||
}});
|
||||
}
|
||||
|
||||
@Override
|
||||
public String serialize() {
|
||||
return SERIALIZED_NAME;
|
||||
}
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
package org.thoughtcrime.securesms.color;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class RedMaterialColor extends MaterialColor {
|
||||
|
||||
static final String SERIALIZED_NAME = "red";
|
||||
|
||||
RedMaterialColor() {
|
||||
super(new HashMap<String, Integer>() {{
|
||||
put("50", 0xFFFFEBEE);
|
||||
put("100", 0xFFFFCDD2);
|
||||
put("200", 0xFFEF9A9A);
|
||||
put("300", 0xFFE57373);
|
||||
put("400", 0xFFEF5350);
|
||||
put("500", 0xFFF44336);
|
||||
put("600", 0xFFE53935);
|
||||
put("700", 0xFFD32F2F);
|
||||
put("800", 0xFFC62828);
|
||||
put("900", 0xFFB71C1C);
|
||||
put("A100", 0xFFFF8A80);
|
||||
put("A200", 0xFFFF5252);
|
||||
put("A400", 0xFFFF1744);
|
||||
put("A700", 0xFFD50000);
|
||||
}});
|
||||
}
|
||||
|
||||
@Override
|
||||
public String serialize() {
|
||||
return SERIALIZED_NAME;
|
||||
}
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
package org.thoughtcrime.securesms.color;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
class TealMaterialColor extends MaterialColor {
|
||||
|
||||
static final String SERIALIZED_NAME = "teal";
|
||||
|
||||
TealMaterialColor() {
|
||||
super(new HashMap<String, Integer>() {{
|
||||
put("50", 0xFFE0F2F1);
|
||||
put("100", 0xFFB2DFDB);
|
||||
put("200", 0xFF80CBC4);
|
||||
put("300", 0xFF4DB6AC);
|
||||
put("400", 0xFF26A69A);
|
||||
put("500", 0xFF009688);
|
||||
put("600", 0xFF00897B);
|
||||
put("700", 0xFF00796B);
|
||||
put("800", 0xFF00695C);
|
||||
put("900", 0xFF004D40);
|
||||
put("A100", 0xFFA7FFEB);
|
||||
put("A200", 0xFF64FFDA);
|
||||
put("A400", 0xFF1DE9B6);
|
||||
put("A700", 0xFF00BFA5);
|
||||
}});
|
||||
}
|
||||
|
||||
@Override
|
||||
public String serialize() {
|
||||
return SERIALIZED_NAME;
|
||||
}
|
||||
}
|
@ -39,7 +39,7 @@ public class AvatarImageView extends ImageView {
|
||||
|
||||
public void setAvatar(@Nullable Recipients recipients, boolean quickContactEnabled) {
|
||||
if (recipients != null) {
|
||||
MaterialColor backgroundColor = recipients.getColor(getContext());
|
||||
MaterialColor backgroundColor = recipients.getColor();
|
||||
setImageDrawable(recipients.getContactPhoto().asDrawable(getContext(), backgroundColor.toConversationColor(getContext()), inverted));
|
||||
setAvatarClickHandler(recipients, quickContactEnabled);
|
||||
} else {
|
||||
|
@ -1,46 +1,16 @@
|
||||
package org.thoughtcrime.securesms.contacts.avatars;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.color.MaterialColor;
|
||||
import org.thoughtcrime.securesms.color.MaterialColors;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class ContactColors {
|
||||
|
||||
public static final MaterialColor UNKNOWN_COLOR = MaterialColors.GREY;
|
||||
public static final MaterialColor UNKNOWN_COLOR = MaterialColor.GREY;
|
||||
|
||||
public static MaterialColor generateFor(@NonNull String name) {
|
||||
return MaterialColors.CONVERSATION_PALETTE.get(Math.abs(name.hashCode()) % MaterialColors.CONVERSATION_PALETTE.size());
|
||||
}
|
||||
|
||||
public static MaterialColor getGroupColor(Context context) {
|
||||
final int actionBarColor = context.getResources().getColor(R.color.textsecure_primary);
|
||||
final int statusBarColor = context.getResources().getColor(R.color.textsecure_primary_dark);
|
||||
|
||||
return new MaterialColor(new HashMap<String, Integer>()) {
|
||||
@Override
|
||||
public int toConversationColor(@NonNull Context context) {
|
||||
return UNKNOWN_COLOR.toConversationColor(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int toActionBarColor(@NonNull Context context) {
|
||||
return actionBarColor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int toStatusBarColor(@NonNull Context context) {
|
||||
return statusBarColor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String serialize() {
|
||||
return "group_color";
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -196,7 +196,7 @@ public class MessageNotifier {
|
||||
Recipients recipients = notifications.get(0).getRecipients();
|
||||
int largeIconTargetSize = context.getResources().getDimensionPixelSize(R.dimen.contact_photo_target_size);
|
||||
Drawable recipientPhoto = recipient.getContactPhoto().asDrawable(context, recipients == null ? ContactColors.UNKNOWN_COLOR.toConversationColor(context) :
|
||||
recipients.getColor(context).toConversationColor(context));
|
||||
recipients.getColor().toConversationColor(context));
|
||||
|
||||
if (recipientPhoto != null) {
|
||||
Bitmap recipientPhotoBitmap = BitmapUtil.createFromDrawable(recipientPhoto, largeIconTargetSize, largeIconTargetSize);
|
||||
|
@ -22,7 +22,6 @@ import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.GradientDrawable;
|
||||
@ -33,7 +32,6 @@ import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.GridLayout;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.TypedValue;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
@ -16,7 +16,6 @@
|
||||
*/
|
||||
package org.thoughtcrime.securesms.recipients;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
@ -157,8 +156,8 @@ public class Recipients implements Iterable<Recipient>, RecipientModifiedListene
|
||||
else return ContactPhotoFactory.getDefaultGroupPhoto();
|
||||
}
|
||||
|
||||
public synchronized @NonNull MaterialColor getColor(Context context) {
|
||||
if (!isSingleRecipient() || isGroupRecipient()) return ContactColors.getGroupColor(context);
|
||||
public synchronized @NonNull MaterialColor getColor() {
|
||||
if (!isSingleRecipient() || isGroupRecipient()) return MaterialColor.GROUP;
|
||||
else if (isEmpty()) return ContactColors.UNKNOWN_COLOR;
|
||||
else return recipients.get(0).getColor();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user