Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/news-android.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid-Development <david-dev@live.de>2021-09-26 14:46:04 +0300
committerDavid Luhmer <david-dev@live.de>2021-09-26 14:46:04 +0300
commitd8016f5aff5fe117cf59968c0a0d07441d487d09 (patch)
tree8e3e4c205cf2b14522ceed86f4f87d8e7469f537 /News-Android-App/src/main/java
parentc53b8cd55e0216bd8d1434b831ced227a2962b03 (diff)
update comments
Signed-off-by: David Luhmer <david-dev@live.de>
Diffstat (limited to 'News-Android-App/src/main/java')
-rw-r--r--News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewsReaderListDialogFragment.java45
-rw-r--r--News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/PodcastFragmentActivity.java16
-rw-r--r--News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/authentication/OwnCloudSyncAdapter.java2
-rw-r--r--News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/database/DatabaseConnectionOrm.java37
-rw-r--r--News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/database/generator/DatabaseOrmGenerator.java4
-rw-r--r--News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/database/generator/SchemaVersion.java1
-rw-r--r--News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/database/generator/Version8.java (renamed from News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/database/generator/Version7.java)23
-rw-r--r--News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/database/model/CurrentRssItemViewDao.java78
-rw-r--r--News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/database/model/DaoMaster.java8
-rw-r--r--News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/database/model/Feed.java16
-rw-r--r--News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/database/model/FeedDao.java193
-rw-r--r--News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/database/model/FolderDao.java63
-rw-r--r--News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/database/model/RssItemDao.java172
-rw-r--r--News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/notification/NextcloudNotificationManager.java106
-rw-r--r--News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/reader/InsertIntoDatabase.java4
-rw-r--r--News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/reader/nextcloud/NextcloudNewsDeserializer.java1
16 files changed, 454 insertions, 315 deletions
diff --git a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewsReaderListDialogFragment.java b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewsReaderListDialogFragment.java
index 6b72e27a..5c5f5ab9 100644
--- a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewsReaderListDialogFragment.java
+++ b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewsReaderListDialogFragment.java
@@ -10,7 +10,6 @@ import android.text.TextWatcher;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
-import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Toast;
@@ -31,8 +30,6 @@ import de.luhmer.owncloudnewsreader.di.ApiProvider;
import de.luhmer.owncloudnewsreader.helper.FavIconHandler;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.annotations.NonNull;
-import io.reactivex.functions.Action;
-import io.reactivex.functions.Consumer;
import io.reactivex.schedulers.Schedulers;
@@ -83,6 +80,8 @@ public class NewsReaderListDialogFragment extends DialogFragment {
mMenuItems.put(getString(R.string.action_feed_move), () -> showMoveFeedView(mFeedId));
+ mMenuItems.put("Notification settings", () -> showNotificationSettingsView(mFeedId));
+
setStyle(DialogFragment.STYLE_NO_TITLE, R.style.FloatingDialog);
}
@@ -279,7 +278,47 @@ public class NewsReaderListDialogFragment extends DialogFragment {
dismiss();
});
});
+ }
+
+ private void showNotificationSettingsView(final long feedId) {
+ binding.lvMenuList.setVisibility(View.GONE);
+ binding.notificationFeedDialog.setVisibility(View.VISIBLE);
+
+ DatabaseConnectionOrm dbConn = new DatabaseConnectionOrm(getContext());
+ Feed feed = dbConn.getFeedById(feedId);
+ String notificationChannel = feed.getNotificationChannel();
+
+ binding.notificationSettingNone.setChecked(false);
+ binding.notificationSettingDefault.setChecked(false);
+ binding.notificationSettingUnique.setChecked(false);
+
+ switch (notificationChannel) {
+ case "none":
+ binding.notificationSettingNone.setChecked(true);
+ break;
+ case "default":
+ binding.notificationSettingDefault.setChecked(true);
+ break;
+ default:
+ binding.notificationSettingUnique.setChecked(true);
+ break;
+ }
+ binding.notificationSettingNone.setOnCheckedChangeListener((button, checked) ->
+ setNotificationChannelForFeed(feed, "none", checked));
+ binding.notificationSettingDefault.setOnCheckedChangeListener((button, checked) ->
+ setNotificationChannelForFeed(feed, "default", checked));
+ binding.notificationSettingUnique.setOnCheckedChangeListener((button, checked) ->
+ // Use the feed name as notification channel name
+ setNotificationChannelForFeed(feed, feed.getFeedTitle(), checked));
+ }
+
+ private void setNotificationChannelForFeed(Feed feed, String channel, Boolean checked) {
+ if (checked) {
+ feed.setNotificationChannel(channel);
+ feed.update();
+ this.showNotificationSettingsView(feed.getId()); // reload dialog
+ }
}
interface MenuAction {
diff --git a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/PodcastFragmentActivity.java b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/PodcastFragmentActivity.java
index 9c9b5f2b..73af7b8d 100644
--- a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/PodcastFragmentActivity.java
+++ b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/PodcastFragmentActivity.java
@@ -1,5 +1,7 @@
package de.luhmer.owncloudnewsreader;
+import static de.luhmer.owncloudnewsreader.Constants.MIN_NEXTCLOUD_FILES_APP_VERSION_CODE;
+
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.content.SharedPreferences;
@@ -28,7 +30,6 @@ import java.util.regex.Pattern;
import javax.inject.Inject;
-import de.luhmer.owncloudnewsreader.ListView.SubscriptionExpandableListAdapter;
import de.luhmer.owncloudnewsreader.database.DatabaseConnectionOrm;
import de.luhmer.owncloudnewsreader.database.model.RssItem;
import de.luhmer.owncloudnewsreader.di.ApiProvider;
@@ -47,8 +48,6 @@ import de.luhmer.owncloudnewsreader.ssl.MemorizingTrustManager;
import de.luhmer.owncloudnewsreader.view.PodcastSlidingUpPanelLayout;
import de.luhmer.owncloudnewsreader.widget.WidgetProvider;
-import static de.luhmer.owncloudnewsreader.Constants.MIN_NEXTCLOUD_FILES_APP_VERSION_CODE;
-
public abstract class PodcastFragmentActivity extends AppCompatActivity implements IPlayPausePodcastClicked {
private static final String TAG = PodcastFragmentActivity.class.getCanonicalName();
@@ -149,16 +148,7 @@ public abstract class PodcastFragmentActivity extends AppCompatActivity implemen
WidgetProvider.UpdateWidget(this);
- if (NextcloudNotificationManager.isUnreadRssCountNotificationVisible(this)) {
- DatabaseConnectionOrm dbConn = new DatabaseConnectionOrm(this);
- int count = Integer.parseInt(dbConn.getUnreadItemsCountForSpecificFolder(SubscriptionExpandableListAdapter.SPECIAL_FOLDERS.ALL_UNREAD_ITEMS));
- NextcloudNotificationManager.showUnreadRssItemsNotification(this, count, mPrefs);
-
- if (count == 0) {
- NextcloudNotificationManager.removeRssItemsNotification(this);
- }
- }
-
+ NextcloudNotificationManager.showUnreadRssItemsNotification(this, mPrefs, true);
super.onPause();
}
diff --git a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/authentication/OwnCloudSyncAdapter.java b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/authentication/OwnCloudSyncAdapter.java
index 9f695399..ae541280 100644
--- a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/authentication/OwnCloudSyncAdapter.java
+++ b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/authentication/OwnCloudSyncAdapter.java
@@ -223,7 +223,7 @@ public class OwnCloudSyncAdapter extends AbstractThreadedSyncAdapter {
// If another app is not in foreground
if (!ForegroundListener.isInForeground()) {
- NextcloudNotificationManager.showUnreadRssItemsNotification(getContext(), newItemsCount, mPrefs);
+ NextcloudNotificationManager.showUnreadRssItemsNotification(getContext(), mPrefs, false);
}
}
}
diff --git a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/database/DatabaseConnectionOrm.java b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/database/DatabaseConnectionOrm.java
index 37b4557e..a1776085 100644
--- a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/database/DatabaseConnectionOrm.java
+++ b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/database/DatabaseConnectionOrm.java
@@ -1,5 +1,10 @@
package de.luhmer.owncloudnewsreader.database;
+import static de.luhmer.owncloudnewsreader.ListView.SubscriptionExpandableListAdapter.SPECIAL_FOLDERS;
+import static de.luhmer.owncloudnewsreader.ListView.SubscriptionExpandableListAdapter.SPECIAL_FOLDERS.ALL_ITEMS;
+import static de.luhmer.owncloudnewsreader.ListView.SubscriptionExpandableListAdapter.SPECIAL_FOLDERS.ALL_STARRED_ITEMS;
+import static de.luhmer.owncloudnewsreader.ListView.SubscriptionExpandableListAdapter.SPECIAL_FOLDERS.ALL_UNREAD_ITEMS;
+
import android.content.Context;
import android.database.Cursor;
import android.os.AsyncTask;
@@ -10,8 +15,10 @@ import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
+import java.util.Set;
import javax.inject.Inject;
import javax.inject.Named;
@@ -35,11 +42,6 @@ import de.luhmer.owncloudnewsreader.model.PodcastFeedItem;
import de.luhmer.owncloudnewsreader.model.PodcastItem;
import de.luhmer.owncloudnewsreader.services.PodcastDownloadService;
-import static de.luhmer.owncloudnewsreader.ListView.SubscriptionExpandableListAdapter.SPECIAL_FOLDERS;
-import static de.luhmer.owncloudnewsreader.ListView.SubscriptionExpandableListAdapter.SPECIAL_FOLDERS.ALL_ITEMS;
-import static de.luhmer.owncloudnewsreader.ListView.SubscriptionExpandableListAdapter.SPECIAL_FOLDERS.ALL_STARRED_ITEMS;
-import static de.luhmer.owncloudnewsreader.ListView.SubscriptionExpandableListAdapter.SPECIAL_FOLDERS.ALL_UNREAD_ITEMS;
-
public class DatabaseConnectionOrm {
public static final List<String> ALLOWED_PODCASTS_TYPES = new ArrayList<String>() {
@@ -359,14 +361,27 @@ public class DatabaseConnectionOrm {
return daoSession.getRssItemDao().queryBuilder().where(RssItemDao.Properties.Read_temp.eq(false)).limit(100).orderDesc(RssItemDao.Properties.PubDate).listLazy();
}
- public LazyList<RssItem> getAllUnreadRssItemsForNotification(SORT_DIRECTION sortDirection) {
- QueryBuilder<RssItem> qb = daoSession.getRssItemDao().queryBuilder().where(RssItemDao.Properties.Read_temp.eq(false)).limit(6);
+ public Set<String> getNotificationGroups() {
+ List<Feed> feeds = daoSession.getFeedDao().loadAll();
+ String[] notificationChannelsGroups = feeds.stream().map(Feed::getNotificationChannel).toArray(String[]::new);
+ return new HashSet<>(Arrays.asList(notificationChannelsGroups));
+ }
+
+ public QueryBuilder<RssItem> getAllUnreadRssItemsForNotificationGroup(SORT_DIRECTION sortDirection, String notificationGroup) {
+ QueryBuilder<RssItem> qb = daoSession.getRssItemDao().queryBuilder()
+ .where(RssItemDao.Properties.Read_temp.eq(false));
+
+ // filter for notification group
+ qb.join(RssItemDao.Properties.FeedId, Feed.class, FeedDao.Properties.Id)
+ .where(FeedDao.Properties.NotificationChannel.eq(notificationGroup));
+
if (sortDirection == SORT_DIRECTION.asc) {
qb = qb.orderAsc(RssItemDao.Properties.PubDate);
} else {
qb = qb.orderDesc(RssItemDao.Properties.PubDate);
}
- return qb.listLazy();
+
+ return qb;
}
public void markAllItemsAsRead() {
@@ -428,13 +443,15 @@ public class DatabaseConnectionOrm {
return null;
}
- };
+ }
- public boolean doesRssItemAlreadyExsists (long feedId) {
+ /*
+ public boolean doesRssItemAlreadyExists (long feedId) {
List<RssItem> feeds = daoSession.getRssItemDao().queryBuilder().where(RssItemDao.Properties.Id.eq(feedId)).list();
return feeds.size() > 0;
}
+ */
public void removeFeedById(final long feedId) {
daoSession.runInTx(new Runnable() {
diff --git a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/database/generator/DatabaseOrmGenerator.java b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/database/generator/DatabaseOrmGenerator.java
index 0dea1d78..0c73e70c 100644
--- a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/database/generator/DatabaseOrmGenerator.java
+++ b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/database/generator/DatabaseOrmGenerator.java
@@ -1,6 +1,5 @@
package de.luhmer.owncloudnewsreader.database.generator;
-import java.io.IOException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
@@ -11,7 +10,6 @@ import de.greenrobot.daogenerator.DaoGenerator;
public class DatabaseOrmGenerator {
private static final String SCHEMA_OUTPUT_DIR = "./News-Android-App/src/main/java/";
-
/**
* Generator main application which builds all of the schema versions
* (including older versions used for migration test purposes) and ensures
@@ -21,7 +19,7 @@ public class DatabaseOrmGenerator {
public static void main(String[] args) throws Exception {
List<SchemaVersion> versions = new ArrayList<>();
- versions.add(new Version7(true));
+ versions.add(new Version8(true));
validateSchemas(versions);
diff --git a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/database/generator/SchemaVersion.java b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/database/generator/SchemaVersion.java
index 66528129..4ee11804 100644
--- a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/database/generator/SchemaVersion.java
+++ b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/database/generator/SchemaVersion.java
@@ -6,7 +6,6 @@ public abstract class SchemaVersion {
public static final String CURRENT_SCHEMA_PACKAGE = "de.luhmer.owncloudnewsreader.database.model";
-
private final Schema schema;
private final boolean current;
diff --git a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/database/generator/Version7.java b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/database/generator/Version8.java
index 06c144e0..fea745e4 100644
--- a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/database/generator/Version7.java
+++ b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/database/generator/Version8.java
@@ -4,28 +4,20 @@ import de.greenrobot.daogenerator.Entity;
import de.greenrobot.daogenerator.Property;
import de.greenrobot.daogenerator.Schema;
-public class Version7 extends SchemaVersion {
+public class Version8 extends SchemaVersion {
/**
* Constructor
*
* @param current
*/
- public Version7(boolean current) {
+ public Version8(boolean current) {
super(current);
Schema schema = getSchema();
addEntitysToSchema(schema);
}
- /**
- * {@inheritDoc}
- */
- @Override
- public int getVersionNumber() {
- return 7;
- }
-
@SuppressWarnings("unused") // id properties (folderId, etc.) need to be in database
private static void addEntitysToSchema(Schema schema) {
@@ -43,6 +35,7 @@ public class Version7 extends SchemaVersion {
feed.addStringProperty("faviconUrl");
feed.addStringProperty("link");
feed.addStringProperty("avgColour");
+ feed.addStringProperty("notificationChannel"); // none, default, <anything-else>
@@ -82,8 +75,6 @@ public class Version7 extends SchemaVersion {
rssItem.addToOne(feed, rssItemFeedId);
-
-
Entity rssItemView = schema.addEntity("CurrentRssItemView");
rssItemView.addIdProperty().notNull();
rssItemView.addLongProperty("rssItemId").notNull();
@@ -91,4 +82,12 @@ public class Version7 extends SchemaVersion {
rssItem.implementsInterface("HasId<Long>");
}
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int getVersionNumber() {
+ return 8;
+ }
}
diff --git a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/database/model/CurrentRssItemViewDao.java b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/database/model/CurrentRssItemViewDao.java
index 399bfbc0..1bd9c10f 100644
--- a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/database/model/CurrentRssItemViewDao.java
+++ b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/database/model/CurrentRssItemViewDao.java
@@ -9,27 +9,26 @@ import de.greenrobot.dao.Property;
import de.greenrobot.dao.internal.DaoConfig;
// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
-/**
+/**
* DAO for table "CURRENT_RSS_ITEM_VIEW".
-*/
+ */
public class CurrentRssItemViewDao extends AbstractDao<CurrentRssItemView, Long> {
public static final String TABLENAME = "CURRENT_RSS_ITEM_VIEW";
- /**
- * Properties of entity CurrentRssItemView.<br/>
- * Can be used for QueryBuilder and for referencing column names.
- */
- public static class Properties {
- public final static Property Id = new Property(0, long.class, "id", true, "_id");
- public final static Property RssItemId = new Property(1, long.class, "rssItemId", false, "RSS_ITEM_ID");
- };
+ /** @inheritdoc */
+ @Override
+ protected void bindValues(SQLiteStatement stmt, CurrentRssItemView entity) {
+ stmt.clearBindings();
+ stmt.bindLong(1, entity.getId());
+ stmt.bindLong(2, entity.getRssItemId());
+ }
public CurrentRssItemViewDao(DaoConfig config) {
super(config);
}
-
+
public CurrentRssItemViewDao(DaoConfig config, DaoSession daoSession) {
super(config, daoSession);
}
@@ -48,50 +47,71 @@ public class CurrentRssItemViewDao extends AbstractDao<CurrentRssItemView, Long>
db.execSQL(sql);
}
- @Override
- protected void bindValues(SQLiteStatement stmt, CurrentRssItemView entity) {
- stmt.clearBindings();
- stmt.bindLong(1, entity.getId());
- stmt.bindLong(2, entity.getRssItemId());
- }
-
+ /**
+ * @inheritdoc
+ */
@Override
public Long readKey(Cursor cursor, int offset) {
- return cursor.getLong(offset);
- }
+ return cursor.getLong(offset + 0);
+ }
+ /**
+ * @inheritdoc
+ */
@Override
public CurrentRssItemView readEntity(Cursor cursor, int offset) {
- return new CurrentRssItemView( //
- cursor.getLong(offset), // id
- cursor.getLong(offset + 1) // rssItemId
+ CurrentRssItemView entity = new CurrentRssItemView( //
+ cursor.getLong(offset + 0), // id
+ cursor.getLong(offset + 1) // rssItemId
);
+ return entity;
}
-
+
+ /**
+ * @inheritdoc
+ */
@Override
public void readEntity(Cursor cursor, CurrentRssItemView entity, int offset) {
- entity.setId(cursor.getLong(offset));
+ entity.setId(cursor.getLong(offset + 0));
entity.setRssItemId(cursor.getLong(offset + 1));
- }
-
+ }
+
+ /**
+ * @inheritdoc
+ */
@Override
protected Long updateKeyAfterInsert(CurrentRssItemView entity, long rowId) {
entity.setId(rowId);
return rowId;
}
-
+
+ /**
+ * @inheritdoc
+ */
@Override
public Long getKey(CurrentRssItemView entity) {
- if(entity != null) {
+ if (entity != null) {
return entity.getId();
} else {
return null;
}
}
+ /**
+ * @inheritdoc
+ */
@Override
protected boolean isEntityUpdateable() {
return true;
}
+
+ /**
+ * Properties of entity CurrentRssItemView.<br/>
+ * Can be used for QueryBuilder and for referencing column names.
+ */
+ public static class Properties {
+ public final static Property Id = new Property(0, long.class, "id", true, "_id");
+ public final static Property RssItemId = new Property(1, long.class, "rssItemId", false, "RSS_ITEM_ID");
+ }
}
diff --git a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/database/model/DaoMaster.java b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/database/model/DaoMaster.java
index 90b1e600..53b01a3f 100644
--- a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/database/model/DaoMaster.java
+++ b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/database/model/DaoMaster.java
@@ -10,11 +10,11 @@ import de.greenrobot.dao.AbstractDaoMaster;
import de.greenrobot.dao.identityscope.IdentityScopeType;
// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
-/**
- * Master of DAO (schema version 7): knows all DAOs.
-*/
+/**
+ * Master of DAO (schema version 8): knows all DAOs.
+ */
public class DaoMaster extends AbstractDaoMaster {
- public static final int SCHEMA_VERSION = 7;
+ public static final int SCHEMA_VERSION = 8;
/** Creates underlying database table using DAOs. */
public static void createAllTables(SQLiteDatabase db, boolean ifNotExists) {
diff --git a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/database/model/Feed.java b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/database/model/Feed.java
index eb883555..7e0c7d46 100644
--- a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/database/model/Feed.java
+++ b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/database/model/Feed.java
@@ -20,6 +20,7 @@ public class Feed {
private String faviconUrl;
private String link;
private String avgColour;
+ private String notificationChannel;
/** Used to resolve relations */
private transient DaoSession daoSession;
@@ -42,13 +43,14 @@ public class Feed {
this.id = id;
}
- public Feed(long id, Long folderId, String feedTitle, String faviconUrl, String link, String avgColour) {
+ public Feed(long id, Long folderId, String feedTitle, String faviconUrl, String link, String avgColour, String notificationChannel) {
this.id = id;
this.folderId = folderId;
this.feedTitle = feedTitle;
this.faviconUrl = faviconUrl;
this.link = link;
this.avgColour = avgColour;
+ this.notificationChannel = notificationChannel;
}
/** called by internal mechanisms, do not call yourself. */
@@ -107,7 +109,17 @@ public class Feed {
this.avgColour = avgColour;
}
- /** To-one relationship, resolved on first access. */
+ public String getNotificationChannel() {
+ return notificationChannel;
+ }
+
+ public void setNotificationChannel(String notificationChannel) {
+ this.notificationChannel = notificationChannel;
+ }
+
+ /**
+ * To-one relationship, resolved on first access.
+ */
public Folder getFolder() {
Long __key = this.folderId;
if (folder__resolvedKey == null || !folder__resolvedKey.equals(__key)) {
diff --git a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/database/model/FeedDao.java b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/database/model/FeedDao.java
index 18d62970..45cf8e4c 100644
--- a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/database/model/FeedDao.java
+++ b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/database/model/FeedDao.java
@@ -22,32 +22,6 @@ public class FeedDao extends AbstractDao<Feed, Long> {
public static final String TABLENAME = "FEED";
- /**
- * Properties of entity Feed.<br/>
- * Can be used for QueryBuilder and for referencing column names.
- */
- public static class Properties {
- public final static Property Id = new Property(0, long.class, "id", true, "_id");
- public final static Property FolderId = new Property(1, Long.class, "folderId", false, "FOLDER_ID");
- public final static Property FeedTitle = new Property(2, String.class, "feedTitle", false, "FEED_TITLE");
- public final static Property FaviconUrl = new Property(3, String.class, "faviconUrl", false, "FAVICON_URL");
- public final static Property Link = new Property(4, String.class, "link", false, "LINK");
- public final static Property AvgColour = new Property(5, String.class, "avgColour", false, "AVG_COLOUR");
- };
-
- private DaoSession daoSession;
-
- private Query<Feed> folder_FeedListQuery;
-
- public FeedDao(DaoConfig config) {
- super(config);
- }
-
- public FeedDao(DaoConfig config, DaoSession daoSession) {
- super(config, daoSession);
- this.daoSession = daoSession;
- }
-
/** Creates the underlying database table. */
public static void createTable(SQLiteDatabase db, boolean ifNotExists) {
String constraint = ifNotExists? "IF NOT EXISTS ": "";
@@ -57,44 +31,75 @@ public class FeedDao extends AbstractDao<Feed, Long> {
"\"FEED_TITLE\" TEXT NOT NULL ," + // 2: feedTitle
"\"FAVICON_URL\" TEXT," + // 3: faviconUrl
"\"LINK\" TEXT," + // 4: link
- "\"AVG_COLOUR\" TEXT);"); // 5: avgColour
+ "\"AVG_COLOUR\" TEXT," + // 5: avgColour
+ "\"NOTIFICATION_CHANNEL\" TEXT);"); // 6: notificationChannel
// Add Indexes
db.execSQL("CREATE INDEX " + constraint + "IDX_FEED_FOLDER_ID ON FEED" +
" (\"FOLDER_ID\");");
}
- /** Drops the underlying database table. */
- public static void dropTable(SQLiteDatabase db, boolean ifExists) {
- String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"FEED\"";
- db.execSQL(sql);
+ private DaoSession daoSession;
+
+ private Query<Feed> folder_FeedListQuery;
+
+ public FeedDao(DaoConfig config) {
+ super(config);
}
- /** @inheritdoc */
+ public FeedDao(DaoConfig config, DaoSession daoSession) {
+ super(config, daoSession);
+ this.daoSession = daoSession;
+ }
+
+ /**
+ * @inheritdoc
+ */
@Override
protected void bindValues(SQLiteStatement stmt, Feed entity) {
stmt.clearBindings();
stmt.bindLong(1, entity.getId());
-
+
Long folderId = entity.getFolderId();
if (folderId != null) {
stmt.bindLong(2, folderId);
}
stmt.bindString(3, entity.getFeedTitle());
-
+
String faviconUrl = entity.getFaviconUrl();
if (faviconUrl != null) {
stmt.bindString(4, faviconUrl);
}
-
+
String link = entity.getLink();
if (link != null) {
stmt.bindString(5, link);
}
-
+
String avgColour = entity.getAvgColour();
if (avgColour != null) {
stmt.bindString(6, avgColour);
}
+
+ String notificationChannel = entity.getNotificationChannel();
+ if (notificationChannel != null) {
+ stmt.bindString(7, notificationChannel);
+ }
+ }
+
+ /**
+ * Drops the underlying database table.
+ */
+ public static void dropTable(SQLiteDatabase db, boolean ifExists) {
+ String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"FEED\"";
+ db.execSQL(sql);
+ }
+
+ /**
+ * @inheritdoc
+ */
+ @Override
+ public Long readKey(Cursor cursor, int offset) {
+ return cursor.getLong(offset + 0);
}
@Override
@@ -103,37 +108,67 @@ public class FeedDao extends AbstractDao<Feed, Long> {
entity.__setDaoSession(daoSession);
}
- /** @inheritdoc */
- @Override
- public Long readKey(Cursor cursor, int offset) {
- return cursor.getLong(offset);
- }
-
- /** @inheritdoc */
+ /**
+ * @inheritdoc
+ */
@Override
public Feed readEntity(Cursor cursor, int offset) {
- return new Feed( //
- cursor.getLong(offset), // id
- cursor.isNull(offset + 1) ? null : cursor.getLong(offset + 1), // folderId
- cursor.getString(offset + 2), // feedTitle
- cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // faviconUrl
- cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // link
- cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5) // avgColour
+ Feed entity = new Feed( //
+ cursor.getLong(offset + 0), // id
+ cursor.isNull(offset + 1) ? null : cursor.getLong(offset + 1), // folderId
+ cursor.getString(offset + 2), // feedTitle
+ cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // faviconUrl
+ cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // link
+ cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // avgColour
+ cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6) // notificationChannel
);
+ return entity;
}
-
- /** @inheritdoc */
+
+ /**
+ * @inheritdoc
+ */
@Override
public void readEntity(Cursor cursor, Feed entity, int offset) {
- entity.setId(cursor.getLong(offset));
+ entity.setId(cursor.getLong(offset + 0));
entity.setFolderId(cursor.isNull(offset + 1) ? null : cursor.getLong(offset + 1));
entity.setFeedTitle(cursor.getString(offset + 2));
entity.setFaviconUrl(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
entity.setLink(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
entity.setAvgColour(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5));
- }
-
- /** @inheritdoc */
+ entity.setNotificationChannel(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6));
+ }
+
+ public Feed loadDeep(Long key) {
+ assertSinglePk();
+ if (key == null) {
+ return null;
+ }
+
+ StringBuilder builder = new StringBuilder(getSelectDeep());
+ builder.append("WHERE ");
+ SqlUtils.appendColumnsEqValue(builder, "T", getPkColumns());
+ String sql = builder.toString();
+
+ String[] keyArray = new String[]{key.toString()};
+ Cursor cursor = db.rawQuery(sql, keyArray);
+
+ try {
+ boolean available = cursor.moveToFirst();
+ if (!available) {
+ return null;
+ } else if (!cursor.isLast()) {
+ throw new IllegalStateException("Expected unique result, but count was " + cursor.getCount());
+ }
+ return loadCurrentDeep(cursor, true);
+ } finally {
+ cursor.close();
+ }
+ }
+
+ /**
+ * @inheritdoc
+ */
@Override
protected Long updateKeyAfterInsert(Feed entity, long rowId) {
entity.setId(rowId);
@@ -185,7 +220,7 @@ public class FeedDao extends AbstractDao<Feed, Long> {
}
return selectDeep;
}
-
+
protected Feed loadCurrentDeep(Cursor cursor, boolean lock) {
Feed entity = loadCurrent(cursor, 0, lock);
int offset = getAllColumns().length;
@@ -193,38 +228,30 @@ public class FeedDao extends AbstractDao<Feed, Long> {
Folder folder = loadCurrentOther(daoSession.getFolderDao(), cursor, offset);
entity.setFolder(folder);
- return entity;
+ return entity;
}
- public Feed loadDeep(Long key) {
- assertSinglePk();
- if (key == null) {
- return null;
- }
-
- StringBuilder builder = new StringBuilder(getSelectDeep());
- builder.append("WHERE ");
- SqlUtils.appendColumnsEqValue(builder, "T", getPkColumns());
- String sql = builder.toString();
-
- String[] keyArray = new String[] { key.toString() };
-
- try (Cursor cursor = db.rawQuery(sql, keyArray)) {
- boolean available = cursor.moveToFirst();
- if (!available) {
- return null;
- } else if (!cursor.isLast()) {
- throw new IllegalStateException("Expected unique result, but count was " + cursor.getCount());
- }
- return loadCurrentDeep(cursor, true);
- }
+ /**
+ * Properties of entity Feed.<br/>
+ * Can be used for QueryBuilder and for referencing column names.
+ */
+ public static class Properties {
+ public final static Property Id = new Property(0, long.class, "id", true, "_id");
+ public final static Property FolderId = new Property(1, Long.class, "folderId", false, "FOLDER_ID");
+ public final static Property FeedTitle = new Property(2, String.class, "feedTitle", false, "FEED_TITLE");
+ public final static Property FaviconUrl = new Property(3, String.class, "faviconUrl", false, "FAVICON_URL");
+ public final static Property Link = new Property(4, String.class, "link", false, "LINK");
+ public final static Property AvgColour = new Property(5, String.class, "avgColour", false, "AVG_COLOUR");
+ public final static Property NotificationChannel = new Property(6, String.class, "notificationChannel", false, "NOTIFICATION_CHANNEL");
}
-
- /** Reads all available rows from the given cursor and returns a list of new ImageTO objects. */
+
+ /**
+ * Reads all available rows from the given cursor and returns a list of new ImageTO objects.
+ */
public List<Feed> loadAllDeepFromCursor(Cursor cursor) {
int count = cursor.getCount();
List<Feed> list = new ArrayList<Feed>(count);
-
+
if (cursor.moveToFirst()) {
if (identityScope != null) {
identityScope.lock();
diff --git a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/database/model/FolderDao.java b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/database/model/FolderDao.java
index f43b942d..b17151d0 100644
--- a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/database/model/FolderDao.java
+++ b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/database/model/FolderDao.java
@@ -9,21 +9,18 @@ import de.greenrobot.dao.Property;
import de.greenrobot.dao.internal.DaoConfig;
// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
-/**
+/**
* DAO for table "FOLDER".
-*/
+ */
public class FolderDao extends AbstractDao<Folder, Long> {
public static final String TABLENAME = "FOLDER";
- /**
- * Properties of entity Folder.<br/>
- * Can be used for QueryBuilder and for referencing column names.
- */
- public static class Properties {
- public final static Property Id = new Property(0, long.class, "id", true, "_id");
- public final static Property Label = new Property(1, String.class, "label", false, "LABEL");
- };
+ /** @inheritdoc */
+ @Override
+ public Long readKey(Cursor cursor, int offset) {
+ return cursor.getLong(offset + 0);
+ }
private DaoSession daoSession;
@@ -31,7 +28,7 @@ public class FolderDao extends AbstractDao<Folder, Long> {
public FolderDao(DaoConfig config) {
super(config);
}
-
+
public FolderDao(DaoConfig config, DaoSession daoSession) {
super(config, daoSession);
this.daoSession = daoSession;
@@ -67,34 +64,44 @@ public class FolderDao extends AbstractDao<Folder, Long> {
/** @inheritdoc */
@Override
- public Long readKey(Cursor cursor, int offset) {
- return cursor.getLong(offset);
- }
-
- /** @inheritdoc */
- @Override
public Folder readEntity(Cursor cursor, int offset) {
- return new Folder( //
- cursor.getLong(offset), // id
- cursor.getString(offset + 1) // label
+ Folder entity = new Folder( //
+ cursor.getLong(offset + 0), // id
+ cursor.getString(offset + 1) // label
);
+ return entity;
}
-
- /** @inheritdoc */
+
+ /**
+ * @inheritdoc
+ */
@Override
public void readEntity(Cursor cursor, Folder entity, int offset) {
- entity.setId(cursor.getLong(offset));
+ entity.setId(cursor.getLong(offset + 0));
entity.setLabel(cursor.getString(offset + 1));
- }
-
- /** @inheritdoc */
+ }
+
+ /**
+ * Properties of entity Folder.<br/>
+ * Can be used for QueryBuilder and for referencing column names.
+ */
+ public static class Properties {
+ public final static Property Id = new Property(0, long.class, "id", true, "_id");
+ public final static Property Label = new Property(1, String.class, "label", false, "LABEL");
+ }
+
+ /**
+ * @inheritdoc
+ */
@Override
protected Long updateKeyAfterInsert(Folder entity, long rowId) {
entity.setId(rowId);
return rowId;
}
-
- /** @inheritdoc */
+
+ /**
+ * @inheritdoc
+ */
@Override
public Long getKey(Folder entity) {
if(entity != null) {
diff --git a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/database/model/RssItemDao.java b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/database/model/RssItemDao.java
index 38f19bc8..d6ba7141 100644
--- a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/database/model/RssItemDao.java
+++ b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/database/model/RssItemDao.java
@@ -15,39 +15,18 @@ import de.greenrobot.dao.query.Query;
import de.greenrobot.dao.query.QueryBuilder;
// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
-/**
+/**
* DAO for table "RSS_ITEM".
-*/
+ */
public class RssItemDao extends AbstractDao<RssItem, Long> {
public static final String TABLENAME = "RSS_ITEM";
- /**
- * Properties of entity RssItem.<br/>
- * Can be used for QueryBuilder and for referencing column names.
- */
- public static class Properties {
- public final static Property Id = new Property(0, long.class, "id", true, "_id");
- public final static Property FeedId = new Property(1, long.class, "feedId", false, "FEED_ID");
- public final static Property Link = new Property(2, String.class, "link", false, "LINK");
- public final static Property Title = new Property(3, String.class, "title", false, "TITLE");
- public final static Property Body = new Property(4, String.class, "body", false, "BODY");
- public final static Property Read = new Property(5, Boolean.class, "read", false, "READ");
- public final static Property Starred = new Property(6, Boolean.class, "starred", false, "STARRED");
- public final static Property Author = new Property(7, String.class, "author", false, "AUTHOR");
- public final static Property Guid = new Property(8, String.class, "guid", false, "GUID");
- public final static Property GuidHash = new Property(9, String.class, "guidHash", false, "GUID_HASH");
- public final static Property Fingerprint = new Property(10, String.class, "fingerprint", false, "FINGERPRINT");
- public final static Property Read_temp = new Property(11, Boolean.class, "read_temp", false, "READ_TEMP");
- public final static Property Starred_temp = new Property(12, Boolean.class, "starred_temp", false, "STARRED_TEMP");
- public final static Property LastModified = new Property(13, java.util.Date.class, "lastModified", false, "LAST_MODIFIED");
- public final static Property PubDate = new Property(14, java.util.Date.class, "pubDate", false, "PUB_DATE");
- public final static Property EnclosureLink = new Property(15, String.class, "enclosureLink", false, "ENCLOSURE_LINK");
- public final static Property EnclosureMime = new Property(16, String.class, "enclosureMime", false, "ENCLOSURE_MIME");
- public final static Property MediaThumbnail = new Property(17, String.class, "mediaThumbnail", false, "MEDIA_THUMBNAIL");
- public final static Property MediaDescription = new Property(18, String.class, "mediaDescription", false, "MEDIA_DESCRIPTION");
- public final static Property Rtl = new Property(19, Boolean.class, "rtl", false, "RTL");
- };
+ /** @inheritdoc */
+ @Override
+ public Long readKey(Cursor cursor, int offset) {
+ return cursor.getLong(offset + 0);
+ }
private DaoSession daoSession;
@@ -56,7 +35,7 @@ public class RssItemDao extends AbstractDao<RssItem, Long> {
public RssItemDao(DaoConfig config) {
super(config);
}
-
+
public RssItemDao(DaoConfig config, DaoSession daoSession) {
super(config, daoSession);
this.daoSession = daoSession;
@@ -187,25 +166,19 @@ public class RssItemDao extends AbstractDao<RssItem, Long> {
/** @inheritdoc */
@Override
- public Long readKey(Cursor cursor, int offset) {
- return cursor.getLong(offset);
- }
-
- /** @inheritdoc */
- @Override
public RssItem readEntity(Cursor cursor, int offset) {
- return new RssItem( //
- cursor.getLong(offset), // id
- cursor.getLong(offset + 1), // feedId
- cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // link
- cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // title
- cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // body
- cursor.isNull(offset + 5) ? null : cursor.getShort(offset + 5) != 0, // read
- cursor.isNull(offset + 6) ? null : cursor.getShort(offset + 6) != 0, // starred
- cursor.getString(offset + 7), // author
- cursor.getString(offset + 8), // guid
- cursor.getString(offset + 9), // guidHash
- cursor.getString(offset + 10), // fingerprint
+ RssItem entity = new RssItem( //
+ cursor.getLong(offset + 0), // id
+ cursor.getLong(offset + 1), // feedId
+ cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // link
+ cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // title
+ cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // body
+ cursor.isNull(offset + 5) ? null : cursor.getShort(offset + 5) != 0, // read
+ cursor.isNull(offset + 6) ? null : cursor.getShort(offset + 6) != 0, // starred
+ cursor.getString(offset + 7), // author
+ cursor.getString(offset + 8), // guid
+ cursor.getString(offset + 9), // guidHash
+ cursor.getString(offset + 10), // fingerprint
cursor.isNull(offset + 11) ? null : cursor.getShort(offset + 11) != 0, // read_temp
cursor.isNull(offset + 12) ? null : cursor.getShort(offset + 12) != 0, // starred_temp
cursor.isNull(offset + 13) ? null : new java.util.Date(cursor.getLong(offset + 13)), // lastModified
@@ -216,12 +189,13 @@ public class RssItemDao extends AbstractDao<RssItem, Long> {
cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18), // mediaDescription
cursor.isNull(offset + 19) ? null : cursor.getShort(offset + 19) != 0 // rtl
);
+ return entity;
}
-
+
/** @inheritdoc */
@Override
public void readEntity(Cursor cursor, RssItem entity, int offset) {
- entity.setId(cursor.getLong(offset));
+ entity.setId(cursor.getLong(offset + 0));
entity.setFeedId(cursor.getLong(offset + 1));
entity.setLink(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
entity.setTitle(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
@@ -241,16 +215,47 @@ public class RssItemDao extends AbstractDao<RssItem, Long> {
entity.setMediaThumbnail(cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17));
entity.setMediaDescription(cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18));
entity.setRtl(cursor.isNull(offset + 19) ? null : cursor.getShort(offset + 19) != 0);
- }
-
- /** @inheritdoc */
+ }
+
+ public RssItem loadDeep(Long key) {
+ assertSinglePk();
+ if (key == null) {
+ return null;
+ }
+
+ StringBuilder builder = new StringBuilder(getSelectDeep());
+ builder.append("WHERE ");
+ SqlUtils.appendColumnsEqValue(builder, "T", getPkColumns());
+ String sql = builder.toString();
+
+ String[] keyArray = new String[]{key.toString()};
+ Cursor cursor = db.rawQuery(sql, keyArray);
+
+ try {
+ boolean available = cursor.moveToFirst();
+ if (!available) {
+ return null;
+ } else if (!cursor.isLast()) {
+ throw new IllegalStateException("Expected unique result, but count was " + cursor.getCount());
+ }
+ return loadCurrentDeep(cursor, true);
+ } finally {
+ cursor.close();
+ }
+ }
+
+ /**
+ * @inheritdoc
+ */
@Override
protected Long updateKeyAfterInsert(RssItem entity, long rowId) {
entity.setId(rowId);
return rowId;
}
-
- /** @inheritdoc */
+
+ /**
+ * @inheritdoc
+ */
@Override
public Long getKey(RssItem entity) {
if(entity != null) {
@@ -301,42 +306,47 @@ public class RssItemDao extends AbstractDao<RssItem, Long> {
int offset = getAllColumns().length;
Feed feed = loadCurrentOther(daoSession.getFeedDao(), cursor, offset);
- if(feed != null) {
+ if (feed != null) {
entity.setFeed(feed);
}
- return entity;
+ return entity;
}
- public RssItem loadDeep(Long key) {
- assertSinglePk();
- if (key == null) {
- return null;
- }
-
- StringBuilder builder = new StringBuilder(getSelectDeep());
- builder.append("WHERE ");
- SqlUtils.appendColumnsEqValue(builder, "T", getPkColumns());
- String sql = builder.toString();
-
- String[] keyArray = new String[] { key.toString() };
-
- try (Cursor cursor = db.rawQuery(sql, keyArray)) {
- boolean available = cursor.moveToFirst();
- if (!available) {
- return null;
- } else if (!cursor.isLast()) {
- throw new IllegalStateException("Expected unique result, but count was " + cursor.getCount());
- }
- return loadCurrentDeep(cursor, true);
- }
+ /**
+ * Properties of entity RssItem.<br/>
+ * Can be used for QueryBuilder and for referencing column names.
+ */
+ public static class Properties {
+ public final static Property Id = new Property(0, long.class, "id", true, "_id");
+ public final static Property FeedId = new Property(1, long.class, "feedId", false, "FEED_ID");
+ public final static Property Link = new Property(2, String.class, "link", false, "LINK");
+ public final static Property Title = new Property(3, String.class, "title", false, "TITLE");
+ public final static Property Body = new Property(4, String.class, "body", false, "BODY");
+ public final static Property Read = new Property(5, Boolean.class, "read", false, "READ");
+ public final static Property Starred = new Property(6, Boolean.class, "starred", false, "STARRED");
+ public final static Property Author = new Property(7, String.class, "author", false, "AUTHOR");
+ public final static Property Guid = new Property(8, String.class, "guid", false, "GUID");
+ public final static Property GuidHash = new Property(9, String.class, "guidHash", false, "GUID_HASH");
+ public final static Property Fingerprint = new Property(10, String.class, "fingerprint", false, "FINGERPRINT");
+ public final static Property Read_temp = new Property(11, Boolean.class, "read_temp", false, "READ_TEMP");
+ public final static Property Starred_temp = new Property(12, Boolean.class, "starred_temp", false, "STARRED_TEMP");
+ public final static Property LastModified = new Property(13, java.util.Date.class, "lastModified", false, "LAST_MODIFIED");
+ public final static Property PubDate = new Property(14, java.util.Date.class, "pubDate", false, "PUB_DATE");
+ public final static Property EnclosureLink = new Property(15, String.class, "enclosureLink", false, "ENCLOSURE_LINK");
+ public final static Property EnclosureMime = new Property(16, String.class, "enclosureMime", false, "ENCLOSURE_MIME");
+ public final static Property MediaThumbnail = new Property(17, String.class, "mediaThumbnail", false, "MEDIA_THUMBNAIL");
+ public final static Property MediaDescription = new Property(18, String.class, "mediaDescription", false, "MEDIA_DESCRIPTION");
+ public final static Property Rtl = new Property(19, Boolean.class, "rtl", false, "RTL");
}
-
- /** Reads all available rows from the given cursor and returns a list of new ImageTO objects. */
+
+ /**
+ * Reads all available rows from the given cursor and returns a list of new ImageTO objects.
+ */
public List<RssItem> loadAllDeepFromCursor(Cursor cursor) {
int count = cursor.getCount();
List<RssItem> list = new ArrayList<RssItem>(count);
-
+
if (cursor.moveToFirst()) {
if (identityScope != null) {
identityScope.lock();
diff --git a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/notification/NextcloudNotificationManager.java b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/notification/NextcloudNotificationManager.java
index b7eeb9ce..2fd19d5f 100644
--- a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/notification/NextcloudNotificationManager.java
+++ b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/notification/NextcloudNotificationManager.java
@@ -34,7 +34,9 @@ import com.nostra13.universalimageloader.core.assist.ImageSize;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
+import java.util.Set;
+import de.greenrobot.dao.query.QueryBuilder;
import de.luhmer.owncloudnewsreader.BuildConfig;
import de.luhmer.owncloudnewsreader.NewsReaderListActivity;
import de.luhmer.owncloudnewsreader.R;
@@ -46,7 +48,7 @@ import de.luhmer.owncloudnewsreader.helper.NotificationActionReceiver;
public class NextcloudNotificationManager {
private static final int ID_DownloadSingleImageComplete = 10;
- private static final int UNREAD_RSS_ITEMS_NOTIFICATION_ID = 246;
+ // private static final int UNREAD_RSS_ITEMS_NOTIFICATION_ID = 246;
public static void showNotificationDownloadSingleImageComplete(Context context, File imagePath) {
String channelDownloadImage = context.getString(R.string.action_img_download);
@@ -262,66 +264,84 @@ public class NextcloudNotificationManager {
}
- public static void showUnreadRssItemsNotification(Context context, int newItemsCount, SharedPreferences mPrefs) {
+ public static void showUnreadRssItemsNotification(Context context, SharedPreferences mPrefs, Boolean updateExistingNotificationsOnly) {
Resources res = context.getResources();
- String tickerMessage = res.getQuantityString(R.plurals.notification_new_items_ticker, newItemsCount, newItemsCount);
- String contentText = res.getQuantityString(R.plurals.notification_new_items_text, newItemsCount, newItemsCount);
String channelId = context.getString(R.string.app_name);
NotificationManager notificationManager = getNotificationManagerAndCreateChannel(context, channelId);
DatabaseConnectionOrm dbConn = new DatabaseConnectionOrm(context);
DatabaseConnectionOrm.SORT_DIRECTION sortDirection = DatabaseUtils.getSortDirectionFromSettings(mPrefs);
- List<RssItem> items = dbConn.getAllUnreadRssItemsForNotification(sortDirection);
- List<String> previewLines = new ArrayList<>();
- for (RssItem item : items) {
- // • = \u2022, ● = \u25CF, ○ = \u25CB, ▪ = \u25AA, ■ = \u25A0, □ = \u25A1, ► = \u25BA
- previewLines.add("\u2022 " + item.getTitle().trim());
+ Set<String> notificationGroups = dbConn.getNotificationGroups();
+ for (String notificationGroup : notificationGroups) {
+ // use hashcode for notification group as identifier for the notification
+ Integer notificationId = notificationGroup.hashCode();
+
+ QueryBuilder<RssItem> qbItemsForNotificationGroup = dbConn.getAllUnreadRssItemsForNotificationGroup(sortDirection, notificationGroup);
+
+ Integer newItemsCount = Math.toIntExact(qbItemsForNotificationGroup.count());
+ List<RssItem> items = qbItemsForNotificationGroup.limit(6).list(); // only read 6 items from database
+ String tickerMessage = res.getQuantityString(R.plurals.notification_new_items_ticker, newItemsCount, newItemsCount);
+ String contentText = res.getQuantityString(R.plurals.notification_new_items_text, newItemsCount, newItemsCount);
+ if (items.size() > 0) {
+ contentText = "\u2022 " + items.get(0).getTitle();
+ }
+ String contentTitle = notificationGroup.equals("default") ? tickerMessage : String.format("[%s] %s", notificationGroup, tickerMessage);
+
+ List<String> previewLines = new ArrayList<>();
+ for (RssItem item : items) {
+ // • = \u2022, ● = \u25CF, ○ = \u25CB, ▪ = \u25AA, ■ = \u25A0, □ = \u25A1, ► = \u25BA
+ previewLines.add("\u2022 " + item.getTitle().trim());
+ }
+ String previewText = TextUtils.join("\n", previewLines);
+
+ Intent markAllAsReadIntent = new Intent(context, NotificationActionReceiver.class);
+ markAllAsReadIntent.setAction(NOTIFICATION_ACTION_MARK_ALL_AS_READ_STRING);
+ markAllAsReadIntent.putExtra(EXTRA_NOTIFICATION_ID, notificationId);
+ PendingIntent markAllAsReadPendingIntent = PendingIntent.getBroadcast(context, 0, markAllAsReadIntent, PendingIntent.FLAG_ONE_SHOT);
+
+ NotificationCompat.Builder builder =
+ new NotificationCompat.Builder(context, channelId)
+ .setSmallIcon(R.drawable.ic_notification)
+ .setContentTitle(contentTitle)
+ .setStyle(new NotificationCompat.BigTextStyle().bigText(previewText))
+ //.setDefaults(Notification.DEFAULT_ALL)
+ .addAction(R.drawable.ic_checkbox_white, context.getString(R.string.menu_markAllAsRead), markAllAsReadPendingIntent)
+ .setAutoCancel(true)
+ .setNumber(newItemsCount)
+ .setContentText(contentText);
+
+
+ Intent notificationIntent = new Intent(context, NewsReaderListActivity.class);
+ PendingIntent contentIntent = PendingIntent.getActivity(context, notificationId, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
+ builder.setContentIntent(contentIntent);
+
+ // if the user exists the app we need to update the notifications - but only if the notification is already visible
+ if (updateExistingNotificationsOnly && !isUnreadRssCountNotificationVisible(context, notificationId)) {
+ continue;
+ }
+
+ if (newItemsCount > 0) {
+ notificationManager.notify(notificationId, builder.build());
+ } else {
+ // no new items available - hide/remove notification
+ notificationManager.cancel(notificationId);
+ }
}
- String previewText = TextUtils.join("\n", previewLines);
-
- Intent markAllAsReadIntent = new Intent(context, NotificationActionReceiver.class);
- markAllAsReadIntent.setAction(NOTIFICATION_ACTION_MARK_ALL_AS_READ_STRING);
- markAllAsReadIntent.putExtra(EXTRA_NOTIFICATION_ID, UNREAD_RSS_ITEMS_NOTIFICATION_ID);
- PendingIntent markAllAsReadPendingIntent = PendingIntent.getBroadcast(context, 0, markAllAsReadIntent, PendingIntent.FLAG_ONE_SHOT);
-
- NotificationCompat.Builder builder =
- new NotificationCompat.Builder(context, channelId)
- .setSmallIcon(R.drawable.ic_notification)
- .setContentTitle(tickerMessage)
- .setStyle(new NotificationCompat.BigTextStyle().bigText(previewText))
- //.setDefaults(Notification.DEFAULT_ALL)
- .addAction(R.drawable.ic_checkbox_white, context.getString(R.string.menu_markAllAsRead), markAllAsReadPendingIntent)
- .setAutoCancel(true)
- .setNumber(newItemsCount)
- .setContentText(contentText);
-
-
- Intent notificationIntent = new Intent(context, NewsReaderListActivity.class);
- PendingIntent contentIntent = PendingIntent.getActivity(context, UNREAD_RSS_ITEMS_NOTIFICATION_ID, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
- builder.setContentIntent(contentIntent);
-
- notificationManager.notify(UNREAD_RSS_ITEMS_NOTIFICATION_ID, builder.build());
}
- public static boolean isUnreadRssCountNotificationVisible(Context context) {
+ public static boolean isUnreadRssCountNotificationVisible(Context context, Integer notificationId) {
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
- for(StatusBarNotification statusBarNotification : notificationManager.getActiveNotifications()) {
- if(statusBarNotification.getId() == UNREAD_RSS_ITEMS_NOTIFICATION_ID) {
+ for (StatusBarNotification statusBarNotification : notificationManager.getActiveNotifications()) {
+ if (statusBarNotification.getId() == notificationId) {
return true;
}
}
}
return false;
-
- }
-
- public static void removeRssItemsNotification(Context context) {
- NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
- manager.cancel(UNREAD_RSS_ITEMS_NOTIFICATION_ID);
}
@@ -335,8 +355,6 @@ public class NextcloudNotificationManager {
-
-
private static NotificationManager getNotificationManagerAndCreateChannel(Context context, String channelId) {
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
diff --git a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/reader/InsertIntoDatabase.java b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/reader/InsertIntoDatabase.java
index 8d42dbe5..41030719 100644
--- a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/reader/InsertIntoDatabase.java
+++ b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/reader/InsertIntoDatabase.java
@@ -80,8 +80,10 @@ public class InsertIntoDatabase {
if(oldFeed.getId() == newFeed.getId()) {
found = true;
- //Set the avg color after sync again.
+ // Set the avg color after sync again.
newFeed.setAvgColour(oldFeed.getAvgColour());
+ // Set the notification channel after sync again
+ newFeed.setNotificationChannel(oldFeed.getNotificationChannel());
dbConn.updateFeed(newFeed);
break;
}
diff --git a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/reader/nextcloud/NextcloudNewsDeserializer.java b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/reader/nextcloud/NextcloudNewsDeserializer.java
index 8b0a51e6..73a8a360 100644
--- a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/reader/nextcloud/NextcloudNewsDeserializer.java
+++ b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/reader/nextcloud/NextcloudNewsDeserializer.java
@@ -62,6 +62,7 @@ public class NextcloudNewsDeserializer<T> implements JsonDeserializer<List<T>> {
faviconLink = null;
Feed feed = new Feed();
+ feed.setNotificationChannel("default");
feed.setId(e.get("id").getAsLong());
JsonElement folderId = e.get("folderId");