diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index d818edf0b3..2d5b808bce 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -1,20 +1,18 @@ -**Is it a ?** +# Fill out this template with your issue then delete these lines only leaving the titles and your responses. -- [ ] Bug Report - -- [ ] Feature Request +# For a Bug Report: ## Bug Report -### Step 1: Are you ready to report? +### Are you ready to report? - Your issue may already be reported! Please search on the [issue track](../) before creating one. - - [ ] I have tested with the last (dev) version of the software. ( If not, and if possible, run your test again with the most recent version available.) + - Ensure you have tested with the last (dev) version of the software. (If not, and if possible, run your test again with the most recent version available.) -### Step 2: What is your environment? +### Environment * version of the software you use : _____ * device / operating system : _____ -### Step 3: Describe the problem: +### The Bug: * What do you obtain? A copy of the error message or a screenshot is always useful. @@ -30,12 +28,14 @@ * What should be the behaviour from your point of view? How do you expect the service to work? -### Step 4 (optional) : Other Comments: +### Other Comments: * What is the context of this ticket? If not obvious, explain why you need to do this. * If you have an idea about the technical background of the ticket, please share it. +# For a Feature Request: + ## Feature Request #### Feature Description diff --git a/.gitignore b/.gitignore index 0ee45035e6..8d9b5b8c31 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,9 @@ # Files for the Dalvik VM *.dex +header.txt +app/header.bash + # Java class files *.class diff --git a/app/build.gradle b/app/build.gradle index 8efe84d56e..bc3c52921d 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -89,10 +89,10 @@ dependencies { implementation 'commons-io:commons-io:2.5' // Square - implementation 'com.squareup.okhttp3:okhttp:3.7.0' - implementation 'com.squareup.okhttp3:logging-interceptor:3.6.0' - implementation 'com.squareup.retrofit2:retrofit:2.1.0' - implementation 'com.squareup.retrofit2:adapter-rxjava:2.1.0' + implementation "com.squareup.okhttp3:okhttp:$okHttpVersion" + implementation "com.squareup.okhttp3:logging-interceptor:$okHttpVersion" + implementation "com.squareup.retrofit2:retrofit:$retrofitVersion" + implementation "com.squareup.retrofit2:adapter-rxjava2:$retrofitVersion" implementation('com.squareup.retrofit2:converter-simplexml:2.1.0') { exclude group: 'xpp3', module: 'xpp3' exclude group: 'stax', module: 'stax-api' @@ -106,8 +106,8 @@ dependencies { annotationProcessor 'com.jakewharton:butterknife-compiler:8.0.1' // RxJava - implementation 'io.reactivex:rxandroid:1.1.0' - implementation 'io.reactivex:rxjava:1.1.5' + implementation "io.reactivex.rxjava2:rxandroid:$rxAndroidVersion" + implementation "io.reactivex.rxjava2:rxjava:$rxJavaVersion" // JUnit testImplementation 'junit:junit:4.12' @@ -147,6 +147,7 @@ android { // See https://github.com/linkedin/dexmaker/issues/65 for why we need the following line. testInstrumentationRunnerArguments.notClass = 'com.android.dex.DexIndexOverflowException' multiDexEnabled true + vectorDrawables.useSupportLibrary = true } aaptOptions { diff --git a/app/src/androidTest/java/org/kiwix/kiwixmobile/testutils/TestUtils.java b/app/src/androidTest/java/org/kiwix/kiwixmobile/testutils/TestUtils.java index 0812e2e825..16252939a2 100644 --- a/app/src/androidTest/java/org/kiwix/kiwixmobile/testutils/TestUtils.java +++ b/app/src/androidTest/java/org/kiwix/kiwixmobile/testutils/TestUtils.java @@ -1,3 +1,20 @@ +/* + * Kiwix Android + * Copyright (C) 2018 Kiwix + * + * 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 . + */ package org.kiwix.kiwixmobile.testutils; import android.Manifest; diff --git a/app/src/androidTestKiwix/java/org/kiwix/kiwixmobile/di/components/TestComponent.java b/app/src/androidTestKiwix/java/org/kiwix/kiwixmobile/di/components/TestComponent.java index f01a8840dd..811df2c788 100644 --- a/app/src/androidTestKiwix/java/org/kiwix/kiwixmobile/di/components/TestComponent.java +++ b/app/src/androidTestKiwix/java/org/kiwix/kiwixmobile/di/components/TestComponent.java @@ -1,3 +1,20 @@ +/* + * Kiwix Android + * Copyright (C) 2018 Kiwix + * + * 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 . + */ package org.kiwix.kiwixmobile.di.components; import org.kiwix.kiwixmobile.di.modules.ApplicationModule; diff --git a/app/src/androidTestKiwix/java/org/kiwix/kiwixmobile/di/modules/TestJNIModule.java b/app/src/androidTestKiwix/java/org/kiwix/kiwixmobile/di/modules/TestJNIModule.java index 3375c65633..23c425e5bd 100644 --- a/app/src/androidTestKiwix/java/org/kiwix/kiwixmobile/di/modules/TestJNIModule.java +++ b/app/src/androidTestKiwix/java/org/kiwix/kiwixmobile/di/modules/TestJNIModule.java @@ -1,3 +1,20 @@ +/* + * Kiwix Android + * Copyright (C) 2018 Kiwix + * + * 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 . + */ package org.kiwix.kiwixmobile.di.modules; import org.apache.commons.io.IOUtils; diff --git a/app/src/androidTestKiwix/java/org/kiwix/kiwixmobile/di/modules/TestNetworkModule.java b/app/src/androidTestKiwix/java/org/kiwix/kiwixmobile/di/modules/TestNetworkModule.java index 87ca7905ed..b8f7c676b0 100644 --- a/app/src/androidTestKiwix/java/org/kiwix/kiwixmobile/di/modules/TestNetworkModule.java +++ b/app/src/androidTestKiwix/java/org/kiwix/kiwixmobile/di/modules/TestNetworkModule.java @@ -1,3 +1,20 @@ +/* + * Kiwix Android + * Copyright (C) 2018 Kiwix + * + * 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 . + */ package org.kiwix.kiwixmobile.di.modules; diff --git a/app/src/androidTestKiwix/java/org/kiwix/kiwixmobile/tests/BasicTest.java b/app/src/androidTestKiwix/java/org/kiwix/kiwixmobile/tests/BasicTest.java index 987bdcb273..55e31241ad 100644 --- a/app/src/androidTestKiwix/java/org/kiwix/kiwixmobile/tests/BasicTest.java +++ b/app/src/androidTestKiwix/java/org/kiwix/kiwixmobile/tests/BasicTest.java @@ -1,3 +1,20 @@ +/* + * Kiwix Android + * Copyright (C) 2018 Kiwix + * + * 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 . + */ package org.kiwix.kiwixmobile.tests; diff --git a/app/src/androidTestKiwix/java/org/kiwix/kiwixmobile/tests/ContentTest.java b/app/src/androidTestKiwix/java/org/kiwix/kiwixmobile/tests/ContentTest.java index ee8f4f5b31..0386c12a3c 100644 --- a/app/src/androidTestKiwix/java/org/kiwix/kiwixmobile/tests/ContentTest.java +++ b/app/src/androidTestKiwix/java/org/kiwix/kiwixmobile/tests/ContentTest.java @@ -1,3 +1,20 @@ +/* + * Kiwix Android + * Copyright (C) 2018 Kiwix + * + * 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 . + */ package org.kiwix.kiwixmobile.tests; diff --git a/app/src/androidTestKiwix/java/org/kiwix/kiwixmobile/tests/DownloadTest.java b/app/src/androidTestKiwix/java/org/kiwix/kiwixmobile/tests/DownloadTest.java index 192151bea2..9d0f39c4c7 100644 --- a/app/src/androidTestKiwix/java/org/kiwix/kiwixmobile/tests/DownloadTest.java +++ b/app/src/androidTestKiwix/java/org/kiwix/kiwixmobile/tests/DownloadTest.java @@ -1,3 +1,20 @@ +/* + * Kiwix Android + * Copyright (C) 2018 Kiwix + * + * 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 . + */ package org.kiwix.kiwixmobile.tests; diff --git a/app/src/androidTestKiwix/java/org/kiwix/kiwixmobile/tests/KiwixMobileActivityTest.java b/app/src/androidTestKiwix/java/org/kiwix/kiwixmobile/tests/KiwixMobileActivityTest.java index b0f17ca835..aa751afef8 100644 --- a/app/src/androidTestKiwix/java/org/kiwix/kiwixmobile/tests/KiwixMobileActivityTest.java +++ b/app/src/androidTestKiwix/java/org/kiwix/kiwixmobile/tests/KiwixMobileActivityTest.java @@ -1,3 +1,20 @@ +/* + * Kiwix Android + * Copyright (C) 2018 Kiwix + * + * 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 . + */ package org.kiwix.kiwixmobile.tests; /** diff --git a/app/src/androidTestKiwix/java/org/kiwix/kiwixmobile/tests/NetworkTest.java b/app/src/androidTestKiwix/java/org/kiwix/kiwixmobile/tests/NetworkTest.java index 5d085b4e49..75f3b8cb56 100644 --- a/app/src/androidTestKiwix/java/org/kiwix/kiwixmobile/tests/NetworkTest.java +++ b/app/src/androidTestKiwix/java/org/kiwix/kiwixmobile/tests/NetworkTest.java @@ -1,3 +1,20 @@ +/* + * Kiwix Android + * Copyright (C) 2018 Kiwix + * + * 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 . + */ package org.kiwix.kiwixmobile.tests; import android.support.test.espresso.Espresso; diff --git a/app/src/androidTestKiwix/java/org/kiwix/kiwixmobile/tests/ZimTest.java b/app/src/androidTestKiwix/java/org/kiwix/kiwixmobile/tests/ZimTest.java index 7ff9cc19d7..b359533c6c 100644 --- a/app/src/androidTestKiwix/java/org/kiwix/kiwixmobile/tests/ZimTest.java +++ b/app/src/androidTestKiwix/java/org/kiwix/kiwixmobile/tests/ZimTest.java @@ -1,3 +1,20 @@ +/* + * Kiwix Android + * Copyright (C) 2018 Kiwix + * + * 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 . + */ package org.kiwix.kiwixmobile.tests; import android.content.Context; diff --git a/app/src/androidTestKiwix/java/org/kiwix/kiwixmobile/utils/KiwixIdlingResource.java b/app/src/androidTestKiwix/java/org/kiwix/kiwixmobile/utils/KiwixIdlingResource.java index c6568fb0f0..d3d3a3cfee 100644 --- a/app/src/androidTestKiwix/java/org/kiwix/kiwixmobile/utils/KiwixIdlingResource.java +++ b/app/src/androidTestKiwix/java/org/kiwix/kiwixmobile/utils/KiwixIdlingResource.java @@ -1,3 +1,20 @@ +/* + * Kiwix Android + * Copyright (C) 2018 Kiwix + * + * 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 . + */ package org.kiwix.kiwixmobile.utils; import android.support.test.espresso.IdlingResource; diff --git a/app/src/androidTestKiwix/java/org/kiwix/kiwixmobile/utils/StandardActions.java b/app/src/androidTestKiwix/java/org/kiwix/kiwixmobile/utils/StandardActions.java index 435e5754ab..3548db3a21 100644 --- a/app/src/androidTestKiwix/java/org/kiwix/kiwixmobile/utils/StandardActions.java +++ b/app/src/androidTestKiwix/java/org/kiwix/kiwixmobile/utils/StandardActions.java @@ -1,3 +1,20 @@ +/* + * Kiwix Android + * Copyright (C) 2018 Kiwix + * + * 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 . + */ package org.kiwix.kiwixmobile.utils; import static android.support.test.espresso.Espresso.onView; diff --git a/app/src/androidTestKiwix/java/org/kiwix/kiwixmobile/utils/TestNetworkInterceptor.java b/app/src/androidTestKiwix/java/org/kiwix/kiwixmobile/utils/TestNetworkInterceptor.java index 4cfc3bd94d..d81a777d62 100644 --- a/app/src/androidTestKiwix/java/org/kiwix/kiwixmobile/utils/TestNetworkInterceptor.java +++ b/app/src/androidTestKiwix/java/org/kiwix/kiwixmobile/utils/TestNetworkInterceptor.java @@ -1,3 +1,20 @@ +/* + * Kiwix Android + * Copyright (C) 2018 Kiwix + * + * 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 . + */ package org.kiwix.kiwixmobile.utils; import org.kiwix.kiwixmobile.KiwixApplication; diff --git a/app/src/main/java/org/kiwix/kiwixmobile/KiwixActionBarDrawerToggle.java b/app/src/main/java/org/kiwix/kiwixmobile/KiwixActionBarDrawerToggle.java index 4bbce8172d..fb0b4b33ec 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/KiwixActionBarDrawerToggle.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/KiwixActionBarDrawerToggle.java @@ -1,3 +1,20 @@ +/* + * Kiwix Android + * Copyright (C) 2018 Kiwix + * + * 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 . + */ package org.kiwix.kiwixmobile; import android.support.v4.view.GravityCompat; diff --git a/app/src/main/java/org/kiwix/kiwixmobile/KiwixApplication.java b/app/src/main/java/org/kiwix/kiwixmobile/KiwixApplication.java index 9d02fc9c94..1fcf383ffa 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/KiwixApplication.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/KiwixApplication.java @@ -1,7 +1,25 @@ +/* + * Kiwix Android + * Copyright (C) 2018 Kiwix + * + * 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 . + */ package org.kiwix.kiwixmobile; import android.content.Context; import android.support.multidex.MultiDexApplication; +import android.support.v7.app.AppCompatDelegate; import org.kiwix.kiwixmobile.di.components.ApplicationComponent; import org.kiwix.kiwixmobile.di.components.DaggerApplicationComponent; @@ -10,6 +28,11 @@ public class KiwixApplication extends MultiDexApplication { private static KiwixApplication application; + + static { + AppCompatDelegate.setCompatVectorFromResourcesEnabled(true); + } + private ApplicationComponent applicationComponent; public static KiwixApplication getInstance() { diff --git a/app/src/main/java/org/kiwix/kiwixmobile/KiwixMobileActivity.java b/app/src/main/java/org/kiwix/kiwixmobile/KiwixMobileActivity.java index 8f2e748822..781af2950d 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/KiwixMobileActivity.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/KiwixMobileActivity.java @@ -32,11 +32,11 @@ import android.graphics.Color; import android.graphics.PorterDuff; import android.graphics.drawable.Drawable; +import android.media.AudioManager; import android.net.Uri; import android.os.Build; import android.os.Bundle; import android.os.Handler; -import android.preference.PreferenceManager; import android.support.annotation.NonNull; import android.support.design.widget.CoordinatorLayout; import android.support.design.widget.Snackbar; @@ -92,6 +92,7 @@ import org.kiwix.kiwixmobile.utils.LanguageUtils; import org.kiwix.kiwixmobile.utils.NetworkUtils; import org.kiwix.kiwixmobile.utils.RateAppCounter; +import org.kiwix.kiwixmobile.utils.SharedPreferenceUtil; import org.kiwix.kiwixmobile.utils.StyleUtils; import org.kiwix.kiwixmobile.utils.files.FileReader; import org.kiwix.kiwixmobile.utils.files.FileUtils; @@ -132,17 +133,7 @@ import static org.kiwix.kiwixmobile.utils.Constants.EXTRA_SEARCH; import static org.kiwix.kiwixmobile.utils.Constants.EXTRA_ZIM_FILE; import static org.kiwix.kiwixmobile.utils.Constants.EXTRA_ZIM_FILE_2; -import static org.kiwix.kiwixmobile.utils.Constants.PREF_BACK_TO_TOP; -import static org.kiwix.kiwixmobile.utils.Constants.PREF_BOTTOM_TOOLBAR; -import static org.kiwix.kiwixmobile.utils.Constants.PREF_EXTERNAL_LINK_POPUP; -import static org.kiwix.kiwixmobile.utils.Constants.PREF_FULLSCREEN; -import static org.kiwix.kiwixmobile.utils.Constants.PREF_HIDE_TOOLBAR; import static org.kiwix.kiwixmobile.utils.Constants.PREF_KIWIX_MOBILE; -import static org.kiwix.kiwixmobile.utils.Constants.PREF_LANG; -import static org.kiwix.kiwixmobile.utils.Constants.PREF_NEW_TAB_BACKGROUND; -import static org.kiwix.kiwixmobile.utils.Constants.PREF_WIFI_ONLY; -import static org.kiwix.kiwixmobile.utils.Constants.PREF_ZOOM; -import static org.kiwix.kiwixmobile.utils.Constants.PREF_ZOOM_ENABLED; import static org.kiwix.kiwixmobile.utils.Constants.REQUEST_FILE_SEARCH; import static org.kiwix.kiwixmobile.utils.Constants.REQUEST_FILE_SELECT; import static org.kiwix.kiwixmobile.utils.Constants.REQUEST_PREFERENCES; @@ -156,6 +147,8 @@ import static org.kiwix.kiwixmobile.utils.Constants.TAG_FILE_SEARCHED; import static org.kiwix.kiwixmobile.utils.Constants.TAG_KIWIX; import static org.kiwix.kiwixmobile.utils.StyleUtils.dialogStyle; +import static android.os.Build.VERSION.SDK_INT; +import static android.os.Build.VERSION_CODES; public class KiwixMobileActivity extends BaseActivity implements WebViewCallback { @@ -221,8 +214,6 @@ public class KiwixMobileActivity extends BaseActivity implements WebViewCallback private boolean isFirstRun; - private SharedPreferences settings; - private BookmarksDao bookmarksDao; @BindView(R.id.toolbar) Toolbar toolbar; @@ -269,6 +260,7 @@ public class KiwixMobileActivity extends BaseActivity implements WebViewCallback @Inject OkHttpClient okHttpClient; + @Inject SharedPreferenceUtil sharedPreferenceUtil; @Override public void onActionModeStarted(ActionMode mode) { @@ -361,13 +353,12 @@ public void onBookmarkTabLongClicked() { public void onCreate(Bundle savedInstanceState) { getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); - SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); - wifiOnly = sharedPreferences.getBoolean(PREF_WIFI_ONLY, true); - nightMode = KiwixSettingsActivity.nightMode(sharedPreferences); + super.onCreate(savedInstanceState); + wifiOnly = sharedPreferenceUtil.getPrefWifiOnly(); + nightMode = KiwixSettingsActivity.nightMode(sharedPreferenceUtil); if (nightMode) { setTheme(R.style.AppTheme_Night); } - super.onCreate(savedInstanceState); handleLocaleCheck(); setContentView(R.layout.main); ButterKnife.bind(this); @@ -378,7 +369,11 @@ public void onCreate(Bundle savedInstanceState) { initPlayStoreUri(); - isHideToolbar = sharedPreferences.getBoolean(PREF_HIDE_TOOLBAR, true); + if (SDK_INT <= VERSION_CODES.LOLLIPOP) { + snackbarLayout.setFitsSystemWindows(true); + } + + isHideToolbar = sharedPreferenceUtil.getPrefHideToolbar(); FileReader fileReader = new FileReader(); documentParserJs = fileReader.readFile("js/documentParser.js", this); @@ -526,8 +521,7 @@ private void initPlayStoreUri() { } private void checkForRateDialog() { - settings = PreferenceManager.getDefaultSharedPreferences(this); - isFirstRun = settings.getBoolean("isFirstRun", true); + isFirstRun = sharedPreferenceUtil.getPrefIsFirstRun(); visitCounterPref = new RateAppCounter(this); tempVisitCount = visitCounterPref.getCount(); ++tempVisitCount; @@ -633,7 +627,25 @@ public void onSpeakingEnded() { pauseTTSButton.setText(R.string.tts_pause); }); } - }); + }, new AudioManager.OnAudioFocusChangeListener() { + @Override + public void onAudioFocusChange(int focusChange) { + Log.d(TAG_KIWIX, "Focus change: " + String.valueOf(focusChange)); + if (tts.currentTTSTask == null) { + tts.stop(); + return; + } + switch (focusChange) { + case (AudioManager.AUDIOFOCUS_LOSS): + if (!tts.currentTTSTask.paused) tts.pauseOrResume(); + pauseTTSButton.setText(R.string.tts_resume); + break; + case (AudioManager.AUDIOFOCUS_GAIN): + pauseTTSButton.setText(R.string.tts_pause); + break; + } + } + }); pauseTTSButton.setOnClickListener(view -> { if (tts.currentTTSTask == null) { @@ -655,8 +667,8 @@ public void onSpeakingEnded() { // Reset the Locale and change the font of all TextViews and its subclasses, if necessary private void handleLocaleCheck() { - LanguageUtils.handleLocaleChange(this); - new LanguageUtils(this).changeFont(getLayoutInflater()); + LanguageUtils.handleLocaleChange(this, sharedPreferenceUtil); + new LanguageUtils(this).changeFont(getLayoutInflater(), sharedPreferenceUtil); } @Override @@ -899,10 +911,7 @@ private void openFullScreen() { int classicScreenFlag = WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN; getWindow().addFlags(fullScreenFlag); getWindow().clearFlags(classicScreenFlag); - SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this); - SharedPreferences.Editor editor = settings.edit(); - editor.putBoolean(PREF_FULLSCREEN, true); - editor.apply(); + sharedPreferenceUtil.putPrefFullScreen(true); expandDrawers(); isFullscreenOpened = true; getCurrentWebView().requestLayout(); @@ -914,7 +923,7 @@ private void openFullScreen() { private void closeFullScreen() { toolbarContainer.setVisibility(View.VISIBLE); - if (settings.getBoolean(PREF_BOTTOM_TOOLBAR, false)) { + if (sharedPreferenceUtil.getPrefBottomToolbar()) { pageBottomTabLayout.setVisibility(View.VISIBLE); menuBookmarks.setVisible(false); } @@ -924,10 +933,7 @@ private void closeFullScreen() { int classicScreenFlag = WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN; getWindow().clearFlags(fullScreenFlag); getWindow().addFlags(classicScreenFlag); - SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this); - SharedPreferences.Editor editor = settings.edit(); - editor.putBoolean(PREF_FULLSCREEN, false); - editor.apply(); + sharedPreferenceUtil.putPrefFullScreen(false); shrinkDrawers(); isFullscreenOpened = false; getCurrentWebView().requestLayout(); @@ -976,11 +982,7 @@ private void externalLinkPopup(Intent intent) { // do nothing }) .setNeutralButton(R.string.do_not_ask_anymore, (dialogInterface, i) -> { - PreferenceManager - .getDefaultSharedPreferences(KiwixMobileActivity.this) - .edit() - .putBoolean(PREF_EXTERNAL_LINK_POPUP, false) - .apply(); + sharedPreferenceUtil.putPrefExternalLinkPopup(false); isExternalLinkPopup = false; startActivity(intent); @@ -1155,6 +1157,8 @@ public boolean onKeyDown(int keyCode, KeyEvent event) { case KeyEvent.KEYCODE_BACK: if (getCurrentWebView().canGoBack()) { getCurrentWebView().goBack(); + } else if (isFullscreenOpened) { + closeFullScreen(); } else { finish(); } @@ -1253,7 +1257,7 @@ public void onResume() { mWebViews.get(currentWebViewIndex).findViewById(R.id.get_content_card).setEnabled(true); } - if (settings.getBoolean(PREF_BOTTOM_TOOLBAR, false)) { + if (sharedPreferenceUtil.getPrefBottomToolbar()) { pageBottomTabLayout.setVisibility(View.VISIBLE); if (menuBookmarks != null) { menuBookmarks.setVisible(false); @@ -1554,9 +1558,7 @@ public boolean onCreateOptionsMenu(Menu menu) { openFullScreen(); } - if (PreferenceManager - .getDefaultSharedPreferences(getApplicationContext()) - .getBoolean(PREF_BOTTOM_TOOLBAR, false)) { + if (sharedPreferenceUtil.getPrefBottomToolbar()) { menu.findItem(R.id.menu_bookmarks).setVisible(false); } @@ -1643,17 +1645,16 @@ public void toggleImageViewGrayFilter(ImageView image, boolean state) { public void loadPrefs() { - SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); - nightMode = KiwixSettingsActivity.nightMode(sharedPreferences); - isBackToTopEnabled = sharedPreferences.getBoolean(PREF_BACK_TO_TOP, false); - isHideToolbar = sharedPreferences.getBoolean(PREF_HIDE_TOOLBAR, true); - isFullscreenOpened = sharedPreferences.getBoolean(PREF_FULLSCREEN, false); - boolean isZoomEnabled = sharedPreferences.getBoolean(PREF_ZOOM_ENABLED, false); - isOpenNewTabInBackground = sharedPreferences.getBoolean(PREF_NEW_TAB_BACKGROUND, false); - isExternalLinkPopup = sharedPreferences.getBoolean(PREF_EXTERNAL_LINK_POPUP, true); + nightMode = KiwixSettingsActivity.nightMode(sharedPreferenceUtil); + isBackToTopEnabled = sharedPreferenceUtil.getPrefBackToTop(); + isHideToolbar = sharedPreferenceUtil.getPrefHideToolbar(); + isFullscreenOpened = sharedPreferenceUtil.getPrefFullScreen(); + boolean isZoomEnabled = sharedPreferenceUtil.getPrefZoomEnabled(); + isOpenNewTabInBackground = sharedPreferenceUtil.getPrefNewTabBackground(); + isExternalLinkPopup = sharedPreferenceUtil.getPrefExternalLinkPopup(); if (isZoomEnabled) { - int zoomScale = (int) sharedPreferences.getFloat(PREF_ZOOM, 100.0f); + int zoomScale = (int) sharedPreferenceUtil.getPrefZoom(); getCurrentWebView().setInitialScale(zoomScale); } else { getCurrentWebView().setInitialScale(0); @@ -1782,11 +1783,7 @@ private void manageExternalLaunchAndRestoringViewState() { LanguageUtils.handleLocaleChange(this, BuildConfig.ENFORCED_LANG); // save new locale into preferences for next startup - SharedPreferences sharedPreferences = - PreferenceManager.getDefaultSharedPreferences(this); - SharedPreferences.Editor editor = sharedPreferences.edit(); - editor.putString(PREF_LANG, BuildConfig.ENFORCED_LANG); - editor.apply(); + sharedPreferenceUtil.putPrefLanguage(BuildConfig.ENFORCED_LANG); // restart activity for new locale to take effect this.setResult(1236); @@ -1852,10 +1849,8 @@ public void onPause() { @Override public void webViewUrlLoading() { if (isFirstRun && !BuildConfig.DEBUG) { contentsDrawerHint(); - SharedPreferences.Editor editor = settings.edit(); - editor.putBoolean("isFirstRun", false); // It is no longer the first run + sharedPreferenceUtil.putPrefIsFirstRun(false);// It is no longer the first run isFirstRun = false; - editor.apply(); } } diff --git a/app/src/main/java/org/kiwix/kiwixmobile/KiwixWebChromeClient.java b/app/src/main/java/org/kiwix/kiwixmobile/KiwixWebChromeClient.java index f7b798b612..8fd507a450 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/KiwixWebChromeClient.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/KiwixWebChromeClient.java @@ -1,3 +1,20 @@ +/* + * Kiwix Android + * Copyright (C) 2018 Kiwix + * + * 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 . + */ package org.kiwix.kiwixmobile; import android.webkit.WebChromeClient; diff --git a/app/src/main/java/org/kiwix/kiwixmobile/KiwixWebViewClient.java b/app/src/main/java/org/kiwix/kiwixmobile/KiwixWebViewClient.java index 3bb8cb6db4..d9d1d6091e 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/KiwixWebViewClient.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/KiwixWebViewClient.java @@ -1,3 +1,20 @@ +/* + * Kiwix Android + * Copyright (C) 2018 Kiwix + * + * 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 . + */ package org.kiwix.kiwixmobile; import android.content.Intent; diff --git a/app/src/main/java/org/kiwix/kiwixmobile/PageBottomTab.java b/app/src/main/java/org/kiwix/kiwixmobile/PageBottomTab.java index a26986ce85..f6b2478992 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/PageBottomTab.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/PageBottomTab.java @@ -1,3 +1,20 @@ +/* + * Kiwix Android + * Copyright (C) 2018 Kiwix + * + * 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 . + */ package org.kiwix.kiwixmobile; import android.support.annotation.NonNull; diff --git a/app/src/main/java/org/kiwix/kiwixmobile/TabDrawerAdapter.java b/app/src/main/java/org/kiwix/kiwixmobile/TabDrawerAdapter.java index d16bb494ad..546357c037 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/TabDrawerAdapter.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/TabDrawerAdapter.java @@ -1,6 +1,24 @@ +/* + * Kiwix Android + * Copyright (C) 2018 Kiwix + * + * 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 . + */ package org.kiwix.kiwixmobile; import android.support.v7.widget.RecyclerView; +import android.text.Html; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -14,6 +32,9 @@ import butterknife.BindView; import butterknife.ButterKnife; +import static android.os.Build.VERSION.SDK_INT; +import static android.os.Build.VERSION_CODES.N; + public class TabDrawerAdapter extends RecyclerView.Adapter { private TabClickListener listener; private List webViews; @@ -33,7 +54,7 @@ public TabDrawerAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int view @Override public void onBindViewHolder(ViewHolder holder, int position) { KiwixWebView webView = webViews.get(position); - holder.title.setText(webView.getTitle()); + holder.title.setText(stripHtml(webView.getTitle())); holder.exit.setOnClickListener(v -> listener.onCloseTab(v, position)); holder.itemView.setOnClickListener(v -> { listener.onSelectTab(v, position); @@ -76,4 +97,12 @@ public ViewHolder(View v) { ButterKnife.bind(this, v); } } + + public String stripHtml(String html) { + if (SDK_INT >= N) { + return Html.fromHtml(html, Html.FROM_HTML_MODE_LEGACY).toString(); + } else { + return Html.fromHtml(html).toString(); + } + } } \ No newline at end of file diff --git a/app/src/main/java/org/kiwix/kiwixmobile/TableDrawerAdapter.java b/app/src/main/java/org/kiwix/kiwixmobile/TableDrawerAdapter.java index df729520fc..19a180e4c0 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/TableDrawerAdapter.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/TableDrawerAdapter.java @@ -1,3 +1,20 @@ +/* + * Kiwix Android + * Copyright (C) 2018 Kiwix + * + * 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 . + */ package org.kiwix.kiwixmobile; import android.content.Context; diff --git a/app/src/main/java/org/kiwix/kiwixmobile/WebViewCallback.java b/app/src/main/java/org/kiwix/kiwixmobile/WebViewCallback.java index 9db788d5a0..dc9404f405 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/WebViewCallback.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/WebViewCallback.java @@ -1,3 +1,20 @@ +/* + * Kiwix Android + * Copyright (C) 2018 Kiwix + * + * 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 . + */ package org.kiwix.kiwixmobile; import android.content.Intent; diff --git a/app/src/main/java/org/kiwix/kiwixmobile/base/BaseActivity.java b/app/src/main/java/org/kiwix/kiwixmobile/base/BaseActivity.java index 77c6676ee4..b17244664d 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/base/BaseActivity.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/base/BaseActivity.java @@ -1,3 +1,20 @@ +/* + * Kiwix Android + * Copyright (C) 2018 Kiwix + * + * 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 . + */ package org.kiwix.kiwixmobile.base; import android.os.Bundle; diff --git a/app/src/main/java/org/kiwix/kiwixmobile/base/BasePresenter.java b/app/src/main/java/org/kiwix/kiwixmobile/base/BasePresenter.java index 24815f915a..fc684b1e03 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/base/BasePresenter.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/base/BasePresenter.java @@ -1,3 +1,20 @@ +/* + * Kiwix Android + * Copyright (C) 2018 Kiwix + * + * 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 . + */ package org.kiwix.kiwixmobile.base; /** diff --git a/app/src/main/java/org/kiwix/kiwixmobile/base/Presenter.java b/app/src/main/java/org/kiwix/kiwixmobile/base/Presenter.java index cafc76fdfc..ac1eac1f48 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/base/Presenter.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/base/Presenter.java @@ -1,3 +1,20 @@ +/* + * Kiwix Android + * Copyright (C) 2018 Kiwix + * + * 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 . + */ package org.kiwix.kiwixmobile.base; /** diff --git a/app/src/main/java/org/kiwix/kiwixmobile/base/ViewCallback.java b/app/src/main/java/org/kiwix/kiwixmobile/base/ViewCallback.java index e2fcb101fa..e587011165 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/base/ViewCallback.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/base/ViewCallback.java @@ -1,3 +1,20 @@ +/* + * Kiwix Android + * Copyright (C) 2018 Kiwix + * + * 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 . + */ package org.kiwix.kiwixmobile.base; /** diff --git a/app/src/main/java/org/kiwix/kiwixmobile/bookmarks_view/BookmarksActivity.java b/app/src/main/java/org/kiwix/kiwixmobile/bookmarks_view/BookmarksActivity.java index 660a3e2875..52fb59f754 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/bookmarks_view/BookmarksActivity.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/bookmarks_view/BookmarksActivity.java @@ -30,6 +30,7 @@ import android.support.design.widget.CoordinatorLayout; import android.support.design.widget.Snackbar; import android.support.v7.widget.Toolbar; +import android.text.Html; import android.util.SparseBooleanArray; import android.view.ActionMode; import android.view.LayoutInflater; @@ -49,6 +50,7 @@ import org.kiwix.kiwixmobile.base.BaseActivity; import org.kiwix.kiwixmobile.di.components.ApplicationComponent; import org.kiwix.kiwixmobile.settings.KiwixSettingsActivity; +import org.kiwix.kiwixmobile.utils.SharedPreferenceUtil; import java.util.ArrayList; import java.util.List; @@ -61,6 +63,8 @@ import static org.kiwix.kiwixmobile.utils.Constants.EXTRA_BOOKMARK_CLICKED; import static org.kiwix.kiwixmobile.utils.Constants.EXTRA_CHOSE_X_TITLE; import static org.kiwix.kiwixmobile.utils.Constants.EXTRA_CHOSE_X_URL; +import static android.os.Build.VERSION.SDK_INT; +import static android.os.Build.VERSION_CODES.N; public class BookmarksActivity extends BaseActivity implements AdapterView.OnItemClickListener, BookmarksViewCallback { @@ -76,15 +80,16 @@ public class BookmarksActivity extends BaseActivity LinearLayout noBookmarksLayout; @Inject BookmarksPresenter presenter; + @Inject + SharedPreferenceUtil sharedPreferenceUtil; private ActionModeListener actionModeListener; @Override protected void onCreate(Bundle savedInstanceState) { - SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); - if (KiwixSettingsActivity.nightMode(sharedPreferences)) { + super.onCreate(savedInstanceState); + if (KiwixSettingsActivity.nightMode(sharedPreferenceUtil)) { setTheme(R.style.AppTheme_Night); } - super.onCreate(savedInstanceState); setContentView(R.layout.activity_bookmarks); ButterKnife.bind(this); @@ -143,6 +148,24 @@ private void setUpToolbar() { toolbar.setNavigationOnClickListener(v -> onBackPressed()); } + public ArrayList stripHtml(ArrayList html) { + ArrayList parsed = new ArrayList<>(); + if (html.size() != 0) { + if (SDK_INT >= N) { + for (int i = 0; i < html.size(); i++) { + parsed.add(i, Html.fromHtml(html.get(i), Html.FROM_HTML_MODE_LEGACY).toString()); + } + } else { + for (int i = 0; i < html.size(); i++) { + parsed.add(i, Html.fromHtml(html.get(i)).toString()); + } + } + return parsed; + } else { + return null; + } + } + @Override public void onItemClick(AdapterView parent, View view, int position, long id) { Intent intent = new Intent(this, KiwixMobileActivity.class); @@ -181,7 +204,9 @@ public void onBackPressed() { public void showBookmarks(ArrayList bookmarks, ArrayList bookmarkUrls) { this.bookmarks.clear(); this.bookmarkUrls.clear(); - this.bookmarks.addAll(bookmarks); + ArrayList parsedBookmarks = new ArrayList<>(); + parsedBookmarks = stripHtml(bookmarks); + this.bookmarks.addAll(parsedBookmarks); this.bookmarkUrls.addAll(bookmarkUrls); adapter.notifyDataSetChanged(); setNoBookmarksState(); diff --git a/app/src/main/java/org/kiwix/kiwixmobile/bookmarks_view/BookmarksPresenter.java b/app/src/main/java/org/kiwix/kiwixmobile/bookmarks_view/BookmarksPresenter.java index 6f52999f1a..49e13e1656 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/bookmarks_view/BookmarksPresenter.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/bookmarks_view/BookmarksPresenter.java @@ -1,3 +1,20 @@ +/* + * Kiwix Android + * Copyright (C) 2018 Kiwix + * + * 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 . + */ package org.kiwix.kiwixmobile.bookmarks_view; import android.content.Context; diff --git a/app/src/main/java/org/kiwix/kiwixmobile/bookmarks_view/BookmarksViewCallback.java b/app/src/main/java/org/kiwix/kiwixmobile/bookmarks_view/BookmarksViewCallback.java index c5673c40b2..ca8cf1dad8 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/bookmarks_view/BookmarksViewCallback.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/bookmarks_view/BookmarksViewCallback.java @@ -1,3 +1,20 @@ +/* + * Kiwix Android + * Copyright (C) 2018 Kiwix + * + * 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 . + */ package org.kiwix.kiwixmobile.bookmarks_view; import org.kiwix.kiwixmobile.base.ViewCallback; diff --git a/app/src/main/java/org/kiwix/kiwixmobile/database/BookDao.java b/app/src/main/java/org/kiwix/kiwixmobile/database/BookDao.java index 5b2eb7e08b..a81b427bd7 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/database/BookDao.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/database/BookDao.java @@ -1,3 +1,20 @@ +/* + * Kiwix Android + * Copyright (C) 2018 Kiwix + * + * 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 . + */ package org.kiwix.kiwixmobile.database; diff --git a/app/src/main/java/org/kiwix/kiwixmobile/database/BookmarksDao.java b/app/src/main/java/org/kiwix/kiwixmobile/database/BookmarksDao.java index 831d4f0836..55dfee12e1 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/database/BookmarksDao.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/database/BookmarksDao.java @@ -1,3 +1,20 @@ +/* + * Kiwix Android + * Copyright (C) 2018 Kiwix + * + * 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 . + */ package org.kiwix.kiwixmobile.database; diff --git a/app/src/main/java/org/kiwix/kiwixmobile/database/RecentSearchDao.java b/app/src/main/java/org/kiwix/kiwixmobile/database/RecentSearchDao.java index 6dbf7a5856..e85704cf47 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/database/RecentSearchDao.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/database/RecentSearchDao.java @@ -1,3 +1,20 @@ +/* + * Kiwix Android + * Copyright (C) 2018 Kiwix + * + * 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 . + */ package org.kiwix.kiwixmobile.database; import com.yahoo.squidb.data.SquidCursor; diff --git a/app/src/main/java/org/kiwix/kiwixmobile/database/entity/BookmarksSpec.java b/app/src/main/java/org/kiwix/kiwixmobile/database/entity/BookmarksSpec.java index 938acba499..aa72637810 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/database/entity/BookmarksSpec.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/database/entity/BookmarksSpec.java @@ -1,3 +1,20 @@ +/* + * Kiwix Android + * Copyright (C) 2018 Kiwix + * + * 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 . + */ package org.kiwix.kiwixmobile.database.entity; import com.yahoo.squidb.annotations.ColumnSpec; diff --git a/app/src/main/java/org/kiwix/kiwixmobile/database/entity/RecentSearchSpec.java b/app/src/main/java/org/kiwix/kiwixmobile/database/entity/RecentSearchSpec.java index 1027470fe6..3e9d4ab587 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/database/entity/RecentSearchSpec.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/database/entity/RecentSearchSpec.java @@ -1,3 +1,20 @@ +/* + * Kiwix Android + * Copyright (C) 2018 Kiwix + * + * 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 . + */ package org.kiwix.kiwixmobile.database.entity; import com.yahoo.squidb.annotations.ColumnSpec; diff --git a/app/src/main/java/org/kiwix/kiwixmobile/di/PerActivity.java b/app/src/main/java/org/kiwix/kiwixmobile/di/PerActivity.java index 06a050a34e..1cc013c76c 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/di/PerActivity.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/di/PerActivity.java @@ -1,3 +1,20 @@ +/* + * Kiwix Android + * Copyright (C) 2018 Kiwix + * + * 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 . + */ package org.kiwix.kiwixmobile.di; import java.lang.annotation.Retention; diff --git a/app/src/main/java/org/kiwix/kiwixmobile/di/components/ApplicationComponent.java b/app/src/main/java/org/kiwix/kiwixmobile/di/components/ApplicationComponent.java index 6783c62e96..0fda985b01 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/di/components/ApplicationComponent.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/di/components/ApplicationComponent.java @@ -1,3 +1,20 @@ +/* + * Kiwix Android + * Copyright (C) 2018 Kiwix + * + * 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 . + */ package org.kiwix.kiwixmobile.di.components; import org.kiwix.kiwixmobile.KiwixMobileActivity; @@ -6,9 +23,13 @@ import org.kiwix.kiwixmobile.di.modules.ApplicationModule; import org.kiwix.kiwixmobile.di.modules.JNIModule; import org.kiwix.kiwixmobile.di.modules.NetworkModule; +import org.kiwix.kiwixmobile.downloader.DownloadFragment; import org.kiwix.kiwixmobile.downloader.DownloadService; import org.kiwix.kiwixmobile.library.LibraryAdapter; import org.kiwix.kiwixmobile.search.SearchActivity; +import org.kiwix.kiwixmobile.settings.KiwixSettingsActivity; +import org.kiwix.kiwixmobile.views.AutoCompleteAdapter; +import org.kiwix.kiwixmobile.views.web.KiwixWebView; import org.kiwix.kiwixmobile.zim_manager.ZimManageActivity; import org.kiwix.kiwixmobile.zim_manager.fileselect_view.ZimFileSelectFragment; import org.kiwix.kiwixmobile.zim_manager.library_view.LibraryFragment; @@ -41,4 +62,14 @@ public interface ApplicationComponent { void inject(SearchActivity searchActivity); void inject(ZimManageActivity zimManageActivity); + + void inject(KiwixWebView kiwixWebView); + + void inject(KiwixSettingsActivity kiwixSettingsActivity); + + void inject(KiwixSettingsActivity.PrefsFragment prefsFragment); + + void inject(DownloadFragment downloadFragment); + + void inject(AutoCompleteAdapter autoCompleteAdapter); } diff --git a/app/src/main/java/org/kiwix/kiwixmobile/di/modules/ApplicationModule.java b/app/src/main/java/org/kiwix/kiwixmobile/di/modules/ApplicationModule.java index d718e53315..62b527b586 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/di/modules/ApplicationModule.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/di/modules/ApplicationModule.java @@ -1,3 +1,20 @@ +/* + * Kiwix Android + * Copyright (C) 2018 Kiwix + * + * 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 . + */ package org.kiwix.kiwixmobile.di.modules; import android.app.NotificationManager; diff --git a/app/src/main/java/org/kiwix/kiwixmobile/di/modules/JNIModule.java b/app/src/main/java/org/kiwix/kiwixmobile/di/modules/JNIModule.java index e037bcfef7..09019e5781 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/di/modules/JNIModule.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/di/modules/JNIModule.java @@ -1,3 +1,20 @@ +/* + * Kiwix Android + * Copyright (C) 2018 Kiwix + * + * 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 . + */ package org.kiwix.kiwixmobile.di.modules; import org.kiwix.kiwixlib.JNIKiwix; diff --git a/app/src/main/java/org/kiwix/kiwixmobile/di/modules/NetworkModule.java b/app/src/main/java/org/kiwix/kiwixmobile/di/modules/NetworkModule.java index 080827af89..62e831ba85 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/di/modules/NetworkModule.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/di/modules/NetworkModule.java @@ -1,3 +1,20 @@ +/* + * Kiwix Android + * Copyright (C) 2018 Kiwix + * + * 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 . + */ package org.kiwix.kiwixmobile.di.modules; import android.content.Context; diff --git a/app/src/main/java/org/kiwix/kiwixmobile/downloader/Chunk.java b/app/src/main/java/org/kiwix/kiwixmobile/downloader/Chunk.java index 585a05db48..24c741d0ee 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/downloader/Chunk.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/downloader/Chunk.java @@ -1,3 +1,20 @@ +/* + * Kiwix Android + * Copyright (C) 2018 Kiwix + * + * 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 . + */ package org.kiwix.kiwixmobile.downloader; public class Chunk { diff --git a/app/src/main/java/org/kiwix/kiwixmobile/downloader/ChunkUtils.java b/app/src/main/java/org/kiwix/kiwixmobile/downloader/ChunkUtils.java index 92136a3769..2731e2897d 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/downloader/ChunkUtils.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/downloader/ChunkUtils.java @@ -1,3 +1,20 @@ +/* + * Kiwix Android + * Copyright (C) 2018 Kiwix + * + * 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 . + */ package org.kiwix.kiwixmobile.downloader; import org.kiwix.kiwixmobile.utils.StorageUtils; diff --git a/app/src/main/java/org/kiwix/kiwixmobile/downloader/DownloadFragment.java b/app/src/main/java/org/kiwix/kiwixmobile/downloader/DownloadFragment.java index 3c88994288..96b03bb205 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/downloader/DownloadFragment.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/downloader/DownloadFragment.java @@ -1,3 +1,20 @@ +/* + * Kiwix Android + * Copyright (C) 2018 Kiwix + * + * 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 . + */ package org.kiwix.kiwixmobile.downloader; @@ -32,6 +49,7 @@ import org.kiwix.kiwixmobile.R; import org.kiwix.kiwixmobile.library.entity.LibraryNetworkEntity; import org.kiwix.kiwixmobile.utils.NetworkUtils; +import org.kiwix.kiwixmobile.utils.SharedPreferenceUtil; import org.kiwix.kiwixmobile.utils.files.FileUtils; import org.kiwix.kiwixmobile.zim_manager.ZimManageActivity; import org.kiwix.kiwixmobile.zim_manager.fileselect_view.ZimFileSelectFragment; @@ -40,6 +58,8 @@ import java.util.Arrays; import java.util.LinkedHashMap; +import javax.inject.Inject; + import static org.kiwix.kiwixmobile.utils.Constants.PREF_WIFI_ONLY; import static org.kiwix.kiwixmobile.utils.StyleUtils.dialogStyle; @@ -56,8 +76,15 @@ public class DownloadFragment extends Fragment { private Activity faActivity; private boolean hasArtificiallyPaused; + @Inject static SharedPreferenceUtil sharedPreferenceUtil; + + private void setupDagger() { + KiwixApplication.getInstance().getApplicationComponent().inject(this); + } + @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + setupDagger(); faActivity = super.getActivity(); relLayout = (RelativeLayout) inflater.inflate(R.layout.download_management, container, false); @@ -100,10 +127,7 @@ public static void showNoWiFiWarning(Context context, Runnable yesAction) { .setTitle(R.string.wifi_only_title) .setMessage(R.string.wifi_only_msg) .setPositiveButton(R.string.yes, (dialog, i) -> { - PreferenceManager.getDefaultSharedPreferences(context) - .edit() - .putBoolean(PREF_WIFI_ONLY, false) - .apply(); + sharedPreferenceUtil.putPrefWifiOnly(false); KiwixMobileActivity.wifiOnly = false; yesAction.run(); }) diff --git a/app/src/main/java/org/kiwix/kiwixmobile/downloader/DownloadIntent.java b/app/src/main/java/org/kiwix/kiwixmobile/downloader/DownloadIntent.java index 519d59bcc1..ccba6c3d42 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/downloader/DownloadIntent.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/downloader/DownloadIntent.java @@ -1,3 +1,20 @@ +/* + * Kiwix Android + * Copyright (C) 2018 Kiwix + * + * 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 . + */ package org.kiwix.kiwixmobile.downloader; public class DownloadIntent { diff --git a/app/src/main/java/org/kiwix/kiwixmobile/downloader/DownloadService.java b/app/src/main/java/org/kiwix/kiwixmobile/downloader/DownloadService.java index ace0498223..2091bd7936 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/downloader/DownloadService.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/downloader/DownloadService.java @@ -1,3 +1,20 @@ +/* + * Kiwix Android + * Copyright (C) 2018 Kiwix + * + * 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 . + */ package org.kiwix.kiwixmobile.downloader; import android.app.NotificationManager; @@ -26,6 +43,7 @@ import org.kiwix.kiwixmobile.library.entity.LibraryNetworkEntity; import org.kiwix.kiwixmobile.network.KiwixService; import org.kiwix.kiwixmobile.utils.NetworkUtils; +import org.kiwix.kiwixmobile.utils.SharedPreferenceUtil; import org.kiwix.kiwixmobile.utils.StorageUtils; import org.kiwix.kiwixmobile.utils.TestingUtils; import org.kiwix.kiwixmobile.utils.files.FileUtils; @@ -40,12 +58,12 @@ import javax.inject.Inject; +import io.reactivex.Observable; +import io.reactivex.android.schedulers.AndroidSchedulers; import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.Response; import okio.BufferedSource; -import rx.Observable; -import rx.android.schedulers.AndroidSchedulers; import static org.kiwix.kiwixmobile.utils.Constants.EXTRA_BOOK; import static org.kiwix.kiwixmobile.utils.Constants.EXTRA_LIBRARY; @@ -85,6 +103,9 @@ public class DownloadService extends Service { private static DownloadFragment downloadFragment; Handler handler = new Handler(Looper.getMainLooper()); + @Inject + SharedPreferenceUtil sharedPreferenceUtil; + public static void setDownloadFragment(DownloadFragment dFragment) { downloadFragment = dFragment; } @@ -98,8 +119,7 @@ private void setupDagger(){ public void onCreate() { setupDagger(); - SD_CARD = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()) - .getString(PREF_STORAGE,Environment.getExternalStorageDirectory().getPath()); + SD_CARD = sharedPreferenceUtil.getPrefStorage(); KIWIX_ROOT = SD_CARD + "/Kiwix/"; KIWIX_ROOT = checkWritable(KIWIX_ROOT); @@ -134,8 +154,7 @@ public int onStartCommand(Intent intent, int flags, int startId) { } - SD_CARD = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()) - .getString(PREF_STORAGE,Environment.getExternalStorageDirectory().getPath()); + SD_CARD = sharedPreferenceUtil.getPrefStorage(); KIWIX_ROOT = SD_CARD + "/Kiwix/"; KIWIX_ROOT = checkWritable(KIWIX_ROOT); @@ -276,9 +295,9 @@ private void downloadBook(String url, int notificationID, LibraryNetworkEntity.B .retryWhen(errors -> errors.flatMap(error -> Observable.timer(5, TimeUnit.SECONDS))) .subscribeOn(AndroidSchedulers.mainThread()) .flatMap(metaLink -> getMetaLinkContentLength(metaLink.getRelevantUrl().getValue())) - .flatMap(pair -> Observable.from(ChunkUtils.getChunks(pair.first, pair.second, notificationID))) + .flatMap(pair -> Observable.fromIterable(ChunkUtils.getChunks(pair.first, pair.second, notificationID))) .concatMap(this::downloadChunk) - .distinctUntilChanged().doOnCompleted(() -> {updateDownloadFragmentComplete(notificationID);}) + .distinctUntilChanged().doOnComplete(() -> updateDownloadFragmentComplete(notificationID)) .subscribe(progress -> { if (progress == 100) { notification.get(notificationID).setOngoing(false); @@ -343,14 +362,13 @@ private void updateForeground() { private Observable> getMetaLinkContentLength(String url) { return Observable.create(subscriber -> { - if (subscriber.isUnsubscribed()) return; try { Request request = new Request.Builder().url(url).head().build(); Response response = httpClient.newCall(request).execute(); String LengthHeader = response.headers().get("Content-Length"); long contentLength = LengthHeader == null ? 0 : Long.parseLong(LengthHeader); subscriber.onNext(new Pair<>(url, contentLength)); - subscriber.onCompleted(); + subscriber.onComplete(); if (!response.isSuccessful()) subscriber.onError(new Exception(response.message())); } catch (IOException e) { subscriber.onError(e); @@ -360,11 +378,10 @@ private Observable> getMetaLinkContentLength(String url) { private Observable downloadChunk(Chunk chunk) { return Observable.create(subscriber -> { - if (subscriber.isUnsubscribed()) return; try { // Stop if download is completed or download canceled if (chunk.isDownloaded || downloadStatus.get(chunk.getNotificationID()) == CANCEL) { - subscriber.onCompleted(); + subscriber.onComplete(); return; } @@ -377,7 +394,7 @@ private Observable downloadChunk(Chunk chunk) { if (fullFile.exists() && fullFile.length() == chunk.getSize()) { // Mark chunk status as downloaded chunk.isDownloaded = true; - subscriber.onCompleted(); + subscriber.onComplete(); return; } else if (!file.exists()) { file.createNewFile(); @@ -509,7 +526,7 @@ private Observable downloadChunk(Chunk chunk) { } // Mark chunk status as downloaded chunk.isDownloaded = true; - subscriber.onCompleted(); + subscriber.onComplete(); } catch (IOException e) { // Catch unforeseen file system errors subscriber.onError(e); diff --git a/app/src/main/java/org/kiwix/kiwixmobile/library/LibraryAdapter.java b/app/src/main/java/org/kiwix/kiwixmobile/library/LibraryAdapter.java index db2423071c..d71b3f40fb 100755 --- a/app/src/main/java/org/kiwix/kiwixmobile/library/LibraryAdapter.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/library/LibraryAdapter.java @@ -56,11 +56,11 @@ import javax.inject.Inject; -import rx.Completable; -import rx.Observable; -import rx.Subscription; -import rx.android.schedulers.AndroidSchedulers; -import rx.schedulers.Schedulers; +import io.reactivex.Completable; +import io.reactivex.Observable; +import io.reactivex.android.schedulers.AndroidSchedulers; +import io.reactivex.disposables.Disposable; +import io.reactivex.schedulers.Schedulers; import static org.kiwix.kiwixmobile.utils.NetworkUtils.parseURL; @@ -77,7 +77,7 @@ public class LibraryAdapter extends BaseAdapter { private final BookDao bookDao; private final LayoutInflater layoutInflater; private final BookFilter bookFilter = new BookFilter(); - private Subscription saveNetworkLanguageSubscription; + private Disposable saveNetworkLanguageDisposable; @Inject BookUtils bookUtils; private void setupDagger() { @@ -214,9 +214,11 @@ public View getView(int position, View convertView, ViewGroup parent) { } private boolean languageActive(Book book) { - return Observable.from(languages) - .takeFirst(language -> language.languageCode.equals(book.getLanguage())) - .map(language -> language.active).toBlocking().firstOrDefault(false); + return Observable.fromIterable(languages) + .filter(language -> language.languageCode.equals(book.getLanguage())) + .firstElement() + .map(language -> language.active) + .blockingGet(false); } private Observable getMatches(Book b, String s) { @@ -227,7 +229,11 @@ private Observable getMatches(Book b, String s) { text.append(bookUtils.localeMap.get(b.getLanguage()).getDisplayLanguage()).append("|"); } String[] words = s.toLowerCase().split("\\s+"); - b.searchMatches = Observable.from(words).filter(text.toString().toLowerCase()::contains).count().toBlocking().first(); + b.searchMatches = Observable.fromArray(words) + .filter(text.toString().toLowerCase()::contains) + .count() + .blockingGet() + .intValue(); if (b.searchMatches > 0) { return Observable.just(b); } else { @@ -241,42 +247,46 @@ protected FilterResults performFiltering(CharSequence s) { ArrayList books = bookDao.getBooks(); listItems.clear(); if (s.length() == 0) { - List selectedLanguages = Observable.from(allBooks) + List selectedLanguages = Observable.fromIterable(allBooks) .filter(LibraryAdapter.this::languageActive) .filter(book -> !books.contains(book)) .filter(book -> !DownloadFragment.mDownloads.values().contains(book)) .filter(book -> !LibraryFragment.downloadingBooks.contains(book)) - .toList().toBlocking().single(); + .toList() + .blockingGet(); - List unselectedLanguages = Observable.from(allBooks) + List unselectedLanguages = Observable.fromIterable(allBooks) .filter(book -> !languageActive(book)) .filter(book -> !books.contains(book)) .filter(book -> !DownloadFragment.mDownloads.values().contains(book)) .filter(book -> !LibraryFragment.downloadingBooks.contains(book)) - .toList().toBlocking().single(); + .toList() + .blockingGet(); listItems.add(new ListItem(context.getResources().getString(R.string.your_languages), LIST_ITEM_TYPE_DIVIDER)); addBooks(selectedLanguages); listItems.add(new ListItem(context.getResources().getString(R.string.other_languages), LIST_ITEM_TYPE_DIVIDER)); addBooks(unselectedLanguages); } else { - List selectedLanguages = Observable.from(allBooks) + List selectedLanguages = Observable.fromIterable(allBooks) .filter(LibraryAdapter.this::languageActive) .filter(book -> !books.contains(book)) .filter(book -> !DownloadFragment.mDownloads.values().contains(book)) .filter(book -> !LibraryFragment.downloadingBooks.contains(book)) .flatMap(book -> getMatches(book, s.toString())) - .toList().toBlocking().single(); + .toList() + .blockingGet(); Collections.sort(selectedLanguages, new BookMatchComparator()); - List unselectedLanguages = Observable.from(allBooks) + List unselectedLanguages = Observable.fromIterable(allBooks) .filter(book -> !languageActive(book)) .filter(book -> !books.contains(book)) .filter(book -> !DownloadFragment.mDownloads.values().contains(book)) .filter(book -> !LibraryFragment.downloadingBooks.contains(book)) .flatMap(book -> getMatches(book, s.toString())) - .toList().toBlocking().single(); + .toList() + .blockingGet(); Collections.sort(unselectedLanguages, new BookMatchComparator()); @@ -454,17 +464,17 @@ public Language(String languageCode, Boolean active) { @Override public boolean equals(Object obj) { return ((Language) obj).language.equals(language) && - ((Language) obj).active.equals(active); + ((Language) obj).active.equals(active); } } private void saveNetworkLanguages() { - if (saveNetworkLanguageSubscription != null) { - saveNetworkLanguageSubscription.unsubscribe(); + if (saveNetworkLanguageDisposable != null && !saveNetworkLanguageDisposable.isDisposed()) { + saveNetworkLanguageDisposable.dispose(); } - saveNetworkLanguageSubscription = Completable.fromAction(() -> networkLanguageDao.saveFilteredLanguages(languages)) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .subscribe(); + saveNetworkLanguageDisposable = Completable.fromAction(() -> networkLanguageDao.saveFilteredLanguages(languages)) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(); } } diff --git a/app/src/main/java/org/kiwix/kiwixmobile/library/entity/MetaLinkNetworkEntity.java b/app/src/main/java/org/kiwix/kiwixmobile/library/entity/MetaLinkNetworkEntity.java index 64251806ab..20b9badc13 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/library/entity/MetaLinkNetworkEntity.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/library/entity/MetaLinkNetworkEntity.java @@ -1,3 +1,20 @@ +/* + * Kiwix Android + * Copyright (C) 2018 Kiwix + * + * 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 . + */ package org.kiwix.kiwixmobile.library.entity; import org.simpleframework.xml.Attribute; diff --git a/app/src/main/java/org/kiwix/kiwixmobile/network/KiwixService.java b/app/src/main/java/org/kiwix/kiwixmobile/network/KiwixService.java index b5929fd077..551bc8b4e9 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/network/KiwixService.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/network/KiwixService.java @@ -1,16 +1,33 @@ +/* + * Kiwix Android + * Copyright (C) 2018 Kiwix + * + * 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 . + */ package org.kiwix.kiwixmobile.network; import org.kiwix.kiwixmobile.library.entity.LibraryNetworkEntity; import org.kiwix.kiwixmobile.library.entity.MetaLinkNetworkEntity; +import io.reactivex.Observable; +import io.reactivex.schedulers.Schedulers; import okhttp3.OkHttpClient; import retrofit2.Retrofit; -import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory; +import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory; import retrofit2.converter.simplexml.SimpleXmlConverterFactory; import retrofit2.http.GET; import retrofit2.http.Url; -import rx.Observable; -import rx.schedulers.Schedulers; public interface KiwixService { @GET("/library/library_zim.xml") Observable getLibrary(); @@ -26,7 +43,7 @@ public static KiwixService newHacklistService(OkHttpClient okHttpClient, String .baseUrl(baseUrl) .client(okHttpClient) .addConverterFactory(SimpleXmlConverterFactory.create()) - .addCallAdapterFactory(RxJavaCallAdapterFactory.createWithScheduler(Schedulers.io())) + .addCallAdapterFactory(RxJava2CallAdapterFactory.createWithScheduler(Schedulers.io())) .build(); return retrofit.create(KiwixService.class); diff --git a/app/src/main/java/org/kiwix/kiwixmobile/network/UserAgentInterceptor.java b/app/src/main/java/org/kiwix/kiwixmobile/network/UserAgentInterceptor.java index 25a4ee60bc..ec857d8430 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/network/UserAgentInterceptor.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/network/UserAgentInterceptor.java @@ -1,3 +1,20 @@ +/* + * Kiwix Android + * Copyright (C) 2018 Kiwix + * + * 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 . + */ package org.kiwix.kiwixmobile.network; import java.io.IOException; diff --git a/app/src/main/java/org/kiwix/kiwixmobile/search/SearchActivity.java b/app/src/main/java/org/kiwix/kiwixmobile/search/SearchActivity.java index 0d9dce5f02..76cdd9ecc5 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/search/SearchActivity.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/search/SearchActivity.java @@ -1,10 +1,25 @@ +/* + * Kiwix Android + * Copyright (C) 2018 Kiwix + * + * 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 . + */ package org.kiwix.kiwixmobile.search; import android.content.ActivityNotFoundException; import android.content.Intent; -import android.content.SharedPreferences; import android.os.Bundle; -import android.preference.PreferenceManager; import android.provider.Settings; import android.speech.RecognizerIntent; import android.support.v4.view.MenuItemCompat; @@ -25,6 +40,7 @@ import org.kiwix.kiwixmobile.KiwixApplication; import org.kiwix.kiwixmobile.KiwixMobileActivity; import org.kiwix.kiwixmobile.R; +import org.kiwix.kiwixmobile.utils.SharedPreferenceUtil; import org.kiwix.kiwixmobile.views.AutoCompleteAdapter; import java.util.ArrayList; @@ -35,7 +51,6 @@ import static org.kiwix.kiwixmobile.utils.Constants.EXTRA_IS_WIDGET_VOICE; import static org.kiwix.kiwixmobile.utils.Constants.EXTRA_SEARCH; -import static org.kiwix.kiwixmobile.utils.Constants.PREF_NIGHTMODE; import static org.kiwix.kiwixmobile.utils.Constants.TAG_FILE_SEARCHED; import static org.kiwix.kiwixmobile.utils.StyleUtils.dialogStyle; @@ -50,6 +65,8 @@ public class SearchActivity extends AppCompatActivity @Inject SearchPresenter searchPresenter; + @Inject + SharedPreferenceUtil sharedPreferenceUtil; private void setupDagger() { KiwixApplication.getInstance().getApplicationComponent().inject(this); @@ -57,11 +74,10 @@ private void setupDagger() { @Override protected void onCreate(Bundle savedInstanceState) { - SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); - if (sharedPreferences.getBoolean(PREF_NIGHTMODE, false)) { + setupDagger(); + if (sharedPreferenceUtil.getPrefNightMode()) { setTheme(R.style.AppTheme_Night); } - setupDagger(); super.onCreate(savedInstanceState); View contentView = LayoutInflater.from(this).inflate(R.layout.search, null); setContentView(contentView); diff --git a/app/src/main/java/org/kiwix/kiwixmobile/search/SearchPresenter.java b/app/src/main/java/org/kiwix/kiwixmobile/search/SearchPresenter.java index 19ecbd236d..4525181b75 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/search/SearchPresenter.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/search/SearchPresenter.java @@ -1,3 +1,20 @@ +/* + * Kiwix Android + * Copyright (C) 2018 Kiwix + * + * 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 . + */ package org.kiwix.kiwixmobile.search; import android.content.Context; diff --git a/app/src/main/java/org/kiwix/kiwixmobile/search/SearchViewCallback.java b/app/src/main/java/org/kiwix/kiwixmobile/search/SearchViewCallback.java index 8bf6a54b52..4a24369e4a 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/search/SearchViewCallback.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/search/SearchViewCallback.java @@ -1,3 +1,20 @@ +/* + * Kiwix Android + * Copyright (C) 2018 Kiwix + * + * 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 . + */ package org.kiwix.kiwixmobile.search; import org.kiwix.kiwixmobile.base.ViewCallback; diff --git a/app/src/main/java/org/kiwix/kiwixmobile/settings/KiwixSettingsActivity.java b/app/src/main/java/org/kiwix/kiwixmobile/settings/KiwixSettingsActivity.java index e3ff8e5e6e..09e3b1fec3 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/settings/KiwixSettingsActivity.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/settings/KiwixSettingsActivity.java @@ -20,16 +20,15 @@ package org.kiwix.kiwixmobile.settings; import android.app.FragmentManager; -import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; import android.os.Environment; import android.preference.EditTextPreference; +import android.preference.ListPreference; import android.preference.Preference; import android.preference.PreferenceCategory; import android.preference.PreferenceFragment; -import android.preference.PreferenceManager; import android.preference.PreferenceScreen; import android.support.v7.app.AlertDialog; import android.support.v7.app.AppCompatActivity; @@ -40,11 +39,13 @@ import android.widget.Toast; import org.kiwix.kiwixmobile.BuildConfig; +import org.kiwix.kiwixmobile.KiwixApplication; import org.kiwix.kiwixmobile.KiwixMobileActivity; import org.kiwix.kiwixmobile.R; import org.kiwix.kiwixmobile.database.KiwixDatabase; import org.kiwix.kiwixmobile.database.RecentSearchDao; import org.kiwix.kiwixmobile.utils.LanguageUtils; +import org.kiwix.kiwixmobile.utils.SharedPreferenceUtil; import org.kiwix.kiwixmobile.utils.StyleUtils; import org.kiwix.kiwixmobile.views.LanguageSelectDialog; import org.kiwix.kiwixmobile.views.SliderPreference; @@ -52,8 +53,11 @@ import java.io.File; import java.util.Calendar; +import java.util.List; import java.util.Locale; +import javax.inject.Inject; + import eu.mhutti1.utils.storage.StorageDevice; import eu.mhutti1.utils.storage.StorageSelectDialog; @@ -64,7 +68,6 @@ import static org.kiwix.kiwixmobile.utils.Constants.PREF_LANG; import static org.kiwix.kiwixmobile.utils.Constants.PREF_NIGHTMODE; import static org.kiwix.kiwixmobile.utils.Constants.PREF_STORAGE; -import static org.kiwix.kiwixmobile.utils.Constants.PREF_STORAGE_TITLE; import static org.kiwix.kiwixmobile.utils.Constants.PREF_VERSION; import static org.kiwix.kiwixmobile.utils.Constants.PREF_WIFI_ONLY; import static org.kiwix.kiwixmobile.utils.Constants.PREF_ZOOM; @@ -75,17 +78,22 @@ public class KiwixSettingsActivity extends AppCompatActivity { - public static String zimFile; - public static boolean allHistoryCleared = false; private static final int DAWN_HOUR = 6; private static final int DUSK_HOUR = 18; + @Inject + SharedPreferenceUtil sharedPreferenceUtil; + + private void setupDagger() { + KiwixApplication.getInstance().getApplicationComponent().inject(this); + } + @Override public void onCreate(Bundle savedInstanceState) { - - if(nightMode(PreferenceManager.getDefaultSharedPreferences(this))){ + setupDagger(); + if(nightMode(sharedPreferenceUtil)){ setTheme(R.style.AppTheme_Night); } getWindow().setWindowAnimations(R.style.WindowAnimationTransition); @@ -124,14 +132,14 @@ private void setUpToolbar() { toolbar.setNavigationOnClickListener(v -> onBackPressed()); } - public static boolean nightMode(SharedPreferences preferences){ - boolean autoNightMode = preferences.getBoolean(PREF_AUTONIGHTMODE, false); + public static boolean nightMode(SharedPreferenceUtil sharedPreferenceUtil){ + boolean autoNightMode = sharedPreferenceUtil.getPrefAutoNightMode(); if(autoNightMode){ Calendar cal = Calendar.getInstance(); int hour = cal.get(Calendar.HOUR_OF_DAY); return hour < DAWN_HOUR || hour > DUSK_HOUR; } else{ - return preferences.getBoolean(PREF_NIGHTMODE, false); + return sharedPreferenceUtil.getPrefNightMode(); } } @@ -141,34 +149,40 @@ public static class PrefsFragment extends PreferenceFragment implements private SliderPreference mSlider; private RecentSearchDao recentSearchDao; + @Inject SharedPreferenceUtil sharedPreferenceUtil; + + void setupDagger() { + KiwixApplication.getInstance().getApplicationComponent().inject(this); + } + @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + setupDagger(); addPreferencesFromResource(R.xml.preferences); - boolean auto_night_mode = PreferenceManager.getDefaultSharedPreferences(getActivity()) - .getBoolean(PREF_AUTONIGHTMODE, false); + boolean auto_night_mode = sharedPreferenceUtil.getPrefAutoNightMode(); - if(auto_night_mode){ + if (auto_night_mode) { getPreferenceScreen().findPreference(PREF_NIGHTMODE).setEnabled(false); } if (BuildConfig.ENFORCED_LANG.equals("")) { setUpLanguageChooser(PREF_LANG); } else { - getPreferenceScreen().removePreference(getPrefrence("pref_language")); + getPreferenceScreen().removePreference(findPreference("pref_language")); } if (BuildConfig.IS_CUSTOM_APP) { PreferenceCategory notificationsCategory = (PreferenceCategory) findPreference("pref_extras"); - notificationsCategory.removePreference(getPrefrence("pref_wifi_only")); + notificationsCategory.removePreference(findPreference("pref_wifi_only")); } - mSlider = (SliderPreference) getPrefrence(PREF_ZOOM); + mSlider = (SliderPreference) findPreference(PREF_ZOOM); setSliderState(); setStorage(); setUpSettings(); - new LanguageUtils(getActivity()).changeFont(getActivity().getLayoutInflater()); + new LanguageUtils(getActivity()).changeFont(getActivity().getLayoutInflater(), sharedPreferenceUtil); recentSearchDao = new RecentSearchDao(KiwixDatabase.getInstance(getActivity())); } @@ -177,19 +191,16 @@ private void deleteSearchHistoryFromDb() { recentSearchDao.deleteSearchHistory(); } - private void setStorage(){ + private void setStorage() { if (BuildConfig.IS_CUSTOM_APP) { - getPreferenceScreen().removePreference(getPrefrence("pref_storage")); + getPreferenceScreen().removePreference(findPreference("pref_storage")); } else { if (Environment.isExternalStorageEmulated()) { - getPrefrence(PREF_STORAGE).setTitle(PreferenceManager.getDefaultSharedPreferences(getActivity()) - .getString(PREF_STORAGE_TITLE, "Internal")); + findPreference(PREF_STORAGE).setTitle(sharedPreferenceUtil.getPrefStorageTitle("Internal")); } else { - getPrefrence(PREF_STORAGE).setTitle(PreferenceManager.getDefaultSharedPreferences(getActivity()) - .getString(PREF_STORAGE_TITLE, "External")); + findPreference(PREF_STORAGE).setTitle(sharedPreferenceUtil.getPrefStorageTitle("External")); } - getPrefrence(PREF_STORAGE).setSummary(LibraryUtils.bytesToHuman( new File(PreferenceManager.getDefaultSharedPreferences(getActivity()) - .getString(PREF_STORAGE, Environment.getExternalStorageDirectory().getPath())).getFreeSpace())); + findPreference(PREF_STORAGE).setSummary(LibraryUtils.bytesToHuman( new File(sharedPreferenceUtil.getPrefStorage()).getFreeSpace())); } } @@ -222,11 +233,29 @@ public void setUpSettings() { } private void setUpLanguageChooser(String preferenceId) { - Preference languagePref = getPrefrence(preferenceId); - SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity()); - String selectedLang = sharedPreferences.getString(PREF_LANG, Locale.getDefault().toString()); - + ListPreference languagePref = (ListPreference) findPreference(preferenceId); + String selectedLang = sharedPreferenceUtil.getPrefLanguage(Locale.getDefault().toString()); + List languageCodeList = new LanguageUtils(getActivity()).getKeys(); + selectedLang = languageCodeList.contains(selectedLang) ? selectedLang : "en"; + String code[] = languageCodeList.toArray(new String[languageCodeList.size()]); + String[] entries = new String[code.length]; + for (int index = 0; index < code.length; index++) { + Locale locale = new Locale(code[index]); + entries[index] = locale.getDisplayLanguage() + " (" + locale.getDisplayLanguage(locale) + ") "; + } + languagePref.setEntries(entries); + languagePref.setEntryValues(code); + languagePref.setDefaultValue(selectedLang); + languagePref.setValue(selectedLang); languagePref.setTitle(new Locale(selectedLang).getDisplayLanguage()); + languagePref.setOnPreferenceChangeListener((preference, newValue) -> { + String languageCode = (String) newValue; + LanguageUtils.handleLocaleChange(getActivity(), languageCode); + preference.setTitle(new Locale(languageCode).getLanguage()); + sharedPreferenceUtil.putPrefLanguage(languageCode); + restartActivity(); + return true; + }); } private void restartActivity() { @@ -243,10 +272,6 @@ private void setAppVersionNumber() { versionPref.setSummary(version); } - private Preference getPrefrence(String preferenceId) { - return PrefsFragment.this.findPreference(preferenceId); - } - @Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { @@ -259,40 +284,45 @@ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, Strin } if (key.equals(PREF_NIGHTMODE)) { KiwixMobileActivity.refresh = true; - KiwixMobileActivity.nightMode = nightMode(sharedPreferences); + KiwixMobileActivity.nightMode = nightMode(sharedPreferenceUtil); getActivity().finish(); startActivity(new Intent(getActivity(), KiwixSettingsActivity.class)); } if (key.equals(PREF_WIFI_ONLY)) { KiwixMobileActivity.wifiOnly = sharedPreferences.getBoolean(PREF_WIFI_ONLY, true); } - if(key.equals(PREF_AUTONIGHTMODE)){ + if (key.equals(PREF_AUTONIGHTMODE)) { KiwixMobileActivity.refresh = true; - KiwixMobileActivity.nightMode = nightMode(sharedPreferences); + KiwixMobileActivity.nightMode = nightMode(sharedPreferenceUtil); getActivity().finish(); startActivity(new Intent(getActivity(), KiwixSettingsActivity.class)); } } private void clearAllHistoryDialog() { + int warningResId; + if (nightMode(sharedPreferenceUtil)) { + warningResId = R.drawable.ic_warning_white; + } + else { + warningResId = R.drawable.ic_warning_black; + } new AlertDialog.Builder(getActivity(), dialogStyle()) .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, new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int which) { - deleteSearchHistoryFromDb(); - allHistoryCleared = true; - Toast.makeText(getActivity(), getResources().getString(R.string.all_history_cleared_toast), Toast.LENGTH_SHORT).show(); - } + .setPositiveButton(android.R.string.yes, (dialog, which) -> { + deleteSearchHistoryFromDb(); + 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(android.R.drawable.ic_dialog_alert) + .setIcon(warningResId) .show(); } - public void openCredits(){ + public void openCredits() { WebView view = (WebView) LayoutInflater.from(getActivity()).inflate(R.layout.credits_webview, null); view.loadUrl("file:///android_asset/credits.html"); new AlertDialog.Builder(getActivity(), dialogStyle()) @@ -313,33 +343,9 @@ public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, if (preference.getKey().equalsIgnoreCase(PREF_STORAGE)) openFolderSelect(); - if (preference.getKey().equalsIgnoreCase(PREF_LANG)) - openLanguageSelect(); - return true; } - public void openLanguageSelect() { - SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity()); - LanguageUtils languageUtils = new LanguageUtils(getActivity()); - String selectedLang = sharedPreferences.getString(PREF_LANG, Locale.getDefault().toString()); - - new LanguageSelectDialog.Builder(getActivity(), dialogStyle()) - .setLanguages(languageUtils.getLanguageList()) - .setSingleSelect(true) - .setSelectedLanguage(selectedLang) - .setOnLanguageSelectedListener((languageCode -> { - SharedPreferences.Editor editor = sharedPreferences.edit(); - editor.putString(PREF_LANG, languageCode); - editor.apply(); - - LanguageUtils.handleLocaleChange(getActivity(), languageCode); - // Request a restart when the user returns to the Activity, that called this Activity - restartActivity(); - })) - .show(); - } - public void openFolderSelect(){ FragmentManager fm = getFragmentManager(); StorageSelectDialog dialogFragment = new StorageSelectDialog(); @@ -350,23 +356,19 @@ public void openFolderSelect(){ dialogFragment.setArguments(b); dialogFragment.setOnSelectListener(this); dialogFragment.show(fm, getResources().getString(R.string.pref_storage)); - } @Override public void selectionCallback(StorageDevice storageDevice) { findPreference(PREF_STORAGE).setSummary(storageDevice.getSize()); - SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity()); - SharedPreferences.Editor editor = sharedPreferences.edit(); - editor.putString(PREF_STORAGE,storageDevice.getName()); + sharedPreferenceUtil.putPrefStorage(storageDevice.getName()); if (storageDevice.isInternal()) { findPreference(PREF_STORAGE).setTitle(getResources().getString(R.string.internal_storage)); - editor.putString(PREF_STORAGE_TITLE, getResources().getString(R.string.internal_storage)); + sharedPreferenceUtil.putPrefStorageTitle(getResources().getString(R.string.internal_storage)); } else { findPreference(PREF_STORAGE).setTitle(getResources().getString(R.string.external_storage)); - editor.putString(PREF_STORAGE_TITLE, getResources().getString(R.string.external_storage)); + sharedPreferenceUtil.putPrefStorageTitle(getResources().getString(R.string.external_storage)); } - editor.apply(); } } } diff --git a/app/src/main/java/org/kiwix/kiwixmobile/utils/BookUtils.java b/app/src/main/java/org/kiwix/kiwixmobile/utils/BookUtils.java index bd69a7624c..1f3d266ad7 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/utils/BookUtils.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/utils/BookUtils.java @@ -1,3 +1,20 @@ +/* + * Kiwix Android + * Copyright (C) 2018 Kiwix + * + * 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 . + */ package org.kiwix.kiwixmobile.utils; import java.util.HashMap; diff --git a/app/src/main/java/org/kiwix/kiwixmobile/utils/Constants.java b/app/src/main/java/org/kiwix/kiwixmobile/utils/Constants.java index f9baca53e0..946fc2d40f 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/utils/Constants.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/utils/Constants.java @@ -1,3 +1,20 @@ +/* + * Kiwix Android + * Copyright (C) 2018 Kiwix + * + * 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 . + */ package org.kiwix.kiwixmobile.utils; public final class Constants { @@ -61,6 +78,8 @@ public final class Constants { public static final String PREF_EXTERNAL_LINK_POPUP = "pref_external_link_popup"; + public static final String PREF_IS_FIRST_RUN = "isFirstRun"; + // Tags public static final String TAG_FILE_SEARCHED = "searchedarticle"; diff --git a/app/src/main/java/org/kiwix/kiwixmobile/utils/DimenUtils.java b/app/src/main/java/org/kiwix/kiwixmobile/utils/DimenUtils.java index b988394ac7..7cd300d799 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/utils/DimenUtils.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/utils/DimenUtils.java @@ -1,3 +1,20 @@ +/* + * Kiwix Android + * Copyright (C) 2018 Kiwix + * + * 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 . + */ package org.kiwix.kiwixmobile.utils; import android.content.Context; diff --git a/app/src/main/java/org/kiwix/kiwixmobile/utils/DocumentParser.java b/app/src/main/java/org/kiwix/kiwixmobile/utils/DocumentParser.java index 1b3abb9cf7..148ea421b7 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/utils/DocumentParser.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/utils/DocumentParser.java @@ -1,3 +1,20 @@ +/* + * Kiwix Android + * Copyright (C) 2018 Kiwix + * + * 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 . + */ package org.kiwix.kiwixmobile.utils; import android.os.Handler; diff --git a/app/src/main/java/org/kiwix/kiwixmobile/utils/KiwixTextToSpeech.java b/app/src/main/java/org/kiwix/kiwixmobile/utils/KiwixTextToSpeech.java index ce2d52f582..982d3451d4 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/utils/KiwixTextToSpeech.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/utils/KiwixTextToSpeech.java @@ -1,7 +1,26 @@ +/* + * Kiwix Android + * Copyright (C) 2018 Kiwix + * + * 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 . + */ package org.kiwix.kiwixmobile.utils; import android.annotation.SuppressLint; import android.content.Context; +import android.media.AudioManager; +import android.media.AudioManager.OnAudioFocusChangeListener; import android.os.Build; import android.os.Build.VERSION; import android.os.Build.VERSION_CODES; @@ -35,6 +54,12 @@ public class KiwixTextToSpeech { public TTSTask currentTTSTask = null; + private AudioManager am; + + final Object focuslock; + + private OnAudioFocusChangeListener onAudioFocusChangeListener; + /** * Constructor. * @@ -46,10 +71,13 @@ public class KiwixTextToSpeech { */ public KiwixTextToSpeech(Context context, final OnInitSucceedListener onInitSucceedListener, - final OnSpeakingListener onSpeakingListener) { + final OnSpeakingListener onSpeakingListener, final OnAudioFocusChangeListener onAudioFocusChangeListener) { Log.d(TAG_KIWIX, "Initializing TextToSpeech"); this.context = context; this.onSpeakingListener = onSpeakingListener; + this.onAudioFocusChangeListener = onAudioFocusChangeListener; + am = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); + focuslock = new Object(); initTTS(onInitSucceedListener); } @@ -109,9 +137,17 @@ public void readAloud(WebView webView) { } else { tts.setLanguage(locale); - // We use JavaScript to get the content of the page conveniently, earlier making some - // changes in the page - webView.loadUrl("javascript:" + + if (requestAudioFocus()) { + loadURL(webView); + } + } + } + } + + public void loadURL(WebView webView) { + // We use JavaScript to get the content of the page conveniently, earlier making some + // changes in the page + webView.loadUrl("javascript:" + "body = document.getElementsByTagName('body')[0].cloneNode(true);" + // Remove some elements that are shouldn't be read (table of contents, // references numbers, thumbnail captions, duplicated title, etc.) @@ -121,8 +157,6 @@ public void readAloud(WebView webView) { " elem.parentElement.removeChild(elem);" + "});" + "tts.speakAloud(body.innerText);"); - } - } } public void stop() { @@ -135,14 +169,29 @@ public void stop() { } } + public Boolean requestAudioFocus() { + int audioFocusRequest = am.requestAudioFocus(onAudioFocusChangeListener, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN); + + Log.d(TAG_KIWIX, "Audio Focus Requested"); + + synchronized (focuslock) { + if (audioFocusRequest == AudioManager.AUDIOFOCUS_REQUEST_GRANTED) { + return true; + } else { + return false; + } + } + } + public void pauseOrResume() { - if (currentTTSTask == null) + if (currentTTSTask == null) { return; - - if (currentTTSTask.paused) + } else if (currentTTSTask.paused) { + if (!requestAudioFocus()) return; currentTTSTask.start(); - else + } else { currentTTSTask.pause(); + } } public void initWebView(WebView webView) { diff --git a/app/src/main/java/org/kiwix/kiwixmobile/utils/LanguageUtils.java b/app/src/main/java/org/kiwix/kiwixmobile/utils/LanguageUtils.java index d67ce69808..3ad6c06cc1 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/utils/LanguageUtils.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/utils/LanguageUtils.java @@ -21,12 +21,10 @@ import android.annotation.TargetApi; import android.content.Context; -import android.content.SharedPreferences; import android.content.res.Configuration; import android.graphics.Typeface; import android.os.Build; import android.os.Handler; -import android.preference.PreferenceManager; import android.util.AttributeSet; import android.util.Log; import android.util.TypedValue; @@ -66,10 +64,8 @@ public LanguageUtils(Context context) { sortLanguageList(context.getResources().getConfiguration().locale); } - public static void handleLocaleChange(Context context) { - - SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); - String language = prefs.getString(PREF_LANG, ""); + public static void handleLocaleChange(Context context, SharedPreferenceUtil sharedPreferenceUtil) { + String language = sharedPreferenceUtil.getPrefLanguage(""); if (language.isEmpty()) { return; @@ -189,7 +185,7 @@ private void sortLanguageList(Locale locale) { // Check, if the selected Locale is supported and weather we actually need to change our font. // We do this by checking, if our Locale is available in the List, that Locale.getAvailableLocales() returns. - private boolean haveToChangeFont() { + private boolean haveToChangeFont(SharedPreferenceUtil sharedPreferenceUtil) { for (Locale s : Locale.getAvailableLocales()) { if (s.getLanguage().equals(Locale.getDefault().toString())) { @@ -197,8 +193,7 @@ private boolean haveToChangeFont() { } // Don't change the language, if the options hasn't been set - SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mContext); - String language = prefs.getString(PREF_LANG, ""); + String language = sharedPreferenceUtil.getPrefLanguage(""); if (language.isEmpty()) { return false; @@ -215,9 +210,9 @@ private boolean haveToChangeFont() { // which also sets a Factory on the LayoutInflator, we have to access the private field of the // LayoutInflater, that handles this restriction via Java's reflection API // and make it accessible set it to false again. - public void changeFont(LayoutInflater layoutInflater) { + public void changeFont(LayoutInflater layoutInflater, SharedPreferenceUtil sharedPreferenceUtil) { - if (!haveToChangeFont()) { + if (!haveToChangeFont(sharedPreferenceUtil)) { return; } diff --git a/app/src/main/java/org/kiwix/kiwixmobile/utils/NetworkUtils.java b/app/src/main/java/org/kiwix/kiwixmobile/utils/NetworkUtils.java index 43b9f278f0..e4c7351f8b 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/utils/NetworkUtils.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/utils/NetworkUtils.java @@ -1,3 +1,20 @@ +/* + * Kiwix Android + * Copyright (C) 2018 Kiwix + * + * 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 . + */ package org.kiwix.kiwixmobile.utils; import android.content.Context; @@ -68,8 +85,13 @@ public static String getFileNameFromUrl(String url) { public static String parseURL(Context context, String url) { String details; try { - details = url.substring(url.lastIndexOf("/") + 1, url.length() - 10); - details = details.substring(details.indexOf("_", details.indexOf("_") + 1) + 1, details.lastIndexOf("_")); + details = url.substring(url.lastIndexOf("/") + 1); + int beginIndex = details.indexOf("_", details.indexOf("_") + 1) + 1; + int endIndex = details.lastIndexOf("_"); + if (beginIndex < 0 || endIndex > details.length() || beginIndex > endIndex) { + return ""; + } + details = details.substring(beginIndex, endIndex); details = details.replaceAll("_", " "); details = details.replaceAll("all", ""); details = details.replaceAll("nopic", context.getString(R.string.zim_nopic)); diff --git a/app/src/main/java/org/kiwix/kiwixmobile/utils/SharedPreferenceUtil.java b/app/src/main/java/org/kiwix/kiwixmobile/utils/SharedPreferenceUtil.java new file mode 100644 index 0000000000..4a5fed7952 --- /dev/null +++ b/app/src/main/java/org/kiwix/kiwixmobile/utils/SharedPreferenceUtil.java @@ -0,0 +1,142 @@ +package org.kiwix.kiwixmobile.utils; + +import android.content.Context; +import android.content.SharedPreferences; +import android.os.Environment; +import android.preference.PreferenceManager; + +import javax.inject.Inject; +import javax.inject.Singleton; + +import static org.kiwix.kiwixmobile.utils.Constants.PREF_AUTONIGHTMODE; +import static org.kiwix.kiwixmobile.utils.Constants.PREF_BACK_TO_TOP; +import static org.kiwix.kiwixmobile.utils.Constants.PREF_BOTTOM_TOOLBAR; +import static org.kiwix.kiwixmobile.utils.Constants.PREF_EXTERNAL_LINK_POPUP; +import static org.kiwix.kiwixmobile.utils.Constants.PREF_FULLSCREEN; +import static org.kiwix.kiwixmobile.utils.Constants.PREF_FULL_TEXT_SEARCH; +import static org.kiwix.kiwixmobile.utils.Constants.PREF_HIDE_TOOLBAR; +import static org.kiwix.kiwixmobile.utils.Constants.PREF_IS_FIRST_RUN; +import static org.kiwix.kiwixmobile.utils.Constants.PREF_LANG; +import static org.kiwix.kiwixmobile.utils.Constants.PREF_NEW_TAB_BACKGROUND; +import static org.kiwix.kiwixmobile.utils.Constants.PREF_NIGHTMODE; +import static org.kiwix.kiwixmobile.utils.Constants.PREF_STORAGE; +import static org.kiwix.kiwixmobile.utils.Constants.PREF_STORAGE_TITLE; +import static org.kiwix.kiwixmobile.utils.Constants.PREF_WIFI_ONLY; +import static org.kiwix.kiwixmobile.utils.Constants.PREF_ZOOM; +import static org.kiwix.kiwixmobile.utils.Constants.PREF_ZOOM_ENABLED; + +/** + * Manager for the Default Shared Preferences of the application. + */ + +@Singleton +public class SharedPreferenceUtil { + private SharedPreferences sharedPreferences; + private SharedPreferences.Editor editor; + + @Inject + public SharedPreferenceUtil(Context context) { + sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); + editor = sharedPreferences.edit(); + } + + public void remove(String key) { + editor.remove(key).apply(); + } + + //Getters + + public boolean getPrefWifiOnly() { + return sharedPreferences.getBoolean(PREF_WIFI_ONLY, true); + } + + public boolean getPrefHideToolbar() { + return sharedPreferences.getBoolean(PREF_HIDE_TOOLBAR, true); + } + + public boolean getPrefIsFirstRun() { + return sharedPreferences.getBoolean(PREF_IS_FIRST_RUN, true); + } + + public boolean getPrefFullScreen() { + return sharedPreferences.getBoolean(PREF_FULLSCREEN, false); + } + + public boolean getPrefBottomToolbar() { + return sharedPreferences.getBoolean(PREF_BOTTOM_TOOLBAR, false); + } + + public boolean getPrefBackToTop() { + return sharedPreferences.getBoolean(PREF_BACK_TO_TOP, false); + } + + public boolean getPrefZoomEnabled() { + return sharedPreferences.getBoolean(PREF_ZOOM_ENABLED, false); + } + + public boolean getPrefNewTabBackground() { + return sharedPreferences.getBoolean(PREF_NEW_TAB_BACKGROUND, false); + } + + public boolean getPrefExternalLinkPopup() { + return sharedPreferences.getBoolean(PREF_EXTERNAL_LINK_POPUP, true); + } + + public float getPrefZoom() { + return sharedPreferences.getFloat(PREF_ZOOM, 100.0f); + } + + public String getPrefLanguage(String defaultLanguage) { + return sharedPreferences.getString(PREF_LANG, defaultLanguage); + } + + public String getPrefStorage() { + return sharedPreferences.getString(PREF_STORAGE, Environment.getExternalStorageDirectory().getPath()); + } + + public boolean getPrefNightMode() { + return sharedPreferences.getBoolean(PREF_NIGHTMODE, false); + } + + public boolean getPrefAutoNightMode() { + return sharedPreferences.getBoolean(PREF_AUTONIGHTMODE, false); + } + + public String getPrefStorageTitle(String defaultTitle) { + return sharedPreferences.getString(PREF_STORAGE_TITLE, defaultTitle); + } + + public boolean getPrefFullTextSearch() { + return sharedPreferences.getBoolean(PREF_FULL_TEXT_SEARCH, false); + } + + // Setters + + public void putPrefLanguage(String language) { + editor.putString(PREF_LANG, language).apply(); + } + + public void putPrefIsFirstRun(boolean isFirstRun) { + editor.putBoolean(PREF_IS_FIRST_RUN, isFirstRun); + } + + public void putPrefWifiOnly(boolean wifiOnly) { + editor.putBoolean(PREF_WIFI_ONLY, wifiOnly).apply(); + } + + public void putPrefStorageTitle(String storageTitle) { + editor.putString(PREF_STORAGE_TITLE, storageTitle).apply(); + } + + public void putPrefStorage(String storage) { + editor.putString(PREF_STORAGE, storage).apply(); + } + + public void putPrefFullScreen(boolean fullScreen) { + editor.putBoolean(PREF_FULLSCREEN, fullScreen).apply(); + } + + public void putPrefExternalLinkPopup(boolean externalLinkPopup) { + editor.putBoolean(PREF_EXTERNAL_LINK_POPUP, externalLinkPopup).apply(); + } +} diff --git a/app/src/main/java/org/kiwix/kiwixmobile/utils/SplashActivity.java b/app/src/main/java/org/kiwix/kiwixmobile/utils/SplashActivity.java index d44a5d7736..d93d662b4e 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/utils/SplashActivity.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/utils/SplashActivity.java @@ -1,3 +1,20 @@ +/* + * Kiwix Android + * Copyright (C) 2018 Kiwix + * + * 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 . + */ package org.kiwix.kiwixmobile.utils; import android.content.Intent; diff --git a/app/src/main/java/org/kiwix/kiwixmobile/utils/StorageUtils.java b/app/src/main/java/org/kiwix/kiwixmobile/utils/StorageUtils.java index 23998c0ec5..833b4072c9 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/utils/StorageUtils.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/utils/StorageUtils.java @@ -1,3 +1,20 @@ +/* + * Kiwix Android + * Copyright (C) 2018 Kiwix + * + * 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 . + */ package org.kiwix.kiwixmobile.utils; public class StorageUtils { diff --git a/app/src/main/java/org/kiwix/kiwixmobile/utils/StyleUtils.java b/app/src/main/java/org/kiwix/kiwixmobile/utils/StyleUtils.java index 54638fbb1e..8570992c17 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/utils/StyleUtils.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/utils/StyleUtils.java @@ -34,7 +34,7 @@ public class StyleUtils { public static int dialogStyle() { if (KiwixMobileActivity.nightMode) { - return android.R.style.Theme_Holo_Dialog; + return R.style.AppTheme_Dialog_Night; } else { return R.style.AppTheme_Dialog; } diff --git a/app/src/main/java/org/kiwix/kiwixmobile/utils/TestingUtils.java b/app/src/main/java/org/kiwix/kiwixmobile/utils/TestingUtils.java index 77cc15fdaf..b45f259b4c 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/utils/TestingUtils.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/utils/TestingUtils.java @@ -1,3 +1,20 @@ +/* + * Kiwix Android + * Copyright (C) 2018 Kiwix + * + * 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 . + */ package org.kiwix.kiwixmobile.utils; import java.util.HashSet; diff --git a/app/src/main/java/org/kiwix/kiwixmobile/utils/files/FileReader.java b/app/src/main/java/org/kiwix/kiwixmobile/utils/files/FileReader.java index 823ce00bb9..f4bc9a7ce0 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/utils/files/FileReader.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/utils/files/FileReader.java @@ -1,3 +1,20 @@ +/* + * Kiwix Android + * Copyright (C) 2018 Kiwix + * + * 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 . + */ package org.kiwix.kiwixmobile.utils.files; import android.content.Context; diff --git a/app/src/main/java/org/kiwix/kiwixmobile/utils/files/FileUtils.java b/app/src/main/java/org/kiwix/kiwixmobile/utils/files/FileUtils.java index 57a8302593..69e07aafe7 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/utils/files/FileUtils.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/utils/files/FileUtils.java @@ -1,3 +1,20 @@ +/* + * Kiwix Android + * Copyright (C) 2018 Kiwix + * + * 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 . + */ package org.kiwix.kiwixmobile.utils.files; import android.content.ContentUris; diff --git a/app/src/main/java/org/kiwix/kiwixmobile/views/AnimatedProgressBar.java b/app/src/main/java/org/kiwix/kiwixmobile/views/AnimatedProgressBar.java index 71db9839a0..9c71a7075c 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/views/AnimatedProgressBar.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/views/AnimatedProgressBar.java @@ -1,3 +1,20 @@ +/* + * Kiwix Android + * Copyright (C) 2018 Kiwix + * + * 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 . + */ package org.kiwix.kiwixmobile.views; import android.animation.ObjectAnimator; diff --git a/app/src/main/java/org/kiwix/kiwixmobile/views/AutoCompleteAdapter.java b/app/src/main/java/org/kiwix/kiwixmobile/views/AutoCompleteAdapter.java index 98f9376b7b..4ecd9eb104 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/views/AutoCompleteAdapter.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/views/AutoCompleteAdapter.java @@ -1,9 +1,23 @@ +/* + * Kiwix Android + * Copyright (C) 2018 Kiwix + * + * 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 . + */ package org.kiwix.kiwixmobile.views; import android.content.Context; -import android.content.SharedPreferences; -import android.os.ResultReceiver; -import android.preference.PreferenceManager; import android.text.Html; import android.view.View; import android.view.ViewGroup; @@ -14,16 +28,15 @@ import org.kiwix.kiwixlib.JNIKiwix; import org.kiwix.kiwixlib.JNIKiwixSearcher; -import org.kiwix.kiwixmobile.KiwixMobileActivity; +import org.kiwix.kiwixmobile.KiwixApplication; import org.kiwix.kiwixmobile.ZimContentProvider; +import org.kiwix.kiwixmobile.utils.SharedPreferenceUtil; import java.util.ArrayList; import java.util.List; import javax.inject.Inject; -import static org.kiwix.kiwixmobile.utils.Constants.PREF_FULL_TEXT_SEARCH; - public class AutoCompleteAdapter extends ArrayAdapter implements Filterable { private List mData; @@ -33,12 +46,19 @@ public class AutoCompleteAdapter extends ArrayAdapter implements Filtera private Context context; @Inject JNIKiwix currentJNIReader; + @Inject + SharedPreferenceUtil sharedPreferenceUtil; + + private void setupDagger() { + KiwixApplication.getInstance().getApplicationComponent().inject(this); + } public AutoCompleteAdapter(Context context) { super(context, android.R.layout.simple_list_item_1); this.context = context; mData = new ArrayList<>(); mFilter = new KiwixFilter(); + setupDagger(); } @Override @@ -85,8 +105,7 @@ protected FilterResults performFiltering(CharSequence constraint) { final String query = constraint.toString(); /* Fulltext search */ - SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); - if (sharedPreferences.getBoolean(PREF_FULL_TEXT_SEARCH, false)) { + if (sharedPreferenceUtil.getPrefFullTextSearch()) { ZimContentProvider.jniSearcher.search(query, 200); JNIKiwixSearcher.Result result = ZimContentProvider.jniSearcher.getNextResult(); while (result != null) { diff --git a/app/src/main/java/org/kiwix/kiwixmobile/views/LanguageSelectDialog.java b/app/src/main/java/org/kiwix/kiwixmobile/views/LanguageSelectDialog.java index ee8bc8ef7e..a808fdb3d1 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/views/LanguageSelectDialog.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/views/LanguageSelectDialog.java @@ -1,3 +1,20 @@ +/* + * Kiwix Android + * Copyright (C) 2018 Kiwix + * + * 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 . + */ package org.kiwix.kiwixmobile.views; import android.content.Context; diff --git a/app/src/main/java/org/kiwix/kiwixmobile/views/PageBottomTabLayout.java b/app/src/main/java/org/kiwix/kiwixmobile/views/PageBottomTabLayout.java index d2aff29387..944ea0abc7 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/views/PageBottomTabLayout.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/views/PageBottomTabLayout.java @@ -1,3 +1,20 @@ +/* + * Kiwix Android + * Copyright (C) 2018 Kiwix + * + * 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 . + */ package org.kiwix.kiwixmobile.views; import android.content.Context; diff --git a/app/src/main/java/org/kiwix/kiwixmobile/views/SliderPreference.java b/app/src/main/java/org/kiwix/kiwixmobile/views/SliderPreference.java index cddcad7618..614ec3613e 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/views/SliderPreference.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/views/SliderPreference.java @@ -1,3 +1,20 @@ +/* + * Kiwix Android + * Copyright (C) 2018 Kiwix + * + * 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 . + */ package org.kiwix.kiwixmobile.views; import android.content.Context; diff --git a/app/src/main/java/org/kiwix/kiwixmobile/views/web/KiwixWebView.java b/app/src/main/java/org/kiwix/kiwixmobile/views/web/KiwixWebView.java index 03ef266897..b82a9363bf 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/views/web/KiwixWebView.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/views/web/KiwixWebView.java @@ -20,14 +20,12 @@ package org.kiwix.kiwixmobile.views.web; import android.content.Context; -import android.content.SharedPreferences; import android.graphics.ColorMatrixColorFilter; import android.graphics.Paint; import android.net.Uri; import android.os.Environment; import android.os.Handler; import android.os.Message; -import android.preference.PreferenceManager; import android.util.AttributeSet; import android.util.Log; import android.view.ContextMenu; @@ -36,12 +34,14 @@ import android.webkit.WebView; import android.widget.Toast; +import org.kiwix.kiwixmobile.KiwixApplication; import org.kiwix.kiwixmobile.KiwixMobileActivity; import org.kiwix.kiwixmobile.KiwixWebChromeClient; import org.kiwix.kiwixmobile.KiwixWebViewClient; import org.kiwix.kiwixmobile.R; import org.kiwix.kiwixmobile.WebViewCallback; import org.kiwix.kiwixmobile.utils.LanguageUtils; +import org.kiwix.kiwixmobile.utils.SharedPreferenceUtil; import java.io.File; import java.io.FileOutputStream; @@ -49,6 +49,8 @@ import java.io.InputStream; import java.io.OutputStream; +import javax.inject.Inject; + public class KiwixWebView extends WebView { private static final String PREF_ZOOM = "pref_zoom_slider"; @@ -62,6 +64,7 @@ public class KiwixWebView extends WebView { 0, 0, 0, 1.0f, 0 // alpha }; private WebViewCallback callback; + @Inject SharedPreferenceUtil sharedPreferenceUtil; private Handler saveHandler = new Handler() { @@ -121,6 +124,7 @@ public void handleMessage(Message msg) { public KiwixWebView(Context context, WebViewCallback callback, AttributeSet attrs) { super(context, attrs); this.callback = callback; + setupDagger(); // Set the user agent to the current locale so it can be read with navigator.userAgent getSettings().setUserAgentString(LanguageUtils.getCurrentLocale(context).toString()); setWebViewClient(new KiwixWebViewClient(callback)); @@ -128,15 +132,17 @@ public KiwixWebView(Context context, WebViewCallback callback, AttributeSet attr getSettings().setDomStorageEnabled(true); } + private void setupDagger() { + KiwixApplication.getInstance().getApplicationComponent().inject(this); + } + public void loadPrefs() { disableZoomControls(); - SharedPreferences sharedPreferences = - PreferenceManager.getDefaultSharedPreferences(getContext()); - boolean zoomEnabled = sharedPreferences.getBoolean(PREF_ZOOM_ENABLED, false); + boolean zoomEnabled = sharedPreferenceUtil.getPrefZoomEnabled(); if (zoomEnabled) { - int zoomScale = (int) sharedPreferences.getFloat(PREF_ZOOM, 100.0f); + int zoomScale = (int) sharedPreferenceUtil.getPrefZoom(); setInitialScale(zoomScale); } else { setInitialScale(0); diff --git a/app/src/main/java/org/kiwix/kiwixmobile/views/web/ToolbarStaticKiwixWebView.java b/app/src/main/java/org/kiwix/kiwixmobile/views/web/ToolbarStaticKiwixWebView.java index 24755a59ba..2b00f33d3a 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/views/web/ToolbarStaticKiwixWebView.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/views/web/ToolbarStaticKiwixWebView.java @@ -1,3 +1,20 @@ +/* + * Kiwix Android + * Copyright (C) 2018 Kiwix + * + * 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 . + */ package org.kiwix.kiwixmobile.views.web; import android.content.Context; diff --git a/app/src/main/java/org/kiwix/kiwixmobile/zim_manager/SectionsPagerAdapter.java b/app/src/main/java/org/kiwix/kiwixmobile/zim_manager/SectionsPagerAdapter.java index 0a977875e3..8b8ca5d95a 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/zim_manager/SectionsPagerAdapter.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/zim_manager/SectionsPagerAdapter.java @@ -1,3 +1,20 @@ +/* + * Kiwix Android + * Copyright (C) 2018 Kiwix + * + * 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 . + */ package org.kiwix.kiwixmobile.zim_manager; import android.content.Context; diff --git a/app/src/main/java/org/kiwix/kiwixmobile/zim_manager/ZimManageActivity.java b/app/src/main/java/org/kiwix/kiwixmobile/zim_manager/ZimManageActivity.java index f33054b4ac..6bcd5982d6 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/zim_manager/ZimManageActivity.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/zim_manager/ZimManageActivity.java @@ -1,16 +1,30 @@ +/* + * Kiwix Android + * Copyright (C) 2018 Kiwix + * + * 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 . + */ package org.kiwix.kiwixmobile.zim_manager; import android.content.Intent; -import android.content.SharedPreferences; import android.os.Bundle; -import android.preference.PreferenceManager; import android.provider.Settings; import android.support.annotation.NonNull; import android.support.design.widget.AppBarLayout; import android.support.design.widget.CoordinatorLayout; import android.support.design.widget.TabLayout; import android.support.v4.app.FragmentPagerAdapter; -import android.support.v4.view.MenuItemCompat; import android.support.v4.view.ViewPager; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.SearchView; @@ -18,13 +32,13 @@ import android.util.Log; import android.view.Menu; import android.view.MenuItem; -import android.view.View; import android.widget.Toast; import org.kiwix.kiwixmobile.KiwixApplication; import org.kiwix.kiwixmobile.KiwixMobileActivity; import org.kiwix.kiwixmobile.R; import org.kiwix.kiwixmobile.settings.KiwixSettingsActivity; +import org.kiwix.kiwixmobile.utils.SharedPreferenceUtil; import org.kiwix.kiwixmobile.views.LanguageSelectDialog; import org.kiwix.kiwixmobile.zim_manager.library_view.LibraryFragment; @@ -64,6 +78,8 @@ public class ZimManageActivity extends AppCompatActivity implements ZimManageVie @Inject ZimManagePresenter zimManagePresenter; + @Inject + SharedPreferenceUtil sharedPreferenceUtil; private void setupDagger() { KiwixApplication.getInstance().getApplicationComponent().inject(this); @@ -71,13 +87,12 @@ private void setupDagger() { @Override protected void onCreate(Bundle savedInstanceState) { - SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); - if (KiwixSettingsActivity.nightMode(sharedPreferences)) { + setupDagger(); + if (KiwixSettingsActivity.nightMode(sharedPreferenceUtil)) { setTheme(R.style.AppTheme_Night); } super.onCreate(savedInstanceState); setContentView(R.layout.zim_manager); - setupDagger(); setUpToolbar(); zimManagePresenter.attachView(this); diff --git a/app/src/main/java/org/kiwix/kiwixmobile/zim_manager/ZimManagePresenter.java b/app/src/main/java/org/kiwix/kiwixmobile/zim_manager/ZimManagePresenter.java index 609ae1d461..153ed798c0 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/zim_manager/ZimManagePresenter.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/zim_manager/ZimManagePresenter.java @@ -1,3 +1,20 @@ +/* + * Kiwix Android + * Copyright (C) 2018 Kiwix + * + * 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 . + */ package org.kiwix.kiwixmobile.zim_manager; import android.content.Context; diff --git a/app/src/main/java/org/kiwix/kiwixmobile/zim_manager/ZimManageViewCallback.java b/app/src/main/java/org/kiwix/kiwixmobile/zim_manager/ZimManageViewCallback.java index 7e1c401148..c46deb6533 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/zim_manager/ZimManageViewCallback.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/zim_manager/ZimManageViewCallback.java @@ -1,3 +1,20 @@ +/* + * Kiwix Android + * Copyright (C) 2018 Kiwix + * + * 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 . + */ package org.kiwix.kiwixmobile.zim_manager; import org.kiwix.kiwixmobile.base.ViewCallback; diff --git a/app/src/main/java/org/kiwix/kiwixmobile/zim_manager/fileselect_view/ZimFileSelectFragment.java b/app/src/main/java/org/kiwix/kiwixmobile/zim_manager/fileselect_view/ZimFileSelectFragment.java index 62906921ef..d67022f866 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/zim_manager/fileselect_view/ZimFileSelectFragment.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/zim_manager/fileselect_view/ZimFileSelectFragment.java @@ -27,15 +27,12 @@ import android.net.Uri; import android.os.Build; import android.os.Bundle; -import android.os.Environment; -import android.preference.PreferenceManager; import android.support.v4.app.Fragment; import android.support.v4.content.ContextCompat; import android.support.v4.widget.SwipeRefreshLayout; import android.support.v7.app.AlertDialog; import android.util.Log; import android.view.LayoutInflater; -import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; @@ -48,7 +45,6 @@ import android.widget.Toast; import org.kiwix.kiwixmobile.KiwixApplication; -import org.kiwix.kiwixmobile.KiwixMobileActivity; import org.kiwix.kiwixmobile.R; import org.kiwix.kiwixmobile.ZimContentProvider; import org.kiwix.kiwixmobile.database.BookDao; @@ -57,6 +53,7 @@ import org.kiwix.kiwixmobile.library.entity.LibraryNetworkEntity; import org.kiwix.kiwixmobile.utils.BookUtils; import org.kiwix.kiwixmobile.utils.LanguageUtils; +import org.kiwix.kiwixmobile.utils.SharedPreferenceUtil; import org.kiwix.kiwixmobile.utils.TestingUtils; import org.kiwix.kiwixmobile.utils.files.FileSearch; import org.kiwix.kiwixmobile.utils.files.FileUtils; @@ -70,7 +67,6 @@ import javax.inject.Inject; -import static org.kiwix.kiwixmobile.utils.Constants.PREF_STORAGE; import static org.kiwix.kiwixmobile.utils.Constants.REQUEST_STORAGE_PERMISSION; import static org.kiwix.kiwixmobile.utils.Constants.TAG_KIWIX; import static org.kiwix.kiwixmobile.utils.NetworkUtils.parseURL; @@ -93,6 +89,7 @@ public class ZimFileSelectFragment extends Fragment @Inject ZimFileSelectPresenter presenter; @Inject BookUtils bookUtils; + @Inject SharedPreferenceUtil sharedPreferenceUtil; private void setupDagger() { KiwixApplication.getInstance().getApplicationComponent().inject(this); @@ -105,7 +102,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa presenter.attachView(this); // Replace LinearLayout by the type of the root element of the layout you're trying to load llLayout = (RelativeLayout) inflater.inflate(R.layout.zim_list, container, false); - new LanguageUtils(super.getActivity()).changeFont(super.getActivity().getLayoutInflater()); + new LanguageUtils(super.getActivity()).changeFont(super.getActivity().getLayoutInflater(), sharedPreferenceUtil); mFileMessage = llLayout.findViewById(R.id.file_management_no_files); mZimFileList = llLayout.findViewById(R.id.zimfilelist); @@ -269,8 +266,7 @@ public void onScanCompleted() { swipeRefreshLayout.setRefreshing(false); }); } - }).scan(PreferenceManager.getDefaultSharedPreferences(context) - .getString(PREF_STORAGE, Environment.getExternalStorageDirectory().getPath())); + }).scan(sharedPreferenceUtil.getPrefStorage()); } @Override diff --git a/app/src/main/java/org/kiwix/kiwixmobile/zim_manager/fileselect_view/ZimFileSelectPresenter.java b/app/src/main/java/org/kiwix/kiwixmobile/zim_manager/fileselect_view/ZimFileSelectPresenter.java index b0798d6933..7abd5ef064 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/zim_manager/fileselect_view/ZimFileSelectPresenter.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/zim_manager/fileselect_view/ZimFileSelectPresenter.java @@ -1,3 +1,20 @@ +/* + * Kiwix Android + * Copyright (C) 2018 Kiwix + * + * 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 . + */ package org.kiwix.kiwixmobile.zim_manager.fileselect_view; import android.content.Context; diff --git a/app/src/main/java/org/kiwix/kiwixmobile/zim_manager/fileselect_view/ZimFileSelectViewCallback.java b/app/src/main/java/org/kiwix/kiwixmobile/zim_manager/fileselect_view/ZimFileSelectViewCallback.java index 63a00cba52..c5be8a024b 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/zim_manager/fileselect_view/ZimFileSelectViewCallback.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/zim_manager/fileselect_view/ZimFileSelectViewCallback.java @@ -1,3 +1,20 @@ +/* + * Kiwix Android + * Copyright (C) 2018 Kiwix + * + * 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 . + */ package org.kiwix.kiwixmobile.zim_manager.fileselect_view; import org.kiwix.kiwixmobile.base.ViewCallback; diff --git a/app/src/main/java/org/kiwix/kiwixmobile/zim_manager/library_view/LibraryFragment.java b/app/src/main/java/org/kiwix/kiwixmobile/zim_manager/library_view/LibraryFragment.java index 78a7e13828..4258eddf2c 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/zim_manager/library_view/LibraryFragment.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/zim_manager/library_view/LibraryFragment.java @@ -1,25 +1,37 @@ +/* + * Kiwix Android + * Copyright (C) 2018 Kiwix + * + * 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 . + */ package org.kiwix.kiwixmobile.zim_manager.library_view; import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.Context; -import android.content.DialogInterface; import android.content.Intent; import android.content.IntentFilter; import android.content.ServiceConnection; -import android.content.SharedPreferences; import android.graphics.Color; import android.net.ConnectivityManager; import android.net.NetworkInfo; import android.os.Bundle; -import android.os.Environment; import android.os.IBinder; -import android.preference.PreferenceManager; import android.support.design.widget.Snackbar; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.widget.SwipeRefreshLayout; -import android.support.v7.app.AlertDialog; import android.util.Log; import android.view.LayoutInflater; import android.view.View; @@ -28,7 +40,6 @@ import android.widget.Button; import android.widget.LinearLayout; import android.widget.ListView; -import android.widget.RelativeLayout; import android.widget.TextView; import android.widget.Toast; @@ -41,6 +52,7 @@ import org.kiwix.kiwixmobile.library.LibraryAdapter; import org.kiwix.kiwixmobile.network.KiwixService; import org.kiwix.kiwixmobile.utils.NetworkUtils; +import org.kiwix.kiwixmobile.utils.SharedPreferenceUtil; import org.kiwix.kiwixmobile.utils.StorageUtils; import org.kiwix.kiwixmobile.utils.StyleUtils; import org.kiwix.kiwixmobile.utils.TestingUtils; @@ -62,9 +74,6 @@ import static org.kiwix.kiwixmobile.downloader.DownloadService.KIWIX_ROOT; import static org.kiwix.kiwixmobile.library.entity.LibraryNetworkEntity.Book; import static org.kiwix.kiwixmobile.utils.Constants.EXTRA_BOOK; -import static org.kiwix.kiwixmobile.utils.Constants.PREF_STORAGE; -import static org.kiwix.kiwixmobile.utils.Constants.PREF_STORAGE_TITLE; -import static org.kiwix.kiwixmobile.utils.StyleUtils.dialogStyle; public class LibraryFragment extends Fragment implements AdapterView.OnItemClickListener, StorageSelectDialog.OnSelectListener, LibraryViewCallback { @@ -109,6 +118,9 @@ public class LibraryFragment extends Fragment @Inject LibraryPresenter presenter; + @Inject + SharedPreferenceUtil sharedPreferenceUtil; + private void setupDagger() { KiwixApplication.getInstance().getApplicationComponent().inject(this); } @@ -318,23 +330,17 @@ public void downloadFile(Book book) { } public long getSpaceAvailable() { - return new File(PreferenceManager.getDefaultSharedPreferences(super.getActivity()) - .getString(PREF_STORAGE, Environment.getExternalStorageDirectory() - .getPath())).getFreeSpace(); + return new File(sharedPreferenceUtil.getPrefStorage()).getFreeSpace(); } @Override public void selectionCallback(StorageDevice storageDevice) { - SharedPreferences sharedPreferences = - PreferenceManager.getDefaultSharedPreferences(getActivity()); - SharedPreferences.Editor editor = sharedPreferences.edit(); - editor.putString(PREF_STORAGE, storageDevice.getName()); + sharedPreferenceUtil.putPrefStorage(storageDevice.getName()); if (storageDevice.isInternal()) { - editor.putString(PREF_STORAGE_TITLE, getResources().getString(R.string.internal_storage)); + sharedPreferenceUtil.putPrefStorageTitle(getResources().getString(R.string.internal_storage)); } else { - editor.putString(PREF_STORAGE_TITLE, getResources().getString(R.string.external_storage)); + sharedPreferenceUtil.putPrefStorageTitle(getResources().getString(R.string.external_storage)); } - editor.apply(); } public class DownloadServiceConnection { diff --git a/app/src/main/java/org/kiwix/kiwixmobile/zim_manager/library_view/LibraryPresenter.java b/app/src/main/java/org/kiwix/kiwixmobile/zim_manager/library_view/LibraryPresenter.java index 1510616dd5..82fb23a46e 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/zim_manager/library_view/LibraryPresenter.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/zim_manager/library_view/LibraryPresenter.java @@ -1,3 +1,20 @@ +/* + * Kiwix Android + * Copyright (C) 2018 Kiwix + * + * 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 . + */ package org.kiwix.kiwixmobile.zim_manager.library_view; import android.content.Context; @@ -12,7 +29,7 @@ import javax.inject.Inject; -import rx.android.schedulers.AndroidSchedulers; +import io.reactivex.android.schedulers.AndroidSchedulers; /** * Created by EladKeyshawn on 06/04/2017. diff --git a/app/src/main/java/org/kiwix/kiwixmobile/zim_manager/library_view/LibraryUtils.java b/app/src/main/java/org/kiwix/kiwixmobile/zim_manager/library_view/LibraryUtils.java index 22d46f9bba..7cc3fc59fe 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/zim_manager/library_view/LibraryUtils.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/zim_manager/library_view/LibraryUtils.java @@ -1,3 +1,20 @@ +/* + * Kiwix Android + * Copyright (C) 2018 Kiwix + * + * 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 . + */ package org.kiwix.kiwixmobile.zim_manager.library_view; import java.math.BigDecimal; diff --git a/app/src/main/java/org/kiwix/kiwixmobile/zim_manager/library_view/LibraryViewCallback.java b/app/src/main/java/org/kiwix/kiwixmobile/zim_manager/library_view/LibraryViewCallback.java index 675c61f85d..b379081f93 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/zim_manager/library_view/LibraryViewCallback.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/zim_manager/library_view/LibraryViewCallback.java @@ -1,3 +1,20 @@ +/* + * Kiwix Android + * Copyright (C) 2018 Kiwix + * + * 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 . + */ package org.kiwix.kiwixmobile.zim_manager.library_view; import org.kiwix.kiwixmobile.base.ViewCallback; diff --git a/app/src/main/res/drawable-hdpi-v11/kiwix_notification.png b/app/src/main/res/drawable-hdpi-v11/kiwix_notification.png deleted file mode 100644 index b6d7fcd241..0000000000 Binary files a/app/src/main/res/drawable-hdpi-v11/kiwix_notification.png and /dev/null differ diff --git a/app/src/main/res/drawable-hdpi-v9/kiwix_notification.png b/app/src/main/res/drawable-hdpi-v9/kiwix_notification.png deleted file mode 100644 index 4443e18009..0000000000 Binary files a/app/src/main/res/drawable-hdpi-v9/kiwix_notification.png and /dev/null differ diff --git a/app/src/main/res/drawable-hdpi/action_bookmark.png b/app/src/main/res/drawable-hdpi/action_bookmark.png deleted file mode 100644 index c9ab32870c..0000000000 Binary files a/app/src/main/res/drawable-hdpi/action_bookmark.png and /dev/null differ diff --git a/app/src/main/res/drawable-hdpi/action_bookmark_active.png b/app/src/main/res/drawable-hdpi/action_bookmark_active.png deleted file mode 100644 index 111b191847..0000000000 Binary files a/app/src/main/res/drawable-hdpi/action_bookmark_active.png and /dev/null differ diff --git a/app/src/main/res/drawable-hdpi/action_find_next.png b/app/src/main/res/drawable-hdpi/action_find_next.png deleted file mode 100644 index 2fe4f81ee4..0000000000 Binary files a/app/src/main/res/drawable-hdpi/action_find_next.png and /dev/null differ diff --git a/app/src/main/res/drawable-hdpi/action_find_previous.png b/app/src/main/res/drawable-hdpi/action_find_previous.png deleted file mode 100644 index d4e9bd17f1..0000000000 Binary files a/app/src/main/res/drawable-hdpi/action_find_previous.png and /dev/null differ diff --git a/app/src/main/res/drawable-hdpi/action_help.png b/app/src/main/res/drawable-hdpi/action_help.png deleted file mode 100644 index 36094f0c9f..0000000000 Binary files a/app/src/main/res/drawable-hdpi/action_help.png and /dev/null differ diff --git a/app/src/main/res/drawable-hdpi/action_home.png b/app/src/main/res/drawable-hdpi/action_home.png deleted file mode 100644 index bef070cb90..0000000000 Binary files a/app/src/main/res/drawable-hdpi/action_home.png and /dev/null differ diff --git a/app/src/main/res/drawable-hdpi/action_open_file.png b/app/src/main/res/drawable-hdpi/action_open_file.png deleted file mode 100644 index bce09bcd8a..0000000000 Binary files a/app/src/main/res/drawable-hdpi/action_open_file.png and /dev/null differ diff --git a/app/src/main/res/drawable-hdpi/action_randomarticle.png b/app/src/main/res/drawable-hdpi/action_randomarticle.png deleted file mode 100644 index 0219201287..0000000000 Binary files a/app/src/main/res/drawable-hdpi/action_randomarticle.png and /dev/null differ diff --git a/app/src/main/res/drawable-hdpi/action_search.png b/app/src/main/res/drawable-hdpi/action_search.png deleted file mode 100644 index 6bf9dc7a8e..0000000000 Binary files a/app/src/main/res/drawable-hdpi/action_search.png and /dev/null differ diff --git a/app/src/main/res/drawable-hdpi/fullscreen.png b/app/src/main/res/drawable-hdpi/fullscreen.png deleted file mode 100755 index c150cb58db..0000000000 Binary files a/app/src/main/res/drawable-hdpi/fullscreen.png and /dev/null differ diff --git a/app/src/main/res/drawable-hdpi/fullscreen_exit.png b/app/src/main/res/drawable-hdpi/fullscreen_exit.png deleted file mode 100644 index 8328e2efe0..0000000000 Binary files a/app/src/main/res/drawable-hdpi/fullscreen_exit.png and /dev/null differ diff --git a/app/src/main/res/drawable-hdpi/ic_mic_black_24dp.png b/app/src/main/res/drawable-hdpi/ic_mic_black_24dp.png deleted file mode 100644 index 74218e1a65..0000000000 Binary files a/app/src/main/res/drawable-hdpi/ic_mic_black_24dp.png and /dev/null differ diff --git a/app/src/main/res/drawable-hdpi/ic_stars_black_24dp.png b/app/src/main/res/drawable-hdpi/ic_stars_black_24dp.png deleted file mode 100644 index fba38967bc..0000000000 Binary files a/app/src/main/res/drawable-hdpi/ic_stars_black_24dp.png and /dev/null differ diff --git a/app/src/main/res/drawable-hdpi/kiwix_notification.png b/app/src/main/res/drawable-hdpi/kiwix_notification.png index b13bd32c0a..b6d7fcd241 100644 Binary files a/app/src/main/res/drawable-hdpi/kiwix_notification.png and b/app/src/main/res/drawable-hdpi/kiwix_notification.png differ diff --git a/app/src/main/res/drawable-hdpi/navigation_forward.png b/app/src/main/res/drawable-hdpi/navigation_forward.png deleted file mode 100644 index d924a57a18..0000000000 Binary files a/app/src/main/res/drawable-hdpi/navigation_forward.png and /dev/null differ diff --git a/app/src/main/res/drawable-mdpi-v11/kiwix_notification.png b/app/src/main/res/drawable-mdpi-v11/kiwix_notification.png deleted file mode 100644 index 8fc2a28d04..0000000000 Binary files a/app/src/main/res/drawable-mdpi-v11/kiwix_notification.png and /dev/null differ diff --git a/app/src/main/res/drawable-mdpi-v9/kiwix_notification.png b/app/src/main/res/drawable-mdpi-v9/kiwix_notification.png deleted file mode 100644 index dc159d48ee..0000000000 Binary files a/app/src/main/res/drawable-mdpi-v9/kiwix_notification.png and /dev/null differ diff --git a/app/src/main/res/drawable-mdpi/action_bookmark.png b/app/src/main/res/drawable-mdpi/action_bookmark.png deleted file mode 100644 index e302ef6fa2..0000000000 Binary files a/app/src/main/res/drawable-mdpi/action_bookmark.png and /dev/null differ diff --git a/app/src/main/res/drawable-mdpi/action_bookmark_active.png b/app/src/main/res/drawable-mdpi/action_bookmark_active.png deleted file mode 100644 index 86eecdd4a0..0000000000 Binary files a/app/src/main/res/drawable-mdpi/action_bookmark_active.png and /dev/null differ diff --git a/app/src/main/res/drawable-mdpi/action_find_next.png b/app/src/main/res/drawable-mdpi/action_find_next.png deleted file mode 100644 index c138916f9c..0000000000 Binary files a/app/src/main/res/drawable-mdpi/action_find_next.png and /dev/null differ diff --git a/app/src/main/res/drawable-mdpi/action_find_previous.png b/app/src/main/res/drawable-mdpi/action_find_previous.png deleted file mode 100644 index d2392744c6..0000000000 Binary files a/app/src/main/res/drawable-mdpi/action_find_previous.png and /dev/null differ diff --git a/app/src/main/res/drawable-mdpi/action_help.png b/app/src/main/res/drawable-mdpi/action_help.png deleted file mode 100644 index 204342f339..0000000000 Binary files a/app/src/main/res/drawable-mdpi/action_help.png and /dev/null differ diff --git a/app/src/main/res/drawable-mdpi/action_home.png b/app/src/main/res/drawable-mdpi/action_home.png deleted file mode 100644 index 1e5b80e247..0000000000 Binary files a/app/src/main/res/drawable-mdpi/action_home.png and /dev/null differ diff --git a/app/src/main/res/drawable-mdpi/action_open_file.png b/app/src/main/res/drawable-mdpi/action_open_file.png deleted file mode 100644 index 60397d4a57..0000000000 Binary files a/app/src/main/res/drawable-mdpi/action_open_file.png and /dev/null differ diff --git a/app/src/main/res/drawable-mdpi/action_randomarticle.png b/app/src/main/res/drawable-mdpi/action_randomarticle.png deleted file mode 100644 index 1f2b4fffcd..0000000000 Binary files a/app/src/main/res/drawable-mdpi/action_randomarticle.png and /dev/null differ diff --git a/app/src/main/res/drawable-mdpi/action_search.png b/app/src/main/res/drawable-mdpi/action_search.png deleted file mode 100644 index bbfbc96cbc..0000000000 Binary files a/app/src/main/res/drawable-mdpi/action_search.png and /dev/null differ diff --git a/app/src/main/res/drawable-mdpi/fullscreen.png b/app/src/main/res/drawable-mdpi/fullscreen.png deleted file mode 100755 index 2d3bb49ba9..0000000000 Binary files a/app/src/main/res/drawable-mdpi/fullscreen.png and /dev/null differ diff --git a/app/src/main/res/drawable-mdpi/ic_mic_black_24dp.png b/app/src/main/res/drawable-mdpi/ic_mic_black_24dp.png deleted file mode 100644 index 19a16138fe..0000000000 Binary files a/app/src/main/res/drawable-mdpi/ic_mic_black_24dp.png and /dev/null differ diff --git a/app/src/main/res/drawable-mdpi/ic_stars_black_24dp.png b/app/src/main/res/drawable-mdpi/ic_stars_black_24dp.png deleted file mode 100644 index 365c321d4c..0000000000 Binary files a/app/src/main/res/drawable-mdpi/ic_stars_black_24dp.png and /dev/null differ diff --git a/app/src/main/res/drawable-mdpi/kiwix_notification.png b/app/src/main/res/drawable-mdpi/kiwix_notification.png index f7c1336f05..8fc2a28d04 100644 Binary files a/app/src/main/res/drawable-mdpi/kiwix_notification.png and b/app/src/main/res/drawable-mdpi/kiwix_notification.png differ diff --git a/app/src/main/res/drawable-mdpi/navigation_forward.png b/app/src/main/res/drawable-mdpi/navigation_forward.png deleted file mode 100644 index f3430d2780..0000000000 Binary files a/app/src/main/res/drawable-mdpi/navigation_forward.png and /dev/null differ diff --git a/app/src/main/res/drawable-xhdpi-v11/kiwix_notification.png b/app/src/main/res/drawable-xhdpi-v11/kiwix_notification.png deleted file mode 100644 index 12a866f278..0000000000 Binary files a/app/src/main/res/drawable-xhdpi-v11/kiwix_notification.png and /dev/null differ diff --git a/app/src/main/res/drawable-xhdpi-v9/kiwix_notification.png b/app/src/main/res/drawable-xhdpi-v9/kiwix_notification.png deleted file mode 100644 index 82a691a7d8..0000000000 Binary files a/app/src/main/res/drawable-xhdpi-v9/kiwix_notification.png and /dev/null differ diff --git a/app/src/main/res/drawable-xhdpi/action_bookmark.png b/app/src/main/res/drawable-xhdpi/action_bookmark.png deleted file mode 100644 index 7e41906c5f..0000000000 Binary files a/app/src/main/res/drawable-xhdpi/action_bookmark.png and /dev/null differ diff --git a/app/src/main/res/drawable-xhdpi/action_bookmark_active.png b/app/src/main/res/drawable-xhdpi/action_bookmark_active.png deleted file mode 100644 index aa5879215e..0000000000 Binary files a/app/src/main/res/drawable-xhdpi/action_bookmark_active.png and /dev/null differ diff --git a/app/src/main/res/drawable-xhdpi/action_find_next.png b/app/src/main/res/drawable-xhdpi/action_find_next.png deleted file mode 100644 index e822605379..0000000000 Binary files a/app/src/main/res/drawable-xhdpi/action_find_next.png and /dev/null differ diff --git a/app/src/main/res/drawable-xhdpi/action_find_previous.png b/app/src/main/res/drawable-xhdpi/action_find_previous.png deleted file mode 100644 index 0ba45876c6..0000000000 Binary files a/app/src/main/res/drawable-xhdpi/action_find_previous.png and /dev/null differ diff --git a/app/src/main/res/drawable-xhdpi/action_help.png b/app/src/main/res/drawable-xhdpi/action_help.png deleted file mode 100644 index 716d3566b1..0000000000 Binary files a/app/src/main/res/drawable-xhdpi/action_help.png and /dev/null differ diff --git a/app/src/main/res/drawable-xhdpi/action_home.png b/app/src/main/res/drawable-xhdpi/action_home.png deleted file mode 100644 index f7dc554c69..0000000000 Binary files a/app/src/main/res/drawable-xhdpi/action_home.png and /dev/null differ diff --git a/app/src/main/res/drawable-xhdpi/action_open_file.png b/app/src/main/res/drawable-xhdpi/action_open_file.png deleted file mode 100644 index 56aaae965d..0000000000 Binary files a/app/src/main/res/drawable-xhdpi/action_open_file.png and /dev/null differ diff --git a/app/src/main/res/drawable-xhdpi/action_randomarticle.png b/app/src/main/res/drawable-xhdpi/action_randomarticle.png deleted file mode 100644 index e5f2bfc066..0000000000 Binary files a/app/src/main/res/drawable-xhdpi/action_randomarticle.png and /dev/null differ diff --git a/app/src/main/res/drawable-xhdpi/action_search.png b/app/src/main/res/drawable-xhdpi/action_search.png deleted file mode 100644 index abbb989510..0000000000 Binary files a/app/src/main/res/drawable-xhdpi/action_search.png and /dev/null differ diff --git a/app/src/main/res/drawable-xhdpi/fullscreen.png b/app/src/main/res/drawable-xhdpi/fullscreen.png deleted file mode 100755 index 4423c7ce99..0000000000 Binary files a/app/src/main/res/drawable-xhdpi/fullscreen.png and /dev/null differ diff --git a/app/src/main/res/drawable-xhdpi/fullscreen_exit.png b/app/src/main/res/drawable-xhdpi/fullscreen_exit.png deleted file mode 100644 index 2221235dfa..0000000000 Binary files a/app/src/main/res/drawable-xhdpi/fullscreen_exit.png and /dev/null differ diff --git a/app/src/main/res/drawable-xhdpi/ic_mic_black_24dp.png b/app/src/main/res/drawable-xhdpi/ic_mic_black_24dp.png deleted file mode 100644 index cac51c37a3..0000000000 Binary files a/app/src/main/res/drawable-xhdpi/ic_mic_black_24dp.png and /dev/null differ diff --git a/app/src/main/res/drawable-xhdpi/ic_stars_black_24dp.png b/app/src/main/res/drawable-xhdpi/ic_stars_black_24dp.png deleted file mode 100644 index ee380e48ba..0000000000 Binary files a/app/src/main/res/drawable-xhdpi/ic_stars_black_24dp.png and /dev/null differ diff --git a/app/src/main/res/drawable-xhdpi/kiwix_notification.png b/app/src/main/res/drawable-xhdpi/kiwix_notification.png index 455f283eff..12a866f278 100644 Binary files a/app/src/main/res/drawable-xhdpi/kiwix_notification.png and b/app/src/main/res/drawable-xhdpi/kiwix_notification.png differ diff --git a/app/src/main/res/drawable-xhdpi/navigation_forward.png b/app/src/main/res/drawable-xhdpi/navigation_forward.png deleted file mode 100644 index 25316c6fe0..0000000000 Binary files a/app/src/main/res/drawable-xhdpi/navigation_forward.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi-v11/kiwix_notification.png b/app/src/main/res/drawable-xxhdpi-v11/kiwix_notification.png deleted file mode 100644 index 5b0ca908e8..0000000000 Binary files a/app/src/main/res/drawable-xxhdpi-v11/kiwix_notification.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi-v9/kiwix_notification.png b/app/src/main/res/drawable-xxhdpi-v9/kiwix_notification.png deleted file mode 100644 index d66de4e240..0000000000 Binary files a/app/src/main/res/drawable-xxhdpi-v9/kiwix_notification.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/action_bookmark.png b/app/src/main/res/drawable-xxhdpi/action_bookmark.png deleted file mode 100644 index 25ef8341aa..0000000000 Binary files a/app/src/main/res/drawable-xxhdpi/action_bookmark.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/action_bookmark_active.png b/app/src/main/res/drawable-xxhdpi/action_bookmark_active.png deleted file mode 100644 index 66dc3917a3..0000000000 Binary files a/app/src/main/res/drawable-xxhdpi/action_bookmark_active.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/action_home.png b/app/src/main/res/drawable-xxhdpi/action_home.png deleted file mode 100644 index 8a4d8470b6..0000000000 Binary files a/app/src/main/res/drawable-xxhdpi/action_home.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/action_open_file.png b/app/src/main/res/drawable-xxhdpi/action_open_file.png deleted file mode 100644 index a9d0597176..0000000000 Binary files a/app/src/main/res/drawable-xxhdpi/action_open_file.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/action_search.png b/app/src/main/res/drawable-xxhdpi/action_search.png deleted file mode 100644 index 20d80eedeb..0000000000 Binary files a/app/src/main/res/drawable-xxhdpi/action_search.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/fullscreen.png b/app/src/main/res/drawable-xxhdpi/fullscreen.png deleted file mode 100755 index 9b8131124d..0000000000 Binary files a/app/src/main/res/drawable-xxhdpi/fullscreen.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_mic_black_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_mic_black_24dp.png deleted file mode 100644 index ad8299e77f..0000000000 Binary files a/app/src/main/res/drawable-xxhdpi/ic_mic_black_24dp.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_stars_black_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_stars_black_24dp.png deleted file mode 100644 index 1777459930..0000000000 Binary files a/app/src/main/res/drawable-xxhdpi/ic_stars_black_24dp.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/kiwix_notification.png b/app/src/main/res/drawable-xxhdpi/kiwix_notification.png index ce2dedb47e..5b0ca908e8 100644 Binary files a/app/src/main/res/drawable-xxhdpi/kiwix_notification.png and b/app/src/main/res/drawable-xxhdpi/kiwix_notification.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/action_bookmark.png b/app/src/main/res/drawable-xxxhdpi/action_bookmark.png deleted file mode 100644 index 5a82e2e2cb..0000000000 Binary files a/app/src/main/res/drawable-xxxhdpi/action_bookmark.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxxhdpi/action_bookmark_active.png b/app/src/main/res/drawable-xxxhdpi/action_bookmark_active.png deleted file mode 100644 index 74b1c0bbcd..0000000000 Binary files a/app/src/main/res/drawable-xxxhdpi/action_bookmark_active.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxxhdpi/action_home.png b/app/src/main/res/drawable-xxxhdpi/action_home.png deleted file mode 100644 index 356814b9cd..0000000000 Binary files a/app/src/main/res/drawable-xxxhdpi/action_home.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxxhdpi/action_open_file.png b/app/src/main/res/drawable-xxxhdpi/action_open_file.png deleted file mode 100644 index c4933d39aa..0000000000 Binary files a/app/src/main/res/drawable-xxxhdpi/action_open_file.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxxhdpi/action_search.png b/app/src/main/res/drawable-xxxhdpi/action_search.png deleted file mode 100644 index 4cce1d96fc..0000000000 Binary files a/app/src/main/res/drawable-xxxhdpi/action_search.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxxhdpi/action_voice.png b/app/src/main/res/drawable-xxxhdpi/action_voice.png deleted file mode 100644 index 6768c9a862..0000000000 Binary files a/app/src/main/res/drawable-xxxhdpi/action_voice.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxxhdpi/fullscreen.png b/app/src/main/res/drawable-xxxhdpi/fullscreen.png deleted file mode 100755 index c1dcfb2902..0000000000 Binary files a/app/src/main/res/drawable-xxxhdpi/fullscreen.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxxhdpi/ic_mic_black_24dp.png b/app/src/main/res/drawable-xxxhdpi/ic_mic_black_24dp.png deleted file mode 100644 index cf70b63beb..0000000000 Binary files a/app/src/main/res/drawable-xxxhdpi/ic_mic_black_24dp.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxxhdpi/ic_stars_black_24dp.png b/app/src/main/res/drawable-xxxhdpi/ic_stars_black_24dp.png deleted file mode 100644 index 4746c16e86..0000000000 Binary files a/app/src/main/res/drawable-xxxhdpi/ic_stars_black_24dp.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxxhdpi/icon_question.png b/app/src/main/res/drawable-xxxhdpi/icon_question.png deleted file mode 100644 index 9555818ed8..0000000000 Binary files a/app/src/main/res/drawable-xxxhdpi/icon_question.png and /dev/null differ diff --git a/app/src/main/res/drawable/action_bookmark.xml b/app/src/main/res/drawable/action_bookmark.xml new file mode 100644 index 0000000000..1da8d9c3dd --- /dev/null +++ b/app/src/main/res/drawable/action_bookmark.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/action_bookmark_active.xml b/app/src/main/res/drawable/action_bookmark_active.xml new file mode 100644 index 0000000000..f66fb30011 --- /dev/null +++ b/app/src/main/res/drawable/action_bookmark_active.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/action_find_next.xml b/app/src/main/res/drawable/action_find_next.xml new file mode 100644 index 0000000000..07bcd9cbb5 --- /dev/null +++ b/app/src/main/res/drawable/action_find_next.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/action_find_previous.xml b/app/src/main/res/drawable/action_find_previous.xml new file mode 100644 index 0000000000..c3e00aff5f --- /dev/null +++ b/app/src/main/res/drawable/action_find_previous.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/action_home.xml b/app/src/main/res/drawable/action_home.xml new file mode 100644 index 0000000000..121f87909e --- /dev/null +++ b/app/src/main/res/drawable/action_home.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/action_open_file.xml b/app/src/main/res/drawable/action_open_file.xml new file mode 100644 index 0000000000..36c8dcc0d8 --- /dev/null +++ b/app/src/main/res/drawable/action_open_file.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/action_randomarticle.xml b/app/src/main/res/drawable/action_randomarticle.xml new file mode 100644 index 0000000000..a3c88521d8 --- /dev/null +++ b/app/src/main/res/drawable/action_randomarticle.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/action_search.xml b/app/src/main/res/drawable/action_search.xml new file mode 100644 index 0000000000..4b749bd45c --- /dev/null +++ b/app/src/main/res/drawable/action_search.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/action_voice.xml b/app/src/main/res/drawable/action_voice.xml new file mode 100644 index 0000000000..35e25196de --- /dev/null +++ b/app/src/main/res/drawable/action_voice.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/drawable/fullscreen.png b/app/src/main/res/drawable/fullscreen.png deleted file mode 100755 index c1dcfb2902..0000000000 Binary files a/app/src/main/res/drawable/fullscreen.png and /dev/null differ diff --git a/app/src/main/res/drawable/fullscreen.xml b/app/src/main/res/drawable/fullscreen.xml new file mode 100644 index 0000000000..2dbc5502c7 --- /dev/null +++ b/app/src/main/res/drawable/fullscreen.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/fullscreen_exit.xml b/app/src/main/res/drawable/fullscreen_exit.xml new file mode 100644 index 0000000000..8592e853ab --- /dev/null +++ b/app/src/main/res/drawable/fullscreen_exit.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_mic_black_24dp.xml b/app/src/main/res/drawable/ic_mic_black_24dp.xml new file mode 100644 index 0000000000..609bae313a --- /dev/null +++ b/app/src/main/res/drawable/ic_mic_black_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_stars_black_24dp.xml b/app/src/main/res/drawable/ic_stars_black_24dp.xml new file mode 100644 index 0000000000..2c1d574921 --- /dev/null +++ b/app/src/main/res/drawable/ic_stars_black_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_warning_black.xml b/app/src/main/res/drawable/ic_warning_black.xml new file mode 100644 index 0000000000..d95b1af6fc --- /dev/null +++ b/app/src/main/res/drawable/ic_warning_black.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_warning_white.xml b/app/src/main/res/drawable/ic_warning_white.xml new file mode 100644 index 0000000000..15392f5e35 --- /dev/null +++ b/app/src/main/res/drawable/ic_warning_white.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/icon_question.xml b/app/src/main/res/drawable/icon_question.xml new file mode 100644 index 0000000000..44565beccd --- /dev/null +++ b/app/src/main/res/drawable/icon_question.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/layout/activity_bookmarks.xml b/app/src/main/res/layout/activity_bookmarks.xml index 4595e59cdd..310dd31dce 100644 --- a/app/src/main/res/layout/activity_bookmarks.xml +++ b/app/src/main/res/layout/activity_bookmarks.xml @@ -49,8 +49,8 @@ android:visibility="gone"> diff --git a/app/src/main/res/layout/bookmark_tab.xml b/app/src/main/res/layout/bookmark_tab.xml index e409281bbd..03ee9a2aa2 100644 --- a/app/src/main/res/layout/bookmark_tab.xml +++ b/app/src/main/res/layout/bookmark_tab.xml @@ -1,13 +1,14 @@ + android:layout_height="wrap_content" + xmlns:app="http://schemas.android.com/apk/res-auto"> \ No newline at end of file diff --git a/app/src/main/res/layout/bookmarks_row.xml b/app/src/main/res/layout/bookmarks_row.xml index b068869912..366c8c9569 100644 --- a/app/src/main/res/layout/bookmarks_row.xml +++ b/app/src/main/res/layout/bookmarks_row.xml @@ -14,7 +14,7 @@ android:id="@+id/bookmark_title" android:layout_width="fill_parent" android:layout_height="fill_parent" - android:layout_margin="@dimen/dimen_15dp" + android:layout_margin="@dimen/bookmark_title_margin" android:textColor="@drawable/bookmarks_selector" android:textSize="@dimen/bookmark_title_text_size" /> diff --git a/app/src/main/res/layout/download_item.xml b/app/src/main/res/layout/download_item.xml index 3d29a952d4..f7a433f6ca 100644 --- a/app/src/main/res/layout/download_item.xml +++ b/app/src/main/res/layout/download_item.xml @@ -11,17 +11,17 @@ + android:padding="@dimen/download_progress_padding" /> @@ -89,11 +89,11 @@ android:layout_alignParentEnd="true" android:layout_alignParentRight="true" android:layout_gravity="center_vertical" - android:layout_marginLeft="@dimen/dimen_medium_padding" - android:layout_marginRight="@dimen/dimen_medium_padding" + android:layout_marginLeft="@dimen/stop_horizontal_margin" + android:layout_marginRight="@dimen/stop_horizontal_margin" android:layout_weight="0.5" - android:minHeight="@dimen/dimen_35dp" - android:minWidth="@dimen/dimen_35dp" + android:minHeight="@dimen/stop_min_height" + android:minWidth="@dimen/stop_min_width" android:src="@drawable/ic_stop_black_24dp" android:text="@string/download_stop" /> diff --git a/app/src/main/res/layout/download_management.xml b/app/src/main/res/layout/download_management.xml index f3140d9f8b..de0f667c9d 100644 --- a/app/src/main/res/layout/download_management.xml +++ b/app/src/main/res/layout/download_management.xml @@ -15,7 +15,7 @@ android:orientation="vertical" android:paddingBottom="@dimen/download_management_no_downloads_padding_bottom" android:text="@string/no_downloads_here" - android:textSize="@dimen/dimen_20sp" + android:textSize="@dimen/download_management_no_downloads_text_size" android:visibility="gone" /> + android:src="?attr/plusDrawable" /> @@ -43,35 +43,42 @@ - -