Compare commits

...

4 Commits

Author SHA1 Message Date
Dennis Guse e3cdc952a2 Release: v4.16.1 2024-12-11 22:10:30 +01:00
Dennis Guse aaf78e0b74 Settings: language chooser is now available for all Android versions.
Part of #1974
2024-12-11 22:06:09 +01:00
Dennis Guse c3a2c0d6d0 Github actions: checkout won't fetch tags unless we do a full clone. 2024-12-06 07:58:35 +01:00
Dennis Guse 05fbfcb914 Nightly build: provide details on build failure. 2024-12-06 07:24:13 +01:00
7 changed files with 80 additions and 12 deletions
+3
View File
@@ -9,6 +9,9 @@ jobs:
steps:
- name: checkout
uses: actions/checkout@v4
with:
fetch-tags: true
fetch-depth: 0 #TODO See https://github.com/actions/checkout/issues/1471
- uses: actions/setup-java@v4
with:
+5 -3
View File
@@ -1,5 +1,4 @@
name: Linting
on:
push:
pull_request:
@@ -10,12 +9,15 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
- name: checkout
uses: actions/checkout@v4
with:
fetch-tags: true
fetch-depth: 0 #TODO See https://github.com/actions/checkout/issues/1471
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
distribution: 'adopt'
java-version: '17'
- run: ./gradlew lint
+3
View File
@@ -11,6 +11,9 @@ jobs:
steps:
- name: checkout
uses: actions/checkout@v4
with:
fetch-tags: true
fetch-depth: 0 #TODO See https://github.com/actions/checkout/issues/1471
- uses: actions/setup-java@v4
with:
+4 -4
View File
@@ -26,7 +26,7 @@ def getVersionName = { ->
}
return stdout.toString().trim()
} catch (ignored) {
return null
throw new GradleException('VersionName could not be read:' + ignored.message)
}
}
@@ -39,7 +39,7 @@ def getVersionCode = { ->
}
return Integer.valueOf(stdout.toString().trim())
} catch (ignored) {
return null
throw new GradleException('VersionCode could not be read:' + ignored.message)
}
}
@@ -64,8 +64,8 @@ android {
defaultConfig {
applicationId "de.dennisguse.opentracks"
versionCode 5941
versionName "v4.16.0"
versionCode 5945
versionName "v4.16.1"
buildConfigField "String", "VERSION_NAME_FULL", "\"${getVersionName()}\""
@@ -0,0 +1,8 @@
v4.16.1: OpenTracks
Changes:
- In-app language selector now available for all Android versions
(due to some popular demand)
Developer:
- Github actions: checkout was not fetching tags (nightly)
+10
View File
@@ -401,6 +401,16 @@ limitations under the License.
android:name=".services.TrackDeleteService"
android:exported="false"
android:permission="android.permission.BIND_JOB_SERVICE"/>
<!--Necessary for SDK < 33 to (re-)store per app locale information-->
<service
android:name="androidx.appcompat.app.AppLocalesMetadataHolderService"
android:enabled="false"
android:exported="false">
<meta-data
android:name="autoStoreLocales"
android:value="true" />
</service>
</application>
<queries>
@@ -1,25 +1,36 @@
package de.dennisguse.opentracks.settings;
import android.annotation.SuppressLint;
import android.app.LocaleConfig;
import android.content.Context;
import android.os.Build;
import android.os.LocaleList;
import android.util.AttributeSet;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.core.app.LocaleManagerCompat;
import androidx.core.os.LocaleListCompat;
import androidx.preference.ListPreference;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Locale;
import java.util.Optional;
import de.dennisguse.opentracks.R;
public class LocalePreference extends ListPreference {
private String TAG = LocalePreference.class.getSimpleName();
public LocalePreference(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
init(context);
@@ -40,18 +51,17 @@ public class LocalePreference extends ListPreference {
init(context);
}
// /data/user/0/de.dennisguse.opentracks.debug/files/androidx.appcompat.app.AppCompatDelegate.application_locales_record_file: open failed: ENOENT (No such file or directory)
private void init(Context context) {
setPersistent(false);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
setEnabled(false);
return;
}
LocaleItem systemDefaultLocale = new LocaleItem("", context.getString(R.string.settings_locale_system_default));
LocaleItem currentLocale = new LocaleItem(Locale.getDefault().toLanguageTag(), Locale.getDefault().getDisplayName());
// All available options
LocaleList supportedLocales = LocaleConfig.fromContextIgnoringOverride(context).getSupportedLocales();
LocaleList supportedLocales = getLocaleListCompat();
ArrayList<LocaleItem> localeItemsSorting = new ArrayList<>();
for (int i = 0; i < supportedLocales.size(); i++) {
Locale current = supportedLocales.get(i);
@@ -104,4 +114,36 @@ public class LocalePreference extends ListPreference {
String displayName
) {
}
// TODO Get this functionality from any Androidx compat library: should be in LocaleListCompat or LocaleManagerCompat
// 2024-12-12: on Android 14-: LocaleManagerCompat.getApplicationLocales(getContext()) returned "[]"
// See: https://stackoverflow.com/questions/78116375/per-app-language-preferences-get-list-of-apps-available-language-programmatic
@Deprecated
private LocaleList getLocaleListCompat() {
var a = LocaleManagerCompat.getApplicationLocales(getContext());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
return LocaleConfig.fromContextIgnoringOverride(getContext()).getSupportedLocales();
}
@SuppressLint("DiscouragedApi") int localesConfigId = getContext().getResources().getIdentifier("_generated_res_locale_config", "xml", getContext().getPackageName());
List<String> localeList = new ArrayList<>();
XmlPullParser xpp = getContext().getResources().getXml(localesConfigId);
try {
while (xpp.getEventType() != XmlPullParser.END_DOCUMENT) {
if (xpp.getEventType() == XmlPullParser.START_TAG) {
if ("locale".equals(xpp.getName()) && xpp.getAttributeCount() > 0 && xpp.getAttributeName(0).equals("name")) {
localeList.add(xpp.getAttributeValue(0));
}
}
xpp.next();
}
} catch (IOException | XmlPullParserException e) {
Log.e(TAG, "Could not load locales: " + e.getMessage());
}
Optional<String> locales = localeList.stream().reduce((s1, s2) -> s1 + "," + s2);
return locales
.map(LocaleList::forLanguageTags)
.orElseGet(LocaleList::getEmptyLocaleList);
}
}