Skip to content
This repository was archived by the owner on Jun 22, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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"
Expand Down
6 changes: 4 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
buildscript {
project.ext {
kotlin_version = '1.4.32'
compileSdkVersion = 30
targetSdkVersion = 30
compileSdkVersion = 31
targetSdkVersion = 31
minSdkVersion = 14

targetJavaVersion = JavaVersion.VERSION_1_8

versionName = '1.2.10'
versionCode = 10210

Expand Down
10 changes: 9 additions & 1 deletion localization/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -29,7 +37,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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand Down