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.
This commit is contained in:
Moxie Marlinspike 2013-06-21 11:56:59 -07:00
parent 2ffc70a95b
commit 5263ac1f1a
62 changed files with 443 additions and 156 deletions

View File

@ -10,19 +10,19 @@
android:label="Access to TextSecure Secrets" android:label="Access to TextSecure Secrets"
android:protectionLevel="signature" /> android:protectionLevel="signature" />
<uses-permission android:name="org.thoughtcrime.securesms.ACCESS_SECRETS"></uses-permission> <uses-permission android:name="org.thoughtcrime.securesms.ACCESS_SECRETS"/>
<uses-permission android:name="android.permission.READ_PROFILE"></uses-permission> <uses-permission android:name="android.permission.READ_PROFILE"/>
<uses-permission android:name="android.permission.WRITE_PROFILE"></uses-permission> <uses-permission android:name="android.permission.WRITE_PROFILE"/>
<uses-permission android:name="android.permission.BROADCAST_WAP_PUSH"></uses-permission> <uses-permission android:name="android.permission.BROADCAST_WAP_PUSH"/>
<uses-permission android:name="android.permission.READ_CONTACTS"></uses-permission> <uses-permission android:name="android.permission.READ_CONTACTS"/>
<uses-permission android:name="android.permission.WRITE_CONTACTS"></uses-permission> <uses-permission android:name="android.permission.WRITE_CONTACTS"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.RECEIVE_SMS"></uses-permission> <uses-permission android:name="android.permission.RECEIVE_SMS"/>
<uses-permission android:name="android.permission.RECEIVE_MMS"></uses-permission> <uses-permission android:name="android.permission.RECEIVE_MMS"/>
<uses-permission android:name="android.permission.READ_SMS"></uses-permission> <uses-permission android:name="android.permission.READ_SMS"/>
<uses-permission android:name="android.permission.SEND_SMS"></uses-permission> <uses-permission android:name="android.permission.SEND_SMS"/>
<uses-permission android:name="android.permission.WRITE_SMS"></uses-permission> <uses-permission android:name="android.permission.WRITE_SMS"/>
<uses-permission android:name="android.permission.VIBRATE"></uses-permission> <uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" /> <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" /> <uses-permission android:name="android.permission.READ_PHONE_STATE" />
@ -40,7 +40,7 @@
<application android:icon="@drawable/icon" <application android:icon="@drawable/icon"
android:label="@string/app_name" android:label="@string/app_name"
android:theme="@style/Theme.Sherlock.Light.DarkActionBar"> android:theme="@style/TextSecure.LightTheme">
<activity android:name=".RoutingActivity" <activity android:name=".RoutingActivity"
android:theme="@style/NoAnimation.Theme.Sherlock.Light.DarkActionBar" android:theme="@style/NoAnimation.Theme.Sherlock.Light.DarkActionBar"

Binary file not shown.

After

Width:  |  Height:  |  Size: 312 B

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 319 B

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 827 B

View File

Before

Width:  |  Height:  |  Size: 927 B

After

Width:  |  Height:  |  Size: 927 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 156 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 245 B

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 246 B

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 609 B

View File

Before

Width:  |  Height:  |  Size: 692 B

After

Width:  |  Height:  |  Size: 692 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 151 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 372 B

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 375 B

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 160 B

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -18,7 +18,7 @@
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_height="fill_parent"
android:orientation="vertical" android:orientation="vertical"
android:background="@drawable/white_background" android:background="?conversation_background"
android:gravity="bottom"> android:gravity="bottom">
<fragment <fragment
@ -38,7 +38,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:orientation="vertical"
android:paddingBottom="5dip" android:paddingBottom="5dip"
android:background="#fff"> android:background="?conversation_background">
<LinearLayout <LinearLayout
android:id="@+id/attachment_editor" android:id="@+id/attachment_editor"
@ -51,7 +51,8 @@
android:id="@+id/attachment_thumbnail" android:id="@+id/attachment_thumbnail"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="150dip" android:layout_height="150dip"
android:layout_weight="1" /> android:layout_weight="1"
android:contentDescription="Attachment Thumbnail"/>
<LinearLayout <LinearLayout
android:orientation="vertical" android:orientation="vertical"
@ -70,7 +71,7 @@
</LinearLayout> </LinearLayout>
<View android:background="#eeeeee" <View android:background="?conversation_editor_background"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="1dp" /> android:layout_height="1dp" />
@ -97,7 +98,7 @@
android:maxLength="1000" android:maxLength="1000"
android:maxLines="4" android:maxLines="4"
android:nextFocusRight="@+id/send_button" android:nextFocusRight="@+id/send_button"
android:textColor="@android:color/black" /> android:textColor="?conversation_editor_text_color" />
<ImageButton <ImageButton
android:id="@+id/send_button" android:id="@+id/send_button"
@ -108,19 +109,17 @@
android:contentDescription="@string/conversation_activity__send" android:contentDescription="@string/conversation_activity__send"
android:nextFocusLeft="@+id/embedded_text_editor" android:nextFocusLeft="@+id/embedded_text_editor"
android:padding="12dp" android:padding="12dp"
android:src="@drawable/ic_send_holo_light" android:src="?conversation_send_button"
android:clickable="false" android:clickable="false"
android:enabled="false" /> android:enabled="false" />
<!-- android:tint="#66ffffff" />-->
"
</LinearLayout> </LinearLayout>
<TextView android:id="@+id/space_left" <TextView android:id="@+id/space_left"
android:paddingLeft="5dip" android:paddingLeft="5dip"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="160/160 (1)" android:text="160/160 (1)" />
/>
</LinearLayout> </LinearLayout>
</ScrollView> </ScrollView>
</RelativeLayout> </RelativeLayout>

View File

