mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-16 10:56:50 -04:00
1581 part two, committing core app dependency injection files, not running git hooks so that I can check in with @macgills and see if I'm on partly the right track.
This commit is contained in:
parent
b555ef04a3
commit
d38b4e83fc
@ -17,6 +17,7 @@ apply plugin: 'com.android.library'
|
||||
apply plugin: KiwixConfigurationPlugin
|
||||
apply plugin: 'io.objectbox'
|
||||
apply plugin: 'com.jakewharton.butterknife'
|
||||
apply plugin: 'kotlin-kapt'
|
||||
|
||||
android {
|
||||
buildTypes {
|
||||
@ -36,6 +37,9 @@ dependencies {
|
||||
// use jdk8 java.time backport, as long app < Build.VERSION_CODES.O
|
||||
implementation(Libs.threetenabp)
|
||||
|
||||
implementation 'com.google.dagger:dagger:2.25.2'
|
||||
kapt 'com.google.dagger:dagger-compiler:2.25.2'
|
||||
|
||||
// Get kiwixlib online if it is not populated locally
|
||||
if (!shouldUseLocalVersion()) {
|
||||
api(Libs.kiwixlib)
|
||||
@ -66,4 +70,5 @@ dependencies {
|
||||
implementation(Libs.android_arch_lifecycle_extensions)
|
||||
implementation(Libs.objectbox_kotlin)
|
||||
implementation(Libs.objectbox_rxjava)
|
||||
|
||||
}
|
||||
|
@ -36,10 +36,12 @@ import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.inject.Inject;
|
||||
import org.kiwix.kiwixmobile.core.CoreApp;
|
||||
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.di.components.BookmarksActivityComponent;
|
||||
import org.kiwix.kiwixmobile.core.extensions.ImageViewExtensionsKt;
|
||||
import org.kiwix.kiwixmobile.core.main.CoreMainActivity;
|
||||
import org.kiwix.kiwixmobile.core.reader.ZimReaderContainer;
|
||||
@ -50,6 +52,8 @@ import static org.kiwix.kiwixmobile.core.utils.Constants.EXTRA_CHOSE_X_URL;
|
||||
public class BookmarksActivity extends BaseActivity implements BookmarksContract.View,
|
||||
BookmarksAdapter.OnItemClickListener {
|
||||
|
||||
BookmarksActivityComponent bookmarksActivityComponent;
|
||||
|
||||
private final List<BookmarkItem> bookmarksList = new ArrayList<>();
|
||||
private final List<BookmarkItem> allBookmarks = new ArrayList<>();
|
||||
private final List<BookmarkItem> deleteList = new ArrayList<>();
|
||||
@ -58,7 +62,7 @@ public class BookmarksActivity extends BaseActivity implements BookmarksContract
|
||||
Toolbar toolbar;
|
||||
@BindView(R2.id.recycler_view)
|
||||
RecyclerView recyclerView;
|
||||
@Inject
|
||||
//@Inject
|
||||
BookmarksContract.Presenter presenter;
|
||||
@Inject
|
||||
ZimReaderContainer zimReaderContainer;
|
||||
@ -111,6 +115,8 @@ public class BookmarksActivity extends BaseActivity implements BookmarksContract
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
bookmarksActivityComponent = CoreApp.getCoreComponent().bookmarksActivityComponent().build();
|
||||
bookmarksActivityComponent.inject(this);
|
||||
super.onCreate(savedInstanceState);
|
||||
presenter.attachView(this);
|
||||
setContentView(R.layout.activity_bookmarks);
|
||||
|
@ -79,6 +79,11 @@ interface CoreComponent {
|
||||
fun connectivityManager(): ConnectivityManager
|
||||
fun context(): Context
|
||||
fun downloader(): Downloader
|
||||
fun bookmarksActivityComponent(): BookmarksActivityComponent.Builder
|
||||
fun errorActivityComponent(): ErrorActivityComponent.Builder
|
||||
fun historyActivityComponent(): HistoryActivityComponent.Builder
|
||||
fun helpActivityComponent(): HelpActivityComponent.Builder
|
||||
fun zimHostActivityComponent(): ZimHostActivityComponent.Builder
|
||||
|
||||
fun inject(application: CoreApp)
|
||||
fun inject(zimContentProvider: ZimContentProvider)
|
||||
|
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* 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.di.components
|
||||
|
||||
import dagger.Subcomponent
|
||||
import org.kiwix.kiwixmobile.core.di.ActivityScope
|
||||
import org.kiwix.kiwixmobile.core.error.ErrorActivity
|
||||
|
||||
@ActivityScope
|
||||
@Subcomponent
|
||||
interface ErrorActivityComponent {
|
||||
|
||||
@Subcomponent.Builder
|
||||
interface Builder {
|
||||
fun build(): ErrorActivityComponent
|
||||
}
|
||||
|
||||
fun inject(errorActivity: ErrorActivity)
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* 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.di.components
|
||||
|
||||
import dagger.Subcomponent
|
||||
import org.kiwix.kiwixmobile.core.di.ActivityScope
|
||||
import org.kiwix.kiwixmobile.core.help.HelpActivity
|
||||
|
||||
@ActivityScope
|
||||
@Subcomponent
|
||||
interface HelpActivityComponent {
|
||||
|
||||
@Subcomponent.Builder
|
||||
interface Builder {
|
||||
fun build(): HelpActivityComponent
|
||||
}
|
||||
|
||||
fun inject(helpActivity: HelpActivity)
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* 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.di.components
|
||||
|
||||
import dagger.Subcomponent
|
||||
import org.kiwix.kiwixmobile.core.di.ActivityScope
|
||||
import org.kiwix.kiwixmobile.core.history.HistoryActivity
|
||||
import org.kiwix.kiwixmobile.core.history.HistoryModule
|
||||
|
||||
@ActivityScope
|
||||
@Subcomponent(modules = [HistoryModule::class])
|
||||
interface HistoryActivityComponent {
|
||||
|
||||
@Subcomponent.Builder
|
||||
interface Builder {
|
||||
fun build(): HistoryActivityComponent
|
||||
}
|
||||
|
||||
fun inject(historyActivity: HistoryActivity)
|
||||
}
|
@ -20,15 +20,16 @@ package org.kiwix.kiwixmobile.core.di.modules;
|
||||
|
||||
import dagger.Module;
|
||||
import dagger.android.ContributesAndroidInjector;
|
||||
import javax.inject.Inject;
|
||||
import org.kiwix.kiwixmobile.core.bookmark.BookmarksActivity;
|
||||
import org.kiwix.kiwixmobile.core.bookmark.BookmarksModule;
|
||||
import org.kiwix.kiwixmobile.core.di.ActivityScope;
|
||||
import org.kiwix.kiwixmobile.core.di.components.SearchActivityComponent;
|
||||
import org.kiwix.kiwixmobile.core.error.ErrorActivity;
|
||||
import org.kiwix.kiwixmobile.core.help.HelpActivity;
|
||||
import org.kiwix.kiwixmobile.core.history.HistoryActivity;
|
||||
import org.kiwix.kiwixmobile.core.history.HistoryModule;
|
||||
import org.kiwix.kiwixmobile.core.search.SearchActivity;
|
||||
import org.kiwix.kiwixmobile.core.splash.CoreSplashActivity;
|
||||
import org.kiwix.kiwixmobile.core.webserver.ZimHostActivity;
|
||||
import org.kiwix.kiwixmobile.core.webserver.ZimHostModule;
|
||||
|
||||
@ -42,7 +43,7 @@ import org.kiwix.kiwixmobile.core.webserver.ZimHostModule;
|
||||
public abstract class ActivityBindingModule {
|
||||
|
||||
@ActivityScope
|
||||
@ContributesAndroidInjector
|
||||
@ContributesAndroidInjector(modules = ActivityModule.class)
|
||||
public abstract SearchActivity provideSearchActivity();
|
||||
|
||||
@ActivityScope
|
||||
|
@ -33,9 +33,12 @@ import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.util.List;
|
||||
import javax.inject.Inject;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.kiwix.kiwixmobile.core.CoreApp;
|
||||
import org.kiwix.kiwixmobile.core.R;
|
||||
import org.kiwix.kiwixmobile.core.R2;
|
||||
import org.kiwix.kiwixmobile.core.base.BaseActivity;
|
||||
import org.kiwix.kiwixmobile.core.di.components.ErrorActivityComponent;
|
||||
import org.kiwix.kiwixmobile.core.entity.LibraryNetworkEntity;
|
||||
import org.kiwix.kiwixmobile.core.dao.NewBookDao;
|
||||
import org.kiwix.kiwixmobile.core.splash.CoreSplashActivity;
|
||||
@ -46,6 +49,8 @@ import static org.kiwix.kiwixmobile.core.utils.LanguageUtils.getCurrentLocale;
|
||||
|
||||
public class ErrorActivity extends BaseActivity {
|
||||
|
||||
ErrorActivityComponent errorActivityComponent;
|
||||
|
||||
@Inject
|
||||
NewBookDao bookDao;
|
||||
@Inject
|
||||
@ -79,6 +84,10 @@ public class ErrorActivity extends BaseActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
errorActivityComponent = CoreApp.getCoreComponent().errorActivityComponent().build();
|
||||
errorActivityComponent.inject(this);
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_kiwix_error);
|
||||
Intent callingIntent = getIntent();
|
||||
|
@ -27,15 +27,20 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||
import butterknife.BindView;
|
||||
import butterknife.OnClick;
|
||||
import java.util.HashMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.kiwix.kiwixmobile.core.CoreApp;
|
||||
import org.kiwix.kiwixmobile.core.R;
|
||||
import org.kiwix.kiwixmobile.core.R2;
|
||||
import org.kiwix.kiwixmobile.core.base.BaseActivity;
|
||||
import org.kiwix.kiwixmobile.core.di.components.HelpActivityComponent;
|
||||
import org.kiwix.kiwixmobile.core.utils.LanguageUtils;
|
||||
|
||||
import static org.kiwix.kiwixmobile.core.utils.Constants.CONTACT_EMAIL_ADDRESS;
|
||||
|
||||
public class HelpActivity extends BaseActivity {
|
||||
|
||||
HelpActivityComponent helpActivityComponent;
|
||||
|
||||
private final HashMap<String, String> titleDescriptionMap = new HashMap<>();
|
||||
|
||||
@BindView(R2.id.activity_help_toolbar)
|
||||
@ -45,6 +50,9 @@ public class HelpActivity extends BaseActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
helpActivityComponent = CoreApp.getCoreComponent().helpActivityComponent().build();
|
||||
helpActivityComponent.inject(this);
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_help);
|
||||
setSupportActionBar(toolbar);
|
||||
|
@ -39,10 +39,13 @@ import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.inject.Inject;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.kiwix.kiwixmobile.core.CoreApp;
|
||||
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.di.components.HistoryActivityComponent;
|
||||
import org.kiwix.kiwixmobile.core.extensions.ImageViewExtensionsKt;
|
||||
import org.kiwix.kiwixmobile.core.main.CoreMainActivity;
|
||||
import org.kiwix.kiwixmobile.core.reader.ZimReaderContainer;
|
||||
@ -123,9 +126,13 @@ public class HistoryActivity extends BaseActivity implements HistoryContract.Vie
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
HistoryActivityComponent historyActivityComponent;
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
historyActivityComponent = CoreApp.getCoreComponent().historyActivityComponent().build();
|
||||
historyActivityComponent.inject(this);
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
presenter.attachView(this);
|
||||
setContentView(R.layout.activity_history);
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
package org.kiwix.kiwixmobile.core.webserver;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
@ -39,9 +40,12 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.inject.Inject;
|
||||
import kotlin.Unit;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.kiwix.kiwixmobile.core.CoreApp;
|
||||
import org.kiwix.kiwixmobile.core.R;
|
||||
import org.kiwix.kiwixmobile.core.R2;
|
||||
import org.kiwix.kiwixmobile.core.base.BaseActivity;
|
||||
import org.kiwix.kiwixmobile.core.di.components.ZimHostActivityComponent;
|
||||
import org.kiwix.kiwixmobile.core.utils.AlertDialogShower;
|
||||
import org.kiwix.kiwixmobile.core.utils.KiwixDialog;
|
||||
import org.kiwix.kiwixmobile.core.utils.ServerUtils;
|
||||
@ -58,6 +62,8 @@ import static org.kiwix.kiwixmobile.core.wifi_hotspot.HotspotService.ACTION_STOP
|
||||
public class ZimHostActivity extends BaseActivity implements
|
||||
ZimHostCallbacks, ZimHostContract.View {
|
||||
|
||||
ZimHostActivityComponent zimHostActivityComponent;
|
||||
|
||||
@BindView(R2.id.startServerButton)
|
||||
Button startServerButton;
|
||||
@BindView(R2.id.server_textView)
|
||||
@ -68,7 +74,7 @@ public class ZimHostActivity extends BaseActivity implements
|
||||
@Inject
|
||||
ZimHostContract.Presenter presenter;
|
||||
|
||||
@Inject
|
||||
//@Inject
|
||||
AlertDialogShower alertDialogShower;
|
||||
|
||||
private static final String TAG = "ZimHostActivity";
|
||||
@ -84,6 +90,8 @@ public class ZimHostActivity extends BaseActivity implements
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
zimHostActivityComponent = CoreApp.getCoreComponent().zimHostActivityComponent().build();
|
||||
zimHostActivityComponent.inject(this);
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_zim_host);
|
||||
|
||||
@ -129,7 +137,7 @@ public class ZimHostActivity extends BaseActivity implements
|
||||
if (getSelectedBooksPath().size() > 0) {
|
||||
startHotspotHelper();
|
||||
} else {
|
||||
Toast.makeText(ZimHostActivity.this, R.string.no_books_selected_toast_message,
|
||||
Toast.makeText(this, R.string.no_books_selected_toast_message,
|
||||
Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
} else {
|
||||
|
@ -1,6 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/kiwix_search_widget_layout_id_height"
|
||||
android:layout_marginLeft="@dimen/kiwix_search_widget_margin"
|
||||
@ -26,7 +27,7 @@
|
||||
android:layout_weight="0.7"
|
||||
android:text="@string/search_widget_text"
|
||||
android:textColor="@color/grey"
|
||||
/>
|
||||
tools:text="@string/search_widget_text" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/search_widget_star"
|
||||
|
Loading…
x
Reference in New Issue
Block a user