Theme Support
1) Broke out the UI elements of the major Activites into stylable attributes. 2) Created a 'light' and 'dark' theme for the newly stylable attrs. 3) Touched up some of the UI spacing. 4) Implemented dynamic theme switching support.pull/1/head
After Width: | Height: | Size: 312 B |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 319 B |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 4.2 KiB |
After Width: | Height: | Size: 827 B |
Before Width: | Height: | Size: 927 B After Width: | Height: | Size: 927 B |
After Width: | Height: | Size: 156 B |
After Width: | Height: | Size: 245 B |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 246 B |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 3.5 KiB |
After Width: | Height: | Size: 609 B |
Before Width: | Height: | Size: 692 B After Width: | Height: | Size: 692 B |
After Width: | Height: | Size: 151 B |
After Width: | Height: | Size: 372 B |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 375 B |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 4.6 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 1.0 KiB |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 160 B |
@ -1,26 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2007 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_selected="true"
|
||||
android:drawable="@android:color/transparent" />
|
||||
<item android:state_pressed="true" android:state_selected="false"
|
||||
android:drawable="@android:color/transparent" />
|
||||
<item android:state_selected="false" android:state_activated="false"
|
||||
android:drawable="@color/read_bgcolor" />
|
||||
<item android:state_activated="true"
|
||||
android:drawable="@drawable/list_selector_background_selected" />
|
||||
</selector>
|
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_selected="true"
|
||||
android:drawable="@android:color/transparent" />
|
||||
<item android:state_pressed="true" android:state_selected="false"
|
||||
android:drawable="@android:color/transparent" />
|
||||
<item android:state_selected="false" android:state_activated="false"
|
||||
android:drawable="@color/conversation_list_item_background_read_dark" />
|
||||
<item android:state_activated="true"
|
||||
android:drawable="@drawable/list_selector_background_selected" />
|
||||
</selector>
|
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_selected="true"
|
||||
android:drawable="@android:color/transparent" />
|
||||
<item android:state_pressed="true" android:state_selected="false"
|
||||
android:drawable="@android:color/transparent" />
|
||||
<item android:state_selected="false" android:state_activated="false"
|
||||
android:drawable="@color/conversation_list_item_background_read_light" />
|
||||
<item android:state_activated="true"
|
||||
android:drawable="@drawable/list_selector_background_selected" />
|
||||
</selector>
|
@ -1,26 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2007 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_selected="true"
|
||||
android:drawable="@android:color/transparent" />
|
||||
<item android:state_pressed="true" android:state_selected="false"
|
||||
android:drawable="@android:color/transparent" />
|
||||
<item android:state_selected="false" android:state_activated="false"
|
||||
android:drawable="@color/unread_bgcolor" />
|
||||
<item android:state_activated="true"
|
||||
android:drawable="@drawable/list_selector_background_selected" />
|
||||
</selector>
|
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_selected="true"
|
||||
android:drawable="@android:color/transparent" />
|
||||
<item android:state_pressed="true" android:state_selected="false"
|
||||
android:drawable="@android:color/transparent" />
|
||||
<item android:state_selected="false" android:state_activated="false"
|
||||
android:drawable="@color/conversation_list_item_background_unread_dark" />
|
||||
<item android:state_activated="true"
|
||||
android:drawable="@drawable/list_selector_background_selected" />
|
||||
</selector>
|
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_selected="true"
|
||||
android:drawable="@android:color/transparent" />
|
||||
<item android:state_pressed="true" android:state_selected="false"
|
||||
android:drawable="@android:color/transparent" />
|
||||
<item android:state_selected="false" android:state_activated="false"
|
||||
android:drawable="@color/conversation_list_item_background_unread_light" />
|
||||
<item android:state_activated="true"
|
||||
android:drawable="@drawable/list_selector_background_selected" />
|
||||
</selector>
|
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="edit_text_light_theme">#ff000000</color>
|
||||
<color name="edit_text_dark_theme">#ffeeeeee</color>
|
||||
</resources>
|
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="edit_text_light_theme">#ff000000</color>
|
||||
<color name="edit_text_dark_theme">#ff000000</color>
|
||||
</resources>
|
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<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"/>
|
||||
<attr name="conversation_list_item_count_color" format="reference|color"/>
|
||||
|
||||
<attr name="conversation_background" format="reference|color"/>
|
||||
<attr name="conversation_card_background" format="reference|color"/>
|
||||
<attr name="conversation_text_primary_color" format="reference|color"/>
|
||||
<attr name="conversation_text_secondary_color" format="reference|color"/>
|
||||
<attr name="conversation_avatar_divet_right" format="reference"/>
|
||||
<attr name="conversation_avatar_divet_left" format="reference"/>
|
||||
<attr name="conversation_editor_background" format="reference|color"/>
|
||||
<attr name="conversation_editor_text_color" format="reference|color"/>
|
||||
<attr name="conversation_send_button" format="reference"/>
|
||||
<attr name="conversation_send_secure_button" format="reference"/>
|
||||
<attr name="conversation_delivered_indicator" format="reference"/>
|
||||
</resources>
|
@ -1,8 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<drawable name="white_background">#ffffffff</drawable>
|
||||
<drawable name="text_color_black">#ff000000</drawable>
|
||||
|
||||
<color name="unread_bgcolor">#ffffffff</color>
|
||||
<color name="read_bgcolor">#ffeeeeee</color>
|
||||
|
||||
<color name="white">#ffffffff</color>
|
||||
<color name="black">#ff000000</color>
|
||||
|
||||
<color name="conversation_list_item_background_read_light">#ffeeeeee</color>
|
||||
<color name="conversation_list_item_background_unread_light">#ffffffff</color>
|
||||
<color name="conversation_list_item_background_read_dark">#ff000000</color>
|
||||
<color name="conversation_list_item_background_unread_dark">#ff333333</color>
|
||||
|
||||
</resources>
|
@ -0,0 +1,41 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<style name="TextSecure.LightTheme" parent="@style/Theme.Sherlock.Light.DarkActionBar">
|
||||
<item name="conversation_list_item_background_read">@drawable/conversation_list_item_background_read_light</item>
|
||||
<item name="conversation_list_item_background_unread">@drawable/conversation_list_item_background_unread_light</item>
|
||||
<item name="conversation_list_item_background_selected">@drawable/list_selected_holo_light</item>
|
||||
<item name="conversation_list_item_count_color">#66333333</item>
|
||||
|
||||
<item name="conversation_card_background">#ffdddddd</item>
|
||||
<item name="conversation_background">@color/white</item>
|
||||
<item name="conversation_text_primary_color">@color/abs__primary_text_holo_light</item>
|
||||
<item name="conversation_text_secondary_color">#ffcccccc</item>
|
||||
<item name="conversation_avatar_divet_right">@drawable/divet_right_light</item>
|
||||
<item name="conversation_avatar_divet_left">@drawable/divet_left_light</item>
|
||||
<item name="conversation_editor_background">#eeeeee</item>
|
||||
<item name="conversation_editor_text_color">@color/edit_text_light_theme</item>
|
||||
<item name="conversation_send_button">@drawable/ic_send_holo_light</item>
|
||||
<item name="conversation_send_secure_button">@drawable/ic_send_encrypted_holo_light</item>
|
||||
<item name="conversation_delivered_indicator">@drawable/ic_sms_mms_delivered_light</item>
|
||||
</style>
|
||||
|
||||
<style name="TextSecure.DarkTheme" parent="@style/Theme.Sherlock">
|
||||
<item name="conversation_list_item_background_read">@drawable/conversation_list_item_background_read_dark</item>
|
||||
<item name="conversation_list_item_background_unread">@drawable/conversation_list_item_background_unread_dark</item>
|
||||
<item name="conversation_list_item_background_selected">@drawable/list_selected_holo_dark</item>
|
||||
<item name="conversation_list_item_count_color">#66dddddd</item>
|
||||
|
||||
<item name="conversation_card_background">#ffdddddd</item>
|
||||
<item name="conversation_background">@color/black</item>
|
||||
<item name="conversation_text_primary_color">@color/abs__primary_text_holo_dark</item>
|
||||
<item name="conversation_text_secondary_color">#ffcccccc</item>
|
||||
<item name="conversation_avatar_divet_right">@drawable/divet_right_dark</item>
|
||||
<item name="conversation_avatar_divet_left">@drawable/divet_left_dark</item>
|
||||
<item name="conversation_editor_background">@color/black</item>
|
||||
<item name="conversation_editor_text_color">@color/edit_text_dark_theme</item>
|
||||
<item name="conversation_send_button">@drawable/ic_send_holo_dark</item>
|
||||
<item name="conversation_send_secure_button">@drawable/ic_send_holo_dark_encrypted</item>
|
||||
<item name="conversation_delivered_indicator">@drawable/ic_sms_mms_delivered_dark</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
@ -0,0 +1,61 @@
|
||||
package org.thoughtcrime.securesms.util;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.preference.PreferenceManager;
|
||||
|
||||
import org.thoughtcrime.securesms.ApplicationPreferencesActivity;
|
||||
import org.thoughtcrime.securesms.R;
|
||||
|
||||
public class DynamicTheme {
|
||||
|
||||
private int currentTheme;
|
||||
|
||||
public void onCreate(Activity activity) {
|
||||
currentTheme = getSelectedTheme(activity);
|
||||
activity.setTheme(currentTheme);
|
||||
}
|
||||
|
||||
public void onResume(Activity activity) {
|
||||
if (currentTheme != getSelectedTheme(activity)) {
|
||||
Intent intent = activity.getIntent();
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
|
||||
|
||||
activity.startActivity(intent);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ECLAIR) {
|
||||
OverridePendingTransition.invoke(activity);
|
||||
}
|
||||
|
||||
activity.finish();
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ECLAIR) {
|
||||
OverridePendingTransition.invoke(activity);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static int getSelectedTheme(Context context) {
|
||||
String theme = PreferenceManager.getDefaultSharedPreferences(context)
|
||||
.getString(ApplicationPreferencesActivity.THEME_PREF, "light");
|
||||
|
||||
return getSelectedTheme(theme);
|
||||
}
|
||||
|
||||
public static int getSelectedTheme(String theme) {
|
||||
if (theme.equals("light")) {
|
||||
return R.style.TextSecure_LightTheme;
|
||||
} else if (theme.equals("dark")) {
|
||||
return R.style.TextSecure_DarkTheme;
|
||||
}
|
||||
|
||||
return R.style.TextSecure_LightTheme;
|
||||
}
|
||||
|
||||
private static final class OverridePendingTransition {
|
||||
static void invoke(Activity activity) {
|
||||
activity.overridePendingTransition(0, 0);
|
||||
}
|
||||
}
|
||||
}
|