@ -9,8 +9,9 @@
<RelativeLayout <RelativeLayout
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="fill_parent"
android:orientation="horizontal"> android:orientation="horizontal"
android:background="?conversation_card_background">
<view xmlns:android="http://schemas.android.com/apk/res/android" <view xmlns:android="http://schemas.android.com/apk/res/android"
class="org.thoughtcrime.securesms.components.ImageDivet" class="org.thoughtcrime.securesms.components.ImageDivet"
@ -20,14 +21,15 @@
android:layout_width="60dp" android:layout_width="60dp"
android:layout_height="60dp" android:layout_height="60dp"
android:cropToPadding="true" android:cropToPadding="true"
android:layout_marginRight="10dip"
android:scaleType="centerCrop" /> android:scaleType="centerCrop" />
<LinearLayout android:id="@+id/conversation_item_parent" <LinearLayout android:id="@+id/conversation_item_parent"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="match_parent"
android:layout_toLeftOf="@+id/indicators_parent" android:layout_toLeftOf="@+id/indicators_parent"
android:layout_toRightOf="@id/contact_photo" android:layout_toRightOf="@id/contact_photo"
android:background="?conversation_background"
android:paddingLeft="10dip"
android:orientation="vertical" > android:orientation="vertical" >
<TextView android:id="@+id/conversation_item_body" <TextView android:id="@+id/conversation_item_body"
@ -35,14 +37,16 @@
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:linksClickable="true" android:linksClickable="true"
android:paddingTop="5dip"
android:textAppearance="?android:attr/textAppearanceSmall" android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#ff000000" android:textColor="?conversation_text_primary_color"
android:textSize="16sp" /> android:textSize="16sp" />
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mms_view" android:id="@+id/mms_view"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_height="fill_parent"
android:visibility="gone"
android:paddingTop="7dip" android:paddingTop="7dip"
android:paddingBottom="7dip"> android:paddingBottom="7dip">
@ -54,7 +58,8 @@
android:scaleType="centerInside" android:scaleType="centerInside"
android:adjustViewBounds="true" android:adjustViewBounds="true"
android:background="@android:drawable/picture_frame" android:background="@android:drawable/picture_frame"
android:visibility="gone" /> android:visibility="gone"
android:contentDescription="Message Media"/>
<ImageButton <ImageButton
android:id="@+id/play_slideshow_button" android:id="@+id/play_slideshow_button"
@ -62,7 +67,8 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:src="@drawable/mms_play_btn" android:src="@drawable/mms_play_btn"
android:layout_gravity="center" android:layout_gravity="center"
android:visibility="gone" /> android:visibility="gone"
android:contentDescription="Play Button"/>
</FrameLayout> </FrameLayout>
@ -91,16 +97,18 @@
</LinearLayout> </LinearLayout>
<LinearLayout android:layout_width="fill_parent" <LinearLayout android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="match_parent"
android:orientation="horizontal" android:orientation="horizontal"
android:paddingTop="5dip"
android:gravity="left"> android:gravity="left">
<ImageView android:id="@+id/delivered_indicator" <ImageView android:id="@+id/delivered_indicator"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingRight="3dip" android:paddingRight="3dip"
android:src="@drawable/ic_sms_mms_delivered" android:src="?conversation_delivered_indicator"
android:visibility="gone" /> android:visibility="gone"
android:contentDescription="Delivered Indicator"/>
<TextView android:id="@+id/group_message_status" <TextView android:id="@+id/group_message_status"
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -108,7 +116,7 @@
android:linksClickable="false" android:linksClickable="false"
android:textAppearance="?android:attr/textAppearanceSmall" android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_gravity="left" android:layout_gravity="left"
android:textColor="#ffcccccc" android:textColor="?conversation_text_secondary_color"
android:visibility="gone" android:visibility="gone"
android:layout_marginRight="8dip" android:layout_marginRight="8dip"
android:paddingTop="1dip"/> android:paddingTop="1dip"/>
@ -120,7 +128,7 @@
android:linksClickable="false" android:linksClickable="false"
android:textAppearance="?android:attr/textAppearanceSmall" android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_gravity="left" android:layout_gravity="left"
android:textColor="#ffcccccc" android:textColor="?conversation_text_secondary_color"
android:paddingTop="1dip"/> android:paddingTop="1dip"/>
</LinearLayout> </LinearLayout>
@ -128,34 +136,35 @@
<LinearLayout android:id="@+id/indicators_parent" <LinearLayout android:id="@+id/indicators_parent"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="fill_parent"
android:layout_centerVertical="true"
android:orientation="vertical" android:orientation="vertical"
android:layout_alignParentRight="true"> android:layout_alignParentRight="true"
android:gravity="center_vertical"
android:background="?conversation_background">
<ImageView <ImageView
android:id="@+id/key_exchange_indicator" android:id="@+id/key_exchange_indicator"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:src="@drawable/ic_menu_login" android:src="@drawable/ic_menu_login"
android:visibility="gone" /> android:visibility="gone"
android:contentDescription="Key Exchange Indicator"/>
<ImageView <ImageView
android:id="@+id/sms_secure_indicator" android:id="@+id/sms_secure_indicator"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:src="@drawable/ic_menu_lock_holo_light" android:src="@drawable/ic_menu_lock_holo_light"
android:visibility="gone" /> android:visibility="gone"
android:contentDescription="Secure Message Indicator"/>
<ImageView <ImageView
android:id="@+id/sms_failed_indicator" android:id="@+id/sms_failed_indicator"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:src="@drawable/ic_list_alert_sms_failed" android:src="@drawable/ic_list_alert_sms_failed"
android:visibility="gone" /> android:visibility="gone"
android:contentDescription="Send Failed Indicator"/>
</LinearLayout> </LinearLayout>
</RelativeLayout> </RelativeLayout>

View File

