mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 18:59:06 +01:00
update notifications on system language change
This commit is contained in:
@@ -579,6 +579,7 @@ class AndroidNotificationManagerImpl implements AndroidNotificationManager,
|
||||
|
||||
@UiThread
|
||||
private void updateContactAddedNotification() {
|
||||
if (contactAddedTotal == 0) return;
|
||||
BriarNotificationBuilder b =
|
||||
new BriarNotificationBuilder(appContext, CONTACT_CHANNEL_ID);
|
||||
b.setSmallIcon(R.drawable.notification_contact_added);
|
||||
@@ -713,4 +714,16 @@ class AndroidNotificationManagerImpl implements AndroidNotificationManager,
|
||||
public void unblockAllBlogPostNotifications() {
|
||||
androidExecutor.runOnUiThread((Runnable) () -> blockBlogs = false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restartNotifications(boolean locked, boolean mayAlertAgain) {
|
||||
androidExecutor.runOnUiThread(() -> {
|
||||
updateForegroundNotification(locked);
|
||||
updateContactNotification(mayAlertAgain);
|
||||
updateBlogPostNotification(mayAlertAgain);
|
||||
updateForumPostNotification(mayAlertAgain);
|
||||
updateGroupMessageNotification(mayAlertAgain);
|
||||
updateContactAddedNotification();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,8 +105,9 @@ public class BriarApplicationImpl extends Application
|
||||
@Override
|
||||
public void onConfigurationChanged(@NonNull Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
Localizer.getInstance()
|
||||
.applicationConfigurationChanged(this, newConfig);
|
||||
Localizer.getInstance().applicationConfigurationChanged(this, newConfig,
|
||||
applicationComponent.androidNotificationManager(),
|
||||
applicationComponent.lockManager().isLocked());
|
||||
}
|
||||
|
||||
private void setTheme(Context ctx, SharedPreferences prefs) {
|
||||
|
||||
@@ -7,6 +7,7 @@ import android.content.res.Resources;
|
||||
import android.support.v4.text.TextUtilsCompat;
|
||||
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.briar.api.android.AndroidNotificationManager;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
@@ -124,13 +125,23 @@ public class Localizer {
|
||||
Resources.getSystem().getDisplayMetrics());
|
||||
}
|
||||
|
||||
public void applicationConfigurationChanged(Context appContext,
|
||||
Configuration newConfig) {
|
||||
private Locale getLocaleFromConfig(Configuration config) {
|
||||
if (SDK_INT >= 24) {
|
||||
if (newConfig.getLocales().get(0) == locale) return;
|
||||
return config.getLocales().get(0);
|
||||
} else {
|
||||
if (newConfig.locale == locale) return;
|
||||
return config.locale;
|
||||
}
|
||||
}
|
||||
|
||||
public void applicationConfigurationChanged(Context appContext,
|
||||
Configuration newConfig,
|
||||
AndroidNotificationManager androidNotificationManager,
|
||||
boolean locked) {
|
||||
Locale newLocale = getLocaleFromConfig(newConfig);
|
||||
if (locale == null && newLocale != systemLocale) {
|
||||
androidNotificationManager.restartNotifications(locked, false);
|
||||
}
|
||||
if (newLocale == locale) return;
|
||||
setLocaleAndSystemConfiguration(locale);
|
||||
if (SDK_INT < 17) setLocaleLegacy(appContext);
|
||||
}
|
||||
@@ -145,7 +156,8 @@ public class Localizer {
|
||||
public static boolean isLocaleSupported(Locale locale) {
|
||||
if (SDK_INT >= 21) return true;
|
||||
if (locale.getLanguage().equals("ast")) return false;
|
||||
if (SDK_INT == 15 && locale.getLanguage().equals("hi")) return false;
|
||||
if (SDK_INT == 15 && locale.getLanguage().equals("hi"))
|
||||
return false;
|
||||
if (SDK_INT >= 17) return true;
|
||||
return isLeftToRight(locale);
|
||||
}
|
||||
@@ -155,7 +167,8 @@ public class Localizer {
|
||||
// TextUtilsCompat returns the wrong direction for Hebrew on some phones
|
||||
String language = locale.getLanguage();
|
||||
if (language.equals("iw") || language.equals("he")) return false;
|
||||
int direction = TextUtilsCompat.getLayoutDirectionFromLocale(locale);
|
||||
int direction =
|
||||
TextUtilsCompat.getLayoutDirectionFromLocale(locale);
|
||||
return direction == LAYOUT_DIRECTION_LTR;
|
||||
}
|
||||
|
||||
|
||||
@@ -93,4 +93,7 @@ public interface AndroidNotificationManager {
|
||||
void blockAllBlogPostNotifications();
|
||||
|
||||
void unblockAllBlogPostNotifications();
|
||||
|
||||
void restartNotifications(boolean locked, boolean mayAlertAgain);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user