Skip to content
Snippets Groups Projects
Verified Commit ba4a4aea authored by Torsten Grote's avatar Torsten Grote
Browse files

Only show a Dismiss button attached to the sign-in reminder

Also change the logo to a logout icon
parent 391e869d
No related branches found
No related tags found
No related merge requests found
......@@ -15,7 +15,6 @@ import org.briarproject.briar.R;
import org.briarproject.briar.android.AndroidComponent;
import org.briarproject.briar.android.BriarApplication;
import org.briarproject.briar.android.navdrawer.NavDrawerActivity;
import org.briarproject.briar.android.settings.SettingsActivity;
import javax.inject.Inject;
......@@ -29,13 +28,14 @@ import static android.os.Build.VERSION.SDK_INT;
import static android.support.v4.app.NotificationCompat.PRIORITY_LOW;
import static android.support.v4.app.NotificationCompat.VISIBILITY_SECRET;
import static org.briarproject.briar.android.TestingConstants.FEATURE_FLAG_SIGN_IN_REMINDER;
import static org.briarproject.briar.android.settings.SettingsActivity.NO_NOTIFY_SIGN_IN;
import static org.briarproject.briar.android.settings.SettingsFragment.NOTIFY_SIGN_IN;
import static org.briarproject.briar.api.android.AndroidNotificationManager.REMINDER_CHANNEL_ID;
import static org.briarproject.briar.api.android.AndroidNotificationManager.REMINDER_NOTIFICATION_ID;
public class SignInReminderReceiver extends BroadcastReceiver {
public static final String DISMISS_REMINDER = "dismissReminder";
@Inject
DatabaseConfig databaseConfig;
......@@ -57,6 +57,8 @@ public class SignInReminderReceiver extends BroadcastReceiver {
showSignInNotification(ctx);
}
}
} else if (action.equals(DISMISS_REMINDER)) {
dismissReminder(ctx);
}
}
......@@ -76,7 +78,7 @@ public class SignInReminderReceiver extends BroadcastReceiver {
NotificationCompat.Builder b =
new NotificationCompat.Builder(ctx, REMINDER_CHANNEL_ID);
b.setSmallIcon(R.drawable.notification_reminder);
b.setSmallIcon(R.drawable.ic_signout);
b.setColor(ContextCompat.getColor(ctx, R.color.briar_primary));
b.setContentTitle(ctx.getText(R.string.reminder_notification_title));
b.setContentText(ctx.getText(R.string.reminder_notification_text));
......@@ -84,12 +86,12 @@ public class SignInReminderReceiver extends BroadcastReceiver {
b.setWhen(0); // Don't show the time
b.setPriority(PRIORITY_LOW);
// Add a 'Do not show sign-in reminder' action
// Add a 'Dismiss' action
String actionTitle =
ctx.getString(R.string.reminder_notification_do_not_show_again);
Intent i1 = new Intent(ctx, SettingsActivity.class);
i1.setAction(NO_NOTIFY_SIGN_IN);
PendingIntent actionIntent = PendingIntent.getActivity(ctx, 0, i1, 0);
ctx.getString(R.string.reminder_notification_dismiss);
Intent i1 = new Intent(ctx, SignInReminderReceiver.class);
i1.setAction(DISMISS_REMINDER);
PendingIntent actionIntent = PendingIntent.getBroadcast(ctx, 0, i1, 0);
b.addAction(0, actionTitle, actionIntent);
Intent i = new Intent(ctx, NavDrawerActivity.class);
......@@ -99,4 +101,11 @@ public class SignInReminderReceiver extends BroadcastReceiver {
nm.notify(REMINDER_NOTIFICATION_ID, b.build());
}
private void dismissReminder(Context ctx) {
NotificationManager nm = (NotificationManager)
ctx.getSystemService(NOTIFICATION_SERVICE);
if (nm == null) return;
nm.cancel(REMINDER_NOTIFICATION_ID);
}
}
package org.briarproject.briar.android.settings;
import android.app.NotificationManager;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.view.MenuItem;
import org.briarproject.briar.R;
import org.briarproject.briar.android.BriarApplication;
import org.briarproject.briar.android.activity.ActivityComponent;
import org.briarproject.briar.android.activity.BriarActivity;
import static org.briarproject.briar.android.settings.SettingsFragment.NOTIFY_SIGN_IN;
import static org.briarproject.briar.api.android.AndroidNotificationManager.REMINDER_NOTIFICATION_ID;
public class SettingsActivity extends BriarActivity {
public static final String NO_NOTIFY_SIGN_IN = "noNotifySignIn";
@Override
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
// Maybe turn off sign-in reminder
Intent intent = getIntent();
if (intent != null && NO_NOTIFY_SIGN_IN.equals(intent.getAction())) {
// Turn it off
BriarApplication app = (BriarApplication) getApplication();
SharedPreferences prefs = app.getDefaultSharedPreferences();
prefs.edit().putBoolean(NOTIFY_SIGN_IN, false).apply();
// Remove sign-in reminder notification
NotificationManager nm = (NotificationManager)
getSystemService(NOTIFICATION_SERVICE);
if (nm != null) nm.cancel(REMINDER_NOTIFICATION_ID);
// Finish this activity again
finish();
}
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setHomeButtonEnabled(true);
......
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24"
android:viewportWidth="24">
<path
android:fillColor="#FFFFFFFF"
android:pathData="M17,17.25V14H10V10H17V6.75L22.25,12L17,17.25M13,2A2,2 0 0,1 15,4V8H13V4H4V20H13V16H15V20A2,2 0 0,1 13,22H4A2,2 0 0,1 2,20V4A2,2 0 0,1 4,2H13Z"/>
</vector>
\ No newline at end of file
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M13,8.2l-1,-1 -4,4 -4,-4 -1,1 4,4 -4,4 1,1 4,-4 4,4 1,-1 -4,-4 4,-4zM19,1H9c-1.1,0 -2,0.9 -2,2v3h2V4h10v16H9v-2H7v3c0,1.1 0.9,2 2,2h10c1.1,0 2,-0.9 2,-2V3c0,-1.1 -0.9,-2 -2,-2z"/>
</vector>
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24"
android:viewportWidth="24">
<path
android:fillColor="#ffffff"
android:pathData="M 12 0 A 12 12 0 0 0 4.875 2.3613281 L 6.9316406 4.4160156 C 7.0875805 3.8805807 7.5639651 3.4765625 8.1464844 3.4765625 L 8.7480469 3.4765625 C 9.4535014 3.4765625 10.035156 4.0582174 10.035156 4.7636719 L 10.035156 6.4003906 L 8.9140625 6.4003906 L 9.4238281 6.9101562 L 13.404297 6.9101562 L 13.404297 10.085938 L 12.601562 10.085938 L 13.914062 11.398438 L 13.914062 4.7636719 C 13.914062 4.0582174 14.495717 3.4765625 15.201172 3.4765625 L 15.802734 3.4765625 C 16.515461 3.4765625 17.089844 4.0582174 17.089844 4.7636719 L 17.089844 13.455078 L 15.96875 13.455078 L 16.478516 13.964844 L 19.236328 13.964844 C 19.941782 13.964844 20.516165 14.546498 20.523438 15.251953 L 20.523438 15.853516 C 20.523438 16.436036 20.119418 16.91242 19.583984 17.068359 L 21.638672 19.125 A 12 12 0 0 0 24 12 A 12 12 0 0 0 12 0 z M 1.2617188 1.3632812 L 0 2.6269531 L 2.3125 4.9472656 A 12 12 0 0 0 0 12 A 12 12 0 0 0 12 24 A 12 12 0 0 0 19.027344 21.707031 L 21.314453 24 L 22.576172 22.734375 L 2.7519531 2.8554688 L 1.9863281 2.0898438 L 1.2617188 1.3632812 z M 17.599609 6.9101562 L 19.236328 6.9101562 C 19.941782 6.9101562 20.516165 7.4918111 20.523438 8.1972656 L 20.523438 8.7988281 C 20.523438 9.511555 19.941782 10.085937 19.236328 10.085938 L 17.599609 10.085938 L 17.599609 6.9101562 z M 4.359375 6.9980469 L 7.4394531 10.085938 L 4.7128906 10.085938 C 4.0001632 10.085938 3.4257813 9.504282 3.4257812 8.7988281 L 3.4257812 8.1972656 C 3.4257812 7.6133228 3.8294199 7.1540656 4.359375 6.9980469 z M 6.859375 10.595703 L 7.9472656 10.595703 L 10.035156 12.689453 L 10.035156 19.287109 C 10.035156 19.992562 9.4535014 20.574219 8.7480469 20.574219 L 8.1464844 20.574219 C 7.4337573 20.574219 6.859375 19.992563 6.859375 19.287109 L 6.859375 10.595703 z M 4.7128906 13.964844 L 6.3496094 13.964844 L 6.3496094 17.140625 L 4.7128906 17.140625 C 4.0001632 17.140625 3.4257813 16.558971 3.4257812 15.853516 L 3.4257812 15.251953 C 3.4257812 14.539226 4.007436 13.964844 4.7128906 13.964844 z M 10.544922 13.964844 L 11.306641 13.964844 L 14.474609 17.140625 L 10.544922 17.140625 L 10.544922 13.964844 z M 13.914062 17.650391 L 14.982422 17.650391 L 16.992188 19.666016 C 16.827053 20.182975 16.371277 20.574219 15.802734 20.574219 L 15.201172 20.574219 C 14.495717 20.574219 13.914063 19.992563 13.914062 19.287109 L 13.914062 17.650391 z"/>
</vector>
\ No newline at end of file
......@@ -28,7 +28,7 @@
android:title="@string/settings_button"/>
<item
android:id="@+id/nav_btn_signout"
android:icon="@drawable/ic_signout_black_24dp"
android:icon="@drawable/ic_signout"
android:title="@string/sign_out_button"/>
</group>
......
......@@ -69,9 +69,9 @@
<!-- Notifications -->
<string name="reminder_notification_title">Signed out of Briar</string>
<string name="reminder_notification_text">Tap to sign back in or swipe to dismiss.</string>
<string name="reminder_notification_text">Tap to sign back in.</string>
<string name="reminder_notification_channel_title">Briar Sign-in Reminder</string>
<string name="reminder_notification_do_not_show_again">Don\'t show again</string>
<string name="reminder_notification_dismiss">Dismiss</string>
<string name="ongoing_notification_title">Signed into Briar</string>
<string name="ongoing_notification_text">Touch to open Briar.</string>
<plurals name="private_message_notification_text">
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment