From 3c4d6a59f190911733cdbcc241bb4e9a759a8532 Mon Sep 17 00:00:00 2001 From: Akexorcist Date: Tue, 11 May 2021 17:13:53 +0700 Subject: [PATCH 01/18] Update readme for context in `getDefaultLanguage` --- README.md | 2 +- .../localizationactivity/ui/LocalizationApplication.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a696afb..95f97eb 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,7 @@ Custom application class which extends from `LocalizationApplication` is require ```kotlin class MainApplication: LocalizationApplication() { /* ... */ - override fun getDefaultLanguage() = Locale.ENGLISH + override fun getDefaultLanguage(context: Context) = Locale.ENGLISH } ``` diff --git a/localization/src/main/java/com/akexorcist/localizationactivity/ui/LocalizationApplication.kt b/localization/src/main/java/com/akexorcist/localizationactivity/ui/LocalizationApplication.kt index 8cc7f00..f37d1ed 100644 --- a/localization/src/main/java/com/akexorcist/localizationactivity/ui/LocalizationApplication.kt +++ b/localization/src/main/java/com/akexorcist/localizationactivity/ui/LocalizationApplication.kt @@ -28,5 +28,5 @@ abstract class LocalizationApplication : Application() { return localizationDelegate.getResources(this, super.getResources()) } - abstract fun getDefaultLanguage(base: Context): Locale + abstract fun getDefaultLanguage(context: Context): Locale } From 5700d469fe026e5a37c45c6c1309e2b6015147e8 Mon Sep 17 00:00:00 2001 From: Akexorcist Date: Wed, 8 Dec 2021 04:44:32 +0700 Subject: [PATCH 02/18] Update SDK version and dependencies * Compile SDK Version 31 * Target SDK Version 31 * Gradle 7.0.2 * Android Gradle Plugin 4.2.2 * Kotlin 1.6.0 * AndroidX AppCompat 1.4.0 * Hilt 2.40.2 * AndroidX Test 1.4.0, 1.1.3 * AndroidX Espresso 3.4.0 --- app/build.gradle | 20 ++++++++++---------- build.gradle | 10 ++++------ gradle/wrapper/gradle-wrapper.properties | 2 +- 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 60ae514..9086bc7 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -38,29 +38,29 @@ android { } buildFeatures { - viewBinding = true + viewBinding true } testOptions { - animationsDisabled = true + animationsDisabled true } } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" - implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'androidx.appcompat:appcompat:1.4.0' implementation 'androidx.viewpager:viewpager:1.0.0' implementation 'androidx.preference:preference-ktx:1.1.1' implementation "androidx.viewpager2:viewpager2:1.0.0" - implementation "com.google.dagger:hilt-android:2.33-beta" - kapt "com.google.dagger:hilt-compiler:2.33-beta" + implementation 'com.google.dagger:hilt-android:2.40.4' + kapt 'com.google.dagger:hilt-compiler:2.40.4' - androidTestImplementation 'androidx.test:runner:1.3.0' - androidTestImplementation 'androidx.test:rules:1.3.0' - androidTestImplementation 'androidx.test.ext:junit:1.1.2' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' - androidTestImplementation 'androidx.test.espresso:espresso-web:3.3.0' + androidTestImplementation 'androidx.test:runner:1.4.0' + androidTestImplementation 'androidx.test:rules:1.4.0' + androidTestImplementation 'androidx.test.ext:junit:1.1.3' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' + androidTestImplementation 'androidx.test.espresso:espresso-web:3.4.0' androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0' androidTestImplementation 'com.agoda.kakao:kakao:2.4.0' diff --git a/build.gradle b/build.gradle index 69f0166..1fb6ed0 100644 --- a/build.gradle +++ b/build.gradle @@ -1,8 +1,8 @@ buildscript { project.ext { - kotlin_version = '1.4.32' - compileSdkVersion = 30 - targetSdkVersion = 30 + kotlin_version = '1.6.0' + compileSdkVersion = 31 + targetSdkVersion = 31 minSdkVersion = 14 versionName = '1.2.10' @@ -26,12 +26,11 @@ buildscript { } repositories { - jcenter() mavenCentral() google() } dependencies { - classpath 'com.android.tools.build:gradle:4.1.3' + classpath 'com.android.tools.build:gradle:4.2.2' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$project.kotlin_version" classpath "org.jetbrains.dokka:dokka-android-gradle-plugin:0.9.17" classpath "com.google.dagger:hilt-android-gradle-plugin:2.33-beta" @@ -40,7 +39,6 @@ buildscript { allprojects { repositories { - jcenter() mavenCentral() google() } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 901829d..02c9afd 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip From 58c353f727ba57f312dcaeebf565fd8681eda2ca Mon Sep 17 00:00:00 2001 From: Akexorcist Date: Mon, 20 Dec 2021 02:27:57 +0700 Subject: [PATCH 03/18] Fix WebView crash issue #118 #114 #105 --- .../localizationapp/DialogWebViewTest.kt | 28 ++++++++- app/src/main/AndroidManifest.xml | 61 ++++++++++++++----- .../localizationapp/MainApplication.kt | 10 +++ .../localizationapp/hilt/StoryProvider.kt | 3 +- 4 files changed, 85 insertions(+), 17 deletions(-) diff --git a/app/src/androidTest/java/com/akexorcist/localizationapp/DialogWebViewTest.kt b/app/src/androidTest/java/com/akexorcist/localizationapp/DialogWebViewTest.kt index de888d6..414209f 100644 --- a/app/src/androidTest/java/com/akexorcist/localizationapp/DialogWebViewTest.kt +++ b/app/src/androidTest/java/com/akexorcist/localizationapp/DialogWebViewTest.kt @@ -27,20 +27,46 @@ class DialogWebViewTest { @Test fun dialogAndWebView() { + // Japan onScreen { buttonDialogWebView { scrollTo() click() } } - Thread.sleep(1000L) + onScreen { + buttonChangeLanguage { click() } + } + onScreen { + buttonJapanese { click() } + } onScreen { buttonShowWebsite { click() } } onScreen { + webViewContent { + withElement(Locator.ID, "content") { + hasText(ExpectedContent.HELLO_WORLD_JAPANESE) + } + } + buttonBack { click() } + } + onScreen { buttonBack { click() } } + onScreen { + textViewTitle { + hasText(ExpectedContent.HELLO_WORLD_JAPANESE) + } + } + // American + onScreen { + buttonDialogWebView { + scrollTo() + click() + } + } onScreen { buttonChangeLanguage { click() } } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 2d1da1d..3316e98 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -10,30 +10,61 @@ android:label="@string/app_name" android:supportsRtl="true" android:theme="@style/AppTheme"> - + - - - - - - - - + + + + + + + + - - - - - - + + + + + + Date: Mon, 20 Dec 2021 02:32:15 +0700 Subject: [PATCH 04/18] Add onCreate in LocalizationApplicationDelegate --- .../java/com/akexorcist/localizationapp/MainApplication.kt | 2 +- .../core/LocalizationApplicationDelegate.kt | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/akexorcist/localizationapp/MainApplication.kt b/app/src/main/java/com/akexorcist/localizationapp/MainApplication.kt index 06cafb3..2d0b9ad 100644 --- a/app/src/main/java/com/akexorcist/localizationapp/MainApplication.kt +++ b/app/src/main/java/com/akexorcist/localizationapp/MainApplication.kt @@ -15,7 +15,7 @@ class MainApplication : Application() { override fun onCreate() { super.onCreate() - WebView(this).destroy() + localizationDelegate.onCreate(this) } override fun attachBaseContext(base: Context) { diff --git a/localization/src/main/java/com/akexorcist/localizationactivity/core/LocalizationApplicationDelegate.kt b/localization/src/main/java/com/akexorcist/localizationactivity/core/LocalizationApplicationDelegate.kt index a3c34c2..0b25171 100644 --- a/localization/src/main/java/com/akexorcist/localizationactivity/core/LocalizationApplicationDelegate.kt +++ b/localization/src/main/java/com/akexorcist/localizationactivity/core/LocalizationApplicationDelegate.kt @@ -2,9 +2,13 @@ package com.akexorcist.localizationactivity.core import android.content.Context import android.content.res.Resources +import android.webkit.WebView import java.util.* class LocalizationApplicationDelegate { + fun onCreate(context: Context) { + WebView(context).destroy() + } fun onConfigurationChanged(context: Context) = LocalizationUtility.getLocalizedContext(context) From 5bdfc3c9382ebfff93e5b44f1a2f6b2d59f617a2 Mon Sep 17 00:00:00 2001 From: Akexorcist Date: Mon, 20 Dec 2021 03:00:29 +0700 Subject: [PATCH 05/18] Update device list for UI test --- .github/workflows/android.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 60f877a..a2f7985 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -84,8 +84,8 @@ jobs: --type instrumentation --app app-debug/app-debug.apk --test app-debug-androidTest/app-debug-androidTest.apk - --device model=flame,version=30,locale=en,orientation=portrait - --device model=crownlte,version=28,locale=en,orientation=portrait + --device model=redfin,version=30,locale=en,orientation=portrait + --device model=greatlte,version=28,locale=en,orientation=portrait --device model=OnePlus3T,version=26,locale=en,orientation=portrait --device model=HWMHA,version=24,locale=en,orientation=portrait --device model=grandppltedx,version=23,locale=en,orientation=portrait From b789544d4bcb144107f23f691affb5aad106e6a9 Mon Sep 17 00:00:00 2001 From: Akexorcist Date: Mon, 20 Dec 2021 03:04:11 +0700 Subject: [PATCH 06/18] Change japan to italy for UI test --- .../com/akexorcist/localizationapp/DialogWebViewTest.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/androidTest/java/com/akexorcist/localizationapp/DialogWebViewTest.kt b/app/src/androidTest/java/com/akexorcist/localizationapp/DialogWebViewTest.kt index 414209f..05f1fab 100644 --- a/app/src/androidTest/java/com/akexorcist/localizationapp/DialogWebViewTest.kt +++ b/app/src/androidTest/java/com/akexorcist/localizationapp/DialogWebViewTest.kt @@ -27,7 +27,7 @@ class DialogWebViewTest { @Test fun dialogAndWebView() { - // Japan + // Italy onScreen { buttonDialogWebView { scrollTo() @@ -38,7 +38,7 @@ class DialogWebViewTest { buttonChangeLanguage { click() } } onScreen { - buttonJapanese { click() } + buttonItalian { click() } } onScreen { buttonShowWebsite { click() } @@ -46,7 +46,7 @@ class DialogWebViewTest { onScreen { webViewContent { withElement(Locator.ID, "content") { - hasText(ExpectedContent.HELLO_WORLD_JAPANESE) + hasText(ExpectedContent.HELLO_WORLD_ITALIAN) } } buttonBack { click() } @@ -56,7 +56,7 @@ class DialogWebViewTest { } onScreen { textViewTitle { - hasText(ExpectedContent.HELLO_WORLD_JAPANESE) + hasText(ExpectedContent.HELLO_WORLD_ITALIAN) } } From ced19c1442e7bb277d2240244b1119e4431c78a1 Mon Sep 17 00:00:00 2001 From: Akexorcist Date: Mon, 20 Dec 2021 03:12:19 +0700 Subject: [PATCH 07/18] Update device list for UI test --- .github/workflows/android.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index a2f7985..59ff23d 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -85,7 +85,7 @@ jobs: --app app-debug/app-debug.apk --test app-debug-androidTest/app-debug-androidTest.apk --device model=redfin,version=30,locale=en,orientation=portrait - --device model=greatlte,version=28,locale=en,orientation=portrait + --device model=greatlteks,version=28,locale=en,orientation=portrait --device model=OnePlus3T,version=26,locale=en,orientation=portrait --device model=HWMHA,version=24,locale=en,orientation=portrait --device model=grandppltedx,version=23,locale=en,orientation=portrait From 108e5a54c37032f99d13dfba64ebec0557240cf0 Mon Sep 17 00:00:00 2001 From: Akexorcist Date: Mon, 20 Dec 2021 03:26:57 +0700 Subject: [PATCH 08/18] Update device list for UI test --- .github/workflows/android.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 59ff23d..bb2c12e 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -89,4 +89,4 @@ jobs: --device model=OnePlus3T,version=26,locale=en,orientation=portrait --device model=HWMHA,version=24,locale=en,orientation=portrait --device model=grandppltedx,version=23,locale=en,orientation=portrait - --device model=Nexus5,version=21,locale=en,orientation=portrait" + --device model=hwALE-H,version=21,locale=en,orientation=portrait" From 7b78ded893036e9fc4e04b8aa7713c7a63096c58 Mon Sep 17 00:00:00 2001 From: Chatchawan Kotarasu Date: Tue, 21 Dec 2021 12:19:20 +0700 Subject: [PATCH 09/18] fix: WebView crashing on Android 5 *BREAKING CHANGES* - change `targetSdkVersion` from 30 to 31 - change `appcompat` version to `1.4.0` --- app/build.gradle | 2 +- build.gradle | 4 +-- localization/build.gradle | 2 +- .../ui/LocalizationActivity.kt | 29 ++++++++++++++----- 4 files changed, 26 insertions(+), 11 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 60ae514..687064f 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -49,7 +49,7 @@ android { dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" - implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'androidx.appcompat:appcompat:1.4.0' implementation 'androidx.viewpager:viewpager:1.0.0' implementation 'androidx.preference:preference-ktx:1.1.1' implementation "androidx.viewpager2:viewpager2:1.0.0" diff --git a/build.gradle b/build.gradle index 69f0166..42d8f63 100644 --- a/build.gradle +++ b/build.gradle @@ -1,8 +1,8 @@ buildscript { project.ext { kotlin_version = '1.4.32' - compileSdkVersion = 30 - targetSdkVersion = 30 + compileSdkVersion = 31 + targetSdkVersion = 31 minSdkVersion = 14 versionName = '1.2.10' diff --git a/localization/build.gradle b/localization/build.gradle index 82a9911..9e51a6c 100644 --- a/localization/build.gradle +++ b/localization/build.gradle @@ -29,7 +29,7 @@ task dokkaJavadoc(type: org.jetbrains.dokka.gradle.DokkaTask) { dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$project.kotlin_version" - implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'androidx.appcompat:appcompat:1.4.0' implementation "androidx.activity:activity-ktx:1.2.2" testImplementation 'junit:junit:4.13.2' androidTestImplementation 'androidx.test.ext:junit:1.1.2' diff --git a/localization/src/main/java/com/akexorcist/localizationactivity/ui/LocalizationActivity.kt b/localization/src/main/java/com/akexorcist/localizationactivity/ui/LocalizationActivity.kt index 991130a..354c1f7 100644 --- a/localization/src/main/java/com/akexorcist/localizationactivity/ui/LocalizationActivity.kt +++ b/localization/src/main/java/com/akexorcist/localizationactivity/ui/LocalizationActivity.kt @@ -2,8 +2,8 @@ package com.akexorcist.localizationactivity.ui import android.content.Context import android.content.res.Resources -import android.os.Build import android.os.Bundle +import androidx.annotation.CallSuper import androidx.annotation.LayoutRes import androidx.appcompat.app.AppCompatActivity import com.akexorcist.localizationactivity.core.LocalizationActivityDelegate @@ -30,12 +30,27 @@ abstract class LocalizationActivity : AppCompatActivity, OnLocaleChangedListener } override fun attachBaseContext(newBase: Context) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { - applyOverrideConfiguration(localizationDelegate.updateConfigurationLocale(newBase)) - super.attachBaseContext(newBase) - } else { - super.attachBaseContext(localizationDelegate.attachBaseContext(newBase)) - } + super.attachBaseContext(delegateBaseContext(newBase)) + } + + /** + * Get a base context for [attachBaseContext]. You can override this function to wrap this + * context by using ContextWrapper. For example, if your project use ViewPump from + * `io.github.inflationx:viewpump` module ([ViewPump](https://github.com/InflationX/ViewPump)), + * you can override this method to wrap this context with `ViewPumpContextWrapper`. + * ```Kotlin + * override fun delegateBaseContext(context: Context): Context { + * val localizedContext: Context = super.delegateBaseContext(context) + * return ViewPumpContextWrapper.wrap(localizedContext) + * } + * ``` + * @param context a new base context from [attachBaseContext] parameter. + * @return a new base context. By default, it will return + * [LocalizationActivityDelegate.attachBaseContext] + */ + @CallSuper + open fun delegateBaseContext(context: Context): Context { + return localizationDelegate.attachBaseContext(context) } override fun getBaseContext(): Context { From 67c5d422a8e8f9a9300b14c95e6f9e9460377f06 Mon Sep 17 00:00:00 2001 From: Chatchawan Kotarasu Date: Tue, 21 Dec 2021 13:32:46 +0700 Subject: [PATCH 10/18] fix: add jvmTarget 1.8 to localization module --- app/build.gradle | 6 +++--- build.gradle | 2 ++ localization/build.gradle | 8 ++++++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 687064f..98b650c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -29,12 +29,12 @@ android { } compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 + sourceCompatibility project.targetJavaVersion + targetCompatibility project.targetJavaVersion } kotlinOptions { - jvmTarget = '1.8' + jvmTarget = project.targetJavaVersion.toString() } buildFeatures { diff --git a/build.gradle b/build.gradle index 42d8f63..5912aa4 100644 --- a/build.gradle +++ b/build.gradle @@ -5,6 +5,8 @@ buildscript { targetSdkVersion = 31 minSdkVersion = 14 + targetJavaVersion = JavaVersion.VERSION_1_8 + versionName = '1.2.10' versionCode = 10210 diff --git a/localization/build.gradle b/localization/build.gradle index 9e51a6c..864ce4d 100644 --- a/localization/build.gradle +++ b/localization/build.gradle @@ -20,6 +20,14 @@ android { res.srcDirs = ['src/main/res'] } } + + compileOptions { + sourceCompatibility project.targetJavaVersion + targetCompatibility project.targetJavaVersion + } + kotlinOptions { + jvmTarget = project.targetJavaVersion.toString() + } } task dokkaJavadoc(type: org.jetbrains.dokka.gradle.DokkaTask) { From e288eaac77e98c32357fe2f222dc6e722147d7d7 Mon Sep 17 00:00:00 2001 From: Akexorcist Date: Wed, 22 Dec 2021 00:43:55 +0700 Subject: [PATCH 11/18] Update SDK version and dependencies * Kotlin 1.6.10 * Activity KTX 1.4.0 * AndroidX Test JUnit 1.1.3 * AndroidX Test Runner 1.4.0 * AndroidX Espresso 3.4.0 --- build.gradle | 2 +- localization/build.gradle | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/build.gradle b/build.gradle index 3f420eb..83fe938 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,6 @@ buildscript { project.ext { - kotlin_version = '1.6.0' + kotlin_version = '1.6.10' compileSdkVersion = 31 targetSdkVersion = 31 minSdkVersion = 14 diff --git a/localization/build.gradle b/localization/build.gradle index 864ce4d..743490a 100644 --- a/localization/build.gradle +++ b/localization/build.gradle @@ -38,11 +38,11 @@ task dokkaJavadoc(type: org.jetbrains.dokka.gradle.DokkaTask) { dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$project.kotlin_version" implementation 'androidx.appcompat:appcompat:1.4.0' - implementation "androidx.activity:activity-ktx:1.2.2" + implementation "androidx.activity:activity-ktx:1.4.0" testImplementation 'junit:junit:4.13.2' - androidTestImplementation 'androidx.test.ext:junit:1.1.2' - androidTestImplementation 'androidx.test:runner:1.3.0' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' + androidTestImplementation 'androidx.test.ext:junit:1.1.3' + androidTestImplementation 'androidx.test:runner:1.4.0' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' } //apply from: '../publish/mavencentral.gradle' From 20d8d5c5cab4bc893bb6812797561cd0eab62572 Mon Sep 17 00:00:00 2001 From: Akexorcist Date: Wed, 22 Dec 2021 00:58:35 +0700 Subject: [PATCH 12/18] Update to 1.2.11 --- CHANGELOG.md | 13 +++++++++++++ README.md | 4 ++-- build.gradle | 4 ++-- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 952f01f..7e879ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,19 @@ Release Notes ==== +1.2.11 +-- +* [Bug] Bug fixed [#105](https://github.com/akexorcist/Localization/pull/105) [#118](https://github.com/akexorcist/Localization/pull/118) [#114](https://github.com/akexorcist/Localization/pull/114) [#118](https://github.com/akexorcist/Localization/pull/118) +* [PR] [#125](https://github.com/akexorcist/Localization/pull/125) - Fix WebView crashing on Android 5 +* Update Gradle and dependencies version + * Compile SDK Version 31 + * Target SDK Version 31 + * Kotlin : 1.6.10 + * Gradle : 7.0.2 + * Gradle Plugin : 4.2.2 + * Activity KTX : 1.4.0 + * AndroidX AppCompat 1.4.0 + 1.2.10 -- * [Bug] Bug fixed [#105](https://github.com/akexorcist/Localization/issues/105) [#103](https://github.com/akexorcist/Localization/issues/103) [#92](https://github.com/akexorcist/Localization/issues/92) diff --git a/README.md b/README.md index 95f97eb..d8d2236 100644 --- a/README.md +++ b/README.md @@ -40,12 +40,12 @@ allprojects { Gradle ```groovy -implementation 'com.akexorcist:localization:1.2.10' +implementation 'com.akexorcist:localization:1.2.11' ``` (Optional) You can exclude `androidx.appcompat:appcompat`, if your project does not use AppCompat. ```groovy -implementation ('com.akexorcist:localization:1.2.10') { +implementation ('com.akexorcist:localization:1.2.11') { exclude group: 'androidx.core', module: 'core' } ``` diff --git a/build.gradle b/build.gradle index 83fe938..9cceb74 100644 --- a/build.gradle +++ b/build.gradle @@ -7,8 +7,8 @@ buildscript { targetJavaVersion = JavaVersion.VERSION_1_8 - versionName = '1.2.10' - versionCode = 10210 + versionName = '1.2.11' + versionCode = 10211 libraryName = 'Localization' libraryDescription = 'In-app language changing library for Android' From 6096656ed770f9ed51da6d589f67fb97cb93977e Mon Sep 17 00:00:00 2001 From: Akexorcist Date: Wed, 22 Dec 2021 01:18:28 +0700 Subject: [PATCH 13/18] Update JDK in CI to v15 --- .github/workflows/android.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index bb2c12e..da3b139 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -13,10 +13,10 @@ jobs: steps: - uses: actions/checkout@v2 - - name: set up JDK 1.8 + - name: set up JDK 15 uses: actions/setup-java@v1 with: - java-version: 1.8 + java-version: 15 - name: Grant execute permission for gradlew run: chmod +x gradlew @@ -29,10 +29,10 @@ jobs: steps: - uses: actions/checkout@v2 - - name: set up JDK 1.8 + - name: set up JDK 15 uses: actions/setup-java@v1 with: - java-version: 1.8 + java-version: 15 - name: Grant execute permission for gradlew run: chmod +x gradlew From 7a7f3d8b2664d6fd5c735d1b05964c46e99cd7a1 Mon Sep 17 00:00:00 2001 From: Akexorcist Date: Fri, 31 Dec 2021 03:54:49 +0700 Subject: [PATCH 14/18] Clean up --- .../java/com/akexorcist/localizationapp/MainApplication.kt | 4 ---- .../java/com/akexorcist/localizationapp/hilt/StoryProvider.kt | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/app/src/main/java/com/akexorcist/localizationapp/MainApplication.kt b/app/src/main/java/com/akexorcist/localizationapp/MainApplication.kt index 2d0b9ad..0984129 100644 --- a/app/src/main/java/com/akexorcist/localizationapp/MainApplication.kt +++ b/app/src/main/java/com/akexorcist/localizationapp/MainApplication.kt @@ -32,10 +32,6 @@ class MainApplication : Application() { return localizationDelegate.getApplicationContext(super.getApplicationContext()) } -// override fun getApplicationContext(): Context { -// return localizationDelegate.getApplicationContext2(super.getApplicationContext()) -// } - override fun getResources(): Resources { return localizationDelegate.getResources(baseContext, super.getResources()) } diff --git a/app/src/main/java/com/akexorcist/localizationapp/hilt/StoryProvider.kt b/app/src/main/java/com/akexorcist/localizationapp/hilt/StoryProvider.kt index 08929ba..61bfbe4 100644 --- a/app/src/main/java/com/akexorcist/localizationapp/hilt/StoryProvider.kt +++ b/app/src/main/java/com/akexorcist/localizationapp/hilt/StoryProvider.kt @@ -14,6 +14,6 @@ class SimpleStoryProvider @Inject constructor( @ApplicationContext private val appContext: Context ) : StoryProvider { override fun getAppleStory(): String { - return appContext.toLocalizedContext().getString(R.string.sample_apple_story) + return appContext.getString(R.string.sample_apple_story) } } From f8abe5932ec8f09567014b611414a0f0f04a53f2 Mon Sep 17 00:00:00 2001 From: Akexorcist Date: Wed, 22 Jun 2022 03:54:40 +0700 Subject: [PATCH 15/18] Add discontinued information and guide --- MIGRATE_TO_ANDROIDX.md | 28 ++++++++++++++++++++++++++++ README.md | 3 +++ 2 files changed, 31 insertions(+) create mode 100644 MIGRATE_TO_ANDROIDX.md diff --git a/MIGRATE_TO_ANDROIDX.md b/MIGRATE_TO_ANDROIDX.md new file mode 100644 index 0000000..f9c130c --- /dev/null +++ b/MIGRATE_TO_ANDROIDX.md @@ -0,0 +1,28 @@ +# Migrate to AndroidX +Since AndroidX supports per-app language preferences for backward compatibility. Please migrate this library to AndroidX for more stability, compatibility, and longer supports from Google team. + +* Remove `LocalizationApplicationDelegate` from Application class +* Replace `LocalizationActivity` with `AppCompatActivity` or remove `LocalizationActivityDelegate` from your custom Activity +* Replace `setLanguage(language)` with `AppCompatDelegate.setApplicationLocales(LocaleListCompat.forLanguageTags(language))` +* Remove `toLocalizedContext()` and use original Context +* Remove `LocalizationServiceDelegate` from Service class +* Add `androidx.appcompat.app.AppLocalesMetadataHolderService` as `` in Android Manifest (see [Support Android 12 and lower](https://developer.android.com/about/versions/13/features/app-languages#android12-impl)) +```xml + + + + + + + + +``` +* Remove this library from your project (`implementation 'com.akexorcist:localization:'`) +* Test your app + +For more information about per-app language preferences, see [Per-app language preferences](https://developer.android.com/about/versions/13/features/app-languages) diff --git a/README.md b/README.md index d8d2236..f82bbb8 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,9 @@ ![Minimum SDK Version](https://img.shields.io/badge/minSdkVersion-14-brightgreen) [![Workflow Status](https://github.com/akexorcist/Android-Localization/actions/workflows/android.yml/badge.svg)](https://github.com/akexorcist/Localization/actions) +Discontinued +==== +Since Google announced Android 13 with per-app language preferences supports. This feature also backport to older Android version with AndroidX. So there's no reason to contribute this library anymore. For more stability, compatibility, and longer supports from Google team, please migrate to AndroidX. See [Migrate to AndroidX guide](./MIGRATE_TO_ANDROIDX). Localization Library ==== From 9c48c1441de41c46ae2819781d7a7e201b309c51 Mon Sep 17 00:00:00 2001 From: Akexorcist Date: Wed, 22 Jun 2022 03:55:49 +0700 Subject: [PATCH 16/18] Fix incorrect link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f82bbb8..fe02409 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Discontinued ==== -Since Google announced Android 13 with per-app language preferences supports. This feature also backport to older Android version with AndroidX. So there's no reason to contribute this library anymore. For more stability, compatibility, and longer supports from Google team, please migrate to AndroidX. See [Migrate to AndroidX guide](./MIGRATE_TO_ANDROIDX). +Since Google announced Android 13 with per-app language preferences supports. This feature also backport to older Android version with AndroidX. So there's no reason to contribute this library anymore. For more stability, compatibility, and longer supports from Google team, please migrate to AndroidX. See [Migrate to AndroidX guide](./MIGRATE_TO_ANDROIDX.md). Localization Library ==== From aba659f3ed58e08454deb5c3874b21e74be2943e Mon Sep 17 00:00:00 2001 From: Akexorcist Date: Wed, 22 Jun 2022 03:58:42 +0700 Subject: [PATCH 17/18] Update migrate to AndroidX guide --- MIGRATE_TO_ANDROIDX.md | 1 + 1 file changed, 1 insertion(+) diff --git a/MIGRATE_TO_ANDROIDX.md b/MIGRATE_TO_ANDROIDX.md index f9c130c..b06057c 100644 --- a/MIGRATE_TO_ANDROIDX.md +++ b/MIGRATE_TO_ANDROIDX.md @@ -1,6 +1,7 @@ # Migrate to AndroidX Since AndroidX supports per-app language preferences for backward compatibility. Please migrate this library to AndroidX for more stability, compatibility, and longer supports from Google team. +* AppCompat `1.6.0-alpha03` or higher is required (see [AppCompat release notes](https://developer.android.com/jetpack/androidx/releases/appcompat)) * Remove `LocalizationApplicationDelegate` from Application class * Replace `LocalizationActivity` with `AppCompatActivity` or remove `LocalizationActivityDelegate` from your custom Activity * Replace `setLanguage(language)` with `AppCompatDelegate.setApplicationLocales(LocaleListCompat.forLanguageTags(language))` From 019efa0bdd32c2ce887892abd00dc43c2c5a4faf Mon Sep 17 00:00:00 2001 From: Akexorcist Date: Wed, 22 Jun 2022 04:00:21 +0700 Subject: [PATCH 18/18] Update migrate to AndroidX guide --- MIGRATE_TO_ANDROIDX.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/MIGRATE_TO_ANDROIDX.md b/MIGRATE_TO_ANDROIDX.md index b06057c..1fe49ac 100644 --- a/MIGRATE_TO_ANDROIDX.md +++ b/MIGRATE_TO_ANDROIDX.md @@ -4,7 +4,11 @@ Since AndroidX supports per-app language preferences for backward compatibility. * AppCompat `1.6.0-alpha03` or higher is required (see [AppCompat release notes](https://developer.android.com/jetpack/androidx/releases/appcompat)) * Remove `LocalizationApplicationDelegate` from Application class * Replace `LocalizationActivity` with `AppCompatActivity` or remove `LocalizationActivityDelegate` from your custom Activity -* Replace `setLanguage(language)` with `AppCompatDelegate.setApplicationLocales(LocaleListCompat.forLanguageTags(language))` +* Replace `setLanguage(language)` with `AppCompatDelegate.setApplicationLocales()` +```kotlin +val locales = LocaleListCompat.forLanguageTags(language) +AppCompatDelegate.setApplicationLocales(locales) +``` * Remove `toLocalizedContext()` and use original Context * Remove `LocalizationServiceDelegate` from Service class * Add `androidx.appcompat.app.AppLocalesMetadataHolderService` as `` in Android Manifest (see [Support Android 12 and lower](https://developer.android.com/about/versions/13/features/app-languages#android12-impl))