@ -7,48 +7,51 @@
android:paddingLeft="10dip" android:paddingLeft="10dip"
android:orientation="horizontal"> android:orientation="horizontal">
<RelativeLayout <RelativeLayout android:layout_width="fill_parent"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:layout_height="wrap_content" android:orientation="horizontal"
android:orientation="horizontal"> android:background="?conversation_card_background">
<LinearLayout android:id="@+id/indicators_parent" <LinearLayout android:id="@+id/indicators_parent"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="match_parent"
android:orientation="vertical" android:orientation="vertical"
android:layout_centerVertical="true" android:layout_alignParentLeft="true"
android:layout_alignParentLeft="true"> android:gravity="center_vertical"
android:background="?conversation_background">
<ImageView <ImageView
android:id="@+id/key_exchange_indicator" android:id="@+id/key_exchange_indicator"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:src="@drawable/ic_menu_login" android:src="@drawable/ic_menu_login"
android:visibility="gone" /> android:visibility="gone"
android:contentDescription="Key Exchange Indicator"/>
<ImageView <ImageView
android:id="@+id/sms_secure_indicator" android:id="@+id/sms_secure_indicator"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:src="@drawable/ic_menu_lock_holo_light" android:src="@drawable/ic_menu_lock_holo_light"
android:visibility="gone" /> android:visibility="gone"
android:contentDescription="Secure Message Indicator"/>
<ImageView <ImageView
android:id="@+id/sms_failed_indicator" android:id="@+id/sms_failed_indicator"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:src="@drawable/ic_list_alert_sms_failed" android:src="@drawable/ic_list_alert_sms_failed"
android:visibility="gone" /> android:visibility="gone"
android:contentDescription="Send Failed Indicator"/>
</LinearLayout> </LinearLayout>
<LinearLayout android:id="@+id/conversation_item_parent" <LinearLayout android:id="@+id/conversation_item_parent"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="match_parent"
android:layout_toRightOf="@id/indicators_parent" android:layout_toRightOf="@id/indicators_parent"
android:layout_toLeftOf="@+id/contact_photo" android:layout_toLeftOf="@+id/contact_photo"
android:background="?conversation_background"
android:paddingRight="10dip"
android:orientation="vertical" > android:orientation="vertical" >
<TextView android:id="@+id/conversation_item_body" <TextView android:id="@+id/conversation_item_body"
@ -58,13 +61,14 @@
android:linksClickable="true" android:linksClickable="true"
android:textAppearance="?android:attr/textAppearanceSmall" android:textAppearance="?android:attr/textAppearanceSmall"
android:gravity="right" android:gravity="right"
android:textColor="#ff000000" android:textColor="?conversation_text_primary_color"
android:textSize="16sp" /> android:textSize="16sp" />
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mms_view" android:id="@+id/mms_view"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_height="fill_parent"
android:visibility="gone"
android:paddingTop="7dip" android:paddingTop="7dip"
android:paddingBottom="7dip"> android:paddingBottom="7dip">
@ -76,7 +80,8 @@
android:scaleType="centerInside" android:scaleType="centerInside"
android:adjustViewBounds="true" android:adjustViewBounds="true"
android:background="@android:drawable/picture_frame" android:background="@android:drawable/picture_frame"
android:visibility="gone" /> android:visibility="gone"
android:contentDescription="Media Message"/>
<ImageButton <ImageButton
android:id="@+id/play_slideshow_button" android:id="@+id/play_slideshow_button"
@ -84,7 +89,8 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:src="@drawable/mms_play_btn" android:src="@drawable/mms_play_btn"
android:layout_gravity="center" android:layout_gravity="center"
android:visibility="gone" /> android:visibility="gone"
android:contentDescription="Play Button"/>
</FrameLayout> </FrameLayout>
@ -113,16 +119,18 @@
</LinearLayout> </LinearLayout>
<LinearLayout android:layout_width="fill_parent" <LinearLayout android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="match_parent"
android:orientation="horizontal" android:orientation="horizontal"
android:paddingTop="5dip"
android:gravity="right"> android:gravity="right">
<ImageView android:id="@+id/delivered_indicator" <ImageView android:id="@+id/delivered_indicator"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingRight="3dip" android:paddingRight="3dip"
android:src="@drawable/ic_sms_mms_delivered" android:src="?conversation_delivered_indicator"
android:visibility="gone" /> android:visibility="gone"
android:contentDescription="Delivered Indicator"/>
<TextView android:id="@+id/group_message_status" <TextView android:id="@+id/group_message_status"
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -130,7 +138,7 @@
android:linksClickable="false" android:linksClickable="false"
android:textAppearance="?android:attr/textAppearanceSmall" android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_gravity="right" android:layout_gravity="right"
android:textColor="#ffcccccc" android:textColor="?conversation_text_secondary_color"
android:visibility="gone" android:visibility="gone"
android:layout_marginRight="8dip" android:layout_marginRight="8dip"
android:paddingTop="1dip"/> android:paddingTop="1dip"/>
@ -142,7 +150,7 @@
android:linksClickable="false" android:linksClickable="false"
android:textAppearance="?android:attr/textAppearanceSmall" android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_gravity="right" android:layout_gravity="right"
android:textColor="#ffcccccc" android:textColor="?conversation_text_secondary_color"
android:paddingTop="1dip"/> android:paddingTop="1dip"/>
</LinearLayout> </LinearLayout>
@ -158,7 +166,6 @@
android:layout_width="60dp" android:layout_width="60dp"
android:layout_height="60dp" android:layout_height="60dp"
android:cropToPadding="true" android:cropToPadding="true"
android:layout_marginLeft="10dip"
android:layout_marginRight="0dip" android:layout_marginRight="0dip"
android:padding="0dip" android:padding="0dip"
android:scaleType="centerCrop" /> android:scaleType="centerCrop" />

View File

