-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Android Oreo Issues Has Been Resolved. #30
base: master
Are you sure you want to change the base?
Changes from 3 commits
1c645f3
7857e40
b59f924
e1f647b
aa011ce
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.ahmedjazzar.rosetta.app; | ||
|
||
import android.content.Context; | ||
import android.content.SharedPreferences; | ||
import android.os.Bundle; | ||
import android.preference.PreferenceManager; | ||
import android.support.v7.app.AppCompatActivity; | ||
|
||
import com.ahmedjazzar.rosetta.ContextWrapper; | ||
|
||
import java.util.Locale; | ||
|
||
public abstract class BaseActivity extends AppCompatActivity { | ||
SharedPreferences mSharedPreferences; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
|
||
} | ||
|
||
@Override | ||
protected void attachBaseContext(Context newBase) { | ||
mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(newBase); | ||
Locale locale = new Locale(mSharedPreferences.getString("user_preferred_language", "en")); | ||
Context context = ContextWrapper.wrap(newBase, locale); | ||
super.attachBaseContext(context); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
package com.ahmedjazzar.rosetta.app; | ||
|
||
import android.app.Application; | ||
import android.content.Context; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why all these unused imports? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @zeeshanrasool91 Any updates on these? |
||
import android.content.SharedPreferences; | ||
import android.preference.PreferenceManager; | ||
|
||
import com.ahmedjazzar.rosetta.ContextWrapper; | ||
import com.ahmedjazzar.rosetta.LanguageSwitcher; | ||
|
||
import java.util.HashSet; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,6 @@ | |
<item name="windowActionBar">false</item> | ||
<item name="windowNoTitle">true</item> | ||
<item name="android:windowDrawsSystemBarBackgrounds">true</item> | ||
<item name="android:statusBarColor">@android:color/transparent</item> | ||
<item name="android:statusBarColor">@color/colorPrimaryDark</item> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this change necessary? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it was actually showing me transparent view on my Lollipop device. |
||
</style> | ||
</resources> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,9 +3,10 @@ | |
buildscript { | ||
repositories { | ||
jcenter() | ||
google() | ||
} | ||
dependencies { | ||
classpath 'com.android.tools.build:gradle:1.5.0' | ||
classpath 'com.android.tools.build:gradle:3.1.3' | ||
|
||
// NOTE: Do not place your application dependencies here; they belong | ||
// in the individual module build.gradle files | ||
|
@@ -15,6 +16,7 @@ buildscript { | |
allprojects { | ||
repositories { | ||
jcenter() | ||
google() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are we using this repository? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it is required by Latest Compat Libraries |
||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#Wed Oct 21 11:34:03 PDT 2015 | ||
#Thu Jun 21 17:34:17 PKT 2018 | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.8-all.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ ext { | |
siteUrl = 'https://github.com/ahmedaljazzar/rosetta' | ||
gitUrl = 'https://github.com/ahmedaljazzar/rosetta.git' | ||
|
||
libraryVersion = '1.0.1' | ||
libraryVersion = '1.0.2' | ||
|
||
developerId = 'ahmedaljazzar' | ||
developerName = 'Ahmed Jazzar' | ||
|
@@ -29,11 +29,12 @@ buildscript { | |
repositories { | ||
jcenter() | ||
mavenCentral() | ||
google() | ||
} | ||
dependencies { | ||
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.4' | ||
classpath 'com.android.tools.build:gradle:1.2.3' | ||
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3' | ||
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3' | ||
classpath 'com.android.tools.build:gradle:3.1.3' | ||
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0' | ||
} | ||
} | ||
|
||
|
@@ -45,12 +46,12 @@ android { | |
maven { url 'http://repo1.maven.org/maven2' } | ||
} | ||
|
||
compileSdkVersion 23 | ||
buildToolsVersion "23.0.2" | ||
compileSdkVersion 27 | ||
buildToolsVersion '27.0.3' | ||
|
||
defaultConfig { | ||
minSdkVersion 14 | ||
targetSdkVersion 23 | ||
minSdkVersion 15 | ||
targetSdkVersion 27 | ||
versionCode 3 | ||
versionName "1.0.1" | ||
} | ||
|
@@ -64,11 +65,12 @@ android { | |
} | ||
|
||
dependencies { | ||
compile fileTree(dir: 'libs', include: ['*.jar']) | ||
testCompile 'junit:junit:4.12' | ||
testCompile 'org.mockito:mockito-core:1.10.19' | ||
compile 'com.android.support:appcompat-v7:23.1.1' | ||
implementation fileTree(dir: 'libs', include: ['*.jar']) | ||
testImplementation 'junit:junit:4.12' | ||
testImplementation 'org.mockito:mockito-core:2.7.22' | ||
implementation 'com.android.support:appcompat-v7:27.1.1' | ||
implementation 'com.jakewharton:process-phoenix:2.0.0' | ||
} | ||
|
||
apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/installv1.gradle' | ||
apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/bintrayv1.gradle' | ||
//apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/installv1.gradle' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need to comment, just remove the line. |
||
//apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/bintrayv1.gradle' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need to comment as well, just remove the line. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.ahmedjazzar.rosetta"> | ||
|
||
<application android:supportsRtl="true" /> | ||
<application android:supportsRtl="true"/> | ||
</manifest> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.ahmedjazzar.rosetta; | ||
|
||
import android.content.Context; | ||
import android.content.res.Configuration; | ||
import android.content.res.Resources; | ||
import android.os.Build; | ||
import android.os.LocaleList; | ||
|
||
import java.util.Locale; | ||
|
||
public class ContextWrapper extends android.content.ContextWrapper { | ||
|
||
public ContextWrapper(Context base) { | ||
super(base); | ||
} | ||
|
||
public static ContextWrapper wrap(Context context, Locale newLocale) { | ||
|
||
Resources res = context.getResources(); | ||
Configuration configuration = res.getConfiguration(); | ||
|
||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { | ||
configuration.setLocale(newLocale); | ||
|
||
LocaleList localeList = new LocaleList(newLocale); | ||
LocaleList.setDefault(localeList); | ||
configuration.setLocales(localeList); | ||
|
||
context = context.createConfigurationContext(configuration); | ||
|
||
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { | ||
configuration.setLocale(newLocale); | ||
context = context.createConfigurationContext(configuration); | ||
|
||
} else { | ||
configuration.locale = newLocale; | ||
res.updateConfiguration(configuration, res.getDisplayMetrics()); | ||
} | ||
|
||
return new ContextWrapper(context); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,8 @@ | |
import android.widget.Button; | ||
import android.widget.TextView; | ||
|
||
import com.jakewharton.processphoenix.ProcessPhoenix; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Locale; | ||
|
||
|
@@ -153,7 +155,8 @@ protected void onPositiveClick() { | |
getActivity(), mSelectedLanguage)) { | ||
|
||
mLogger.info("App locale changed successfully."); | ||
LocalesUtils.refreshApplication(getActivity()); | ||
//LocalesUtils.refreshApplication(getActivity()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just remove it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. when i was using your refresh method the problem was that it was recreating application and current activity both. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cool with me, but just no need to comment, removing the line is enough. |
||
ProcessPhoenix.triggerRebirth(getActivity()); | ||
} else { | ||
mLogger.error("Unsuccessful trial to change the App locale."); | ||
// TODO: notify the user that his request not placed | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,8 @@ | |
import android.support.v4.app.FragmentActivity; | ||
import android.util.DisplayMetrics; | ||
|
||
import com.jakewharton.processphoenix.ProcessPhoenix; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.HashSet; | ||
|
@@ -265,7 +267,8 @@ static boolean setLocale(Locale newLocale, Activity activity) { | |
} | ||
|
||
if (LocalesUtils.setAppLocale(activity.getApplicationContext(), newLocale)) { | ||
LocalesUtils.refreshApplication(activity); | ||
//LocalesUtils.refreshApplication(activity); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just remove it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. when i was using your refresh method the problem was that it was recreating application and current activity both. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cool with me, but just no need to comment, removing the line is enough. |
||
ProcessPhoenix.triggerRebirth(activity); | ||
return true; | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for this method if it doesn't contain changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zeeshanrasool91 Any updates ion this?