mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-08-03 10:46:53 -04:00
Merge pull request #2134 from kiwix/macgills/feature/2110-text-zoom
#2110 Zoom controls disappeared in v3.3.1
This commit is contained in:
commit
577a60cf13
@ -18,104 +18,70 @@
|
|||||||
|
|
||||||
package org.kiwix.kiwixmobile.settings;
|
package org.kiwix.kiwixmobile.settings;
|
||||||
|
|
||||||
import android.preference.Preference;
|
import android.view.View;
|
||||||
|
import androidx.annotation.StringRes;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
import androidx.test.rule.ActivityTestRule;
|
import androidx.test.rule.ActivityTestRule;
|
||||||
|
import org.hamcrest.Matcher;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.kiwix.kiwixmobile.core.R;
|
import org.kiwix.kiwixmobile.core.R;
|
||||||
import org.kiwix.kiwixmobile.main.KiwixMainActivity;
|
|
||||||
|
|
||||||
import static androidx.test.espresso.Espresso.onData;
|
import static androidx.test.espresso.Espresso.onView;
|
||||||
import static androidx.test.espresso.action.ViewActions.click;
|
import static androidx.test.espresso.action.ViewActions.click;
|
||||||
import static androidx.test.espresso.matcher.PreferenceMatchers.withKey;
|
import static androidx.test.espresso.contrib.RecyclerViewActions.actionOnItem;
|
||||||
|
import static androidx.test.espresso.matcher.ViewMatchers.hasDescendant;
|
||||||
|
import static androidx.test.espresso.matcher.ViewMatchers.withClassName;
|
||||||
|
import static androidx.test.espresso.matcher.ViewMatchers.withText;
|
||||||
import static com.schibsted.spain.barista.assertion.BaristaVisibilityAssertions.assertDisplayed;
|
import static com.schibsted.spain.barista.assertion.BaristaVisibilityAssertions.assertDisplayed;
|
||||||
import static org.hamcrest.Matchers.allOf;
|
import static org.hamcrest.Matchers.anyOf;
|
||||||
import static org.hamcrest.Matchers.instanceOf;
|
|
||||||
import static org.hamcrest.Matchers.is;
|
import static org.hamcrest.Matchers.is;
|
||||||
import static org.kiwix.kiwixmobile.utils.StandardActions.enterSettings;
|
|
||||||
|
|
||||||
public class KiwixSettingsActivityTest {
|
public class KiwixSettingsActivityTest {
|
||||||
@Rule
|
@Rule
|
||||||
public ActivityTestRule<KiwixMainActivity> activityTestRule =
|
public ActivityTestRule<KiwixSettingsActivity> activityTestRule =
|
||||||
new ActivityTestRule<>(KiwixMainActivity.class);
|
new ActivityTestRule<>(KiwixSettingsActivity.class);
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testToggle() {
|
public void testToggle() {
|
||||||
enterSettings();
|
clickOn(R.string.pref_back_to_top);
|
||||||
|
clickOn(R.string.pref_hide_toolbar);
|
||||||
|
clickOn(R.string.pref_newtab_background_title);
|
||||||
|
clickOn(R.string.pref_external_link_popup_title);
|
||||||
|
clickOn(R.string.pref_wifi_only);
|
||||||
|
}
|
||||||
|
|
||||||
onData(allOf(
|
private void clickOn(@StringRes int... stringIds) {
|
||||||
is(instanceOf(Preference.class)),
|
Matcher<View>[] matchers= new Matcher[stringIds.length];
|
||||||
withKey("pref_backtotop")))
|
for (int i = 0; i < stringIds.length; i++) {
|
||||||
.perform(click());
|
matchers[i]= withText(stringIds[i]);
|
||||||
|
}
|
||||||
onData(allOf(
|
onView(withClassName(is(RecyclerView.class.getName())))
|
||||||
is(instanceOf(Preference.class)),
|
.perform(actionOnItem(hasDescendant(anyOf(matchers)), click()));
|
||||||
withKey("pref_hidetoolbar")))
|
|
||||||
.perform(click());
|
|
||||||
|
|
||||||
onData(allOf(
|
|
||||||
is(instanceOf(Preference.class)),
|
|
||||||
withKey("pref_newtab_background")))
|
|
||||||
.perform(click());
|
|
||||||
|
|
||||||
onData(allOf(
|
|
||||||
is(instanceOf(Preference.class)),
|
|
||||||
withKey("pref_external_link_popup")))
|
|
||||||
.perform(click());
|
|
||||||
|
|
||||||
/*onData(allOf(
|
|
||||||
is(instanceOf(Preference.class)),
|
|
||||||
withKey("pref_full_text_search")))
|
|
||||||
.perform(click());*/
|
|
||||||
|
|
||||||
onData(allOf(
|
|
||||||
is(instanceOf(Preference.class)),
|
|
||||||
withKey("pref_wifi_only")))
|
|
||||||
.perform(click());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testLanguageDialog() {
|
public void testLanguageDialog() {
|
||||||
enterSettings();
|
clickOn(R.string.device_default);
|
||||||
onData(allOf(
|
|
||||||
is(instanceOf(Preference.class)),
|
|
||||||
withKey("pref_language_chooser")))
|
|
||||||
.perform(click());
|
|
||||||
|
|
||||||
assertDisplayed(R.string.pref_language_title);
|
assertDisplayed(R.string.pref_language_title);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testStorageDialog() {
|
public void testStorageDialog() {
|
||||||
enterSettings();
|
clickOn(R.string.internal_storage, R.string.external_storage);
|
||||||
onData(allOf(
|
|
||||||
is(instanceOf(Preference.class)),
|
|
||||||
withKey("pref_select_folder")))
|
|
||||||
.perform(click());
|
|
||||||
|
|
||||||
assertDisplayed(R.string.pref_storage);
|
assertDisplayed(R.string.pref_storage);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testHistoryDialog() {
|
public void testHistoryDialog() {
|
||||||
enterSettings();
|
clickOn(R.string.pref_clear_all_history_title);
|
||||||
onData(allOf(
|
|
||||||
is(instanceOf(Preference.class)),
|
|
||||||
withKey("pref_clear_all_history")))
|
|
||||||
.perform(click());
|
|
||||||
|
|
||||||
assertDisplayed(R.string.clear_all_history_dialog_title);
|
assertDisplayed(R.string.clear_all_history_dialog_title);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNightModeDialog() {
|
public void testNightModeDialog() {
|
||||||
enterSettings();
|
clickOn(R.string.pref_night_mode);
|
||||||
onData(allOf(
|
|
||||||
is(instanceOf(Preference.class)),
|
|
||||||
withKey("pref_night_mode")))
|
|
||||||
.perform(click());
|
|
||||||
|
|
||||||
for (String nightModeString : nightModeStrings()) {
|
for (String nightModeString : nightModeStrings()) {
|
||||||
assertDisplayed(nightModeString);
|
assertDisplayed(nightModeString);
|
||||||
}
|
}
|
||||||
|
@ -20,22 +20,26 @@ package org.kiwix.kiwixmobile.settings
|
|||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.os.Environment
|
import android.os.Environment
|
||||||
|
import androidx.preference.Preference
|
||||||
import org.kiwix.kiwixmobile.core.settings.CorePrefsFragment
|
import org.kiwix.kiwixmobile.core.settings.CorePrefsFragment
|
||||||
import org.kiwix.kiwixmobile.core.utils.SharedPreferenceUtil.PREF_LANG
|
import org.kiwix.kiwixmobile.core.utils.SharedPreferenceUtil
|
||||||
import org.kiwix.kiwixmobile.core.utils.SharedPreferenceUtil.PREF_STORAGE
|
import org.kiwix.kiwixmobile.core.utils.SharedPreferenceUtil.PREF_STORAGE
|
||||||
|
|
||||||
class KiwixPrefsFragment : CorePrefsFragment() {
|
class KiwixPrefsFragment : CorePrefsFragment() {
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
|
||||||
super.onCreate(savedInstanceState)
|
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||||
setUpLanguageChooser(PREF_LANG)
|
super.onCreatePreferences(savedInstanceState, rootKey)
|
||||||
|
setUpLanguageChooser(SharedPreferenceUtil.PREF_LANG)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setStorage() {
|
override fun setStorage() {
|
||||||
if (Environment.isExternalStorageEmulated()) {
|
if (Environment.isExternalStorageEmulated()) {
|
||||||
findPreference(PREF_STORAGE).title = sharedPreferenceUtil.getPrefStorageTitle("Internal")
|
findPreference<Preference>(PREF_STORAGE)?.title =
|
||||||
|
sharedPreferenceUtil.getPrefStorageTitle("Internal")
|
||||||
} else {
|
} else {
|
||||||
findPreference(PREF_STORAGE).title = sharedPreferenceUtil.getPrefStorageTitle("External")
|
findPreference<Preference>(PREF_STORAGE)?.title =
|
||||||
|
sharedPreferenceUtil.getPrefStorageTitle("External")
|
||||||
}
|
}
|
||||||
findPreference(PREF_STORAGE).summary = storageCalculator.calculateAvailableSpace()
|
findPreference<Preference>(PREF_STORAGE)?.summary = storageCalculator.calculateAvailableSpace()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ class ZimFileSelectFragment : BaseFragment() {
|
|||||||
private val disposable = CompositeDisposable()
|
private val disposable = CompositeDisposable()
|
||||||
|
|
||||||
private val zimManageViewModel by lazy {
|
private val zimManageViewModel by lazy {
|
||||||
activity!!.viewModel<ZimManageViewModel>(viewModelFactory)
|
requireActivity().viewModel<ZimManageViewModel>(viewModelFactory)
|
||||||
}
|
}
|
||||||
private val bookDelegate: BookDelegate by lazy {
|
private val bookDelegate: BookDelegate by lazy {
|
||||||
BookDelegate(sharedPreferenceUtil,
|
BookDelegate(sharedPreferenceUtil,
|
||||||
@ -87,8 +87,8 @@ class ZimFileSelectFragment : BaseFragment() {
|
|||||||
container: ViewGroup?,
|
container: ViewGroup?,
|
||||||
savedInstanceState: Bundle?
|
savedInstanceState: Bundle?
|
||||||
): View? {
|
): View? {
|
||||||
LanguageUtils(activity!!)
|
LanguageUtils(requireActivity())
|
||||||
.changeFont(activity!!.layoutInflater, sharedPreferenceUtil)
|
.changeFont(requireActivity().layoutInflater, sharedPreferenceUtil)
|
||||||
return inflater.inflate(R.layout.zim_list, container, false)
|
return inflater.inflate(R.layout.zim_list, container, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,7 +121,7 @@ class ZimFileSelectFragment : BaseFragment() {
|
|||||||
|
|
||||||
private fun sideEffects() = zimManageViewModel.sideEffects.subscribe(
|
private fun sideEffects() = zimManageViewModel.sideEffects.subscribe(
|
||||||
{
|
{
|
||||||
val effectResult = it.invokeWith(activity!! as AppCompatActivity)
|
val effectResult = it.invokeWith(requireActivity() as AppCompatActivity)
|
||||||
if (effectResult is ActionMode) {
|
if (effectResult is ActionMode) {
|
||||||
actionMode = effectResult
|
actionMode = effectResult
|
||||||
}
|
}
|
||||||
@ -159,7 +159,7 @@ class ZimFileSelectFragment : BaseFragment() {
|
|||||||
|
|
||||||
private fun checkPermissions() {
|
private fun checkPermissions() {
|
||||||
if (ContextCompat.checkSelfPermission(
|
if (ContextCompat.checkSelfPermission(
|
||||||
activity!!,
|
requireActivity(),
|
||||||
Manifest.permission.READ_EXTERNAL_STORAGE
|
Manifest.permission.READ_EXTERNAL_STORAGE
|
||||||
) != PackageManager.PERMISSION_GRANTED
|
) != PackageManager.PERMISSION_GRANTED
|
||||||
) {
|
) {
|
||||||
|
@ -72,7 +72,7 @@ class LibraryFragment : BaseFragment() {
|
|||||||
@Inject lateinit var availableSpaceCalculator: AvailableSpaceCalculator
|
@Inject lateinit var availableSpaceCalculator: AvailableSpaceCalculator
|
||||||
|
|
||||||
private val zimManageViewModel by lazy {
|
private val zimManageViewModel by lazy {
|
||||||
activity!!.viewModel<ZimManageViewModel>(viewModelFactory)
|
requireActivity().viewModel<ZimManageViewModel>(viewModelFactory)
|
||||||
}
|
}
|
||||||
|
|
||||||
private val libraryAdapter: LibraryAdapter by lazy {
|
private val libraryAdapter: LibraryAdapter by lazy {
|
||||||
@ -86,7 +86,7 @@ class LibraryFragment : BaseFragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private val noWifiWithWifiOnlyPreferenceSet
|
private val noWifiWithWifiOnlyPreferenceSet
|
||||||
get() = sharedPreferenceUtil.prefWifiOnly && !NetworkUtils.isWiFi(context!!)
|
get() = sharedPreferenceUtil.prefWifiOnly && !NetworkUtils.isWiFi(requireContext())
|
||||||
|
|
||||||
private val isNotConnected get() = conMan.activeNetworkInfo?.isConnected == false
|
private val isNotConnected get() = conMan.activeNetworkInfo?.isConnected == false
|
||||||
|
|
||||||
@ -216,5 +216,5 @@ class LibraryFragment : BaseFragment() {
|
|||||||
.apply {
|
.apply {
|
||||||
onSelectAction = ::storeDeviceInPreferences
|
onSelectAction = ::storeDeviceInPreferences
|
||||||
}
|
}
|
||||||
.show(fragmentManager!!, getString(R.string.pref_storage))
|
.show(requireFragmentManager(), getString(R.string.pref_storage))
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import kotlin.String
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generated by https://github.com/jmfayard/buildSrcVersions
|
* Generated by https://github.com/jmfayard/buildSrcVersions
|
||||||
*
|
*
|
||||||
@ -30,19 +32,19 @@ object Libs {
|
|||||||
Versions.androidx_test_espresso
|
Versions.androidx_test_espresso
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* https://github.com/square/retrofit/
|
* https://github.com/square/retrofit
|
||||||
*/
|
*/
|
||||||
const val adapter_rxjava2: String = "com.squareup.retrofit2:adapter-rxjava2:" +
|
const val adapter_rxjava2: String = "com.squareup.retrofit2:adapter-rxjava2:" +
|
||||||
Versions.com_squareup_retrofit2
|
Versions.com_squareup_retrofit2
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* https://github.com/square/retrofit/
|
* https://github.com/square/retrofit
|
||||||
*/
|
*/
|
||||||
const val converter_simplexml: String = "com.squareup.retrofit2:converter-simplexml:" +
|
const val converter_simplexml: String = "com.squareup.retrofit2:converter-simplexml:" +
|
||||||
Versions.com_squareup_retrofit2
|
Versions.com_squareup_retrofit2
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* https://github.com/square/retrofit/
|
* https://github.com/square/retrofit
|
||||||
*/
|
*/
|
||||||
const val retrofit: String = "com.squareup.retrofit2:retrofit:" + Versions.com_squareup_retrofit2
|
const val retrofit: String = "com.squareup.retrofit2:retrofit:" + Versions.com_squareup_retrofit2
|
||||||
|
|
||||||
@ -165,7 +167,7 @@ object Libs {
|
|||||||
Versions.io_objectbox
|
Versions.io_objectbox
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* http://objectbox.io
|
* https://objectbox.io
|
||||||
*/
|
*/
|
||||||
const val objectbox_kotlin: String = "io.objectbox:objectbox-kotlin:" + Versions.io_objectbox
|
const val objectbox_kotlin: String = "io.objectbox:objectbox-kotlin:" + Versions.io_objectbox
|
||||||
|
|
||||||
@ -176,7 +178,7 @@ object Libs {
|
|||||||
Versions.io_objectbox
|
Versions.io_objectbox
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* http://objectbox.io
|
* https://objectbox.io
|
||||||
*/
|
*/
|
||||||
const val objectbox_rxjava: String = "io.objectbox:objectbox-rxjava:" + Versions.io_objectbox
|
const val objectbox_rxjava: String = "io.objectbox:objectbox-rxjava:" + Versions.io_objectbox
|
||||||
|
|
||||||
@ -228,9 +230,6 @@ object Libs {
|
|||||||
const val multidex_instrumentation: String = "androidx.multidex:multidex-instrumentation:" +
|
const val multidex_instrumentation: String = "androidx.multidex:multidex-instrumentation:" +
|
||||||
Versions.multidex_instrumentation
|
Versions.multidex_instrumentation
|
||||||
|
|
||||||
const val detekt_gradle_plugin: String = "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:" +
|
|
||||||
Versions.detekt_gradle_plugin
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* http://jcp.org/en/jsr/detail?id=250
|
* http://jcp.org/en/jsr/detail?id=250
|
||||||
*/
|
*/
|
||||||
@ -238,7 +237,7 @@ object Libs {
|
|||||||
Versions.javax_annotation_api
|
Versions.javax_annotation_api
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* https://github.com/square/okhttp
|
* https://square.github.io/okhttp/
|
||||||
*/
|
*/
|
||||||
const val logging_interceptor: String = "com.squareup.okhttp3:logging-interceptor:" +
|
const val logging_interceptor: String = "com.squareup.okhttp3:logging-interceptor:" +
|
||||||
Versions.logging_interceptor
|
Versions.logging_interceptor
|
||||||
@ -263,18 +262,18 @@ object Libs {
|
|||||||
*/
|
*/
|
||||||
const val collection_ktx: String = "androidx.collection:collection-ktx:" + Versions.collection_ktx
|
const val collection_ktx: String = "androidx.collection:collection-ktx:" + Versions.collection_ktx
|
||||||
|
|
||||||
const val jacoco_android: String = "com.hiya:jacoco-android:" +
|
/**
|
||||||
Versions.jacoco_android
|
* https://developer.android.com/jetpack/androidx
|
||||||
|
*/
|
||||||
|
const val preference_ktx: String = "androidx.preference:preference-ktx:" + Versions.preference_ktx
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* https://junit.org/junit5/
|
* https://junit.org/junit5/
|
||||||
*/
|
*/
|
||||||
const val junit_jupiter: String = "org.junit.jupiter:junit-jupiter:" + Versions.junit_jupiter
|
const val junit_jupiter: String = "org.junit.jupiter:junit-jupiter:" + Versions.junit_jupiter
|
||||||
|
|
||||||
const val ktlint_gradle: String = "org.jlleitschuh.gradle:ktlint-gradle:" + Versions.ktlint_gradle
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* https://github.com/square/okhttp
|
* https://square.github.io/okhttp/
|
||||||
*/
|
*/
|
||||||
const val mockwebserver: String = "com.squareup.okhttp3:mockwebserver:" + Versions.mockwebserver
|
const val mockwebserver: String = "com.squareup.okhttp3:mockwebserver:" + Versions.mockwebserver
|
||||||
|
|
||||||
@ -368,7 +367,7 @@ object Libs {
|
|||||||
const val ktlint: String = "com.pinterest:ktlint:" + Versions.ktlint
|
const val ktlint: String = "com.pinterest:ktlint:" + Versions.ktlint
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* https://github.com/square/okhttp
|
* https://square.github.io/okhttp/
|
||||||
*/
|
*/
|
||||||
const val okhttp: String = "com.squareup.okhttp3:okhttp:" + Versions.okhttp
|
const val okhttp: String = "com.squareup.okhttp3:okhttp:" + Versions.okhttp
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import kotlin.String
|
||||||
import org.gradle.plugin.use.PluginDependenciesSpec
|
import org.gradle.plugin.use.PluginDependenciesSpec
|
||||||
import org.gradle.plugin.use.PluginDependencySpec
|
import org.gradle.plugin.use.PluginDependencySpec
|
||||||
|
|
||||||
@ -13,11 +14,11 @@ import org.gradle.plugin.use.PluginDependencySpec
|
|||||||
object Versions {
|
object Versions {
|
||||||
const val androidx_test_espresso: String = "3.1.1" // available: "3.2.0"
|
const val androidx_test_espresso: String = "3.1.1" // available: "3.2.0"
|
||||||
|
|
||||||
const val com_squareup_retrofit2: String = "2.5.0" // available: "2.7.1"
|
const val com_squareup_retrofit2: String = "2.5.0" // available: "2.9.0"
|
||||||
|
|
||||||
const val org_jetbrains_kotlin: String = "1.3.72"
|
const val org_jetbrains_kotlin: String = "1.3.72"
|
||||||
|
|
||||||
const val com_google_dagger: String = "2.26"
|
const val com_google_dagger: String = "2.26" // available: "2.28"
|
||||||
|
|
||||||
const val com_yahoo_squidb: String = "2.0.0" // available: "3.2.3"
|
const val com_yahoo_squidb: String = "2.0.0" // available: "3.2.3"
|
||||||
|
|
||||||
@ -25,57 +26,53 @@ object Versions {
|
|||||||
|
|
||||||
const val androidx_test: String = "1.2.0"
|
const val androidx_test: String = "1.2.0"
|
||||||
|
|
||||||
const val io_objectbox: String = "2.3.4" // available: "2.5.1"
|
const val io_objectbox: String = "2.3.4" // available: "2.6.0"
|
||||||
|
|
||||||
const val org_jacoco: String = "0.7.9"
|
const val org_jacoco: String = "0.7.9"
|
||||||
|
|
||||||
const val io_mockk: String = "1.9.2"
|
const val io_mockk: String = "1.9.2" // available: "1.10.0"
|
||||||
|
|
||||||
const val android_arch_lifecycle_extensions: String = "1.1.1"
|
const val android_arch_lifecycle_extensions: String = "1.1.1"
|
||||||
|
|
||||||
const val com_android_tools_build_gradle: String = "3.5.3"
|
const val com_android_tools_build_gradle: String = "3.5.3" // available: "4.0.0"
|
||||||
|
|
||||||
const val de_fayard_buildsrcversions_gradle_plugin: String = "0.7.0"
|
const val de_fayard_buildsrcversions_gradle_plugin: String = "0.7.0"
|
||||||
|
|
||||||
const val com_github_triplet_play_gradle_plugin: String = "2.6.2"
|
const val com_github_triplet_play_gradle_plugin: String = "2.6.2" // available: "2.8.0"
|
||||||
|
|
||||||
const val multidex_instrumentation: String = "2.0.0"
|
const val multidex_instrumentation: String = "2.0.0"
|
||||||
|
|
||||||
const val detekt_gradle_plugin: String = "1.5.1"
|
|
||||||
|
|
||||||
const val javax_annotation_api: String = "1.3.2"
|
const val javax_annotation_api: String = "1.3.2"
|
||||||
|
|
||||||
const val logging_interceptor: String = "3.12.1" // available: "4.3.1"
|
const val logging_interceptor: String = "3.12.1" // available: "4.7.2"
|
||||||
|
|
||||||
const val ink_page_indicator: String = "1.3.0"
|
const val ink_page_indicator: String = "1.3.0"
|
||||||
|
|
||||||
const val leakcanary_android: String = "2.2"
|
const val leakcanary_android: String = "2.2" // available: "2.3"
|
||||||
|
|
||||||
const val constraintlayout: String = "1.1.3"
|
const val constraintlayout: String = "1.1.3"
|
||||||
|
|
||||||
const val collection_ktx: String = "1.1.0"
|
const val collection_ktx: String = "1.1.0"
|
||||||
|
|
||||||
const val jacoco_android: String = "0.2"
|
const val preference_ktx: String = "1.1.1"
|
||||||
|
|
||||||
const val junit_jupiter: String = "5.4.2" // available: "5.6.0"
|
const val junit_jupiter: String = "5.4.2" // available: "5.6.2"
|
||||||
|
|
||||||
const val ktlint_gradle: String = "9.2.1"
|
const val mockwebserver: String = "3.6.0" // available: "4.7.2"
|
||||||
|
|
||||||
const val mockwebserver: String = "3.6.0" // available: "4.3.1"
|
|
||||||
|
|
||||||
const val xfetch2okhttp: String = "3.1.4"
|
const val xfetch2okhttp: String = "3.1.4"
|
||||||
|
|
||||||
const val assertj_core: String = "3.11.1" // available: "3.15.0"
|
const val assertj_core: String = "3.11.1" // available: "3.16.1"
|
||||||
|
|
||||||
const val core_testing: String = "2.1.0"
|
const val core_testing: String = "2.1.0"
|
||||||
|
|
||||||
const val fragment_ktx: String = "1.2.1"
|
const val fragment_ktx: String = "1.2.1" // available: "1.2.4"
|
||||||
|
|
||||||
const val lint_gradle: String = "26.5.3"
|
const val lint_gradle: String = "27.0.0"
|
||||||
|
|
||||||
const val testing_ktx: String = "1.1.1"
|
const val testing_ktx: String = "1.1.1" // available: "1.1.2"
|
||||||
|
|
||||||
const val threetenabp: String = "1.1.1" // available: "1.2.2"
|
const val threetenabp: String = "1.1.1" // available: "1.2.4"
|
||||||
|
|
||||||
const val uiautomator: String = "2.2.0"
|
const val uiautomator: String = "2.2.0"
|
||||||
|
|
||||||
@ -87,7 +84,7 @@ object Versions {
|
|||||||
|
|
||||||
const val rxandroid: String = "2.1.0" // available: "2.1.1"
|
const val rxandroid: String = "2.1.0" // available: "2.1.1"
|
||||||
|
|
||||||
const val core_ktx: String = "1.2.0"
|
const val core_ktx: String = "1.2.0" // available: "1.3.0"
|
||||||
|
|
||||||
const val kiwixlib: String = "9.1.2"
|
const val kiwixlib: String = "9.1.2"
|
||||||
|
|
||||||
@ -95,19 +92,19 @@ object Versions {
|
|||||||
|
|
||||||
const val multidex: String = "2.0.1"
|
const val multidex: String = "2.0.1"
|
||||||
|
|
||||||
const val barista: String = "2.7.1" // available: "3.2.0"
|
const val barista: String = "2.7.1" // available: "3.5.0"
|
||||||
|
|
||||||
const val xfetch2: String = "3.1.4"
|
const val xfetch2: String = "3.1.4"
|
||||||
|
|
||||||
const val jsr305: String = "3.0.2"
|
const val jsr305: String = "3.0.2"
|
||||||
|
|
||||||
const val ktlint: String = "0.36.0"
|
const val ktlint: String = "0.36.0" // available: "0.37.1"
|
||||||
|
|
||||||
const val okhttp: String = "3.12.1" // available: "4.3.1"
|
const val okhttp: String = "3.12.1" // available: "4.7.2"
|
||||||
|
|
||||||
const val rxjava: String = "2.2.5" // available: "2.2.17"
|
const val rxjava: String = "2.2.5" // available: "2.2.19"
|
||||||
|
|
||||||
const val aapt2: String = "3.5.2-5435860" // available: "3.5.3-5435860"
|
const val aapt2: String = "4.0.0-6051327"
|
||||||
|
|
||||||
const val junit: String = "1.1.1"
|
const val junit: String = "1.1.1"
|
||||||
|
|
||||||
@ -116,7 +113,7 @@ object Versions {
|
|||||||
* See issue 19: How to update Gradle itself?
|
* See issue 19: How to update Gradle itself?
|
||||||
* https://github.com/jmfayard/buildSrcVersions/issues/19
|
* https://github.com/jmfayard/buildSrcVersions/issues/19
|
||||||
*/
|
*/
|
||||||
const val gradleLatestVersion: String = "6.1.1"
|
const val gradleLatestVersion: String = "6.5"
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -181,6 +181,7 @@ class AllProjectConfigurer {
|
|||||||
implementation(Libs.xfetch2okhttp)
|
implementation(Libs.xfetch2okhttp)
|
||||||
implementation(Libs.rxandroid)
|
implementation(Libs.rxandroid)
|
||||||
implementation(Libs.rxjava)
|
implementation(Libs.rxjava)
|
||||||
|
implementation(Libs.preference_ktx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,5 +6,5 @@ if ./gradlew jacocoInstrumentationTestReport; then
|
|||||||
echo "jacocoInstrumentationTestReport succeeded" >&2
|
echo "jacocoInstrumentationTestReport succeeded" >&2
|
||||||
else
|
else
|
||||||
adb exec-out screencap -p >screencap.png
|
adb exec-out screencap -p >screencap.png
|
||||||
echo "jacocoInstrumentationTestReport failed" >&2
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
@ -6,5 +6,5 @@ if ./gradlew connectedDebugAndroidTest; then
|
|||||||
echo "connectedDebugAndroidTest succeeded" >&2
|
echo "connectedDebugAndroidTest succeeded" >&2
|
||||||
else
|
else
|
||||||
adb exec-out screencap -p >screencap.png
|
adb exec-out screencap -p >screencap.png
|
||||||
echo "connectedDebugAndroidTest failed" >&2
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
@ -70,7 +70,7 @@ class StorageSelectDialog : DialogFragment() {
|
|||||||
layoutManager = LinearLayoutManager(context, RecyclerView.VERTICAL, false)
|
layoutManager = LinearLayoutManager(context, RecyclerView.VERTICAL, false)
|
||||||
setHasFixedSize(true)
|
setHasFixedSize(true)
|
||||||
}
|
}
|
||||||
Flowable.fromCallable { StorageDeviceUtils.getWritableStorage(activity!!) }
|
Flowable.fromCallable { StorageDeviceUtils.getWritableStorage(requireActivity()) }
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(
|
.subscribe(
|
||||||
|
@ -34,6 +34,7 @@ import android.view.ViewGroup;
|
|||||||
import android.webkit.WebSettings;
|
import android.webkit.WebSettings;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
import com.cprcrack.videowebview.VideoEnabledWebView;
|
import com.cprcrack.videowebview.VideoEnabledWebView;
|
||||||
|
import io.reactivex.disposables.CompositeDisposable;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -55,18 +56,17 @@ public class KiwixWebView extends VideoEnabledWebView {
|
|||||||
0, 0, -1.0f, 0, 255, // blue
|
0, 0, -1.0f, 0, 255, // blue
|
||||||
0, 0, 0, 1.0f, 0 // alpha
|
0, 0, 0, 1.0f, 0 // alpha
|
||||||
};
|
};
|
||||||
private final ViewGroup videoView;
|
|
||||||
@Inject
|
@Inject
|
||||||
SharedPreferenceUtil sharedPreferenceUtil;
|
SharedPreferenceUtil sharedPreferenceUtil;
|
||||||
@Inject
|
@Inject
|
||||||
ZimReaderContainer zimReaderContainer;
|
ZimReaderContainer zimReaderContainer;
|
||||||
private final WebViewCallback callback;
|
private final WebViewCallback callback;
|
||||||
|
private CompositeDisposable compositeDisposable = new CompositeDisposable();
|
||||||
|
|
||||||
@SuppressLint("SetJavaScriptEnabled")
|
@SuppressLint("SetJavaScriptEnabled")
|
||||||
public KiwixWebView(Context context, WebViewCallback callback, AttributeSet attrs,
|
public KiwixWebView(Context context, WebViewCallback callback, AttributeSet attrs,
|
||||||
ViewGroup nonVideoView, ViewGroup videoView, CoreWebViewClient webViewClient) {
|
ViewGroup nonVideoView, ViewGroup videoView, CoreWebViewClient webViewClient) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
this.videoView = videoView;
|
|
||||||
if (BuildConfig.DEBUG == true && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
if (BuildConfig.DEBUG == true && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||||
setWebContentsDebuggingEnabled(true);
|
setWebContentsDebuggingEnabled(true);
|
||||||
}
|
}
|
||||||
@ -123,6 +123,19 @@ public class KiwixWebView extends VideoEnabledWebView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override protected void onAttachedToWindow() {
|
||||||
|
super.onAttachedToWindow();
|
||||||
|
compositeDisposable.add(
|
||||||
|
sharedPreferenceUtil.getTextZooms()
|
||||||
|
.subscribe(textZoom -> getSettings().setTextZoom(textZoom))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override protected void onDetachedFromWindow() {
|
||||||
|
super.onDetachedFromWindow();
|
||||||
|
compositeDisposable.clear();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onScrollChanged(int l, int t, int oldl, int oldt) {
|
protected void onScrollChanged(int l, int t, int oldl, int oldt) {
|
||||||
super.onScrollChanged(l, t, oldl, oldt);
|
super.onScrollChanged(l, t, oldl, oldt);
|
||||||
|
@ -24,15 +24,14 @@ import android.content.Intent;
|
|||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.EditTextPreference;
|
|
||||||
import android.preference.ListPreference;
|
|
||||||
import android.preference.Preference;
|
|
||||||
import android.preference.PreferenceFragment;
|
|
||||||
import android.preference.PreferenceScreen;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.webkit.WebView;
|
import android.webkit.WebView;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
|
import androidx.preference.EditTextPreference;
|
||||||
|
import androidx.preference.ListPreference;
|
||||||
|
import androidx.preference.Preference;
|
||||||
|
import androidx.preference.PreferenceFragmentCompat;
|
||||||
import com.google.android.material.snackbar.Snackbar;
|
import com.google.android.material.snackbar.Snackbar;
|
||||||
import eu.mhutti1.utils.storage.StorageDevice;
|
import eu.mhutti1.utils.storage.StorageDevice;
|
||||||
import eu.mhutti1.utils.storage.StorageSelectDialog;
|
import eu.mhutti1.utils.storage.StorageSelectDialog;
|
||||||
@ -56,7 +55,7 @@ import static org.kiwix.kiwixmobile.core.utils.ConstantsKt.RESULT_RESTART;
|
|||||||
import static org.kiwix.kiwixmobile.core.utils.SharedPreferenceUtil.PREF_NIGHT_MODE;
|
import static org.kiwix.kiwixmobile.core.utils.SharedPreferenceUtil.PREF_NIGHT_MODE;
|
||||||
import static org.kiwix.kiwixmobile.core.utils.SharedPreferenceUtil.PREF_STORAGE;
|
import static org.kiwix.kiwixmobile.core.utils.SharedPreferenceUtil.PREF_STORAGE;
|
||||||
|
|
||||||
public abstract class CorePrefsFragment extends PreferenceFragment implements
|
public abstract class CorePrefsFragment extends PreferenceFragmentCompat implements
|
||||||
SettingsContract.View,
|
SettingsContract.View,
|
||||||
SharedPreferences.OnSharedPreferenceChangeListener {
|
SharedPreferences.OnSharedPreferenceChangeListener {
|
||||||
|
|
||||||
@ -64,6 +63,9 @@ public abstract class CorePrefsFragment extends PreferenceFragment implements
|
|||||||
public static final String PREF_CLEAR_ALL_HISTORY = "pref_clear_all_history";
|
public static final String PREF_CLEAR_ALL_HISTORY = "pref_clear_all_history";
|
||||||
public static final String PREF_CLEAR_ALL_NOTES = "pref_clear_all_notes";
|
public static final String PREF_CLEAR_ALL_NOTES = "pref_clear_all_notes";
|
||||||
public static final String PREF_CREDITS = "pref_credits";
|
public static final String PREF_CREDITS = "pref_credits";
|
||||||
|
private static final int ZOOM_OFFSET = 2;
|
||||||
|
private static final int ZOOM_SCALE = 25;
|
||||||
|
private static final String INTERNAL_TEXT_ZOOM = "text_zoom";
|
||||||
@Inject
|
@Inject
|
||||||
SettingsPresenter presenter;
|
SettingsPresenter presenter;
|
||||||
@Inject
|
@Inject
|
||||||
@ -76,21 +78,35 @@ public abstract class CorePrefsFragment extends PreferenceFragment implements
|
|||||||
protected DialogShower alertDialogShower;
|
protected DialogShower alertDialogShower;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
||||||
CoreApp.getCoreComponent()
|
CoreApp.getCoreComponent()
|
||||||
.activityComponentBuilder()
|
.activityComponentBuilder()
|
||||||
.activity(getActivity())
|
.activity(getActivity())
|
||||||
.build()
|
.build()
|
||||||
.inject(this);
|
.inject(this);
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
addPreferencesFromResource(R.xml.preferences);
|
addPreferencesFromResource(R.xml.preferences);
|
||||||
|
|
||||||
setStorage();
|
setStorage();
|
||||||
setUpSettings();
|
setUpSettings();
|
||||||
|
setupZoom();
|
||||||
new LanguageUtils(getActivity()).changeFont(getActivity().getLayoutInflater(),
|
new LanguageUtils(getActivity()).changeFont(getActivity().getLayoutInflater(),
|
||||||
sharedPreferenceUtil);
|
sharedPreferenceUtil);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setupZoom() {
|
||||||
|
final Preference textZoom = findPreference(INTERNAL_TEXT_ZOOM);
|
||||||
|
textZoom.setOnPreferenceChangeListener(
|
||||||
|
(preference, newValue) -> {
|
||||||
|
sharedPreferenceUtil.setTextZoom((((Integer) newValue) + ZOOM_OFFSET) * ZOOM_SCALE);
|
||||||
|
updateTextZoomSummary(textZoom);
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
updateTextZoomSummary(textZoom);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateTextZoomSummary(Preference textZoom) {
|
||||||
|
textZoom.setSummary(getString(R.string.percentage, sharedPreferenceUtil.getTextZoom()));
|
||||||
|
}
|
||||||
|
|
||||||
protected abstract void setStorage();
|
protected abstract void setStorage();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -112,7 +128,7 @@ public abstract class CorePrefsFragment extends PreferenceFragment implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void setUpLanguageChooser(String preferenceId) {
|
protected void setUpLanguageChooser(String preferenceId) {
|
||||||
ListPreference languagePref = (ListPreference) findPreference(preferenceId);
|
ListPreference languagePref = findPreference(preferenceId);
|
||||||
List<String> languageCodeList = new LanguageUtils(getActivity()).getKeys();
|
List<String> languageCodeList = new LanguageUtils(getActivity()).getKeys();
|
||||||
languageCodeList.add(0, Locale.ROOT.getLanguage());
|
languageCodeList.add(0, Locale.ROOT.getLanguage());
|
||||||
final String selectedLang =
|
final String selectedLang =
|
||||||
@ -154,7 +170,7 @@ public abstract class CorePrefsFragment extends PreferenceFragment implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setAppVersionNumber() {
|
private void setAppVersionNumber() {
|
||||||
EditTextPreference versionPref = (EditTextPreference) findPreference(PREF_VERSION);
|
EditTextPreference versionPref = findPreference(PREF_VERSION);
|
||||||
versionPref.setSummary(getVersionName() + " Build: " + getVersionCode());
|
versionPref.setSummary(getVersionName() + " Build: " + getVersionCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -205,7 +221,8 @@ public abstract class CorePrefsFragment extends PreferenceFragment implements
|
|||||||
if (ContextCompat.checkSelfPermission(getActivity(),
|
if (ContextCompat.checkSelfPermission(getActivity(),
|
||||||
Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
||||||
!= PackageManager.PERMISSION_GRANTED) {
|
!= PackageManager.PERMISSION_GRANTED) {
|
||||||
Snackbar.make(getView(), R.string.ext_storage_permission_not_granted, Snackbar.LENGTH_SHORT).show();
|
Snackbar.make(getView(), R.string.ext_storage_permission_not_granted, Snackbar.LENGTH_SHORT)
|
||||||
|
.show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -229,9 +246,7 @@ public abstract class CorePrefsFragment extends PreferenceFragment implements
|
|||||||
alertDialogShower.show(new KiwixDialog.OpenCredits(() -> view));
|
alertDialogShower.show(new KiwixDialog.OpenCredits(() -> view));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override public boolean onPreferenceTreeClick(Preference preference) {
|
||||||
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen,
|
|
||||||
Preference preference) {
|
|
||||||
if (preference.getKey().equalsIgnoreCase(PREF_CLEAR_ALL_HISTORY)) {
|
if (preference.getKey().equalsIgnoreCase(PREF_CLEAR_ALL_HISTORY)) {
|
||||||
clearAllHistoryDialog();
|
clearAllHistoryDialog();
|
||||||
}
|
}
|
||||||
|
@ -18,10 +18,10 @@
|
|||||||
|
|
||||||
package org.kiwix.kiwixmobile.core.settings;
|
package org.kiwix.kiwixmobile.core.settings;
|
||||||
|
|
||||||
import android.app.Fragment;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import androidx.appcompat.widget.Toolbar;
|
import androidx.appcompat.widget.Toolbar;
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
import org.kiwix.kiwixmobile.core.R;
|
import org.kiwix.kiwixmobile.core.R;
|
||||||
import org.kiwix.kiwixmobile.core.base.BaseActivity;
|
import org.kiwix.kiwixmobile.core.base.BaseActivity;
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ public abstract class CoreSettingsActivity extends BaseActivity {
|
|||||||
|
|
||||||
allHistoryCleared = false;
|
allHistoryCleared = false;
|
||||||
|
|
||||||
getFragmentManager()
|
getSupportFragmentManager()
|
||||||
.beginTransaction().
|
.beginTransaction().
|
||||||
replace(R.id.content_frame, createPreferenceFragment())
|
replace(R.id.content_frame, createPreferenceFragment())
|
||||||
.commit();
|
.commit();
|
||||||
|
@ -1,91 +0,0 @@
|
|||||||
/*
|
|
||||||
* Kiwix Android
|
|
||||||
* Copyright (c) 2019 Kiwix <android.kiwix.org>
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.kiwix.kiwixmobile.core.settings;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.preference.SwitchPreference;
|
|
||||||
import android.util.AttributeSet;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.Switch;
|
|
||||||
|
|
||||||
public class CustomSwitchPreference extends SwitchPreference {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct a new SwitchPreference with the given style options.
|
|
||||||
*
|
|
||||||
* @param context The Context that will style this preference
|
|
||||||
* @param attrs Style attributes that differ from the default
|
|
||||||
* @param defStyle Theme attribute defining the default style options
|
|
||||||
*/
|
|
||||||
public CustomSwitchPreference(Context context, AttributeSet attrs, int defStyle) {
|
|
||||||
super(context, attrs, defStyle);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct a new SwitchPreference with the given style options.
|
|
||||||
*
|
|
||||||
* @param context The Context that will style this preference
|
|
||||||
* @param attrs Style attributes that differ from the default
|
|
||||||
*/
|
|
||||||
public CustomSwitchPreference(Context context, AttributeSet attrs) {
|
|
||||||
super(context, attrs);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct a new SwitchPreference with default style options.
|
|
||||||
*
|
|
||||||
* @param context The Context that will style this preference
|
|
||||||
*/
|
|
||||||
public CustomSwitchPreference(Context context) {
|
|
||||||
super(context, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onBindView(View view) {
|
|
||||||
// Clean listener before invoke SwitchPreference.onBindView
|
|
||||||
ViewGroup viewGroup = (ViewGroup) view;
|
|
||||||
clearListenerInViewGroup(viewGroup);
|
|
||||||
super.onBindView(view);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Clear listener in Switch for specify ViewGroup.
|
|
||||||
*
|
|
||||||
* @param viewGroup The ViewGroup that will need to clear the listener.
|
|
||||||
*/
|
|
||||||
private void clearListenerInViewGroup(ViewGroup viewGroup) {
|
|
||||||
if (null == viewGroup) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int count = viewGroup.getChildCount();
|
|
||||||
for (int n = 0; n < count; ++n) {
|
|
||||||
View childView = viewGroup.getChildAt(n);
|
|
||||||
if (childView instanceof Switch) {
|
|
||||||
final Switch switchView = (Switch) childView;
|
|
||||||
switchView.setOnCheckedChangeListener(null);
|
|
||||||
return;
|
|
||||||
} else if (childView instanceof ViewGroup) {
|
|
||||||
ViewGroup childGroup = (ViewGroup) childView;
|
|
||||||
clearListenerInViewGroup(childGroup);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -58,8 +58,10 @@ public class SharedPreferenceUtil {
|
|||||||
private static final String PREF_SHOW_HISTORY_CURRENT_BOOK = "show_history_current_book";
|
private static final String PREF_SHOW_HISTORY_CURRENT_BOOK = "show_history_current_book";
|
||||||
private static final String PREF_HOSTED_BOOKS = "hosted_books";
|
private static final String PREF_HOSTED_BOOKS = "hosted_books";
|
||||||
public static final String PREF_NIGHT_MODE = "pref_night_mode";
|
public static final String PREF_NIGHT_MODE = "pref_night_mode";
|
||||||
|
private static final String TEXT_ZOOM = "true_text_zoom";
|
||||||
private SharedPreferences sharedPreferences;
|
private SharedPreferences sharedPreferences;
|
||||||
private final PublishProcessor<String> prefStorages = PublishProcessor.create();
|
private final PublishProcessor<String> prefStorages = PublishProcessor.create();
|
||||||
|
private final PublishProcessor<Integer> textZooms = PublishProcessor.create();
|
||||||
private final PublishProcessor<NightModeConfig.Mode> nightModes = PublishProcessor.create();
|
private final PublishProcessor<NightModeConfig.Mode> nightModes = PublishProcessor.create();
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@ -217,4 +219,17 @@ public class SharedPreferenceUtil {
|
|||||||
.putStringSet(PREF_HOSTED_BOOKS, hostedBooks)
|
.putStringSet(PREF_HOSTED_BOOKS, hostedBooks)
|
||||||
.apply();
|
.apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setTextZoom(int textZoom) {
|
||||||
|
sharedPreferences.edit().putInt(TEXT_ZOOM, textZoom).apply();
|
||||||
|
textZooms.offer(textZoom);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getTextZoom() {
|
||||||
|
return sharedPreferences.getInt(TEXT_ZOOM, 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Flowable<Integer> getTextZooms() {
|
||||||
|
return textZooms.startWith(getTextZoom());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -273,6 +273,8 @@
|
|||||||
<string name="crash_checkbox_file_system">File System Details</string>
|
<string name="crash_checkbox_file_system">File System Details</string>
|
||||||
<string name="diagnostic_report">Diagnostic Report</string>
|
<string name="diagnostic_report">Diagnostic Report</string>
|
||||||
<string name="diagnostic_report_message">Please send all the following details so we can diagnose the problem</string>
|
<string name="diagnostic_report_message">Please send all the following details so we can diagnose the problem</string>
|
||||||
|
<string name="percentage">%d%%</string>
|
||||||
|
<string name="pref_text_zoom_title">Text Zoom</string>
|
||||||
<string-array name="pref_night_modes_entries">
|
<string-array name="pref_night_modes_entries">
|
||||||
<item>@string/on</item>
|
<item>@string/on</item>
|
||||||
<item>@string/off</item>
|
<item>@string/off</item>
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
app:iconSpaceReserved="false">
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:key="pref_display"
|
android:key="pref_display"
|
||||||
android:title="@string/pref_display_title">
|
android:title="@string/pref_display_title"
|
||||||
|
app:iconSpaceReserved="false">
|
||||||
|
|
||||||
<ListPreference
|
<ListPreference
|
||||||
android:defaultValue="-1"
|
android:defaultValue="-1"
|
||||||
@ -9,90 +12,113 @@
|
|||||||
android:entryValues="@array/pref_night_modes_values"
|
android:entryValues="@array/pref_night_modes_values"
|
||||||
android:key="pref_night_mode"
|
android:key="pref_night_mode"
|
||||||
android:summary="@string/pref_night_mode_summary"
|
android:summary="@string/pref_night_mode_summary"
|
||||||
android:title="@string/pref_night_mode" />
|
android:title="@string/pref_night_mode"
|
||||||
|
app:iconSpaceReserved="false" />
|
||||||
|
|
||||||
<org.kiwix.kiwixmobile.core.settings.CustomSwitchPreference
|
<SwitchPreferenceCompat
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
android:key="pref_backtotop"
|
android:key="pref_backtotop"
|
||||||
android:summary="@string/pref_back_to_top_summary"
|
android:summary="@string/pref_back_to_top_summary"
|
||||||
android:title="@string/pref_back_to_top" />
|
android:title="@string/pref_back_to_top"
|
||||||
|
app:iconSpaceReserved="false" />
|
||||||
|
|
||||||
<org.kiwix.kiwixmobile.core.settings.CustomSwitchPreference
|
<SwitchPreferenceCompat
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
android:key="pref_hidetoolbar"
|
android:key="pref_hidetoolbar"
|
||||||
android:summary="@string/pref_hide_toolbar_summary"
|
android:summary="@string/pref_hide_toolbar_summary"
|
||||||
android:title="@string/pref_hide_toolbar" />
|
android:title="@string/pref_hide_toolbar"
|
||||||
|
app:iconSpaceReserved="false" />
|
||||||
|
|
||||||
|
<SeekBarPreference
|
||||||
|
android:defaultValue="2"
|
||||||
|
android:max="6"
|
||||||
|
app:iconSpaceReserved="false"
|
||||||
|
app:key="text_zoom"
|
||||||
|
app:title="@string/pref_text_zoom_title"
|
||||||
|
app:updatesContinuously="true" />
|
||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:key="pref_extras"
|
android:key="pref_extras"
|
||||||
android:title="@string/pref_extras">
|
android:title="@string/pref_extras"
|
||||||
|
app:iconSpaceReserved="false">
|
||||||
|
|
||||||
<org.kiwix.kiwixmobile.core.settings.CustomSwitchPreference
|
<SwitchPreferenceCompat
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
android:key="pref_newtab_background"
|
android:key="pref_newtab_background"
|
||||||
android:summary="@string/pref_newtab_background_summary"
|
android:summary="@string/pref_newtab_background_summary"
|
||||||
android:title="@string/pref_newtab_background_title" />
|
android:title="@string/pref_newtab_background_title"
|
||||||
|
app:iconSpaceReserved="false" />
|
||||||
|
|
||||||
<org.kiwix.kiwixmobile.core.settings.CustomSwitchPreference
|
<SwitchPreferenceCompat
|
||||||
android:defaultValue="true"
|
android:defaultValue="true"
|
||||||
android:key="pref_external_link_popup"
|
android:key="pref_external_link_popup"
|
||||||
android:summary="@string/pref_external_link_popup_summary"
|
android:summary="@string/pref_external_link_popup_summary"
|
||||||
android:title="@string/pref_external_link_popup_title" />
|
android:title="@string/pref_external_link_popup_title"
|
||||||
|
app:iconSpaceReserved="false" />
|
||||||
|
|
||||||
<org.kiwix.kiwixmobile.core.settings.CustomSwitchPreference
|
<SwitchPreferenceCompat
|
||||||
android:defaultValue="true"
|
android:defaultValue="true"
|
||||||
android:key="pref_wifi_only"
|
android:key="pref_wifi_only"
|
||||||
android:summary="@string/pref_wifi_only"
|
android:summary="@string/pref_wifi_only"
|
||||||
android:title="@string/pref_wifi_only" />
|
android:title="@string/pref_wifi_only"
|
||||||
|
app:iconSpaceReserved="false" />
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:key="pref_storage"
|
android:key="pref_storage"
|
||||||
android:title="@string/pref_storage">
|
app:title="@string/pref_storage"
|
||||||
|
app:iconSpaceReserved="false">
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
android:key="pref_select_folder"
|
android:key="pref_select_folder"
|
||||||
android:title="@string/pref_current_folder" />
|
android:title="@string/pref_current_folder"
|
||||||
|
app:iconSpaceReserved="false" />
|
||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:key="pref_history"
|
android:key="pref_history"
|
||||||
android:title="History">
|
android:title="History"
|
||||||
|
app:iconSpaceReserved="false">
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
android:key="pref_clear_all_history"
|
android:key="pref_clear_all_history"
|
||||||
android:summary="@string/pref_clear_all_history_summary"
|
android:summary="@string/pref_clear_all_history_summary"
|
||||||
android:title="@string/pref_clear_all_history_title" />
|
android:title="@string/pref_clear_all_history_title"
|
||||||
|
app:iconSpaceReserved="false" />
|
||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:key="pref_notes"
|
android:key="pref_notes"
|
||||||
android:title="Notes">
|
android:title="Notes"
|
||||||
|
app:iconSpaceReserved="false">
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
android:key="pref_clear_all_notes"
|
android:key="pref_clear_all_notes"
|
||||||
android:summary="@string/pref_clear_all_notes_summary"
|
android:summary="@string/pref_clear_all_notes_summary"
|
||||||
android:title="@string/pref_clear_all_notes_title" />
|
android:title="@string/pref_clear_all_notes_title"
|
||||||
|
app:iconSpaceReserved="false" />
|
||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:key="pref_language"
|
android:key="pref_language"
|
||||||
android:title="@string/pref_language_title">
|
android:title="@string/pref_language_title"
|
||||||
|
app:iconSpaceReserved="false">
|
||||||
|
|
||||||
<ListPreference
|
<ListPreference
|
||||||
android:key="pref_language_chooser"
|
android:key="pref_language_chooser"
|
||||||
android:summary="@string/pref_language_chooser"
|
android:summary="@string/pref_language_chooser"
|
||||||
android:title="@string/pref_language_title" />
|
android:title="@string/pref_language_title"
|
||||||
|
app:iconSpaceReserved="false" />
|
||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:key="pref_info"
|
android:key="pref_info"
|
||||||
android:title="@string/pref_info_title">
|
android:title="@string/pref_info_title"
|
||||||
|
app:iconSpaceReserved="false">
|
||||||
|
|
||||||
<EditTextPreference
|
<EditTextPreference
|
||||||
android:enabled="false"
|
android:enabled="false"
|
||||||
@ -100,12 +126,14 @@
|
|||||||
android:persistent="false"
|
android:persistent="false"
|
||||||
android:selectable="true"
|
android:selectable="true"
|
||||||
android:shouldDisableView="false"
|
android:shouldDisableView="false"
|
||||||
android:title="@string/pref_info_version" />
|
android:title="@string/pref_info_version"
|
||||||
|
app:iconSpaceReserved="false" />
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
android:key="pref_credits"
|
android:key="pref_credits"
|
||||||
android:summary="@string/pref_credits"
|
android:summary="@string/pref_credits"
|
||||||
android:title="@string/pref_credits_title" />
|
android:title="@string/pref_credits_title"
|
||||||
|
app:iconSpaceReserved="false" />
|
||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
|
@ -19,22 +19,20 @@
|
|||||||
package org.kiwix.kiwixmobile.custom.settings
|
package org.kiwix.kiwixmobile.custom.settings
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.preference.PreferenceCategory
|
|
||||||
import org.kiwix.kiwixmobile.core.settings.CorePrefsFragment
|
import org.kiwix.kiwixmobile.core.settings.CorePrefsFragment
|
||||||
import org.kiwix.kiwixmobile.core.utils.SharedPreferenceUtil.PREF_LANG
|
import org.kiwix.kiwixmobile.core.utils.SharedPreferenceUtil.PREF_LANG
|
||||||
|
import org.kiwix.kiwixmobile.core.utils.SharedPreferenceUtil.PREF_WIFI_ONLY
|
||||||
import org.kiwix.kiwixmobile.custom.BuildConfig
|
import org.kiwix.kiwixmobile.custom.BuildConfig
|
||||||
|
|
||||||
class CustomPrefsFragment : CorePrefsFragment() {
|
class CustomPrefsFragment : CorePrefsFragment() {
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreatePreferences(savedInstanceState, rootKey)
|
||||||
if (BuildConfig.ENFORCED_LANG == "") {
|
if (BuildConfig.ENFORCED_LANG.isEmpty()) {
|
||||||
setUpLanguageChooser(PREF_LANG)
|
setUpLanguageChooser(PREF_LANG)
|
||||||
} else {
|
} else {
|
||||||
preferenceScreen.removePreference(findPreference("pref_language"))
|
preferenceScreen.removePreference(findPreference("pref_language"))
|
||||||
}
|
}
|
||||||
|
preferenceScreen.removePreference(findPreference(PREF_WIFI_ONLY))
|
||||||
val notificationsCategory = findPreference("pref_extras") as PreferenceCategory
|
|
||||||
notificationsCategory.removePreference(findPreference("pref_wifi_only"))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setStorage() {
|
override fun setStorage() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user