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.
fork-5.53.8
Moxie Marlinspike 2012-09-09 09:18:17 -07:00
rodzic 312942439d
commit 7a7dba66ad
15 zmienionych plików z 107 dodań i 4 usunięć

Plik binarny nie jest wyświetlany.

Przed

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

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 1.0 KiB

Plik binarny nie jest wyświetlany.

Po

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

Plik binarny nie jest wyświetlany.

Po

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

Plik binarny nie jest wyświetlany.

Przed

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

Po

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

Plik binarny nie jest wyświetlany.

Po

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

Plik binarny nie jest wyświetlany.

Po

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

Plik binarny nie jest wyświetlany.

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 1.4 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 1.4 KiB

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 1.4 KiB

Plik binarny nie jest wyświetlany.

Po

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

@ -11,4 +11,15 @@
<item name="android:backgroundDimEnabled">false</item>
<item name="android:background">@android:color/transparent</item>
</style>
</resources>
<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>

Wyświetl plik

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