@ -1,9 +1,8 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<org.thoughtcrime.securesms.ConversationListItem xmlns:android="http://schemas.android.com/apk/res/android" <org.thoughtcrime.securesms.ConversationListItem
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content">
android:paddingRight="10dip"
>
<FrameLayout android:id="@+id/contact_photo_frame" <FrameLayout android:id="@+id/contact_photo_frame"
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -11,6 +10,7 @@
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:layout_alignParentLeft="true" android:layout_alignParentLeft="true"
android:visibility="visible"> android:visibility="visible">
<QuickContactBadge android:id="@+id/contact_photo_badge" <QuickContactBadge android:id="@+id/contact_photo_badge"
style="?android:attr/quickContactBadgeStyleWindowLarge" style="?android:attr/quickContactBadgeStyleWindowLarge"
android:visibility="gone" /> android:visibility="gone" />
@ -20,7 +20,8 @@
android:layout_height="60dp" android:layout_height="60dp"
android:cropToPadding="true" android:cropToPadding="true"
android:scaleType="centerCrop" android:scaleType="centerCrop"
android:visibility="gone" /> android:visibility="gone"
android:contentDescription="Contact Photo Image"/>
</FrameLayout> </FrameLayout>
<!--<CheckBox android:id="@+id/checkbox"--> <!--<CheckBox android:id="@+id/checkbox"-->
@ -37,18 +38,19 @@
android:singleLine="true" android:singleLine="true"
android:layout_marginTop="6dip" android:layout_marginTop="6dip"
android:layout_marginRight="5dip" android:layout_marginRight="5dip"
android:layout_marginLeft="5dip" android:layout_marginLeft="10dip"
android:layout_marginBottom="10dip"
android:layout_alignTop="@id/contact_photo_frame" android:layout_alignTop="@id/contact_photo_frame"
android:layout_toRightOf="@id/contact_photo_frame" android:layout_toRightOf="@id/contact_photo_frame"
android:layout_alignWithParentIfMissing="true" android:layout_alignWithParentIfMissing="true"
android:ellipsize="marquee" android:ellipsize="marquee"/>
android:textColor="#000000"/>
<!--android:layout_toLeftOf="@id/checkbox"--> <!--android:layout_toLeftOf="@id/checkbox"-->
<TextView android:id="@+id/date" <TextView android:id="@+id/date"
android:layout_marginBottom="10dip" android:layout_marginBottom="10dip"
android:layout_marginLeft="5dip" android:layout_marginLeft="5dip"
android:paddingRight="10dip"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall" android:textAppearance="?android:attr/textAppearanceSmall"
@ -64,7 +66,8 @@
android:layout_alignBottom="@id/date" android:layout_alignBottom="@id/date"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:src="@drawable/ic_list_alert_sms_failed" /> android:src="@drawable/ic_list_alert_sms_failed"
android:contentDescription="Error Alert"/>
<ImageView android:id="@+id/attachment" <ImageView android:id="@+id/attachment"
android:layout_marginLeft="3dip" android:layout_marginLeft="3dip"
@ -73,7 +76,8 @@
android:visibility="gone" android:visibility="gone"
android:layout_toLeftOf="@id/error" android:layout_toLeftOf="@id/error"
android:layout_alignBottom="@id/date" android:layout_alignBottom="@id/date"
android:src="@drawable/ic_attachment_universal_small" /> android:src="@drawable/ic_attachment_universal_small"
android:contentDescription="Attachment Indicator"/>
<TextView android:id="@+id/subject" <TextView android:id="@+id/subject"
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -81,7 +85,7 @@
android:textAppearance="?android:attr/textAppearanceSmall" android:textAppearance="?android:attr/textAppearanceSmall"
android:singleLine="true" android:singleLine="true"
android:layout_marginBottom="10dip" android:layout_marginBottom="10dip"
android:layout_marginLeft="5dip" android:layout_marginLeft="10dip"
android:layout_alignBottom="@id/contact_photo_frame" android:layout_alignBottom="@id/contact_photo_frame"
android:layout_toRightOf="@id/contact_photo_frame" android:layout_toRightOf="@id/contact_photo_frame"
android:layout_toLeftOf="@id/date" android:layout_toLeftOf="@id/date"

View File

@ -18,7 +18,7 @@
<TextView android:id="@+id/text1" <TextView android:id="@+id/text1"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="fill_parent" android:layout_height="fill_parent"
android:textColor="@drawable/text_color_black" android:textColor="@color/black"
android:gravity="center_vertical" android:gravity="center_vertical"
android:textAppearance="?android:attr/textAppearanceLarge" android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_gravity="center_horizontal|center_vertical" /> android:layout_gravity="center_horizontal|center_vertical" />

View File

@ -8,7 +8,7 @@
android:paddingBottom="5dip" android:paddingBottom="5dip"
android:paddingLeft="5dip" android:paddingLeft="5dip"
android:paddingRight="5dip" android:paddingRight="5dip"
android:background="@drawable/white_background" android:background="?conversation_background"
android:orientation="vertical" > android:orientation="vertical" >
<org.thoughtcrime.securesms.contacts.RecipientsEditor android:id="@+id/recipients_text" <org.thoughtcrime.securesms.contacts.RecipientsEditor android:id="@+id/recipients_text"

View File

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

5
res/values-v8/colors.xml Normal file
View File

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

View File

@ -6,6 +6,16 @@
<item>@string/preferences__hours</item> <item>@string/preferences__hours</item>
</string-array> </string-array>
<string-array name="pref_theme_entries">
<item>@string/preferences__light_theme</item>
<item>@string/preferences__dark_theme</item>
</string-array>
<string-array name="pref_theme_values" translatable="false">
<item>light</item>
<item>dark</item>
</string-array>
<string-array name="pref_led_color_entries"> <string-array name="pref_led_color_entries">
<item>@string/preferences__green</item> <item>@string/preferences__green</item>
<item>@string/preferences__red</item> <item>@string/preferences__red</item>

19
res/values/attrs.xml Normal file
View File

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

View File

@ -1,8 +1,12 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<drawable name="white_background">#ffffffff</drawable>
<drawable name="text_color_black">#ff000000</drawable>
<color name="unread_bgcolor">#ffffffff</color> <color name="white">#ffffffff</color>
<color name="read_bgcolor">#ffeeeeee</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> </resources>

View File

@ -457,7 +457,8 @@
<string name="preferences__conversation_length_limit">Conversation length limit</string> <string name="preferences__conversation_length_limit">Conversation length limit</string>
<string name="preferences__trim_all_threads_now">Trim all threads now</string> <string name="preferences__trim_all_threads_now">Trim all threads now</string>
<string name="preferences__scan_through_all_conversation_threads_and_enforce_conversation_length_limits">Scan through all conversation threads and enforce conversation length limits</string> <string name="preferences__scan_through_all_conversation_threads_and_enforce_conversation_length_limits">Scan through all conversation threads and enforce conversation length limits</string>
<string name="preferences__light_theme">Light Theme</string>
<string name="preferences__dark_theme">Dark Theme</string>
<!-- **************************************** --> <!-- **************************************** -->
<!-- menus --> <!-- menus -->
@ -527,6 +528,8 @@
<!-- verify_keys --> <!-- verify_keys -->
<string name="verify_keys__menu_verified">Verified</string> <string name="verify_keys__menu_verified">Verified</string>
<string name="preferences__appearance">Appearance</string>
<string name="preferences__theme">Theme</string>
<!-- EOF --> <!-- EOF -->
</resources> </resources>

