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

Widget and kotlin migration #89

Merged
merged 6 commits into from
Mar 6, 2023
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions app/src/main/java/com/quranapp/android/QuranApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import android.content.Context
import android.os.Build
import android.webkit.WebView
import androidx.appcompat.app.AppCompatDelegate
import com.quranapp.android.utils.exceptions.CustomExceptionHandler
import com.quranapp.android.utils.app.NotificationUtils
import com.quranapp.android.utils.app.ThemeUtils
import com.quranapp.android.utils.exceptions.CustomExceptionHandler

class QuranApp : Application() {
override fun attachBaseContext(base: Context) {
Expand Down Expand Up @@ -35,4 +35,4 @@ class QuranApp : Application() {
// Handler for uncaught exceptions
Thread.setDefaultUncaughtExceptionHandler(CustomExceptionHandler(this))
}
}
}
41 changes: 30 additions & 11 deletions app/src/main/java/com/quranapp/android/activities/ActivityAbout.kt
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ class ActivityAbout : BaseActivity() {
setup(
binding,
LytReaderSettingsItemBinding.inflate(layoutInflater).apply {
root.setOnClickListener { AppBridge.newOpener(it.context).browseLink(ApiConfig.GITHUB_REPOSITORY_URL) }
root.setOnClickListener {
AppBridge.newOpener(it.context).browseLink(ApiConfig.GITHUB_REPOSITORY_URL)
}
},
R.drawable.icon_github,
R.string.github
Expand Down Expand Up @@ -102,18 +104,36 @@ class ActivityAbout : BaseActivity() {
parent.container.addView(binding.root)
}

private fun prepareTitle(binding: LytReaderSettingsItemBinding, titleRes: Int, subtitle: String?) {
private fun prepareTitle(
binding: LytReaderSettingsItemBinding,
titleRes: Int,
subtitle: String?
) {
val ssb = SpannableStringBuilder()

ssb.append(SpannableString(str(titleRes)).apply {
setSpan(StyleSpan(Typeface.BOLD), 0, length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
})
ssb.append(
SpannableString(str(titleRes)).apply {
setSpan(StyleSpan(Typeface.BOLD), 0, length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
}
)

if (!subtitle.isNullOrEmpty()) {
ssb.append("\n").append(SpannableString(subtitle).apply {
setSpan(AbsoluteSizeSpan(dimen(R.dimen.dmnCommonSize2)), 0, length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
setSpan(ForegroundColorSpan(color(R.color.colorText3)), 0, length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
})
ssb.append("\n").append(
SpannableString(subtitle).apply {
setSpan(
AbsoluteSizeSpan(dimen(R.dimen.dmnCommonSize2)),
0,
length,
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
)
setSpan(
ForegroundColorSpan(color(R.color.colorText3)),
0,
length,
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
)
}
)
}

binding.launcher.text = ssb
Expand All @@ -127,11 +147,10 @@ class ActivityAbout : BaseActivity() {
textView.setDrawables(drawable(startIconRes), null, chevronRight, null)
}


private fun setupLauncherParams(launcherView: View) {
launcherView.layoutParams = LinearLayout.LayoutParams(MATCH_PARENT, WRAP_CONTENT).apply {
updateMarginVertical(dp2px(5f))
updateMarginHorizontal(dp2px(10f))
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.GridLayoutManager;
Expand Down Expand Up @@ -137,8 +136,9 @@ public void onRightIconClick() {

private void deleteAllWithCheckpoint() {
boolean isSelecting = mAdapter != null && mAdapter.mIsSelecting && !mAdapter.mSelectedModels.isEmpty();
String title = isSelecting ? getString(R.string.strTitleBookmarkDeleteCount, mAdapter.mSelectedModels.size()) : getString(
R.string.strTitleBookmarkDeleteAll);
String title = isSelecting ? getString(R.string.strTitleBookmarkDeleteCount,
mAdapter.mSelectedModels.size()) : getString(
R.string.strTitleBookmarkDeleteAll);
int dec = isSelecting ? R.string.strMsgBookmarkDeleteSelected : R.string.strMsgBookmarkDeleteAll;
int labelNeg = isSelecting ? R.string.strLabelRemove : R.string.strLabelRemoveAll;

Expand Down Expand Up @@ -229,7 +229,8 @@ public void onView(BookmarkModel model, int position) {
}

public void onOpen(BookmarkModel model) {
Intent intent = ReaderFactory.prepareVerseRangeIntent(model.getChapterNo(), model.getFromVerseNo(), model.getToVerseNo());
Intent intent = ReaderFactory.prepareVerseRangeIntent(model.getChapterNo(), model.getFromVerseNo(),
model.getToVerseNo());
intent.setClass(this, ActivityReader.class);
startActivity(intent);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,19 @@
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.quranapp.android.utils.exceptions.NoInternetException;
import com.quranapp.android.utils.Log;
import com.peacedesign.android.utils.WindowUtils;
import com.quranapp.android.R;
import com.quranapp.android.components.quran.QuranMeta;
import com.quranapp.android.databinding.ActivityChapterInfoBinding;
import com.quranapp.android.utils.Log;
import com.quranapp.android.utils.Logger;
import com.quranapp.android.utils.chapterInfo.ChapterInfoJSInterface;
import com.quranapp.android.utils.chapterInfo.ChapterInfoUtils;
import com.quranapp.android.utils.chapterInfo.ChapterInfoWebViewClient;
import com.quranapp.android.utils.exceptions.NoInternetException;
import com.quranapp.android.utils.receivers.NetworkStateReceiver;
import com.quranapp.android.utils.thread.runner.CallableTaskRunner;
import com.quranapp.android.utils.thread.tasks.BaseCallableTask;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import android.os.Bundle;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
package com.quranapp.android.activities;

import static com.quranapp.android.components.editor.VerseEditor.BG_ALPHA_DEFAULT;
import static com.quranapp.android.components.editor.VerseEditor.BG_TYPE_COLORS;
import static com.quranapp.android.components.editor.VerseEditor.BG_TYPE_IMAGE;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.graphics.Bitmap;
Expand All @@ -22,12 +18,14 @@
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.Toast;

import androidx.activity.result.ActivityResult;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.viewpager2.widget.ViewPager2;
import static com.quranapp.android.components.editor.VerseEditor.BG_ALPHA_DEFAULT;
import static com.quranapp.android.components.editor.VerseEditor.BG_TYPE_COLORS;
import static com.quranapp.android.components.editor.VerseEditor.BG_TYPE_IMAGE;

import com.peacedesign.android.utils.AppBridge;
import com.peacedesign.android.utils.ColorUtils;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatDelegate;
Expand All @@ -24,7 +23,7 @@
import com.quranapp.android.utils.app.ThemeUtils;
import com.quranapp.android.utils.gesture.HoverPushOpacityEffect;
import com.quranapp.android.utils.sharedPrefs.SPAppActions;
import com.quranapp.android.utils.univ.SimpleTabSelectorListener;
import com.quranapp.android.utils.simplified.SimpleTabSelectorListener;

public class ActivityOnboarding extends BaseActivity {
private ActivityOnboardBinding mBinding;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,6 @@

package com.quranapp.android.activities;

import static android.view.View.GONE;
import static android.view.View.VISIBLE;
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
import static java.util.regex.Pattern.CASE_INSENSITIVE;
import static java.util.regex.Pattern.DOTALL;
import static java.util.regex.Pattern.LITERAL;

import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
Expand All @@ -23,11 +16,16 @@
import android.widget.AdapterView;
import android.widget.EditText;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.LinearLayoutManager;
import static java.util.regex.Pattern.CASE_INSENSITIVE;
import static java.util.regex.Pattern.DOTALL;
import static java.util.regex.Pattern.LITERAL;
import static android.view.View.GONE;
import static android.view.View.VISIBLE;
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;

import com.quranapp.android.R;
import com.quranapp.android.activities.base.BaseActivity;
Expand All @@ -39,7 +37,7 @@
import com.quranapp.android.databinding.ActivityTopicsBinding;
import com.quranapp.android.databinding.LytTopicsActivityHeaderBinding;
import com.quranapp.android.utils.extended.GapedItemDecoration;
import com.quranapp.android.utils.univ.SimpleTextWatcher;
import com.quranapp.android.utils.simplified.SimpleTextWatcher;
import com.quranapp.android.views.helper.Spinner2;

import java.util.ArrayList;
Expand Down Expand Up @@ -119,10 +117,10 @@ private void initHeader(LytTopicsActivityHeaderBinding header) {

EditText searchBox = header.searchContainer.searchBox;
searchBox.setPaddingRelative(
dp2px(5),
searchBox.getPaddingTop(),
searchBox.getPaddingEnd(),
searchBox.getPaddingBottom()
dp2px(5),
searchBox.getPaddingTop(),
searchBox.getPaddingEnd(),
searchBox.getPaddingBottom()
);
header.searchContainer.btnClear.setOnClickListener(v -> header.searchContainer.searchBox.setText(null));
searchBox.setOnFocusChangeListener((v, hasFocus) -> {
Expand All @@ -144,7 +142,8 @@ private void initProphetFilters(Spinner2 spinner) {
}

int itemLayoutRes = R.layout.lyt_topic_filter_spinner_item;
TopicFilterSpinnerAdapter adapter = new TopicFilterSpinnerAdapter(spinner.getContext(), itemLayoutRes, R.id.text, filters);
TopicFilterSpinnerAdapter adapter = new TopicFilterSpinnerAdapter(spinner.getContext(), itemLayoutRes,
R.id.text, filters);
spinner.setAdapterWithDynamicWidth(adapter);

// running it twice before and after setting listener to prevent it to be invoked for the first time.
Expand Down Expand Up @@ -194,7 +193,8 @@ private void toggleSearchBox(LytTopicsActivityHeaderBinding header, boolean show

if (showSearch) {
searchBox.requestFocus();
InputMethodManager imm = (InputMethodManager) searchBox.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
InputMethodManager imm = (InputMethodManager) searchBox.getContext().getSystemService(
Context.INPUT_METHOD_SERVICE);
imm.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, 0);
} else {
searchBox.clearFocus();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
package com.quranapp.android.activities;

import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.GridLayoutManager;
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;

import com.peacedesign.android.utils.WindowUtils;
import com.quranapp.android.R;
Expand Down Expand Up @@ -119,7 +117,8 @@ private void setupAdapter(List<ReadHistoryModel> models) {
}

public void onOpen(ReadHistoryModel model) {
Intent intent = ReaderFactory.prepareVerseRangeIntent(model.getChapterNo(), model.getFromVerseNo(), model.getToVerseNo());
Intent intent = ReaderFactory.prepareVerseRangeIntent(model.getChapterNo(), model.getFromVerseNo(),
model.getToVerseNo());
intent.setClass(this, ActivityReader.class);
startActivity(intent);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
package com.quranapp.android.activities;

import static android.view.View.GONE;
import static android.view.View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
import static android.view.View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;
import static android.view.View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
import static android.view.View.VISIBLE;
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
import static android.view.WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION;
import static android.view.WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
import android.annotation.SuppressLint;
import android.content.Intent;
import android.content.IntentFilter;
import android.graphics.Color;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.text.SpannableStringBuilder;
import android.view.View;
import android.view.Window;
import android.widget.LinearLayout;
import android.widget.Toast;
import androidx.activity.result.ActivityResult;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.core.view.WindowInsetsControllerCompat;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import static com.quranapp.android.components.quran.QuranMeta.canShowBismillah;
import static com.quranapp.android.reader_managers.ReaderParams.READER_READ_TYPE_CHAPTER;
import static com.quranapp.android.reader_managers.ReaderParams.READER_READ_TYPE_JUZ;
Expand All @@ -33,28 +45,14 @@
import static com.quranapp.android.utils.univ.Keys.READER_KEY_TRANSL_SLUGS;
import static com.quranapp.android.utils.univ.Keys.READER_KEY_VERSES;
import static com.quranapp.android.utils.univ.RegexPattern.VERSE_RANGE_PATTERN;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.content.IntentFilter;
import android.graphics.Color;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.text.SpannableStringBuilder;
import android.view.View;
import android.view.Window;
import android.widget.LinearLayout;
import android.widget.Toast;

import androidx.activity.result.ActivityResult;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.core.view.WindowInsetsControllerCompat;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import static android.view.View.GONE;
import static android.view.View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
import static android.view.View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;
import static android.view.View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
import static android.view.View.VISIBLE;
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
import static android.view.WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION;
import static android.view.WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;

import com.quranapp.android.R;
import com.quranapp.android.adapters.ADPQuranPages;
Expand Down Expand Up @@ -475,10 +473,13 @@ private void initQuran(Intent intent) {
}

switch (mReaderParams.readType) {
case READER_READ_TYPE_VERSES: initVerseRange(initialChapter, initVerses); break;
case READER_READ_TYPE_JUZ: initJuz(initJuzNo); break;
case READER_READ_TYPE_VERSES: initVerseRange(initialChapter, initVerses);
break;
case READER_READ_TYPE_JUZ: initJuz(initJuzNo);
break;
case READER_READ_TYPE_CHAPTER:
default: initChapter(initialChapter); break;
default: initChapter(initialChapter);
break;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

Expand All @@ -18,7 +17,7 @@
import com.quranapp.android.frags.readerindex.FragReaderIndexChapters;
import com.quranapp.android.frags.readerindex.FragReaderIndexJuz;
import com.quranapp.android.interfaceUtils.readerIndex.FragReaderIndexCallback;
import com.quranapp.android.utils.univ.SimpleTabSelectorListener;
import com.quranapp.android.utils.simplified.SimpleTabSelectorListener;

import java.util.ArrayList;
import java.util.List;
Expand Down
Loading