mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-16 02:48:08 -04:00
#1600 Move ZimHostActivity to app module
This commit is contained in:
parent
ec4525560f
commit
d18d25d6fb
@ -2,6 +2,8 @@
|
|||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="org.kiwix.kiwixmobile">
|
package="org.kiwix.kiwixmobile">
|
||||||
|
|
||||||
|
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||||
|
|
||||||
<application android:name=".KiwixApp">
|
<application android:name=".KiwixApp">
|
||||||
<activity
|
<activity
|
||||||
android:name=".main.KiwixMainActivity"
|
android:name=".main.KiwixMainActivity"
|
||||||
@ -140,5 +142,8 @@
|
|||||||
<data android:host="*" />
|
<data android:host="*" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
<activity android:name=".webserver.ZimHostActivity" />
|
||||||
|
|
||||||
|
<service android:name=".webserver.wifi_hotspot.HotspotService" />
|
||||||
</application>
|
</application>
|
||||||
</manifest>
|
</manifest>
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
package org.kiwix.kiwixmobile
|
package org.kiwix.kiwixmobile
|
||||||
|
|
||||||
import org.kiwix.kiwixmobile.core.base.BaseActivity
|
import org.kiwix.kiwixmobile.core.base.BaseActivity
|
||||||
import org.kiwix.kiwixmobile.di.components.KiwixComponent
|
import org.kiwix.kiwixmobile.core.di.components.KiwixComponent
|
||||||
|
|
||||||
private val BaseActivity.kiwixComponent: KiwixComponent
|
private val BaseActivity.kiwixComponent: KiwixComponent
|
||||||
get() = (applicationContext as KiwixApp).kiwixComponent
|
get() = (applicationContext as KiwixApp).kiwixComponent
|
||||||
|
@ -19,8 +19,8 @@
|
|||||||
package org.kiwix.kiwixmobile
|
package org.kiwix.kiwixmobile
|
||||||
|
|
||||||
import org.kiwix.kiwixmobile.core.CoreApp
|
import org.kiwix.kiwixmobile.core.CoreApp
|
||||||
import org.kiwix.kiwixmobile.di.components.DaggerKiwixComponent
|
import org.kiwix.kiwixmobile.core.di.components.DaggerKiwixComponent
|
||||||
import org.kiwix.kiwixmobile.di.components.KiwixComponent
|
import org.kiwix.kiwixmobile.core.di.components.KiwixComponent
|
||||||
|
|
||||||
class KiwixApp : CoreApp() {
|
class KiwixApp : CoreApp() {
|
||||||
@Suppress("ConvertLambdaToReference") // we want the entire call to be lazy
|
@Suppress("ConvertLambdaToReference") // we want the entire call to be lazy
|
||||||
|
@ -23,7 +23,7 @@ import java.util.Map;
|
|||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Provider;
|
import javax.inject.Provider;
|
||||||
import org.kiwix.kiwixmobile.core.ViewModelFactory;
|
import org.kiwix.kiwixmobile.core.ViewModelFactory;
|
||||||
import org.kiwix.kiwixmobile.di.KiwixScope;
|
import org.kiwix.kiwixmobile.core.di.KiwixScope;
|
||||||
|
|
||||||
@KiwixScope
|
@KiwixScope
|
||||||
public class KiwixViewModelFactory extends ViewModelFactory {
|
public class KiwixViewModelFactory extends ViewModelFactory {
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.kiwix.kiwixmobile.di
|
package org.kiwix.kiwixmobile.core.di
|
||||||
|
|
||||||
import javax.inject.Scope
|
import javax.inject.Scope
|
||||||
|
|
@ -15,17 +15,19 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
package org.kiwix.kiwixmobile.di.components
|
package org.kiwix.kiwixmobile.core.di.components
|
||||||
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import dagger.BindsInstance
|
import dagger.BindsInstance
|
||||||
import dagger.Subcomponent
|
import dagger.Subcomponent
|
||||||
import org.kiwix.kiwixmobile.core.di.ActivityScope
|
import org.kiwix.kiwixmobile.core.di.ActivityScope
|
||||||
import org.kiwix.kiwixmobile.di.modules.KiwixActivityModule
|
import org.kiwix.kiwixmobile.core.di.modules.KiwixActivityModule
|
||||||
import org.kiwix.kiwixmobile.language.LanguageActivity
|
import org.kiwix.kiwixmobile.language.LanguageActivity
|
||||||
import org.kiwix.kiwixmobile.local_file_transfer.LocalFileTransferActivity
|
import org.kiwix.kiwixmobile.local_file_transfer.LocalFileTransferActivity
|
||||||
import org.kiwix.kiwixmobile.main.KiwixMainActivity
|
import org.kiwix.kiwixmobile.main.KiwixMainActivity
|
||||||
import org.kiwix.kiwixmobile.settings.KiwixSettingsActivity
|
import org.kiwix.kiwixmobile.settings.KiwixSettingsActivity
|
||||||
|
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.ZimManageActivity
|
||||||
import org.kiwix.kiwixmobile.zim_manager.download_view.DownloadFragment
|
import org.kiwix.kiwixmobile.zim_manager.download_view.DownloadFragment
|
||||||
import org.kiwix.kiwixmobile.zim_manager.fileselect_view.ZimFileSelectFragment
|
import org.kiwix.kiwixmobile.zim_manager.fileselect_view.ZimFileSelectFragment
|
||||||
@ -33,7 +35,12 @@ import org.kiwix.kiwixmobile.zim_manager.fileselect_view.effects.DeleteFiles
|
|||||||
import org.kiwix.kiwixmobile.zim_manager.library_view.LibraryFragment
|
import org.kiwix.kiwixmobile.zim_manager.library_view.LibraryFragment
|
||||||
|
|
||||||
@ActivityScope
|
@ActivityScope
|
||||||
@Subcomponent(modules = [KiwixActivityModule::class])
|
@Subcomponent(
|
||||||
|
modules = [
|
||||||
|
KiwixActivityModule::class,
|
||||||
|
ZimHostModule::class
|
||||||
|
]
|
||||||
|
)
|
||||||
interface KiwixActivityComponent {
|
interface KiwixActivityComponent {
|
||||||
fun inject(downloadFragment: DownloadFragment)
|
fun inject(downloadFragment: DownloadFragment)
|
||||||
fun inject(libraryFragment: LibraryFragment)
|
fun inject(libraryFragment: LibraryFragment)
|
||||||
@ -44,6 +51,7 @@ interface KiwixActivityComponent {
|
|||||||
fun inject(languageActivity: LanguageActivity)
|
fun inject(languageActivity: LanguageActivity)
|
||||||
fun inject(kiwixMainActivity: KiwixMainActivity)
|
fun inject(kiwixMainActivity: KiwixMainActivity)
|
||||||
fun inject(kiwixSettingsActivity: KiwixSettingsActivity)
|
fun inject(kiwixSettingsActivity: KiwixSettingsActivity)
|
||||||
|
fun inject(zimHostActivity: ZimHostActivity)
|
||||||
|
|
||||||
@Subcomponent.Builder
|
@Subcomponent.Builder
|
||||||
interface Builder {
|
interface Builder {
|
@ -16,13 +16,12 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.kiwix.kiwixmobile.di.components
|
package org.kiwix.kiwixmobile.core.di.components
|
||||||
|
|
||||||
import dagger.Component
|
import dagger.Component
|
||||||
import org.kiwix.kiwixmobile.core.di.components.CoreComponent
|
import org.kiwix.kiwixmobile.core.di.KiwixScope
|
||||||
import org.kiwix.kiwixmobile.di.modules.KiwixModule
|
import org.kiwix.kiwixmobile.core.di.modules.KiwixModule
|
||||||
import org.kiwix.kiwixmobile.di.KiwixScope
|
import org.kiwix.kiwixmobile.core.di.modules.ViewModelModule
|
||||||
import org.kiwix.kiwixmobile.di.modules.ViewModelModule
|
|
||||||
|
|
||||||
@KiwixScope
|
@KiwixScope
|
||||||
@Component(
|
@Component(
|
||||||
@ -31,4 +30,5 @@ import org.kiwix.kiwixmobile.di.modules.ViewModelModule
|
|||||||
)
|
)
|
||||||
interface KiwixComponent {
|
interface KiwixComponent {
|
||||||
fun activityComponentBuilder(): KiwixActivityComponent.Builder
|
fun activityComponentBuilder(): KiwixActivityComponent.Builder
|
||||||
|
fun serviceComponent(): ServiceComponent.Builder
|
||||||
}
|
}
|
@ -23,7 +23,7 @@ import dagger.BindsInstance
|
|||||||
import dagger.Subcomponent
|
import dagger.Subcomponent
|
||||||
import org.kiwix.kiwixmobile.core.di.ServiceScope
|
import org.kiwix.kiwixmobile.core.di.ServiceScope
|
||||||
import org.kiwix.kiwixmobile.core.di.modules.ServiceModule
|
import org.kiwix.kiwixmobile.core.di.modules.ServiceModule
|
||||||
import org.kiwix.kiwixmobile.core.wifi_hotspot.HotspotService
|
import org.kiwix.kiwixmobile.webserver.wifi_hotspot.HotspotService
|
||||||
|
|
||||||
@Subcomponent(modules = [ServiceModule::class])
|
@Subcomponent(modules = [ServiceModule::class])
|
||||||
@ServiceScope
|
@ServiceScope
|
@ -16,10 +16,9 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.kiwix.kiwixmobile.di.modules
|
package org.kiwix.kiwixmobile.core.di.modules
|
||||||
|
|
||||||
import dagger.Module
|
import dagger.Module
|
||||||
import org.kiwix.kiwixmobile.core.di.modules.ActivityModule
|
|
||||||
|
|
||||||
@Module(includes = [ActivityModule::class])
|
@Module(includes = [ActivityModule::class])
|
||||||
class KiwixActivityModule
|
class KiwixActivityModule
|
@ -16,13 +16,13 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.kiwix.kiwixmobile.di.modules
|
package org.kiwix.kiwixmobile.core.di.modules
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.location.LocationManager
|
import android.location.LocationManager
|
||||||
import dagger.Module
|
import dagger.Module
|
||||||
import dagger.Provides
|
import dagger.Provides
|
||||||
import org.kiwix.kiwixmobile.di.KiwixScope
|
import org.kiwix.kiwixmobile.core.di.KiwixScope
|
||||||
|
|
||||||
@Module
|
@Module
|
||||||
object KiwixModule {
|
object KiwixModule {
|
@ -26,11 +26,11 @@ import dagger.Provides
|
|||||||
import org.kiwix.kiwixlib.JNIKiwixLibrary
|
import org.kiwix.kiwixlib.JNIKiwixLibrary
|
||||||
import org.kiwix.kiwixlib.JNIKiwixServer
|
import org.kiwix.kiwixlib.JNIKiwixServer
|
||||||
import org.kiwix.kiwixmobile.core.di.ServiceScope
|
import org.kiwix.kiwixmobile.core.di.ServiceScope
|
||||||
import org.kiwix.kiwixmobile.core.webserver.WebServerHelper
|
import org.kiwix.kiwixmobile.webserver.WebServerHelper
|
||||||
import org.kiwix.kiwixmobile.core.wifi_hotspot.HotspotNotificationManager
|
import org.kiwix.kiwixmobile.webserver.wifi_hotspot.HotspotNotificationManager
|
||||||
import org.kiwix.kiwixmobile.core.wifi_hotspot.HotspotStateReceiver
|
import org.kiwix.kiwixmobile.webserver.wifi_hotspot.HotspotStateReceiver
|
||||||
import org.kiwix.kiwixmobile.core.wifi_hotspot.HotspotStateReceiver.Callback
|
import org.kiwix.kiwixmobile.webserver.wifi_hotspot.HotspotStateReceiver.Callback
|
||||||
import org.kiwix.kiwixmobile.core.wifi_hotspot.IpAddressCallbacks
|
import org.kiwix.kiwixmobile.webserver.wifi_hotspot.IpAddressCallbacks
|
||||||
|
|
||||||
@Module
|
@Module
|
||||||
class ServiceModule {
|
class ServiceModule {
|
||||||
@ -41,12 +41,7 @@ class ServiceModule {
|
|||||||
jniKiwixLibrary: JNIKiwixLibrary,
|
jniKiwixLibrary: JNIKiwixLibrary,
|
||||||
kiwixServer: JNIKiwixServer,
|
kiwixServer: JNIKiwixServer,
|
||||||
ipAddressCallbacks: IpAddressCallbacks
|
ipAddressCallbacks: IpAddressCallbacks
|
||||||
): WebServerHelper =
|
): WebServerHelper = WebServerHelper(jniKiwixLibrary, kiwixServer, ipAddressCallbacks)
|
||||||
WebServerHelper(
|
|
||||||
jniKiwixLibrary,
|
|
||||||
kiwixServer,
|
|
||||||
ipAddressCallbacks
|
|
||||||
)
|
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@ServiceScope
|
@ServiceScope
|
||||||
@ -67,19 +62,15 @@ class ServiceModule {
|
|||||||
fun providesHotspotNotificationManager(
|
fun providesHotspotNotificationManager(
|
||||||
notificationManager: NotificationManager,
|
notificationManager: NotificationManager,
|
||||||
context: Context
|
context: Context
|
||||||
): HotspotNotificationManager =
|
): HotspotNotificationManager = HotspotNotificationManager(notificationManager, context)
|
||||||
HotspotNotificationManager(notificationManager, context)
|
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@ServiceScope
|
@ServiceScope
|
||||||
fun providesHotspotStateReceiver(
|
fun providesHotspotStateReceiver(callback: Callback): HotspotStateReceiver =
|
||||||
callback: Callback
|
|
||||||
): HotspotStateReceiver =
|
|
||||||
HotspotStateReceiver(callback)
|
HotspotStateReceiver(callback)
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@ServiceScope
|
@ServiceScope
|
||||||
fun providesHotspotStateReceiverCallback(
|
fun providesHotspotStateReceiverCallback(service: Service): HotspotStateReceiver.Callback =
|
||||||
service: Service
|
service as Callback
|
||||||
): HotspotStateReceiver.Callback = service as Callback
|
|
||||||
}
|
}
|
@ -16,7 +16,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.kiwix.kiwixmobile.di.modules
|
package org.kiwix.kiwixmobile.core.di.modules
|
||||||
|
|
||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
import androidx.lifecycle.ViewModelProvider
|
import androidx.lifecycle.ViewModelProvider
|
||||||
@ -25,7 +25,7 @@ import dagger.Module
|
|||||||
import dagger.multibindings.IntoMap
|
import dagger.multibindings.IntoMap
|
||||||
import org.kiwix.kiwixmobile.KiwixViewModelFactory
|
import org.kiwix.kiwixmobile.KiwixViewModelFactory
|
||||||
import org.kiwix.kiwixmobile.language.viewmodel.LanguageViewModel
|
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
|
import org.kiwix.kiwixmobile.zim_manager.ZimManageViewModel
|
||||||
|
|
||||||
@Module
|
@Module
|
@ -43,6 +43,7 @@ import org.kiwix.kiwixmobile.core.utils.SharedPreferenceUtil.PREF_KIWIX_MOBILE
|
|||||||
import org.kiwix.kiwixmobile.core.utils.UpdateUtils.reformatProviderUrl
|
import org.kiwix.kiwixmobile.core.utils.UpdateUtils.reformatProviderUrl
|
||||||
import org.kiwix.kiwixmobile.core.utils.files.FileUtils
|
import org.kiwix.kiwixmobile.core.utils.files.FileUtils
|
||||||
import org.kiwix.kiwixmobile.kiwixActivityComponent
|
import org.kiwix.kiwixmobile.kiwixActivityComponent
|
||||||
|
import org.kiwix.kiwixmobile.webserver.ZimHostActivity
|
||||||
import org.kiwix.kiwixmobile.zim_manager.ZimManageActivity
|
import org.kiwix.kiwixmobile.zim_manager.ZimManageActivity
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
@ -116,6 +117,10 @@ class KiwixMainActivity : CoreMainActivity() {
|
|||||||
override fun hasValidFileAndUrl(url: String?, zimFileReader: ZimFileReader?) =
|
override fun hasValidFileAndUrl(url: String?, zimFileReader: ZimFileReader?) =
|
||||||
super.hasValidFileAndUrl(url, zimFileReader) && url != homeUrl
|
super.hasValidFileAndUrl(url, zimFileReader) && url != homeUrl
|
||||||
|
|
||||||
|
override fun onHostBooksClicked() {
|
||||||
|
start<ZimHostActivity>()
|
||||||
|
}
|
||||||
|
|
||||||
override fun urlIsInvalid() =
|
override fun urlIsInvalid() =
|
||||||
super.urlIsInvalid() || currentWebView.url == homeUrl
|
super.urlIsInvalid() || currentWebView.url == homeUrl
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.kiwix.kiwixmobile.core.webserver;
|
package org.kiwix.kiwixmobile.webserver;
|
||||||
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
@ -29,7 +29,7 @@ import org.kiwix.kiwixlib.JNIKiwixException;
|
|||||||
import org.kiwix.kiwixlib.JNIKiwixLibrary;
|
import org.kiwix.kiwixlib.JNIKiwixLibrary;
|
||||||
import org.kiwix.kiwixlib.JNIKiwixServer;
|
import org.kiwix.kiwixlib.JNIKiwixServer;
|
||||||
import org.kiwix.kiwixmobile.core.utils.ServerUtils;
|
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;
|
import static org.kiwix.kiwixmobile.core.utils.ServerUtils.INVALID_IP;
|
||||||
|
|
@ -16,7 +16,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.kiwix.kiwixmobile.core.webserver;
|
package org.kiwix.kiwixmobile.webserver;
|
||||||
|
|
||||||
import android.app.ProgressDialog;
|
import android.app.ProgressDialog;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
@ -39,24 +39,26 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import kotlin.Unit;
|
import kotlin.Unit;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.kiwix.kiwixmobile.ActivityExtensionsKt;
|
||||||
import org.kiwix.kiwixmobile.core.R;
|
import org.kiwix.kiwixmobile.core.R;
|
||||||
import org.kiwix.kiwixmobile.core.R2;
|
import org.kiwix.kiwixmobile.core.R2;
|
||||||
import org.kiwix.kiwixmobile.core.base.BaseActivity;
|
import org.kiwix.kiwixmobile.core.base.BaseActivity;
|
||||||
import org.kiwix.kiwixmobile.core.utils.AlertDialogShower;
|
import org.kiwix.kiwixmobile.core.utils.AlertDialogShower;
|
||||||
import org.kiwix.kiwixmobile.core.utils.KiwixDialog;
|
import org.kiwix.kiwixmobile.core.utils.KiwixDialog;
|
||||||
import org.kiwix.kiwixmobile.core.utils.ServerUtils;
|
import org.kiwix.kiwixmobile.core.utils.ServerUtils;
|
||||||
import org.kiwix.kiwixmobile.core.wifi_hotspot.HotspotService;
|
|
||||||
import org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.SelectionMode;
|
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.BookOnDiskDelegate;
|
||||||
import org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.adapter.BooksOnDiskAdapter;
|
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;
|
||||||
|
import org.kiwix.kiwixmobile.webserver.wifi_hotspot.HotspotService;
|
||||||
|
|
||||||
import static org.kiwix.kiwixmobile.core.wifi_hotspot.HotspotService.ACTION_CHECK_IP_ADDRESS;
|
import static org.kiwix.kiwixmobile.webserver.wifi_hotspot.HotspotService.ACTION_CHECK_IP_ADDRESS;
|
||||||
import static org.kiwix.kiwixmobile.core.wifi_hotspot.HotspotService.ACTION_START_SERVER;
|
import static org.kiwix.kiwixmobile.webserver.wifi_hotspot.HotspotService.ACTION_START_SERVER;
|
||||||
import static org.kiwix.kiwixmobile.core.wifi_hotspot.HotspotService.ACTION_STOP_SERVER;
|
import static org.kiwix.kiwixmobile.webserver.wifi_hotspot.HotspotService.ACTION_STOP_SERVER;
|
||||||
|
|
||||||
public class ZimHostActivity extends BaseActivity implements
|
public class ZimHostActivity extends BaseActivity implements
|
||||||
ZimHostCallbacks, ZimHostContract.View {
|
ZimHostCallbacks, ZimHostContract.View {
|
||||||
|
|
||||||
@BindView(R2.id.startServerButton)
|
@BindView(R2.id.startServerButton)
|
||||||
Button startServerButton;
|
Button startServerButton;
|
||||||
@ -82,6 +84,10 @@ public class ZimHostActivity extends BaseActivity implements
|
|||||||
private ServiceConnection serviceConnection;
|
private ServiceConnection serviceConnection;
|
||||||
private ProgressDialog progressDialog;
|
private ProgressDialog progressDialog;
|
||||||
|
|
||||||
|
@Override protected void injection() {
|
||||||
|
ActivityExtensionsKt.getKiwixActivityComponent(this).inject(this);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
@ -139,11 +145,11 @@ public class ZimHostActivity extends BaseActivity implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void startHotspotHelper() {
|
private void startHotspotHelper() {
|
||||||
if (ServerUtils.isServerStarted) {
|
if (ServerUtils.isServerStarted) {
|
||||||
startService(createHotspotIntent(ACTION_STOP_SERVER));
|
startService(createHotspotIntent(ACTION_STOP_SERVER));
|
||||||
} else {
|
} else {
|
||||||
startHotspotManuallyDialog();
|
startHotspotManuallyDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private ArrayList<String> getSelectedBooksPath() {
|
private ArrayList<String> getSelectedBooksPath() {
|
||||||
@ -289,7 +295,7 @@ public class ZimHostActivity extends BaseActivity implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void addBooks(@Nullable List<BooksOnDiskListItem> books) {
|
@Override public void addBooks(@NotNull List<? extends BooksOnDiskListItem> books) {
|
||||||
booksAdapter.setItems(books);
|
booksAdapter.setItems(books);
|
||||||
}
|
}
|
||||||
|
|
@ -15,20 +15,12 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
package org.kiwix.kiwixmobile.webserver
|
||||||
|
|
||||||
package org.kiwix.kiwixmobile.core.webserver;
|
interface ZimHostCallbacks {
|
||||||
|
fun onServerStarted(ip: String)
|
||||||
import androidx.annotation.NonNull;
|
fun onServerStopped()
|
||||||
|
fun onServerFailedToStart()
|
||||||
public interface ZimHostCallbacks {
|
fun onIpAddressValid()
|
||||||
|
fun onIpAddressInvalid()
|
||||||
void onServerStarted(@NonNull String ip);
|
|
||||||
|
|
||||||
void onServerStopped();
|
|
||||||
|
|
||||||
void onServerFailedToStart();
|
|
||||||
|
|
||||||
void onIpAddressValid();
|
|
||||||
|
|
||||||
void onIpAddressInvalid();
|
|
||||||
}
|
}
|
@ -15,22 +15,17 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
package org.kiwix.kiwixmobile.webserver
|
||||||
|
|
||||||
package org.kiwix.kiwixmobile.core.webserver;
|
import org.kiwix.kiwixmobile.core.base.BaseContract
|
||||||
|
import org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.adapter.BooksOnDiskListItem
|
||||||
import java.util.List;
|
|
||||||
import org.kiwix.kiwixmobile.core.base.BaseContract;
|
|
||||||
import org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.adapter.BooksOnDiskListItem;
|
|
||||||
|
|
||||||
class ZimHostContract {
|
class ZimHostContract {
|
||||||
|
interface View : BaseContract.View<Presenter> {
|
||||||
interface View
|
fun addBooks(books: List<BooksOnDiskListItem>)
|
||||||
extends BaseContract.View<ZimHostContract.Presenter> {
|
|
||||||
void addBooks(List<BooksOnDiskListItem> books);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Presenter
|
interface Presenter : BaseContract.Presenter<View> {
|
||||||
extends BaseContract.Presenter<ZimHostContract.View> {
|
fun loadBooks()
|
||||||
void loadBooks();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -15,26 +15,14 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
package org.kiwix.kiwixmobile.webserver
|
||||||
|
|
||||||
package org.kiwix.kiwixmobile.core.webserver;
|
import dagger.Binds
|
||||||
|
import dagger.Module
|
||||||
import android.app.Activity;
|
import org.kiwix.kiwixmobile.core.di.ActivityScope
|
||||||
import dagger.Module;
|
|
||||||
import dagger.Provides;
|
|
||||||
import org.kiwix.kiwixmobile.core.di.ActivityScope;
|
|
||||||
|
|
||||||
@Module
|
@Module
|
||||||
public class ZimHostModule {
|
abstract class ZimHostModule {
|
||||||
|
@ActivityScope @Binds
|
||||||
@ActivityScope
|
abstract fun bindsZimHostPresenter(zimHostPresenter: ZimHostPresenter): ZimHostContract.Presenter
|
||||||
@Provides
|
|
||||||
ZimHostContract.Presenter provideZimHostPresenter(ZimHostPresenter zimHostPresenter) {
|
|
||||||
return zimHostPresenter;
|
|
||||||
}
|
|
||||||
|
|
||||||
@ActivityScope
|
|
||||||
@Provides Activity providesActivity(ZimHostActivity zimHostActivity) {
|
|
||||||
return zimHostActivity;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,56 @@
|
|||||||
|
/*
|
||||||
|
* 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() {
|
||||||
|
dataSource.languageCategorizedBooks
|
||||||
|
.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"
|
||||||
|
}
|
||||||
|
}
|
@ -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.Notification;
|
||||||
import android.app.NotificationChannel;
|
import android.app.NotificationChannel;
|
||||||
@ -30,7 +30,7 @@ import androidx.core.app.NotificationCompat;
|
|||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import org.kiwix.kiwixmobile.core.R;
|
import org.kiwix.kiwixmobile.core.R;
|
||||||
import org.kiwix.kiwixmobile.core.utils.Constants;
|
import org.kiwix.kiwixmobile.core.utils.Constants;
|
||||||
import org.kiwix.kiwixmobile.core.webserver.ZimHostActivity;
|
import org.kiwix.kiwixmobile.webserver.ZimHostActivity;
|
||||||
|
|
||||||
public class HotspotNotificationManager {
|
public class HotspotNotificationManager {
|
||||||
|
|
@ -16,7 +16,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.kiwix.kiwixmobile.core.wifi_hotspot;
|
package org.kiwix.kiwixmobile.webserver.wifi_hotspot;
|
||||||
|
|
||||||
import android.app.Service;
|
import android.app.Service;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
@ -26,15 +26,15 @@ import android.widget.Toast;
|
|||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import javax.inject.Inject;
|
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.R;
|
||||||
import org.kiwix.kiwixmobile.core.extensions.ContextExtensionsKt;
|
import org.kiwix.kiwixmobile.core.extensions.ContextExtensionsKt;
|
||||||
import org.kiwix.kiwixmobile.core.utils.ServerUtils;
|
import org.kiwix.kiwixmobile.core.utils.ServerUtils;
|
||||||
import org.kiwix.kiwixmobile.core.webserver.WebServerHelper;
|
import org.kiwix.kiwixmobile.webserver.WebServerHelper;
|
||||||
import org.kiwix.kiwixmobile.core.webserver.ZimHostCallbacks;
|
import org.kiwix.kiwixmobile.webserver.ZimHostCallbacks;
|
||||||
|
|
||||||
import static org.kiwix.kiwixmobile.core.webserver.ZimHostActivity.SELECTED_ZIM_PATHS_KEY;
|
import static org.kiwix.kiwixmobile.webserver.ZimHostActivity.SELECTED_ZIM_PATHS_KEY;
|
||||||
import static org.kiwix.kiwixmobile.core.wifi_hotspot.HotspotNotificationManager.HOTSPOT_NOTIFICATION_ID;
|
import static org.kiwix.kiwixmobile.webserver.wifi_hotspot.HotspotNotificationManager.HOTSPOT_NOTIFICATION_ID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* HotspotService is used to add a foreground service for the wifi hotspot.
|
* HotspotService is used to add a foreground service for the wifi hotspot.
|
||||||
@ -59,7 +59,7 @@ public class HotspotService extends Service
|
|||||||
HotspotStateReceiver hotspotStateReceiver;
|
HotspotStateReceiver hotspotStateReceiver;
|
||||||
|
|
||||||
@Override public void onCreate() {
|
@Override public void onCreate() {
|
||||||
CoreApp.getCoreComponent()
|
((KiwixApp) this.getApplicationContext()).getKiwixComponent()
|
||||||
.serviceComponent()
|
.serviceComponent()
|
||||||
.service(this)
|
.service(this)
|
||||||
.build()
|
.build()
|
@ -15,12 +15,12 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* 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.Context
|
||||||
import android.content.Intent
|
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.core.base.BaseBroadcastReceiver
|
||||||
|
import org.kiwix.kiwixmobile.webserver.wifi_hotspot.HotspotStateReceiver.HotspotState.DISABLED
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
const val EXTRA_WIFI_AP_STATE = "wifi_state"
|
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_ENABLED = 13
|
||||||
const val WIFI_AP_STATE_FAILED = 14
|
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 val action: String = ACTION_WIFI_AP_STATE
|
||||||
|
|
||||||
override fun onIntentWithActionReceived(context: Context, intent: Intent) {
|
override fun onIntentWithActionReceived(context: Context, intent: Intent) {
|
@ -16,7 +16,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.kiwix.kiwixmobile.core.wifi_hotspot;
|
package org.kiwix.kiwixmobile.webserver.wifi_hotspot;
|
||||||
|
|
||||||
public interface IpAddressCallbacks {
|
public interface IpAddressCallbacks {
|
||||||
|
|
@ -8,8 +8,6 @@
|
|||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
||||||
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
|
|
||||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
|
||||||
|
|
||||||
<!-- Device with versions >= Pie need this permission -->
|
<!-- Device with versions >= Pie need this permission -->
|
||||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||||
@ -47,7 +45,6 @@
|
|||||||
|
|
||||||
<activity android:name=".search.SearchActivity" />
|
<activity android:name=".search.SearchActivity" />
|
||||||
<activity android:name=".bookmark.BookmarksActivity" />
|
<activity android:name=".bookmark.BookmarksActivity" />
|
||||||
<activity android:name=".webserver.ZimHostActivity" />
|
|
||||||
|
|
||||||
<provider
|
<provider
|
||||||
android:name=".reader.ZimContentProvider"
|
android:name=".reader.ZimContentProvider"
|
||||||
@ -68,7 +65,6 @@
|
|||||||
android:resource="@xml/kiwix_widget_provider_info" />
|
android:resource="@xml/kiwix_widget_provider_info" />
|
||||||
</receiver>
|
</receiver>
|
||||||
|
|
||||||
<service android:name=".wifi_hotspot.HotspotService" />
|
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".error.ErrorActivity"
|
android:name=".error.ErrorActivity"
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.kiwix.kiwixmobile.di
|
package org.kiwix.kiwixmobile.core.di
|
||||||
|
|
||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
import dagger.MapKey
|
import dagger.MapKey
|
@ -18,12 +18,14 @@
|
|||||||
package org.kiwix.kiwixmobile.core.di.components
|
package org.kiwix.kiwixmobile.core.di.components
|
||||||
|
|
||||||
import android.app.Application
|
import android.app.Application
|
||||||
|
import android.app.NotificationManager
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.net.ConnectivityManager
|
import android.net.ConnectivityManager
|
||||||
import dagger.BindsInstance
|
import dagger.BindsInstance
|
||||||
import dagger.Component
|
import dagger.Component
|
||||||
import eu.mhutti1.utils.storage.StorageSelectDialog
|
import eu.mhutti1.utils.storage.StorageSelectDialog
|
||||||
import org.kiwix.kiwixmobile.core.CoreApp
|
import org.kiwix.kiwixmobile.core.CoreApp
|
||||||
|
import org.kiwix.kiwixmobile.core.StorageObserver
|
||||||
import org.kiwix.kiwixmobile.core.dao.FetchDownloadDao
|
import org.kiwix.kiwixmobile.core.dao.FetchDownloadDao
|
||||||
import org.kiwix.kiwixmobile.core.dao.NewBookDao
|
import org.kiwix.kiwixmobile.core.dao.NewBookDao
|
||||||
import org.kiwix.kiwixmobile.core.dao.NewLanguagesDao
|
import org.kiwix.kiwixmobile.core.dao.NewLanguagesDao
|
||||||
@ -43,7 +45,6 @@ import org.kiwix.kiwixmobile.core.search.AutoCompleteAdapter
|
|||||||
import org.kiwix.kiwixmobile.core.settings.CorePrefsFragment
|
import org.kiwix.kiwixmobile.core.settings.CorePrefsFragment
|
||||||
import org.kiwix.kiwixmobile.core.utils.BookUtils
|
import org.kiwix.kiwixmobile.core.utils.BookUtils
|
||||||
import org.kiwix.kiwixmobile.core.utils.SharedPreferenceUtil
|
import org.kiwix.kiwixmobile.core.utils.SharedPreferenceUtil
|
||||||
import org.kiwix.kiwixmobile.core.StorageObserver
|
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
@ -64,7 +65,6 @@ interface CoreComponent {
|
|||||||
fun build(): CoreComponent
|
fun build(): CoreComponent
|
||||||
}
|
}
|
||||||
|
|
||||||
fun serviceComponent(): ServiceComponent.Builder
|
|
||||||
fun zimReaderContainer(): ZimReaderContainer
|
fun zimReaderContainer(): ZimReaderContainer
|
||||||
fun sharedPrefUtil(): SharedPreferenceUtil
|
fun sharedPrefUtil(): SharedPreferenceUtil
|
||||||
fun zimFileReaderFactory(): ZimFileReader.Factory
|
fun zimFileReaderFactory(): ZimFileReader.Factory
|
||||||
@ -79,6 +79,7 @@ interface CoreComponent {
|
|||||||
fun connectivityManager(): ConnectivityManager
|
fun connectivityManager(): ConnectivityManager
|
||||||
fun context(): Context
|
fun context(): Context
|
||||||
fun downloader(): Downloader
|
fun downloader(): Downloader
|
||||||
|
fun notificationManager(): NotificationManager
|
||||||
|
|
||||||
fun inject(application: CoreApp)
|
fun inject(application: CoreApp)
|
||||||
fun inject(zimContentProvider: ZimContentProvider)
|
fun inject(zimContentProvider: ZimContentProvider)
|
||||||
|
@ -31,8 +31,6 @@ import org.kiwix.kiwixmobile.core.intro.IntroActivity;
|
|||||||
import org.kiwix.kiwixmobile.core.intro.IntroModule;
|
import org.kiwix.kiwixmobile.core.intro.IntroModule;
|
||||||
import org.kiwix.kiwixmobile.core.search.SearchActivity;
|
import org.kiwix.kiwixmobile.core.search.SearchActivity;
|
||||||
import org.kiwix.kiwixmobile.core.splash.SplashActivity;
|
import org.kiwix.kiwixmobile.core.splash.SplashActivity;
|
||||||
import org.kiwix.kiwixmobile.core.webserver.ZimHostActivity;
|
|
||||||
import org.kiwix.kiwixmobile.core.webserver.ZimHostModule;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dagger.Android annotation processor will create the sub-components. We also specify the modules
|
* Dagger.Android annotation processor will create the sub-components. We also specify the modules
|
||||||
@ -70,8 +68,4 @@ public abstract class ActivityBindingModule {
|
|||||||
@ActivityScope
|
@ActivityScope
|
||||||
@ContributesAndroidInjector
|
@ContributesAndroidInjector
|
||||||
public abstract HelpActivity provideHelpActivity();
|
public abstract HelpActivity provideHelpActivity();
|
||||||
|
|
||||||
@ActivityScope
|
|
||||||
@ContributesAndroidInjector(modules = ZimHostModule.class)
|
|
||||||
public abstract ZimHostActivity provideZimHostActivity();
|
|
||||||
}
|
}
|
||||||
|
@ -112,7 +112,6 @@ import org.kiwix.kiwixmobile.core.utils.LanguageUtils;
|
|||||||
import org.kiwix.kiwixmobile.core.utils.NetworkUtils;
|
import org.kiwix.kiwixmobile.core.utils.NetworkUtils;
|
||||||
import org.kiwix.kiwixmobile.core.utils.StyleUtils;
|
import org.kiwix.kiwixmobile.core.utils.StyleUtils;
|
||||||
import org.kiwix.kiwixmobile.core.utils.files.FileUtils;
|
import org.kiwix.kiwixmobile.core.utils.files.FileUtils;
|
||||||
import org.kiwix.kiwixmobile.core.webserver.ZimHostActivity;
|
|
||||||
import org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.adapter.BookOnDiskDelegate;
|
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.BooksOnDiskAdapter;
|
||||||
import org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.adapter.BooksOnDiskListItem;
|
import org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.adapter.BooksOnDiskListItem;
|
||||||
@ -889,13 +888,14 @@ public abstract class CoreMainActivity extends BaseActivity implements WebViewCa
|
|||||||
intentSupportKiwix.putExtra(EXTRA_EXTERNAL_LINK, true);
|
intentSupportKiwix.putExtra(EXTRA_EXTERNAL_LINK, true);
|
||||||
openExternalUrl(intentSupportKiwix);
|
openExternalUrl(intentSupportKiwix);
|
||||||
} else if (itemId == R.id.menu_host_books) {
|
} else if (itemId == R.id.menu_host_books) {
|
||||||
Intent intent = new Intent(this, ZimHostActivity.class);
|
onHostBooksClicked();
|
||||||
startActivity(intent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected abstract void onHostBooksClicked();
|
||||||
|
|
||||||
protected abstract void createNewTab();
|
protected abstract void createNewTab();
|
||||||
|
|
||||||
/** Creates the full screen AddNoteDialog, which is a DialogFragment */
|
/** Creates the full screen AddNoteDialog, which is a DialogFragment */
|
||||||
|
@ -1,62 +0,0 @@
|
|||||||
/*
|
|
||||||
* Kiwix Android
|
|
||||||
* Copyright (c) 2019 Kiwix <android.kiwix.org>
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.kiwix.kiwixmobile.core.webserver;
|
|
||||||
|
|
||||||
import android.util.Log;
|
|
||||||
import io.reactivex.SingleObserver;
|
|
||||||
import io.reactivex.disposables.Disposable;
|
|
||||||
import java.util.List;
|
|
||||||
import javax.inject.Inject;
|
|
||||||
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;
|
|
||||||
|
|
||||||
@ActivityScope
|
|
||||||
class ZimHostPresenter extends BasePresenter<ZimHostContract.View>
|
|
||||||
implements ZimHostContract.Presenter {
|
|
||||||
|
|
||||||
private static final String TAG = "ZimHostPresenter";
|
|
||||||
private final DataSource dataSource;
|
|
||||||
|
|
||||||
@Inject ZimHostPresenter(DataSource dataSource) {
|
|
||||||
this.dataSource = dataSource;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void loadBooks() {
|
|
||||||
dataSource.getLanguageCategorizedBooks()
|
|
||||||
.subscribe(new SingleObserver<List<BooksOnDiskListItem>>() {
|
|
||||||
@Override
|
|
||||||
public void onSubscribe(Disposable d) {
|
|
||||||
compositeDisposable.add(d);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSuccess(List<BooksOnDiskListItem> books) {
|
|
||||||
view.addBooks(books);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onError(Throwable e) {
|
|
||||||
Log.e(TAG, "Unable to load books", e);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
@ -25,7 +25,7 @@ import dagger.Module
|
|||||||
import dagger.multibindings.IntoMap
|
import dagger.multibindings.IntoMap
|
||||||
import org.kiwix.kiwixmobile.custom.CustomViewModelFactory
|
import org.kiwix.kiwixmobile.custom.CustomViewModelFactory
|
||||||
import org.kiwix.kiwixmobile.custom.download.CustomDownloadViewModel
|
import org.kiwix.kiwixmobile.custom.download.CustomDownloadViewModel
|
||||||
import org.kiwix.kiwixmobile.di.ViewModelKey
|
import org.kiwix.kiwixmobile.core.di.ViewModelKey
|
||||||
|
|
||||||
@Module
|
@Module
|
||||||
abstract class CustomViewModelModule {
|
abstract class CustomViewModelModule {
|
||||||
|
@ -74,9 +74,14 @@ class CustomMainActivity : CoreMainActivity() {
|
|||||||
val onCreateOptionsMenu = super.onCreateOptionsMenu(menu)
|
val onCreateOptionsMenu = super.onCreateOptionsMenu(menu)
|
||||||
menu?.findItem(R.id.menu_help)?.isVisible = false
|
menu?.findItem(R.id.menu_help)?.isVisible = false
|
||||||
menu?.findItem(R.id.menu_openfile)?.isVisible = false
|
menu?.findItem(R.id.menu_openfile)?.isVisible = false
|
||||||
|
menu?.findItem(R.id.menu_host_books)?.isVisible = false
|
||||||
return onCreateOptionsMenu
|
return onCreateOptionsMenu
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onHostBooksClicked() {
|
||||||
|
TODO("not implemented")
|
||||||
|
}
|
||||||
|
|
||||||
override fun createWebClient(
|
override fun createWebClient(
|
||||||
webViewCallback: WebViewCallback,
|
webViewCallback: WebViewCallback,
|
||||||
zimReaderContainer: ZimReaderContainer
|
zimReaderContainer: ZimReaderContainer
|
||||||
|
Loading…
x
Reference in New Issue
Block a user