Skip to content
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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
29 changes: 17 additions & 12 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android'

android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
compileSdkVersion 29
buildToolsVersion '29.0.3'

defaultConfig {
applicationId "com.ahmedjazzar.rosetta.app"
minSdkVersion 14
targetSdkVersion 23
minSdkVersion 15
targetSdkVersion 29
versionCode 1
versionName "0.9.3"
}
Expand All @@ -20,12 +22,15 @@ android {
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'

testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:1.10.19'

compile project(':rosetta')
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.google.android.material:material:1.1.0'
testImplementation 'junit:junit:4.13'
testImplementation 'org.mockito:mockito-core:2.23.0'
implementation project(':rosetta')
implementation "androidx.core:core-ktx:1.2.0"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
repositories {
mavenCentral()
}
6 changes: 3 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@
package="com.ahmedjazzar.rosetta.app">

<application
android:name=".MainApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:name=".MainApplication" >
android:theme="@style/AppTheme">

<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
Expand Down
29 changes: 29 additions & 0 deletions app/src/main/java/com/ahmedjazzar/rosetta/app/BaseActivity.java
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 androidx.appcompat.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);
Copy link
Owner

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.

Copy link
Owner

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?


}

@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);
}
}
16 changes: 6 additions & 10 deletions app/src/main/java/com/ahmedjazzar/rosetta/app/MainActivity.java
Original file line number Diff line number Diff line change
@@ -1,27 +1,23 @@
package com.ahmedjazzar.rosetta.app;

import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.view.View;
import android.view.Menu;
import android.view.MenuItem;

import com.ahmedjazzar.rosetta.LanguageSwitcher;

import java.util.Locale;

public class MainActivity extends AppCompatActivity {
public class MainActivity extends BaseActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
Toolbar toolbar = findViewById(R.id.toolbar);

// This floating button switching between Arabic and English Locales manually upon click
final FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
final FloatingActionButton fab = findViewById(R.id.fab);
setSupportActionBar(toolbar);

if (MainApplication.languageSwitcher.getCurrentLocale().getLanguage().equals("ar")) {
Expand Down
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;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why all these unused imports?

Copy link
Owner

Choose a reason for hiding this comment

The 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;
Expand Down
12 changes: 6 additions & 6 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.ahmedjazzar.rosetta.app.MainActivity">

<android.support.design.widget.AppBarLayout
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">

<android.support.v7.widget.Toolbar
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay" />

</android.support.design.widget.AppBarLayout>
</com.google.android.material.appbar.AppBarLayout>

<include layout="@layout/content_main" />

<android.support.design.widget.FloatingActionButton
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/fab_margin"
android:src="@drawable/ic_action_name" />

</android.support.design.widget.CoordinatorLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
2 changes: 1 addition & 1 deletion app/src/main/res/values-v21/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this change necessary?

Copy link
Author

Choose a reason for hiding this comment

The 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>
6 changes: 5 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.3.71'
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
classpath 'com.android.tools.build:gradle:3.6.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand All @@ -15,6 +18,7 @@ buildscript {
allprojects {
repositories {
jcenter()
google()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we using this repository?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is required by Latest Compat Libraries

}
}

Expand Down
4 changes: 3 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
# org.gradle.parallel=true
android.enableJetifier=true
android.useAndroidX=true
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed Oct 21 11:34:03 PDT 2015
#Mon Mar 30 15:47:02 GST 2020
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-5.6.4-all.zip
37 changes: 23 additions & 14 deletions rosetta/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android'

ext {
bintrayRepo = 'maven'
Expand All @@ -14,7 +16,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'
Expand All @@ -29,11 +31,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.8.4'
classpath 'com.android.tools.build:gradle:3.6.1'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
}
}

Expand All @@ -45,12 +48,12 @@ android {
maven { url 'http://repo1.maven.org/maven2' }
}

compileSdkVersion 23
buildToolsVersion "23.0.2"
compileSdkVersion 29
buildToolsVersion '29.0.3'

defaultConfig {
minSdkVersion 14
targetSdkVersion 23
minSdkVersion 15
targetSdkVersion 29
versionCode 3
versionName "1.0.1"
}
Expand All @@ -64,11 +67,17 @@ 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.13'
testImplementation 'org.mockito:mockito-core:2.23.0'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.jakewharton:process-phoenix:2.0.0'
implementation "androidx.core:core-ktx:1.2.0"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
repositories {
mavenCentral()
}

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'
Copy link
Owner

Choose a reason for hiding this comment

The 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'
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to comment as well, just remove the line.

2 changes: 1 addition & 1 deletion rosetta/src/main/AndroidManifest.xml
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>
42 changes: 42 additions & 0 deletions rosetta/src/main/java/com/ahmedjazzar/rosetta/ContextWrapper.java
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
Expand Up @@ -2,8 +2,8 @@

import android.app.Activity;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v4.app.FragmentActivity;
import androidx.annotation.NonNull;
import androidx.fragment.app.FragmentActivity;

import java.util.HashSet;
import java.util.Locale;
Expand Down
Loading