diff --git a/app/build.gradle b/app/build.gradle
index 38f3de2a3..6d236fe91 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -70,6 +70,7 @@ dependencies {
compile 'com.jakewharton:disklrucache:2.0.2'
compile 'org.jsoup:jsoup:1.8.3'
compile 'io.reactivex:rxandroid:1.0.1'
+ compile 'io.reactivex:rxjava:1.1.0'
compile 'com.f2prateek.rx.preferences:rx-preferences:1.0.1'
compile "com.pushtorefresh.storio:sqlite:$STORIO_VERSION"
compile "com.pushtorefresh.storio:sqlite-annotations:$STORIO_VERSION"
@@ -86,6 +87,7 @@ dependencies {
provided "frankiesardo:icepick-processor:$ICEPICK_VERSION"
compile 'com.github.dmytrodanylyk.android-process-button:library:1.0.4'
compile 'eu.davidea:flexible-adapter:4.1.0@aar'
+ compile 'com.nononsenseapps:filepicker:2.5.0'
compile "com.google.dagger:dagger:$DAGGER_VERSION"
apt "com.google.dagger:dagger-compiler:$DAGGER_VERSION"
@@ -98,9 +100,6 @@ dependencies {
compile('com.github.afollestad.material-dialogs:core:0.8.5.2@aar') {
transitive = true
}
- compile('com.github.afollestad.material-dialogs:commons:0.8.5.2@aar') {
- transitive = true
- }
testCompile 'junit:junit:4.12'
testCompile "org.hamcrest:hamcrest-core:$HAMCREST_VERSION"
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 11309792c..50f2b8608 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -40,6 +40,12 @@
android:parentActivityName=".ui.main.MainActivity" >
+
+
+
diff --git a/app/src/main/java/eu/kanade/mangafeed/App.java b/app/src/main/java/eu/kanade/mangafeed/App.java
index 071f6dad5..4c76c466b 100644
--- a/app/src/main/java/eu/kanade/mangafeed/App.java
+++ b/app/src/main/java/eu/kanade/mangafeed/App.java
@@ -3,6 +3,7 @@ package eu.kanade.mangafeed;
import android.app.Application;
import android.content.Context;
+import org.acra.ACRA;
import org.acra.annotation.ReportsCrashes;
import eu.kanade.mangafeed.injection.ComponentReflectionInjector;
@@ -12,30 +13,29 @@ import eu.kanade.mangafeed.injection.module.AppModule;
import timber.log.Timber;
@ReportsCrashes(
- formUri = "http://couch.kanade.eu/acra-manga/_design/acra-storage/_update/report",
+ formUri = "http://mangafeed.kanade.eu/crash_report",
reportType = org.acra.sender.HttpSender.Type.JSON,
httpMethod = org.acra.sender.HttpSender.Method.PUT,
- formUriBasicAuthLogin="test",
- formUriBasicAuthPassword="test"
+ excludeMatchingSharedPreferencesKeys={".*username.*",".*password.*"}
)
public class App extends Application {
- AppComponent mApplicationComponent;
- ComponentReflectionInjector mComponentInjector;
+ AppComponent applicationComponent;
+ ComponentReflectionInjector componentInjector;
@Override
public void onCreate() {
super.onCreate();
if (BuildConfig.DEBUG) Timber.plant(new Timber.DebugTree());
- mApplicationComponent = DaggerAppComponent.builder()
+ applicationComponent = DaggerAppComponent.builder()
.appModule(new AppModule(this))
.build();
- mComponentInjector =
- new ComponentReflectionInjector<>(AppComponent.class, mApplicationComponent);
+ componentInjector =
+ new ComponentReflectionInjector<>(AppComponent.class, applicationComponent);
- //ACRA.init(this);
+ ACRA.init(this);
}
public static App get(Context context) {
@@ -43,15 +43,15 @@ public class App extends Application {
}
public AppComponent getComponent() {
- return mApplicationComponent;
+ return applicationComponent;
}
public ComponentReflectionInjector getComponentReflection() {
- return mComponentInjector;
+ return componentInjector;
}
// Needed to replace the component with a test specific one
public void setComponent(AppComponent applicationComponent) {
- mApplicationComponent = applicationComponent;
+ this.applicationComponent = applicationComponent;
}
}
diff --git a/app/src/main/java/eu/kanade/mangafeed/data/database/DatabaseHelper.java b/app/src/main/java/eu/kanade/mangafeed/data/database/DatabaseHelper.java
index 814c1e3bc..779f692d0 100644
--- a/app/src/main/java/eu/kanade/mangafeed/data/database/DatabaseHelper.java
+++ b/app/src/main/java/eu/kanade/mangafeed/data/database/DatabaseHelper.java
@@ -27,6 +27,7 @@ import eu.kanade.mangafeed.data.database.models.ChapterSyncStorIOSQLiteGetResolv
import eu.kanade.mangafeed.data.database.models.ChapterSyncStorIOSQLitePutResolver;
import eu.kanade.mangafeed.data.database.models.Manga;
import eu.kanade.mangafeed.data.database.models.MangaStorIOSQLiteDeleteResolver;
+import eu.kanade.mangafeed.data.database.models.MangaStorIOSQLiteGetResolver;
import eu.kanade.mangafeed.data.database.models.MangaStorIOSQLitePutResolver;
import eu.kanade.mangafeed.data.database.resolvers.MangaWithUnreadGetResolver;
import eu.kanade.mangafeed.data.database.tables.ChapterSyncTable;
@@ -46,7 +47,7 @@ public class DatabaseHelper {
.sqliteOpenHelper(new DbOpenHelper(context))
.addTypeMapping(Manga.class, SQLiteTypeMapping.builder()
.putResolver(new MangaStorIOSQLitePutResolver())
- .getResolver(new MangaWithUnreadGetResolver())
+ .getResolver(new MangaStorIOSQLiteGetResolver())
.deleteResolver(new MangaStorIOSQLiteDeleteResolver())
.build())
.addTypeMapping(Chapter.class, SQLiteTypeMapping.builder()
@@ -94,6 +95,7 @@ public class DatabaseHelper {
.query(favoriteMangasWithUnreadQuery)
.observesTables(MangaTable.TABLE, ChapterTable.TABLE)
.build())
+ .withGetResolver(MangaWithUnreadGetResolver.instance)
.prepare();
}
diff --git a/app/src/main/java/eu/kanade/mangafeed/data/database/resolvers/MangaWithUnreadGetResolver.java b/app/src/main/java/eu/kanade/mangafeed/data/database/resolvers/MangaWithUnreadGetResolver.java
index e438513e7..546bf3420 100644
--- a/app/src/main/java/eu/kanade/mangafeed/data/database/resolvers/MangaWithUnreadGetResolver.java
+++ b/app/src/main/java/eu/kanade/mangafeed/data/database/resolvers/MangaWithUnreadGetResolver.java
@@ -9,12 +9,14 @@ import eu.kanade.mangafeed.data.database.tables.MangaTable;
public class MangaWithUnreadGetResolver extends MangaStorIOSQLiteGetResolver {
+ public static final MangaWithUnreadGetResolver instance = new MangaWithUnreadGetResolver();
+
@Override
+ @NonNull
public Manga mapFromCursor(@NonNull Cursor cursor) {
Manga manga = super.mapFromCursor(cursor);
int unreadColumn = cursor.getColumnIndex(MangaTable.COLUMN_UNREAD);
- if (unreadColumn != -1)
- manga.unread = cursor.getInt(unreadColumn);
+ manga.unread = cursor.getInt(unreadColumn);
return manga;
}
diff --git a/app/src/main/java/eu/kanade/mangafeed/data/preference/PreferencesHelper.java b/app/src/main/java/eu/kanade/mangafeed/data/preference/PreferencesHelper.java
index 1ca74cef8..6a57da63a 100644
--- a/app/src/main/java/eu/kanade/mangafeed/data/preference/PreferencesHelper.java
+++ b/app/src/main/java/eu/kanade/mangafeed/data/preference/PreferencesHelper.java
@@ -2,15 +2,17 @@ package eu.kanade.mangafeed.data.preference;
import android.content.Context;
import android.content.SharedPreferences;
+import android.os.Environment;
import android.preference.PreferenceManager;
import com.f2prateek.rx.preferences.Preference;
import com.f2prateek.rx.preferences.RxSharedPreferences;
+import java.io.File;
+
import eu.kanade.mangafeed.R;
import eu.kanade.mangafeed.data.chaptersync.BaseChapterSync;
import eu.kanade.mangafeed.data.source.base.Source;
-import eu.kanade.mangafeed.util.DiskUtils;
import rx.Observable;
public class PreferencesHelper {
@@ -24,12 +26,21 @@ public class PreferencesHelper {
private static final String CHAPTERSYNC_ACCOUNT_USERNAME = "pref_chaptersync_username_";
private static final String CHAPTERSYNC_ACCOUNT_PASSWORD = "pref_chaptersync_password_";
+ private File defaultDownloadsDir;
+
public PreferencesHelper(Context context) {
this.context = context;
PreferenceManager.setDefaultValues(context, R.xml.pref_reader, false);
prefs = PreferenceManager.getDefaultSharedPreferences(context);
rxPrefs = RxSharedPreferences.create(prefs);
+
+ defaultDownloadsDir = new File(Environment.getExternalStorageDirectory() +
+ File.separator + context.getString(R.string.app_name), "downloads");
+
+ // Create default directory
+ if (getDownloadsDirectory().equals(defaultDownloadsDir.getAbsolutePath()))
+ defaultDownloadsDir.mkdirs();
}
private String getKey(int keyResource) {
@@ -108,7 +119,11 @@ public class PreferencesHelper {
public String getDownloadsDirectory() {
return prefs.getString(getKey(R.string.pref_download_directory_key),
- DiskUtils.getStorageDirectories(context)[0]);
+ defaultDownloadsDir.getAbsolutePath());
+ }
+
+ public void setDownloadsDirectory(String path) {
+ prefs.edit().putString(getKey(R.string.pref_download_directory_key), path).apply();
}
public int getDownloadThreads() {
diff --git a/app/src/main/java/eu/kanade/mangafeed/data/sync/LibraryUpdateService.java b/app/src/main/java/eu/kanade/mangafeed/data/sync/LibraryUpdateService.java
index c6d96071c..b705467c8 100644
--- a/app/src/main/java/eu/kanade/mangafeed/data/sync/LibraryUpdateService.java
+++ b/app/src/main/java/eu/kanade/mangafeed/data/sync/LibraryUpdateService.java
@@ -32,7 +32,6 @@ public class LibraryUpdateService extends Service {
@Inject SourceManager sourceManager;
private Subscription updateSubscription;
- private Subscription favoriteMangasSubscription;
public static final int UPDATE_NOTIFICATION_ID = 1;
@@ -68,14 +67,9 @@ public class LibraryUpdateService extends Service {
return START_NOT_STICKY;
}
- if (favoriteMangasSubscription != null && !favoriteMangasSubscription.isUnsubscribed())
- favoriteMangasSubscription.unsubscribe();
-
- favoriteMangasSubscription = db.getFavoriteMangas().createObservable()
+ Observable.fromCallable(() -> db.getFavoriteMangas().executeAsBlocking())
.subscribe(mangas -> {
- // Don't receive further db updates
- favoriteMangasSubscription.unsubscribe();
- this.startUpdating(mangas, startId);
+ startUpdating(mangas, startId);
});
return START_STICKY;
diff --git a/app/src/main/java/eu/kanade/mangafeed/ui/setting/SettingsAccountsFragment.java b/app/src/main/java/eu/kanade/mangafeed/ui/setting/SettingsAccountsFragment.java
index fe04f989b..eb021022b 100644
--- a/app/src/main/java/eu/kanade/mangafeed/ui/setting/SettingsAccountsFragment.java
+++ b/app/src/main/java/eu/kanade/mangafeed/ui/setting/SettingsAccountsFragment.java
@@ -3,6 +3,9 @@ package eu.kanade.mangafeed.ui.setting;
import android.os.Bundle;
import android.preference.PreferenceCategory;
import android.preference.PreferenceScreen;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
import java.util.List;
@@ -24,13 +27,18 @@ public class SettingsAccountsFragment extends SettingsNestedFragment {
public static SettingsNestedFragment newInstance(int resourcePreference, int resourceTitle) {
SettingsNestedFragment fragment = new SettingsAccountsFragment();
- fragment.setBundle(resourcePreference, resourceTitle);
+ fragment.setArgs(resourcePreference, resourceTitle);
return fragment;
}
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
App.get(getActivity()).getComponent().inject(this);
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedSate) {
+ View view = super.onCreateView(inflater, container, savedSate);
PreferenceScreen screen = getPreferenceScreen();
@@ -60,6 +68,7 @@ public class SettingsAccountsFragment extends SettingsNestedFragment {
chapterSyncCategory.addPreference(dialog);
}
+ return view;
}
private List