Skip to content

Commit

Permalink
Merge pull request #6 from faisalcodes/master
Browse files Browse the repository at this point in the history
Kotlin migration
  • Loading branch information
faisalcodes authored Jan 30, 2023
2 parents daad277 + 2bf3b58 commit db28c93
Show file tree
Hide file tree
Showing 30 changed files with 181 additions and 514 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;

@SuppressWarnings("RegExpRedundantEscape")
public class RecitationUtils {
public static final String DIR_NAME = FileUtils.createPath(AppUtils.BASE_APP_DOWNLOADED_SAVED_DATA_DIR, "recitations");
public static final Pattern URL_CHAPTER_PATTERN = Pattern.compile("\\{chapNo:(.*?)\\}", Pattern.CASE_INSENSITIVE);
Expand All @@ -55,16 +54,6 @@ public class RecitationUtils {
public static final String KEY_RECITATION_REPEAT = "key.recitation.repeat";
public static final String KEY_RECITATION_CONTINUE_CHAPTER = "key.recitation.continue_chapter";
public static final String KEY_RECITATION_VERSE_SYNC = "key.recitation.verse_sync";

/*public static final String REC_MISHARY_RASHID = "mishary-rashid";
public static final String REC_AS_SUDAIS = "as-sudais";
public static final String REC_AR_RIFAI = "ar-rifai";
public static final String REC_ABDUL_BASIT = "abdul-basit";
public static final String REC_AL_SHATRI = "al-shatri";
public static final String REC_AL_SHURAYM = "as-shuraym";
public static final String RECITATION_DEFAULT_RECITER = REC_AR_RIFAI;*/

public static final boolean RECITATION_DEFAULT_REPEAT = false;
public static final boolean RECITATION_DEFAULT_CONTINUE_CHAPTER = true;
public static final boolean RECITATION_DEFAULT_VERSE_SYNC = true;
Expand Down
34 changes: 17 additions & 17 deletions app/src/main/java/com/quranapp/android/utils/sp/SPReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,16 @@
import static com.quranapp.android.utils.reader.TextSizeUtils.TEXT_SIZE_MULT_AR_DEFAULT;
import static com.quranapp.android.utils.reader.TextSizeUtils.TEXT_SIZE_MULT_TRANS_DEFAULT;
import static com.quranapp.android.utils.reader.TranslUtils.KEY_TRANSLATIONS;
import static com.quranapp.android.utils.reader.recitation.RecitationUtils.KEY_RECITATION_CONTINUE_CHAPTER;
import static com.quranapp.android.utils.reader.recitation.RecitationUtils.KEY_RECITATION_RECITER;
import static com.quranapp.android.utils.reader.recitation.RecitationUtils.KEY_RECITATION_REPEAT;
import static com.quranapp.android.utils.reader.recitation.RecitationUtils.KEY_RECITATION_VERSE_SYNC;
import static com.quranapp.android.utils.reader.recitation.RecitationUtils.RECITATION_DEFAULT_CONTINUE_CHAPTER;
import static com.quranapp.android.utils.reader.recitation.RecitationUtils.RECITATION_DEFAULT_REPEAT;
import static com.quranapp.android.utils.reader.recitation.RecitationUtils.RECITATION_DEFAULT_VERSE_SYNC;
import static com.quranapp.android.utils.univ.Keys.READER_KEY_READER_STYLE;

import android.content.Context;
import android.content.SharedPreferences;

import com.quranapp.android.utils.reader.TranslUtils;
import com.quranapp.android.utils.reader.recitation.RecitationUtils;
import com.quranapp.android.utils.univ.Keys;

import java.util.HashSet;
import java.util.Set;
Expand Down Expand Up @@ -132,10 +129,10 @@ public static boolean getRecitationRepeatVerse(Context context) {
SharedPreferences sp = context.getSharedPreferences(SP_RECITATION_OPTIONS, Context.MODE_PRIVATE);

if (!sp.contains(KEY_RECITATION_REPEAT)) {
setRecitationRepeatVerse(context, RECITATION_DEFAULT_REPEAT);
setRecitationRepeatVerse(context, RecitationUtils.RECITATION_DEFAULT_REPEAT);
}

return sp.getBoolean(KEY_RECITATION_REPEAT, RECITATION_DEFAULT_REPEAT);
return sp.getBoolean(KEY_RECITATION_REPEAT, RecitationUtils.RECITATION_DEFAULT_REPEAT);
}

public static void setRecitationRepeatVerse(Context context, boolean repeatVerse) {
Expand All @@ -148,34 +145,37 @@ public static void setRecitationRepeatVerse(Context context, boolean repeatVerse
public static boolean getRecitationContinueChapter(Context context) {
SharedPreferences sp = context.getSharedPreferences(SP_RECITATION_OPTIONS, Context.MODE_PRIVATE);

if (!sp.contains(KEY_RECITATION_CONTINUE_CHAPTER)) {
setRecitationContinueChapter(context, RECITATION_DEFAULT_CONTINUE_CHAPTER);
if (!sp.contains(RecitationUtils.KEY_RECITATION_CONTINUE_CHAPTER)) {
setRecitationContinueChapter(context, RecitationUtils.RECITATION_DEFAULT_CONTINUE_CHAPTER);
}

return sp.getBoolean(KEY_RECITATION_CONTINUE_CHAPTER, RECITATION_DEFAULT_CONTINUE_CHAPTER);
return sp.getBoolean(
RecitationUtils.KEY_RECITATION_CONTINUE_CHAPTER,
RecitationUtils.RECITATION_DEFAULT_CONTINUE_CHAPTER
);
}

public static void setRecitationContinueChapter(Context context, boolean continueChapter) {
SharedPreferences sp = context.getSharedPreferences(SP_RECITATION_OPTIONS, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sp.edit();
editor.putBoolean(KEY_RECITATION_CONTINUE_CHAPTER, continueChapter);
editor.putBoolean(RecitationUtils.KEY_RECITATION_CONTINUE_CHAPTER, continueChapter);
editor.apply();
}

public static boolean getRecitationScrollSync(Context context) {
SharedPreferences sp = context.getSharedPreferences(SP_RECITATION_OPTIONS, Context.MODE_PRIVATE);

if (!sp.contains(KEY_RECITATION_VERSE_SYNC)) {
if (!sp.contains(RecitationUtils.KEY_RECITATION_VERSE_SYNC)) {
setRecitationVerseSync(context, RECITATION_DEFAULT_VERSE_SYNC);
}

return sp.getBoolean(KEY_RECITATION_VERSE_SYNC, RECITATION_DEFAULT_VERSE_SYNC);
return sp.getBoolean(RecitationUtils.KEY_RECITATION_VERSE_SYNC, RECITATION_DEFAULT_VERSE_SYNC);
}

public static void setRecitationVerseSync(Context context, boolean sync) {
SharedPreferences sp = context.getSharedPreferences(SP_RECITATION_OPTIONS, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sp.edit();
editor.putBoolean(KEY_RECITATION_VERSE_SYNC, sync);
editor.putBoolean(RecitationUtils.KEY_RECITATION_VERSE_SYNC, sync);
editor.apply();
}

Expand All @@ -199,18 +199,18 @@ public static void setSavedScript(Context context, String font) {
public static int getSavedReaderStyle(Context context) {
SharedPreferences sp = context.getSharedPreferences(SP_READER_STYLE, Context.MODE_PRIVATE);

if (!sp.contains(READER_KEY_READER_STYLE)) {
if (!sp.contains(Keys.READER_KEY_READER_STYLE)) {
setSavedReaderStyle(context, READER_STYLE_DEFAULT);
}

sp = context.getSharedPreferences(SP_READER_STYLE, Context.MODE_PRIVATE);
return sp.getInt(READER_KEY_READER_STYLE, READER_STYLE_DEFAULT);
return sp.getInt(Keys.READER_KEY_READER_STYLE, READER_STYLE_DEFAULT);
}

public static void setSavedReaderStyle(Context context, int readerStyle) {
SharedPreferences sp = context.getSharedPreferences(SP_READER_STYLE, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sp.edit();
editor.putInt(READER_KEY_READER_STYLE, readerStyle);
editor.putInt(Keys.READER_KEY_READER_STYLE, readerStyle);
editor.apply();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public ActivityBuffer() {
/**
* Executes the Runnable if there's an available Context. Otherwise, defers execution until it becomes available.
*/
public final void safely(final ActivityAvailableListener<R> listener) {
public void safely(final ActivityAvailableListener<R> listener) {
// Synchronize along the current instance.
synchronized (this) {
// Do we have a context available?
Expand All @@ -54,7 +54,7 @@ public final void safely(final ActivityAvailableListener<R> listener) {
/**
* Called to inform the ActivityBuffer that there's an available Activity reference.
*/
public final void onActivityGained(final R activity) {
public void onActivityGained(final R activity) {
// Synchronize along ourself.
synchronized (this) {
// Update the Activity reference.
Expand All @@ -78,7 +78,7 @@ public final void onActivityGained(final R activity) {
/**
* Called to inform the ActivityBuffer that the Context has been lost.
*/
public final void onActivityLost() {
public void onActivityLost() {
// Synchronize along ourself.
synchronized (this) {
// Remove the Context reference.
Expand All @@ -89,7 +89,7 @@ public final void onActivityLost() {
/**
* Defines whether there's a safe Context available for the ActivityBuffer.
*/
public final boolean isContextAvailable() {
public boolean isContextAvailable() {
// Synchronize upon ourself.
synchronized (this) {
// Return the state of the Activity reference.
Expand Down

This file was deleted.

19 changes: 19 additions & 0 deletions app/src/main/java/com/quranapp/android/utils/univ/ActivityUtils.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.quranapp.android.utils.univ

import android.content.Context
import android.content.Intent
import android.net.Uri
import android.provider.Settings

object ActivityUtils {
fun openAppDetailsActivity(context: Context) {
val settingIntent = Intent()
settingIntent.action = Settings.ACTION_APPLICATION_DETAILS_SETTINGS
settingIntent.addCategory(Intent.CATEGORY_DEFAULT)
settingIntent.data = Uri.parse("package:" + context.packageName)
settingIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
settingIntent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY)
settingIntent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS)
context.startActivity(settingIntent)
}
}
189 changes: 0 additions & 189 deletions app/src/main/java/com/quranapp/android/utils/univ/BitmapUtils.java

This file was deleted.

Loading

0 comments on commit db28c93

Please sign in to comment.