mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-22 12:03:09 -04:00
commit
03be00e101
@ -11,7 +11,7 @@ apply(from = rootProject.file("jacoco.gradle"))
|
||||
ext {
|
||||
set("versionMajor", 3)
|
||||
set("versionMinor", 2)
|
||||
set("versionPatch", 0)
|
||||
set("versionPatch", 1)
|
||||
}
|
||||
|
||||
fun generateVersionName() = "${ext["versionMajor"]}.${ext["versionMinor"]}.${ext["versionPatch"]}"
|
||||
|
@ -221,7 +221,7 @@ class ZimHostActivity : BaseActivity(), ZimHostCallbacks, ZimHostContract.View {
|
||||
// Advice user to turn on hotspot manually for API<26
|
||||
private fun startHotspotManuallyDialog() {
|
||||
|
||||
alertDialogShower.show(KiwixDialog.StartHotspotManually(),
|
||||
alertDialogShower.show(KiwixDialog.StartHotspotManually,
|
||||
::launchTetheringSettingsScreen,
|
||||
{},
|
||||
{
|
||||
|
@ -13,7 +13,7 @@ repositories {
|
||||
dependencies {
|
||||
implementation("com.android.tools.build:gradle:3.5.3")
|
||||
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.61")
|
||||
implementation("com.dicedmelon.gradle:jacoco-android:0.1.4")
|
||||
implementation("com.hiya:jacoco-android:0.2")
|
||||
implementation("org.jlleitschuh.gradle:ktlint-gradle:9.2.1")
|
||||
implementation("com.google.apis:google-api-services-androidpublisher:v3-rev129-1.25.0")
|
||||
implementation("io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.5.1")
|
||||
|
@ -263,7 +263,7 @@ object Libs {
|
||||
*/
|
||||
const val collection_ktx: String = "androidx.collection:collection-ktx:" + Versions.collection_ktx
|
||||
|
||||
const val jacoco_android: String = "com.dicedmelon.gradle:jacoco-android:" +
|
||||
const val jacoco_android: String = "com.hiya:jacoco-android:" +
|
||||
Versions.jacoco_android
|
||||
|
||||
/**
|
||||
|
@ -55,7 +55,7 @@ object Versions {
|
||||
|
||||
const val collection_ktx: String = "1.1.0"
|
||||
|
||||
const val jacoco_android: String = "0.1.4"
|
||||
const val jacoco_android: String = "0.2"
|
||||
|
||||
const val junit_jupiter: String = "5.4.2" // available: "5.6.0"
|
||||
|
||||
|
@ -39,7 +39,7 @@ class AllProjectConfigurer {
|
||||
target.plugins.apply("kotlin-android")
|
||||
target.plugins.apply("kotlin-android-extensions")
|
||||
target.plugins.apply("kotlin-kapt")
|
||||
target.plugins.apply("jacoco-android")
|
||||
target.plugins.apply("com.hiya.jacoco-android")
|
||||
target.plugins.apply("org.jlleitschuh.gradle.ktlint")
|
||||
target.plugins.apply("io.gitlab.arturbosch.detekt")
|
||||
}
|
||||
@ -52,12 +52,12 @@ class AllProjectConfigurer {
|
||||
setMinSdkVersion(Config.minSdk)
|
||||
setTargetSdkVersion(Config.targetSdk)
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
multiDexEnabled = true
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
getByName("debug") {
|
||||
isTestCoverageEnabled = true
|
||||
multiDexEnabled = true
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -394,7 +394,7 @@ performance:
|
||||
active: true
|
||||
excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
|
||||
SpreadOperator:
|
||||
active: true
|
||||
active: false
|
||||
excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
|
||||
UnnecessaryTemporaryInstantiation:
|
||||
active: true
|
||||
|
@ -17,13 +17,14 @@
|
||||
*/
|
||||
package org.kiwix.kiwixmobile.core;
|
||||
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.os.Environment;
|
||||
import android.os.StrictMode;
|
||||
import android.util.Log;
|
||||
import androidx.appcompat.app.AppCompatDelegate;
|
||||
import androidx.multidex.MultiDexApplication;
|
||||
import androidx.multidex.MultiDex;
|
||||
import com.jakewharton.threetenabp.AndroidThreeTen;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@ -33,7 +34,7 @@ import org.kiwix.kiwixmobile.core.di.components.CoreComponent;
|
||||
import org.kiwix.kiwixmobile.core.di.components.DaggerCoreComponent;
|
||||
import org.kiwix.kiwixmobile.core.downloader.DownloadMonitor;
|
||||
|
||||
public abstract class CoreApp extends MultiDexApplication {
|
||||
public abstract class CoreApp extends Application {
|
||||
|
||||
private static CoreApp app;
|
||||
private static CoreComponent coreComponent;
|
||||
@ -64,6 +65,9 @@ public abstract class CoreApp extends MultiDexApplication {
|
||||
@Override
|
||||
protected void attachBaseContext(Context base) {
|
||||
super.attachBaseContext(base);
|
||||
if (BuildConfig.DEBUG) {
|
||||
MultiDex.install(this);
|
||||
}
|
||||
app = this;
|
||||
setCoreComponent(DaggerCoreComponent.builder()
|
||||
.context(this)
|
||||
|
@ -25,12 +25,14 @@ import org.kiwix.kiwixmobile.core.di.ActivityScope
|
||||
import org.kiwix.kiwixmobile.core.di.modules.ActivityModule
|
||||
import org.kiwix.kiwixmobile.core.search.SearchActivity
|
||||
import org.kiwix.kiwixmobile.core.search.viewmodel.effects.ShowDeleteSearchDialog
|
||||
import org.kiwix.kiwixmobile.core.settings.CorePrefsFragment
|
||||
|
||||
@ActivityScope
|
||||
@Subcomponent(modules = [ActivityModule::class])
|
||||
interface CoreActivityComponent {
|
||||
fun inject(searchActivity: SearchActivity)
|
||||
fun inject(showDeleteSearchDialog: ShowDeleteSearchDialog)
|
||||
fun inject(corePrefsFragment: CorePrefsFragment)
|
||||
|
||||
@Subcomponent.Builder
|
||||
interface Builder {
|
||||
|
@ -54,7 +54,6 @@ import org.kiwix.kiwixmobile.core.reader.ZimContentProvider
|
||||
import org.kiwix.kiwixmobile.core.reader.ZimFileReader
|
||||
import org.kiwix.kiwixmobile.core.reader.ZimReaderContainer
|
||||
import org.kiwix.kiwixmobile.core.search.SearchActivity
|
||||
import org.kiwix.kiwixmobile.core.settings.CorePrefsFragment
|
||||
import org.kiwix.kiwixmobile.core.settings.CoreSettingsActivity
|
||||
import org.kiwix.kiwixmobile.core.utils.BookUtils
|
||||
import org.kiwix.kiwixmobile.core.utils.SharedPreferenceUtil
|
||||
@ -107,7 +106,6 @@ interface CoreComponent {
|
||||
fun inject(application: CoreApp)
|
||||
fun inject(zimContentProvider: ZimContentProvider)
|
||||
fun inject(kiwixWebView: KiwixWebView)
|
||||
fun inject(prefsFragment: CorePrefsFragment)
|
||||
fun inject(storageSelectDialog: StorageSelectDialog)
|
||||
fun inject(addNoteDialog: AddNoteDialog)
|
||||
|
||||
|
@ -19,12 +19,13 @@
|
||||
package org.kiwix.kiwixmobile.core.main;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import org.kiwix.kiwixmobile.core.R;
|
||||
import javax.inject.Inject;
|
||||
import kotlin.Unit;
|
||||
import org.kiwix.kiwixmobile.core.utils.DialogShower;
|
||||
import org.kiwix.kiwixmobile.core.utils.KiwixDialog;
|
||||
import org.kiwix.kiwixmobile.core.utils.SharedPreferenceUtil;
|
||||
|
||||
/**
|
||||
@ -48,6 +49,8 @@ public class ConfirmationAlertDialogFragment extends DialogFragment {
|
||||
private SharedPreferenceUtil sharedPreferenceUtil;
|
||||
private int stringResourceId;
|
||||
private String parentDialogFragmentTAG;
|
||||
@Inject
|
||||
protected DialogShower alertDialogShower;
|
||||
|
||||
public ConfirmationAlertDialogFragment(SharedPreferenceUtil sharedPreferenceUtil,
|
||||
String parentDialogFragmentTAG, int stringResourceId) {
|
||||
@ -59,27 +62,20 @@ public class ConfirmationAlertDialogFragment extends DialogFragment {
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
Fragment parentDialogFragment = getFragmentManager().findFragmentByTag(parentDialogFragmentTAG);
|
||||
|
||||
return new AlertDialog.Builder(getActivity()).setMessage(stringResourceId)
|
||||
.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
|
||||
if (parentDialogFragment != null) {
|
||||
((UserClickListener) parentDialogFragment).onPositiveClick();
|
||||
}
|
||||
return alertDialogShower.create(new KiwixDialog.ConfirmationAlertDialogFragment(stringResourceId),
|
||||
() -> {
|
||||
if (parentDialogFragment != null) {
|
||||
((UserClickListener) parentDialogFragment).onPositiveClick();
|
||||
}
|
||||
})
|
||||
.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
|
||||
if (parentDialogFragment != null) {
|
||||
((UserClickListener) parentDialogFragment).onNegativeClick();
|
||||
}
|
||||
return Unit.INSTANCE;
|
||||
},
|
||||
() -> {
|
||||
if (parentDialogFragment != null) {
|
||||
((UserClickListener) parentDialogFragment).onNegativeClick();
|
||||
}
|
||||
})
|
||||
.create();
|
||||
return Unit.INSTANCE;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -53,7 +53,6 @@ import android.widget.Toast;
|
||||
import androidx.annotation.AnimRes;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.ActionBar;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.widget.AppCompatButton;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
@ -109,7 +108,9 @@ import org.kiwix.kiwixmobile.core.reader.ZimFileReader;
|
||||
import org.kiwix.kiwixmobile.core.reader.ZimReaderContainer;
|
||||
import org.kiwix.kiwixmobile.core.search.SearchActivity;
|
||||
import org.kiwix.kiwixmobile.core.search.viewmodel.effects.SearchInPreviousScreen;
|
||||
import org.kiwix.kiwixmobile.core.utils.DialogShower;
|
||||
import org.kiwix.kiwixmobile.core.utils.DimenUtils;
|
||||
import org.kiwix.kiwixmobile.core.utils.KiwixDialog;
|
||||
import org.kiwix.kiwixmobile.core.utils.LanguageUtils;
|
||||
import org.kiwix.kiwixmobile.core.utils.NetworkUtils;
|
||||
import org.kiwix.kiwixmobile.core.utils.StyleUtils;
|
||||
@ -213,6 +214,8 @@ public abstract class CoreMainActivity extends BaseActivity
|
||||
protected NewBookmarksDao newBookmarksDao;
|
||||
@Inject
|
||||
protected NewBookDao newBookDao;
|
||||
@Inject
|
||||
protected DialogShower alertDialogShower;
|
||||
|
||||
private CountDownTimer hideBackToTopTimer = new CountDownTimer(1200, 1200) {
|
||||
@Override
|
||||
@ -637,28 +640,22 @@ public abstract class CoreMainActivity extends BaseActivity
|
||||
}
|
||||
|
||||
private void showRateDialog() {
|
||||
String title = getString(R.string.rate_dialog_title);
|
||||
String message = getString(R.string.rate_dialog_msg_1) + " "
|
||||
+ getString(R.string.app_name)
|
||||
+ getString(R.string.rate_dialog_msg_2);
|
||||
String positive = getString(R.string.rate_dialog_positive);
|
||||
String negative = getString(R.string.no_thanks);
|
||||
String neutral = getString(R.string.rate_dialog_neutral);
|
||||
|
||||
new AlertDialog.Builder(this)
|
||||
.setTitle(title)
|
||||
.setMessage(message)
|
||||
.setPositiveButton(positive, (dialog, id) -> {
|
||||
alertDialogShower.show(new KiwixDialog.ShowRate(getIconResId()),
|
||||
() -> {
|
||||
visitCounterPref.setNoThanksState(true);
|
||||
goToRateApp();
|
||||
})
|
||||
.setNegativeButton(negative, (dialog, id) -> visitCounterPref.setNoThanksState(true))
|
||||
.setNeutralButton(neutral, (dialog, id) -> {
|
||||
return Unit.INSTANCE;
|
||||
},
|
||||
() -> {
|
||||
visitCounterPref.setNoThanksState(true);
|
||||
return Unit.INSTANCE;
|
||||
},
|
||||
() ->{
|
||||
tempVisitCount = 0;
|
||||
visitCounterPref.setCount(tempVisitCount);
|
||||
})
|
||||
.setIcon(ContextCompat.getDrawable(this, getIconResId()))
|
||||
.show();
|
||||
return Unit.INSTANCE;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
protected abstract int getIconResId();
|
||||
@ -1074,21 +1071,20 @@ public abstract class CoreMainActivity extends BaseActivity
|
||||
}
|
||||
|
||||
private void externalLinkPopup(Intent intent) {
|
||||
new AlertDialog.Builder(this)
|
||||
.setTitle(R.string.external_link_popup_dialog_title)
|
||||
.setMessage(R.string.external_link_popup_dialog_message)
|
||||
.setNegativeButton(android.R.string.no, (dialogInterface, i) -> {
|
||||
// do nothing
|
||||
})
|
||||
.setNeutralButton(R.string.do_not_ask_anymore, (dialogInterface, i) -> {
|
||||
alertDialogShower.show(KiwixDialog.ExternalLinkPopup.INSTANCE,
|
||||
() -> {
|
||||
startActivity(intent);
|
||||
return Unit.INSTANCE;
|
||||
},
|
||||
null,
|
||||
() -> {
|
||||
sharedPreferenceUtil.putPrefExternalLinkPopup(false);
|
||||
isExternalLinkPopup = false;
|
||||
|
||||
startActivity(intent);
|
||||
})
|
||||
.setPositiveButton(android.R.string.yes, (dialogInterface, i) -> startActivity(intent))
|
||||
.setIcon(R.drawable.ic_warning)
|
||||
.show();
|
||||
return Unit.INSTANCE;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
protected void openZimFile(@NonNull File file) {
|
||||
@ -1364,14 +1360,7 @@ public abstract class CoreMainActivity extends BaseActivity
|
||||
private void contentsDrawerHint() {
|
||||
drawerLayout.postDelayed(() -> drawerLayout.openDrawer(GravityCompat.END), 500);
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
builder.setMessage(getString(R.string.hint_contents_drawer_message))
|
||||
.setPositiveButton(getString(R.string.got_it), (dialog, id) -> {
|
||||
})
|
||||
.setTitle(R.string.did_you_know)
|
||||
.setIcon(R.drawable.icon_question);
|
||||
AlertDialog alert = builder.create();
|
||||
alert.show();
|
||||
alertDialogShower.show(KiwixDialog.ContentsDrawerHint.INSTANCE);
|
||||
}
|
||||
|
||||
private void openArticle(String articleUrl) {
|
||||
@ -1688,25 +1677,21 @@ public abstract class CoreMainActivity extends BaseActivity
|
||||
}
|
||||
|
||||
protected void showOpenInNewTabDialog(String url) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
|
||||
builder.setPositiveButton(android.R.string.yes, (dialog, id) -> {
|
||||
if (isOpenNewTabInBackground) {
|
||||
newTabInBackground(url);
|
||||
Snackbar.make(snackbarRoot, R.string.new_tab_snack_bar, Snackbar.LENGTH_LONG)
|
||||
.setAction(getString(R.string.open), v -> {
|
||||
if (webViewList.size() > 1) selectTab(webViewList.size() - 1);
|
||||
})
|
||||
.setActionTextColor(getResources().getColor(R.color.white))
|
||||
.show();
|
||||
} else {
|
||||
newTab(url);
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(android.R.string.no, null);
|
||||
builder.setMessage(getString(R.string.open_in_new_tab));
|
||||
AlertDialog dialog = builder.create();
|
||||
dialog.show();
|
||||
alertDialogShower.show(KiwixDialog.YesNoDialog.OpenInNewTab.INSTANCE,
|
||||
() -> {
|
||||
if (isOpenNewTabInBackground) {
|
||||
newTabInBackground(url);
|
||||
Snackbar.make(snackbarRoot, R.string.new_tab_snack_bar, Snackbar.LENGTH_LONG)
|
||||
.setAction(getString(R.string.open), v -> {
|
||||
if (webViewList.size() > 1) selectTab(webViewList.size() - 1);
|
||||
})
|
||||
.setActionTextColor(getResources().getColor(R.color.white))
|
||||
.show();
|
||||
} else {
|
||||
newTab(url);
|
||||
}
|
||||
return Unit.INSTANCE;
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -144,7 +144,6 @@ class SearchActivity : BaseActivity() {
|
||||
}
|
||||
|
||||
private fun render(searchString: String) {
|
||||
searchView.setQuery(searchString, false)
|
||||
searchInTextMenuItem.isEnabled = searchString.isNotBlank()
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,6 @@ import org.kiwix.kiwixmobile.core.search.viewmodel.effects.SearchIntentProcessin
|
||||
import org.kiwix.kiwixmobile.core.search.viewmodel.effects.ShowDeleteSearchDialog
|
||||
import org.kiwix.kiwixmobile.core.search.viewmodel.effects.ShowToast
|
||||
import org.kiwix.kiwixmobile.core.search.viewmodel.effects.StartSpeechInput
|
||||
import java.util.concurrent.TimeUnit.MILLISECONDS
|
||||
import javax.inject.Inject
|
||||
|
||||
class SearchViewModel @Inject constructor(
|
||||
@ -127,8 +126,7 @@ class SearchViewModel @Inject constructor(
|
||||
searchResultsFromZimReader(),
|
||||
filter,
|
||||
Function3(this::reduce)
|
||||
).debounce(100, MILLISECONDS)
|
||||
.subscribe(state::postValue, Throwable::printStackTrace)
|
||||
).subscribe(state::postValue, Throwable::printStackTrace)
|
||||
|
||||
private fun reduce(
|
||||
recentSearchResults: List<SearchListItem>,
|
||||
|
@ -33,7 +33,6 @@ import android.view.LayoutInflater;
|
||||
import android.webkit.WebView;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.Toast;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import eu.mhutti1.utils.storage.StorageDevice;
|
||||
@ -50,6 +49,8 @@ import org.kiwix.kiwixmobile.core.NightModeConfig;
|
||||
import org.kiwix.kiwixmobile.core.R;
|
||||
import org.kiwix.kiwixmobile.core.extensions.ContextExtensionsKt;
|
||||
import org.kiwix.kiwixmobile.core.main.AddNoteDialog;
|
||||
import org.kiwix.kiwixmobile.core.utils.DialogShower;
|
||||
import org.kiwix.kiwixmobile.core.utils.KiwixDialog;
|
||||
import org.kiwix.kiwixmobile.core.utils.LanguageUtils;
|
||||
import org.kiwix.kiwixmobile.core.utils.SharedPreferenceUtil;
|
||||
|
||||
@ -75,12 +76,17 @@ public abstract class CorePrefsFragment extends PreferenceFragment implements
|
||||
protected StorageCalculator storageCalculator;
|
||||
@Inject
|
||||
protected NightModeConfig nightModeConfig;
|
||||
|
||||
@Inject
|
||||
protected DialogShower alertDialogShower;
|
||||
private SliderPreference mSlider;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
CoreApp.getCoreComponent().inject(this);
|
||||
CoreApp.getCoreComponent()
|
||||
.activityComponentBuilder()
|
||||
.activity(getActivity())
|
||||
.build()
|
||||
.inject(this);
|
||||
super.onCreate(savedInstanceState);
|
||||
addPreferencesFromResource(R.xml.preferences);
|
||||
|
||||
@ -199,28 +205,20 @@ public abstract class CorePrefsFragment extends PreferenceFragment implements
|
||||
}
|
||||
|
||||
private void clearAllHistoryDialog() {
|
||||
new AlertDialog.Builder(getActivity())
|
||||
.setTitle(getResources().getString(R.string.clear_all_history_dialog_title))
|
||||
.setMessage(getResources().getString(R.string.clear_recent_and_tabs_history_dialog))
|
||||
.setPositiveButton(android.R.string.yes, (dialog, which) -> {
|
||||
presenter.clearHistory();
|
||||
CoreSettingsActivity.allHistoryCleared = true;
|
||||
Toast.makeText(getActivity(),
|
||||
getResources().getString(R.string.all_history_cleared_toast), Toast.LENGTH_SHORT)
|
||||
.show();
|
||||
})
|
||||
.setNegativeButton(android.R.string.no, (dialog, which) -> {
|
||||
// do nothing
|
||||
})
|
||||
.setIcon(R.drawable.ic_warning)
|
||||
.show();
|
||||
alertDialogShower.show(KiwixDialog.ClearAllHistory.INSTANCE, () -> {
|
||||
presenter.clearHistory();
|
||||
CoreSettingsActivity.allHistoryCleared = true;
|
||||
ContextExtensionsKt.toast(getActivity(), R.string.all_history_cleared_toast,
|
||||
Toast.LENGTH_SHORT);
|
||||
return Unit.INSTANCE;
|
||||
});
|
||||
}
|
||||
|
||||
private void showClearAllNotesDialog() {
|
||||
new AlertDialog.Builder(getActivity()).setMessage(R.string.delete_notes_confirmation_msg)
|
||||
.setNegativeButton(android.R.string.cancel, null) // Do nothing for 'Cancel' button
|
||||
.setPositiveButton(R.string.yes, (dialog, which) -> clearAllNotes())
|
||||
.show();
|
||||
alertDialogShower.show(KiwixDialog.ClearAllNotes.INSTANCE, () -> {
|
||||
clearAllNotes();
|
||||
return Unit.INSTANCE;
|
||||
});
|
||||
}
|
||||
|
||||
private void clearAllNotes() {
|
||||
@ -252,10 +250,7 @@ public abstract class CorePrefsFragment extends PreferenceFragment implements
|
||||
view.getSettings().setJavaScriptEnabled(true);
|
||||
view.setBackgroundColor(0);
|
||||
}
|
||||
new AlertDialog.Builder(getActivity())
|
||||
.setView(view)
|
||||
.setPositiveButton(android.R.string.ok, null)
|
||||
.show();
|
||||
alertDialogShower.show(new KiwixDialog.OpenCredits(() -> view));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -19,16 +19,21 @@
|
||||
package org.kiwix.kiwixmobile.core.utils
|
||||
|
||||
import android.app.Activity
|
||||
import android.app.Dialog
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import org.kiwix.kiwixmobile.core.utils.KiwixDialog.StartHotspotManually
|
||||
import javax.inject.Inject
|
||||
|
||||
class AlertDialogShower @Inject constructor(private val activity: Activity) : DialogShower {
|
||||
override fun show(dialog: KiwixDialog, vararg clickListeners: () -> Unit) {
|
||||
AlertDialog.Builder(activity)
|
||||
create(dialog, *clickListeners).show()
|
||||
}
|
||||
|
||||
override fun create(dialog: KiwixDialog, vararg clickListeners: () -> Unit): Dialog {
|
||||
return AlertDialog.Builder(activity)
|
||||
.apply {
|
||||
dialog.title?.let(this::setTitle)
|
||||
setMessage(activity.getString(dialog.message, *bodyArguments(dialog)))
|
||||
dialog.icon?.let(this::setIcon)
|
||||
dialog.message?.let { setMessage(activity.getString(it, *bodyArguments(dialog))) }
|
||||
setPositiveButton(dialog.positiveMessage) { _, _ ->
|
||||
clickListeners.getOrNull(0)
|
||||
?.invoke()
|
||||
@ -39,15 +44,16 @@ class AlertDialogShower @Inject constructor(private val activity: Activity) : Di
|
||||
?.invoke()
|
||||
}
|
||||
}
|
||||
if (dialog is StartHotspotManually) {
|
||||
setNeutralButton(dialog.neutralMessage) { _, _ ->
|
||||
dialog.neutralMessage?.let {
|
||||
setNeutralButton(it) { _, _ ->
|
||||
clickListeners.getOrNull(2)
|
||||
?.invoke()
|
||||
}
|
||||
}
|
||||
dialog.getView?.let { setView(it()) }
|
||||
setCancelable(dialog.cancelable)
|
||||
}
|
||||
.show()
|
||||
.create()
|
||||
}
|
||||
|
||||
private fun bodyArguments(dialog: KiwixDialog) =
|
||||
|
@ -17,9 +17,16 @@
|
||||
*/
|
||||
package org.kiwix.kiwixmobile.core.utils
|
||||
|
||||
import android.app.Dialog
|
||||
|
||||
interface DialogShower {
|
||||
fun show(
|
||||
dialog: KiwixDialog,
|
||||
vararg clickListeners: (() -> Unit)
|
||||
)
|
||||
|
||||
fun create(
|
||||
dialog: KiwixDialog,
|
||||
vararg clickListeners: (() -> Unit)
|
||||
): Dialog
|
||||
}
|
||||
|
@ -19,15 +19,19 @@
|
||||
package org.kiwix.kiwixmobile.core.utils
|
||||
|
||||
import android.net.wifi.WifiConfiguration
|
||||
import android.view.View
|
||||
import org.kiwix.kiwixmobile.core.R
|
||||
import org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.adapter.BooksOnDiskListItem.BookOnDisk
|
||||
|
||||
sealed class KiwixDialog(
|
||||
val title: Int?,
|
||||
val message: Int,
|
||||
val message: Int?,
|
||||
val positiveMessage: Int,
|
||||
val negativeMessage: Int?,
|
||||
val cancelable: Boolean = true
|
||||
val cancelable: Boolean = true,
|
||||
val icon: Int? = null,
|
||||
val neutralMessage: Int? = null,
|
||||
val getView: (() -> View)? = null
|
||||
) {
|
||||
|
||||
data class DeleteZim(override val args: List<Any>) : KiwixDialog(
|
||||
@ -84,13 +88,12 @@ sealed class KiwixDialog(
|
||||
)
|
||||
}
|
||||
|
||||
data class StartHotspotManually(
|
||||
val neutralMessage: Int = R.string.hotspot_dialog_neutral_button
|
||||
) : KiwixDialog(
|
||||
object StartHotspotManually : KiwixDialog(
|
||||
R.string.hotspot_dialog_title,
|
||||
R.string.hotspot_dialog_message,
|
||||
R.string.go_to_settings,
|
||||
null
|
||||
null,
|
||||
neutralMessage = R.string.hotspot_dialog_neutral_button
|
||||
)
|
||||
|
||||
data class FileTransferConfirmation(override val args: List<Any>) : KiwixDialog(
|
||||
@ -103,6 +106,68 @@ sealed class KiwixDialog(
|
||||
null, R.string.delete_recent_search_item, R.string.delete, R.string.no
|
||||
)
|
||||
|
||||
object ContentsDrawerHint : KiwixDialog(
|
||||
R.string.did_you_know,
|
||||
R.string.hint_contents_drawer_message,
|
||||
R.string.got_it,
|
||||
null,
|
||||
icon = R.drawable.icon_question
|
||||
)
|
||||
|
||||
object ExternalLinkPopup : KiwixDialog(
|
||||
R.string.external_link_popup_dialog_title,
|
||||
R.string.external_link_popup_dialog_message,
|
||||
android.R.string.yes,
|
||||
android.R.string.no,
|
||||
icon = R.drawable.ic_warning,
|
||||
neutralMessage = R.string.do_not_ask_anymore
|
||||
)
|
||||
|
||||
data class ShowRate(override val args: List<Any>, val customIcon: Int?) : KiwixDialog(
|
||||
R.string.rate_dialog_title,
|
||||
R.string.triple_arg_format_string,
|
||||
R.string.rate_dialog_positive,
|
||||
R.string.no_thanks,
|
||||
icon = customIcon,
|
||||
neutralMessage = R.string.rate_dialog_neutral
|
||||
),
|
||||
HasBodyFormatArgs {
|
||||
constructor(icon: Int?) : this(
|
||||
listOf(R.string.rate_dialog_msg_1, R.string.app_name, R.string.rate_dialog_msg_2),
|
||||
icon
|
||||
)
|
||||
}
|
||||
|
||||
object ClearAllHistory : KiwixDialog(
|
||||
R.string.clear_all_history_dialog_title,
|
||||
R.string.clear_recent_and_tabs_history_dialog,
|
||||
R.string.yes,
|
||||
R.string.no,
|
||||
icon = R.drawable.ic_warning
|
||||
)
|
||||
|
||||
object ClearAllNotes : KiwixDialog(
|
||||
null,
|
||||
R.string.delete_notes_confirmation_msg,
|
||||
R.string.yes,
|
||||
android.R.string.cancel
|
||||
)
|
||||
|
||||
data class OpenCredits(val customGetView: (() -> View)?) : KiwixDialog(
|
||||
null,
|
||||
null,
|
||||
android.R.string.ok,
|
||||
null,
|
||||
getView = customGetView
|
||||
)
|
||||
|
||||
data class ConfirmationAlertDialogFragment(val customMessage: Int) : KiwixDialog(
|
||||
null,
|
||||
customMessage,
|
||||
R.string.yes,
|
||||
android.R.string.cancel
|
||||
)
|
||||
|
||||
open class YesNoDialog(
|
||||
title: Int,
|
||||
message: Int
|
||||
@ -114,6 +179,10 @@ sealed class KiwixDialog(
|
||||
object WifiOnly : YesNoDialog(
|
||||
R.string.wifi_only_title, R.string.wifi_only_msg
|
||||
)
|
||||
|
||||
object OpenInNewTab : YesNoDialog(
|
||||
R.string.open_in_new_tab, R.string.open_in_new_tab
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,5 +5,5 @@
|
||||
<item>medium</item>
|
||||
<item>large</item>
|
||||
</string-array>
|
||||
|
||||
<string name="triple_arg_format_string" translatable="false">%s %s %s</string>
|
||||
</resources>
|
||||
|
@ -39,6 +39,7 @@
|
||||
|
||||
<style name="Widget.KiwixTheme.Chip.Choice.Static" parent="Widget.MaterialComponents.Chip.Choice">
|
||||
<item name="android:clickable">false</item>
|
||||
<item name="android:textAlignment" tools:ignore="NewApi">center</item>
|
||||
</style>
|
||||
|
||||
<style name="list_item_title" parent="TextAppearance.KiwixTheme.Subtitle1" />
|
||||
|
4
gradle/wrapper/gradle-wrapper.properties
vendored
4
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,6 +1,6 @@
|
||||
#Sun Jun 16 15:57:45 CDT 2019
|
||||
#Tue Feb 25 11:46:45 IST 2020
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.1-all.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.2.1-all.zip
|
||||
|
@ -51,10 +51,10 @@ task jacocoInstrumentationTestReport(type: JacocoReport, dependsOn: ['createDebu
|
||||
includes: ['jacoco/testDebugUnitTest.exec',
|
||||
'outputs/code_coverage/debugAndroidTest/connected/**/*.ec'])
|
||||
}
|
||||
sourceDirectories = files([javaSrc, kotlinSrc])
|
||||
classDirectories = files([javaClasses, kotlinClasses])
|
||||
sourceDirectories.from = files(javaSrc, kotlinSrc)
|
||||
classDirectories.from = files(javaClasses, kotlinClasses)
|
||||
print execution
|
||||
executionData = files(execution)
|
||||
executionData.from = files(execution)
|
||||
doLast() {
|
||||
print "file://${reports.html.destination}/index.html"
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user