use Locale DISPLAY category on Android >= 24
https://gitlab.com/fdroid/fdroidclient/-/issues/1440#note_1315001793
This commit is contained in:
parent
1f7ed43c12
commit
29e69fcf1d
|
@ -0,0 +1,17 @@
|
|||
package org.fdroid.fdroid.compat;
|
||||
|
||||
import android.os.Build;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* @see <a href="https://developer.android.com/about/versions/oreo/android-8.0-changes#lai">use default DISPLAY category Locale</a>
|
||||
*/
|
||||
public class LocaleCompat {
|
||||
public static Locale getDefault() {
|
||||
if (Build.VERSION.SDK_INT >= 24) {
|
||||
return Locale.getDefault(java.util.Locale.Category.DISPLAY);
|
||||
} else {
|
||||
return Locale.getDefault();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -47,13 +47,13 @@ import org.fdroid.fdroid.NfcNotEnabledActivity;
|
|||
import org.fdroid.fdroid.R;
|
||||
import org.fdroid.fdroid.UpdateService;
|
||||
import org.fdroid.fdroid.Utils;
|
||||
import org.fdroid.fdroid.compat.LocaleCompat;
|
||||
import org.fdroid.fdroid.data.App;
|
||||
import org.fdroid.fdroid.data.DBHelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
|
||||
|
@ -413,7 +413,7 @@ public class RepoDetailsActivity extends AppCompatActivity {
|
|||
disposable = Single.fromCallable(() -> appDao.getNumberOfAppsInRepository(repoId))
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(appCount -> numApps.setText(String.format(Locale.getDefault(), "%d", appCount)));
|
||||
.subscribe(appCount -> numApps.setText(String.format(LocaleCompat.getDefault(), "%d", appCount)));
|
||||
|
||||
setupDescription(repoView, repo);
|
||||
setupRepoFingerprint(repoView, repo);
|
||||
|
|
|
@ -44,6 +44,7 @@ import org.fdroid.fdroid.FDroidApp;
|
|||
import org.fdroid.fdroid.Preferences;
|
||||
import org.fdroid.fdroid.R;
|
||||
import org.fdroid.fdroid.Utils;
|
||||
import org.fdroid.fdroid.compat.LocaleCompat;
|
||||
import org.fdroid.fdroid.data.DBHelper;
|
||||
import org.fdroid.fdroid.views.main.MainActivity;
|
||||
|
||||
|
@ -57,7 +58,6 @@ import androidx.recyclerview.widget.RecyclerView;
|
|||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Provides scrollable listing of apps for search and category views.
|
||||
|
@ -269,9 +269,9 @@ public class AppListActivity extends AppCompatActivity implements CategoryTextWa
|
|||
return Long.compare(o2.getLastUpdated(), o1.getLastUpdated());
|
||||
} else if (sortClauseSelected.equals(SortClause.WORDS)) {
|
||||
String n1 = (o1.getName() == null ? "" : o1.getName())
|
||||
.toLowerCase(Locale.getDefault());
|
||||
.toLowerCase(LocaleCompat.getDefault());
|
||||
String n2 = (o2.getName() == null ? "" : o2.getName())
|
||||
.toLowerCase(Locale.getDefault());
|
||||
.toLowerCase(LocaleCompat.getDefault());
|
||||
return n1.compareTo(n2);
|
||||
}
|
||||
return 0;
|
||||
|
|
|
@ -30,6 +30,7 @@ import org.apache.commons.io.FileUtils;
|
|||
import org.fdroid.download.HttpPoster;
|
||||
import org.fdroid.fdroid.Preferences;
|
||||
import org.fdroid.fdroid.Utils;
|
||||
import org.fdroid.fdroid.compat.LocaleCompat;
|
||||
import org.fdroid.fdroid.installer.InstallHistoryService;
|
||||
import org.fdroid.fdroid.net.DownloaderFactory;
|
||||
import org.json.JSONArray;
|
||||
|
@ -281,7 +282,7 @@ public class FDroidMetricsWorker extends Worker {
|
|||
private static class CleanInsightsReport {
|
||||
MatomoEvent[] events = new MatomoEvent[0];
|
||||
final long idsite = 3; // NOPMD
|
||||
final String lang = Locale.getDefault().getLanguage();
|
||||
final String lang = LocaleCompat.getDefault().getLanguage();
|
||||
final String ua = Utils.getUserAgent();
|
||||
|
||||
private String getJsonString() throws JSONException {
|
||||
|
|
Loading…
Reference in New Issue