Skip to content
Snippets Groups Projects
Commit 293a259e authored by Julian Dehm's avatar Julian Dehm Committed by jd
Browse files

update notifications on system language change

parent d164e174
No related branches found
No related tags found
No related merge requests found
Pipeline #3789 passed
......@@ -572,6 +572,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);
......@@ -686,4 +687,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();
});
}
}
......@@ -145,8 +145,9 @@ public class BriarApplicationImpl extends Application
@Override
public void onConfigurationChanged(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;
}
......
......@@ -85,4 +85,7 @@ public interface AndroidNotificationManager {
void blockAllBlogPostNotifications();
void unblockAllBlogPostNotifications();
void restartNotifications(boolean locked, boolean mayAlertAgain);
}
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