Skip to content

Commit

Permalink
android 32 support + updates
Browse files Browse the repository at this point in the history
  • Loading branch information
mhashim6 committed Oct 6, 2022
1 parent a80f2ca commit 3387751
Show file tree
Hide file tree
Showing 35 changed files with 168 additions and 129 deletions.
33 changes: 17 additions & 16 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 28
compileSdkVersion 32
defaultConfig {
applicationId "mhashim6.android.thetwoauthentics"
minSdkVersion 15
targetSdkVersion 26
versionCode 30
versionName "1.9.9.5"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
minSdkVersion 16
targetSdkVersion 32
versionCode 31
versionName "1.9.9.6"
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
vectorDrawables.useSupportLibrary = true
resConfigs "en", "ar"
buildToolsVersion "28.0.3"
buildToolsVersion "31.0.0"
}
buildTypes {
release {
Expand All @@ -30,20 +30,21 @@ android {
}

dependencies {
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'androidx.recyclerview:recyclerview:1.2.1'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.readystatesoftware.sqliteasset:sqliteassethelper:2.0.1'
implementation 'uk.co.chrisjenx:calligraphy:2.2.0'
implementation 'io.github.inflationx:calligraphy3:3.1.1'
implementation 'io.github.inflationx:viewpump:2.0.3'
implementation 'com.github.javiersantos:AppUpdater:2.6.1'
implementation 'com.android.support:customtabs:28.0.0'
implementation 'androidx.browser:browser:1.4.0'
implementation 'com.github.hotchemi:android-rate:1.0.1'
testImplementation 'junit:junit:4.12'
testImplementation 'junit:junit:4.13.2'
}
repositories {
mavenCentral()
Expand Down
6 changes: 4 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
android:configChanges="orientation"
android:launchMode="singleTop"
android:noHistory="true"
android:theme="@style/SplashTheme">
android:theme="@style/SplashTheme"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
Expand All @@ -38,7 +39,8 @@
android:name=".app.results.ResultsActivity">
</activity>

<activity android:name=".app.AboutActivity">
<activity android:name=".app.AboutActivity"
android:exported="true">
<intent-filter>
<action android:name="alsahihan.about.action"/>
<category android:name="android.intent.category.DEFAULT"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.widget.AppCompatButton;
import android.support.v7.widget.AppCompatTextView;
import androidx.appcompat.widget.AppCompatButton;
import androidx.appcompat.widget.AppCompatTextView;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Toast;
Expand Down
31 changes: 17 additions & 14 deletions app/src/main/java/mhashim6/android/thetwoauthentics/app/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@
import android.content.res.Resources;
import android.os.Build;
import android.preference.PreferenceManager;
import android.support.annotation.NonNull;

import androidx.annotation.NonNull;

import java.util.Locale;

import io.github.inflationx.calligraphy3.CalligraphyConfig;
import io.github.inflationx.calligraphy3.CalligraphyInterceptor;
import io.github.inflationx.viewpump.ViewPump;
import mhashim6.android.thetwoauthentics.R;
import uk.co.chrisjenx.calligraphy.CalligraphyConfig;

/**
* Created by mhashim6 on 12/07/2017.
Expand All @@ -23,13 +26,13 @@ public class App extends Application {
public void onCreate() {
super.onCreate();

CalligraphyConfig.initDefault(new CalligraphyConfig.Builder()
.setDefaultFontPath("fonts/calibri.ttf")
.setFontAttrId(R.attr.fontPath)
.build()
);

initLocale(getApplicationContext());
ViewPump.init(ViewPump.builder()
.addInterceptor(new CalligraphyInterceptor(
new CalligraphyConfig.Builder()
.setDefaultFontPath("fonts/calibri.ttf")
.setFontAttrId(R.attr.fontPath)
.build()))
.build());

/* Thread.setDefaultUncaughtExceptionHandler((thread, throwable) -> {
Log.d("hi", "lol");
Expand All @@ -43,16 +46,16 @@ public void onCreate() {
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
initLocale(getApplicationContext());
initLocale(getBaseContext());
}

public void initLocale(@NonNull Context context) {
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
public static void initLocale(@NonNull Context context) {
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
boolean forceArabic = preferences.getBoolean("arabic_key", false);

final Locale locale;
if (forceArabic)
locale = new Locale("ar");
locale = new Locale("ar", "EG");
else
locale = Resources.getSystem().getConfiguration().locale;

Expand All @@ -63,7 +66,7 @@ public void initLocale(@NonNull Context context) {
}*/
}

private void setLocale(@NonNull Context context, @NonNull Locale locale) {
private static void setLocale(@NonNull Context context, @NonNull Locale locale) {
final Resources resources = context.getResources();
Configuration config = resources.getConfiguration();
config.locale = locale;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package mhashim6.android.thetwoauthentics.app;

import android.content.Context;
import android.support.v4.content.res.ResourcesCompat;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import androidx.core.content.res.ResourcesCompat;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.widget.ProgressBar;

import io.github.inflationx.viewpump.ViewPumpContextWrapper;
import mhashim6.android.thetwoauthentics.R;
import uk.co.chrisjenx.calligraphy.CalligraphyContextWrapper;

/**
* Created by mhashim6 on 19/09/2017.
Expand All @@ -29,6 +29,7 @@ protected void initToolBar(String title, boolean setDisplayHomeAsUpEnabled) {

@Override
protected void attachBaseContext(Context newBase) {
super.attachBaseContext(CalligraphyContextWrapper.wrap(newBase));
super.attachBaseContext(ViewPumpContextWrapper.wrap(newBase));
App.initLocale(this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.AppCompatImageButton;
import android.support.v7.widget.SearchView;
import com.google.android.material.snackbar.Snackbar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.AppCompatImageButton;
import androidx.appcompat.widget.SearchView;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
Expand Down Expand Up @@ -120,6 +120,7 @@ public boolean onCreateOptionsMenu(Menu menu) {

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == AppCompatActivity.RESULT_OK) {
recreate();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import android.preference.CheckBoxPreference;
import android.preference.PreferenceFragment;
import android.preference.PreferenceManager;
import android.support.v7.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatActivity;

import mhashim6.android.thetwoauthentics.R;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatActivity;

import static mhashim6.android.thetwoauthentics.app.Utils.WORKERS;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import android.content.Intent;
import android.graphics.Color;
import android.net.Uri;
import android.support.customtabs.CustomTabsIntent;
import android.support.v7.app.AppCompatActivity;
import androidx.browser.customtabs.CustomTabsIntent;
import androidx.appcompat.app.AppCompatActivity;
import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.style.ForegroundColorSpan;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
import android.os.Handler;
import android.os.Looper;
import android.preference.PreferenceManager;
import android.support.design.widget.Snackbar;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import com.google.android.material.snackbar.Snackbar;
import com.google.android.material.tabs.TabLayout;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;
import androidx.viewpager.widget.ViewPager;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
Expand Down Expand Up @@ -165,6 +165,7 @@ public boolean onCreateOptionsMenu(Menu menu) {

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == RESULT_OK) {
setResult(RESULT_OK);
finish();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
import android.app.Activity;
import android.content.Context;
import android.os.SystemClock;
import android.support.design.widget.Snackbar;
import android.support.v7.widget.AppCompatImageButton;
import android.support.v7.widget.AppCompatTextView;
import android.support.v7.widget.RecyclerView;

import com.google.android.material.snackbar.Snackbar;

import androidx.appcompat.widget.AppCompatImageButton;
import androidx.appcompat.widget.AppCompatTextView;
import androidx.recyclerview.widget.RecyclerView;

import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
Expand Down Expand Up @@ -116,12 +119,11 @@ public void onClick(View view) { //option button action.
PopupMenu popup = new PopupMenu(context, view);
Menu menu = popup.getMenu();
MenuInflater inflater = popup.getMenuInflater();
inflater.inflate(R.menu.menu_hadith_options, menu);

if (TYPE == ResultsActivity.SEARCH)
menu.add(Menu.NONE, R.id.save_item, Menu.NONE, R.string.save);
inflater.inflate(R.menu.menu_hadith_options, menu);
else
menu.add(Menu.NONE, R.id.remove_item, Menu.NONE, R.string.remove);
inflater.inflate(R.menu.menu_saved_hadith_options, menu);

popup.setOnMenuItemClickListener(HadithViewHolder.this);
popup.show();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@


import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.DefaultItemAnimator;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package mhashim6.android.thetwoauthentics.app.results;

import android.support.annotation.Nullable;
import androidx.annotation.Nullable;

import java.util.Collections;
import java.util.List;
Expand Down
10 changes: 5 additions & 5 deletions app/src/main/res/layout-land/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
layout="@layout/toolbar">
</include>

<android.support.v7.widget.CardView
<androidx.cardview.widget.CardView
android:layout_width="450dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
Expand All @@ -35,7 +35,7 @@
android:orientation="horizontal"
>

<android.support.v7.widget.AppCompatImageButton
<androidx.appcompat.widget.AppCompatImageButton
android:id="@+id/search_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
Expand All @@ -46,7 +46,7 @@
android:src="@drawable/search_icon_tinted"
app:backgroundTint="@android:color/transparent"/>

<android.support.v7.widget.SearchView
<androidx.appcompat.widget.SearchView
android:id="@+id/search_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand All @@ -59,13 +59,13 @@
/>
</LinearLayout>

<android.support.v7.widget.AppCompatTextView
<androidx.appcompat.widget.AppCompatTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="15dp"
android:text="@string/search_guide"/>

</LinearLayout>
</android.support.v7.widget.CardView>
</androidx.cardview.widget.CardView>

</LinearLayout>
2 changes: 1 addition & 1 deletion app/src/main/res/layout-land/recycler_view.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.RecyclerView
<androidx.recyclerview.widget.RecyclerView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
Expand Down
Loading

0 comments on commit 3387751

Please sign in to comment.