diff options
author | Gerardo Vázquez <gerardolgvr0310@gmail.com> | 2020-06-26 16:38:08 -0500 |
---|---|---|
committer | Gerardo Vázquez <gerardolgvr0310@gmail.com> | 2020-06-26 16:38:08 -0500 |
commit | b36078b8f198d166c31863558198510cf574e656 (patch) | |
tree | 657f069aa1fec1830f79eb3e6aabab498926fc5b /app/src/main/java/de/danoeh | |
parent | 8d6fab6ead5a8d69456a0494e2df6fd90f54e1d4 (diff) | |
download | AntennaPod-b36078b8f198d166c31863558198510cf574e656.zip |
adding shared preferences to ShareEpisodeDialog
Diffstat (limited to 'app/src/main/java/de/danoeh')
3 files changed, 28 insertions, 2 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/activity/MediaplayerActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/MediaplayerActivity.java index a148ddb4f..7bb7361f0 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/MediaplayerActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/MediaplayerActivity.java @@ -391,7 +391,8 @@ public abstract class MediaplayerActivity extends CastEnabledActivity implements break; case R.id.share_item: if (feedItem != null) { - new ShareDialog(this, feedItem).show(((AppCompatActivity) this).getSupportFragmentManager(), "ShareEpisodeDialog"); + new ShareDialog(this, feedItem) + .show(((AppCompatActivity) this).getSupportFragmentManager(), "ShareEpisodeDialog"); } break; default: diff --git a/app/src/main/java/de/danoeh/antennapod/dialog/ShareDialog.java b/app/src/main/java/de/danoeh/antennapod/dialog/ShareDialog.java index 2a8364199..7bc7f5e67 100644 --- a/app/src/main/java/de/danoeh/antennapod/dialog/ShareDialog.java +++ b/app/src/main/java/de/danoeh/antennapod/dialog/ShareDialog.java @@ -3,7 +3,9 @@ package de.danoeh.antennapod.dialog; import android.app.Dialog; import android.content.Context; import android.content.DialogInterface; +import android.content.SharedPreferences; import android.os.Bundle; +import android.preference.PreferenceManager; import android.view.View; import android.widget.RadioButton; import android.widget.RadioGroup; @@ -15,6 +17,7 @@ import androidx.appcompat.app.AlertDialog; import androidx.fragment.app.DialogFragment; import de.danoeh.antennapod.R; import de.danoeh.antennapod.core.feed.FeedItem; +import de.danoeh.antennapod.core.preferences.UserPreferences; import de.danoeh.antennapod.core.util.ShareUtils; public class ShareDialog extends DialogFragment { @@ -27,10 +30,12 @@ public class ShareDialog extends DialogFragment { private RadioButton radioEpisodeWebsite; private RadioButton radioMediaFile; private Switch switchStartAt; + private SharedPreferences prefs; public ShareDialog(Context ctx, FeedItem item) { this.ctx = ctx; this.item = item; + prefs = PreferenceManager.getDefaultSharedPreferences(ctx); } @NonNull @@ -55,15 +60,23 @@ public class ShareDialog extends DialogFragment { if (radioEpisodeWebsite.isChecked()) { if (switchStartAt.isChecked()) { ShareUtils.shareFeedItemLink(ctx, item, true); + prefs.edit().putBoolean(UserPreferences.PREF_SHARE_EPISODE_START_AT, true).apply(); } else { ShareUtils.shareFeedItemLink(ctx, item); + prefs.edit().putBoolean(UserPreferences.PREF_SHARE_EPISODE_START_AT, false).apply(); } + prefs.edit().putBoolean(UserPreferences.PREF_SHARE_EPISODE_WEBSITE, true).apply(); + prefs.edit().putBoolean(UserPreferences.PREF_SHARE_EPISODE_MEDIA, false).apply(); } else { if (switchStartAt.isChecked()) { ShareUtils.shareFeedItemDownloadLink(ctx, item, true); + prefs.edit().putBoolean(UserPreferences.PREF_SHARE_EPISODE_START_AT, true).apply(); } else { ShareUtils.shareFeedItemDownloadLink(ctx, item); + prefs.edit().putBoolean(UserPreferences.PREF_SHARE_EPISODE_START_AT, false).apply(); } + prefs.edit().putBoolean(UserPreferences.PREF_SHARE_EPISODE_MEDIA, true).apply(); + prefs.edit().putBoolean(UserPreferences.PREF_SHARE_EPISODE_WEBSITE, false).apply(); } } }) @@ -87,5 +100,16 @@ public class ShareDialog extends DialogFragment { radioMediaFile.setVisibility(View.GONE); radioEpisodeWebsite.setChecked(true); } + + if (radioEpisodeWebsite.getVisibility() == View.VISIBLE && radioMediaFile.getVisibility() == View.VISIBLE) { + boolean radioEpisodeWebsiteIsChecked = prefs.getBoolean(UserPreferences.PREF_SHARE_EPISODE_WEBSITE, false); + radioEpisodeWebsite.setChecked(radioEpisodeWebsiteIsChecked); + + boolean radioMediaIsChecked = prefs.getBoolean(UserPreferences.PREF_SHARE_EPISODE_MEDIA, false); + radioMediaFile.setChecked(radioMediaIsChecked); + } + + boolean switchIsChecked = prefs.getBoolean(UserPreferences.PREF_SHARE_EPISODE_START_AT, false); + switchStartAt.setChecked(switchIsChecked); } } diff --git a/app/src/main/java/de/danoeh/antennapod/menuhandler/FeedItemMenuHandler.java b/app/src/main/java/de/danoeh/antennapod/menuhandler/FeedItemMenuHandler.java index 92a88263a..c63bdc3c4 100644 --- a/app/src/main/java/de/danoeh/antennapod/menuhandler/FeedItemMenuHandler.java +++ b/app/src/main/java/de/danoeh/antennapod/menuhandler/FeedItemMenuHandler.java @@ -236,7 +236,8 @@ public class FeedItemMenuHandler { IntentUtils.openInBrowser(context, FeedItemUtil.getLinkWithFallback(selectedItem)); break; case R.id.share_item: - new ShareDialog(context, selectedItem).show(((AppCompatActivity) context).getSupportFragmentManager(), "ShareEpisodeDialog"); + new ShareDialog(context, selectedItem) + .show(((AppCompatActivity) context).getSupportFragmentManager(), "ShareEpisodeDialog"); break; default: Log.d(TAG, "Unknown menuItemId: " + menuItemId); |