Update passphrase caching notification strategy.
On platforms (API >= 11) that support receiving click events within a notification, we change the notification format so that users can "lock" TextSecure with a click. For all platforms, we change the notification icon in the status bar from a "lock" to an "unlock," to better reflect the situation. This is all part of the master plan for eliminating the passphrase timeout option.
Before Width: | Height: | Size: 767 B After Width: | Height: | Size: 1.0 KiB |
BIN
res/drawable-hdpi/icon_lock.png
Normal file
After Width: | Height: | Size: 767 B |
BIN
res/drawable-hdpi/notify_panel_notification_icon_bg.png
Normal file
After Width: | Height: | Size: 107 B |
Before Width: | Height: | Size: 620 B After Width: | Height: | Size: 633 B |
BIN
res/drawable-mdpi/icon_lock.png
Normal file
After Width: | Height: | Size: 620 B |
BIN
res/drawable-mdpi/notify_panel_notification_icon_bg.png
Normal file
After Width: | Height: | Size: 98 B |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
BIN
res/drawable-xhdpi/icon_lock.png
Normal file
After Width: | Height: | Size: 1.4 KiB |
BIN
res/drawable-xhdpi/notify_panel_notification_icon_bg.png
Normal file
After Width: | Height: | Size: 138 B |
21
res/drawable/notify_panel_notification_icon_bg_tile.xml
Normal file
@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2011 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.
|
||||
-->
|
||||
|
||||
<bitmap
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:tileMode="repeat"
|
||||
android:src="@drawable/notify_panel_notification_icon_bg"
|
||||
/>
|
44
res/layout/key_caching_notification.xml
Normal file
@ -0,0 +1,44 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent">
|
||||
|
||||
<LinearLayout android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:orientation="vertical"
|
||||
android:layout_marginLeft="10dip">
|
||||
<TextView android:id="@+id/title"
|
||||
android:textAppearance="@style/NotificationTitle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:singleLine="true"
|
||||
android:ellipsize="marquee"
|
||||
android:fadingEdge="horizontal"
|
||||
android:text="@string/passphrase_cached"
|
||||
/>
|
||||
|
||||
<TextView android:id="@+id/text2"
|
||||
android:textAppearance="@style/NotificationText"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="-2dp"
|
||||
android:layout_marginBottom="-2dp"
|
||||
android:singleLine="true"
|
||||
android:fadingEdge="horizontal"
|
||||
android:ellipsize="marquee"
|
||||
android:text="@string/textsecure_passphrase_cached"
|
||||
/>
|
||||
</LinearLayout>
|
||||
|
||||
<ImageView android:id="@+id/lock_cache_icon"
|
||||
android:src="@drawable/icon_lock"
|
||||
android:layout_width="64dp"
|
||||
android:layout_height="64dp"
|
||||
android:background="@drawable/notify_panel_notification_icon_bg_tile"
|
||||
android:scaleType="center"
|
||||
android:layout_alignParentRight="true"
|
||||
/>
|
||||
|
||||
</RelativeLayout>
|
5
res/values-v9/styles.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<style name="NotificationText" parent="android:TextAppearance.StatusBar.EventContent" />
|
||||
<style name="NotificationTitle" parent="android:TextAppearance.StatusBar.EventContent.Title" />
|
||||
</resources>
|
@ -196,7 +196,7 @@
|
||||
|
||||
<!-- KeyCachingService -->
|
||||
<string name="textsecure_passphrase_cached">TextSecure Passphrase Cached</string>
|
||||
<string name="textsecure_cached">TextSecure Cached</string>
|
||||
<string name="passphrase_cached">Passphrase Cached</string>
|
||||
|
||||
<!-- MessageNotifier -->
|
||||
<string name="_d_new_messages">(%d) New messages</string>
|
||||
|
@ -11,4 +11,15 @@
|
||||
<item name="android:backgroundDimEnabled">false</item>
|
||||
<item name="android:background">@android:color/transparent</item>
|
||||
</style>
|
||||
|
||||
|
||||
<style name="NotificationText">
|
||||
<item name="android:textColor">?android:attr/textColorPrimary</item>
|
||||
</style>
|
||||
|
||||
<style name="NotificationTitle">
|
||||
<item name="android:textColor">?android:attr/textColorPrimary</item>
|
||||
<item name="android:textStyle">bold</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
@ -23,10 +23,12 @@ import android.app.Service;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Binder;
|
||||
import android.os.Build;
|
||||
import android.os.IBinder;
|
||||
import android.os.SystemClock;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
import android.widget.RemoteViews;
|
||||
|
||||
import org.thoughtcrime.securesms.ApplicationPreferencesActivity;
|
||||
import org.thoughtcrime.securesms.ConversationListActivity;
|
||||
@ -141,19 +143,39 @@ public class KeyCachingService extends Service {
|
||||
}
|
||||
}
|
||||
|
||||
private void foregroundService() {
|
||||
private void foregroundServiceModern() {
|
||||
Notification notification = new Notification(R.drawable.icon_cached, null, System.currentTimeMillis());
|
||||
RemoteViews remoteViews = new RemoteViews(getPackageName(), R.layout.key_caching_notification);
|
||||
|
||||
Intent intent = new Intent(this, KeyCachingService.class);
|
||||
intent.setAction(PASSPHRASE_EXPIRED_EVENT);
|
||||
PendingIntent pendingIntent = PendingIntent.getService(getApplicationContext(), 0, intent, 0);
|
||||
remoteViews.setOnClickPendingIntent(R.id.lock_cache_icon, pendingIntent);
|
||||
|
||||
notification.contentView = remoteViews;
|
||||
|
||||
stopForeground(true);
|
||||
startForeground(SERVICE_RUNNING_ID, notification);
|
||||
}
|
||||
|
||||
private void foregroundServiceLegacy() {
|
||||
Notification notification = new Notification(R.drawable.icon_cached,
|
||||
getString(R.string.textsecure_passphrase_cached),
|
||||
System.currentTimeMillis());
|
||||
Intent intent = new Intent(this, ConversationListActivity.class);
|
||||
PendingIntent launchIntent = PendingIntent.getActivity(getApplicationContext(), 0, intent, 0);
|
||||
notification.setLatestEventInfo(getApplicationContext(), getString(R.string.textsecure_cached),
|
||||
notification.setLatestEventInfo(getApplicationContext(), getString(R.string.passphrase_cached),
|
||||
getString(R.string.textsecure_passphrase_cached), launchIntent);
|
||||
|
||||
stopForeground(true);
|
||||
startForeground(SERVICE_RUNNING_ID, notification);
|
||||
}
|
||||
|
||||
private void foregroundService() {
|
||||
if (Build.VERSION.SDK_INT >= 11) foregroundServiceModern();
|
||||
else foregroundServiceLegacy();
|
||||
}
|
||||
|
||||
private void broadcastNewSecret() {
|
||||
Log.w("service", "Broadcasting new secret...");
|
||||
Intent intent = new Intent(NEW_KEY_EVENT);
|
||||
|