Create new module to contain database related files

This commit is contained in:
Shinokuni 2020-01-02 15:19:57 +01:00
parent 0b841193b5
commit fe78ea4f68
83 changed files with 349 additions and 212 deletions

View File

@ -13,13 +13,6 @@ android {
versionName "1.1.1"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
javaCompileOptions {
annotationProcessorOptions {
arguments = [
"room.incremental": "true"
]
}
}
}
testOptions {
@ -53,6 +46,7 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(':readropslibrary')
implementation project(':readropsdb')
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.google.android.material:material:1.0.0'
@ -80,14 +74,6 @@ dependencies {
implementation 'androidx.lifecycle:lifecycle-extensions:2.1.0'
kapt 'androidx.lifecycle:lifecycle-common-java8:2.1.0'
implementation 'androidx.room:room-runtime:2.2.2'
kapt 'androidx.room:room-compiler:2.2.2'
implementation 'androidx.room:room-rxjava2:2.2.2'
implementation 'androidx.paging:paging-runtime:2.1.0'
implementation 'androidx.paging:paging-common:2.1.0'
implementation 'joda-time:joda-time:2.10.5'
implementation 'org.jsoup:jsoup:1.12.1'
implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'

View File

@ -19,8 +19,8 @@ import androidx.recyclerview.widget.LinearLayoutManager;
import com.afollestad.materialdialogs.MaterialDialog;
import com.readrops.app.R;
import com.readrops.app.adapters.AccountTypeListAdapter;
import com.readrops.app.database.entities.account.Account;
import com.readrops.app.database.entities.account.AccountType;
import com.readrops.readropsdb.entities.account.Account;
import com.readrops.readropsdb.entities.account.AccountType;
import com.readrops.app.databinding.ActivityAccountTypeListBinding;
import com.readrops.app.utils.Utils;
import com.readrops.app.viewmodels.AccountViewModel;

View File

@ -12,8 +12,8 @@ import androidx.databinding.DataBindingUtil;
import androidx.lifecycle.ViewModelProviders;
import com.readrops.app.R;
import com.readrops.app.database.entities.account.Account;
import com.readrops.app.database.entities.account.AccountType;
import com.readrops.readropsdb.entities.account.Account;
import com.readrops.readropsdb.entities.account.AccountType;
import com.readrops.app.databinding.ActivityAddAccountBinding;
import com.readrops.app.utils.SharedPreferencesManager;
import com.readrops.app.utils.Utils;

View File

@ -25,8 +25,8 @@ import com.mikepenz.fastadapter.commons.utils.DiffCallback;
import com.mikepenz.fastadapter.commons.utils.FastAdapterDiffUtil;
import com.readrops.app.R;
import com.readrops.app.adapters.AccountArrayAdapter;
import com.readrops.app.database.entities.Feed;
import com.readrops.app.database.entities.account.Account;
import com.readrops.readropsdb.entities.Feed;
import com.readrops.readropsdb.entities.account.Account;
import com.readrops.app.databinding.ActivityAddFeedBinding;
import com.readrops.app.utils.FeedInsertionResult;
import com.readrops.app.utils.ParsingResult;

View File

@ -39,8 +39,8 @@ import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.appbar.CollapsingToolbarLayout;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.readrops.app.R;
import com.readrops.app.database.entities.Item;
import com.readrops.app.database.pojo.ItemWithFeed;
import com.readrops.readropsdb.entities.Item;
import com.readrops.readropsdb.pojo.ItemWithFeed;
import com.readrops.app.utils.DateUtils;
import com.readrops.app.utils.GlideApp;
import com.readrops.app.utils.PermissionManager;

View File

@ -42,10 +42,12 @@ import com.mikepenz.materialdrawer.model.SecondaryDrawerItem;
import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem;
import com.readrops.app.R;
import com.readrops.app.adapters.MainItemListAdapter;
import com.readrops.app.database.entities.Feed;
import com.readrops.app.database.entities.Folder;
import com.readrops.app.database.entities.account.Account;
import com.readrops.app.database.pojo.ItemWithFeed;
import com.readrops.readropsdb.entities.Feed;
import com.readrops.readropsdb.entities.Folder;
import com.readrops.readropsdb.entities.account.Account;
import com.readrops.readropsdb.filters.FilterType;
import com.readrops.readropsdb.filters.ListSortType;
import com.readrops.readropsdb.pojo.ItemWithFeed;
import com.readrops.app.utils.DrawerManager;
import com.readrops.app.utils.GlideApp;
import com.readrops.app.utils.ReadropsItemTouchCallback;
@ -233,12 +235,12 @@ public class MainActivity extends AppCompatActivity implements SwipeRefreshLayou
switch (id) {
case DrawerManager.ARTICLES_ITEM_ID:
viewModel.setFilterType(MainViewModel.FilterType.NO_FILTER);
viewModel.setFilterType(FilterType.NO_FILTER);
scrollToTop = true;
viewModel.invalidate();
break;
case DrawerManager.READ_LATER_ID:
viewModel.setFilterType(MainViewModel.FilterType.READ_IT_LATER_FILTER);
viewModel.setFilterType(FilterType.READ_IT_LATER_FILTER);
viewModel.invalidate();
break;
case DrawerManager.ABOUT_ID:
@ -255,7 +257,7 @@ public class MainActivity extends AppCompatActivity implements SwipeRefreshLayou
drawer.closeDrawer();
viewModel.setFilterFeedId((int) drawerItem.getIdentifier());
viewModel.setFilterType(MainViewModel.FilterType.FEED_FILTER);
viewModel.setFilterType(FilterType.FEED_FILTER);
viewModel.invalidate();
}
}
@ -410,7 +412,7 @@ public class MainActivity extends AppCompatActivity implements SwipeRefreshLayou
.doOnError(throwable -> Utils.showSnackbar(rootLayout, throwable.getMessage()))
.subscribe();
if (viewModel.getFilterType() == MainViewModel.FilterType.READ_IT_LATER_FILTER)
if (viewModel.getFilterType() == FilterType.READ_IT_LATER_FILTER)
adapter.notifyItemChanged(viewHolder.getAdapterPosition());
}
}
@ -726,8 +728,4 @@ public class MainActivity extends AppCompatActivity implements SwipeRefreshLayou
super.onSaveInstanceState(outState);
}
public enum ListSortType {
NEWEST_TO_OLDEST,
OLDEST_TO_NEWEST
}
}

