mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 02:39:05 +01:00
Compare commits
12 Commits
lock-down-
...
fix_nonloc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e24728055c | ||
|
|
b2dc99bf26 | ||
|
|
50d144c917 | ||
|
|
da7f57e0af | ||
|
|
2374f8b4c9 | ||
|
|
5b77f28ce0 | ||
|
|
c247e3aa4e | ||
|
|
8e0b71c76f | ||
|
|
88f57893e8 | ||
|
|
b111abb484 | ||
|
|
4415598d3d | ||
|
|
40e14d3e94 |
@@ -38,8 +38,8 @@ configurations {
|
||||
|
||||
dependencies {
|
||||
implementation project(path: ':bramble-core', configuration: 'default')
|
||||
tor 'org.briarproject:tor-android:0.3.5.13@zip'
|
||||
tor 'org.briarproject:obfs4proxy-android:0.0.12-dev-40245c4a@zip'
|
||||
tor 'org.briarproject:tor-android:0.3.5.12@zip'
|
||||
tor 'org.briarproject:obfs4proxy-android:0.0.11-2@zip'
|
||||
|
||||
annotationProcessor 'com.google.dagger:dagger-compiler:2.24'
|
||||
|
||||
|
||||
@@ -75,8 +75,8 @@ dependencyVerification {
|
||||
'org.beanshell:bsh:1.3.0:bsh-1.3.0.jar:9b04edc75d19db54f1b4e8b5355e9364384c6cf71eb0a1b9724c159d779879f8',
|
||||
'org.bouncycastle:bcpkix-jdk15on:1.56:bcpkix-jdk15on-1.56.jar:7043dee4e9e7175e93e0b36f45b1ec1ecb893c5f755667e8b916eb8dd201c6ca',
|
||||
'org.bouncycastle:bcprov-jdk15on:1.56:bcprov-jdk15on-1.56.jar:963e1ee14f808ffb99897d848ddcdb28fa91ddda867eb18d303e82728f878349',
|
||||
'org.briarproject:obfs4proxy-android:0.0.12-dev-40245c4a:obfs4proxy-android-0.0.12-dev-40245c4a.zip:8ab05a8f8391be2cb5ab2b665c281a06d9e3a756bd0f95a40a36ca927866ea82',
|
||||
'org.briarproject:tor-android:0.3.5.13:tor-android-0.3.5.13.zip:e0978db136731dae07774b722970cdae1e462fb5adc82845dd80a7e2d87f356c',
|
||||
'org.briarproject:obfs4proxy-android:0.0.11-2:obfs4proxy-android-0.0.11-2.zip:57e55cbe87aa2aac210fdbb6cd8cdeafe15f825406a08ebf77a8b787aa2c6a8a',
|
||||
'org.briarproject:tor-android:0.3.5.12:tor-android-0.3.5.12.zip:db71fb3290acff79d572af0752570eaf6aad7c4d88c9b9aa0b4d5afe2b9ead9c',
|
||||
'org.checkerframework:checker-compat-qual:2.5.3:checker-compat-qual-2.5.3.jar:d76b9afea61c7c082908023f0cbc1427fab9abd2df915c8b8a3e7a509bccbc6d',
|
||||
'org.checkerframework:checker-qual:2.5.2:checker-qual-2.5.2.jar:64b02691c8b9d4e7700f8ee2e742dce7ea2c6e81e662b7522c9ee3bf568c040a',
|
||||
'org.checkerframework:checker-qual:2.8.1:checker-qual-2.8.1.jar:9103499008bcecd4e948da29b17864abb64304e15706444ae209d17ebe0575df',
|
||||
|
||||
@@ -179,13 +179,6 @@ class LifecycleManagerImpl implements LifecycleManager, MigrationListener {
|
||||
LOG.info("Stopping services");
|
||||
state = STOPPING;
|
||||
eventBus.broadcast(new LifecycleEvent(STOPPING));
|
||||
LOG.info("Sleeping a bit to simulate slowness");
|
||||
try {
|
||||
Thread.sleep(5000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
LOG.info("Done simulating slowness");
|
||||
for (Service s : services) {
|
||||
long start = now();
|
||||
s.stopService();
|
||||
|
||||
@@ -16,8 +16,8 @@ dependencies {
|
||||
implementation fileTree(dir: 'libs', include: '*.jar')
|
||||
implementation 'net.java.dev.jna:jna:4.5.2'
|
||||
implementation 'net.java.dev.jna:jna-platform:4.5.2'
|
||||
tor 'org.briarproject:tor:0.3.5.13@zip'
|
||||
tor 'org.briarproject:obfs4proxy:0.0.12-dev-40245c4a@zip'
|
||||
tor 'org.briarproject:tor:0.3.5.12@zip'
|
||||
tor 'org.briarproject:obfs4proxy:0.0.7@zip'
|
||||
|
||||
annotationProcessor 'com.google.dagger:dagger-compiler:2.24'
|
||||
|
||||
|
||||
@@ -23,8 +23,8 @@ dependencyVerification {
|
||||
'org.apache.ant:ant-launcher:1.9.4:ant-launcher-1.9.4.jar:7bccea20b41801ca17bcbc909a78c835d0f443f12d639c77bd6ae3d05861608d',
|
||||
'org.apache.ant:ant:1.9.4:ant-1.9.4.jar:649ae0730251de07b8913f49286d46bba7b92d47c5f332610aa426c4f02161d8',
|
||||
'org.beanshell:bsh:1.3.0:bsh-1.3.0.jar:9b04edc75d19db54f1b4e8b5355e9364384c6cf71eb0a1b9724c159d779879f8',
|
||||
'org.briarproject:obfs4proxy:0.0.12-dev-40245c4a:obfs4proxy-0.0.12-dev-40245c4a.zip:172029e7058b3a83ac93ac4991a44bf76e16ce8d46f558f5836d57da3cb3a766',
|
||||
'org.briarproject:tor:0.3.5.13:tor-0.3.5.13.zip:1c5f0b821ee2aadb0ea04aa96caab3ca0a08370cce8de81c2dfe04d172f8a2a0',
|
||||
'org.briarproject:obfs4proxy:0.0.7:obfs4proxy-0.0.7.zip:5b2f693262ce43a7e130f7cc7d5d1617925330640a2eb6d71085e95df8ee0642',
|
||||
'org.briarproject:tor:0.3.5.12:tor-0.3.5.12.zip:2f542c4befd216f2226bf7c76e3b8b2d99af6f146a8cb28bf727f42014587006',
|
||||
'org.checkerframework:checker-compat-qual:2.5.3:checker-compat-qual-2.5.3.jar:d76b9afea61c7c082908023f0cbc1427fab9abd2df915c8b8a3e7a509bccbc6d',
|
||||
'org.checkerframework:checker-qual:2.5.2:checker-qual-2.5.2.jar:64b02691c8b9d4e7700f8ee2e742dce7ea2c6e81e662b7522c9ee3bf568c040a',
|
||||
'org.codehaus.mojo:animal-sniffer-annotations:1.17:animal-sniffer-annotations-1.17.jar:92654f493ecfec52082e76354f0ebf87648dc3d5cec2e3c3cdb947c016747a53',
|
||||
|
||||
@@ -117,9 +117,22 @@
|
||||
|
||||
<activity
|
||||
android:name="org.briarproject.briar.android.navdrawer.NavDrawerActivity"
|
||||
android:exported="false"
|
||||
android:launchMode="singleTask"
|
||||
android:theme="@style/BriarTheme.NoActionBar" />
|
||||
android:theme="@style/BriarTheme.NoActionBar">
|
||||
<intent-filter android:label="@string/add_contact_remotely_title_case">
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
|
||||
<data android:scheme="briar" />
|
||||
</intent-filter>
|
||||
<intent-filter android:label="@string/add_contact_remotely_title_case">
|
||||
<action android:name="android.intent.action.SEND" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<data android:mimeType="text/plain" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name="org.briarproject.briar.android.conversation.ConversationActivity"
|
||||
@@ -427,27 +440,8 @@
|
||||
<activity
|
||||
android:name=".android.contact.add.remote.AddContactActivity"
|
||||
android:label="@string/add_contact_remotely_title_case"
|
||||
android:parentActivityName="org.briarproject.briar.android.navdrawer.NavDrawerActivity"
|
||||
android:theme="@style/BriarTheme"
|
||||
android:windowSoftInputMode="adjustResize|stateHidden">
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value="org.briarproject.briar.android.navdrawer.NavDrawerActivity" />
|
||||
|
||||
<intent-filter android:label="@string/add_contact_remotely_title_case">
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
|
||||
<data android:scheme="briar" />
|
||||
</intent-filter>
|
||||
<intent-filter android:label="@string/add_contact_remotely_title_case">
|
||||
<action android:name="android.intent.action.SEND" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<data android:mimeType="text/plain" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
android:windowSoftInputMode="adjustResize|stateHidden" />
|
||||
|
||||
<activity
|
||||
android:name=".android.contact.add.remote.PendingContactListActivity"
|
||||
|
||||
@@ -25,7 +25,7 @@ class BriarAccountManager extends AndroidAccountManager {
|
||||
public void deleteAccount() {
|
||||
synchronized (stateChangeLock) {
|
||||
super.deleteAccount();
|
||||
Localizer.reinitialize();
|
||||
Localizer.reinitialize(appContext);
|
||||
UiUtils.setTheme(appContext,
|
||||
appContext.getString(R.string.pref_theme_light_value));
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,7 +51,6 @@ public class BriarApplicationImpl extends Application
|
||||
Localizer.initialize(prefs);
|
||||
super.attachBaseContext(
|
||||
Localizer.getInstance().setLocale(base));
|
||||
Localizer.getInstance().setLocale(this);
|
||||
setTheme(base, prefs);
|
||||
}
|
||||
|
||||
@@ -82,6 +81,7 @@ public class BriarApplicationImpl extends Application
|
||||
rootLogger.setLevel(IS_DEBUG_BUILD ? FINE : INFO);
|
||||
|
||||
LOG.info("Created");
|
||||
Localizer.getInstance().setLocaleLegacy(this);
|
||||
|
||||
EmojiManager.install(new GoogleEmojiProvider());
|
||||
}
|
||||
@@ -105,7 +105,9 @@ public class BriarApplicationImpl extends Application
|
||||
@Override
|
||||
public void onConfigurationChanged(@NonNull Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
Localizer.getInstance().setLocale(this);
|
||||
Localizer.getInstance().applicationConfigurationChanged(this, newConfig,
|
||||
applicationComponent.androidNotificationManager(),
|
||||
applicationComponent.lockManager().isLocked());
|
||||
}
|
||||
|
||||
private void setTheme(Context ctx, SharedPreferences prefs) {
|
||||
|
||||
@@ -170,7 +170,6 @@ public class BriarService extends Service {
|
||||
@Override
|
||||
protected void attachBaseContext(Context base) {
|
||||
super.attachBaseContext(Localizer.getInstance().setLocale(base));
|
||||
Localizer.getInstance().setLocale(this);
|
||||
}
|
||||
|
||||
private void showStartupFailureNotification(StartResult result) {
|
||||
|
||||
@@ -6,12 +6,16 @@ import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.briar.api.android.AndroidNotificationManager;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import androidx.core.text.TextUtilsCompat;
|
||||
|
||||
import static android.os.Build.VERSION.SDK_INT;
|
||||
import static androidx.core.view.ViewCompat.LAYOUT_DIRECTION_LTR;
|
||||
import static org.briarproject.briar.android.settings.SettingsFragment.LANGUAGE;
|
||||
|
||||
@NotNullByDefault
|
||||
@@ -21,6 +25,7 @@ public class Localizer {
|
||||
@Nullable
|
||||
private static Localizer INSTANCE;
|
||||
private final Locale systemLocale;
|
||||
@Nullable
|
||||
private final Locale locale;
|
||||
|
||||
private Localizer(SharedPreferences sharedPreferences) {
|
||||
@@ -30,10 +35,17 @@ public class Localizer {
|
||||
|
||||
private Localizer(Locale systemLocale, @Nullable Locale userLocale) {
|
||||
this.systemLocale = systemLocale;
|
||||
if (userLocale == null) locale = systemLocale;
|
||||
else locale = userLocale;
|
||||
locale = userLocale;
|
||||
setLocaleAndSystemConfiguration(locale);
|
||||
}
|
||||
|
||||
private Localizer(Locale systemLocale) {
|
||||
this.systemLocale = systemLocale;
|
||||
locale = null;
|
||||
setLocaleAndSystemConfiguration(systemLocale);
|
||||
}
|
||||
|
||||
|
||||
// Instantiate the Localizer.
|
||||
public static synchronized void initialize(SharedPreferences prefs) {
|
||||
if (INSTANCE == null)
|
||||
@@ -41,9 +53,11 @@ public class Localizer {
|
||||
}
|
||||
|
||||
// Reinstantiate the Localizer with the system locale
|
||||
public static synchronized void reinitialize() {
|
||||
if (INSTANCE != null)
|
||||
INSTANCE = new Localizer(INSTANCE.systemLocale, null);
|
||||
public static synchronized void reinitialize(Context appContext) {
|
||||
if (INSTANCE != null && INSTANCE.locale != null) {
|
||||
INSTANCE = new Localizer(INSTANCE.systemLocale);
|
||||
INSTANCE.forceLocale(appContext, INSTANCE.systemLocale);
|
||||
}
|
||||
}
|
||||
|
||||
// Get the current instance.
|
||||
@@ -64,43 +78,98 @@ public class Localizer {
|
||||
if (tag.contains("-")) {
|
||||
String[] langArray = tag.split("-");
|
||||
return new Locale(langArray[0], langArray[1]);
|
||||
} else
|
||||
} else {
|
||||
return new Locale(tag);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Apply localization to the specified context.
|
||||
*
|
||||
* It updates the configuration of the context's resources object but can
|
||||
* also return a new context derived from the context parameter. Hence
|
||||
* make sure to work with the return value of this method instead of
|
||||
* the context you passed as a parameter.
|
||||
*
|
||||
* This method also has side-effects as it calls Locale#setDefault().
|
||||
*
|
||||
* When using this in attachBaseContext() of Application, Service or
|
||||
* Activity subclasses, it is important to not only apply this method to the
|
||||
* base Context parameter received in that method, but also apply it on the
|
||||
* class itself which also extends Context.
|
||||
*/
|
||||
// Returns the localized version of context
|
||||
public Context setLocale(Context context) {
|
||||
if (locale == null || SDK_INT < 17) return context;
|
||||
Resources res = context.getResources();
|
||||
Configuration conf = res.getConfiguration();
|
||||
Locale currentLocale;
|
||||
if (SDK_INT >= 24) {
|
||||
currentLocale = conf.getLocales().get(0);
|
||||
} else
|
||||
currentLocale = conf.locale;
|
||||
if (locale.equals(currentLocale))
|
||||
return context;
|
||||
Locale.setDefault(locale);
|
||||
updateConfiguration(conf, locale);
|
||||
return context.createConfigurationContext(conf);
|
||||
}
|
||||
|
||||
// For API < 17 only.
|
||||
public void setLocaleLegacy(Context appContext) {
|
||||
if (SDK_INT >= 17 || locale == null) return;
|
||||
forceLocale(appContext, locale);
|
||||
}
|
||||
|
||||
// Forces the update of the resources through the deprecated API.
|
||||
private void forceLocale(Context context, Locale locale) {
|
||||
Resources res = context.getResources();
|
||||
Configuration conf = res.getConfiguration();
|
||||
updateConfiguration(conf, locale);
|
||||
res.updateConfiguration(conf, res.getDisplayMetrics());
|
||||
}
|
||||
|
||||
private void updateConfiguration(Configuration conf, Locale locale) {
|
||||
if (SDK_INT >= 17) {
|
||||
conf.setLocale(locale);
|
||||
context = context.createConfigurationContext(conf);
|
||||
} else
|
||||
} else {
|
||||
conf.locale = locale;
|
||||
//noinspection deprecation
|
||||
res.updateConfiguration(conf, res.getDisplayMetrics());
|
||||
return context;
|
||||
}
|
||||
}
|
||||
|
||||
private void setLocaleAndSystemConfiguration(@Nullable Locale locale) {
|
||||
if (locale == null) return;
|
||||
Locale.setDefault(locale);
|
||||
if (SDK_INT >= 23) return;
|
||||
Resources systemResources = Resources.getSystem();
|
||||
Configuration systemConfiguration = systemResources.getConfiguration();
|
||||
updateConfiguration(systemConfiguration, locale);
|
||||
// DateUtils uses the system resources, so we need to update them too.
|
||||
//noinspection deprecation
|
||||
systemResources.updateConfiguration(systemConfiguration,
|
||||
systemResources.getDisplayMetrics());
|
||||
}
|
||||
|
||||
private Locale getLocaleFromConfig(Configuration config) {
|
||||
if (SDK_INT >= 24) {
|
||||
return config.getLocales().get(0);
|
||||
} else {
|
||||
//noinspection deprecation
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether the language represented by locale
|
||||
* should be offered to the user on this device.
|
||||
* * Android doesn't pick up Asturian on API < 21
|
||||
* * RTL languages are supported since API >= 17
|
||||
*/
|
||||
public static boolean isLocaleSupported(Locale locale) {
|
||||
if (SDK_INT >= 21) return true;
|
||||
if (locale.getLanguage().equals("ast")) return false;
|
||||
if (SDK_INT >= 17) return true;
|
||||
return isLeftToRight(locale);
|
||||
}
|
||||
|
||||
// Exclude RTL locales on API < 17, they won't be laid out correctly
|
||||
private static boolean isLeftToRight(Locale locale) {
|
||||
// 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);
|
||||
return direction == LAYOUT_DIRECTION_LTR;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -109,7 +109,6 @@ public abstract class BaseActivity extends AppCompatActivity
|
||||
protected void attachBaseContext(Context base) {
|
||||
super.attachBaseContext(
|
||||
Localizer.getInstance().setLocale(base));
|
||||
Localizer.getInstance().setLocale(this);
|
||||
}
|
||||
|
||||
public ActivityComponent getActivityComponent() {
|
||||
|
||||
@@ -11,7 +11,6 @@ import org.briarproject.briar.R;
|
||||
import org.briarproject.briar.android.activity.ActivityComponent;
|
||||
import org.briarproject.briar.android.activity.BriarActivity;
|
||||
import org.briarproject.briar.android.fragment.BaseFragment.BaseFragmentListener;
|
||||
import org.briarproject.briar.android.navdrawer.NavDrawerActivity;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.inject.Inject;
|
||||
@@ -103,11 +102,4 @@ public class AddContactActivity extends BriarActivity implements
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
Intent i = new Intent(this, NavDrawerActivity.class);
|
||||
startActivity(i);
|
||||
finish();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@ import static org.briarproject.bramble.api.contact.HandshakeLinkConstants.LINK_R
|
||||
|
||||
class IntentRouter {
|
||||
|
||||
// TODO
|
||||
static void handleExternalIntent(Context ctx, Intent i) {
|
||||
String action = i.getAction();
|
||||
// add remote contact with clicked briar:// link
|
||||
|
||||
@@ -101,6 +101,8 @@ public class NavDrawerActivity extends BriarActivity implements
|
||||
Uri.parse("briar-content://org.briarproject.briar/blog");
|
||||
public static Uri CONTACT_ADDED_URI =
|
||||
Uri.parse("briar-content://org.briarproject.briar/contact/added");
|
||||
public static Uri SIGN_OUT_URI =
|
||||
Uri.parse("briar-content://org.briarproject.briar/sign-out");
|
||||
|
||||
private final List<Transport> transports = new ArrayList<>(3);
|
||||
private final MutableLiveData<ImageView> torIcon = new MutableLiveData<>();
|
||||
@@ -234,6 +236,8 @@ public class NavDrawerActivity extends BriarActivity implements
|
||||
startFragment(ForumListFragment.newInstance(), R.id.nav_btn_forums);
|
||||
} else if (BLOG_URI.equals(uri)) {
|
||||
startFragment(FeedFragment.newInstance(), R.id.nav_btn_blogs);
|
||||
} else if (SIGN_OUT_URI.equals(uri)) {
|
||||
signOut(false, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -79,10 +79,9 @@ public class GroupActivity extends
|
||||
|
||||
// start with group disabled and enable when not dissolved
|
||||
setGroupEnabled(false);
|
||||
viewModel.isDissolved().observe(this, dissolved -> {
|
||||
viewModel.isDissolved().observeEvent(this, dissolved -> {
|
||||
setGroupEnabled(!dissolved);
|
||||
// only show dialog when no prior state
|
||||
if (dissolved && state == null) onGroupDissolved();
|
||||
if (dissolved) onGroupDissolved();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -154,7 +153,7 @@ public class GroupActivity extends
|
||||
|
||||
@Override
|
||||
public void onReplyClick(GroupMessageItem item) {
|
||||
Boolean isDissolved = viewModel.isDissolved().getValue();
|
||||
Boolean isDissolved = viewModel.isDissolved().getLastValue();
|
||||
if (isDissolved != null && !isDissolved) super.onReplyClick(item);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,8 @@ import org.briarproject.bramble.api.system.AndroidExecutor;
|
||||
import org.briarproject.bramble.api.system.Clock;
|
||||
import org.briarproject.briar.android.sharing.SharingController;
|
||||
import org.briarproject.briar.android.threaded.ThreadListViewModel;
|
||||
import org.briarproject.briar.android.viewmodel.LiveEvent;
|
||||
import org.briarproject.briar.android.viewmodel.MutableLiveEvent;
|
||||
import org.briarproject.briar.api.android.AndroidNotificationManager;
|
||||
import org.briarproject.briar.api.client.MessageTracker;
|
||||
import org.briarproject.briar.api.client.MessageTracker.GroupCount;
|
||||
@@ -69,8 +71,8 @@ class GroupViewModel extends ThreadListViewModel<GroupMessageItem> {
|
||||
private final MutableLiveData<PrivateGroup> privateGroup =
|
||||
new MutableLiveData<>();
|
||||
private final MutableLiveData<Boolean> isCreator = new MutableLiveData<>();
|
||||
private final MutableLiveData<Boolean> isDissolved =
|
||||
new MutableLiveData<>();
|
||||
private final MutableLiveEvent<Boolean> isDissolved =
|
||||
new MutableLiveEvent<>();
|
||||
|
||||
@Inject
|
||||
GroupViewModel(Application application,
|
||||
@@ -127,7 +129,7 @@ class GroupViewModel extends ThreadListViewModel<GroupMessageItem> {
|
||||
} else if (e instanceof GroupDissolvedEvent) {
|
||||
GroupDissolvedEvent g = (GroupDissolvedEvent) e;
|
||||
if (g.getGroupId().equals(groupId)) {
|
||||
isDissolved.setValue(true);
|
||||
isDissolved.setEvent(true);
|
||||
}
|
||||
} else {
|
||||
super.eventOccurred(e);
|
||||
@@ -162,7 +164,7 @@ class GroupViewModel extends ThreadListViewModel<GroupMessageItem> {
|
||||
loadList(txn -> {
|
||||
// check first if group is dissolved
|
||||
isDissolved
|
||||
.postValue(privateGroupManager.isDissolved(txn, groupId));
|
||||
.postEvent(privateGroupManager.isDissolved(txn, groupId));
|
||||
// now continue to load the items
|
||||
long start = now();
|
||||
List<GroupMessageHeader> headers =
|
||||
@@ -280,7 +282,7 @@ class GroupViewModel extends ThreadListViewModel<GroupMessageItem> {
|
||||
return isCreator;
|
||||
}
|
||||
|
||||
LiveData<Boolean> isDissolved() {
|
||||
LiveEvent<Boolean> isDissolved() {
|
||||
return isDissolved;
|
||||
}
|
||||
|
||||
|
||||
@@ -46,16 +46,11 @@ public class SettingsActivity extends BriarActivity {
|
||||
|
||||
setContentView(R.layout.activity_settings);
|
||||
|
||||
ViewModelProvider provider =
|
||||
new ViewModelProvider(this, viewModelFactory);
|
||||
settingsViewModel = provider.get(SettingsViewModel.class);
|
||||
|
||||
settingsViewModel.getLanguageChange().observeEvent(this, b -> {
|
||||
signOut(false, false);
|
||||
finishAffinity();
|
||||
});
|
||||
|
||||
if (featureFlags.shouldEnableProfilePictures()) {
|
||||
ViewModelProvider provider =
|
||||
new ViewModelProvider(this, viewModelFactory);
|
||||
settingsViewModel = provider.get(SettingsViewModel.class);
|
||||
|
||||
TextView textViewUserName = findViewById(R.id.username);
|
||||
CircleImageView imageViewAvatar =
|
||||
findViewById(R.id.avatarImage);
|
||||
|
||||
@@ -44,8 +44,6 @@ import javax.inject.Inject;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.StringRes;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.core.text.TextUtilsCompat;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.preference.ListPreference;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.Preference.OnPreferenceChangeListener;
|
||||
@@ -55,6 +53,7 @@ import androidx.preference.SwitchPreference;
|
||||
|
||||
import static android.app.Activity.RESULT_OK;
|
||||
import static android.content.Intent.FLAG_ACTIVITY_CLEAR_TASK;
|
||||
import static android.content.Intent.FLAG_ACTIVITY_CLEAR_TOP;
|
||||
import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
|
||||
import static android.media.RingtoneManager.ACTION_RINGTONE_PICKER;
|
||||
import static android.media.RingtoneManager.EXTRA_RINGTONE_DEFAULT_URI;
|
||||
@@ -70,7 +69,6 @@ import static android.provider.Settings.EXTRA_APP_PACKAGE;
|
||||
import static android.provider.Settings.EXTRA_CHANNEL_ID;
|
||||
import static android.provider.Settings.System.DEFAULT_NOTIFICATION_URI;
|
||||
import static android.widget.Toast.LENGTH_SHORT;
|
||||
import static androidx.core.view.ViewCompat.LAYOUT_DIRECTION_LTR;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
import static java.util.logging.Level.INFO;
|
||||
import static java.util.logging.Level.WARNING;
|
||||
@@ -89,6 +87,7 @@ import static org.briarproject.bramble.util.LogUtils.now;
|
||||
import static org.briarproject.briar.android.BriarApplication.ENTRY_ACTIVITY;
|
||||
import static org.briarproject.briar.android.TestingConstants.IS_DEBUG_BUILD;
|
||||
import static org.briarproject.briar.android.activity.RequestCodes.REQUEST_RINGTONE;
|
||||
import static org.briarproject.briar.android.navdrawer.NavDrawerActivity.SIGN_OUT_URI;
|
||||
import static org.briarproject.briar.android.util.UiUtils.getCountryDisplayName;
|
||||
import static org.briarproject.briar.android.util.UiUtils.hasScreenLock;
|
||||
import static org.briarproject.briar.android.util.UiUtils.triggerFeedback;
|
||||
@@ -164,19 +163,12 @@ public class SettingsFragment extends PreferenceFragmentCompat
|
||||
LocationUtils locationUtils;
|
||||
@Inject
|
||||
CircumventionProvider circumventionProvider;
|
||||
@Inject
|
||||
ViewModelProvider.Factory viewModelFactory;
|
||||
|
||||
private SettingsViewModel viewModel;
|
||||
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
super.onAttach(context);
|
||||
listener = (SettingsActivity) context;
|
||||
listener.getActivityComponent().inject(this);
|
||||
|
||||
viewModel = new ViewModelProvider(requireActivity(), viewModelFactory)
|
||||
.get(SettingsViewModel.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -302,19 +294,27 @@ public class SettingsFragment extends PreferenceFragmentCompat
|
||||
Locale locale = Localizer.getLocaleFromTag(tag);
|
||||
if (locale == null)
|
||||
throw new IllegalStateException();
|
||||
// Exclude RTL locales on API < 17, they won't be laid out correctly
|
||||
if (SDK_INT < 17 && !isLeftToRight(locale)) {
|
||||
// Check if the locale is supported on this device
|
||||
if (!Localizer.isLocaleSupported(locale)) {
|
||||
if (LOG.isLoggable(INFO))
|
||||
LOG.info("Skipping RTL locale " + tag);
|
||||
LOG.info("Skipping unsupported locale " + tag);
|
||||
continue;
|
||||
}
|
||||
String nativeName = locale.getDisplayName(locale);
|
||||
// Fallback to English if the name is unknown in both native and
|
||||
// current locale.
|
||||
if (nativeName.equals(tag)) {
|
||||
String tmp = locale.getDisplayLanguage(Locale.ENGLISH);
|
||||
if (!tmp.isEmpty() && !tmp.equals(nativeName))
|
||||
nativeName = tmp;
|
||||
String nativeName;
|
||||
// Unknown languages won't be translated to their native name.
|
||||
if (locale.getLanguage().equals("ast")) {
|
||||
nativeName = "Asturianu";
|
||||
} else if (locale.getLanguage().equals("oc")) {
|
||||
nativeName = "Occitan";
|
||||
} else {
|
||||
nativeName = locale.getDisplayName(locale);
|
||||
// Fallback to English if the name is unknown in both native and
|
||||
// current locale.
|
||||
if (nativeName.equals(tag)) {
|
||||
String tmp = locale.getDisplayLanguage(Locale.ENGLISH);
|
||||
if (!tmp.isEmpty() && !tmp.equals(nativeName))
|
||||
nativeName = tmp;
|
||||
}
|
||||
}
|
||||
// Prefix with LRM marker to prevent any RTL direction
|
||||
entries.add("\u200E" + nativeName.substring(0, 1).toUpperCase()
|
||||
@@ -325,13 +325,6 @@ public class SettingsFragment extends PreferenceFragmentCompat
|
||||
language.setEntryValues(entryValues.toArray(new CharSequence[0]));
|
||||
}
|
||||
|
||||
private boolean isLeftToRight(Locale locale) {
|
||||
// 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);
|
||||
return direction == LAYOUT_DIRECTION_LTR;
|
||||
}
|
||||
|
||||
private void setTorNetworkSummary(int torNetworkSetting) {
|
||||
if (torNetworkSetting != PREF_TOR_NETWORK_AUTOMATIC) {
|
||||
@@ -644,7 +637,11 @@ public class SettingsFragment extends PreferenceFragmentCompat
|
||||
builder.setPositiveButton(R.string.sign_out_button,
|
||||
(dialogInterface, i) -> {
|
||||
language.setValue(newValue);
|
||||
viewModel.languageChanged();
|
||||
Intent intent = new Intent(getContext(), ENTRY_ACTIVITY);
|
||||
intent.setFlags(FLAG_ACTIVITY_CLEAR_TOP);
|
||||
intent.setData(SIGN_OUT_URI);
|
||||
requireActivity().startActivity(intent);
|
||||
requireActivity().finish();
|
||||
});
|
||||
builder.setNegativeButton(R.string.cancel, null);
|
||||
builder.setCancelable(false);
|
||||
|
||||
@@ -56,9 +56,6 @@ class SettingsViewModel extends AndroidViewModel {
|
||||
private final MutableLiveEvent<Boolean> setAvatarFailed =
|
||||
new MutableLiveEvent<>();
|
||||
|
||||
private final MutableLiveEvent<Boolean> languageChanged =
|
||||
new MutableLiveEvent<>();
|
||||
|
||||
@Inject
|
||||
SettingsViewModel(Application application,
|
||||
IdentityManager identityManager,
|
||||
@@ -86,10 +83,6 @@ class SettingsViewModel extends AndroidViewModel {
|
||||
return setAvatarFailed;
|
||||
}
|
||||
|
||||
LiveEvent<Boolean> getLanguageChange() {
|
||||
return languageChanged;
|
||||
}
|
||||
|
||||
private void loadOwnIdentityInfo() {
|
||||
dbExecutor.execute(() -> {
|
||||
try {
|
||||
@@ -138,8 +131,4 @@ class SettingsViewModel extends AndroidViewModel {
|
||||
});
|
||||
}
|
||||
|
||||
void languageChanged() {
|
||||
languageChanged.setEvent(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package org.briarproject.briar.android.splash;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
@@ -8,7 +7,6 @@ import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
|
||||
import org.briarproject.briar.R;
|
||||
import org.briarproject.briar.android.Localizer;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
@@ -29,13 +27,6 @@ public class ExpiredActivity extends AppCompatActivity
|
||||
findViewById(R.id.download_briar_button).setOnClickListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void attachBaseContext(Context base) {
|
||||
super.attachBaseContext(
|
||||
Localizer.getInstance().setLocale(base));
|
||||
Localizer.getInstance().setLocale(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Uri uri = Uri.parse("https://briarproject.org/download.html");
|
||||
|
||||
@@ -93,4 +93,7 @@ public interface AndroidNotificationManager {
|
||||
void blockAllBlogPostNotifications();
|
||||
|
||||
void unblockAllBlogPostNotifications();
|
||||
|
||||
void restartNotifications(boolean locked, boolean mayAlertAgain);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
dependencyVerification {
|
||||
verify = [
|
||||
'junit:junit:4.13.1:junit-4.13.1.jar:c30719db974d6452793fe191b3638a5777005485bae145924044530ffa5f6122',
|
||||
'org.codehaus.mojo.signature:java16:1.1:java16-1.1.signature:53799223a2c98dba2d0add810bed76315460df285c69e4f397ae6098f87dd619',
|
||||
'org.codehaus.mojo:animal-sniffer-ant-tasks:1.16:animal-sniffer-ant-tasks-1.16.jar:890040976fbe2d584619a6a61b1fd2e925b3b5eb342a85eb2762c467c0d64e90',
|
||||
'org.codehaus.mojo:animal-sniffer:1.16:animal-sniffer-1.16.jar:72be8bcc226ba43b937c722a08a07852bfa1b11400089265d5df0ee7b38b1d52',
|
||||
'org.hamcrest:hamcrest-core:1.3:hamcrest-core-1.3.jar:66fdef91e9739348df7a096aa384a5685f4e875584cce89386a7a47251c4d8e9',
|
||||
'org.ow2.asm:asm-all:5.2:asm-all-5.2.jar:7fbffbc1db3422e2101689fd88df8384b15817b52b9b2b267b9f6d2511dc198d',
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user