Merge branch 'develop' into feature/abdul/1557

This commit is contained in:
Abdul Wadood 2019-12-03 22:58:11 +05:30
commit be043ba1ac
340 changed files with 3106 additions and 4569 deletions

View File

@ -1,5 +1,14 @@
Fixes #[Add issue number here. If you do not solve the issue entirely, please change the message e.g. "First steps for issues #IssueNumber]
<!--
- Add the issue number here.
Changes: [Add here what changes were made in this issue and if possible provide links.]
- If you haven't solved the issue completely use "Linked issue #{issue_number}.
- After solving the issue completely change it to "Fixes #{issue_number}.
-->
Fixes #
Screenshots/GIF for the change: [If possible, please add relevant screenshots/GIF]
<!-- Add here what changes were made in this issue and if possible provide links. -->
<!-- If possible, please add relevant screenshots / GIFs -->
**Screenshots**

View File

@ -10,6 +10,9 @@
</value>
</option>
<option name="LINE_SEPARATOR" value="&#10;" />
<AndroidXmlCodeStyleSettings>
<option name="ARRANGEMENT_SETTINGS_MIGRATED_TO_191" value="true" />
</AndroidXmlCodeStyleSettings>
<GroovyCodeStyleSettings>
<option name="ALIGN_MULTILINE_LIST_OR_MAP" value="false" />
<option name="ALIGN_NAMED_ARGS_IN_MAP" value="false" />
@ -328,4 +331,4 @@
</indentOptions>
</codeStyleSettings>
</code_scheme>
</component>
</component>

View File

@ -11,6 +11,7 @@
<inspection_tool class="AndroidLintAnimatorKeep" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="AndroidLintAppCompatMethod" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="AndroidLintAppIndexingService" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="AndroidLintAppLinkUrlError" enabled="false" level="ERROR" enabled_by_default="false" />
<inspection_tool class="AndroidLintAppLinksAutoVerifyError" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="AndroidLintAppLinksAutoVerifyWarning" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="AndroidLintApplySharedPref" enabled="true" level="ERROR" enabled_by_default="true" />
@ -24,12 +25,11 @@
<inspection_tool class="AndroidLintButtonOrder" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="AndroidLintButtonStyle" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="AndroidLintCanvasSize" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="AndroidLintCheckResult" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
<inspection_tool class="AndroidLintCheckResult" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
<inspection_tool class="AndroidLintClickableViewAccessibility" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="AndroidLintCommitPrefEdits" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="AndroidLintCommitTransaction" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="AndroidLintConstantLocale" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="AndroidLintContentDescription" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="AndroidLintConvertToWebp" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="AndroidLintCustomViewStyleable" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="AndroidLintCutPasteId" enabled="true" level="ERROR" enabled_by_default="true" />
@ -42,7 +42,7 @@
<inspection_tool class="AndroidLintDrawAllocation" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="AndroidLintDuplicateDivider" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="AndroidLintDuplicateIncludedIds" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="AndroidLintDuplicateStrings" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
<inspection_tool class="AndroidLintDuplicateStrings" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
<inspection_tool class="AndroidLintDuplicateUsesFeature" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="AndroidLintEasterEgg" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="AndroidLintEnqueueWork" enabled="true" level="ERROR" enabled_by_default="true" />
@ -57,8 +57,8 @@
<inspection_tool class="AndroidLintFontValidationWarning" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="AndroidLintGetInstance" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="AndroidLintGifUsage" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="AndroidLintGoogleAppIndexingApiWarning" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="AndroidLintGoogleAppIndexingWarning" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="AndroidLintGoogleAppIndexingApiWarning" enabled="false" level="ERROR" enabled_by_default="false" />
<inspection_tool class="AndroidLintGoogleAppIndexingWarning" enabled="false" level="ERROR" enabled_by_default="false" />
<inspection_tool class="AndroidLintGradleDependency" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="AndroidLintGradleDeprecated" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="AndroidLintGradleDynamicVersion" enabled="true" level="ERROR" enabled_by_default="true" />
@ -69,7 +69,6 @@
<inspection_tool class="AndroidLintHardcodedText" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="AndroidLintHardwareIds" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="AndroidLintIconColors" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="AndroidLintIconDipSize" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="AndroidLintIconDuplicates" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="AndroidLintIconDuplicatesConfig" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="AndroidLintIconExpectedSize" enabled="true" level="ERROR" enabled_by_default="true" />
@ -98,11 +97,11 @@
<inspection_tool class="AndroidLintJobSchedulerService" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="AndroidLintKeyboardInaccessibleWidget" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="AndroidLintKotlinPropertyAccess" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="AndroidLintLabelFor" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
<inspection_tool class="AndroidLintLabelFor" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
<inspection_tool class="AndroidLintLambdaLast" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="AndroidLintLintBaseline" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="AndroidLintLocaleFolder" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="AndroidLintLogConditional" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
<inspection_tool class="AndroidLintLogConditional" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
<inspection_tool class="AndroidLintMangledCRLF" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="AndroidLintManifestOrder" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="AndroidLintMergeRootFrame" enabled="true" level="ERROR" enabled_by_default="true" />
@ -112,7 +111,7 @@
<inspection_tool class="AndroidLintMissingBackupPin" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="AndroidLintMissingFirebaseInstanceTokenRefresh" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="AndroidLintMissingId" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="AndroidLintMissingTranslation" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
<inspection_tool class="AndroidLintMissingTranslation" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
<inspection_tool class="AndroidLintMissingVersion" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="AndroidLintNegativeMargin" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="AndroidLintNestedScrolling" enabled="true" level="ERROR" enabled_by_default="true" />

View File