View File

@ -14,8 +14,8 @@ import androidx.lifecycle.ViewModelProviders;
import com.afollestad.materialdialogs.MaterialDialog;
import com.readrops.app.R;
import com.readrops.app.database.entities.Folder;
import com.readrops.app.database.entities.account.Account;
import com.readrops.readropsdb.entities.Folder;
import com.readrops.readropsdb.entities.account.Account;
import com.readrops.app.databinding.ActivityManageFeedsFoldersBinding;
import com.readrops.app.fragments.FeedsFragment;
import com.readrops.app.fragments.FoldersFragment;

View File

@ -7,7 +7,7 @@ import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import com.readrops.app.R;
import com.readrops.app.database.entities.account.Account;
import com.readrops.readropsdb.entities.account.Account;
import com.readrops.app.fragments.settings.AccountSettingsFragment;
import com.readrops.app.fragments.settings.SettingsFragment;

View File

@ -12,7 +12,7 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.readrops.app.R;
import com.readrops.app.database.entities.account.Account;
import com.readrops.readropsdb.entities.account.Account;
import java.util.List;

View File

@ -8,7 +8,7 @@ import androidx.databinding.DataBindingUtil;
import androidx.recyclerview.widget.RecyclerView;
import com.readrops.app.R;
import com.readrops.app.database.entities.account.AccountType;
import com.readrops.readropsdb.entities.account.AccountType;
import com.readrops.app.databinding.AccountTypeItemBinding;
import java.util.List;

View File

@ -14,7 +14,7 @@ import androidx.recyclerview.widget.RecyclerView;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.readrops.app.R;
import com.readrops.app.database.pojo.FeedWithFolder;
import com.readrops.readropsdb.pojo.FeedWithFolder;
import com.readrops.app.utils.GlideApp;
import java.util.List;

View File

@ -12,8 +12,8 @@ import androidx.recyclerview.widget.ListAdapter;
import androidx.recyclerview.widget.RecyclerView;
import com.readrops.app.R;
import com.readrops.app.database.entities.Folder;
import com.readrops.app.database.pojo.FolderWithFeedCount;
import com.readrops.readropsdb.entities.Folder;
import com.readrops.readropsdb.pojo.FolderWithFeedCount;
import com.readrops.app.databinding.FolderLayoutBinding;
import java.util.List;

View File

@ -26,8 +26,8 @@ import com.bumptech.glide.request.RequestOptions;
import com.bumptech.glide.request.transition.DrawableCrossFadeFactory;
import com.bumptech.glide.util.ViewPreloadSizeProvider;
import com.readrops.app.R;
import com.readrops.app.database.entities.Item;
import com.readrops.app.database.pojo.ItemWithFeed;
import com.readrops.readropsdb.entities.Item;
import com.readrops.readropsdb.pojo.ItemWithFeed;
import com.readrops.app.databinding.ListItemBinding;
import com.readrops.app.utils.DateUtils;
import com.readrops.app.utils.GlideRequests;

View File

@ -15,10 +15,10 @@ import androidx.lifecycle.ViewModelProviders;
import com.google.android.material.textfield.TextInputEditText;
import com.readrops.app.R;
import com.readrops.app.database.entities.Feed;
import com.readrops.app.database.entities.Folder;
import com.readrops.app.database.entities.account.Account;
import com.readrops.app.database.pojo.FeedWithFolder;
import com.readrops.readropsdb.entities.Feed;
import com.readrops.readropsdb.entities.Folder;
import com.readrops.readropsdb.entities.account.Account;
import com.readrops.readropsdb.pojo.FeedWithFolder;
import com.readrops.app.viewmodels.ManageFeedsFoldersViewModel;
import java.util.ArrayList;

View File

@ -9,8 +9,8 @@ import android.view.ViewGroup
import androidx.databinding.DataBindingUtil
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import com.readrops.app.R
import com.readrops.app.database.entities.account.Account
import com.readrops.app.database.pojo.FeedWithFolder
import com.readrops.readropsdb.entities.account.Account
import com.readrops.readropsdb.pojo.FeedWithFolder
import com.readrops.app.databinding.FeedOptionsLayoutBinding
import com.readrops.app.utils.ReadropsKeys.ACCOUNT

View File