41
res/values/themes.xml Normal file
View File

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

View File

@ -62,6 +62,15 @@
android:summary="@string/preferences__also_vibrate_when_notified" /> android:summary="@string/preferences__also_vibrate_when_notified" />
</PreferenceCategory> </PreferenceCategory>
<PreferenceCategory android:title="@string/preferences__appearance">
<ListPreference android:key="pref_theme"
android:title="@string/preferences__theme"
android:entries="@array/pref_theme_entries"
android:entryValues="@array/pref_theme_values"
android:defaultValue="light">
</ListPreference>
</PreferenceCategory>
<PreferenceCategory android:title="@string/preferences__storage"> <PreferenceCategory android:title="@string/preferences__storage">
<CheckBoxPreference android:defaultValue="false" <CheckBoxPreference android:defaultValue="false"
android:key="pref_trim_threads" android:key="pref_trim_threads"

View File

@ -38,8 +38,10 @@ import org.thoughtcrime.securesms.crypto.IdentityKeyUtil;
import org.thoughtcrime.securesms.crypto.MasterSecret; import org.thoughtcrime.securesms.crypto.MasterSecret;
import org.thoughtcrime.securesms.crypto.MasterSecretUtil; import org.thoughtcrime.securesms.crypto.MasterSecretUtil;
import org.thoughtcrime.securesms.util.Dialogs; import org.thoughtcrime.securesms.util.Dialogs;
import org.thoughtcrime.securesms.util.DynamicTheme;
import org.thoughtcrime.securesms.util.MemoryCleaner; import org.thoughtcrime.securesms.util.MemoryCleaner;
import org.thoughtcrime.securesms.util.Trimmer; import org.thoughtcrime.securesms.util.Trimmer;
import org.thoughtcrime.securesms.util.Util;
import com.actionbarsherlock.view.MenuItem; import com.actionbarsherlock.view.MenuItem;
@ -52,7 +54,9 @@ import java.util.List;
* *
*/ */
public class ApplicationPreferencesActivity extends PassphraseRequiredSherlockPreferenceActivity { public class ApplicationPreferencesActivity extends PassphraseRequiredSherlockPreferenceActivity
implements SharedPreferences.OnSharedPreferenceChangeListener
{
private static final int PICK_IDENTITY_CONTACT = 1; private static final int PICK_IDENTITY_CONTACT = 1;
@ -67,6 +71,7 @@ public class ApplicationPreferencesActivity extends PassphraseRequiredSherlockPr
public static final String PASSPHRASE_TIMEOUT_INTERVAL_PREF = "pref_timeout_interval"; public static final String PASSPHRASE_TIMEOUT_INTERVAL_PREF = "pref_timeout_interval";
public static final String PASSPHRASE_TIMEOUT_PREF = "pref_timeout_passphrase"; public static final String PASSPHRASE_TIMEOUT_PREF = "pref_timeout_passphrase";
public static final String AUTO_KEY_EXCHANGE_PREF = "pref_auto_complete_key_exchange"; public static final String AUTO_KEY_EXCHANGE_PREF = "pref_auto_complete_key_exchange";
public static final String THEME_PREF = "pref_theme";
private static final String DISPLAY_CATEGORY_PREF = "pref_display_category"; private static final String DISPLAY_CATEGORY_PREF = "pref_display_category";
@ -93,8 +98,11 @@ public class ApplicationPreferencesActivity extends PassphraseRequiredSherlockPr
public static final String REGISTERED_GCM_PREF = "pref_gcm_registered"; public static final String REGISTERED_GCM_PREF = "pref_gcm_registered";
public static final String GCM_PASSWORD_PREF = "pref_gcm_password"; public static final String GCM_PASSWORD_PREF = "pref_gcm_password";
private final DynamicTheme dynamicTheme = new DynamicTheme();
@Override @Override
protected void onCreate(Bundle icicle) { protected void onCreate(Bundle icicle) {
dynamicTheme.onCreate(this);
super.onCreate(icicle); super.onCreate(icicle);
this.getSupportActionBar().setDisplayHomeAsUpEnabled(true); this.getSupportActionBar().setDisplayHomeAsUpEnabled(true);
@ -116,6 +124,24 @@ public class ApplicationPreferencesActivity extends PassphraseRequiredSherlockPr
.setOnPreferenceChangeListener(new TrimLengthValidationListener()); .setOnPreferenceChangeListener(new TrimLengthValidationListener());
} }
@Override
public void onStart() {
super.onStart();
getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
}
@Override
public void onResume() {
super.onResume();
dynamicTheme.onResume(this);
}
@Override
public void onStop() {
super.onStop();
getPreferenceScreen().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(this);
}
@Override @Override
public void onDestroy() { public void onDestroy() {
MemoryCleaner.clean((MasterSecret) getIntent().getParcelableExtra("master_secret")); MemoryCleaner.clean((MasterSecret) getIntent().getParcelableExtra("master_secret"));
@ -203,6 +229,13 @@ public class ApplicationPreferencesActivity extends PassphraseRequiredSherlockPr
} }
} }
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
if (key.equals(THEME_PREF)) {
dynamicTheme.onResume(this);
}
}
private class IdentityPreferenceClickListener implements Preference.OnPreferenceClickListener { private class IdentityPreferenceClickListener implements Preference.OnPreferenceClickListener {
@Override @Override
public boolean onPreferenceClick(Preference preference) { public boolean onPreferenceClick(Preference preference) {
@ -328,4 +361,5 @@ public class ApplicationPreferencesActivity extends PassphraseRequiredSherlockPr
((PreferenceScreen)preference).getDialog().getWindow().getDecorView().setBackgroundDrawable(this.getWindow().getDecorView().getBackground().getConstantState().newDrawable()); ((PreferenceScreen)preference).getDialog().getWindow().getDecorView().setBackgroundDrawable(this.getWindow().getDecorView().getBackground().getConstantState().newDrawable());
return false; return false;
} }
} }

