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