@ -16,9 +16,9 @@ import androidx.recyclerview.widget.LinearLayoutManager;
import com.afollestad.materialdialogs.MaterialDialog;
import com.readrops.app.R;
import com.readrops.app.adapters.FeedsAdapter;
import com.readrops.app.database.entities.Feed;
import com.readrops.app.database.entities.account.Account;
import com.readrops.app.database.pojo.FeedWithFolder;
import com.readrops.readropsdb.entities.Feed;
import com.readrops.readropsdb.entities.account.Account;
import com.readrops.readropsdb.pojo.FeedWithFolder;
import com.readrops.app.databinding.FragmentFeedsBinding;
import com.readrops.app.utils.SharedPreferencesManager;
import com.readrops.app.utils.Utils;

View File

@ -7,7 +7,7 @@ import android.view.ViewGroup
import androidx.databinding.DataBindingUtil
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import com.readrops.app.R
import com.readrops.app.database.entities.Folder
import com.readrops.readropsdb.entities.Folder
import com.readrops.app.databinding.FolderOptionsLayoutBinding
class FolderOptionsDialogFragment : BottomSheetDialogFragment() {

View File

@ -17,8 +17,8 @@ import androidx.recyclerview.widget.LinearLayoutManager;
import com.afollestad.materialdialogs.MaterialDialog;
import com.readrops.app.R;
import com.readrops.app.adapters.FoldersAdapter;
import com.readrops.app.database.entities.Folder;
import com.readrops.app.database.entities.account.Account;
import com.readrops.readropsdb.entities.Folder;
import com.readrops.readropsdb.entities.account.Account;
import com.readrops.app.databinding.FragmentFoldersBinding;
import com.readrops.app.utils.SharedPreferencesManager;
import com.readrops.app.utils.Utils;

View File

@ -26,8 +26,8 @@ import com.readrops.app.R;
import com.readrops.app.ReadropsApp;
import com.readrops.app.activities.AddAccountActivity;
import com.readrops.app.activities.ManageFeedsFoldersActivity;
import com.readrops.app.database.entities.account.Account;
import com.readrops.app.database.entities.account.AccountType;
import com.readrops.readropsdb.entities.account.Account;
import com.readrops.readropsdb.entities.account.AccountType;
import com.readrops.app.utils.PermissionManager;
import com.readrops.app.utils.Utils;
import com.readrops.app.utils.matchers.OPMLMatcher;

View File

@ -8,7 +8,7 @@ import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
import com.readrops.app.R;
import com.readrops.app.database.Database;
import com.readrops.readropsdb.Database;
import com.readrops.app.utils.feedscolors.FeedsColorsIntentService;
import java.util.ArrayList;

View File

@ -6,12 +6,12 @@ import android.content.Intent;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.readrops.app.database.Database;
import com.readrops.app.database.entities.Feed;
import com.readrops.app.database.entities.Folder;
import com.readrops.app.database.entities.Item;
import com.readrops.app.database.entities.account.Account;
import com.readrops.app.database.entities.account.AccountType;
import com.readrops.readropsdb.Database;
import com.readrops.readropsdb.entities.Feed;
import com.readrops.readropsdb.entities.Folder;
import com.readrops.readropsdb.entities.Item;
import com.readrops.readropsdb.entities.account.Account;
import com.readrops.readropsdb.entities.account.AccountType;
import com.readrops.app.utils.FeedInsertionResult;
import com.readrops.app.utils.ParsingResult;
import com.readrops.app.utils.feedscolors.FeedColorsKt;

View File

@ -7,15 +7,16 @@ import android.util.TimingLogger;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.readrops.app.database.entities.Feed;
import com.readrops.app.database.entities.Folder;
import com.readrops.app.database.entities.Item;
import com.readrops.app.database.entities.account.Account;
import com.readrops.readropsdb.entities.Feed;
import com.readrops.readropsdb.entities.Folder;
import com.readrops.readropsdb.entities.Item;
import com.readrops.readropsdb.entities.account.Account;
import com.readrops.app.utils.FeedInsertionResult;
import com.readrops.app.utils.matchers.FeedMatcher;
import com.readrops.app.utils.matchers.ItemMatcher;
import com.readrops.app.utils.ParsingResult;
import com.readrops.app.utils.Utils;
import com.readrops.readropslibrary.services.Credentials;
import com.readrops.readropslibrary.services.SyncType;
import com.readrops.readropslibrary.services.freshrss.FreshRSSAPI;
import com.readrops.readropslibrary.services.freshrss.FreshRSSCredentials;
@ -44,7 +45,7 @@ public class FreshRSSRepository extends ARepository<FreshRSSAPI> {
@Override
protected FreshRSSAPI createAPI() {
if (account != null)
return new FreshRSSAPI(account.toCredentials());
return new FreshRSSAPI(Credentials.toCredentials(account));
return null;
}
@ -52,9 +53,9 @@ public class FreshRSSRepository extends ARepository<FreshRSSAPI> {
@Override
public Single<Boolean> login(Account account, boolean insert) {
if (api == null)
api = new FreshRSSAPI(account.toCredentials());
api = new FreshRSSAPI(Credentials.toCredentials(account));
else
api.setCredentials(account.toCredentials());
api.setCredentials(Credentials.toCredentials(account));
return api.login(account.getLogin(), account.getPassword())
.flatMap(token -> {

View File

@ -6,9 +6,9 @@ import android.app.Application;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.readrops.app.database.entities.Feed;
import com.readrops.app.database.entities.Item;
import com.readrops.app.database.entities.account.Account;
import com.readrops.readropsdb.entities.Feed;
import com.readrops.readropsdb.entities.Item;
import com.readrops.readropsdb.entities.account.Account;
import com.readrops.app.utils.FeedInsertionResult;
import com.readrops.app.utils.matchers.FeedMatcher;
import com.readrops.app.utils.HtmlParser;

View File

@ -7,15 +7,16 @@ import android.util.TimingLogger;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.readrops.app.database.entities.Feed;
import com.readrops.app.database.entities.Folder;
import com.readrops.app.database.entities.Item;
import com.readrops.app.database.entities.account.Account;
import com.readrops.readropsdb.entities.Feed;
import com.readrops.readropsdb.entities.Folder;
import com.readrops.readropsdb.entities.Item;
import com.readrops.readropsdb.entities.account.Account;
import com.readrops.app.utils.FeedInsertionResult;
import com.readrops.app.utils.matchers.FeedMatcher;
import com.readrops.app.utils.matchers.ItemMatcher;
import com.readrops.app.utils.ParsingResult;
import com.readrops.app.utils.Utils;
import com.readrops.readropslibrary.services.Credentials;
import com.readrops.readropslibrary.services.SyncType;
import com.readrops.readropslibrary.services.nextcloudnews.NextNewsAPI;
import com.readrops.readropslibrary.services.nextcloudnews.NextNewsSyncData;
@ -51,7 +52,7 @@ public class NextNewsRepository extends ARepository<NextNewsAPI> {
@Override
protected NextNewsAPI createAPI() {
if (account != null)
return new NextNewsAPI(account.toCredentials());
return new NextNewsAPI(Credentials.toCredentials(account));
return null;
}
@ -60,9 +61,9 @@ public class NextNewsRepository extends ARepository<NextNewsAPI> {
public Single<Boolean> login(Account account, boolean insert) {
return Single.<NextNewsUser>create(emitter -> {
if (api == null)
api = new NextNewsAPI(account.toCredentials());
api = new NextNewsAPI(Credentials.toCredentials(account));
else
api.setCredentials(account.toCredentials());
api.setCredentials(Credentials.toCredentials(account));
NextNewsUser user = api.login();

View File

@ -26,9 +26,9 @@ import com.mikepenz.materialdrawer.model.SecondaryDrawerItem;
import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem;
import com.mikepenz.materialdrawer.model.interfaces.IProfile;
import com.readrops.app.R;
import com.readrops.app.database.entities.Feed;
import com.readrops.app.database.entities.Folder;
import com.readrops.app.database.entities.account.Account;
import com.readrops.readropsdb.entities.Feed;
import com.readrops.readropsdb.entities.Folder;
import com.readrops.readropsdb.entities.account.Account;
import java.util.ArrayList;
import java.util.HashMap;

View File

@ -10,7 +10,7 @@ import androidx.annotation.StringRes;
import com.mikepenz.fastadapter.FastAdapter;
import com.mikepenz.fastadapter.items.AbstractItem;
import com.readrops.app.R;
import com.readrops.app.database.entities.Feed;
import com.readrops.readropsdb.entities.Feed;
import org.jetbrains.annotations.NotNull;

View File

@ -9,7 +9,7 @@ import androidx.annotation.NonNull;
import com.mikepenz.fastadapter.FastAdapter;
import com.mikepenz.fastadapter.items.AbstractItem;
import com.readrops.app.R;
import com.readrops.app.database.entities.Feed;
import com.readrops.readropsdb.entities.Feed;
import org.jetbrains.annotations.NotNull;

View File

@ -12,7 +12,7 @@ import androidx.annotation.ColorInt;
import androidx.annotation.Nullable;
import com.readrops.app.R;
import com.readrops.app.database.pojo.ItemWithFeed;
import com.readrops.readropsdb.pojo.ItemWithFeed;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;

View File

@ -1,7 +1,7 @@
package com.readrops.app.utils.feedscolors
import androidx.palette.graphics.Palette
import com.readrops.app.database.entities.Feed
import com.readrops.readropsdb.entities.Feed
import com.readrops.app.utils.HtmlParser
import com.readrops.app.utils.Utils

View File

@ -6,8 +6,8 @@ import androidx.core.app.NotificationCompat
import androidx.core.app.NotificationManagerCompat
import com.readrops.app.R
import com.readrops.app.ReadropsApp
import com.readrops.app.database.Database
import com.readrops.app.database.entities.Feed
import com.readrops.readropsdb.Database
import com.readrops.readropsdb.entities.Feed
import com.readrops.app.utils.ReadropsKeys.FEEDS
class FeedsColorsIntentService : IntentService("FeedsColorsIntentService") {

View File

@ -1,7 +1,7 @@
package com.readrops.app.utils.matchers;
import com.readrops.app.database.entities.Feed;
import com.readrops.app.database.entities.account.Account;
import com.readrops.readropsdb.entities.Feed;
import com.readrops.readropsdb.entities.account.Account;
import com.readrops.readropslibrary.localfeed.atom.ATOMFeed;
import com.readrops.readropslibrary.localfeed.json.JSONFeed;
import com.readrops.readropslibrary.localfeed.rss.RSSChannel;

View File

@ -1,7 +1,7 @@
package com.readrops.app.utils.matchers;
import com.readrops.app.database.entities.Feed;
import com.readrops.app.database.entities.Item;
import com.readrops.readropsdb.entities.Feed;
import com.readrops.readropsdb.entities.Item;
import com.readrops.app.utils.DateUtils;
import com.readrops.app.utils.Utils;
import com.readrops.readropslibrary.localfeed.atom.ATOMEntry;

View File

@ -2,8 +2,8 @@ package com.readrops.app.utils.matchers
import android.content.Context
import com.readrops.app.R
import com.readrops.app.database.entities.Feed
import com.readrops.app.database.entities.Folder
import com.readrops.readropsdb.entities.Feed
import com.readrops.readropsdb.entities.Folder
import com.readrops.readropslibrary.opml.model.Body
import com.readrops.readropslibrary.opml.model.Head
import com.readrops.readropslibrary.opml.model.OPML

View File

@ -7,11 +7,11 @@ import android.util.Log;
import androidx.annotation.NonNull;
import androidx.lifecycle.AndroidViewModel;
import com.readrops.app.database.Database;
import com.readrops.app.database.entities.Feed;
import com.readrops.app.database.entities.Folder;
import com.readrops.app.database.entities.account.Account;
import com.readrops.app.database.entities.account.AccountType;
import com.readrops.readropsdb.Database;
import com.readrops.readropsdb.entities.Feed;
import com.readrops.readropsdb.entities.Folder;
import com.readrops.readropsdb.entities.account.Account;
import com.readrops.readropsdb.entities.account.AccountType;
import com.readrops.app.repositories.ARepository;
import com.readrops.app.utils.matchers.OPMLMatcher;
import com.readrops.readropslibrary.opml.OPMLParser;

View File

@ -7,8 +7,8 @@ import androidx.annotation.NonNull;
import androidx.lifecycle.AndroidViewModel;
import androidx.lifecycle.LiveData;
import com.readrops.app.database.Database;
import com.readrops.app.database.entities.account.Account;
import com.readrops.readropsdb.Database;
import com.readrops.readropsdb.entities.account.Account;
import com.readrops.app.repositories.ARepository;
import com.readrops.app.utils.FeedInsertionResult;
import com.readrops.app.utils.HtmlParser;

View File

@ -9,9 +9,9 @@ import androidx.core.content.FileProvider;
import androidx.lifecycle.AndroidViewModel;
import androidx.lifecycle.LiveData;
import com.readrops.app.database.Database;
import com.readrops.app.database.dao.ItemDao;
import com.readrops.app.database.pojo.ItemWithFeed;
import com.readrops.readropsdb.Database;
import com.readrops.readropsdb.dao.ItemDao;
import com.readrops.readropsdb.pojo.ItemWithFeed;
import java.io.File;
import java.io.FileOutputStream;

View File

@ -9,14 +9,15 @@ import androidx.lifecycle.MediatorLiveData;
import androidx.paging.LivePagedListBuilder;
import androidx.paging.PagedList;
import com.readrops.app.activities.MainActivity;
import com.readrops.app.database.Database;
import com.readrops.app.database.ItemsListQueryBuilder;
import com.readrops.app.database.RoomFactoryWrapper;
import com.readrops.app.database.entities.Feed;
import com.readrops.app.database.entities.Folder;
import com.readrops.app.database.entities.account.Account;
import com.readrops.app.database.pojo.ItemWithFeed;
import com.readrops.readropsdb.Database;
import com.readrops.readropsdb.ItemsListQueryBuilder;
import com.readrops.readropsdb.RoomFactoryWrapper;
import com.readrops.readropsdb.entities.Feed;
import com.readrops.readropsdb.entities.Folder;
import com.readrops.readropsdb.entities.account.Account;
import com.readrops.readropsdb.filters.FilterType;
import com.readrops.readropsdb.filters.ListSortType;
import com.readrops.readropsdb.pojo.ItemWithFeed;
import com.readrops.app.repositories.ARepository;
import java.util.ArrayList;
@ -48,7 +49,7 @@ public class MainViewModel extends AndroidViewModel {
queryBuilder = new ItemsListQueryBuilder();
queryBuilder.setFilterType(FilterType.NO_FILTER);
queryBuilder.setSortType(MainActivity.ListSortType.NEWEST_TO_OLDEST);
queryBuilder.setSortType(ListSortType.NEWEST_TO_OLDEST);
db = Database.getInstance(application);
itemsWithFeed = new MediatorLiveData<>();
@ -99,11 +100,11 @@ public class MainViewModel extends AndroidViewModel {
return queryBuilder.getFilterType();
}
public void setSortType(MainActivity.ListSortType sortType) {
public void setSortType(ListSortType sortType) {
queryBuilder.setSortType(sortType);
}
public MainActivity.ListSortType getSortType() {
public ListSortType getSortType() {
return queryBuilder.getSortType();
}
@ -242,11 +243,5 @@ public class MainViewModel extends AndroidViewModel {
});
}
public enum FilterType {
FEED_FILTER,
READ_IT_LATER_FILTER,
NO_FILTER
}
//endregion
}

View File

@ -6,12 +6,12 @@ import androidx.annotation.NonNull;
import androidx.lifecycle.AndroidViewModel;
import androidx.lifecycle.LiveData;
import com.readrops.app.database.Database;
import com.readrops.app.database.entities.Feed;
import com.readrops.app.database.entities.Folder;
import com.readrops.app.database.entities.account.Account;
import com.readrops.app.database.pojo.FeedWithFolder;
import com.readrops.app.database.pojo.FolderWithFeedCount;
import com.readrops.readropsdb.Database;
import com.readrops.readropsdb.entities.Feed;
import com.readrops.readropsdb.entities.Folder;
import com.readrops.readropsdb.entities.account.Account;
import com.readrops.readropsdb.pojo.FeedWithFolder;
import com.readrops.readropsdb.pojo.FolderWithFeedCount;
import com.readrops.app.repositories.ARepository;
import java.util.List;

View File

@ -53,7 +53,6 @@
<string name="add_account">Ajouter un compte</string>
<string name="no_feed">Aucun flux</string>
<string name="choose_account">Choisir un compte</string>
<string name="local_account">Compte local</string>
<string name="feeds_and_folders">Flux et dossiers</string>
<string name="account">Compte</string>
<string name="manage_feeds_folders">Gérer les flux et dossiers</string>

View File

@ -51,14 +51,10 @@
<string name="account_name">Account name</string>
<string name="login">Login</string>
<string name="password">Password</string>
<string name="nextcloud_news" translatable="false">Nextcloud News</string>
<string name="account_settings">Account settings</string>
<string name="add_account">Add account</string>
<string name="no_feed">No feed</string>
<string name="choose_account">Choose an account</string>
<string name="local_account">Local account</string>
<string name="freshrss" translatable="false">Freshrss</string>
<string name="feedly" translatable="false">Feedly</string>
<string name="feeds_and_folders">Feeds and folders</string>
<string name="account">Account</string>
<string name="manage_feeds_folders">Manage feeds and folders</string>

1
readropsdb/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/build

54
readropsdb/build.gradle Normal file
View File

@ -0,0 +1,54 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
minSdkVersion 21
targetSdkVersion 29
versionCode 1
versionName "1.0"
javaCompileOptions {
annotationProcessorOptions {
arguments = [
"room.incremental": "true"
]
}
}
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles 'consumer-rules.pro'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
api 'androidx.room:room-runtime:2.2.3'
kapt 'androidx.room:room-compiler:2.2.3'
implementation 'androidx.room:room-rxjava2:2.2.3'
api 'androidx.paging:paging-runtime:2.1.1'
api 'androidx.paging:paging-common:2.1.1'
api 'joda-time:joda-time:2.10.5'
}

View File

21
readropsdb/proguard-rules.pro vendored Normal file
View File

@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

View File

@ -0,0 +1,27 @@
package com.readrops.readropsdb;
import android.content.Context;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("com.readrops.readropsdb.test", appContext.getPackageName());
}
}

View File

@ -0,0 +1,2 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.readrops.readropsdb" />

View File

@ -1,8 +1,8 @@
package com.readrops.app.database;
package com.readrops.readropsdb;
import androidx.room.TypeConverter;
import com.readrops.app.database.entities.account.AccountType;
import com.readrops.readropsdb.entities.account.AccountType;
import org.joda.time.LocalDateTime;

View File

@ -1,4 +1,4 @@
package com.readrops.app.database;
package com.readrops.readropsdb;
import android.content.Context;
@ -6,14 +6,14 @@ import androidx.room.Room;
import androidx.room.RoomDatabase;
import androidx.room.TypeConverters;
import com.readrops.app.database.dao.AccountDao;
import com.readrops.app.database.dao.FeedDao;
import com.readrops.app.database.dao.FolderDao;
import com.readrops.app.database.dao.ItemDao;
import com.readrops.app.database.entities.account.Account;
import com.readrops.app.database.entities.Feed;
import com.readrops.app.database.entities.Folder;
import com.readrops.app.database.entities.Item;
import com.readrops.readropsdb.dao.AccountDao;
import com.readrops.readropsdb.dao.FeedDao;
import com.readrops.readropsdb.dao.FolderDao;
import com.readrops.readropsdb.dao.ItemDao;
import com.readrops.readropsdb.entities.account.Account;
import com.readrops.readropsdb.entities.Feed;
import com.readrops.readropsdb.entities.Folder;
import com.readrops.readropsdb.entities.Item;
@androidx.room.Database(entities = {Feed.class, Item.class, Folder.class, Account.class}, version = 1, exportSchema = false)

View File

@ -1,10 +1,10 @@
package com.readrops.app.database;
package com.readrops.readropsdb;
import androidx.sqlite.db.SupportSQLiteQuery;
import androidx.sqlite.db.SupportSQLiteQueryBuilder;
import com.readrops.app.activities.MainActivity;
import com.readrops.app.viewmodels.MainViewModel;
import com.readrops.readropsdb.filters.FilterType;
import com.readrops.readropsdb.filters.ListSortType;
public class ItemsListQueryBuilder {
@ -25,8 +25,8 @@ public class ItemsListQueryBuilder {
private int filterFeedId;
private int accountId;
private MainViewModel.FilterType filterType;
private MainActivity.ListSortType sortType;
private FilterType filterType;
private ListSortType sortType;
public ItemsListQueryBuilder() {
queryBuilder = SupportSQLiteQueryBuilder.builder(SELECT_ALL_JOIN);
@ -64,7 +64,7 @@ public class ItemsListQueryBuilder {
queryBuilder.selection(buildWhereClause(), new String[0]);
if (sortType == MainActivity.ListSortType.NEWEST_TO_OLDEST)
if (sortType == ListSortType.NEWEST_TO_OLDEST)
queryBuilder.orderBy(ORDER_BY_ASC);
else
queryBuilder.orderBy(ORDER_BY_DESC);
@ -88,19 +88,19 @@ public class ItemsListQueryBuilder {
this.filterFeedId = filterFeedId;
}
public MainViewModel.FilterType getFilterType() {
public FilterType getFilterType() {
return filterType;
}
public void setFilterType(MainViewModel.FilterType filterType) {
public void setFilterType(FilterType filterType) {
this.filterType = filterType;
}
public MainActivity.ListSortType getSortType() {
public ListSortType getSortType() {
return sortType;
}
public void setSortType(MainActivity.ListSortType sortType) {
public void setSortType(ListSortType sortType) {
this.sortType = sortType;
}

View File

@ -1,4 +1,4 @@
package com.readrops.app.database;
package com.readrops.readropsdb;
import androidx.annotation.NonNull;
import androidx.paging.DataSource;

View File

@ -1,10 +1,10 @@
package com.readrops.app.database.dao;
package com.readrops.readropsdb.dao;
import androidx.lifecycle.LiveData;
import androidx.room.Dao;
import androidx.room.Query;
import com.readrops.app.database.entities.account.Account;
import com.readrops.readropsdb.entities.account.Account;
import java.util.List;

View File

@ -1,4 +1,4 @@
package com.readrops.app.database.dao;
package com.readrops.readropsdb.dao;
import androidx.room.Delete;
import androidx.room.Insert;

View File

@ -1,4 +1,4 @@
package com.readrops.app.database.dao;
package com.readrops.readropsdb.dao;
import androidx.lifecycle.LiveData;
@ -7,9 +7,9 @@ import androidx.room.Query;
import androidx.room.RoomWarnings;
import androidx.room.Transaction;
import com.readrops.app.database.entities.Feed;
import com.readrops.app.database.entities.account.Account;
import com.readrops.app.database.pojo.FeedWithFolder;
import com.readrops.readropsdb.entities.Feed;
import com.readrops.readropsdb.entities.account.Account;
import com.readrops.readropsdb.pojo.FeedWithFolder;
import java.util.ArrayList;
import java.util.List;

View File

@ -1,13 +1,13 @@
package com.readrops.app.database.dao;
package com.readrops.readropsdb.dao;
import androidx.lifecycle.LiveData;
import androidx.room.Dao;
import androidx.room.Query;
import androidx.room.Transaction;
import com.readrops.app.database.entities.Folder;
import com.readrops.app.database.entities.account.Account;
import com.readrops.app.database.pojo.FolderWithFeedCount;
import com.readrops.readropsdb.entities.Folder;
import com.readrops.readropsdb.entities.account.Account;
import com.readrops.readropsdb.pojo.FolderWithFeedCount;
import java.util.ArrayList;
import java.util.List;

View File

@ -1,4 +1,4 @@
package com.readrops.app.database.dao;
package com.readrops.readropsdb.dao;
import androidx.lifecycle.LiveData;
@ -9,10 +9,10 @@ import androidx.room.RawQuery;
import androidx.room.RoomWarnings;
import androidx.sqlite.db.SupportSQLiteQuery;
import com.readrops.app.database.entities.Feed;
import com.readrops.app.database.entities.Folder;
import com.readrops.app.database.entities.Item;
import com.readrops.app.database.pojo.ItemWithFeed;
import com.readrops.readropsdb.entities.Feed;
import com.readrops.readropsdb.entities.Folder;
import com.readrops.readropsdb.entities.Item;
import com.readrops.readropsdb.pojo.ItemWithFeed;
import java.util.List;

View File

@ -1,4 +1,4 @@
package com.readrops.app.database.entities;
package com.readrops.readropsdb.entities;
import android.os.Parcel;
@ -11,7 +11,7 @@ import androidx.room.ForeignKey;
import androidx.room.Ignore;
import androidx.room.PrimaryKey;
import com.readrops.app.database.entities.account.Account;
import com.readrops.readropsdb.entities.account.Account;
@Entity(foreignKeys = {@ForeignKey(entity = Folder.class, parentColumns = "id",
childColumns = "folder_id", onDelete = ForeignKey.SET_NULL),

View File

@ -1,4 +1,4 @@
package com.readrops.app.database.entities;
package com.readrops.readropsdb.entities;
import android.os.Parcel;
import android.os.Parcelable;
@ -9,7 +9,7 @@ import androidx.room.ForeignKey;
import androidx.room.Ignore;
import androidx.room.PrimaryKey;
import com.readrops.app.database.entities.account.Account;
import com.readrops.readropsdb.entities.account.Account;
@Entity(foreignKeys = @ForeignKey(entity = Account.class, parentColumns = "id",
childColumns = "account_id", onDelete = ForeignKey.CASCADE))

View File

@ -1,4 +1,4 @@
package com.readrops.app.database.entities;
package com.readrops.readropsdb.entities;
import androidx.room.ColumnInfo;
import androidx.room.Entity;

View File

@ -1,4 +1,4 @@
package com.readrops.app.database.entities.account;
package com.readrops.readropsdb.entities.account;
import android.os.Parcel;
import android.os.Parcelable;
@ -9,10 +9,6 @@ import androidx.room.Entity;
import androidx.room.Ignore;
import androidx.room.PrimaryKey;
import com.readrops.readropslibrary.services.Credentials;
import com.readrops.readropslibrary.services.freshrss.FreshRSSCredentials;
import com.readrops.readropslibrary.services.nextcloudnews.NextNewsCredentials;
@Entity
public class Account implements Parcelable {
@ -197,17 +193,6 @@ public class Account implements Parcelable {
dest.writeString(writeToken);
}
public Credentials toCredentials() {
switch (accountType) {
case NEXTCLOUD_NEWS:
return new NextNewsCredentials(login, password, url);
case FRESHRSS:
return new FreshRSSCredentials(token, url);
default:
return null;
}
}
public boolean isLocal() {
return accountType == AccountType.LOCAL;
}

View File

@ -1,4 +1,4 @@
package com.readrops.app.database.entities.account;
package com.readrops.readropsdb.entities.account;
public class AccountConfig {

View File

@ -1,4 +1,4 @@
package com.readrops.app.database.entities.account;
package com.readrops.readropsdb.entities.account;
import android.os.Parcel;
import android.os.Parcelable;
@ -6,7 +6,8 @@ import android.os.Parcelable;
import androidx.annotation.DrawableRes;
import androidx.annotation.StringRes;
import com.readrops.app.R;
import com.readrops.readropsdb.R;
public enum AccountType implements Parcelable {
LOCAL(R.mipmap.ic_launcher, R.string.local_account, AccountConfig.LOCAL),
@ -14,8 +15,10 @@ public enum AccountType implements Parcelable {
FEEDLY(R.drawable.ic_feedly, R.string.feedly, null),
FRESHRSS(R.drawable.ic_freshrss, R.string.freshrss, AccountConfig.FRESHRSS);
private @DrawableRes int iconRes;
private @StringRes int name;
private @DrawableRes
int iconRes;
private @StringRes
int name;
private AccountConfig accountConfig;
@Override
@ -40,11 +43,13 @@ public enum AccountType implements Parcelable {
}
};
public @DrawableRes int getIconRes() {
public @DrawableRes
int getIconRes() {
return iconRes;
}
public @StringRes int getName() {
public @StringRes
int getName() {
return name;
}

View File

@ -0,0 +1,7 @@
package com.readrops.readropsdb.filters;
public enum FilterType {
FEED_FILTER,
READ_IT_LATER_FILTER,
NO_FILTER
}

View File

@ -0,0 +1,6 @@
package com.readrops.readropsdb.filters;
public enum ListSortType {
NEWEST_TO_OLDEST,
OLDEST_TO_NEWEST
}

View File

@ -1,11 +1,12 @@
package com.readrops.app.database.pojo;
package com.readrops.readropsdb.pojo;
import androidx.room.Embedded;
import android.os.Parcel;
import android.os.Parcelable;
import com.readrops.app.database.entities.Feed;
import com.readrops.app.database.entities.Folder;
import androidx.room.Embedded;
import com.readrops.readropsdb.entities.Feed;
import com.readrops.readropsdb.entities.Folder;
public class FeedWithFolder implements Parcelable {

View File

@ -1,9 +1,9 @@
package com.readrops.app.database.pojo;
package com.readrops.readropsdb.pojo;
import androidx.room.ColumnInfo;
import androidx.room.Embedded;
import com.readrops.app.database.entities.Folder;
import com.readrops.readropsdb.entities.Folder;
public class FolderWithFeedCount {

View File

@ -1,11 +1,11 @@
package com.readrops.app.database.pojo;
package com.readrops.readropsdb.pojo;
import androidx.room.ColumnInfo;
import androidx.room.Embedded;
import androidx.annotation.ColorInt;
import com.readrops.app.database.entities.Folder;
import com.readrops.app.database.entities.Item;
import com.readrops.readropsdb.entities.Folder;
import com.readrops.readropsdb.entities.Item;
public class ItemWithFeed {

View File

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

Before

Width:  |  Height:  |  Size: 5.5 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB

View File

Before

Width:  |  Height:  |  Size: 8.5 KiB

After

Width:  |  Height:  |  Size: 8.5 KiB

View File

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">readropsdb</string>
<string name="local_account">Compte local</string>
</resources>

View File

@ -0,0 +1,10 @@
<resources>
<string name="app_name">readropsdb</string>
<string name="freshrss" translatable="false">Freshrss</string>
<string name="feedly" translatable="false">Feedly</string>
<string name="nextcloud_news" translatable="false">Nextcloud News</string>
<string name="local_account">Local account</string>
</resources>

View File

@ -0,0 +1,17 @@
package com.readrops.readropsdb;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() {
assertEquals(4, 2 + 2);
}
}

View File

@ -31,6 +31,7 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(':readropsdb')
implementation "androidx.core:core-ktx:1.1.0"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"

View File

@ -1,5 +1,11 @@
package com.readrops.readropslibrary.services;
import androidx.annotation.Nullable;
import com.readrops.readropsdb.entities.account.Account;
import com.readrops.readropslibrary.services.freshrss.FreshRSSCredentials;
import com.readrops.readropslibrary.services.nextcloudnews.NextNewsCredentials;
public abstract class Credentials {
private String authorization;
@ -18,4 +24,16 @@ public abstract class Credentials {
public String getUrl() {
return url;
}
@Nullable
public static Credentials toCredentials(Account account) {
switch (account.getAccountType()) {
case NEXTCLOUD_NEWS:
return new NextNewsCredentials(account.getLogin(), account.getPassword(), account.getUrl());
case FRESHRSS:
return new FreshRSSCredentials(account.getToken(), account.getUrl());
default:
return null;
}
}
}

View File

@ -1 +1 @@
include ':app', ':readropslibrary'
include ':app', ':readropslibrary', ':readropsdb'