View File

@ -23,6 +23,7 @@ import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction; import android.support.v4.app.FragmentTransaction;
import org.thoughtcrime.securesms.recipients.Recipients; import org.thoughtcrime.securesms.recipients.Recipients;
import org.thoughtcrime.securesms.util.DynamicTheme;
import com.actionbarsherlock.app.ActionBar; import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.app.ActionBar.Tab; import com.actionbarsherlock.app.ActionBar.Tab;
@ -41,6 +42,8 @@ import com.actionbarsherlock.view.MenuItem;
*/ */
public class ContactSelectionActivity extends PassphraseRequiredSherlockFragmentActivity { public class ContactSelectionActivity extends PassphraseRequiredSherlockFragmentActivity {
private final DynamicTheme dynamicTheme = new DynamicTheme();
private ContactSelectionListFragment contactsFragment; private ContactSelectionListFragment contactsFragment;
private ContactSelectionGroupsFragment groupsFragment; private ContactSelectionGroupsFragment groupsFragment;
private ContactSelectionRecentFragment recentFragment; private ContactSelectionRecentFragment recentFragment;
@ -49,6 +52,7 @@ public class ContactSelectionActivity extends PassphraseRequiredSherlockFragment
@Override @Override
protected void onCreate(Bundle icicle) { protected void onCreate(Bundle icicle) {
dynamicTheme.onCreate(this);
super.onCreate(icicle); super.onCreate(icicle);
ActionBar actionBar = this.getSupportActionBar(); ActionBar actionBar = this.getSupportActionBar();
@ -62,6 +66,12 @@ public class ContactSelectionActivity extends PassphraseRequiredSherlockFragment
setupRecentTab(); setupRecentTab();
} }
@Override
public void onResume() {
super.onResume();
dynamicTheme.onResume(this);
}
@Override @Override
public boolean onCreateOptionsMenu(Menu menu) { public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = this.getSupportMenuInflater(); MenuInflater inflater = this.getSupportMenuInflater();

View File

@ -24,6 +24,7 @@ import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.IntentFilter; import android.content.IntentFilter;
import android.content.res.TypedArray;
import android.net.Uri; import android.net.Uri;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Build; import android.os.Build;
@ -75,6 +76,7 @@ import org.thoughtcrime.securesms.sms.OutgoingEncryptedMessage;
import org.thoughtcrime.securesms.sms.OutgoingTextMessage; import org.thoughtcrime.securesms.sms.OutgoingTextMessage;
import org.thoughtcrime.securesms.util.BitmapDecodingException; import org.thoughtcrime.securesms.util.BitmapDecodingException;
import org.thoughtcrime.securesms.util.CharacterCalculator; import org.thoughtcrime.securesms.util.CharacterCalculator;
import org.thoughtcrime.securesms.util.DynamicTheme;
import org.thoughtcrime.securesms.util.EncryptedCharacterCalculator; import org.thoughtcrime.securesms.util.EncryptedCharacterCalculator;
import org.thoughtcrime.securesms.util.InvalidMessageException; import org.thoughtcrime.securesms.util.InvalidMessageException;
import org.thoughtcrime.securesms.util.MemoryCleaner; import org.thoughtcrime.securesms.util.MemoryCleaner;
@ -129,9 +131,11 @@ public class ConversationActivity extends PassphraseRequiredSherlockFragmentActi
private boolean isMmsEnabled = true; private boolean isMmsEnabled = true;
private CharacterCalculator characterCalculator = new CharacterCalculator(); private CharacterCalculator characterCalculator = new CharacterCalculator();
private DynamicTheme dynamicTheme = new DynamicTheme();
@Override @Override
protected void onCreate(Bundle state) { protected void onCreate(Bundle state) {
dynamicTheme.onCreate(this);
super.onCreate(state); super.onCreate(state);
setContentView(R.layout.conversation_activity); setContentView(R.layout.conversation_activity);
@ -154,6 +158,8 @@ public class ConversationActivity extends PassphraseRequiredSherlockFragmentActi
@Override @Override
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
dynamicTheme.onResume(this);
initializeSecurity(); initializeSecurity();
initializeTitleBar(); initializeTitleBar();
initializeMmsEnabledCheck(); initializeMmsEnabledCheck();
@ -513,21 +519,26 @@ public class ConversationActivity extends PassphraseRequiredSherlockFragmentActi
} }
private void initializeSecurity() { private void initializeSecurity() {
int attributes[] = new int[]{R.attr.conversation_send_button,
R.attr.conversation_send_secure_button};
TypedArray drawables = obtainStyledAttributes(attributes);
if (isSingleConversation() && if (isSingleConversation() &&
KeyUtil.isSessionFor(this, getRecipients().getPrimaryRecipient())) KeyUtil.isSessionFor(this, getRecipients().getPrimaryRecipient()))
{ {
sendButton.setImageResource(R.drawable.ic_send_encrypted_holo_light); sendButton.setImageDrawable(drawables.getDrawable(1));
this.isEncryptedConversation = true; this.isEncryptedConversation = true;
this.isAuthenticatedConversation = KeyUtil.isIdentityKeyFor(this, masterSecret, getRecipients().getPrimaryRecipient()); this.isAuthenticatedConversation = KeyUtil.isIdentityKeyFor(this, masterSecret, getRecipients().getPrimaryRecipient());
this.characterCalculator = new EncryptedCharacterCalculator(); this.characterCalculator = new EncryptedCharacterCalculator();
} else { } else {
sendButton.setImageResource(R.drawable.ic_send_holo_light); sendButton.setImageDrawable(drawables.getDrawable(0));
this.isEncryptedConversation = false; this.isEncryptedConversation = false;
this.isAuthenticatedConversation = false; this.isAuthenticatedConversation = false;
this.characterCalculator = new CharacterCalculator(); this.characterCalculator = new CharacterCalculator();
} }
calculateCharactersRemaining(); calculateCharactersRemaining();
drawables.recycle();
} }
private void initializeMmsEnabledCheck() { private void initializeMmsEnabledCheck() {

View File

@ -84,6 +84,7 @@ public class ConversationItem extends LinearLayout {
private ImageView contactPhoto; private ImageView contactPhoto;
private ImageView deliveredImage; private ImageView deliveredImage;
private View mmsContainer;
private ImageView mmsThumbnail; private ImageView mmsThumbnail;
private Button mmsDownloadButton; private Button mmsDownloadButton;
private TextView mmsDownloadingLabel; private TextView mmsDownloadingLabel;
@ -115,6 +116,7 @@ public class ConversationItem extends LinearLayout {
this.secureImage = (ImageView)findViewById(R.id.sms_secure_indicator); this.secureImage = (ImageView)findViewById(R.id.sms_secure_indicator);
this.failedImage = (ImageView)findViewById(R.id.sms_failed_indicator); this.failedImage = (ImageView)findViewById(R.id.sms_failed_indicator);
this.keyImage = (ImageView)findViewById(R.id.key_exchange_indicator); this.keyImage = (ImageView)findViewById(R.id.key_exchange_indicator);
this.mmsContainer = (View) findViewById(R.id.mms_view);
this.mmsThumbnail = (ImageView)findViewById(R.id.image_view); this.mmsThumbnail = (ImageView)findViewById(R.id.image_view);
this.mmsDownloadButton = (Button) findViewById(R.id.mms_download_button); this.mmsDownloadButton = (Button) findViewById(R.id.mms_download_button);
this.mmsDownloadingLabel = (TextView) findViewById(R.id.mms_label_downloading); this.mmsDownloadingLabel = (TextView) findViewById(R.id.mms_label_downloading);
@ -237,9 +239,11 @@ public class ConversationItem extends LinearLayout {
private void setMediaMmsAttributes(MediaMmsMessageRecord messageRecord) { private void setMediaMmsAttributes(MediaMmsMessageRecord messageRecord) {
if (messageRecord.getPartCount() > 0) { if (messageRecord.getPartCount() > 0) {
mmsThumbnail.setVisibility(View.VISIBLE); mmsThumbnail.setVisibility(View.VISIBLE);
mmsContainer.setVisibility(View.VISIBLE);
mmsThumbnail.setImageDrawable(new ColorDrawable(Color.TRANSPARENT)); mmsThumbnail.setImageDrawable(new ColorDrawable(Color.TRANSPARENT));
} else { } else {
mmsThumbnail.setVisibility(View.GONE); mmsThumbnail.setVisibility(View.GONE);
mmsContainer.setVisibility(View.GONE);
} }
slideDeck = messageRecord.getSlideDeck(); slideDeck = messageRecord.getSlideDeck();

View File

@ -21,18 +21,22 @@ import org.thoughtcrime.securesms.recipients.RecipientFactory;
import org.thoughtcrime.securesms.recipients.Recipients; import org.thoughtcrime.securesms.recipients.Recipients;
import org.thoughtcrime.securesms.service.KeyCachingService; import org.thoughtcrime.securesms.service.KeyCachingService;
import org.thoughtcrime.securesms.service.SendReceiveService; import org.thoughtcrime.securesms.service.SendReceiveService;
import org.thoughtcrime.securesms.util.DynamicTheme;
import org.thoughtcrime.securesms.util.MemoryCleaner; import org.thoughtcrime.securesms.util.MemoryCleaner;
public class ConversationListActivity extends PassphraseRequiredSherlockFragmentActivity public class ConversationListActivity extends PassphraseRequiredSherlockFragmentActivity
implements ConversationListFragment.ConversationSelectedListener implements ConversationListFragment.ConversationSelectedListener
{ {
private final DynamicTheme dynamicTheme = new DynamicTheme();
private ConversationListFragment fragment; private ConversationListFragment fragment;
private MasterSecret masterSecret; private MasterSecret masterSecret;
@Override @Override
public void onCreate(Bundle icicle) { public void onCreate(Bundle icicle) {
dynamicTheme.onCreate(this);
super.onCreate(icicle); super.onCreate(icicle);
setContentView(R.layout.conversation_list_activity); setContentView(R.layout.conversation_list_activity);
getSupportActionBar().setTitle("TextSecure"); getSupportActionBar().setTitle("TextSecure");
@ -41,6 +45,12 @@ public class ConversationListActivity extends PassphraseRequiredSherlockFragment
initializeContactUpdatesReceiver(); initializeContactUpdatesReceiver();
} }
@Override
public void onResume() {
super.onResume();
dynamicTheme.onResume(this);
}
@Override @Override
public void onDestroy() { public void onDestroy() {
Log.w("ConversationListActivity", "onDestroy..."); Log.w("ConversationListActivity", "onDestroy...");

View File

@ -18,6 +18,7 @@ package org.thoughtcrime.securesms;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.res.TypedArray;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.Typeface; import android.graphics.Typeface;
import android.net.Uri; import android.net.Uri;
@ -148,13 +149,21 @@ public class ConversationListItem extends RelativeLayout
} }
private void setBackground(boolean read, boolean batch) { private void setBackground(boolean read, boolean batch) {
int[] attributes = new int[]{R.attr.conversation_list_item_background_selected,
R.attr.conversation_list_item_background_read,
R.attr.conversation_list_item_background_unread};
TypedArray drawables = context.obtainStyledAttributes(attributes);
if (batch && selectedThreads.contains(threadId)) { if (batch && selectedThreads.contains(threadId)) {
setBackgroundResource(R.drawable.list_selected_holo_light); setBackgroundDrawable(drawables.getDrawable(0));
} else if (read) { } else if (read) {
setBackgroundResource(R.drawable.conversation_list_item_background_read); setBackgroundDrawable(drawables.getDrawable(1));
} else { } else {
setBackgroundResource(R.drawable.conversation_list_item_background_unread); setBackgroundDrawable(drawables.getDrawable(2));
} }
drawables.recycle();
} }
private boolean isBadgeEnabled() { private boolean isBadgeEnabled() {
@ -162,12 +171,15 @@ public class ConversationListItem extends RelativeLayout
} }
private CharSequence formatFrom(Recipients from, long count, boolean read) { private CharSequence formatFrom(Recipients from, long count, boolean read) {
int attributes[] = new int[] {R.attr.conversation_list_item_count_color};
TypedArray colors = context.obtainStyledAttributes(attributes);
String fromString = from.toShortString(); String fromString = from.toShortString();
SpannableStringBuilder builder = new SpannableStringBuilder(fromString); SpannableStringBuilder builder = new SpannableStringBuilder(fromString);
if (count > 0) { if (count > 0) {
builder.append(" " + count); builder.append(" " + count);
builder.setSpan(new ForegroundColorSpan(Color.parseColor("#66333333")), builder.setSpan(new ForegroundColorSpan(colors.getColor(0,0)),
fromString.length(), builder.length(), fromString.length(), builder.length(),
Spannable.SPAN_INCLUSIVE_EXCLUSIVE); Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
} }
@ -177,6 +189,7 @@ public class ConversationListItem extends RelativeLayout
Spannable.SPAN_INCLUSIVE_EXCLUSIVE); Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
} }
colors.recycle();
return builder; return builder;
} }

View File

@ -5,6 +5,7 @@ import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import com.actionbarsherlock.app.SherlockFragmentActivity; import com.actionbarsherlock.app.SherlockFragmentActivity;
import org.thoughtcrime.securesms.util.DynamicTheme;
public class CountrySelectionActivity extends SherlockFragmentActivity public class CountrySelectionActivity extends SherlockFragmentActivity
implements CountrySelectionFragment.CountrySelectedListener implements CountrySelectionFragment.CountrySelectedListener

View File

@ -17,11 +17,13 @@
package org.thoughtcrime.securesms; package org.thoughtcrime.securesms;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle;
import android.widget.Toast; import android.widget.Toast;
import org.thoughtcrime.securesms.crypto.SerializableKey; import org.thoughtcrime.securesms.crypto.SerializableKey;
import org.thoughtcrime.securesms.util.Base64; import org.thoughtcrime.securesms.util.Base64;
import org.thoughtcrime.securesms.util.Dialogs; import org.thoughtcrime.securesms.util.Dialogs;
import org.thoughtcrime.securesms.util.DynamicTheme;
import com.actionbarsherlock.view.Menu; import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuInflater; import com.actionbarsherlock.view.MenuInflater;
@ -36,6 +38,20 @@ import com.google.zxing.integration.android.IntentResult;
*/ */
public abstract class KeyScanningActivity extends PassphraseRequiredSherlockActivity { public abstract class KeyScanningActivity extends PassphraseRequiredSherlockActivity {
private final DynamicTheme dynamicTheme = new DynamicTheme();
@Override
protected void onCreate(Bundle bundle) {
dynamicTheme.onCreate(this);
super.onCreate(bundle);
}
@Override
public void onResume() {
super.onResume();
dynamicTheme.onResume(this);
}
@Override @Override
public boolean onPrepareOptionsMenu(Menu menu) { public boolean onPrepareOptionsMenu(Menu menu) {
super.onPrepareOptionsMenu(menu); super.onPrepareOptionsMenu(menu);

View File

@ -20,14 +20,26 @@ import android.os.Bundle;
import com.actionbarsherlock.app.SherlockFragmentActivity; import com.actionbarsherlock.app.SherlockFragmentActivity;
import com.actionbarsherlock.view.MenuItem; import com.actionbarsherlock.view.MenuItem;
import org.thoughtcrime.securesms.util.DynamicTheme;
public class ReviewIdentitiesActivity extends SherlockFragmentActivity { public class ReviewIdentitiesActivity extends SherlockFragmentActivity {
private final DynamicTheme dynamicTheme = new DynamicTheme();
@Override
public void onCreate(Bundle bundle) { public void onCreate(Bundle bundle) {
dynamicTheme.onCreate(this);
super.onCreate(bundle); super.onCreate(bundle);
setContentView(R.layout.review_identities); setContentView(R.layout.review_identities);
getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
} }
@Override
public void onResume() {
super.onResume();
dynamicTheme.onResume(this);
}
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) { switch (item.getItemId()) {

View File

@ -2,6 +2,7 @@ package org.thoughtcrime.securesms.components;
import android.content.Context; import android.content.Context;
import android.content.res.Resources; import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.util.AttributeSet; import android.util.AttributeSet;
@ -45,19 +46,24 @@ public class ImageDivet extends ImageView {
} }
private void setDrawable() { private void setDrawable() {
Resources r = getContext().getResources(); int attributes[] = new int[] {R.attr.conversation_avatar_divet_left,
R.attr.conversation_avatar_divet_right};
TypedArray drawables = getContext().obtainStyledAttributes(attributes);
switch (position) { switch (position) {
case 0: case 0:
drawable = r.getDrawable(R.drawable.divet_right); drawable = drawables.getDrawable(1);
break; break;
case 1: case 1:
drawable = r.getDrawable(R.drawable.divet_left); drawable = drawables.getDrawable(0);
break; break;
} }
drawableIntrinsicWidth = drawable.getIntrinsicWidth(); drawableIntrinsicWidth = drawable.getIntrinsicWidth();
drawableIntrinsicHeight = drawable.getIntrinsicHeight(); drawableIntrinsicHeight = drawable.getIntrinsicHeight();
drawables.recycle();
} }
@Override @Override

View File

@ -103,6 +103,9 @@ public class ImageSlide extends Slide {
imageView.setImageDrawable(temporaryDrawable); imageView.setImageDrawable(temporaryDrawable);
if (maxWidth == 0 || maxHeight == 0)
return;
MmsDatabase.slideResolver.execute(new Runnable() { MmsDatabase.slideResolver.execute(new Runnable() {
@Override @Override
public void run() { public void run() {

View File

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

View File

@ -184,7 +184,6 @@ public class Util {
return new String(bout.toByteArray()); return new String(bout.toByteArray());
} }
// public static Bitmap loadScaledBitmap(InputStream src, int targetWidth, int targetHeight) { // public static Bitmap loadScaledBitmap(InputStream src, int targetWidth, int targetHeight) {
// return BitmapFactory.decodeStream(src); // return BitmapFactory.decodeStream(src);
//// BitmapFactory.Options options = new BitmapFactory.Options(); //// BitmapFactory.Options options = new BitmapFactory.Options();