@ -15,10 +15,6 @@ env:
if: type != push OR tag IS present
before_install:
- openssl aes-256-cbc -K $encrypted_82adfa9c3806_key -iv $encrypted_82adfa9c3806_iv -in secrets.tar.enc -out secrets.tar -d
- tar xvf secrets.tar
install:
- pip install --user 'requests[security]'
- wget -r -nH -nd -np -R index.html* robots.txt* http://download.kiwix.org/dev/android/api/licenses/ -e robots=off -P $ANDROID_HOME/licenses || true
@ -52,10 +48,13 @@ before_script:
- adb shell input keyevent 82 &
script:
- ./gradlew jacocoInstrumentationTestReport ktlintCheck lint jacocoTestReport app:assembleRelease
- ./gradlew jacocoInstrumentationTestReport ktlintCheck app:lintDebug core:lintDebug custom:lintCustomexampleDebug jacocoTestDebugUnitTestReport jacocoTestCustomExampleDebugUnitTestReport app:assembleDebug
after_success:
- bash <(curl -s https://codecov.io/bash)
- openssl aes-256-cbc -K $encrypted_82adfa9c3806_key -iv $encrypted_82adfa9c3806_iv -in secrets.tar.enc -out secrets.tar -d
- tar xvf secrets.tar
- ./gradlew app:assembleRelease
before_deploy:
# - export APP_CHANGELOG=$(cat app/src/kiwix/play/release-notes/en-US/default.txt)
@ -83,7 +82,7 @@ deploy:
#publish on play store
- provider: script
skip_cleanup: true
script: ./gradlew publishRelease
script: ./gradlew publishReleaseApk
on:
tags: true

View File

@ -48,7 +48,7 @@ Our branching strategy is based on [this article](https://nvie.com/posts/a-succe
+ **develop** the actively worked on next release of the app, what we branch off of while working on new features and what we merge into upon feature completion
+ **feature/** or feature/\<username\>/ any branch under this directory is an actively developed feature, feature branches culminate in a PR, are merged and deleted.
Typically a feature branch is off of develop and into develop but in rare scenarios if there is an issue in production a branch may be made off master to fix this issue, this type of feature branch must be merged to develop and master before being deleted.
Branch names should be in the format **#\<issue-number\>-kebab-case-title**
Branch names should be in the format **\<issue-number\>-kebab-case-title**
All branches should have distinct history and should be visually easy to follow, for this reason only perform merge commits when merging code either by PR or when synchronising.

View File

@ -16,7 +16,7 @@ with additional meta-data. This is the version for Android.
Kiwix Android is written in [Kotlin](https://kotlinlang.org/) (with a few old
pieces in Java).
[![Build Status](https://travis-ci.org/kiwix/kiwix-android.svg?branch=develop)](https://travis-ci.org/kiwix/kiwix-android)
[![Build Status](https://travis-ci.com/kiwix/kiwix-android.svg?branch=develop)](https://travis-ci.com/kiwix/kiwix-android)
[![codecov](https://codecov.io/gh/kiwix/kiwix-android/branch/develop/graph/badge.svg)](https://codecov.io/gh/kiwix/kiwix-android)
[![CodeFactor](https://www.codefactor.io/repository/github/kiwix/kiwix-android/badge)](https://www.codefactor.io/repository/github/kiwix/kiwix-android)
[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
@ -33,6 +33,8 @@ set up the Android SDK and then run the command: `./gradlew build `
from the root directory of the project.
Kiwix-Android is a multi-module project, in 99% of scenarios you will want to build the `app` module in the `debug` configuration.
If you are interested in our custom apps they have their own repo [kiwix-android-custom](https://github.com/kiwix/kiwix-android-custom
) that goes into further detail
## Libraries Used
@ -74,7 +76,7 @@ guidelines. Pull requests not matching the style will be rejected.
Available communication channels:
* [Web Public Chat channel](https://chat.kiwix.org)
* [Email](mailto:contact+android@kiwix.org)
* [Mailing list](kiwix-developer@lists.sourceforge.net)
* [Mailing list](mailto:kiwix-developer@lists.sourceforge.net)
* [Slack](https://kiwixoffline.slack.com): #android channel
* IRC: #kiwix on irc.freenode.net

View File

@ -1,9 +1,8 @@
import com.android.build.OutputFile
import plugin.KiwixConfigurationPlugin
plugins {
id("com.android.application")
id("com.github.triplet.play") version("2.4.1")
id("com.github.triplet.play") version("2.5.0")
}
apply plugin: KiwixConfigurationPlugin
@ -50,51 +49,17 @@ android {
versionName generateVersionName()
}
signingConfigs {
release {
storeFile file("../kiwix-android.keystore")
storePassword System.getenv("KEY_STORE_PASSWORD") ?: "000000"
keyAlias System.getenv("KEY_ALIAS") ?: "keystore"
keyPassword System.getenv("KEY_PASSWORD") ?: "000000"
}
}
buildTypes {
debug {
multiDexKeepProguard file("multidex-instrumentation-config.pro")
buildConfigField "boolean", "KIWIX_ERROR_ACTIVITY", "false"
}
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
buildConfigField "boolean", "KIWIX_ERROR_ACTIVITY", "true"
}
}
def abiCodes = ['arm64-v8a': 6, 'x86': 3, 'x86_64': 4, 'armeabi-v7a': 5]
def densityCodes = ['mdpi': 2, 'hdpi': 3, 'xhdpi': 4, 'xxhdpi': 5, 'xxxhdpi': 6]
splits {
density {
enable false
reset()
include "mdpi", "hdpi", "xhdpi", "xxhdpi", "xxxhdpi"
}
}
applicationVariants.all { variant ->
variant.outputs.each { output ->
def baseAbiVersionCode = abiCodes.get(output.getFilter(OutputFile.ABI)) ?: 0
def baseDensityVersionCode = densityCodes.get(output.getFilter(OutputFile.DENSITY)) ?: 0
output.versionCodeOverride =
(baseDensityVersionCode * 10000000) +
(baseAbiVersionCode * 1000000) +
variant.versionCode
}
}
sourceSets {
androidTest {
java.srcDirs += "$rootDir/core/src/sharedTestFunctions/java"
@ -113,5 +78,6 @@ play {
dependencies {
implementation(Libs.squidb)
implementation(Libs.squidb_annotations)
implementation(Libs.ink_page_indicator)
kapt(Libs.squidb_processor)
}

View File

@ -85,94 +85,6 @@
column="3"/>
</issue>
<issue
id="SyntheticAccessor"
message="Access to `private` field `requestCheckSystemFileType` of class `Fat32Checker` requires synthetic accessor"
errorLine1=" requestCheckSystemFileType.onNext(Unit)"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src\main\java\org\kiwix\kiwixmobile\zim_manager\Fat32Checker.kt"
line="66"
column="9"/>
</issue>
<issue
id="SyntheticAccessor"
message="Access to `private` method `deleteIfExists` of class `Fat32CheckerKt` requires synthetic accessor"
errorLine1=" File(path).deleteIfExists()"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src\main\java\org\kiwix\kiwixmobile\zim_manager\Fat32Checker.kt"
line="81"
column="5"/>
</issue>
<issue
id="SyntheticAccessor"
message="Access to `private` method `deleteIfExists` of class `Fat32CheckerKt` requires synthetic accessor"
errorLine1=" File(path).deleteIfExists()"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src\main\java\org\kiwix\kiwixmobile\zim_manager\Fat32Checker.kt"
line="92"
column="7"/>
</issue>
<issue
id="SyntheticAccessor"
message="Access to `private` field `activity` of class `WifiDirectManager` requires synthetic accessor"
errorLine1=" Log.d(TAG, activity.getString(R.string.discovery_failed) + &quot;: &quot; + errorMessage);"
errorLine2=" ~~~~~~~~">
<location
file="src\main\java\org\kiwix\kiwixmobile\local_file_transfer\WifiDirectManager.java"
line="146"
column="20"/>
</issue>
<issue
id="SyntheticAccessor"
message="Access to `private` field `hasSenderStartedConnection` of class `WifiDirectManager` requires synthetic accessor"
errorLine1=" hasSenderStartedConnection = true;"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src\main\java\org\kiwix\kiwixmobile\local_file_transfer\WifiDirectManager.java"
line="247"
column="11"/>
</issue>
<issue
id="SyntheticAccessor"
message="Access to `private` field `activity` of class `WifiDirectManager` requires synthetic accessor"
errorLine1=" Log.d(TAG, activity.getString(R.string.connection_failed) + &quot;: &quot; + errorMessage);"
errorLine2=" ~~~~~~~~">
<location
file="src\main\java\org\kiwix\kiwixmobile\local_file_transfer\WifiDirectManager.java"
line="273"
column="20"/>
</issue>
<issue
id="SyntheticAccessor"
message="Access to `private` method `closeChannel` of class `WifiDirectManager` requires synthetic accessor"
errorLine1=" closeChannel();"
errorLine2=" ~~~~~~~~~~~~">
<location
file="src\main\java\org\kiwix\kiwixmobile\local_file_transfer\WifiDirectManager.java"
line="395"
column="9"/>
</issue>
<issue
id="SyntheticAccessor"
message="Access to `private` method `closeChannel` of class `WifiDirectManager` requires synthetic accessor"
errorLine1=" closeChannel();"
errorLine2=" ~~~~~~~~~~~~">
<location
file="src\main\java\org\kiwix\kiwixmobile\local_file_transfer\WifiDirectManager.java"
line="401"
column="9"/>
</issue>
<issue
id="SelectableText"
message="Consider making the text value selectable by specifying `android:textIsSelectable=&quot;true&quot;`"
@ -290,18 +202,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~">
<location
file="src\main\java\org\kiwix\kiwixmobile\main\KiwixMainActivity.kt"
line="44"
column="7"/>
</issue>
<issue
id="GoogleAppIndexingApiWarning"
message="Missing support for Firebase App Indexing API"
errorLine1="class ZimManageActivity : BaseActivity() {"
errorLine2=" ~~~~~~~~~~~~~~~~~">
<location
file="src\main\java\org\kiwix\kiwixmobile\zim_manager\ZimManageActivity.kt"
line="48"
line="49"
column="7"/>
</issue>
@ -407,32 +308,10 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src\main\java\org\kiwix\kiwixmobile\KiwixViewModelFactory.java"
line="33"
line="32"
column="32"/>
</issue>
<issue
id="UnknownNullness"
message="Unknown nullability; explicitly declare as `@Nullable` or `@NonNull` to improve Kotlin interoperability; see https://android.github.io/kotlin-guides/interop.html#nullability-annotations"
errorLine1=" public &lt;T extends ViewModel> T create(Class&lt;T> modelClass) {"
errorLine2=" ~">
<location
file="src\main\java\org\kiwix\kiwixmobile\KiwixViewModelFactory.java"
line="39"
column="32"/>
</issue>
<issue
id="UnknownNullness"
message="Unknown nullability; explicitly declare as `@Nullable` or `@NonNull` to improve Kotlin interoperability; see https://android.github.io/kotlin-guides/interop.html#nullability-annotations"
errorLine1=" public &lt;T extends ViewModel> T create(Class&lt;T> modelClass) {"
errorLine2=" ~~~~~~~~">
<location
file="src\main\java\org\kiwix\kiwixmobile\KiwixViewModelFactory.java"
line="39"
column="41"/>
</issue>
<issue
id="UnknownNullness"
message="Unknown nullability; explicitly declare as `@Nullable` or `@NonNull` to improve Kotlin interoperability; see https://android.github.io/kotlin-guides/interop.html#nullability-annotations"

View File

@ -38,9 +38,6 @@ class HelpActivityTest : BaseActivityTest<HelpActivity>() {
clickOnWhereIsContent()
assertWhereIsContentIsExpanded()
clickOnWhereIsContent()
clickOnLargeZimFiles()
assertLargeZimsIsExpanded()
clickOnLargeZimFiles()
clickOnSendFeedback()
}
}

View File

@ -66,26 +66,6 @@ class HelpRobot : BaseRobot() {
)
}
fun clickOnLargeZimFiles() {
clickOn(TextId(string.help_12))
}
fun assertLargeZimsIsExpanded() {
isVisible(
Text(
helpTextFormat(
string.help_13,
string.help_14,
string.help_15,
string.help_16,
string.help_17,
string.help_18,
string.help_19
)
)
)
}
fun clickOnSendFeedback() {
clickOn(ViewId(id.activity_help_feedback_text_view))
}

View File

@ -21,7 +21,6 @@ import android.os.Build
import androidx.test.filters.SdkSuppress
import org.junit.Test
import org.kiwix.kiwixmobile.BaseActivityTest
import org.kiwix.kiwixmobile.core.intro.IntroActivity
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.JELLY_BEAN_MR2)
class IntroActivityTest : BaseActivityTest<IntroActivity>() {

View File

@ -21,7 +21,7 @@ package org.kiwix.kiwixmobile.intro
import org.kiwix.kiwixmobile.BaseRobot
import org.kiwix.kiwixmobile.Findable.StringId.TextId
import org.kiwix.kiwixmobile.Findable.ViewId
import org.kiwix.kiwixmobile.core.R
import org.kiwix.kiwixmobile.R
import org.kiwix.kiwixmobile.main.MainRobot
import org.kiwix.kiwixmobile.main.main

View File

@ -34,13 +34,11 @@ import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.kiwix.kiwixmobile.core.intro.IntroActivity;
import org.kiwix.kiwixmobile.core.main.CoreMainActivity;
import org.kiwix.kiwixmobile.core.splash.SplashActivity;
import org.kiwix.kiwixmobile.intro.IntroActivity;
import org.kiwix.kiwixmobile.main.KiwixMainActivity;
import static androidx.test.InstrumentationRegistry.getInstrumentation;
import static androidx.test.espresso.intent.Intents.intended;
import static androidx.test.espresso.intent.matcher.IntentMatchers.hasAction;
import static androidx.test.espresso.intent.matcher.IntentMatchers.hasComponent;
import static org.junit.Assert.assertEquals;
import static org.kiwix.kiwixmobile.core.utils.SharedPreferenceUtil.PREF_SHOW_INTRO;
@ -48,10 +46,10 @@ import static org.kiwix.kiwixmobile.testutils.TestUtils.TEST_PAUSE_MS;
@LargeTest
@RunWith(AndroidJUnit4.class)
public class SplashActivityTest {
public class KiwixSplashActivityTest {
private ActivityTestRule<SplashActivity> activityTestRule =
new ActivityTestRule<>(SplashActivity.class, true, false);
private ActivityTestRule<KiwixSplashActivity> activityTestRule =
new ActivityTestRule<>(KiwixSplashActivity.class, true, false);
@Rule
public GrantPermissionRule readPermissionRule =
GrantPermissionRule.grant(Manifest.permission.READ_EXTERNAL_STORAGE);
@ -72,7 +70,6 @@ public class SplashActivityTest {
activityTestRule.launchActivity(new Intent());
BaristaSleepInteractions.sleep(TEST_PAUSE_MS);
// Verify that the SplashActivity is followed by IntroActivity
intended(hasComponent(IntroActivity.class.getName()));
// Verify that the value of the "intro shown" boolean inside the SharedPreferences Database is not changed until the "Get started" button is pressed
@ -87,8 +84,7 @@ public class SplashActivityTest {
activityTestRule.launchActivity(new Intent());
BaristaSleepInteractions.sleep(TEST_PAUSE_MS);
// Verify that the SplashActivity is followed by CoreMainActivity
intended(hasAction(CoreMainActivity.class.getCanonicalName()));
intended(hasComponent(KiwixMainActivity.class.getCanonicalName()));
}
@After

View File

@ -1 +0,0 @@
contact+android@kiwix.org

View File

@ -1 +0,0 @@
http://www.kiwix.org

View File

@ -1 +0,0 @@
en-US

View File

@ -1,9 +0,0 @@
Die ganze Wikipedia auf deinem Mobilgerät!
Kiwix ist eine Programm, daß das Lesen der Wikipedia und anderer Inhalte (Ubuntu Dokumentation, WikiLeaks, WikiVoyage, WikiSource, etc) ohne Internetverbindung erlaubt.
Sobald du die Inhaltsdateien heruntergeladen hast, die sehr groß sein können, benötigst du keine Internetverbindung um sie zu verwenden.
Siehe die Hilfe in der App und unsere Webseite für Informationen über verfügbare Inhalte.
Anmerkung: Kiwix existiert auch für PCs (Windows, Mac, Linux) verfügbar..

View File

@ -1 +0,0 @@
Die Wikipedia immer dabei; ohne Internetverbindung!

View File

@ -1 +0,0 @@
Kiwix, Wikipedia offline

View File

@ -1,7 +0,0 @@
The whole of Wikipedia on your device!
The app is a lightweight piece of software reading bigger files stored on your device or SD card: once it is installed, you can select which additional content you would like to download (Wikipedia, Wiktionary, TED talks, etc.) and be ready for when your internet connexion is bad (or need to be in airplane mode)!
Please read the instructions inside the App or on the website (www.kiwix.org) to learn about the various contents that are available for download.
Note: Kiwix is also available on regular computers (Windows, Mac, Linux).

Binary file not shown.

Before

Width:  |  Height:  |  Size: 253 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 522 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 491 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 212 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 185 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 491 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 145 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 323 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 491 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 522 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 68 KiB

View File

@ -1 +0,0 @@
Wikipedia (and a lot more) at hand everywhere. No internet required!

View File

@ -1 +0,0 @@
Kiwix, Wikipedia offline

View File

@ -1,11 +0,0 @@
Tout Wikipédia dans votre mobile !
Kiwix est un lecteur de contenus hors-ligne qui peut être utilisé pour Wikipédia ainsi que d'autres contenus (Documentation Ubuntu, WikiLeaks, WikiVoyage, WikiSource, etc).
Une fois que vous avez téléchargé le fichier de contenu (potentiellement très gros), vous n'avez plus du tout besoin de connexion pour l'utiliser.
Kiwix est une application légère utilisant des fichiers ZIM que vous aurez préalablement téléchargé et stocké sur la mémoire externe (carte SD).
Merci de consulter les instructions d'utilisations dans l'application ainsi que sur le site web pour en savoir plus sur les contenus disponibles.
Note: Kiwix est aussi disponible sur ordinateur (Windows, Mac, Linux).

View File

@ -1 +0,0 @@
Emportez la Wikipédia partout avec vous ; sans connexion !

View File

@ -1 +0,0 @@
Kiwix, Wikipédia sans Internet

View File

@ -1,11 +0,0 @@
L'intera Wikipedia sempre con te!
Kiwix è un lettore non in linea di contenuti e siti di ogni genere, Wikipedia ma non solo (documentazione di Ubuntu, WikiLeaks, Wikisource, Wikivoyage ecc.).
Una volta scaricato l'archivio ZIM contenente il tutto (potenzialmente molto grande), non serve alcuna connessione a internet per navigarlo.
Kiwix è leggero e gli archivi ZIM si possono scaricare e conservare nel tuo apparecchio android o memoria esterna (scheda SD).
Controlla le istruzioni nell'applicazione e nel sito per sapere di più sui contenuti disponibili.
Nota, Kiwix è disponibile anche per computer normali (Windows, Mac e Linux).

View File

@ -1 +0,0 @@
Wikipedia sempre con te!

View File

@ -1 +0,0 @@
Kiwix

View File

@ -1,5 +0,0 @@
Vikipedi'nin tamamı cihazınızda!
Uygulama, cihazınızda veya SD kartta depolanan büyük dosyalar okuyan hafif bir yazılım parçasıdır: yükledikten sonra, hangi ek içerikler indirmek istediğinizi seçebilirsiniz (Vikipedi, Vikisözlük, TED Konferansları, v.b.) ve ne zaman internet bağlantınız kötü olsa, hazır olabilirsiniz (veya uçak modunda olmanız gerekiyorsa) !
Indirmek için hazır olan çeşitli içerikler hakkında bilgi edinmek için, lütfen uygulama içindeki veya web sitemizindeki talimatları okuyun (www.kiwix.org)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 379 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 809 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 278 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 502 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 121 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 670 KiB

View File

@ -1 +0,0 @@
Kiwix ile, Vikipedi tamamıyla telefonunuza veya tabletinize indirin

View File

@ -1 +0,0 @@
Kiwix - offline Vikipedi

View File

@ -1,4 +0,0 @@
BUGFIX: Some users language was causing a crash due to unstable ISO codes
BUGFIX: Some unstable zim files were crashing when opened
BUGFIX: Long titles were rendering off screen on home page
BUGFIX: Issues when opening a file externally

View File

@ -2,7 +2,29 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.kiwix.kiwixmobile">
<application android:name=".KiwixApp">
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<application
android:name=".KiwixApp"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round">
<activity
android:name=".splash.KiwixSplashActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.Launcher">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.MONKEY" />
</intent-filter>
<meta-data
android:name="android.app.shortcuts"
android:resource="@xml/shortcuts" />
</activity>
<activity android:name=".intro.IntroActivity" />
<activity
android:name=".main.KiwixMainActivity"
android:configChanges="orientation|keyboardHidden|screenSize|locale"
@ -140,5 +162,8 @@
<data android:host="*" />
</intent-filter>
</activity>
<activity android:name=".webserver.ZimHostActivity" />
<service android:name=".webserver.wifi_hotspot.HotspotService" />
</application>
</manifest>

View File

@ -19,40 +19,17 @@
package org.kiwix.kiwixmobile;
import androidx.lifecycle.ViewModel;
import androidx.lifecycle.ViewModelProvider;
import java.util.Map;
import javax.inject.Inject;
import javax.inject.Provider;
import org.kiwix.kiwixmobile.core.ViewModelFactory;
import org.kiwix.kiwixmobile.di.KiwixScope;
@KiwixScope
public class KiwixViewModelFactory implements ViewModelProvider.Factory {
private final Map<Class<? extends ViewModel>, Provider<ViewModel>> creators;
public class KiwixViewModelFactory extends ViewModelFactory {
@Inject
public KiwixViewModelFactory(Map<Class<? extends ViewModel>, Provider<ViewModel>> creators) {
this.creators = creators;
}
@SuppressWarnings("unchecked")
@Override
public <T extends ViewModel> T create(Class<T> modelClass) {
Provider<? extends ViewModel> creator = creators.get(modelClass);
if (creator == null) {
for (Map.Entry<Class<? extends ViewModel>, Provider<ViewModel>> entry : creators.entrySet()) {
if (modelClass.isAssignableFrom(entry.getKey())) {
creator = entry.getValue();
break;
}
}
}
if (creator == null) {
throw new IllegalArgumentException("unknown model class " + modelClass);
}
try {
return (T) creator.get();
} catch (Exception e) {
throw new RuntimeException(e);
}
super(creators);
}
}

View File

@ -15,7 +15,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package org.kiwix.kiwixmobile.core.di
package org.kiwix.kiwixmobile.di
import javax.inject.Scope
import kotlin.annotation.AnnotationRetention.RUNTIME

View File

@ -22,10 +22,15 @@ import dagger.BindsInstance
import dagger.Subcomponent
import org.kiwix.kiwixmobile.core.di.ActivityScope
import org.kiwix.kiwixmobile.di.modules.KiwixActivityModule
import org.kiwix.kiwixmobile.intro.IntroActivity
import org.kiwix.kiwixmobile.intro.IntroModule
import org.kiwix.kiwixmobile.language.LanguageActivity
import org.kiwix.kiwixmobile.local_file_transfer.LocalFileTransferActivity
import org.kiwix.kiwixmobile.main.KiwixMainActivity
import org.kiwix.kiwixmobile.settings.KiwixSettingsActivity
import org.kiwix.kiwixmobile.splash.KiwixSplashActivity
import org.kiwix.kiwixmobile.webserver.ZimHostActivity
import org.kiwix.kiwixmobile.webserver.ZimHostModule
import org.kiwix.kiwixmobile.zim_manager.ZimManageActivity
import org.kiwix.kiwixmobile.zim_manager.download_view.DownloadFragment
import org.kiwix.kiwixmobile.zim_manager.fileselect_view.ZimFileSelectFragment
@ -33,7 +38,13 @@ import org.kiwix.kiwixmobile.zim_manager.fileselect_view.effects.DeleteFiles
import org.kiwix.kiwixmobile.zim_manager.library_view.LibraryFragment
@ActivityScope
@Subcomponent(modules = [KiwixActivityModule::class])
@Subcomponent(
modules = [
KiwixActivityModule::class,
ZimHostModule::class,
IntroModule::class
]
)
interface KiwixActivityComponent {
fun inject(downloadFragment: DownloadFragment)
fun inject(libraryFragment: LibraryFragment)
@ -44,6 +55,9 @@ interface KiwixActivityComponent {
fun inject(languageActivity: LanguageActivity)
fun inject(kiwixMainActivity: KiwixMainActivity)
fun inject(kiwixSettingsActivity: KiwixSettingsActivity)
fun inject(zimHostActivity: ZimHostActivity)
fun inject(introActivity: IntroActivity)
fun inject(kiwixSplashActivity: KiwixSplashActivity)
@Subcomponent.Builder
interface Builder {

View File

@ -19,9 +19,10 @@
package org.kiwix.kiwixmobile.di.components
import dagger.Component
import org.kiwix.kiwixmobile.core.di.components.CoreComponent
import org.kiwix.kiwixmobile.di.modules.KiwixModule
import org.kiwix.kiwixmobile.di.KiwixScope
import org.kiwix.kiwixmobile.core.di.components.CoreComponent
import org.kiwix.kiwixmobile.di.components.ServiceComponent.Builder
import org.kiwix.kiwixmobile.di.modules.KiwixModule
import org.kiwix.kiwixmobile.di.modules.ViewModelModule
@KiwixScope
@ -31,4 +32,5 @@ import org.kiwix.kiwixmobile.di.modules.ViewModelModule
)
interface KiwixComponent {
fun activityComponentBuilder(): KiwixActivityComponent.Builder
fun serviceComponent(): Builder
}

View File

@ -16,14 +16,14 @@
*
*/
package org.kiwix.kiwixmobile.core.di.components
package org.kiwix.kiwixmobile.di.components
import android.app.Service
import dagger.BindsInstance
import dagger.Subcomponent
import org.kiwix.kiwixmobile.core.di.ServiceScope
import org.kiwix.kiwixmobile.core.di.modules.ServiceModule
import org.kiwix.kiwixmobile.core.wifi_hotspot.HotspotService
import org.kiwix.kiwixmobile.di.ServiceScope
import org.kiwix.kiwixmobile.di.modules.ServiceModule
import org.kiwix.kiwixmobile.webserver.wifi_hotspot.HotspotService
@Subcomponent(modules = [ServiceModule::class])
@ServiceScope

View File

@ -16,7 +16,7 @@
*
*/
package org.kiwix.kiwixmobile.core.di.modules
package org.kiwix.kiwixmobile.di.modules
import android.app.NotificationManager
import android.app.Service
@ -25,12 +25,12 @@ import dagger.Module
import dagger.Provides
import org.kiwix.kiwixlib.JNIKiwixLibrary
import org.kiwix.kiwixlib.JNIKiwixServer
import org.kiwix.kiwixmobile.core.di.ServiceScope
import org.kiwix.kiwixmobile.core.webserver.WebServerHelper
import org.kiwix.kiwixmobile.core.wifi_hotspot.HotspotNotificationManager
import org.kiwix.kiwixmobile.core.wifi_hotspot.HotspotStateReceiver
import org.kiwix.kiwixmobile.core.wifi_hotspot.HotspotStateReceiver.Callback
import org.kiwix.kiwixmobile.core.wifi_hotspot.IpAddressCallbacks
import org.kiwix.kiwixmobile.di.ServiceScope
import org.kiwix.kiwixmobile.webserver.WebServerHelper
import org.kiwix.kiwixmobile.webserver.wifi_hotspot.HotspotNotificationManager
import org.kiwix.kiwixmobile.webserver.wifi_hotspot.HotspotStateReceiver
import org.kiwix.kiwixmobile.webserver.wifi_hotspot.HotspotStateReceiver.Callback
import org.kiwix.kiwixmobile.webserver.wifi_hotspot.IpAddressCallbacks
@Module
class ServiceModule {
@ -41,12 +41,7 @@ class ServiceModule {
jniKiwixLibrary: JNIKiwixLibrary,
kiwixServer: JNIKiwixServer,
ipAddressCallbacks: IpAddressCallbacks
): WebServerHelper =
WebServerHelper(
jniKiwixLibrary,
kiwixServer,
ipAddressCallbacks
)
): WebServerHelper = WebServerHelper(jniKiwixLibrary, kiwixServer, ipAddressCallbacks)
@Provides
@ServiceScope
@ -67,19 +62,15 @@ class ServiceModule {
fun providesHotspotNotificationManager(
notificationManager: NotificationManager,
context: Context
): HotspotNotificationManager =
HotspotNotificationManager(notificationManager, context)
): HotspotNotificationManager = HotspotNotificationManager(notificationManager, context)
@Provides
@ServiceScope
fun providesHotspotStateReceiver(
callback: Callback
): HotspotStateReceiver =
fun providesHotspotStateReceiver(callback: Callback): HotspotStateReceiver =
HotspotStateReceiver(callback)
@Provides
@ServiceScope
fun providesHotspotStateReceiverCallback(
service: Service
): HotspotStateReceiver.Callback = service as Callback
fun providesHotspotStateReceiverCallback(service: Service): HotspotStateReceiver.Callback =
service as Callback
}

View File

@ -25,7 +25,7 @@ import dagger.Module
import dagger.multibindings.IntoMap
import org.kiwix.kiwixmobile.KiwixViewModelFactory
import org.kiwix.kiwixmobile.language.viewmodel.LanguageViewModel
import org.kiwix.kiwixmobile.di.ViewModelKey
import org.kiwix.kiwixmobile.core.di.ViewModelKey
import org.kiwix.kiwixmobile.zim_manager.ZimManageViewModel
@Module

View File

@ -16,7 +16,7 @@
*
*/
package org.kiwix.kiwixmobile.core.intro;
package org.kiwix.kiwixmobile.intro;
import android.content.Context;
import android.util.AttributeSet;

View File

@ -16,7 +16,7 @@
*
*/
package org.kiwix.kiwixmobile.core.intro;
package org.kiwix.kiwixmobile.intro;
import android.os.Bundle;
import android.os.Handler;
@ -30,9 +30,9 @@ import com.pixelcan.inkpageindicator.InkPageIndicator;
import java.util.Timer;
import java.util.TimerTask;
import javax.inject.Inject;
import org.kiwix.kiwixmobile.ActivityExtensionsKt;
import org.kiwix.kiwixmobile.R;
import org.kiwix.kiwixmobile.core.Intents;
import org.kiwix.kiwixmobile.core.R;
import org.kiwix.kiwixmobile.core.R2;
import org.kiwix.kiwixmobile.core.base.BaseActivity;
import org.kiwix.kiwixmobile.core.main.CoreMainActivity;
@ -40,9 +40,9 @@ public class IntroActivity extends BaseActivity implements IntroContract.View {
private final Handler handler = new Handler();
private final Timer timer = new Timer();
@BindView(R2.id.view_pager)
@BindView(R.id.view_pager)
ViewPager viewPager;
@BindView(R2.id.tab_indicator)
@BindView(R.id.tab_indicator)
InkPageIndicator tabIndicator;
@Inject
IntroContract.Presenter presenter;
@ -79,6 +79,10 @@ public class IntroActivity extends BaseActivity implements IntroContract.View {
};
private View[] views;
@Override protected void injection() {
ActivityExtensionsKt.getKiwixActivityComponent(this).inject(this);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@ -122,7 +126,7 @@ public class IntroActivity extends BaseActivity implements IntroContract.View {
}
}
@OnClick(R2.id.get_started)
@OnClick(R.id.get_started)
void startMainActivity() {
dismissAutoRotate();
startActivity(Intents.internal(CoreMainActivity.class));

View File

@ -16,11 +16,11 @@
*
*/
package org.kiwix.kiwixmobile.core.intro;
package org.kiwix.kiwixmobile.intro;
import org.kiwix.kiwixmobile.core.base.BaseContract;
interface IntroContract {
public interface IntroContract {
interface View extends BaseContract.View<Presenter> {

View File

@ -15,18 +15,14 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package org.kiwix.kiwixmobile.intro
package org.kiwix.kiwixmobile.core.intro;
import dagger.Module;
import dagger.Provides;
import org.kiwix.kiwixmobile.core.di.ActivityScope;
import dagger.Binds
import dagger.Module
import org.kiwix.kiwixmobile.core.di.ActivityScope
@Module
public class IntroModule {
@ActivityScope
@Provides
IntroContract.Presenter provideIntroPresenter(IntroPresenter presenter) {
return presenter;
}
abstract class IntroModule {
@ActivityScope @Binds
abstract fun bindsPresenter(presenter: IntroPresenter): IntroContract.Presenter
}

View File

@ -16,7 +16,7 @@
*
*/
package org.kiwix.kiwixmobile.core.intro;
package org.kiwix.kiwixmobile.intro;
import android.view.View;
import android.view.ViewGroup;

View File

@ -16,7 +16,7 @@
*
*/
package org.kiwix.kiwixmobile.core.intro;
package org.kiwix.kiwixmobile.intro;
import javax.inject.Inject;
import org.kiwix.kiwixmobile.core.base.BasePresenter;
@ -24,7 +24,8 @@ import org.kiwix.kiwixmobile.core.di.ActivityScope;
import org.kiwix.kiwixmobile.core.utils.SharedPreferenceUtil;
@ActivityScope
class IntroPresenter extends BasePresenter<IntroContract.View> implements IntroContract.Presenter {
public class IntroPresenter extends BasePresenter<IntroContract.View>
implements IntroContract.Presenter {
private final SharedPreferenceUtil preferences;
@Inject IntroPresenter(SharedPreferenceUtil preferences) {

View File

@ -32,7 +32,7 @@ import kotlinx.android.synthetic.main.activity_language.language_recycler_view
import kotlinx.android.synthetic.main.activity_language.toolbar
import org.kiwix.kiwixmobile.R
import org.kiwix.kiwixmobile.core.base.BaseActivity
import org.kiwix.kiwixmobile.core.extensions.viewModel
import org.kiwix.kiwixmobile.core.extensions.ActivityExtensions.viewModel
import org.kiwix.kiwixmobile.kiwixActivityComponent
import org.kiwix.kiwixmobile.language.adapter.LanguageAdapter
import org.kiwix.kiwixmobile.language.adapter.LanguageDelegate.HeaderDelegate

View File

@ -49,9 +49,8 @@ sealed class LanguageListViewHolder<in T : LanguageListItem>(override val contai
val language = item.language
item_language_name.text = language.language
item_language_localized_name.text = language.languageLocalized
item_language_books_count.text = containerView.resources.getQuantityString(
R.plurals.books_count, language.occurencesOfLanguage, language.occurencesOfLanguage
)
item_language_books_count.text = containerView.context
.getString(R.string.books_count, language.occurencesOfLanguage)
item_language_checkbox.isChecked = language.active
item_language_clickable_area.setOnClickListener { clickAction(item) }
}

View File

@ -22,6 +22,7 @@ import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import io.reactivex.disposables.CompositeDisposable
import io.reactivex.processors.PublishProcessor
import org.kiwix.kiwixmobile.core.base.SideEffect
import org.kiwix.kiwixmobile.core.dao.NewLanguagesDao
import org.kiwix.kiwixmobile.language.adapter.LanguageListItem.LanguageItem
import org.kiwix.kiwixmobile.language.viewmodel.Action.Filter
@ -31,7 +32,6 @@ import org.kiwix.kiwixmobile.language.viewmodel.Action.UpdateLanguages
import org.kiwix.kiwixmobile.language.viewmodel.State.Content
import org.kiwix.kiwixmobile.language.viewmodel.State.Loading
import org.kiwix.kiwixmobile.language.viewmodel.State.Saving
import org.kiwix.kiwixmobile.zim_manager.fileselect_view.effects.SideEffect
import javax.inject.Inject
class LanguageViewModel @Inject constructor(

View File

@ -22,7 +22,7 @@ import io.reactivex.Flowable
import io.reactivex.schedulers.Schedulers
import org.kiwix.kiwixmobile.core.dao.NewLanguagesDao
import org.kiwix.kiwixmobile.core.zim_manager.Language
import org.kiwix.kiwixmobile.zim_manager.fileselect_view.effects.SideEffect
import org.kiwix.kiwixmobile.core.base.SideEffect
data class SaveLanguagesAndFinish(
val languages: List<Language>,

View File

@ -21,15 +21,17 @@ package org.kiwix.kiwixmobile.main
import android.content.Intent
import android.os.Bundle
import android.util.Log
import android.view.View
import android.widget.Toast
import androidx.core.net.toFile
import androidx.core.net.toUri
import org.json.JSONArray
import org.kiwix.kiwixmobile.core.R
import org.kiwix.kiwixmobile.core.extensions.start
import org.kiwix.kiwixmobile.core.extensions.ActivityExtensions.start
import org.kiwix.kiwixmobile.core.extensions.toast
import org.kiwix.kiwixmobile.core.main.CoreMainActivity
import org.kiwix.kiwixmobile.core.main.WebViewCallback
import org.kiwix.kiwixmobile.core.reader.ZimFileReader
import org.kiwix.kiwixmobile.core.reader.ZimReaderContainer
import org.kiwix.kiwixmobile.core.utils.Constants.EXTRA_ZIM_FILE
import org.kiwix.kiwixmobile.core.utils.Constants.TAG_CURRENT_ARTICLES
@ -41,10 +43,12 @@ import org.kiwix.kiwixmobile.core.utils.SharedPreferenceUtil.PREF_KIWIX_MOBILE
import org.kiwix.kiwixmobile.core.utils.UpdateUtils.reformatProviderUrl
import org.kiwix.kiwixmobile.core.utils.files.FileUtils
import org.kiwix.kiwixmobile.kiwixActivityComponent
import org.kiwix.kiwixmobile.webserver.ZimHostActivity
import org.kiwix.kiwixmobile.zim_manager.ZimManageActivity
import java.io.File
class KiwixMainActivity : CoreMainActivity() {
private val homeUrl = "file:///android_asset/home.html"
override fun injection() {
kiwixActivityComponent.inject(this)
@ -55,6 +59,21 @@ class KiwixMainActivity : CoreMainActivity() {
manageExternalLaunchAndRestoringViewState()
}
override fun onResume() {
super.onResume()
if (zimReaderContainer.zimFile == null && homeUrl != currentWebView.url) {
showHomePage()
}
if (webViewList.isNotEmpty() && currentWebViewIndex < webViewList.size &&
webViewList[currentWebViewIndex].url != null &&
webViewList[currentWebViewIndex].url == homeUrl &&
webViewList[currentWebViewIndex].findViewById<View>(R.id.get_content_card) != null
) {
webViewList[currentWebViewIndex].findViewById<View>(R.id.get_content_card).isEnabled = true
}
}
override fun createWebClient(
webViewCallback: WebViewCallback,
zimReaderContainer: ZimReaderContainer
@ -95,6 +114,24 @@ class KiwixMainActivity : CoreMainActivity() {
}
}
override fun hasValidFileAndUrl(url: String?, zimFileReader: ZimFileReader?) =
super.hasValidFileAndUrl(url, zimFileReader) && url != homeUrl
override fun urlIsInvalid() =
super.urlIsInvalid() || currentWebView.url == homeUrl
override fun showHomePage() {
currentWebView.removeAllViews()
currentWebView.loadUrl(homeUrl)
}
override fun createNewTab() {
newTab(homeUrl)
}
override fun isInvalidTitle(zimFileTitle: String?) =
super.isInvalidTitle(zimFileTitle) || homeUrl == currentWebView.url
private fun uriFromIntent() =
intent.data ?: intent.getStringExtra(EXTRA_ZIM_FILE)?.let {
File(FileUtils.getFileName(it)).toUri()
@ -133,9 +170,7 @@ class KiwixMainActivity : CoreMainActivity() {
}
override fun manageZimFiles(tab: Int) {
start<ZimManageActivity> {
putExtra(ZimManageActivity.TAB_EXTRA, tab)
}
start<ZimManageActivity> { putExtra(ZimManageActivity.TAB_EXTRA, tab) }
}
override fun onNewIntent(intent: Intent?) {
@ -144,4 +179,8 @@ class KiwixMainActivity : CoreMainActivity() {
openZimFile(intent.data.toFile())
}
}
override fun onHostBooksMenuClicked() {
start<ZimHostActivity>()
}
}

View File

@ -0,0 +1,38 @@
/*
* Kiwix Android
* Copyright (c) 2019 Kiwix <android.kiwix.org>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package org.kiwix.kiwixmobile.splash
import android.content.Intent
import org.kiwix.kiwixmobile.core.splash.CoreSplashActivity
import org.kiwix.kiwixmobile.intro.IntroActivity
import org.kiwix.kiwixmobile.kiwixActivityComponent
import org.kiwix.kiwixmobile.main.KiwixMainActivity
class KiwixSplashActivity : CoreSplashActivity() {
override fun injection() {
kiwixActivityComponent.inject(this)
}
override val intentForNextScreen: Intent
get() = if (sharedPreferenceUtil.showIntro())
Intent(this, IntroActivity::class.java)
else
Intent(this, KiwixMainActivity::class.java)
}

View File

@ -16,7 +16,7 @@
*
*/
package org.kiwix.kiwixmobile.core.webserver;
package org.kiwix.kiwixmobile.webserver;
import android.util.Log;
import androidx.annotation.NonNull;
@ -29,7 +29,7 @@ import org.kiwix.kiwixlib.JNIKiwixException;
import org.kiwix.kiwixlib.JNIKiwixLibrary;
import org.kiwix.kiwixlib.JNIKiwixServer;
import org.kiwix.kiwixmobile.core.utils.ServerUtils;
import org.kiwix.kiwixmobile.core.wifi_hotspot.IpAddressCallbacks;
import org.kiwix.kiwixmobile.webserver.wifi_hotspot.IpAddressCallbacks;
import static org.kiwix.kiwixmobile.core.utils.ServerUtils.INVALID_IP;

View File

@ -16,7 +16,7 @@
*
*/
package org.kiwix.kiwixmobile.core.webserver
package org.kiwix.kiwixmobile.webserver
import android.app.ProgressDialog
import android.content.ComponentName
@ -26,26 +26,27 @@ import android.content.ServiceConnection
import android.os.Bundle
import android.os.IBinder
import android.util.Log
import android.widget.Button
import android.widget.TextView
import android.widget.Toast
import kotlinx.android.synthetic.main.activity_zim_host.recyclerViewZimHost
import kotlinx.android.synthetic.main.activity_zim_host.serverTextView
import kotlinx.android.synthetic.main.activity_zim_host.startServerButton
import kotlinx.android.synthetic.main.activity_zim_host.toolbar
import androidx.appcompat.widget.Toolbar
import androidx.recyclerview.widget.RecyclerView
import org.kiwix.kiwixmobile.R
import org.kiwix.kiwixmobile.core.BuildConfig
import org.kiwix.kiwixmobile.core.R
import org.kiwix.kiwixmobile.core.base.BaseActivity
import org.kiwix.kiwixmobile.core.utils.AlertDialogShower
import org.kiwix.kiwixmobile.core.utils.KiwixDialog
import org.kiwix.kiwixmobile.core.utils.ServerUtils
import org.kiwix.kiwixmobile.core.wifi_hotspot.HotspotService
import org.kiwix.kiwixmobile.core.wifi_hotspot.HotspotService.ACTION_CHECK_IP_ADDRESS
import org.kiwix.kiwixmobile.core.wifi_hotspot.HotspotService.ACTION_START_SERVER
import org.kiwix.kiwixmobile.core.wifi_hotspot.HotspotService.ACTION_STOP_SERVER
import org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.SelectionMode
import org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.adapter.BookOnDiskDelegate
import org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.adapter.BooksOnDiskAdapter
import org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.adapter.BooksOnDiskListItem
import org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.adapter.BooksOnDiskListItem.BookOnDisk
import org.kiwix.kiwixmobile.kiwixActivityComponent
import org.kiwix.kiwixmobile.webserver.wifi_hotspot.HotspotService
import org.kiwix.kiwixmobile.webserver.wifi_hotspot.HotspotService.ACTION_CHECK_IP_ADDRESS
import org.kiwix.kiwixmobile.webserver.wifi_hotspot.HotspotService.ACTION_START_SERVER
import org.kiwix.kiwixmobile.webserver.wifi_hotspot.HotspotService.ACTION_STOP_SERVER
import java.util.ArrayList
import javax.inject.Inject
@ -54,6 +55,10 @@ class ZimHostActivity : BaseActivity(), ZimHostCallbacks, ZimHostContract.View {
internal lateinit var presenter: ZimHostContract.Presenter
@Inject
internal lateinit var alertDialogShower: AlertDialogShower
private lateinit var recyclerViewZimHost: RecyclerView
private lateinit var toolbar: Toolbar
private lateinit var startServerButton: Button
private lateinit var serverTextView: TextView
private lateinit var booksAdapter: BooksOnDiskAdapter
private lateinit var bookDelegate: BookOnDiskDelegate.BookDelegate
private var hotspotService: HotspotService? = null
@ -80,7 +85,10 @@ class ZimHostActivity : BaseActivity(), ZimHostCallbacks, ZimHostContract.View {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_zim_host)
recyclerViewZimHost = findViewById(R.id.recyclerViewZimHost)
toolbar = findViewById(R.id.toolbar)
startServerButton = findViewById(R.id.startServerButton)
serverTextView = findViewById(R.id.serverTextView)
setUpToolbar()
bookDelegate = BookOnDiskDelegate.BookDelegate(sharedPreferenceUtil, null, null,
@ -113,6 +121,10 @@ class ZimHostActivity : BaseActivity(), ZimHostCallbacks, ZimHostContract.View {
startServerButton.setOnClickListener { startStopServer() }
}
override fun injection() {
kiwixActivityComponent.inject(this)
}
private fun startStopServer() {
when {
ServerUtils.isServerStarted -> stopServer()
@ -130,12 +142,11 @@ class ZimHostActivity : BaseActivity(), ZimHostCallbacks, ZimHostContract.View {
}
private fun select(bookOnDisk: BooksOnDiskListItem.BookOnDisk) {
val booksList: ArrayList<BooksOnDiskListItem> = ArrayList()
booksAdapter.items.map {
val booksList: List<BooksOnDiskListItem> = booksAdapter.items.map {
if (it == bookOnDisk) {
it.isSelected = !it.isSelected
}
booksList.add(it)
it
}
booksAdapter.items = booksList
saveHostedBooks(booksList)
@ -174,7 +185,7 @@ class ZimHostActivity : BaseActivity(), ZimHostCallbacks, ZimHostContract.View {
}
}
private fun saveHostedBooks(booksList: ArrayList<BooksOnDiskListItem>) {
private fun saveHostedBooks(booksList: List<BooksOnDiskListItem>) {
sharedPreferenceUtil.hostedBooks = booksList.asSequence()
.filter(BooksOnDiskListItem::isSelected)
.filterIsInstance<BookOnDisk>()
@ -233,8 +244,8 @@ class ZimHostActivity : BaseActivity(), ZimHostCallbacks, ZimHostContract.View {
private fun createHotspotIntent(action: String): Intent =
Intent(this, HotspotService::class.java).setAction(action)
override fun onServerStarted(ipAddress: String) {
ip = ipAddress
override fun onServerStarted(ip: String) {
this.ip = ip
layoutServerStarted()
}

View File

@ -0,0 +1,26 @@
/*
* Kiwix Android
* Copyright (c) 2019 Kiwix <android.kiwix.org>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package org.kiwix.kiwixmobile.webserver
interface ZimHostCallbacks {
fun onServerStarted(ip: String)
fun onServerStopped()
fun onServerFailedToStart()
fun onIpAddressValid()
fun onIpAddressInvalid()
}

View File

@ -15,23 +15,17 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package org.kiwix.kiwixmobile.webserver
package org.kiwix.kiwixmobile.core.webserver;
import java.util.List;
import java.util.Set;
import org.kiwix.kiwixmobile.core.base.BaseContract;
import org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.adapter.BooksOnDiskListItem;
import org.kiwix.kiwixmobile.core.base.BaseContract
import org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.adapter.BooksOnDiskListItem
class ZimHostContract {
interface View
extends BaseContract.View<ZimHostContract.Presenter> {
void addBooks(List<BooksOnDiskListItem> books);
interface View : BaseContract.View<Presenter> {
fun addBooks(books: List<BooksOnDiskListItem>)
}
interface Presenter
extends BaseContract.Presenter<ZimHostContract.View> {
void loadBooks(Set<String> previouslyHostedBooks);
interface Presenter : BaseContract.Presenter<View> {
fun loadBooks(previouslyHostedBooks: Set<String>)
}
}

View File

@ -15,26 +15,14 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package org.kiwix.kiwixmobile.webserver
package org.kiwix.kiwixmobile.core.webserver;
import android.app.Activity;
import dagger.Module;
import dagger.Provides;
import org.kiwix.kiwixmobile.core.di.ActivityScope;
import dagger.Binds
import dagger.Module
import org.kiwix.kiwixmobile.core.di.ActivityScope
@Module
public class ZimHostModule {
@ActivityScope
@Provides
ZimHostContract.Presenter provideZimHostPresenter(ZimHostPresenter zimHostPresenter) {
return zimHostPresenter;
}
@ActivityScope
@Provides Activity providesActivity(ZimHostActivity zimHostActivity) {
return zimHostActivity;
}
abstract class ZimHostModule {
@ActivityScope @Binds
abstract fun bindsZimHostPresenter(zimHostPresenter: ZimHostPresenter): ZimHostContract.Presenter
}

View File

@ -0,0 +1,66 @@
/*
* Kiwix Android
* Copyright (c) 2019 Kiwix <android.kiwix.org>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package org.kiwix.kiwixmobile.webserver
import android.util.Log
import io.reactivex.SingleObserver
import io.reactivex.disposables.Disposable
import org.kiwix.kiwixmobile.core.base.BasePresenter
import org.kiwix.kiwixmobile.core.data.DataSource
import org.kiwix.kiwixmobile.core.di.ActivityScope
import org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.adapter.BooksOnDiskListItem
import org.kiwix.kiwixmobile.webserver.ZimHostContract.Presenter
import org.kiwix.kiwixmobile.webserver.ZimHostContract.View
import javax.inject.Inject
@ActivityScope
class ZimHostPresenter @Inject internal constructor(private val dataSource: DataSource) :
BasePresenter<View>(),
Presenter {
override fun loadBooks(previouslyHostedBooks: Set<String>) {
dataSource.languageCategorizedBooks
.map { books ->
books
.filterIsInstance<BooksOnDiskListItem.BookOnDisk>()
.forEach {
it.isSelected = (
previouslyHostedBooks.contains(it.book.title) || previouslyHostedBooks.isEmpty()
)
}
books
}
.subscribe(object : SingleObserver<List<BooksOnDiskListItem>> {
override fun onSubscribe(d: Disposable) {
compositeDisposable.add(d)
}
override fun onSuccess(books: List<BooksOnDiskListItem>) {
view!!.addBooks(books)
}
override fun onError(e: Throwable) {
Log.e(TAG, "Unable to load books", e)
}
})
}
companion object {
private const val TAG = "ZimHostPresenter"
}
}

View File

@ -16,7 +16,7 @@
*
*/
package org.kiwix.kiwixmobile.core.wifi_hotspot;
package org.kiwix.kiwixmobile.webserver.wifi_hotspot;
import android.app.Notification;
import android.app.NotificationChannel;
@ -30,7 +30,7 @@ import androidx.core.app.NotificationCompat;
import javax.inject.Inject;
import org.kiwix.kiwixmobile.core.R;
import org.kiwix.kiwixmobile.core.utils.Constants;
import org.kiwix.kiwixmobile.core.webserver.ZimHostActivity;
import org.kiwix.kiwixmobile.webserver.ZimHostActivity;
public class HotspotNotificationManager {
@ -76,7 +76,7 @@ public class HotspotNotificationManager {
.setContentTitle(context.getString(R.string.hotspot_notification_content_title))
.setContentText(context.getString(R.string.hotspot_running))
.setContentIntent(contentIntent)
.setSmallIcon(R.mipmap.kiwix_icon)
.setSmallIcon(R.mipmap.ic_launcher)
.setWhen(System.currentTimeMillis())
.addAction(R.drawable.ic_close_white_24dp,
context.getString(R.string.stop_hotspot_button),

View File

@ -16,7 +16,7 @@
*
*/
package org.kiwix.kiwixmobile.core.wifi_hotspot;
package org.kiwix.kiwixmobile.webserver.wifi_hotspot;
import android.app.Service;
import android.content.Intent;
@ -26,15 +26,15 @@ import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import javax.inject.Inject;
import org.kiwix.kiwixmobile.core.CoreApp;
import org.kiwix.kiwixmobile.KiwixApp;
import org.kiwix.kiwixmobile.core.R;
import org.kiwix.kiwixmobile.core.extensions.ContextExtensionsKt;
import org.kiwix.kiwixmobile.core.utils.ServerUtils;
import org.kiwix.kiwixmobile.core.webserver.WebServerHelper;
import org.kiwix.kiwixmobile.core.webserver.ZimHostCallbacks;
import org.kiwix.kiwixmobile.webserver.WebServerHelper;
import org.kiwix.kiwixmobile.webserver.ZimHostCallbacks;
import static org.kiwix.kiwixmobile.core.webserver.ZimHostActivity.SELECTED_ZIM_PATHS_KEY;
import static org.kiwix.kiwixmobile.core.wifi_hotspot.HotspotNotificationManager.HOTSPOT_NOTIFICATION_ID;
import static org.kiwix.kiwixmobile.webserver.ZimHostActivity.SELECTED_ZIM_PATHS_KEY;
import static org.kiwix.kiwixmobile.webserver.wifi_hotspot.HotspotNotificationManager.HOTSPOT_NOTIFICATION_ID;
/**
* HotspotService is used to add a foreground service for the wifi hotspot.
@ -59,7 +59,7 @@ public class HotspotService extends Service
HotspotStateReceiver hotspotStateReceiver;
@Override public void onCreate() {
CoreApp.getCoreComponent()
((KiwixApp) this.getApplicationContext()).getKiwixComponent()
.serviceComponent()
.service(this)
.build()

View File

@ -15,12 +15,12 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package org.kiwix.kiwixmobile.core.wifi_hotspot
package org.kiwix.kiwixmobile.webserver.wifi_hotspot
import android.content.Context
import android.content.Intent
import org.kiwix.kiwixmobile.core.wifi_hotspot.HotspotStateReceiver.HotspotState.DISABLED
import org.kiwix.kiwixmobile.core.base.BaseBroadcastReceiver
import org.kiwix.kiwixmobile.webserver.wifi_hotspot.HotspotStateReceiver.HotspotState.DISABLED
import javax.inject.Inject
const val EXTRA_WIFI_AP_STATE = "wifi_state"
@ -32,7 +32,8 @@ const val WIFI_AP_STATE_ENABLING = 12
const val WIFI_AP_STATE_ENABLED = 13
const val WIFI_AP_STATE_FAILED = 14
class HotspotStateReceiver @Inject constructor(val callback: Callback) : BaseBroadcastReceiver() {
class HotspotStateReceiver @Inject constructor(private val callback: Callback) :
BaseBroadcastReceiver() {
override val action: String = ACTION_WIFI_AP_STATE
override fun onIntentWithActionReceived(context: Context, intent: Intent) {

View File

@ -16,7 +16,7 @@
*
*/
package org.kiwix.kiwixmobile.core.wifi_hotspot;
package org.kiwix.kiwixmobile.webserver.wifi_hotspot;
public interface IpAddressCallbacks {

View File

@ -17,12 +17,9 @@
*/
package org.kiwix.kiwixmobile.zim_manager
import android.app.Activity
import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.provider.Settings.System
import android.util.Log
import android.view.Menu
import android.view.MenuItem
import androidx.appcompat.widget.SearchView
@ -32,17 +29,15 @@ import kotlinx.android.synthetic.main.zim_manager.tabs
import kotlinx.android.synthetic.main.zim_manager.toolbar
import org.kiwix.kiwixmobile.R
import org.kiwix.kiwixmobile.core.base.BaseActivity
import org.kiwix.kiwixmobile.core.extensions.start
import org.kiwix.kiwixmobile.core.extensions.startWithActionFrom
import org.kiwix.kiwixmobile.core.extensions.viewModel
import org.kiwix.kiwixmobile.language.LanguageActivity
import org.kiwix.kiwixmobile.core.main.CoreMainActivity
import org.kiwix.kiwixmobile.core.dao.NewLanguagesDao
import org.kiwix.kiwixmobile.core.utils.Constants.TAG_KIWIX
import org.kiwix.kiwixmobile.core.extensions.ActivityExtensions.start
import org.kiwix.kiwixmobile.core.extensions.ActivityExtensions.startWithActionFrom
import org.kiwix.kiwixmobile.core.extensions.ActivityExtensions.viewModel
import org.kiwix.kiwixmobile.core.main.CoreMainActivity
import org.kiwix.kiwixmobile.core.utils.LanguageUtils
import org.kiwix.kiwixmobile.local_file_transfer.LocalFileTransferActivity
import org.kiwix.kiwixmobile.kiwixActivityComponent
import java.io.File
import org.kiwix.kiwixmobile.language.LanguageActivity
import org.kiwix.kiwixmobile.local_file_transfer.LocalFileTransferActivity
import javax.inject.Inject
class ZimManageActivity : BaseActivity() {
@ -144,20 +139,6 @@ class ZimManageActivity : BaseActivity() {
return super.onOptionsItemSelected(item)
}
// Set zim file and return
fun finishResult(path: String?) {
if (path != null) {
val file = File(path)
val uri = Uri.fromFile(file)
Log.i(TAG_KIWIX, "Opening Zim File: $uri")
setResult(Activity.RESULT_OK, Intent().setData(uri))
finish()
} else {
setResult(Activity.RESULT_CANCELED)
finish()
}
}
companion object {
const val TAB_EXTRA = "TAB"
}

View File

@ -66,7 +66,7 @@ import org.kiwix.kiwixmobile.zim_manager.fileselect_view.effects.DeleteFiles
import org.kiwix.kiwixmobile.zim_manager.fileselect_view.effects.None
import org.kiwix.kiwixmobile.zim_manager.fileselect_view.effects.OpenFile
import org.kiwix.kiwixmobile.zim_manager.fileselect_view.effects.ShareFiles
import org.kiwix.kiwixmobile.zim_manager.fileselect_view.effects.SideEffect
import org.kiwix.kiwixmobile.core.base.SideEffect
import org.kiwix.kiwixmobile.zim_manager.fileselect_view.effects.StartMultiSelection
import org.kiwix.kiwixmobile.zim_manager.library_view.adapter.LibraryListItem
import org.kiwix.kiwixmobile.zim_manager.library_view.adapter.LibraryListItem.BookItem

View File

@ -32,7 +32,7 @@ import org.kiwix.kiwixmobile.core.base.BaseActivity
import org.kiwix.kiwixmobile.core.base.BaseFragment
import org.kiwix.kiwixmobile.core.downloader.Downloader
import org.kiwix.kiwixmobile.core.downloader.model.DownloadItem
import org.kiwix.kiwixmobile.core.extensions.viewModel
import org.kiwix.kiwixmobile.core.extensions.ActivityExtensions.viewModel
import org.kiwix.kiwixmobile.core.utils.DialogShower
import org.kiwix.kiwixmobile.core.utils.KiwixDialog.YesNoDialog.StopDownload
import org.kiwix.kiwixmobile.core.utils.SharedPreferenceUtil

View File

@ -17,7 +17,6 @@
*/
package org.kiwix.kiwixmobile.zim_manager.download_view
import android.content.Context
import android.view.View
import androidx.recyclerview.widget.RecyclerView
import kotlinx.android.extensions.LayoutContainer
@ -29,12 +28,6 @@ import kotlinx.android.synthetic.main.download_item.favicon
import kotlinx.android.synthetic.main.download_item.stop
import kotlinx.android.synthetic.main.download_item.title
import org.kiwix.kiwixmobile.core.downloader.model.DownloadItem
import org.kiwix.kiwixmobile.core.downloader.model.DownloadState
import org.kiwix.kiwixmobile.core.downloader.model.DownloadState.Failed
import org.kiwix.kiwixmobile.core.downloader.model.DownloadState.Paused
import org.kiwix.kiwixmobile.core.downloader.model.DownloadState.Pending
import org.kiwix.kiwixmobile.core.downloader.model.DownloadState.Running
import org.kiwix.kiwixmobile.core.downloader.model.DownloadState.Successful
import org.kiwix.kiwixmobile.core.extensions.setBitmap
class DownloadViewHolder(override val containerView: View) : RecyclerView.ViewHolder(containerView),
@ -50,21 +43,7 @@ class DownloadViewHolder(override val containerView: View) : RecyclerView.ViewHo
stop.setOnClickListener {
itemClickListener.invoke(downloadItem)
}
downloadState.text = toReadableState(downloadItem.downloadState, containerView.context)
eta.text = downloadItem.eta.takeIf { it.seconds > 0L }?.toHumanReadableTime() ?: ""
}
private fun toReadableState(
downloadState: DownloadState,
context: Context
) = when (downloadState) {
is Failed -> context.getString(
downloadState.stringId,
downloadState.reason.name
)
Pending,
Running,
Paused,
Successful -> context.getString(downloadState.stringId)
downloadState.text = downloadItem.downloadState.toReadableState(containerView.context)
eta.text = downloadItem.readableEta
}
}

View File

@ -20,6 +20,8 @@ package org.kiwix.kiwixmobile.zim_manager.fileselect_view
import android.Manifest
import android.content.pm.PackageManager
import android.os.Build.VERSION
import android.os.Build.VERSION_CODES
import android.os.Bundle
import android.view.ActionMode
import android.view.LayoutInflater
@ -37,8 +39,8 @@ import kotlinx.android.synthetic.main.zim_list.zimfilelist
import org.kiwix.kiwixmobile.R
import org.kiwix.kiwixmobile.core.base.BaseActivity
import org.kiwix.kiwixmobile.core.base.BaseFragment
import org.kiwix.kiwixmobile.core.extensions.ActivityExtensions.viewModel
import org.kiwix.kiwixmobile.core.extensions.toast
import org.kiwix.kiwixmobile.core.extensions.viewModel
import org.kiwix.kiwixmobile.core.utils.Constants.REQUEST_STORAGE_PERMISSION
import org.kiwix.kiwixmobile.core.utils.LanguageUtils
import org.kiwix.kiwixmobile.core.utils.SharedPreferenceUtil
@ -143,12 +145,13 @@ class ZimFileSelectFragment : BaseFragment() {
private fun checkPermissions() {
if (ContextCompat.checkSelfPermission(
activity!!,
Manifest.permission.WRITE_EXTERNAL_STORAGE
) != PackageManager.PERMISSION_GRANTED
Manifest.permission.READ_EXTERNAL_STORAGE
) != PackageManager.PERMISSION_GRANTED &&
VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN
) {
context.toast(R.string.request_storage)
requestPermissions(
arrayOf(Manifest.permission.WRITE_EXTERNAL_STORAGE),
arrayOf(Manifest.permission.READ_EXTERNAL_STORAGE),
REQUEST_STORAGE_PERMISSION
)
} else {

View File

@ -20,6 +20,7 @@ package org.kiwix.kiwixmobile.zim_manager.fileselect_view.effects
import android.app.Activity
import org.kiwix.kiwixmobile.R
import org.kiwix.kiwixmobile.core.base.SideEffect
import org.kiwix.kiwixmobile.core.dao.NewBookDao
import org.kiwix.kiwixmobile.core.extensions.toast
import org.kiwix.kiwixmobile.core.reader.ZimReaderContainer

View File

@ -19,6 +19,7 @@
package org.kiwix.kiwixmobile.zim_manager.fileselect_view.effects
import android.app.Activity
import org.kiwix.kiwixmobile.core.base.SideEffect
object None : SideEffect<Unit> {
override fun invokeWith(activity: Activity) {

View File

@ -20,12 +20,14 @@ package org.kiwix.kiwixmobile.zim_manager.fileselect_view.effects
import android.app.Activity
import androidx.core.net.toUri
import org.kiwix.kiwixmobile.core.R
import org.kiwix.kiwixmobile.core.extensions.start
import org.kiwix.kiwixmobile.core.base.SideEffect
import org.kiwix.kiwixmobile.core.extensions.ActivityExtensions.start
import org.kiwix.kiwixmobile.core.extensions.toast
import org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.adapter.BooksOnDiskListItem.BookOnDisk
import org.kiwix.kiwixmobile.main.KiwixMainActivity
class OpenFile(private val bookOnDisk: BookOnDisk) : SideEffect<Unit> {
class OpenFile(private val bookOnDisk: BookOnDisk) :
SideEffect<Unit> {
override fun invokeWith(activity: Activity) {
val file = bookOnDisk.file

View File

@ -24,9 +24,11 @@ import android.net.Uri
import android.os.Build
import androidx.core.content.FileProvider
import org.kiwix.kiwixmobile.core.R
import org.kiwix.kiwixmobile.core.base.SideEffect
import org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.adapter.BooksOnDiskListItem.BookOnDisk
class ShareFiles(private val selectedBooks: List<BookOnDisk>) : SideEffect<Unit> {
class ShareFiles(private val selectedBooks: List<BookOnDisk>) :
SideEffect<Unit> {
override fun invokeWith(activity: Activity) {
val selectedFileShareIntent = Intent()
selectedFileShareIntent.action = Intent.ACTION_SEND_MULTIPLE

View File

@ -22,7 +22,8 @@ import android.app.Activity
import android.view.ActionMode
import io.reactivex.processors.PublishProcessor
import org.kiwix.kiwixmobile.core.R
import org.kiwix.kiwixmobile.core.extensions.startActionMode
import org.kiwix.kiwixmobile.core.base.SideEffect
import org.kiwix.kiwixmobile.core.extensions.ActivityExtensions.startActionMode
import org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.adapter.BooksOnDiskListItem
import org.kiwix.kiwixmobile.zim_manager.ZimManageViewModel.FileSelectActions
import org.kiwix.kiwixmobile.zim_manager.ZimManageViewModel.FileSelectActions.RequestDeleteMultiSelection

View File

@ -39,9 +39,9 @@ import org.kiwix.kiwixmobile.core.base.BaseActivity
import org.kiwix.kiwixmobile.core.base.BaseFragment
import org.kiwix.kiwixmobile.core.downloader.Downloader
import org.kiwix.kiwixmobile.core.entity.LibraryNetworkEntity.Book
import org.kiwix.kiwixmobile.core.extensions.ActivityExtensions.viewModel
import org.kiwix.kiwixmobile.core.extensions.snack
import org.kiwix.kiwixmobile.core.extensions.toast
import org.kiwix.kiwixmobile.core.extensions.viewModel
import org.kiwix.kiwixmobile.core.main.CoreMainActivity
import org.kiwix.kiwixmobile.core.settings.StorageCalculator
import org.kiwix.kiwixmobile.core.utils.BookUtils

View File

@ -4,16 +4,14 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".intro.IntroActivity"
>
tools:context=".intro.IntroActivity">
<org.kiwix.kiwixmobile.core.intro.CustomViewPager
<org.kiwix.kiwixmobile.intro.CustomViewPager
android:id="@+id/view_pager"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="@id/get_started"
app:layout_constraintTop_toTopOf="parent"
/>
app:layout_constraintTop_toTopOf="parent" />
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/get_started"
@ -25,8 +23,7 @@
app:backgroundTint="@android:color/white"
app:layout_constraintBottom_toTopOf="@id/tab_indicator"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
/>
app:layout_constraintStart_toStartOf="parent" />
<com.pixelcan.inkpageindicator.InkPageIndicator
android:id="@+id/tab_indicator"
@ -35,6 +32,5 @@
android:layout_marginBottom="@dimen/activity_vertical_margin"
app:ipi_currentPageIndicatorColor="@color/blue800"
app:ipi_pageIndicatorColor="@color/blueTransparent"
app:layout_constraintBottom_toBottomOf="parent"
/>
app:layout_constraintBottom_toBottomOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -19,7 +19,7 @@
android:adjustViewBounds="true"
android:minHeight="?android:attr/listPreferredItemHeight"
android:scaleType="fitCenter"
android:src="@mipmap/kiwix_icon" />
android:src="@mipmap/ic_launcher" />
<LinearLayout
android:layout_width="0dp"

View File

@ -20,7 +20,7 @@
android:layout_marginRight="@dimen/favicon_margin_right"
android:adjustViewBounds="true"
android:scaleType="fitCenter"
android:src="@mipmap/kiwix_icon"
android:src="@mipmap/ic_launcher"
/>
<LinearLayout

View File

@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<resources><!--placeholder for translation scripts--></resources>

Some files were not shown because too many files have changed in this diff Show More