mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 03:09:04 +01:00
Also remind to sign-in again after app was upgraded
This commit is contained in:
@@ -26,10 +26,11 @@
|
||||
android:theme="@style/BriarTheme">
|
||||
|
||||
<receiver
|
||||
android:name="org.briarproject.briar.android.BootReceiver"
|
||||
android:name="org.briarproject.briar.android.login.SignInReminderReceiver"
|
||||
android:exported="false">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.BOOT_COMPLETED"/>
|
||||
<action android:name="android.intent.action.MY_PACKAGE_REPLACED"/>
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.briarproject.bramble.api.system.AndroidExecutor;
|
||||
import org.briarproject.bramble.api.system.Clock;
|
||||
import org.briarproject.briar.BriarCoreEagerSingletons;
|
||||
import org.briarproject.briar.BriarCoreModule;
|
||||
import org.briarproject.briar.android.login.SignInReminderReceiver;
|
||||
import org.briarproject.briar.android.reporting.BriarReportSender;
|
||||
import org.briarproject.briar.api.android.AndroidNotificationManager;
|
||||
import org.briarproject.briar.api.android.DozeWatchdog;
|
||||
@@ -150,7 +151,7 @@ public interface AndroidComponent
|
||||
@IoExecutor
|
||||
Executor ioExecutor();
|
||||
|
||||
void inject(BootReceiver briarService);
|
||||
void inject(SignInReminderReceiver briarService);
|
||||
|
||||
void inject(BriarService briarService);
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ public class BriarApplicationImpl extends Application
|
||||
private final CachingLogHandler logHandler = new CachingLogHandler();
|
||||
|
||||
private AndroidComponent applicationComponent;
|
||||
private SharedPreferences prefs;
|
||||
private volatile SharedPreferences prefs;
|
||||
|
||||
@Override
|
||||
protected void attachBaseContext(Context base) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.briarproject.briar.android;
|
||||
package org.briarproject.briar.android.login;
|
||||
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.NotificationManager;
|
||||
@@ -12,6 +12,8 @@ import android.support.v4.content.ContextCompat;
|
||||
|
||||
import org.briarproject.bramble.api.db.DatabaseConfig;
|
||||
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;
|
||||
|
||||
@@ -20,6 +22,7 @@ import javax.inject.Inject;
|
||||
import static android.app.NotificationManager.IMPORTANCE_LOW;
|
||||
import static android.content.Context.NOTIFICATION_SERVICE;
|
||||
import static android.content.Intent.ACTION_BOOT_COMPLETED;
|
||||
import static android.content.Intent.ACTION_MY_PACKAGE_REPLACED;
|
||||
import static android.content.Intent.FLAG_ACTIVITY_CLEAR_TOP;
|
||||
import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
|
||||
import static android.os.Build.VERSION.SDK_INT;
|
||||
@@ -31,7 +34,7 @@ import static org.briarproject.briar.android.settings.SettingsFragment.NOTIFY_SI
|
||||
import static org.briarproject.briar.api.android.AndroidNotificationManager.REMINDER_CHANNEL_ID;
|
||||
import static org.briarproject.briar.api.android.AndroidNotificationManager.REMINDER_NOTIFICATION_ID;
|
||||
|
||||
public class BootReceiver extends BroadcastReceiver {
|
||||
public class SignInReminderReceiver extends BroadcastReceiver {
|
||||
|
||||
@Inject
|
||||
DatabaseConfig databaseConfig;
|
||||
@@ -45,7 +48,9 @@ public class BootReceiver extends BroadcastReceiver {
|
||||
applicationComponent.inject(this);
|
||||
|
||||
String action = intent.getAction();
|
||||
if (action != null && action.equals(ACTION_BOOT_COMPLETED)) {
|
||||
if (action == null) return;
|
||||
if (action.equals(ACTION_BOOT_COMPLETED) ||
|
||||
action.equals(ACTION_MY_PACKAGE_REPLACED)) {
|
||||
if (databaseConfig.databaseExists()) {
|
||||
SharedPreferences prefs = app.getDefaultSharedPreferences();
|
||||
if (prefs.getBoolean(NOTIFY_SIGN_IN, true)) {
|
||||
@@ -375,7 +375,7 @@
|
||||
<!-- Settings Notifications -->
|
||||
<string name="notification_settings_title">Notifications</string>
|
||||
<string name="notify_sign_in_title">Remind me to sign in</string>
|
||||
<string name="notify_sign_in_summary">Shows a reminder when the phone starts</string>
|
||||
<string name="notify_sign_in_summary">Show a reminder when the phone starts or the app got updated</string>
|
||||
<string name="notify_private_messages_setting_title">Private messages</string>
|
||||
<string name="notify_private_messages_setting_summary">Show alerts for private messages</string>
|
||||
<string name="notify_private_messages_setting_summary_26">Configure alerts for private messages</string>
|
||||
|
||||
Reference in New Issue
Block a user