diff options
author | ByteHamster <ByteHamster@users.noreply.github.com> | 2024-03-25 23:45:09 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-25 23:45:09 +0100 |
commit | 130da46f5d9c598ca76f4f2127c08bb4ef225b34 (patch) | |
tree | 39007501eeecf0dd188d6f4fa57cd3c6dac6e4b0 /app/src/main/java | |
parent | 160089d3fffeb788464e23b36bc476a3e0cde183 (diff) | |
download | AntennaPod-130da46f5d9c598ca76f4f2127c08bb4ef225b34.zip |
Move widget setup code to widget module (#6996)
Diffstat (limited to 'app/src/main/java')
9 files changed, 9 insertions, 153 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/activity/VideoplayerActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/VideoplayerActivity.java index 516ea29b8..6e0a84bf6 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/VideoplayerActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/VideoplayerActivity.java @@ -51,7 +51,6 @@ import de.danoeh.antennapod.ui.common.Converter; import de.danoeh.antennapod.core.util.FeedItemUtil; import de.danoeh.antennapod.core.util.IntentUtils; import de.danoeh.antennapod.core.util.ShareUtils; -import de.danoeh.antennapod.core.util.TimeSpeedConverter; import de.danoeh.antennapod.core.util.gui.PictureInPictureUtil; import de.danoeh.antennapod.core.util.playback.PlaybackController; import de.danoeh.antennapod.databinding.VideoplayerActivityBinding; @@ -65,6 +64,7 @@ import de.danoeh.antennapod.model.playback.Playable; import de.danoeh.antennapod.playback.base.PlayerStatus; import de.danoeh.antennapod.playback.cast.CastEnabledActivity; import de.danoeh.antennapod.ui.appstartintent.MainActivityStarter; +import de.danoeh.antennapod.ui.episodes.TimeSpeedConverter; import io.reactivex.Observable; import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.disposables.Disposable; diff --git a/app/src/main/java/de/danoeh/antennapod/activity/WidgetConfigActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/WidgetConfigActivity.java deleted file mode 100644 index bfdf6fb63..000000000 --- a/app/src/main/java/de/danoeh/antennapod/activity/WidgetConfigActivity.java +++ /dev/null @@ -1,144 +0,0 @@ -package de.danoeh.antennapod.activity; - -import android.appwidget.AppWidgetManager; -import android.content.Intent; -import android.content.SharedPreferences; -import android.graphics.Color; -import android.os.Build; -import android.os.Bundle; -import android.view.View; -import android.widget.CheckBox; -import android.widget.SeekBar; -import android.widget.TextView; -import androidx.appcompat.app.AppCompatActivity; -import de.danoeh.antennapod.R; -import de.danoeh.antennapod.core.receiver.PlayerWidget; -import de.danoeh.antennapod.core.widget.WidgetUpdaterWorker; -import de.danoeh.antennapod.ui.common.ThemeSwitcher; - -public class WidgetConfigActivity extends AppCompatActivity { - private int appWidgetId = AppWidgetManager.INVALID_APPWIDGET_ID; - - private SeekBar opacitySeekBar; - private TextView opacityTextView; - private View widgetPreview; - private CheckBox ckPlaybackSpeed; - private CheckBox ckRewind; - private CheckBox ckFastForward; - private CheckBox ckSkip; - - @Override - protected void onCreate(Bundle savedInstanceState) { - setTheme(ThemeSwitcher.getTheme(this)); - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_widget_config); - - Intent configIntent = getIntent(); - Bundle extras = configIntent.getExtras(); - if (extras != null) { - appWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, - AppWidgetManager.INVALID_APPWIDGET_ID); - } - - Intent resultValue = new Intent(); - resultValue.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId); - setResult(RESULT_CANCELED, resultValue); - if (appWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID) { - finish(); - } - - opacityTextView = findViewById(R.id.widget_opacity_textView); - opacitySeekBar = findViewById(R.id.widget_opacity_seekBar); - widgetPreview = findViewById(R.id.widgetLayout); - findViewById(R.id.butConfirm).setOnClickListener(v -> confirmCreateWidget()); - opacitySeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { - - @Override - public void onProgressChanged(SeekBar seekBar, int i, boolean b) { - opacityTextView.setText(seekBar.getProgress() + "%"); - int color = getColorWithAlpha(PlayerWidget.DEFAULT_COLOR, opacitySeekBar.getProgress()); - widgetPreview.setBackgroundColor(color); - } - - @Override - public void onStartTrackingTouch(SeekBar seekBar) { - } - - @Override - public void onStopTrackingTouch(SeekBar seekBar) { - } - - }); - - widgetPreview.findViewById(R.id.txtNoPlaying).setVisibility(View.GONE); - TextView title = widgetPreview.findViewById(R.id.txtvTitle); - title.setVisibility(View.VISIBLE); - title.setText(R.string.app_name); - TextView progress = widgetPreview.findViewById(R.id.txtvProgress); - progress.setVisibility(View.VISIBLE); - progress.setText(R.string.position_default_label); - - ckPlaybackSpeed = findViewById(R.id.ckPlaybackSpeed); - ckPlaybackSpeed.setOnClickListener(v -> displayPreviewPanel()); - ckRewind = findViewById(R.id.ckRewind); - ckRewind.setOnClickListener(v -> displayPreviewPanel()); - ckFastForward = findViewById(R.id.ckFastForward); - ckFastForward.setOnClickListener(v -> displayPreviewPanel()); - ckSkip = findViewById(R.id.ckSkip); - ckSkip.setOnClickListener(v -> displayPreviewPanel()); - - setInitialState(); - } - - private void setInitialState() { - SharedPreferences prefs = getSharedPreferences(PlayerWidget.PREFS_NAME, MODE_PRIVATE); - ckPlaybackSpeed.setChecked(prefs.getBoolean(PlayerWidget.KEY_WIDGET_PLAYBACK_SPEED + appWidgetId, false)); - ckRewind.setChecked(prefs.getBoolean(PlayerWidget.KEY_WIDGET_REWIND + appWidgetId, false)); - ckFastForward.setChecked(prefs.getBoolean(PlayerWidget.KEY_WIDGET_FAST_FORWARD + appWidgetId, false)); - ckSkip.setChecked(prefs.getBoolean(PlayerWidget.KEY_WIDGET_SKIP + appWidgetId, false)); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { - int color = prefs.getInt(PlayerWidget.KEY_WIDGET_COLOR + appWidgetId, PlayerWidget.DEFAULT_COLOR); - int opacity = Color.alpha(color) * 100 / 0xFF; - - opacitySeekBar.setProgress(opacity, false); - } - displayPreviewPanel(); - } - - private void displayPreviewPanel() { - boolean showExtendedPreview = - ckPlaybackSpeed.isChecked() || ckRewind.isChecked() || ckFastForward.isChecked() || ckSkip.isChecked(); - widgetPreview.findViewById(R.id.extendedButtonsContainer) - .setVisibility(showExtendedPreview ? View.VISIBLE : View.GONE); - widgetPreview.findViewById(R.id.butPlay).setVisibility(showExtendedPreview ? View.GONE : View.VISIBLE); - widgetPreview.findViewById(R.id.butPlaybackSpeed) - .setVisibility(ckPlaybackSpeed.isChecked() ? View.VISIBLE : View.GONE); - widgetPreview.findViewById(R.id.butFastForward) - .setVisibility(ckFastForward.isChecked() ? View.VISIBLE : View.GONE); - widgetPreview.findViewById(R.id.butSkip).setVisibility(ckSkip.isChecked() ? View.VISIBLE : View.GONE); - widgetPreview.findViewById(R.id.butRew).setVisibility(ckRewind.isChecked() ? View.VISIBLE : View.GONE); - } - - private void confirmCreateWidget() { - int backgroundColor = getColorWithAlpha(PlayerWidget.DEFAULT_COLOR, opacitySeekBar.getProgress()); - - SharedPreferences prefs = getSharedPreferences(PlayerWidget.PREFS_NAME, MODE_PRIVATE); - SharedPreferences.Editor editor = prefs.edit(); - editor.putInt(PlayerWidget.KEY_WIDGET_COLOR + appWidgetId, backgroundColor); - editor.putBoolean(PlayerWidget.KEY_WIDGET_PLAYBACK_SPEED + appWidgetId, ckPlaybackSpeed.isChecked()); - editor.putBoolean(PlayerWidget.KEY_WIDGET_SKIP + appWidgetId, ckSkip.isChecked()); - editor.putBoolean(PlayerWidget.KEY_WIDGET_REWIND + appWidgetId, ckRewind.isChecked()); - editor.putBoolean(PlayerWidget.KEY_WIDGET_FAST_FORWARD + appWidgetId, ckFastForward.isChecked()); - editor.apply(); - - Intent resultValue = new Intent(); - resultValue.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId); - setResult(RESULT_OK, resultValue); - finish(); - WidgetUpdaterWorker.enqueueWork(this); - } - - private int getColorWithAlpha(int color, int opacity) { - return (int) Math.round(0xFF * (0.01 * opacity)) * 0x1000000 + (color & 0xffffff); - } -} diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/AudioPlayerFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/AudioPlayerFragment.java index 0289e3fc2..f20399b3f 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/AudioPlayerFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/AudioPlayerFragment.java @@ -26,6 +26,8 @@ import com.google.android.material.bottomsheet.BottomSheetBehavior; import com.google.android.material.elevation.SurfaceColors; import de.danoeh.antennapod.ui.appstartintent.MediaButtonStarter; +import de.danoeh.antennapod.ui.episodes.PlaybackSpeedUtils; +import de.danoeh.antennapod.ui.episodes.TimeSpeedConverter; import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; @@ -36,10 +38,8 @@ import java.util.List; import de.danoeh.antennapod.R; import de.danoeh.antennapod.activity.MainActivity; -import de.danoeh.antennapod.core.feed.util.PlaybackSpeedUtils; import de.danoeh.antennapod.core.util.ChapterUtils; import de.danoeh.antennapod.ui.common.Converter; -import de.danoeh.antennapod.core.util.TimeSpeedConverter; import de.danoeh.antennapod.core.util.playback.PlaybackController; import de.danoeh.antennapod.dialog.MediaPlayerErrorDialog; import de.danoeh.antennapod.dialog.SkipPreferenceDialog; diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/CoverFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/CoverFragment.java index 4314cdd7b..da1e07e46 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/CoverFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/CoverFragment.java @@ -32,7 +32,6 @@ import com.bumptech.glide.request.RequestOptions; import com.google.android.material.snackbar.Snackbar; import de.danoeh.antennapod.R; import de.danoeh.antennapod.activity.MainActivity; -import de.danoeh.antennapod.core.feed.util.ImageResourceUtils; import de.danoeh.antennapod.core.util.ChapterUtils; import de.danoeh.antennapod.ui.common.DateFormatter; import de.danoeh.antennapod.core.util.playback.PlaybackController; @@ -42,6 +41,7 @@ import de.danoeh.antennapod.model.feed.Chapter; import de.danoeh.antennapod.model.feed.EmbeddedChapterImage; import de.danoeh.antennapod.model.feed.FeedMedia; import de.danoeh.antennapod.model.playback.Playable; +import de.danoeh.antennapod.ui.episodes.ImageResourceUtils; import io.reactivex.Maybe; import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.disposables.Disposable; diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/ExternalPlayerFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/ExternalPlayerFragment.java index b52ebcaae..3ad05eca5 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/ExternalPlayerFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/ExternalPlayerFragment.java @@ -20,11 +20,11 @@ import de.danoeh.antennapod.activity.MainActivity; import de.danoeh.antennapod.event.playback.PlaybackPositionEvent; import de.danoeh.antennapod.event.playback.PlaybackServiceEvent; import de.danoeh.antennapod.model.playback.MediaType; -import de.danoeh.antennapod.core.feed.util.ImageResourceUtils; import de.danoeh.antennapod.core.service.playback.PlaybackService; import de.danoeh.antennapod.model.playback.Playable; import de.danoeh.antennapod.core.util.playback.PlaybackController; import de.danoeh.antennapod.playback.base.PlayerStatus; +import de.danoeh.antennapod.ui.episodes.ImageResourceUtils; import de.danoeh.antennapod.view.PlayButton; import io.reactivex.Maybe; import io.reactivex.android.schedulers.AndroidSchedulers; diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/ItemFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/ItemFragment.java index 54c148aa3..28b845a21 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/ItemFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/ItemFragment.java @@ -44,7 +44,6 @@ import de.danoeh.antennapod.event.PlayerStatusEvent; import de.danoeh.antennapod.event.UnreadItemsUpdateEvent; import de.danoeh.antennapod.model.feed.FeedItem; import de.danoeh.antennapod.model.feed.FeedMedia; -import de.danoeh.antennapod.core.feed.util.ImageResourceUtils; import de.danoeh.antennapod.storage.preferences.UsageStatistics; import de.danoeh.antennapod.net.download.serviceinterface.DownloadServiceInterface; import de.danoeh.antennapod.storage.preferences.UserPreferences; @@ -55,6 +54,7 @@ import de.danoeh.antennapod.ui.common.CircularProgressBar; import de.danoeh.antennapod.ui.common.ThemeUtils; import de.danoeh.antennapod.core.util.playback.PlaybackController; import de.danoeh.antennapod.core.util.gui.ShownotesCleaner; +import de.danoeh.antennapod.ui.episodes.ImageResourceUtils; import de.danoeh.antennapod.view.ShownotesWebView; import io.reactivex.Observable; import io.reactivex.android.schedulers.AndroidSchedulers; diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/QueueFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/QueueFragment.java index 9c6ce8090..65e16dc5b 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/QueueFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/QueueFragment.java @@ -28,6 +28,7 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder; import com.google.android.material.snackbar.Snackbar; import com.leinardi.android.speeddial.SpeedDialView; +import de.danoeh.antennapod.ui.episodes.PlaybackSpeedUtils; import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; @@ -39,7 +40,6 @@ import de.danoeh.antennapod.activity.MainActivity; import de.danoeh.antennapod.adapter.EpisodeItemListAdapter; import de.danoeh.antennapod.adapter.QueueRecyclerAdapter; import de.danoeh.antennapod.core.dialog.ConfirmationDialog; -import de.danoeh.antennapod.core.feed.util.PlaybackSpeedUtils; import de.danoeh.antennapod.core.menuhandler.MenuItemUtils; import de.danoeh.antennapod.storage.database.DBReader; import de.danoeh.antennapod.core.storage.DBWriter; diff --git a/app/src/main/java/de/danoeh/antennapod/view/viewholder/EpisodeItemViewHolder.java b/app/src/main/java/de/danoeh/antennapod/view/viewholder/EpisodeItemViewHolder.java index a57900da8..662830772 100644 --- a/app/src/main/java/de/danoeh/antennapod/view/viewholder/EpisodeItemViewHolder.java +++ b/app/src/main/java/de/danoeh/antennapod/view/viewholder/EpisodeItemViewHolder.java @@ -27,7 +27,6 @@ import de.danoeh.antennapod.ui.common.DateFormatter; import de.danoeh.antennapod.model.feed.FeedItem; import de.danoeh.antennapod.model.feed.FeedMedia; import de.danoeh.antennapod.model.playback.MediaType; -import de.danoeh.antennapod.core.feed.util.ImageResourceUtils; import de.danoeh.antennapod.net.download.serviceinterface.DownloadServiceInterface; import de.danoeh.antennapod.storage.preferences.UserPreferences; import de.danoeh.antennapod.ui.common.Converter; @@ -35,6 +34,7 @@ import de.danoeh.antennapod.net.common.NetworkUtils; import de.danoeh.antennapod.model.playback.Playable; import de.danoeh.antennapod.ui.common.CircularProgressBar; import de.danoeh.antennapod.ui.common.ThemeUtils; +import de.danoeh.antennapod.ui.episodes.ImageResourceUtils; /** * Holds the view which shows FeedItems. diff --git a/app/src/main/java/de/danoeh/antennapod/view/viewholder/HorizontalItemViewHolder.java b/app/src/main/java/de/danoeh/antennapod/view/viewholder/HorizontalItemViewHolder.java index 64867466a..a15cf7cb3 100644 --- a/app/src/main/java/de/danoeh/antennapod/view/viewholder/HorizontalItemViewHolder.java +++ b/app/src/main/java/de/danoeh/antennapod/view/viewholder/HorizontalItemViewHolder.java @@ -13,7 +13,6 @@ import de.danoeh.antennapod.R; import de.danoeh.antennapod.activity.MainActivity; import de.danoeh.antennapod.adapter.CoverLoader; import de.danoeh.antennapod.adapter.actionbutton.ItemActionButton; -import de.danoeh.antennapod.core.feed.util.ImageResourceUtils; import de.danoeh.antennapod.ui.common.DateFormatter; import de.danoeh.antennapod.core.util.PlaybackStatus; import de.danoeh.antennapod.event.playback.PlaybackPositionEvent; @@ -23,6 +22,7 @@ import de.danoeh.antennapod.net.download.serviceinterface.DownloadServiceInterfa import de.danoeh.antennapod.ui.common.CircularProgressBar; import de.danoeh.antennapod.ui.common.SquareImageView; import de.danoeh.antennapod.ui.common.ThemeUtils; +import de.danoeh.antennapod.ui.episodes.ImageResourceUtils; public class HorizontalItemViewHolder extends RecyclerView.ViewHolder { public final CardView card; |