diff --git a/app/build.gradle b/app/build.gradle index d57bed1a..2aca1ef7 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -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' diff --git a/app/src/main/java/com/readrops/app/activities/AccountTypeListActivity.java b/app/src/main/java/com/readrops/app/activities/AccountTypeListActivity.java index 111bf90a..e1e19e9c 100644 --- a/app/src/main/java/com/readrops/app/activities/AccountTypeListActivity.java +++ b/app/src/main/java/com/readrops/app/activities/AccountTypeListActivity.java @@ -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; diff --git a/app/src/main/java/com/readrops/app/activities/AddAccountActivity.java b/app/src/main/java/com/readrops/app/activities/AddAccountActivity.java index 9721b73f..d503933d 100644 --- a/app/src/main/java/com/readrops/app/activities/AddAccountActivity.java +++ b/app/src/main/java/com/readrops/app/activities/AddAccountActivity.java @@ -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; diff --git a/app/src/main/java/com/readrops/app/activities/AddFeedActivity.java b/app/src/main/java/com/readrops/app/activities/AddFeedActivity.java index 9babe8d4..953eaa7a 100644 --- a/app/src/main/java/com/readrops/app/activities/AddFeedActivity.java +++ b/app/src/main/java/com/readrops/app/activities/AddFeedActivity.java @@ -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; diff --git a/app/src/main/java/com/readrops/app/activities/ItemActivity.java b/app/src/main/java/com/readrops/app/activities/ItemActivity.java index ad9ba6fe..33b341f0 100644 --- a/app/src/main/java/com/readrops/app/activities/ItemActivity.java +++ b/app/src/main/java/com/readrops/app/activities/ItemActivity.java @@ -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; diff --git a/app/src/main/java/com/readrops/app/activities/MainActivity.java b/app/src/main/java/com/readrops/app/activities/MainActivity.java index 646e4586..4ee2e279 100644 --- a/app/src/main/java/com/readrops/app/activities/MainActivity.java +++ b/app/src/main/java/com/readrops/app/activities/MainActivity.java @@ -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 - } } diff --git a/app/src/main/java/com/readrops/app/activities/ManageFeedsFoldersActivity.java b/app/src/main/java/com/readrops/app/activities/ManageFeedsFoldersActivity.java index 5199620c..03a1a02c 100644 --- a/app/src/main/java/com/readrops/app/activities/ManageFeedsFoldersActivity.java +++ b/app/src/main/java/com/readrops/app/activities/ManageFeedsFoldersActivity.java @@ -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; diff --git a/app/src/main/java/com/readrops/app/activities/SettingsActivity.java b/app/src/main/java/com/readrops/app/activities/SettingsActivity.java index c9cd2a9f..b2ac92ec 100644 --- a/app/src/main/java/com/readrops/app/activities/SettingsActivity.java +++ b/app/src/main/java/com/readrops/app/activities/SettingsActivity.java @@ -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; diff --git a/app/src/main/java/com/readrops/app/adapters/AccountArrayAdapter.java b/app/src/main/java/com/readrops/app/adapters/AccountArrayAdapter.java index c0816e95..4bd3c810 100644 --- a/app/src/main/java/com/readrops/app/adapters/AccountArrayAdapter.java +++ b/app/src/main/java/com/readrops/app/adapters/AccountArrayAdapter.java @@ -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; diff --git a/app/src/main/java/com/readrops/app/adapters/AccountTypeListAdapter.java b/app/src/main/java/com/readrops/app/adapters/AccountTypeListAdapter.java index 1c09e16d..83d61c3f 100644 --- a/app/src/main/java/com/readrops/app/adapters/AccountTypeListAdapter.java +++ b/app/src/main/java/com/readrops/app/adapters/AccountTypeListAdapter.java @@ -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; diff --git a/app/src/main/java/com/readrops/app/adapters/FeedsAdapter.java b/app/src/main/java/com/readrops/app/adapters/FeedsAdapter.java index 684803c2..1f983c32 100644 --- a/app/src/main/java/com/readrops/app/adapters/FeedsAdapter.java +++ b/app/src/main/java/com/readrops/app/adapters/FeedsAdapter.java @@ -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; diff --git a/app/src/main/java/com/readrops/app/adapters/FoldersAdapter.java b/app/src/main/java/com/readrops/app/adapters/FoldersAdapter.java index 9614c26a..1130edc9 100644 --- a/app/src/main/java/com/readrops/app/adapters/FoldersAdapter.java +++ b/app/src/main/java/com/readrops/app/adapters/FoldersAdapter.java @@ -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; diff --git a/app/src/main/java/com/readrops/app/adapters/MainItemListAdapter.java b/app/src/main/java/com/readrops/app/adapters/MainItemListAdapter.java index 01b9bbbb..a9335337 100644 --- a/app/src/main/java/com/readrops/app/adapters/MainItemListAdapter.java +++ b/app/src/main/java/com/readrops/app/adapters/MainItemListAdapter.java @@ -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; diff --git a/app/src/main/java/com/readrops/app/fragments/EditFeedDialogFragment.java b/app/src/main/java/com/readrops/app/fragments/EditFeedDialogFragment.java index c1501f89..d8c1b229 100644 --- a/app/src/main/java/com/readrops/app/fragments/EditFeedDialogFragment.java +++ b/app/src/main/java/com/readrops/app/fragments/EditFeedDialogFragment.java @@ -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; diff --git a/app/src/main/java/com/readrops/app/fragments/FeedOptionsDialogFragment.kt b/app/src/main/java/com/readrops/app/fragments/FeedOptionsDialogFragment.kt index 101be557..2dfd66f5 100644 --- a/app/src/main/java/com/readrops/app/fragments/FeedOptionsDialogFragment.kt +++ b/app/src/main/java/com/readrops/app/fragments/FeedOptionsDialogFragment.kt @@ -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 diff --git a/app/src/main/java/com/readrops/app/fragments/FeedsFragment.java b/app/src/main/java/com/readrops/app/fragments/FeedsFragment.java index 04197916..f10bfe52 100644 --- a/app/src/main/java/com/readrops/app/fragments/FeedsFragment.java +++ b/app/src/main/java/com/readrops/app/fragments/FeedsFragment.java @@ -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; diff --git a/app/src/main/java/com/readrops/app/fragments/FolderOptionsDialogFragment.kt b/app/src/main/java/com/readrops/app/fragments/FolderOptionsDialogFragment.kt index e3503211..9166a40a 100644 --- a/app/src/main/java/com/readrops/app/fragments/FolderOptionsDialogFragment.kt +++ b/app/src/main/java/com/readrops/app/fragments/FolderOptionsDialogFragment.kt @@ -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() { diff --git a/app/src/main/java/com/readrops/app/fragments/FoldersFragment.java b/app/src/main/java/com/readrops/app/fragments/FoldersFragment.java index 47839447..c4c6083f 100644 --- a/app/src/main/java/com/readrops/app/fragments/FoldersFragment.java +++ b/app/src/main/java/com/readrops/app/fragments/FoldersFragment.java @@ -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; diff --git a/app/src/main/java/com/readrops/app/fragments/settings/AccountSettingsFragment.java b/app/src/main/java/com/readrops/app/fragments/settings/AccountSettingsFragment.java index 1233b1b4..235d0899 100644 --- a/app/src/main/java/com/readrops/app/fragments/settings/AccountSettingsFragment.java +++ b/app/src/main/java/com/readrops/app/fragments/settings/AccountSettingsFragment.java @@ -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; diff --git a/app/src/main/java/com/readrops/app/fragments/settings/SettingsFragment.java b/app/src/main/java/com/readrops/app/fragments/settings/SettingsFragment.java index 6c7608f4..d1730b30 100644 --- a/app/src/main/java/com/readrops/app/fragments/settings/SettingsFragment.java +++ b/app/src/main/java/com/readrops/app/fragments/settings/SettingsFragment.java @@ -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; diff --git a/app/src/main/java/com/readrops/app/repositories/ARepository.java b/app/src/main/java/com/readrops/app/repositories/ARepository.java index 9f0898eb..0f86430e 100644 --- a/app/src/main/java/com/readrops/app/repositories/ARepository.java +++ b/app/src/main/java/com/readrops/app/repositories/ARepository.java @@ -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; diff --git a/app/src/main/java/com/readrops/app/repositories/FreshRSSRepository.java b/app/src/main/java/com/readrops/app/repositories/FreshRSSRepository.java index 0b55e2ef..100066af 100644 --- a/app/src/main/java/com/readrops/app/repositories/FreshRSSRepository.java +++ b/app/src/main/java/com/readrops/app/repositories/FreshRSSRepository.java @@ -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 { @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 { @Override public Single 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 -> { diff --git a/app/src/main/java/com/readrops/app/repositories/LocalFeedRepository.java b/app/src/main/java/com/readrops/app/repositories/LocalFeedRepository.java index fffd9ccf..986d1866 100644 --- a/app/src/main/java/com/readrops/app/repositories/LocalFeedRepository.java +++ b/app/src/main/java/com/readrops/app/repositories/LocalFeedRepository.java @@ -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; diff --git a/app/src/main/java/com/readrops/app/repositories/NextNewsRepository.java b/app/src/main/java/com/readrops/app/repositories/NextNewsRepository.java index 5afa1de0..8e159c14 100644 --- a/app/src/main/java/com/readrops/app/repositories/NextNewsRepository.java +++ b/app/src/main/java/com/readrops/app/repositories/NextNewsRepository.java @@ -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 { @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 { public Single login(Account account, boolean insert) { return Single.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(); diff --git a/app/src/main/java/com/readrops/app/utils/DrawerManager.java b/app/src/main/java/com/readrops/app/utils/DrawerManager.java index 00d1a128..8fe17f0e 100644 --- a/app/src/main/java/com/readrops/app/utils/DrawerManager.java +++ b/app/src/main/java/com/readrops/app/utils/DrawerManager.java @@ -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; diff --git a/app/src/main/java/com/readrops/app/utils/FeedInsertionResult.java b/app/src/main/java/com/readrops/app/utils/FeedInsertionResult.java index ab12729c..4a6bbf8d 100644 --- a/app/src/main/java/com/readrops/app/utils/FeedInsertionResult.java +++ b/app/src/main/java/com/readrops/app/utils/FeedInsertionResult.java @@ -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; diff --git a/app/src/main/java/com/readrops/app/utils/ParsingResult.java b/app/src/main/java/com/readrops/app/utils/ParsingResult.java index 528b186a..691c8dbf 100644 --- a/app/src/main/java/com/readrops/app/utils/ParsingResult.java +++ b/app/src/main/java/com/readrops/app/utils/ParsingResult.java @@ -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; diff --git a/app/src/main/java/com/readrops/app/utils/ReadropsWebView.java b/app/src/main/java/com/readrops/app/utils/ReadropsWebView.java index 0315c8b4..5b810241 100644 --- a/app/src/main/java/com/readrops/app/utils/ReadropsWebView.java +++ b/app/src/main/java/com/readrops/app/utils/ReadropsWebView.java @@ -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; diff --git a/app/src/main/java/com/readrops/app/utils/feedscolors/FeedColors.kt b/app/src/main/java/com/readrops/app/utils/feedscolors/FeedColors.kt index 6c6d83ac..cd049c3e 100644 --- a/app/src/main/java/com/readrops/app/utils/feedscolors/FeedColors.kt +++ b/app/src/main/java/com/readrops/app/utils/feedscolors/FeedColors.kt @@ -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 diff --git a/app/src/main/java/com/readrops/app/utils/feedscolors/FeedsColorsIntentService.kt b/app/src/main/java/com/readrops/app/utils/feedscolors/FeedsColorsIntentService.kt index 97951216..80de257e 100644 --- a/app/src/main/java/com/readrops/app/utils/feedscolors/FeedsColorsIntentService.kt +++ b/app/src/main/java/com/readrops/app/utils/feedscolors/FeedsColorsIntentService.kt @@ -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") { diff --git a/app/src/main/java/com/readrops/app/utils/matchers/FeedMatcher.java b/app/src/main/java/com/readrops/app/utils/matchers/FeedMatcher.java index 27eeb5a1..9d9e3742 100644 --- a/app/src/main/java/com/readrops/app/utils/matchers/FeedMatcher.java +++ b/app/src/main/java/com/readrops/app/utils/matchers/FeedMatcher.java @@ -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; diff --git a/app/src/main/java/com/readrops/app/utils/matchers/ItemMatcher.java b/app/src/main/java/com/readrops/app/utils/matchers/ItemMatcher.java index ab5db91b..d8f6b6e7 100644 --- a/app/src/main/java/com/readrops/app/utils/matchers/ItemMatcher.java +++ b/app/src/main/java/com/readrops/app/utils/matchers/ItemMatcher.java @@ -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; diff --git a/app/src/main/java/com/readrops/app/utils/matchers/OPMLMatcher.kt b/app/src/main/java/com/readrops/app/utils/matchers/OPMLMatcher.kt index 0a2f241b..4ca9045c 100644 --- a/app/src/main/java/com/readrops/app/utils/matchers/OPMLMatcher.kt +++ b/app/src/main/java/com/readrops/app/utils/matchers/OPMLMatcher.kt @@ -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 diff --git a/app/src/main/java/com/readrops/app/viewmodels/AccountViewModel.java b/app/src/main/java/com/readrops/app/viewmodels/AccountViewModel.java index 0f5bc949..ff9b5c2d 100644 --- a/app/src/main/java/com/readrops/app/viewmodels/AccountViewModel.java +++ b/app/src/main/java/com/readrops/app/viewmodels/AccountViewModel.java @@ -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; diff --git a/app/src/main/java/com/readrops/app/viewmodels/AddFeedsViewModel.java b/app/src/main/java/com/readrops/app/viewmodels/AddFeedsViewModel.java index 634878ff..d656476d 100644 --- a/app/src/main/java/com/readrops/app/viewmodels/AddFeedsViewModel.java +++ b/app/src/main/java/com/readrops/app/viewmodels/AddFeedsViewModel.java @@ -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; diff --git a/app/src/main/java/com/readrops/app/viewmodels/ItemViewModel.java b/app/src/main/java/com/readrops/app/viewmodels/ItemViewModel.java index 10585f37..f83cb31c 100644 --- a/app/src/main/java/com/readrops/app/viewmodels/ItemViewModel.java +++ b/app/src/main/java/com/readrops/app/viewmodels/ItemViewModel.java @@ -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; diff --git a/app/src/main/java/com/readrops/app/viewmodels/MainViewModel.java b/app/src/main/java/com/readrops/app/viewmodels/MainViewModel.java index 87d67b26..b368e759 100644 --- a/app/src/main/java/com/readrops/app/viewmodels/MainViewModel.java +++ b/app/src/main/java/com/readrops/app/viewmodels/MainViewModel.java @@ -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 } diff --git a/app/src/main/java/com/readrops/app/viewmodels/ManageFeedsFoldersViewModel.java b/app/src/main/java/com/readrops/app/viewmodels/ManageFeedsFoldersViewModel.java index 8ad3f76d..de1b188e 100644 --- a/app/src/main/java/com/readrops/app/viewmodels/ManageFeedsFoldersViewModel.java +++ b/app/src/main/java/com/readrops/app/viewmodels/ManageFeedsFoldersViewModel.java @@ -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; diff --git a/app/src/main/res/values-fr-rFR/strings.xml b/app/src/main/res/values-fr-rFR/strings.xml index 5d3d389d..b7ba2014 100644 --- a/app/src/main/res/values-fr-rFR/strings.xml +++ b/app/src/main/res/values-fr-rFR/strings.xml @@ -53,7 +53,6 @@ Ajouter un compte Aucun flux Choisir un compte - Compte local Flux et dossiers Compte GĂ©rer les flux et dossiers diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 3a8bb724..cf8dee88 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -51,14 +51,10 @@ Account name Login Password - Nextcloud News Account settings Add account No feed Choose an account - Local account - Freshrss - Feedly Feeds and folders Account Manage feeds and folders diff --git a/readropsdb/.gitignore b/readropsdb/.gitignore new file mode 100644 index 00000000..796b96d1 --- /dev/null +++ b/readropsdb/.gitignore @@ -0,0 +1 @@ +/build diff --git a/readropsdb/build.gradle b/readropsdb/build.gradle new file mode 100644 index 00000000..6ce4d283 --- /dev/null +++ b/readropsdb/build.gradle @@ -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' +} diff --git a/readropsdb/consumer-rules.pro b/readropsdb/consumer-rules.pro new file mode 100644 index 00000000..e69de29b diff --git a/readropsdb/proguard-rules.pro b/readropsdb/proguard-rules.pro new file mode 100644 index 00000000..f1b42451 --- /dev/null +++ b/readropsdb/proguard-rules.pro @@ -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 diff --git a/readropsdb/src/androidTest/java/com/readrops/readropsdb/ExampleInstrumentedTest.java b/readropsdb/src/androidTest/java/com/readrops/readropsdb/ExampleInstrumentedTest.java new file mode 100644 index 00000000..91a14295 --- /dev/null +++ b/readropsdb/src/androidTest/java/com/readrops/readropsdb/ExampleInstrumentedTest.java @@ -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 Testing documentation + */ +@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()); + } +} diff --git a/readropsdb/src/main/AndroidManifest.xml b/readropsdb/src/main/AndroidManifest.xml new file mode 100644 index 00000000..6cce97a5 --- /dev/null +++ b/readropsdb/src/main/AndroidManifest.xml @@ -0,0 +1,2 @@ + diff --git a/app/src/main/java/com/readrops/app/database/Converters.java b/readropsdb/src/main/java/com/readrops/readropsdb/Converters.java similarity index 86% rename from app/src/main/java/com/readrops/app/database/Converters.java rename to readropsdb/src/main/java/com/readrops/readropsdb/Converters.java index fd2338f1..9d9e5c18 100644 --- a/app/src/main/java/com/readrops/app/database/Converters.java +++ b/readropsdb/src/main/java/com/readrops/readropsdb/Converters.java @@ -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; diff --git a/app/src/main/java/com/readrops/app/database/Database.java b/readropsdb/src/main/java/com/readrops/readropsdb/Database.java similarity index 64% rename from app/src/main/java/com/readrops/app/database/Database.java rename to readropsdb/src/main/java/com/readrops/readropsdb/Database.java index c2d566e9..32df2ece 100644 --- a/app/src/main/java/com/readrops/app/database/Database.java +++ b/readropsdb/src/main/java/com/readrops/readropsdb/Database.java @@ -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) diff --git a/app/src/main/java/com/readrops/app/database/ItemsListQueryBuilder.java b/readropsdb/src/main/java/com/readrops/readropsdb/ItemsListQueryBuilder.java similarity index 83% rename from app/src/main/java/com/readrops/app/database/ItemsListQueryBuilder.java rename to readropsdb/src/main/java/com/readrops/readropsdb/ItemsListQueryBuilder.java index 87d8820b..a301e46d 100644 --- a/app/src/main/java/com/readrops/app/database/ItemsListQueryBuilder.java +++ b/readropsdb/src/main/java/com/readrops/readropsdb/ItemsListQueryBuilder.java @@ -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; } diff --git a/app/src/main/java/com/readrops/app/database/RoomFactoryWrapper.java b/readropsdb/src/main/java/com/readrops/readropsdb/RoomFactoryWrapper.java similarity index 98% rename from app/src/main/java/com/readrops/app/database/RoomFactoryWrapper.java rename to readropsdb/src/main/java/com/readrops/readropsdb/RoomFactoryWrapper.java index 4e1175db..8bcf51b5 100644 --- a/app/src/main/java/com/readrops/app/database/RoomFactoryWrapper.java +++ b/readropsdb/src/main/java/com/readrops/readropsdb/RoomFactoryWrapper.java @@ -1,4 +1,4 @@ -package com.readrops.app.database; +package com.readrops.readropsdb; import androidx.annotation.NonNull; import androidx.paging.DataSource; diff --git a/app/src/main/java/com/readrops/app/database/dao/AccountDao.java b/readropsdb/src/main/java/com/readrops/readropsdb/dao/AccountDao.java similarity index 92% rename from app/src/main/java/com/readrops/app/database/dao/AccountDao.java rename to readropsdb/src/main/java/com/readrops/readropsdb/dao/AccountDao.java index ad51c4e7..7f426457 100644 --- a/app/src/main/java/com/readrops/app/database/dao/AccountDao.java +++ b/readropsdb/src/main/java/com/readrops/readropsdb/dao/AccountDao.java @@ -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; diff --git a/app/src/main/java/com/readrops/app/database/dao/BaseDao.java b/readropsdb/src/main/java/com/readrops/readropsdb/dao/BaseDao.java similarity index 94% rename from app/src/main/java/com/readrops/app/database/dao/BaseDao.java rename to readropsdb/src/main/java/com/readrops/readropsdb/dao/BaseDao.java index 0595ff61..5f290e8a 100644 --- a/app/src/main/java/com/readrops/app/database/dao/BaseDao.java +++ b/readropsdb/src/main/java/com/readrops/readropsdb/dao/BaseDao.java @@ -1,4 +1,4 @@ -package com.readrops.app.database.dao; +package com.readrops.readropsdb.dao; import androidx.room.Delete; import androidx.room.Insert; diff --git a/app/src/main/java/com/readrops/app/database/dao/FeedDao.java b/readropsdb/src/main/java/com/readrops/readropsdb/dao/FeedDao.java similarity index 96% rename from app/src/main/java/com/readrops/app/database/dao/FeedDao.java rename to readropsdb/src/main/java/com/readrops/readropsdb/dao/FeedDao.java index 5b1e6dcc..2bf10209 100644 --- a/app/src/main/java/com/readrops/app/database/dao/FeedDao.java +++ b/readropsdb/src/main/java/com/readrops/readropsdb/dao/FeedDao.java @@ -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; diff --git a/app/src/main/java/com/readrops/app/database/dao/FolderDao.java b/readropsdb/src/main/java/com/readrops/readropsdb/dao/FolderDao.java similarity index 92% rename from app/src/main/java/com/readrops/app/database/dao/FolderDao.java rename to readropsdb/src/main/java/com/readrops/readropsdb/dao/FolderDao.java index 43d8d8f0..c86304f0 100644 --- a/app/src/main/java/com/readrops/app/database/dao/FolderDao.java +++ b/readropsdb/src/main/java/com/readrops/readropsdb/dao/FolderDao.java @@ -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; diff --git a/app/src/main/java/com/readrops/app/database/dao/ItemDao.java b/readropsdb/src/main/java/com/readrops/readropsdb/dao/ItemDao.java similarity index 93% rename from app/src/main/java/com/readrops/app/database/dao/ItemDao.java rename to readropsdb/src/main/java/com/readrops/readropsdb/dao/ItemDao.java index 6cede63e..ed5a31b4 100644 --- a/app/src/main/java/com/readrops/app/database/dao/ItemDao.java +++ b/readropsdb/src/main/java/com/readrops/readropsdb/dao/ItemDao.java @@ -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; diff --git a/app/src/main/java/com/readrops/app/database/entities/Feed.java b/readropsdb/src/main/java/com/readrops/readropsdb/entities/Feed.java similarity index 98% rename from app/src/main/java/com/readrops/app/database/entities/Feed.java rename to readropsdb/src/main/java/com/readrops/readropsdb/entities/Feed.java index 7732d06c..da879147 100644 --- a/app/src/main/java/com/readrops/app/database/entities/Feed.java +++ b/readropsdb/src/main/java/com/readrops/readropsdb/entities/Feed.java @@ -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), diff --git a/app/src/main/java/com/readrops/app/database/entities/Folder.java b/readropsdb/src/main/java/com/readrops/readropsdb/entities/Folder.java similarity index 95% rename from app/src/main/java/com/readrops/app/database/entities/Folder.java rename to readropsdb/src/main/java/com/readrops/readropsdb/entities/Folder.java index c8db5c2f..0aad2185 100644 --- a/app/src/main/java/com/readrops/app/database/entities/Folder.java +++ b/readropsdb/src/main/java/com/readrops/readropsdb/entities/Folder.java @@ -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)) diff --git a/app/src/main/java/com/readrops/app/database/entities/Item.java b/readropsdb/src/main/java/com/readrops/readropsdb/entities/Item.java similarity index 98% rename from app/src/main/java/com/readrops/app/database/entities/Item.java rename to readropsdb/src/main/java/com/readrops/readropsdb/entities/Item.java index 0bb10a8d..0156f233 100644 --- a/app/src/main/java/com/readrops/app/database/entities/Item.java +++ b/readropsdb/src/main/java/com/readrops/readropsdb/entities/Item.java @@ -1,4 +1,4 @@ -package com.readrops.app.database.entities; +package com.readrops.readropsdb.entities; import androidx.room.ColumnInfo; import androidx.room.Entity; diff --git a/app/src/main/java/com/readrops/app/database/entities/account/Account.java b/readropsdb/src/main/java/com/readrops/readropsdb/entities/account/Account.java similarity index 89% rename from app/src/main/java/com/readrops/app/database/entities/account/Account.java rename to readropsdb/src/main/java/com/readrops/readropsdb/entities/account/Account.java index 7a4930fc..10ebb7ef 100644 --- a/app/src/main/java/com/readrops/app/database/entities/account/Account.java +++ b/readropsdb/src/main/java/com/readrops/readropsdb/entities/account/Account.java @@ -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; } diff --git a/app/src/main/java/com/readrops/app/database/entities/account/AccountConfig.java b/readropsdb/src/main/java/com/readrops/readropsdb/entities/account/AccountConfig.java similarity index 97% rename from app/src/main/java/com/readrops/app/database/entities/account/AccountConfig.java rename to readropsdb/src/main/java/com/readrops/readropsdb/entities/account/AccountConfig.java index 42c8006b..520c864b 100644 --- a/app/src/main/java/com/readrops/app/database/entities/account/AccountConfig.java +++ b/readropsdb/src/main/java/com/readrops/readropsdb/entities/account/AccountConfig.java @@ -1,4 +1,4 @@ -package com.readrops.app.database.entities.account; +package com.readrops.readropsdb.entities.account; public class AccountConfig { diff --git a/app/src/main/java/com/readrops/app/database/entities/account/AccountType.java b/readropsdb/src/main/java/com/readrops/readropsdb/entities/account/AccountType.java similarity index 84% rename from app/src/main/java/com/readrops/app/database/entities/account/AccountType.java rename to readropsdb/src/main/java/com/readrops/readropsdb/entities/account/AccountType.java index efea0e74..e0cea488 100644 --- a/app/src/main/java/com/readrops/app/database/entities/account/AccountType.java +++ b/readropsdb/src/main/java/com/readrops/readropsdb/entities/account/AccountType.java @@ -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; } diff --git a/readropsdb/src/main/java/com/readrops/readropsdb/filters/FilterType.java b/readropsdb/src/main/java/com/readrops/readropsdb/filters/FilterType.java new file mode 100644 index 00000000..9adfd1cc --- /dev/null +++ b/readropsdb/src/main/java/com/readrops/readropsdb/filters/FilterType.java @@ -0,0 +1,7 @@ +package com.readrops.readropsdb.filters; + +public enum FilterType { + FEED_FILTER, + READ_IT_LATER_FILTER, + NO_FILTER +} diff --git a/readropsdb/src/main/java/com/readrops/readropsdb/filters/ListSortType.java b/readropsdb/src/main/java/com/readrops/readropsdb/filters/ListSortType.java new file mode 100644 index 00000000..0aea2281 --- /dev/null +++ b/readropsdb/src/main/java/com/readrops/readropsdb/filters/ListSortType.java @@ -0,0 +1,6 @@ +package com.readrops.readropsdb.filters; + +public enum ListSortType { + NEWEST_TO_OLDEST, + OLDEST_TO_NEWEST +} diff --git a/app/src/main/java/com/readrops/app/database/pojo/FeedWithFolder.java b/readropsdb/src/main/java/com/readrops/readropsdb/pojo/FeedWithFolder.java similarity index 90% rename from app/src/main/java/com/readrops/app/database/pojo/FeedWithFolder.java rename to readropsdb/src/main/java/com/readrops/readropsdb/pojo/FeedWithFolder.java index afbab27f..f2ac5ca4 100644 --- a/app/src/main/java/com/readrops/app/database/pojo/FeedWithFolder.java +++ b/readropsdb/src/main/java/com/readrops/readropsdb/pojo/FeedWithFolder.java @@ -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 { diff --git a/app/src/main/java/com/readrops/app/database/pojo/FolderWithFeedCount.java b/readropsdb/src/main/java/com/readrops/readropsdb/pojo/FolderWithFeedCount.java similarity index 85% rename from app/src/main/java/com/readrops/app/database/pojo/FolderWithFeedCount.java rename to readropsdb/src/main/java/com/readrops/readropsdb/pojo/FolderWithFeedCount.java index 999b9501..11bddc8c 100644 --- a/app/src/main/java/com/readrops/app/database/pojo/FolderWithFeedCount.java +++ b/readropsdb/src/main/java/com/readrops/readropsdb/pojo/FolderWithFeedCount.java @@ -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 { diff --git a/app/src/main/java/com/readrops/app/database/pojo/ItemWithFeed.java b/readropsdb/src/main/java/com/readrops/readropsdb/pojo/ItemWithFeed.java similarity index 93% rename from app/src/main/java/com/readrops/app/database/pojo/ItemWithFeed.java rename to readropsdb/src/main/java/com/readrops/readropsdb/pojo/ItemWithFeed.java index fff6ff01..fbf121a7 100644 --- a/app/src/main/java/com/readrops/app/database/pojo/ItemWithFeed.java +++ b/readropsdb/src/main/java/com/readrops/readropsdb/pojo/ItemWithFeed.java @@ -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 { diff --git a/app/src/main/res/drawable/ic_feedly.xml b/readropsdb/src/main/res/drawable/ic_feedly.xml similarity index 100% rename from app/src/main/res/drawable/ic_feedly.xml rename to readropsdb/src/main/res/drawable/ic_feedly.xml diff --git a/app/src/main/res/drawable/ic_freshrss.xml b/readropsdb/src/main/res/drawable/ic_freshrss.xml similarity index 100% rename from app/src/main/res/drawable/ic_freshrss.xml rename to readropsdb/src/main/res/drawable/ic_freshrss.xml diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/readropsdb/src/main/res/drawable/ic_launcher_background.xml similarity index 100% rename from app/src/main/res/drawable/ic_launcher_background.xml rename to readropsdb/src/main/res/drawable/ic_launcher_background.xml diff --git a/app/src/main/res/drawable/ic_launcher_foreground.xml b/readropsdb/src/main/res/drawable/ic_launcher_foreground.xml similarity index 100% rename from app/src/main/res/drawable/ic_launcher_foreground.xml rename to readropsdb/src/main/res/drawable/ic_launcher_foreground.xml diff --git a/app/src/main/res/drawable/ic_nextcloud_news.xml b/readropsdb/src/main/res/drawable/ic_nextcloud_news.xml similarity index 100% rename from app/src/main/res/drawable/ic_nextcloud_news.xml rename to readropsdb/src/main/res/drawable/ic_nextcloud_news.xml diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/readropsdb/src/main/res/mipmap-anydpi-v26/ic_launcher.xml similarity index 100% rename from app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml rename to readropsdb/src/main/res/mipmap-anydpi-v26/ic_launcher.xml diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/readropsdb/src/main/res/mipmap-hdpi/ic_launcher.png similarity index 100% rename from app/src/main/res/mipmap-hdpi/ic_launcher.png rename to readropsdb/src/main/res/mipmap-hdpi/ic_launcher.png diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/readropsdb/src/main/res/mipmap-mdpi/ic_launcher.png similarity index 100% rename from app/src/main/res/mipmap-mdpi/ic_launcher.png rename to readropsdb/src/main/res/mipmap-mdpi/ic_launcher.png diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/readropsdb/src/main/res/mipmap-xhdpi/ic_launcher.png similarity index 100% rename from app/src/main/res/mipmap-xhdpi/ic_launcher.png rename to readropsdb/src/main/res/mipmap-xhdpi/ic_launcher.png diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/readropsdb/src/main/res/mipmap-xxhdpi/ic_launcher.png similarity index 100% rename from app/src/main/res/mipmap-xxhdpi/ic_launcher.png rename to readropsdb/src/main/res/mipmap-xxhdpi/ic_launcher.png diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/readropsdb/src/main/res/mipmap-xxxhdpi/ic_launcher.png similarity index 100% rename from app/src/main/res/mipmap-xxxhdpi/ic_launcher.png rename to readropsdb/src/main/res/mipmap-xxxhdpi/ic_launcher.png diff --git a/readropsdb/src/main/res/values-fr/strings.xml b/readropsdb/src/main/res/values-fr/strings.xml new file mode 100644 index 00000000..f378504b --- /dev/null +++ b/readropsdb/src/main/res/values-fr/strings.xml @@ -0,0 +1,6 @@ + + + readropsdb + + Compte local + \ No newline at end of file diff --git a/readropsdb/src/main/res/values/strings.xml b/readropsdb/src/main/res/values/strings.xml new file mode 100644 index 00000000..07bb7afb --- /dev/null +++ b/readropsdb/src/main/res/values/strings.xml @@ -0,0 +1,10 @@ + + readropsdb + + Freshrss + Feedly + Nextcloud News + + Local account + + diff --git a/readropsdb/src/test/java/com/readrops/readropsdb/ExampleUnitTest.java b/readropsdb/src/test/java/com/readrops/readropsdb/ExampleUnitTest.java new file mode 100644 index 00000000..9c256896 --- /dev/null +++ b/readropsdb/src/test/java/com/readrops/readropsdb/ExampleUnitTest.java @@ -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 Testing documentation + */ +public class ExampleUnitTest { + @Test + public void addition_isCorrect() { + assertEquals(4, 2 + 2); + } +} \ No newline at end of file diff --git a/readropslibrary/build.gradle b/readropslibrary/build.gradle index 7bf9e4e8..e5dfcd19 100644 --- a/readropslibrary/build.gradle +++ b/readropslibrary/build.gradle @@ -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" diff --git a/readropslibrary/src/main/java/com/readrops/readropslibrary/services/Credentials.java b/readropslibrary/src/main/java/com/readrops/readropslibrary/services/Credentials.java index 90b76702..09cb50b1 100644 --- a/readropslibrary/src/main/java/com/readrops/readropslibrary/services/Credentials.java +++ b/readropslibrary/src/main/java/com/readrops/readropslibrary/services/Credentials.java @@ -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; + } + } } diff --git a/settings.gradle b/settings.gradle index 4f03bccf..d090ad46 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1 +1 @@ -include ':app', ':readropslibrary' +include ':app', ':readropslibrary', ':readropsdb'