diff --git a/api/src/main/java/com/readrops/api/opml/OPMLParser.kt b/api/src/main/java/com/readrops/api/opml/OPMLParser.kt index e68256bb..0cd1e7c2 100644 --- a/api/src/main/java/com/readrops/api/opml/OPMLParser.kt +++ b/api/src/main/java/com/readrops/api/opml/OPMLParser.kt @@ -108,7 +108,7 @@ object OPMLParser { val feedOutlines = arrayListOf() for (feed in folderAndFeeds.value) { - val feedOutline = Outline(feed.name, feed.url, feed.siteUrl) + val feedOutline = Outline(feed.name, feed.url!!, feed.siteUrl) feedOutlines += feedOutline } @@ -117,7 +117,7 @@ object OPMLParser { outlines += outline } else { for (feed in folderAndFeeds.value) { - outlines += Outline(feed.name, feed.url, feed.siteUrl) + outlines += Outline(feed.name, feed.url!!, feed.siteUrl) } } } diff --git a/api/src/main/java/com/readrops/api/services/freshrss/adapters/FreshRSSFeedsAdapter.kt b/api/src/main/java/com/readrops/api/services/freshrss/adapters/FreshRSSFeedsAdapter.kt index a7c7be4e..e1258c41 100644 --- a/api/src/main/java/com/readrops/api/services/freshrss/adapters/FreshRSSFeedsAdapter.kt +++ b/api/src/main/java/com/readrops/api/services/freshrss/adapters/FreshRSSFeedsAdapter.kt @@ -12,7 +12,7 @@ import com.squareup.moshi.ToJson class FreshRSSFeedsAdapter { @ToJson - fun toJson(feed: Feed): String = "" + fun toJson(feeds: List): String = "" @SuppressLint("CheckResult") @FromJson diff --git a/api/src/main/java/com/readrops/api/services/nextcloudnews/adapters/NextNewsFeedsAdapter.kt b/api/src/main/java/com/readrops/api/services/nextcloudnews/adapters/NextNewsFeedsAdapter.kt index a5ccc6e9..9a523585 100644 --- a/api/src/main/java/com/readrops/api/services/nextcloudnews/adapters/NextNewsFeedsAdapter.kt +++ b/api/src/main/java/com/readrops/api/services/nextcloudnews/adapters/NextNewsFeedsAdapter.kt @@ -14,7 +14,7 @@ import java.net.URI class NextNewsFeedsAdapter { @ToJson - fun toJson(feed: Feed): String = "" + fun toJson(feeds: List): String = "" @SuppressLint("CheckResult") @FromJson 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 0cc45b23..17a18c7f 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 @@ -31,7 +31,7 @@ fun getFaviconLink(feed: Feed) { feed.iconUrl = if (feed.iconUrl != null) feed.iconUrl else - HtmlParser.getFaviconLink(feed.siteUrl) + HtmlParser.getFaviconLink(feed.siteUrl!!) } diff --git a/db/build.gradle b/db/build.gradle index f6d28aac..4f0226a9 100644 --- a/db/build.gradle +++ b/db/build.gradle @@ -1,6 +1,7 @@ apply plugin: 'com.android.library' apply plugin: 'kotlin-android' apply plugin: 'kotlin-kapt' +apply plugin: 'kotlin-parcelize' android { compileSdkVersion rootProject.ext.compileSdkVersion diff --git a/db/src/main/java/com/readrops/db/entities/Feed.java b/db/src/main/java/com/readrops/db/entities/Feed.java deleted file mode 100644 index 10e112be..00000000 --- a/db/src/main/java/com/readrops/db/entities/Feed.java +++ /dev/null @@ -1,271 +0,0 @@ -package com.readrops.db.entities; - - -import android.os.Parcel; -import android.os.Parcelable; - -import androidx.annotation.ColorInt; -import androidx.room.ColumnInfo; -import androidx.room.Entity; -import androidx.room.ForeignKey; -import androidx.room.Ignore; -import androidx.room.PrimaryKey; - -import com.readrops.db.entities.account.Account; - -@Entity(foreignKeys = {@ForeignKey(entity = Folder.class, parentColumns = "id", - childColumns = "folder_id", onDelete = ForeignKey.SET_NULL), - @ForeignKey(entity = Account.class, parentColumns = "id", childColumns = "account_id", - onDelete = ForeignKey.CASCADE)}) -public class Feed implements Parcelable { - - @PrimaryKey(autoGenerate = true) - private int id; - - private String name; - - private String description; - - private String url; - - private String siteUrl; - - private String lastUpdated; - - @ColumnInfo(name = "text_color") - private @ColorInt - int textColor; - - @ColumnInfo(name = "background_color") - private @ColorInt - int backgroundColor; - - @ColumnInfo(name = "icon_url") - private String iconUrl; - - private String etag; - - @ColumnInfo(name = "last_modified") - private String lastModified; - - @ColumnInfo(name = "folder_id", index = true) - private Integer folderId; // nullable foreign key so Integer instead of int - - private String remoteId; // remote id can be string or int - - @ColumnInfo(name = "account_id", index = true) - private int accountId; - - @ColumnInfo(name = "notification_enabled", defaultValue = "1") - private boolean notificationEnabled; - - @Ignore - private int unreadCount; - - @Ignore - private String remoteFolderId; - - public Feed() { - - } - - @Ignore - public Feed(String name, String description, String url) { - this.name = name; - this.description = description; - this.url = url; - } - - protected Feed(Parcel in) { - id = in.readInt(); - name = in.readString(); - description = in.readString(); - url = in.readString(); - siteUrl = in.readString(); - lastUpdated = in.readString(); - textColor = in.readInt(); - backgroundColor = in.readInt(); - iconUrl = in.readString(); - etag = in.readString(); - lastModified = in.readString(); - - int parcelFolderId = in.readInt(); - folderId = parcelFolderId == 0 ? null : parcelFolderId; - - remoteId = in.readString(); - notificationEnabled = in.readByte() != 0; - } - - public static final Creator CREATOR = new Creator() { - @Override - public Feed createFromParcel(Parcel in) { - return new Feed(in); - } - - @Override - public Feed[] newArray(int size) { - return new Feed[size]; - } - }; - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } - - public String getSiteUrl() { - return siteUrl; - } - - public void setSiteUrl(String siteUrl) { - this.siteUrl = siteUrl; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getLastUpdated() { - return lastUpdated; - } - - public void setLastUpdated(String lastUpdated) { - this.lastUpdated = lastUpdated; - } - - public @ColorInt - int getTextColor() { - return textColor; - } - - public void setTextColor(@ColorInt int textColor) { - this.textColor = textColor; - } - - public @ColorInt - int getBackgroundColor() { - return backgroundColor; - } - - public void setBackgroundColor(@ColorInt int backgroundColor) { - this.backgroundColor = backgroundColor; - } - - public String getIconUrl() { - return iconUrl; - } - - public void setIconUrl(String iconUrl) { - this.iconUrl = iconUrl; - } - - public String getEtag() { - return etag; - } - - public void setEtag(String etag) { - this.etag = etag; - } - - public String getLastModified() { - return lastModified; - } - - public void setLastModified(String lastModified) { - this.lastModified = lastModified; - } - - public Integer getFolderId() { - return folderId; - } - - public void setFolderId(Integer folderId) { - this.folderId = folderId; - } - - public int getUnreadCount() { - return unreadCount; - } - - public void setUnreadCount(int unreadCount) { - this.unreadCount = unreadCount; - } - - public String getRemoteId() { - return remoteId; - } - - public void setRemoteId(String remoteId) { - this.remoteId = remoteId; - } - - public int getAccountId() { - return accountId; - } - - public void setAccountId(int accountId) { - this.accountId = accountId; - } - - public boolean isNotificationEnabled() { - return notificationEnabled; - } - - public void setNotificationEnabled(boolean notificationEnabled) { - this.notificationEnabled = notificationEnabled; - } - - public String getRemoteFolderId() { - return remoteFolderId; - } - - public void setRemoteFolderId(String remoteFolderId) { - this.remoteFolderId = remoteFolderId; - } - - @Override - public int describeContents() { - return 0; - } - - @Override - public void writeToParcel(Parcel dest, int flags) { - dest.writeInt(id); - dest.writeString(name); - dest.writeString(description); - dest.writeString(url); - dest.writeString(siteUrl); - dest.writeString(lastUpdated); - dest.writeInt(textColor); - dest.writeInt(backgroundColor); - dest.writeString(iconUrl); - dest.writeString(etag); - dest.writeString(lastModified); - dest.writeInt(folderId == null ? 0 : folderId); - dest.writeString(remoteId); - dest.writeByte((byte) (notificationEnabled ? 1 : 0)); - } -} diff --git a/db/src/main/java/com/readrops/db/entities/Feed.kt b/db/src/main/java/com/readrops/db/entities/Feed.kt new file mode 100644 index 00000000..806d4d44 --- /dev/null +++ b/db/src/main/java/com/readrops/db/entities/Feed.kt @@ -0,0 +1,31 @@ +package com.readrops.db.entities + +import android.os.Parcelable +import androidx.annotation.ColorInt +import androidx.room.* +import com.readrops.db.entities.account.Account +import kotlinx.parcelize.Parcelize + +@Parcelize +@Entity(foreignKeys = [ForeignKey(entity = Folder::class, parentColumns = ["id"], childColumns = ["folder_id"], + onDelete = ForeignKey.SET_NULL), ForeignKey(entity = Account::class, parentColumns = ["id"], + childColumns = ["account_id"], onDelete = ForeignKey.CASCADE)]) +data class Feed( + @PrimaryKey(autoGenerate = true) var id: Int = 0, + var name: String? = null, + var description: String? = null, + var url: String? = null, + var siteUrl: String? = null, + var lastUpdated: String? = null, + @ColumnInfo(name = "text_color") @ColorInt var textColor: Int = 0, + @ColumnInfo(name = "background_color") @ColorInt var backgroundColor: Int = 0, + @ColumnInfo(name = "icon_url") var iconUrl: String? = null, + var etag: String? = null, + @ColumnInfo(name = "last_modified") var lastModified: String? = null, + @ColumnInfo(name = "folder_id", index = true) var folderId: Int? = null, + var remoteId: String? = null, + @ColumnInfo(name = "account_id", index = true) var accountId: Int = 0, + @ColumnInfo(name = "notification_enabled", defaultValue = "1") var isNotificationEnabled: Boolean = false, + @Ignore var unreadCount: Int = 0, + @Ignore var remoteFolderId: String? = null, +) : Parcelable \ No newline at end of file