Add preference for reloading feeds colors
This commit is contained in:
parent
5c35ee3415
commit
96e5316375
@ -19,7 +19,10 @@ import io.reactivex.Single;
|
|||||||
public abstract class FeedDao implements BaseDao<Feed> {
|
public abstract class FeedDao implements BaseDao<Feed> {
|
||||||
|
|
||||||
@Query("Select * from Feed Where account_id = :accountId order by name ASC")
|
@Query("Select * from Feed Where account_id = :accountId order by name ASC")
|
||||||
public abstract List<Feed> getAllFeeds(int accountId);
|
public abstract List<Feed> getFeeds(int accountId);
|
||||||
|
|
||||||
|
@Query("Select * from Feed Order By name ASC")
|
||||||
|
public abstract LiveData<List<Feed>> getAllFeeds();
|
||||||
|
|
||||||
@Query("Select case When :feedUrl In (Select url from Feed Where account_id = :accountId) Then 1 else 0 end")
|
@Query("Select case When :feedUrl In (Select url from Feed Where account_id = :accountId) Then 1 else 0 end")
|
||||||
public abstract boolean feedExists(String feedUrl, int accountId);
|
public abstract boolean feedExists(String feedUrl, int accountId);
|
||||||
|
@ -1,15 +1,41 @@
|
|||||||
package com.readrops.app.fragments.settings;
|
package com.readrops.app.fragments.settings;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
import androidx.preference.Preference;
|
||||||
import androidx.preference.PreferenceFragmentCompat;
|
import androidx.preference.PreferenceFragmentCompat;
|
||||||
|
|
||||||
import com.readrops.app.R;
|
import com.readrops.app.R;
|
||||||
|
import com.readrops.app.database.Database;
|
||||||
|
import com.readrops.app.utils.feedscolors.FeedsColorsIntentService;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
public class SettingsFragment extends PreferenceFragmentCompat {
|
public class SettingsFragment extends PreferenceFragmentCompat {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
||||||
addPreferencesFromResource(R.xml.preferences);
|
addPreferencesFromResource(R.xml.preferences);
|
||||||
|
|
||||||
|
AtomicBoolean serviceStarted = new AtomicBoolean(false);
|
||||||
|
Preference feedsColorsPreference = findPreference("reload_feeds_colors");
|
||||||
|
|
||||||
|
feedsColorsPreference.setOnPreferenceClickListener(preference -> {
|
||||||
|
Database database = Database.getInstance(getContext());
|
||||||
|
|
||||||
|
database.feedDao().getAllFeeds().observe(getActivity(), feeds -> {
|
||||||
|
if (!serviceStarted.get()) {
|
||||||
|
Intent intent = new Intent(getContext(), FeedsColorsIntentService.class);
|
||||||
|
intent.putParcelableArrayListExtra(FeedsColorsIntentService.FEEDS, new ArrayList<>(feeds));
|
||||||
|
|
||||||
|
getContext().startService(intent);
|
||||||
|
serviceStarted.set(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return true;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ public class LocalFeedRepository extends ARepository<Void> {
|
|||||||
List<Feed> feedList;
|
List<Feed> feedList;
|
||||||
|
|
||||||
if (feeds == null || feeds.size() == 0)
|
if (feeds == null || feeds.size() == 0)
|
||||||
feedList = database.feedDao().getAllFeeds(account.getId());
|
feedList = database.feedDao().getFeeds(account.getId());
|
||||||
else
|
else
|
||||||
feedList = new ArrayList<>(feeds);
|
feedList = new ArrayList<>(feeds);
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ fun setFeedColors(feed: Feed) {
|
|||||||
getFaviconLink(feed)
|
getFaviconLink(feed)
|
||||||
|
|
||||||
if (feed.iconUrl != null) {
|
if (feed.iconUrl != null) {
|
||||||
val bitmap = Utils.getImageFromUrl(feed.iconUrl)
|
val bitmap = Utils.getImageFromUrl(feed.iconUrl) ?: return
|
||||||
val palette = Palette.from(bitmap).generate()
|
val palette = Palette.from(bitmap).generate()
|
||||||
|
|
||||||
val dominantSwatch = palette.dominantSwatch
|
val dominantSwatch = palette.dominantSwatch
|
||||||
|
@ -86,5 +86,7 @@
|
|||||||
<string name="feed_insertion_error">Erreur pour le flux %1$s</string>
|
<string name="feed_insertion_error">Erreur pour le flux %1$s</string>
|
||||||
<string name="get_feeds_colors">Récupération des couleurs des flux</string>
|
<string name="get_feeds_colors">Récupération des couleurs des flux</string>
|
||||||
<string name="feeds_colors">Couleurs des flux</string>
|
<string name="feeds_colors">Couleurs des flux</string>
|
||||||
|
<string name="global">Général</string>
|
||||||
|
<string name="reload_feeds_colors">Recharger les couleurs des flux</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
@ -94,4 +94,6 @@
|
|||||||
<string name="feed_insertion_error">Error for feed %1$s</string>
|
<string name="feed_insertion_error">Error for feed %1$s</string>
|
||||||
<string name="get_feeds_colors">Get feeds colors</string>
|
<string name="get_feeds_colors">Get feeds colors</string>
|
||||||
<string name="feeds_colors">Feeds Colors</string>
|
<string name="feeds_colors">Feeds Colors</string>
|
||||||
|
<string name="global">Global</string>
|
||||||
|
<string name="reload_feeds_colors">Reload feeds colors</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -10,4 +10,10 @@
|
|||||||
android:title="@string/number_items_to_parse" />
|
android:title="@string/number_items_to_parse" />
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
|
<PreferenceCategory android:title="@string/global">
|
||||||
|
<Preference
|
||||||
|
android:key="reload_feeds_colors"
|
||||||
|
android:title="@string/reload_feeds_colors" />
|
||||||
|
</PreferenceCategory>
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
Loading…
x
Reference in New Issue
Block a user