diff options
author | H. Lehmann <ByteHamster@users.noreply.github.com> | 2018-05-26 23:45:18 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-26 23:45:18 +0200 |
commit | 532d822b3c1c1dfe66fb3bc3f3687f24dd47c691 (patch) | |
tree | 769e3589345db775b27c06e521f28af678838093 /app | |
parent | 902068723c6b36f96c8ae63e7fc5bf512f3d44f9 (diff) | |
parent | cd0d23d2606c35d783457f2a945f539382018285 (diff) | |
download | AntennaPod-532d822b3c1c1dfe66fb3bc3f3687f24dd47c691.zip |
Merge branch 'develop' into exo-player
Diffstat (limited to 'app')
35 files changed, 510 insertions, 737 deletions
diff --git a/app/build.gradle b/app/build.gradle index e4f66fe64..6c8abbdff 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -83,7 +83,14 @@ android { applicationIdSuffix ".debug" resValue "string", "provider_authority", "de.danoeh.antennapod.debug.provider" buildConfigField STRING, FLATTR_APP_KEY, mFlattrAppKey - buildConfigField STRING, FLATTR_APP_SECRET, mFlattrAppSecret + buildConfigField STRING, FLATTR_APP_SECRET, mFlattrAppSecret + dexcount { + if (project.hasProperty("enableDexcountInDebug")) { + runOnEachPackage enableDexcountInDebug.toBoolean() + } else { // default to not running dexcount + runOnEachPackage false + } + } } release { resValue "string", "provider_authority", "de.danoeh.antennapod.provider" @@ -139,6 +146,7 @@ dependencies { implementation "com.android.support:support-v4:$supportVersion" implementation "com.android.support:appcompat-v7:$supportVersion" implementation "com.android.support:design:$supportVersion" + implementation "com.android.support:preference-v14:$supportVersion" implementation "com.android.support:gridlayout-v7:$supportVersion" implementation "com.android.support:percent:$supportVersion" implementation "com.android.support:recyclerview-v7:$supportVersion" @@ -172,6 +180,7 @@ dependencies { implementation "com.github.AntennaPod:AntennaPod-AudioPlayer:$audioPlayerVersion" implementation 'com.github.mfietz:fyydlin:v0.3' + implementation 'com.github.ByteHamster:SearchPreference:v1.0.8' androidTestImplementation "com.jayway.android.robotium:robotium-solo:$robotiumSoloVersion" } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 03ba97e08..c7541cb59 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -118,12 +118,13 @@ </activity> <service - android:name=".service.PlayerWidgetService" + android:name=".core.service.PlayerWidgetJobService" + android:permission="android.permission.BIND_JOB_SERVICE" android:enabled="true" android:exported="false"> </service> - <receiver android:name=".receiver.PlayerWidget"> + <receiver android:name=".core.receiver.PlayerWidget"> <intent-filter> <action android:name="android.appwidget.action.APPWIDGET_UPDATE"/> </intent-filter> diff --git a/app/src/main/java/de/danoeh/antennapod/activity/AboutActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/AboutActivity.java index 041053a25..4d9b50073 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/AboutActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/AboutActivity.java @@ -21,8 +21,7 @@ import java.nio.charset.Charset; import de.danoeh.antennapod.R; import de.danoeh.antennapod.core.preferences.UserPreferences; -import rx.Observable; -import rx.Subscriber; +import rx.Single; import rx.Subscription; import rx.android.schedulers.AndroidSchedulers; import rx.schedulers.Schedulers; @@ -34,10 +33,8 @@ public class AboutActivity extends AppCompatActivity { private static final String TAG = AboutActivity.class.getSimpleName(); - private WebView webview; - private LinearLayout webviewContainer; - private int depth = 0; - + private WebView webView; + private LinearLayout webViewContainer; private Subscription subscription; @Override @@ -46,28 +43,25 @@ public class AboutActivity extends AppCompatActivity { super.onCreate(savedInstanceState); getSupportActionBar().setDisplayShowHomeEnabled(true); setContentView(R.layout.about); - webviewContainer = (LinearLayout) findViewById(R.id.webvContainer); - webview = (WebView) findViewById(R.id.webvAbout); - webview.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE); + webViewContainer = (LinearLayout) findViewById(R.id.webViewContainer); + webView = (WebView) findViewById(R.id.webViewAbout); + webView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE); if (UserPreferences.getTheme() == R.style.Theme_AntennaPod_Dark) { - if (Build.VERSION.SDK_INT >= 11 - && Build.VERSION.SDK_INT <= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) { - webview.setLayerType(View.LAYER_TYPE_SOFTWARE, null); + if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) { + webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null); } - webview.setBackgroundColor(Color.TRANSPARENT); + webView.setBackgroundColor(Color.TRANSPARENT); } - webview.setWebViewClient(new WebViewClient() { + webView.setWebViewClient(new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { - if(url.startsWith("http")) { - depth++; - return false; - } else { + if (!url.startsWith("http")) { url = url.replace("file:///android_asset/", ""); loadAsset(url); return true; } + return false; } }); @@ -75,7 +69,7 @@ public class AboutActivity extends AppCompatActivity { } private void loadAsset(String filename) { - subscription = Observable.create((Observable.OnSubscribe<String>) subscriber -> { + subscription = Single.create(subscriber -> { InputStream input = null; try { TypedArray res = AboutActivity.this.getTheme().obtainStyledAttributes( @@ -85,8 +79,7 @@ public class AboutActivity extends AppCompatActivity { res.recycle(); input = getAssets().open(filename); String webViewData = IOUtils.toString(input, Charset.defaultCharset()); - if(!webViewData.startsWith("<!DOCTYPE html>")) { - //webViewData = webViewData.replace("\n\n", "</p><p>"); + if (!webViewData.startsWith("<!DOCTYPE html>")) { webViewData = webViewData.replace("%", "%"); webViewData = "<!DOCTYPE html>" + @@ -106,35 +99,29 @@ public class AboutActivity extends AppCompatActivity { " </style>" + "</head><body><p>" + webViewData + "</p></body></html>"; webViewData = webViewData.replace("\n", "<br/>"); - depth++; - } else { - depth = 0; } webViewData = String.format(webViewData, colorString); - subscriber.onNext(webViewData); + subscriber.onSuccess(webViewData); } catch (IOException e) { + Log.e(TAG, Log.getStackTraceString(e)); subscriber.onError(e); } finally { IOUtils.closeQuietly(input); } - subscriber.onCompleted(); }) .subscribeOn(Schedulers.newThread()) .observeOn(AndroidSchedulers.mainThread()) .subscribe( - webviewData -> - webview.loadDataWithBaseURL("file:///android_asset/", webviewData, "text/html", "utf-8", "about:blank"), + webViewData -> + webView.loadDataWithBaseURL("file:///android_asset/", webViewData.toString(), "text/html", "utf-8", "file:///android_asset/" + filename.toString()), error -> Log.e(TAG, Log.getStackTraceString(error)) ); } @Override public void onBackPressed() { - Log.d(TAG, "depth: " + depth); - if(depth == 1) { - loadAsset("about.html"); - } else if(depth > 1) { - webview.goBack(); + if (webView.canGoBack()) { + webView.goBack(); } else { super.onBackPressed(); } @@ -156,9 +143,9 @@ public class AboutActivity extends AppCompatActivity { if(subscription != null) { subscription.unsubscribe(); } - if (webviewContainer != null && webview != null) { - webviewContainer.removeAllViews(); - webview.destroy(); + if (webViewContainer != null && webView != null) { + webViewContainer.removeAllViews(); + webView.destroy(); } } } diff --git a/app/src/main/java/de/danoeh/antennapod/activity/AudioplayerActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/AudioplayerActivity.java index 123f66661..207aec20f 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/AudioplayerActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/AudioplayerActivity.java @@ -13,6 +13,7 @@ import de.danoeh.antennapod.core.feed.MediaType; import de.danoeh.antennapod.core.preferences.UserPreferences; import de.danoeh.antennapod.core.service.playback.PlaybackService; import de.danoeh.antennapod.core.util.playback.ExternalMedia; +import de.danoeh.antennapod.core.util.playback.PlaybackServiceStarter; import de.danoeh.antennapod.dialog.VariableSpeedDialog; /** @@ -34,14 +35,13 @@ public class AudioplayerActivity extends MediaplayerInfoActivity { Log.d(TAG, "Received VIEW intent: " + intent.getData().getPath()); ExternalMedia media = new ExternalMedia(intent.getData().getPath(), MediaType.AUDIO); - Intent launchIntent = new Intent(this, PlaybackService.class); - launchIntent.putExtra(PlaybackService.EXTRA_PLAYABLE, media); - launchIntent.putExtra(PlaybackService.EXTRA_START_WHEN_PREPARED, - true); - launchIntent.putExtra(PlaybackService.EXTRA_SHOULD_STREAM, false); - launchIntent.putExtra(PlaybackService.EXTRA_PREPARE_IMMEDIATELY, - true); - startService(launchIntent); + + new PlaybackServiceStarter(this, media) + .startWhenPrepared(true) + .shouldStream(false) + .prepareImmediately(true) + .start(); + } else if (PlaybackService.isCasting()) { Intent intent = PlaybackService.getPlayerActivityIntent(this); if (intent.getComponent() != null && diff --git a/app/src/main/java/de/danoeh/antennapod/activity/ImportExportActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/ImportExportActivity.java index 6a97adcc3..91462bce9 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/ImportExportActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/ImportExportActivity.java @@ -8,7 +8,7 @@ import android.os.Bundle; import android.os.Environment; import android.os.ParcelFileDescriptor; import android.support.design.widget.Snackbar; -import android.support.v4.content.IntentCompat; +import android.support.v7.app.ActionBar; import android.support.v7.app.AlertDialog; import android.support.v7.app.AppCompatActivity; import android.util.Log; @@ -39,7 +39,10 @@ public class ImportExportActivity extends AppCompatActivity { protected void onCreate(Bundle savedInstanceState) { setTheme(UserPreferences.getTheme()); super.onCreate(savedInstanceState); - getSupportActionBar().setDisplayShowHomeEnabled(true); + ActionBar actionBar = getSupportActionBar(); + if (actionBar != null) { + actionBar.setDisplayShowHomeEnabled(true); + } setContentView(R.layout.import_export_activity); findViewById(R.id.button_export).setOnClickListener(view -> backup()); @@ -125,7 +128,7 @@ public class ImportExportActivity extends AppCompatActivity { d.setPositiveButton(android.R.string.ok, (dialogInterface, i) -> { Intent intent = new Intent(getApplicationContext(), SplashActivity.class); ComponentName cn = intent.getComponent(); - Intent mainIntent = IntentCompat.makeRestartActivityTask(cn); + Intent mainIntent = Intent.makeRestartActivityTask(cn); startActivity(mainIntent); }); d.show(); diff --git a/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java index e593934a9..294ab5af8 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java @@ -30,6 +30,8 @@ import android.widget.ListView; import com.bumptech.glide.Glide; +import de.danoeh.antennapod.core.event.ServiceEvent; +import de.danoeh.antennapod.core.util.gui.NotificationUtils; import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.Validate; @@ -200,6 +202,8 @@ public class MainActivity extends CastEnabledActivity implements NavDrawerActivi transaction.commit(); checkFirstLaunch(); + NotificationUtils.createChannels(this); + UserPreferences.restartUpdateAlarm(false); } private void saveLastNavFragment(String tag) { @@ -739,6 +743,15 @@ public class MainActivity extends CastEnabledActivity implements NavDrawerActivi loadData(); } + public void onEventMainThread(ServiceEvent event) { + Log.d(TAG, "onEvent(" + event + ")"); + switch(event.action) { + case SERVICE_STARTED: + externalPlayerFragment.connectToPlaybackService(); + break; + } + } + public void onEventMainThread(ProgressEvent event) { Log.d(TAG, "onEvent(" + event + ")"); switch(event.action) { 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 21e375435..091f8daab 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/MediaplayerActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/MediaplayerActivity.java @@ -34,6 +34,7 @@ import com.joanzapata.iconify.fonts.FontAwesomeIcons; import java.util.Locale; import de.danoeh.antennapod.R; +import de.danoeh.antennapod.core.event.ServiceEvent; import de.danoeh.antennapod.core.feed.FeedItem; import de.danoeh.antennapod.core.feed.FeedMedia; import de.danoeh.antennapod.core.preferences.UserPreferences; @@ -42,6 +43,7 @@ import de.danoeh.antennapod.core.storage.DBReader; import de.danoeh.antennapod.core.storage.DBTasks; import de.danoeh.antennapod.core.storage.DBWriter; import de.danoeh.antennapod.core.util.Converter; +import de.danoeh.antennapod.core.util.FeedItemUtil; import de.danoeh.antennapod.core.util.Flavors; import de.danoeh.antennapod.core.util.ShareUtils; import de.danoeh.antennapod.core.util.StorageUtils; @@ -270,6 +272,9 @@ public abstract class MediaplayerActivity extends CastEnabledActivity implements controller.release(); } controller = newPlaybackController(); + setupGUI(); + loadMediaInfo(); + onPositionObserverUpdate(); } @Override @@ -320,11 +325,11 @@ public abstract class MediaplayerActivity extends CastEnabledActivity implements ((FeedMedia) media).getItem().getFlattrStatus().flattrable() ); - boolean hasWebsiteLink = media != null && media.getWebsiteLink() != null; + boolean hasWebsiteLink = ( getWebsiteLinkWithFallback(media) != null ); menu.findItem(R.id.visit_website_item).setVisible(hasWebsiteLink); boolean isItemAndHasLink = isFeedMedia && - ((FeedMedia) media).getItem() != null && ((FeedMedia) media).getItem().getLink() != null; + ShareUtils.hasLinkToShare(((FeedMedia) media).getItem()); menu.findItem(R.id.share_link_item).setVisible(isItemAndHasLink); menu.findItem(R.id.share_link_with_position_item).setVisible(isItemAndHasLink); @@ -560,7 +565,7 @@ public abstract class MediaplayerActivity extends CastEnabledActivity implements }); break; case R.id.visit_website_item: - Uri uri = Uri.parse(media.getWebsiteLink()); + Uri uri = Uri.parse(getWebsiteLinkWithFallback(media)); startActivity(new Intent(Intent.ACTION_VIEW, uri)); break; case R.id.support_item: @@ -603,16 +608,37 @@ public abstract class MediaplayerActivity extends CastEnabledActivity implements } } + private static String getWebsiteLinkWithFallback(Playable media) { + if (media == null) { + return null; + } else if (media.getWebsiteLink() != null) { + return media.getWebsiteLink(); + } else if (media instanceof FeedMedia) { + return FeedItemUtil.getLinkWithFallback(((FeedMedia)media).getItem()); + } + return null; + } + @Override protected void onResume() { super.onResume(); Log.d(TAG, "onResume()"); StorageUtils.checkStorageAvailability(this); - if(controller != null) { + if (controller != null) { controller.init(); } } + public void onEventMainThread(ServiceEvent event) { + Log.d(TAG, "onEvent(" + event + ")"); + if (event.action == ServiceEvent.Action.SERVICE_STARTED) { + if (controller != null) { + controller.init(); + } + + } + } + /** * Called by 'handleStatus()' when the PlaybackService is waiting for * a video surface. @@ -853,6 +879,7 @@ public abstract class MediaplayerActivity extends CastEnabledActivity implements if(controller == null) { return; } + controller.init(); controller.playPause(); } diff --git a/app/src/main/java/de/danoeh/antennapod/activity/PreferenceActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/PreferenceActivity.java index a6aec2425..3f005fe36 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/PreferenceActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/PreferenceActivity.java @@ -1,13 +1,12 @@ package de.danoeh.antennapod.activity; -import android.app.Activity; import android.content.Intent; import android.os.Bundle; -import android.preference.Preference; -import android.preference.PreferenceFragment; -import android.preference.PreferenceScreen; import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; +import android.support.v7.preference.Preference; +import android.support.v7.preference.PreferenceFragmentCompat; +import android.support.v7.preference.PreferenceScreen; import android.view.Menu; import android.view.MenuItem; import android.view.ViewGroup; @@ -15,6 +14,9 @@ import android.widget.FrameLayout; import java.lang.ref.WeakReference; +import com.bytehamster.lib.preferencesearch.SearchPreference; +import com.bytehamster.lib.preferencesearch.SearchPreferenceResult; +import com.bytehamster.lib.preferencesearch.SearchPreferenceResultListener; import de.danoeh.antennapod.R; import de.danoeh.antennapod.core.preferences.UserPreferences; import de.danoeh.antennapod.preferences.PreferenceController; @@ -23,20 +25,25 @@ import de.danoeh.antennapod.preferences.PreferenceController; * PreferenceActivity for API 11+. In order to change the behavior of the preference UI, see * PreferenceController. */ -public class PreferenceActivity extends AppCompatActivity { +public class PreferenceActivity extends AppCompatActivity implements SearchPreferenceResultListener { public static final String PARAM_RESOURCE = "resource"; private static WeakReference<PreferenceActivity> instance; private PreferenceController preferenceController; private final PreferenceController.PreferenceUI preferenceUI = new PreferenceController.PreferenceUI() { - private PreferenceFragment fragment; + private PreferenceFragmentCompat fragment; @Override - public void setFragment(PreferenceFragment fragment) { + public void setFragment(PreferenceFragmentCompat fragment) { this.fragment = fragment; } @Override + public PreferenceFragmentCompat getFragment() { + return fragment; + } + + @Override public Preference findPreference(CharSequence key) { return fragment.findPreference(key); } @@ -47,7 +54,7 @@ public class PreferenceActivity extends AppCompatActivity { } @Override - public Activity getActivity() { + public AppCompatActivity getActivity() { return PreferenceActivity.this; } }; @@ -77,12 +84,21 @@ public class PreferenceActivity extends AppCompatActivity { // since the MainFragment depends on the preferenceController already being created preferenceController = new PreferenceController(preferenceUI); - PreferenceFragment prefFragment = new MainFragment(); + showPreferenceScreen(R.xml.preferences, false); + } + + private void showPreferenceScreen(int screen, boolean addHistory) { + PreferenceFragmentCompat prefFragment = new MainFragment(); preferenceUI.setFragment(prefFragment); Bundle args = new Bundle(); - args.putInt(PARAM_RESOURCE, R.xml.preferences); + args.putInt(PARAM_RESOURCE, screen); prefFragment.setArguments(args); - getFragmentManager().beginTransaction().replace(R.id.content, prefFragment).commit(); + if (addHistory) { + getSupportFragmentManager().beginTransaction().replace(R.id.content, prefFragment) + .addToBackStack(getString(PreferenceController.getTitleOfPage(screen))).commit(); + } else { + getSupportFragmentManager().beginTransaction().replace(R.id.content, prefFragment).commit(); + } } @Override @@ -101,10 +117,10 @@ public class PreferenceActivity extends AppCompatActivity { public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: - if (getFragmentManager().getBackStackEntryCount() == 0) { + if (getSupportFragmentManager().getBackStackEntryCount() == 0) { finish(); } else { - getFragmentManager().popBackStack(); + getSupportFragmentManager().popBackStack(); } return true; default: @@ -112,13 +128,23 @@ public class PreferenceActivity extends AppCompatActivity { } } - public static class MainFragment extends PreferenceFragment { + @Override + public void onSearchResultClicked(SearchPreferenceResult result) { + showPreferenceScreen(result.getResourceFile(), true); + result.highlight(preferenceUI.getFragment()); + } + + public static class MainFragment extends PreferenceFragmentCompat { private int screen; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setRetainInstance(true); + } + + @Override + public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { screen = getArguments().getInt(PARAM_RESOURCE); addPreferencesFromResource(screen); PreferenceActivity activity = instance.get(); @@ -133,35 +159,16 @@ public class PreferenceActivity extends AppCompatActivity { super.onResume(); PreferenceActivity activity = instance.get(); if(activity != null && activity.preferenceController != null) { - activity.setTitle(getTitle(screen)); + activity.setTitle(PreferenceController.getTitleOfPage(screen)); activity.preferenceUI.setFragment(this); activity.preferenceController.onResume(screen); } } - private int getTitle(int preferences) { - switch (preferences) { - case R.xml.preferences_network: - return R.string.network_pref; - case R.xml.preferences_autodownload: - return R.string.pref_automatic_download_title; - case R.xml.preferences_playback: - return R.string.playback_pref; - case R.xml.preferences_storage: - return R.string.storage_pref; - case R.xml.preferences_user_interface: - return R.string.user_interface_label; - case R.xml.preferences_integrations: - return R.string.integrations_label; - default: - return R.string.settings_label; - } - } - @Override public void onPause() { PreferenceActivity activity = instance.get(); - if (screen == R.xml.preferences_integrations) { + if (screen == R.xml.preferences_gpodder) { activity.preferenceController.unregisterGpodnet(); } super.onPause(); 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 733f39b63..c8fb12abc 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/VideoplayerActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/VideoplayerActivity.java @@ -30,6 +30,7 @@ import de.danoeh.antennapod.core.service.playback.PlayerStatus; import de.danoeh.antennapod.core.util.gui.PictureInPictureUtil; import de.danoeh.antennapod.core.util.playback.ExternalMedia; import de.danoeh.antennapod.core.util.playback.Playable; +import de.danoeh.antennapod.core.util.playback.PlaybackServiceStarter; import de.danoeh.antennapod.view.AspectRatioVideoView; import java.lang.ref.WeakReference; @@ -82,14 +83,12 @@ public class VideoplayerActivity extends MediaplayerActivity { Log.d(TAG, "Received VIEW intent: " + intent.getData().getPath()); ExternalMedia media = new ExternalMedia(intent.getData().getPath(), MediaType.VIDEO); - Intent launchIntent = new Intent(this, PlaybackService.class); - launchIntent.putExtra(PlaybackService.EXTRA_PLAYABLE, media); - launchIntent.putExtra(PlaybackService.EXTRA_START_WHEN_PREPARED, - true); - launchIntent.putExtra(PlaybackService.EXTRA_SHOULD_STREAM, false); - launchIntent.putExtra(PlaybackService.EXTRA_PREPARE_IMMEDIATELY, - true); - startService(launchIntent); + + new PlaybackServiceStarter(this, media) + .startWhenPrepared(true) + .shouldStream(false) + .prepareImmediately(true) + .start(); } else if (PlaybackService.isCasting()) { Intent intent = PlaybackService.getPlayerActivityIntent(this); if (!intent.getComponent().getClassName().equals(VideoplayerActivity.class.getName())) { diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/DefaultActionButtonCallback.java b/app/src/main/java/de/danoeh/antennapod/adapter/DefaultActionButtonCallback.java index 4a53be9dc..d8f324e8a 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/DefaultActionButtonCallback.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/DefaultActionButtonCallback.java @@ -6,6 +6,7 @@ import android.widget.Toast; import com.afollestad.materialdialogs.MaterialDialog; +import de.danoeh.antennapod.core.util.playback.PlaybackServiceStarter; import org.apache.commons.lang3.Validate; import de.danoeh.antennapod.R; @@ -80,13 +81,19 @@ public class DefaultActionButtonCallback implements ActionButtonCallback { Toast.makeText(context, R.string.download_canceled_msg, Toast.LENGTH_LONG).show(); } } else { // media is downloaded - if (item.hasMedia() && item.getMedia().isCurrentlyPlaying()) { + if (media.isCurrentlyPlaying()) { + new PlaybackServiceStarter(context, media) + .startWhenPrepared(true) + .shouldStream(false) + .start(); context.sendBroadcast(new Intent(PlaybackService.ACTION_PAUSE_PLAY_CURRENT_EPISODE)); - } - else if (item.hasMedia() && item.getMedia().isCurrentlyPaused()) { + } else if (media.isCurrentlyPaused()) { + new PlaybackServiceStarter(context, media) + .startWhenPrepared(true) + .shouldStream(false) + .start(); context.sendBroadcast(new Intent(PlaybackService.ACTION_RESUME_PLAY_CURRENT_EPISODE)); - } - else { + } else { DBTasks.playMedia(context, media, false, true, false); } } diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/DownloadedEpisodesListAdapter.java b/app/src/main/java/de/danoeh/antennapod/adapter/DownloadedEpisodesListAdapter.java index c62c30c90..c4f476634 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/DownloadedEpisodesListAdapter.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/DownloadedEpisodesListAdapter.java @@ -100,8 +100,10 @@ public class DownloadedEpisodesListAdapter extends BaseAdapter { FeedItem.State state = item.getState(); if (state == FeedItem.State.PLAYING) { holder.butSecondary.setEnabled(false); + holder.butSecondary.setAlpha(0.5f); } else { holder.butSecondary.setEnabled(true); + holder.butSecondary.setAlpha(1.0f); } holder.butSecondary.setFocusable(false); holder.butSecondary.setTag(item); 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 2705e7402..b072aeaf2 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/ExternalPlayerFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/ExternalPlayerFragment.java @@ -37,7 +37,6 @@ public class ExternalPlayerFragment extends Fragment { private ImageButton butPlay; private TextView mFeedName; private ProgressBar mProgressBar; - private PlaybackController controller; public ExternalPlayerFragment() { @@ -83,6 +82,11 @@ public class ExternalPlayerFragment extends Fragment { controller.playPause(); } }); + loadMediaInfo(); + } + + public void connectToPlaybackService() { + controller.init(); } private PlaybackController setupPlaybackController() { @@ -164,36 +168,35 @@ public class ExternalPlayerFragment extends Fragment { private boolean loadMediaInfo() { Log.d(TAG, "Loading media info"); - if (controller != null && controller.serviceAvailable()) { - Playable media = controller.getMedia(); - if (media != null) { - txtvTitle.setText(media.getEpisodeTitle()); - mFeedName.setText(media.getFeedTitle()); - mProgressBar.setProgress((int) - ((double) controller.getPosition() / controller.getDuration() * 100)); - - Glide.with(getActivity()) - .load(media.getImageLocation()) - .placeholder(R.color.light_gray) - .error(R.color.light_gray) - .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY) - .fitCenter() - .dontAnimate() - .into(imgvCover); - - fragmentLayout.setVisibility(View.VISIBLE); - if (controller.isPlayingVideoLocally()) { - butPlay.setVisibility(View.GONE); - } else { - butPlay.setVisibility(View.VISIBLE); - } - return true; + if (controller == null) { + Log.w(TAG, "loadMediaInfo was called while PlaybackController was null!"); + return false; + } + + Playable media = controller.getMedia(); + if (media != null) { + txtvTitle.setText(media.getEpisodeTitle()); + mFeedName.setText(media.getFeedTitle()); + onPositionObserverUpdate(); + + Glide.with(getActivity()) + .load(media.getImageLocation()) + .placeholder(R.color.light_gray) + .error(R.color.light_gray) + .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY) + .fitCenter() + .dontAnimate() + .into(imgvCover); + + fragmentLayout.setVisibility(View.VISIBLE); + if (controller.isPlayingVideoLocally()) { + butPlay.setVisibility(View.GONE); } else { - Log.w(TAG, "loadMediaInfo was called while the media object of playbackService was null!"); - return false; + butPlay.setVisibility(View.VISIBLE); } + return true; } else { - Log.w(TAG, "loadMediaInfo was called while playbackService was null!"); + Log.w(TAG, "loadMediaInfo was called while the media object of playbackService was null!"); return false; } } 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 2d11e9f71..6b589493b 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/ItemFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/ItemFragment.java @@ -34,6 +34,7 @@ import com.bumptech.glide.Glide; import com.joanzapata.iconify.Iconify; import com.joanzapata.iconify.widget.IconButton; +import de.danoeh.antennapod.core.service.playback.PlaybackService; import de.danoeh.antennapod.core.util.NetworkUtils; import org.apache.commons.lang3.ArrayUtils; @@ -432,6 +433,16 @@ public class ItemFragment extends Fragment implements OnSwipeGesture { butAction1Text = R.string.download_label; } } + + FeedItem.State state = item.getState(); + if (butAction2Text == R.string.delete_label && state == FeedItem.State.PLAYING) { + butAction2.setEnabled(false); + butAction2.setAlpha(0.5f); + } else { + butAction2.setEnabled(true); + butAction2.setAlpha(1.0f); + } + if(butAction1Icon != null && butAction1Text != 0) { butAction1.setText(butAction1Icon +"\u0020\u0020" + getActivity().getString(butAction1Text)); Iconify.addIcons(butAction1); 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 fba445d3a..bae77d58b 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/QueueFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/QueueFragment.java @@ -327,6 +327,15 @@ public class QueueFragment extends Fragment { case R.id.queue_sort_feed_title_desc: QueueSorter.sort(getActivity(), QueueSorter.Rule.FEED_TITLE_DESC, true); return true; + case R.id.queue_sort_random: + QueueSorter.sort(getActivity(), QueueSorter.Rule.RANDOM, true); + return true; + case R.id.queue_sort_smart_shuffle_asc: + QueueSorter.sort(getActivity(), QueueSorter.Rule.SMART_SHUFFLE_ASC, true); + return true; + case R.id.queue_sort_smart_shuffle_desc: + QueueSorter.sort(getActivity(), QueueSorter.Rule.SMART_SHUFFLE_DESC, true); + return true; default: return false; } @@ -525,14 +534,15 @@ public class QueueFragment extends Fragment { private void refreshInfoBar() { String info = queue.size() + getString(R.string.episodes_suffix); if(queue.size() > 0) { - long duration = 0; + long timeLeft = 0; for(FeedItem item : queue) { if(item.getMedia() != null) { - duration += item.getMedia().getDuration(); + timeLeft += item.getMedia().getDuration() - item.getMedia().getPosition(); } } info += " \u2022 "; - info += Converter.getDurationStringLocalized(getActivity(), duration); + info += getString(R.string.time_left_label); + info += Converter.getDurationStringLocalized(getActivity(), timeLeft); } infoBar.setText(info); } 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 f6f73e017..de47ee5e4 100644 --- a/app/src/main/java/de/danoeh/antennapod/menuhandler/FeedItemMenuHandler.java +++ b/app/src/main/java/de/danoeh/antennapod/menuhandler/FeedItemMenuHandler.java @@ -17,6 +17,7 @@ import de.danoeh.antennapod.core.preferences.UserPreferences; import de.danoeh.antennapod.core.service.playback.PlaybackService; import de.danoeh.antennapod.core.storage.DBTasks; import de.danoeh.antennapod.core.storage.DBWriter; +import de.danoeh.antennapod.core.util.FeedItemUtil; import de.danoeh.antennapod.core.util.IntentUtils; import de.danoeh.antennapod.core.util.LongList; import de.danoeh.antennapod.core.util.ShareUtils; @@ -86,7 +87,7 @@ public class FeedItemMenuHandler { mi.setItemVisibility(R.id.add_to_queue_item, false); } - if (!showExtendedMenu || selectedItem.getLink() == null) { + if (!showExtendedMenu || !ShareUtils.hasLinkToShare(selectedItem)) { mi.setItemVisibility(R.id.visit_website_item, false); mi.setItemVisibility(R.id.share_link_item, false); mi.setItemVisibility(R.id.share_link_with_position_item, false); @@ -216,7 +217,7 @@ public class FeedItemMenuHandler { DBWriter.setFeedItemAutoDownload(selectedItem, false); break; case R.id.visit_website_item: - Uri uri = Uri.parse(selectedItem.getLink()); + Uri uri = Uri.parse(FeedItemUtil.getLinkWithFallback(selectedItem)); Intent intent = new Intent(Intent.ACTION_VIEW, uri); if(IntentUtils.isCallable(context, intent)) { context.startActivity(intent); diff --git a/app/src/main/java/de/danoeh/antennapod/preferences/MasterSwitchPreference.java b/app/src/main/java/de/danoeh/antennapod/preferences/MasterSwitchPreference.java index bcac65804..e500267fe 100644 --- a/app/src/main/java/de/danoeh/antennapod/preferences/MasterSwitchPreference.java +++ b/app/src/main/java/de/danoeh/antennapod/preferences/MasterSwitchPreference.java @@ -4,13 +4,14 @@ import android.annotation.TargetApi; import android.content.Context; import android.graphics.Typeface; import android.os.Build; +import android.support.v14.preference.SwitchPreference; +import android.support.v7.preference.PreferenceViewHolder; import android.util.AttributeSet; import android.util.TypedValue; -import android.view.View; import android.widget.TextView; import de.danoeh.antennapod.R; -public class MasterSwitchPreference extends SwitchCompatPreference { +public class MasterSwitchPreference extends SwitchPreference { public MasterSwitchPreference(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); @@ -29,15 +30,16 @@ public class MasterSwitchPreference extends SwitchCompatPreference { super(context); } + @Override - protected void onBindView(View view) { - super.onBindView(view); + public void onBindViewHolder(PreferenceViewHolder holder) { + super.onBindViewHolder(holder); TypedValue typedValue = new TypedValue(); getContext().getTheme().resolveAttribute(R.attr.master_switch_background, typedValue, true); - view.setBackgroundColor(typedValue.data); + holder.itemView.setBackgroundColor(typedValue.data); - TextView title = (TextView) view.findViewById(android.R.id.title); + TextView title = (TextView) holder.findViewById(android.R.id.title); if (title != null) { title.setTypeface(title.getTypeface(), Typeface.BOLD); } diff --git a/app/src/main/java/de/danoeh/antennapod/preferences/PreferenceController.java b/app/src/main/java/de/danoeh/antennapod/preferences/PreferenceController.java index a6db1986f..c1aea28c8 100644 --- a/app/src/main/java/de/danoeh/antennapod/preferences/PreferenceController.java +++ b/app/src/main/java/de/danoeh/antennapod/preferences/PreferenceController.java @@ -3,7 +3,6 @@ package de.danoeh.antennapod.preferences; import android.Manifest; import android.annotation.SuppressLint; import android.app.Activity; -import android.app.Fragment; import android.app.ProgressDialog; import android.app.TimePickerDialog; import android.content.ActivityNotFoundException; @@ -18,31 +17,29 @@ import android.net.wifi.WifiConfiguration; import android.net.wifi.WifiManager; import android.os.Build; import android.os.Bundle; -import android.preference.CheckBoxPreference; -import android.preference.EditTextPreference; -import android.preference.ListPreference; -import android.preference.Preference; -import android.preference.PreferenceFragment; -import android.preference.PreferenceManager; -import android.preference.PreferenceScreen; import android.support.design.widget.Snackbar; import android.support.v4.app.ActivityCompat; import android.support.v4.content.FileProvider; import android.support.v7.app.AlertDialog; -import android.text.Editable; +import android.support.v7.app.AppCompatActivity; +import android.support.v7.preference.CheckBoxPreference; +import android.support.v7.preference.ListPreference; +import android.support.v7.preference.Preference; +import android.support.v7.preference.PreferenceFragmentCompat; +import android.support.v7.preference.PreferenceManager; +import android.support.v7.preference.PreferenceScreen; import android.text.Html; -import android.text.TextWatcher; import android.text.format.DateFormat; import android.text.format.DateUtils; import android.util.Log; -import android.widget.EditText; import android.widget.ListView; import android.widget.Toast; import com.afollestad.materialdialogs.MaterialDialog; +import com.bytehamster.lib.preferencesearch.SearchConfiguration; +import com.bytehamster.lib.preferencesearch.SearchPreference; import de.danoeh.antennapod.activity.AboutActivity; -import com.afollestad.materialdialogs.prefs.MaterialListPreference; import de.danoeh.antennapod.activity.ImportExportActivity; import de.danoeh.antennapod.activity.MediaplayerActivity; import de.danoeh.antennapod.activity.OpmlImportFromPathActivity; @@ -99,8 +96,9 @@ public class PreferenceController implements SharedPreferences.OnSharedPreferenc private static final String PREF_SCREEN_INTEGRATIONS = "prefScreenIntegrations"; private static final String PREF_SCREEN_STORAGE = "prefScreenStorage"; private static final String PREF_SCREEN_AUTODL = "prefAutoDownloadSettings"; + private static final String PREF_SCREEN_FLATTR = "prefFlattrSettings"; + private static final String PREF_SCREEN_GPODDER = "prefGpodderSettings"; - private static final String PREF_FLATTR_SETTINGS = "prefFlattrSettings"; private static final String PREF_FLATTR_AUTH = "pref_flattr_authenticate"; private static final String PREF_FLATTR_REVOKE = "prefRevokeAccess"; private static final String PREF_AUTO_FLATTR_PREFS = "prefAutoFlattrPrefs"; @@ -176,6 +174,12 @@ public class PreferenceController implements SharedPreferences.OnSharedPreferenc case R.xml.preferences_integrations: setupIntegrationsScreen(); break; + case R.xml.preferences_flattr: + setupFlattrScreen(); + break; + case R.xml.preferences_gpodder: + setupGpodderScreen(); + break; case R.xml.preferences_storage: setupStorageScreen(); break; @@ -295,7 +299,20 @@ public class PreferenceController implements SharedPreferences.OnSharedPreferenc } private void setupIntegrationsScreen() { - final Activity activity = ui.getActivity(); + final AppCompatActivity activity = ui.getActivity(); + + ui.findPreference(PREF_SCREEN_FLATTR).setOnPreferenceClickListener(preference -> { + openScreen(R.xml.preferences_flattr, activity); + return true; + }); + ui.findPreference(PREF_SCREEN_GPODDER).setOnPreferenceClickListener(preference -> { + openScreen(R.xml.preferences_gpodder, activity); + return true; + }); + } + + private void setupFlattrScreen() { + final AppCompatActivity activity = ui.getActivity(); ui.findPreference(PreferenceController.PREF_FLATTR_REVOKE).setOnPreferenceClickListener( preference -> { @@ -304,6 +321,29 @@ public class PreferenceController implements SharedPreferences.OnSharedPreferenc return true; } ); + + ui.findPreference(PreferenceController.PREF_AUTO_FLATTR_PREFS) + .setOnPreferenceClickListener(preference -> { + AutoFlattrPreferenceDialog.newAutoFlattrPreferenceDialog(activity, + new AutoFlattrPreferenceDialog.AutoFlattrPreferenceDialogInterface() { + @Override + public void onCancelled() { + + } + + @Override + public void onConfirmed(boolean autoFlattrEnabled, float autoFlattrValue) { + UserPreferences.setAutoFlattrSettings(autoFlattrEnabled, autoFlattrValue); + checkFlattrItemVisibility(); + } + }); + return true; + }); + } + + private void setupGpodderScreen() { + final AppCompatActivity activity = ui.getActivity(); + ui.findPreference(PreferenceController.PREF_GPODNET_SETLOGIN_INFORMATION) .setOnPreferenceClickListener(preference -> { AuthenticationDialog dialog = new AuthenticationDialog(activity, @@ -351,24 +391,6 @@ public class PreferenceController implements SharedPreferences.OnSharedPreferenc GpodnetSetHostnameDialog.createDialog(activity).setOnDismissListener(dialog -> updateGpodnetPreferenceScreen()); return true; }); - - ui.findPreference(PreferenceController.PREF_AUTO_FLATTR_PREFS) - .setOnPreferenceClickListener(preference -> { - AutoFlattrPreferenceDialog.newAutoFlattrPreferenceDialog(activity, - new AutoFlattrPreferenceDialog.AutoFlattrPreferenceDialogInterface() { - @Override - public void onCancelled() { - - } - - @Override - public void onConfirmed(boolean autoFlattrEnabled, float autoFlattrValue) { - UserPreferences.setAutoFlattrSettings(autoFlattrEnabled, autoFlattrValue); - checkFlattrItemVisibility(); - } - }); - return true; - }); } private void setupPlaybackScreen() { @@ -390,7 +412,7 @@ public class PreferenceController implements SharedPreferences.OnSharedPreferenc return true; }); if (!PictureInPictureUtil.supportsPictureInPicture(activity)) { - MaterialListPreference behaviour = (MaterialListPreference) ui.findPreference(UserPreferences.PREF_VIDEO_BEHAVIOR); + ListPreference behaviour = (ListPreference) ui.findPreference(UserPreferences.PREF_VIDEO_BEHAVIOR); behaviour.setEntries(R.array.video_background_behavior_options_without_pip); behaviour.setEntryValues(R.array.video_background_behavior_values_without_pip); } @@ -427,9 +449,11 @@ public class PreferenceController implements SharedPreferences.OnSharedPreferenc } private void setupNetworkScreen() { - final Activity activity = ui.getActivity(); - ui.findPreference(PREF_SCREEN_AUTODL).setOnPreferenceClickListener(preference -> - openScreen(R.xml.preferences_autodownload, activity)); + final AppCompatActivity activity = ui.getActivity(); + ui.findPreference(PREF_SCREEN_AUTODL).setOnPreferenceClickListener(preference -> { + openScreen(R.xml.preferences_autodownload, activity); + return true; + }); ui.findPreference(UserPreferences.PREF_UPDATE_INTERVAL) .setOnPreferenceClickListener(preference -> { showUpdateIntervalTimePreferencesDialog(); @@ -453,33 +477,6 @@ public class PreferenceController implements SharedPreferences.OnSharedPreferenc } ); // validate and set correct value: number of downloads between 1 and 50 (inclusive) - final EditText ev = ((EditTextPreference) ui.findPreference(UserPreferences.PREF_PARALLEL_DOWNLOADS)).getEditText(); - ev.addTextChangedListener(new TextWatcher() { - @Override - public void beforeTextChanged(CharSequence s, int start, int count, int after) { - } - - @Override - public void onTextChanged(CharSequence s, int start, int before, int count) { - } - - @Override - public void afterTextChanged(Editable s) { - if (s.length() > 0) { - try { - int value = Integer.parseInt(s.toString()); - if (value <= 0) { - ev.setText("1"); - } else if (value > 50) { - ev.setText("50"); - } - } catch (NumberFormatException e) { - ev.setText("6"); - } - ev.setSelection(ev.getText().length()); - } - } - }); ui.findPreference(PREF_PROXY).setOnPreferenceClickListener(preference -> { ProxyDialog dialog = new ProxyDialog(ui.getActivity()); dialog.createDialog().show(); @@ -488,17 +485,28 @@ public class PreferenceController implements SharedPreferences.OnSharedPreferenc } private void setupMainScreen() { - final Activity activity = ui.getActivity(); - ui.findPreference(PREF_SCREEN_USER_INTERFACE).setOnPreferenceClickListener(preference -> - openScreen(R.xml.preferences_user_interface, activity)); - ui.findPreference(PREF_SCREEN_PLAYBACK).setOnPreferenceClickListener(preference -> - openScreen(R.xml.preferences_playback, activity)); - ui.findPreference(PREF_SCREEN_NETWORK).setOnPreferenceClickListener(preference -> - openScreen(R.xml.preferences_network, activity)); - ui.findPreference(PREF_SCREEN_INTEGRATIONS).setOnPreferenceClickListener(preference -> - openScreen(R.xml.preferences_integrations, activity)); - ui.findPreference(PREF_SCREEN_STORAGE).setOnPreferenceClickListener(preference -> - openScreen(R.xml.preferences_storage, activity)); + final AppCompatActivity activity = ui.getActivity(); + setupSearch(); + ui.findPreference(PREF_SCREEN_USER_INTERFACE).setOnPreferenceClickListener(preference -> { + openScreen(R.xml.preferences_user_interface, activity); + return true; + }); + ui.findPreference(PREF_SCREEN_PLAYBACK).setOnPreferenceClickListener(preference -> { + openScreen(R.xml.preferences_playback, activity); + return true; + }); + ui.findPreference(PREF_SCREEN_NETWORK).setOnPreferenceClickListener(preference -> { + openScreen(R.xml.preferences_network, activity); + return true; + }); + ui.findPreference(PREF_SCREEN_INTEGRATIONS).setOnPreferenceClickListener(preference -> { + openScreen(R.xml.preferences_integrations, activity); + return true; + }); + ui.findPreference(PREF_SCREEN_STORAGE).setOnPreferenceClickListener(preference -> { + openScreen(R.xml.preferences_storage, activity); + return true; + }); ui.findPreference(PreferenceController.PREF_ABOUT).setOnPreferenceClickListener( preference -> { @@ -545,15 +553,74 @@ public class PreferenceController implements SharedPreferences.OnSharedPreferenc }); } - private boolean openScreen(int preferences, Activity activity) { - Fragment prefFragment = new PreferenceActivity.MainFragment(); + private void setupSearch() { + final AppCompatActivity activity = ui.getActivity(); + + SearchPreference searchPreference = (SearchPreference) ui.findPreference("searchPreference"); + SearchConfiguration config = searchPreference.getSearchConfiguration(); + config.setActivity(activity); + config.setFragmentContainerViewId(R.id.content); + config.setBreadcrumbsEnabled(true); + + config.index() + .addBreadcrumb(getTitleOfPage(R.xml.preferences_user_interface)) + .addFile(R.xml.preferences_user_interface); + config.index() + .addBreadcrumb(getTitleOfPage(R.xml.preferences_playback)) + .addFile(R.xml.preferences_playback); + config.index() + .addBreadcrumb(getTitleOfPage(R.xml.preferences_network)) + .addFile(R.xml.preferences_network); + config.index() + .addBreadcrumb(getTitleOfPage(R.xml.preferences_storage)) + .addFile(R.xml.preferences_storage); + config.index() + .addBreadcrumb(getTitleOfPage(R.xml.preferences_network)) + .addBreadcrumb(R.string.automation) + .addBreadcrumb(getTitleOfPage(R.xml.preferences_autodownload)) + .addFile(R.xml.preferences_autodownload); + config.index() + .addBreadcrumb(getTitleOfPage(R.xml.preferences_integrations)) + .addBreadcrumb(getTitleOfPage(R.xml.preferences_gpodder)) + .addFile(R.xml.preferences_gpodder); + config.index() + .addBreadcrumb(getTitleOfPage(R.xml.preferences_integrations)) + .addBreadcrumb(getTitleOfPage(R.xml.preferences_flattr)) + .addFile(R.xml.preferences_flattr); + } + + public PreferenceFragmentCompat openScreen(int preferences, AppCompatActivity activity) { + PreferenceFragmentCompat prefFragment = new PreferenceActivity.MainFragment(); Bundle args = new Bundle(); args.putInt(PARAM_RESOURCE, preferences); prefFragment.setArguments(args); - activity.getFragmentManager().beginTransaction() + activity.getSupportFragmentManager().beginTransaction() .replace(R.id.content, prefFragment) .addToBackStack(TAG).commit(); - return true; + return prefFragment; + } + + public static int getTitleOfPage(int preferences) { + switch (preferences) { + case R.xml.preferences_network: + return R.string.network_pref; + case R.xml.preferences_autodownload: + return R.string.pref_automatic_download_title; + case R.xml.preferences_playback: + return R.string.playback_pref; + case R.xml.preferences_storage: + return R.string.storage_pref; + case R.xml.preferences_user_interface: + return R.string.user_interface_label; + case R.xml.preferences_integrations: + return R.string.integrations_label; + case R.xml.preferences_flattr: + return R.string.flattr_label; + case R.xml.preferences_gpodder: + return R.string.gpodnet_main_label; + default: + return R.string.settings_label; + } } private boolean export(ExportWriter exportWriter) { @@ -623,9 +690,14 @@ public class PreferenceController implements SharedPreferences.OnSharedPreferenc setDataFolderText(); break; case R.xml.preferences_integrations: + setIntegrationsItemVisibility(); + return; + case R.xml.preferences_flattr: + checkFlattrItemVisibility(); + break; + case R.xml.preferences_gpodder: GpodnetPreferences.registerOnSharedPreferenceChangeListener(gpoddernetListener); updateGpodnetPreferenceScreen(); - checkFlattrItemVisibility(); break; case R.xml.preferences_playback: checkSonicItemVisibility(); @@ -792,10 +864,13 @@ public class PreferenceController implements SharedPreferences.OnSharedPreferenc } } + private void setIntegrationsItemVisibility() { + ui.findPreference(PreferenceController.PREF_SCREEN_FLATTR).setEnabled(FlattrUtils.hasAPICredentials()); + } + @SuppressWarnings("deprecation") private void checkFlattrItemVisibility() { boolean hasFlattrToken = FlattrUtils.hasToken(); - ui.findPreference(PreferenceController.PREF_FLATTR_SETTINGS).setEnabled(FlattrUtils.hasAPICredentials()); ui.findPreference(PreferenceController.PREF_FLATTR_AUTH).setEnabled(!hasFlattrToken); ui.findPreference(PreferenceController.PREF_FLATTR_REVOKE).setEnabled(hasFlattrToken); ui.findPreference(PreferenceController.PREF_AUTO_FLATTR_PREFS).setEnabled(hasFlattrToken); @@ -1109,7 +1184,8 @@ public class PreferenceController implements SharedPreferences.OnSharedPreferenc public interface PreferenceUI { - void setFragment(PreferenceFragment fragment); + void setFragment(PreferenceFragmentCompat fragment); + PreferenceFragmentCompat getFragment(); /** * Finds a preference based on its key. @@ -1118,6 +1194,6 @@ public class PreferenceController implements SharedPreferences.OnSharedPreferenc PreferenceScreen getPreferenceScreen(); - Activity getActivity(); + AppCompatActivity getActivity(); } } diff --git a/app/src/main/java/de/danoeh/antennapod/preferences/SwitchCompatPreference.java b/app/src/main/java/de/danoeh/antennapod/preferences/SwitchCompatPreference.java deleted file mode 100644 index 10c11b88e..000000000 --- a/app/src/main/java/de/danoeh/antennapod/preferences/SwitchCompatPreference.java +++ /dev/null @@ -1,37 +0,0 @@ -package de.danoeh.antennapod.preferences; - -import android.annotation.TargetApi; -import android.content.Context; -import android.os.Build; -import android.preference.CheckBoxPreference; -import android.util.AttributeSet; - -import de.danoeh.antennapod.R; - -public class SwitchCompatPreference extends CheckBoxPreference { - - public SwitchCompatPreference(Context context, AttributeSet attrs, int defStyleAttr) { - super(context, attrs, defStyleAttr); - init(); - } - - @TargetApi(Build.VERSION_CODES.LOLLIPOP) - public SwitchCompatPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { - super(context, attrs, defStyleAttr, defStyleRes); - init(); - } - - public SwitchCompatPreference(Context context, AttributeSet attrs) { - super(context, attrs); - init(); - } - - public SwitchCompatPreference(Context context) { - super(context); - init(); - } - - private void init() { - setWidgetLayoutResource(R.layout.preference_switch_layout); - } -}
\ No newline at end of file diff --git a/app/src/main/java/de/danoeh/antennapod/receiver/PlayerWidget.java b/app/src/main/java/de/danoeh/antennapod/receiver/PlayerWidget.java deleted file mode 100644 index a90f0f706..000000000 --- a/app/src/main/java/de/danoeh/antennapod/receiver/PlayerWidget.java +++ /dev/null @@ -1,80 +0,0 @@ -package de.danoeh.antennapod.receiver; - -import android.appwidget.AppWidgetManager; -import android.appwidget.AppWidgetProvider; -import android.content.Context; -import android.content.Intent; -import android.content.SharedPreferences; -import android.text.TextUtils; -import android.util.Log; - -import java.util.Arrays; - -import de.danoeh.antennapod.core.service.playback.PlaybackService; -import de.danoeh.antennapod.service.PlayerWidgetService; - -public class PlayerWidget extends AppWidgetProvider { - private static final String TAG = "PlayerWidget"; - private static final String PREFS_NAME = "PlayerWidgetPrefs"; - private static final String KEY_ENABLED = "WidgetEnabled"; - - @Override - public void onReceive(Context context, Intent intent) { - Log.d(TAG, "onReceive"); - super.onReceive(context, intent); - // don't do anything if we're not enabled - if (!isEnabled(context)) { - return; - } - - // these come from the PlaybackService when things should get updated - if (TextUtils.equals(intent.getAction(), PlaybackService.FORCE_WIDGET_UPDATE)) { - startUpdate(context); - } else if (TextUtils.equals(intent.getAction(), PlaybackService.STOP_WIDGET_UPDATE)) { - stopUpdate(context); - } - } - - @Override - public void onEnabled(Context context) { - super.onEnabled(context); - Log.d(TAG, "Widget enabled"); - setEnabled(context, true); - startUpdate(context); - } - - @Override - public void onUpdate(Context context, AppWidgetManager appWidgetManager, - int[] appWidgetIds) { - Log.d(TAG, "onUpdate() called with: " + "context = [" + context + "], appWidgetManager = [" + appWidgetManager + "], appWidgetIds = [" + Arrays.toString(appWidgetIds) + "]"); - startUpdate(context); - } - - @Override - public void onDisabled(Context context) { - super.onDisabled(context); - Log.d(TAG, "Widget disabled"); - setEnabled(context, false); - stopUpdate(context); - } - - private void startUpdate(Context context) { - Log.d(TAG, "startUpdate() called with: " + "context = [" + context + "]"); - context.startService(new Intent(context, PlayerWidgetService.class)); - } - - private void stopUpdate(Context context) { - Log.d(TAG, "stopUpdate() called with: " + "context = [" + context + "]"); - context.stopService(new Intent(context, PlayerWidgetService.class)); - } - - private boolean isEnabled(Context context) { - SharedPreferences prefs = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE); - return prefs.getBoolean(KEY_ENABLED, false); - } - - private void setEnabled(Context context, boolean enabled) { - SharedPreferences prefs = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE); - prefs.edit().putBoolean(KEY_ENABLED, enabled).apply(); - } -} diff --git a/app/src/main/java/de/danoeh/antennapod/service/PlayerWidgetService.java b/app/src/main/java/de/danoeh/antennapod/service/PlayerWidgetService.java deleted file mode 100644 index d5141bd37..000000000 --- a/app/src/main/java/de/danoeh/antennapod/service/PlayerWidgetService.java +++ /dev/null @@ -1,244 +0,0 @@ -package de.danoeh.antennapod.service; - -import android.app.PendingIntent; -import android.app.Service; -import android.appwidget.AppWidgetManager; -import android.content.ComponentName; -import android.content.Intent; -import android.content.ServiceConnection; -import android.os.Build; -import android.os.IBinder; -import android.util.Log; -import android.view.KeyEvent; -import android.view.View; -import android.widget.RemoteViews; - -import de.danoeh.antennapod.R; -import de.danoeh.antennapod.activity.MainActivity; -import de.danoeh.antennapod.core.feed.FeedItem; -import de.danoeh.antennapod.core.feed.FeedMedia; -import de.danoeh.antennapod.core.preferences.UserPreferences; -import de.danoeh.antennapod.core.receiver.MediaButtonReceiver; -import de.danoeh.antennapod.core.service.playback.PlaybackService; -import de.danoeh.antennapod.core.service.playback.PlayerStatus; -import de.danoeh.antennapod.core.storage.DBWriter; -import de.danoeh.antennapod.core.util.Converter; -import de.danoeh.antennapod.core.util.playback.Playable; -import de.danoeh.antennapod.fragment.QueueFragment; -import de.danoeh.antennapod.receiver.PlayerWidget; - -/** - * Updates the state of the player widget - */ -public class PlayerWidgetService extends Service { - private static final String TAG = "PlayerWidgetService"; - - private PlaybackService playbackService; - - /** - * Controls write access to playbackservice reference - */ - private final Object psLock = new Object(); - - /** - * True while service is updating the widget - */ - private volatile boolean isUpdating; - - public PlayerWidgetService() { - } - - @Override - public void onCreate() { - super.onCreate(); - Log.d(TAG, "Service created"); - isUpdating = false; - } - - @Override - public void onDestroy() { - super.onDestroy(); - Log.d(TAG, "Service is about to be destroyed"); - if (playbackService != null) { - Playable playable = playbackService.getPlayable(); - if (playable != null && playable instanceof FeedMedia) { - FeedMedia media = (FeedMedia) playable; - if (media.hasAlmostEnded()) { - Log.d(TAG, "smart mark as read"); - FeedItem item = media.getItem(); - DBWriter.markItemPlayed(item, FeedItem.PLAYED, false); - DBWriter.removeQueueItem(this, item, false); - DBWriter.addItemToPlaybackHistory(media); - if (item.getFeed().getPreferences().getCurrentAutoDelete() && - (!item.isTagged(FeedItem.TAG_FAVORITE) || !UserPreferences.shouldFavoriteKeepEpisode())) { - Log.d(TAG, "Delete " + media.toString()); - DBWriter.deleteFeedMediaOfItem(this, media.getId()); - } - } - } - } - - try { - unbindService(mConnection); - } catch (IllegalArgumentException e) { - Log.w(TAG, "IllegalArgumentException when trying to unbind service"); - } - } - - @Override - public IBinder onBind(Intent intent) { - return null; - } - - @Override - public int onStartCommand(Intent intent, int flags, int startId) { - if (!isUpdating) { - if (playbackService == null && PlaybackService.isRunning) { - bindService(new Intent(this, PlaybackService.class), - mConnection, 0); - } else { - startViewUpdaterIfNotRunning(); - } - } else { - Log.d(TAG, "Service was called while updating. Ignoring update request"); - } - return Service.START_NOT_STICKY; - } - - private void updateViews() { - isUpdating = true; - - ComponentName playerWidget = new ComponentName(this, PlayerWidget.class); - AppWidgetManager manager = AppWidgetManager.getInstance(this); - RemoteViews views = new RemoteViews(getPackageName(), - R.layout.player_widget); - PendingIntent startMediaplayer = PendingIntent.getActivity(this, 0, - PlaybackService.getPlayerActivityIntent(this), 0); - - Intent startApp = new Intent(getBaseContext(), MainActivity.class); - startApp.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - startApp.putExtra(MainActivity.EXTRA_FRAGMENT_TAG, QueueFragment.TAG); - PendingIntent startAppPending = PendingIntent.getActivity(getBaseContext(), 0, startApp, PendingIntent.FLAG_UPDATE_CURRENT); - - boolean nothingPlaying = false; - if (playbackService != null) { - final Playable media = playbackService.getPlayable(); - if (media != null) { - PlayerStatus status = playbackService.getStatus(); - views.setOnClickPendingIntent(R.id.layout_left, startMediaplayer); - - views.setTextViewText(R.id.txtvTitle, media.getEpisodeTitle()); - - String progressString = getProgressString(); - if (progressString != null) { - views.setViewVisibility(R.id.txtvProgress, View.VISIBLE); - views.setTextViewText(R.id.txtvProgress, progressString); - } - - if (status == PlayerStatus.PLAYING) { - views.setImageViewResource(R.id.butPlay, R.drawable.ic_pause_white_24dp); - if (Build.VERSION.SDK_INT >= 15) { - views.setContentDescription(R.id.butPlay, getString(R.string.pause_label)); - } - } else { - views.setImageViewResource(R.id.butPlay, R.drawable.ic_play_arrow_white_24dp); - if (Build.VERSION.SDK_INT >= 15) { - views.setContentDescription(R.id.butPlay, getString(R.string.play_label)); - } - } - views.setOnClickPendingIntent(R.id.butPlay, - createMediaButtonIntent()); - } else { - nothingPlaying = true; - } - } else { - nothingPlaying = true; - } - - if (nothingPlaying) { - // start the app if they click anything - views.setOnClickPendingIntent(R.id.layout_left, startAppPending); - views.setOnClickPendingIntent(R.id.butPlay, startAppPending); - views.setViewVisibility(R.id.txtvProgress, View.INVISIBLE); - views.setTextViewText(R.id.txtvTitle, - this.getString(R.string.no_media_playing_label)); - views.setImageViewResource(R.id.butPlay, R.drawable.ic_play_arrow_white_24dp); - } - - manager.updateAppWidget(playerWidget, views); - isUpdating = false; - } - - /** - * Creates an intent which fakes a mediabutton press - */ - private PendingIntent createMediaButtonIntent() { - KeyEvent event = new KeyEvent(KeyEvent.ACTION_DOWN, - KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE); - Intent startingIntent = new Intent( - MediaButtonReceiver.NOTIFY_BUTTON_RECEIVER); - startingIntent.putExtra(Intent.EXTRA_KEY_EVENT, event); - - return PendingIntent.getBroadcast(this, 0, startingIntent, 0); - } - - private String getProgressString() { - int position = playbackService.getCurrentPosition(); - int duration = playbackService.getDuration(); - if (position > 0 && duration > 0) { - return Converter.getDurationStringLong(position) + " / " - + Converter.getDurationStringLong(duration); - } else { - return null; - } - } - - private final ServiceConnection mConnection = new ServiceConnection() { - public void onServiceConnected(ComponentName className, IBinder service) { - Log.d(TAG, "Connection to service established"); - synchronized (psLock) { - if(service instanceof PlaybackService.LocalBinder) { - playbackService = ((PlaybackService.LocalBinder) service).getService(); - startViewUpdaterIfNotRunning(); - } - } - } - - @Override - public void onServiceDisconnected(ComponentName name) { - synchronized (psLock) { - playbackService = null; - Log.d(TAG, "Disconnected from service"); - } - } - - }; - - private void startViewUpdaterIfNotRunning() { - if (!isUpdating) { - ViewUpdater updateThread = new ViewUpdater(this); - updateThread.start(); - } - } - - class ViewUpdater extends Thread { - private static final String THREAD_NAME = "ViewUpdater"; - private final PlayerWidgetService service; - - public ViewUpdater(PlayerWidgetService service) { - super(); - setName(THREAD_NAME); - this.service = service; - - } - - @Override - public void run() { - synchronized (psLock) { - service.updateViews(); - } - } - - } - -} diff --git a/app/src/main/res/layout/about.xml b/app/src/main/res/layout/about.xml index 02e232d9a..42f5e1245 100644 --- a/app/src/main/res/layout/about.xml +++ b/app/src/main/res/layout/about.xml @@ -1,12 +1,12 @@ <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:id="@+id/webvContainer" + android:id="@+id/webViewContainer" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <WebView - android:id="@+id/webvAbout" + android:id="@+id/webViewAbout" android:layout_width="match_parent" android:layout_height="match_parent" /> diff --git a/app/src/main/res/layout/external_player_fragment.xml b/app/src/main/res/layout/external_player_fragment.xml index 0efee08db..dc890807c 100644 --- a/app/src/main/res/layout/external_player_fragment.xml +++ b/app/src/main/res/layout/external_player_fragment.xml @@ -44,6 +44,7 @@ android:layout_centerVertical="true" android:contentDescription="@string/pause_label" android:background="?attr/selectableItemBackground" + android:src="?attr/av_play_big" tools:src="@drawable/ic_play_arrow_white_36dp"/> <TextView diff --git a/app/src/main/res/layout/mediaplayerinfo_activity.xml b/app/src/main/res/layout/mediaplayerinfo_activity.xml index 64738eb45..21c4940b5 100644 --- a/app/src/main/res/layout/mediaplayerinfo_activity.xml +++ b/app/src/main/res/layout/mediaplayerinfo_activity.xml @@ -110,9 +110,9 @@ android:layout_centerHorizontal="true" android:background="?attr/selectableItemBackground" android:contentDescription="@string/pause_label" - android:src="?attr/av_pause" + android:src="?attr/av_play" android:scaleType="fitCenter" - tools:src="@drawable/ic_pause_white_36dp" + tools:src="@drawable/ic_play_arrow_white_24dp" tools:background="@android:color/holo_green_dark" /> <ImageButton diff --git a/app/src/main/res/layout/player_widget.xml b/app/src/main/res/layout/player_widget.xml deleted file mode 100644 index 4c98895a0..000000000 --- a/app/src/main/res/layout/player_widget.xml +++ /dev/null @@ -1,52 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:padding="@dimen/widget_margin" > - - <RelativeLayout - android:layout_width="match_parent" - android:layout_height="match_parent" - android:background="#262C31" > - - <ImageButton - android:id="@+id/butPlay" - android:contentDescription="@string/play_label" - android:layout_width="56dp" - android:layout_height="match_parent" - android:layout_alignParentRight="true" - android:layout_margin="12dp" - android:background="@drawable/borderless_button_dark" - android:src="@drawable/ic_play_arrow_white_24dp" /> - - <LinearLayout - android:id="@+id/layout_left" - android:layout_width="0dp" - android:layout_height="match_parent" - android:layout_alignParentLeft="true" - android:layout_toLeftOf="@id/butPlay" - android:background="@drawable/borderless_button_dark" - android:gravity="center_vertical" - android:orientation="vertical" > - - <TextView - android:id="@+id/txtvTitle" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_margin="8dp" - android:maxLines="1" - android:text="@string/no_media_playing_label" - android:textColor="@color/white" - android:textSize="@dimen/text_size_medium" - android:textStyle="bold" /> - - <TextView - android:id="@+id/txtvProgress" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_margin="8dp" - android:textColor="@color/white" /> - </LinearLayout> - </RelativeLayout> - -</FrameLayout>
\ No newline at end of file diff --git a/app/src/main/res/layout/preference_switch_layout.xml b/app/src/main/res/layout/preference_switch_layout.xml deleted file mode 100644 index 54fa74061..000000000 --- a/app/src/main/res/layout/preference_switch_layout.xml +++ /dev/null @@ -1,9 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<android.support.v7.widget.SwitchCompat - xmlns:android="http://schemas.android.com/apk/res/android" - android:id="@android:id/checkbox" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:background="@null" - android:clickable="false" - android:focusable="false" />
\ No newline at end of file diff --git a/app/src/main/res/menu/queue.xml b/app/src/main/res/menu/queue.xml index a5fe85865..7b82cbef3 100644 --- a/app/src/main/res/menu/queue.xml +++ b/app/src/main/res/menu/queue.xml @@ -90,6 +90,25 @@ android:title="@string/descending"/> </menu> </item> + + <item + android:id="@+id/queue_sort_random" + android:title="@string/random"> + </item> + + <item + android:id="@+id/queue_sort_smart_shuffle" + android:title="@string/smart_shuffle"> + + <menu> + <item + android:id="@+id/queue_sort_smart_shuffle_asc" + android:title="@string/ascending"/> + <item + android:id="@+id/queue_sort_smart_shuffle_desc" + android:title="@string/descending"/> + </menu> + </item> </menu> </item> diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index 8472f7b26..d3b72e17c 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -1,10 +1,14 @@ <?xml version="1.0" encoding="utf-8"?> <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> + + <com.bytehamster.lib.preferencesearch.SearchPreference + android:key="searchPreference" /> + <Preference - android:key="prefScreenInterface" - android:title="@string/user_interface_label" - android:icon="?attr/type_video" /> + android:key="prefScreenInterface" + android:title="@string/user_interface_label" + android:icon="?attr/type_video" /> <Preference android:key="prefScreenPlayback" diff --git a/app/src/main/res/xml/preferences_autodownload.xml b/app/src/main/res/xml/preferences_autodownload.xml index 72716423a..b5e3182f0 100644 --- a/app/src/main/res/xml/preferences_autodownload.xml +++ b/app/src/main/res/xml/preferences_autodownload.xml @@ -1,20 +1,22 @@ <?xml version="1.0" encoding="utf-8"?> <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:app="http://schemas.android.com/apk/res-auto"> + xmlns:app="http://schemas.android.com/apk/res-auto" + xmlns:search="http://schemas.android.com/apk/com.bytehamster.lib.preferencesearch"> <de.danoeh.antennapod.preferences.MasterSwitchPreference android:key="prefEnableAutoDl" android:title="@string/pref_automatic_download_title" + search:summary="@string/pref_automatic_download_sum" android:defaultValue="false"/> - <com.afollestad.materialdialogs.prefs.MaterialListPreference + <ListPreference android:defaultValue="25" android:entries="@array/episode_cache_size_entries" android:key="prefEpisodeCacheSize" android:title="@string/pref_episode_cache_title" android:entryValues="@array/episode_cache_size_values" app:useStockLayout="true"/> - <com.afollestad.materialdialogs.prefs.MaterialListPreference + <ListPreference android:defaultValue="-1" android:entries="@array/episode_cleanup_entries" android:key="prefEpisodeCleanup" @@ -22,17 +24,17 @@ android:summary="@string/pref_episode_cleanup_summary" android:entryValues="@array/episode_cleanup_values" app:useStockLayout="true"/> - <de.danoeh.antennapod.preferences.SwitchCompatPreference + <SwitchPreference android:key="prefEnableAutoDownloadOnBattery" android:title="@string/pref_automatic_download_on_battery_title" android:summary="@string/pref_automatic_download_on_battery_sum" android:defaultValue="true"/> - <de.danoeh.antennapod.preferences.SwitchCompatPreference + <SwitchPreference android:key="prefEnableAutoDownloadOnMobile" android:title="@string/pref_autodl_allow_on_mobile_title" android:summary="@string/pref_autodl_allow_on_mobile_sum" android:defaultValue="false"/> - <de.danoeh.antennapod.preferences.SwitchCompatPreference + <SwitchPreference android:key="prefEnableAutoDownloadWifiFilter" android:title="@string/pref_autodl_wifi_filter_title" android:summary="@string/pref_autodl_wifi_filter_sum"/> diff --git a/app/src/main/res/xml/preferences_flattr.xml b/app/src/main/res/xml/preferences_flattr.xml new file mode 100644 index 000000000..6b4c38a0b --- /dev/null +++ b/app/src/main/res/xml/preferences_flattr.xml @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="utf-8"?> +<PreferenceScreen + xmlns:android="http://schemas.android.com/apk/res/android"> + + <PreferenceScreen + android:key="pref_flattr_authenticate" + android:summary="@string/pref_flattr_auth_sum" + android:title="@string/pref_flattr_auth_title"> + <intent android:action=".activities.FlattrAuthActivity"/> + </PreferenceScreen> + + <Preference + android:key="prefAutoFlattrPrefs" + android:summary="@string/pref_auto_flattr_sum" + android:title="@string/pref_auto_flattr_title"/> + <Preference + android:key="prefRevokeAccess" + android:summary="@string/pref_revokeAccess_sum" + android:title="@string/pref_revokeAccess_title"/> + +</PreferenceScreen> diff --git a/app/src/main/res/xml/preferences_gpodder.xml b/app/src/main/res/xml/preferences_gpodder.xml new file mode 100644 index 000000000..5789f5f84 --- /dev/null +++ b/app/src/main/res/xml/preferences_gpodder.xml @@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="utf-8"?> +<PreferenceScreen + xmlns:android="http://schemas.android.com/apk/res/android"> + + <PreferenceScreen + android:key="pref_gpodnet_authenticate" + android:title="@string/pref_gpodnet_authenticate_title" + android:summary="@string/pref_gpodnet_authenticate_sum"> + <intent android:action=".activity.gpoddernet.GpodnetAuthenticationActivity"/> + </PreferenceScreen> + <Preference + android:key="pref_gpodnet_setlogin_information" + android:title="@string/pref_gpodnet_setlogin_information_title" + android:summary="@string/pref_gpodnet_setlogin_information_sum"/> + <Preference + android:key="pref_gpodnet_sync" + android:title="@string/pref_gpodnet_sync_changes_title" + android:summary="@string/pref_gpodnet_sync_changes_sum"/> + <Preference + android:key="pref_gpodnet_force_full_sync" + android:title="@string/pref_gpodnet_full_sync_title" + android:summary="@string/pref_gpodnet_full_sync_sum"/> + <Preference + android:key="pref_gpodnet_logout" + android:title="@string/pref_gpodnet_logout_title"/> + <Preference + android:key="pref_gpodnet_hostname" + android:title="@string/pref_gpodnet_sethostname_title"/> + <SwitchPreference + android:key="pref_gpodnet_notifications" + android:title="@string/pref_gpodnet_notifications_title" + android:summary="@string/pref_gpodnet_notifications_sum" + android:defaultValue="true"/> + +</PreferenceScreen> diff --git a/app/src/main/res/xml/preferences_integrations.xml b/app/src/main/res/xml/preferences_integrations.xml index 8ce35b596..c0fd299ec 100644 --- a/app/src/main/res/xml/preferences_integrations.xml +++ b/app/src/main/res/xml/preferences_integrations.xml @@ -3,61 +3,14 @@ xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"> - <PreferenceScreen + <Preference android:key="prefFlattrSettings" android:title="@string/flattr_label" - android:summary="@string/flattr_summary"> - <PreferenceScreen - android:key="pref_flattr_authenticate" - android:summary="@string/pref_flattr_auth_sum" - android:title="@string/pref_flattr_auth_title"> - <intent android:action=".activities.FlattrAuthActivity"/> - </PreferenceScreen> + android:summary="@string/flattr_summary" /> - <Preference - android:key="prefAutoFlattrPrefs" - android:summary="@string/pref_auto_flattr_sum" - android:title="@string/pref_auto_flattr_title"/> - <Preference - android:key="prefRevokeAccess" - android:summary="@string/pref_revokeAccess_sum" - android:title="@string/pref_revokeAccess_title"/> - </PreferenceScreen> - - <PreferenceScreen + <Preference android:key="prefGpodderSettings" android:title="@string/gpodnet_main_label" - android:summary="@string/gpodnet_summary"> - - <PreferenceScreen - android:key="pref_gpodnet_authenticate" - android:title="@string/pref_gpodnet_authenticate_title" - android:summary="@string/pref_gpodnet_authenticate_sum"> - <intent android:action=".activity.gpoddernet.GpodnetAuthenticationActivity"/> - </PreferenceScreen> - <Preference - android:key="pref_gpodnet_setlogin_information" - android:title="@string/pref_gpodnet_setlogin_information_title" - android:summary="@string/pref_gpodnet_setlogin_information_sum"/> - <Preference - android:key="pref_gpodnet_sync" - android:title="@string/pref_gpodnet_sync_changes_title" - android:summary="@string/pref_gpodnet_sync_changes_sum"/> - <Preference - android:key="pref_gpodnet_force_full_sync" - android:title="@string/pref_gpodnet_full_sync_title" - android:summary="@string/pref_gpodnet_full_sync_sum"/> - <Preference - android:key="pref_gpodnet_logout" - android:title="@string/pref_gpodnet_logout_title"/> - <Preference - android:key="pref_gpodnet_hostname" - android:title="@string/pref_gpodnet_sethostname_title"/> - <de.danoeh.antennapod.preferences.SwitchCompatPreference - android:key="pref_gpodnet_notifications" - android:title="@string/pref_gpodnet_notifications_title" - android:summary="@string/pref_gpodnet_notifications_sum" - android:defaultValue="true"/> - </PreferenceScreen> + android:summary="@string/gpodnet_summary" /> </PreferenceScreen> diff --git a/app/src/main/res/xml/preferences_network.xml b/app/src/main/res/xml/preferences_network.xml index 77792bf88..0ab8e5866 100644 --- a/app/src/main/res/xml/preferences_network.xml +++ b/app/src/main/res/xml/preferences_network.xml @@ -1,13 +1,14 @@ <?xml version="1.0" encoding="utf-8"?> <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:app="http://schemas.android.com/apk/res-auto"> + xmlns:app="http://schemas.android.com/apk/res-auto" + xmlns:search="http://schemas.android.com/apk/com.bytehamster.lib.preferencesearch"> <PreferenceCategory android:title="@string/automation"> <Preference android:key="prefAutoUpdateIntervall" android:summary="@string/pref_autoUpdateIntervallOrTime_sum" android:title="@string/pref_autoUpdateIntervallOrTime_title"/> - <de.danoeh.antennapod.preferences.SwitchCompatPreference + <SwitchPreference android:defaultValue="false" android:enabled="true" android:key="prefMobileUpdate" @@ -16,17 +17,18 @@ <Preference android:summary="@string/pref_automatic_download_sum" android:key="prefAutoDownloadSettings" - android:title="@string/pref_automatic_download_title" /> + android:title="@string/pref_automatic_download_title" + search:ignore="true" /> </PreferenceCategory> <PreferenceCategory android:title="@string/download_pref_details"> - <com.afollestad.materialdialogs.prefs.MaterialEditTextPreference + <EditTextPreference android:defaultValue="4" android:inputType="number" android:key="prefParallelDownloads" android:title="@string/pref_parallel_downloads_title" app:useStockLayout="true"/> - <de.danoeh.antennapod.preferences.SwitchCompatPreference + <SwitchPreference android:defaultValue="true" android:enabled="true" android:key="prefShowDownloadReport" diff --git a/app/src/main/res/xml/preferences_playback.xml b/app/src/main/res/xml/preferences_playback.xml index 2562016b2..9182df600 100644 --- a/app/src/main/res/xml/preferences_playback.xml +++ b/app/src/main/res/xml/preferences_playback.xml @@ -4,39 +4,39 @@ xmlns:app="http://schemas.android.com/apk/res-auto"> <PreferenceCategory android:title="@string/interruptions"> - <de.danoeh.antennapod.preferences.SwitchCompatPreference + <SwitchPreference android:defaultValue="true" android:enabled="true" android:key="prefPauseOnHeadsetDisconnect" android:summary="@string/pref_pauseOnDisconnect_sum" android:title="@string/pref_pauseOnHeadsetDisconnect_title"/> - <de.danoeh.antennapod.preferences.SwitchCompatPreference + <SwitchPreference android:defaultValue="true" android:enabled="true" android:dependency="prefPauseOnHeadsetDisconnect" android:key="prefUnpauseOnHeadsetReconnect" android:summary="@string/pref_unpauseOnHeadsetReconnect_sum" android:title="@string/pref_unpauseOnHeadsetReconnect_title"/> - <de.danoeh.antennapod.preferences.SwitchCompatPreference + <SwitchPreference android:defaultValue="false" android:enabled="true" android:dependency="prefPauseOnHeadsetDisconnect" android:key="prefUnpauseOnBluetoothReconnect" android:summary="@string/pref_unpauseOnBluetoothReconnect_sum" android:title="@string/pref_unpauseOnBluetoothReconnect_title"/> - <de.danoeh.antennapod.preferences.SwitchCompatPreference + <SwitchPreference android:defaultValue="false" android:enabled="true" android:key="prefPauseForFocusLoss" android:summary="@string/pref_pausePlaybackForFocusLoss_sum" android:title="@string/pref_pausePlaybackForFocusLoss_title"/> - <de.danoeh.antennapod.preferences.SwitchCompatPreference + <SwitchPreference android:defaultValue="true" android:enabled="true" android:key="prefResumeAfterCall" android:summary="@string/pref_resumeAfterCall_sum" android:title="@string/pref_resumeAfterCall_title"/> - <com.afollestad.materialdialogs.prefs.MaterialListPreference + <ListPreference android:defaultValue="stop" android:entries="@array/video_background_behavior_options" android:entryValues="@array/video_background_behavior_values" @@ -47,13 +47,13 @@ </PreferenceCategory> <PreferenceCategory android:title="@string/buttons"> - <de.danoeh.antennapod.preferences.SwitchCompatPreference + <SwitchPreference android:defaultValue="false" android:enabled="true" android:key="prefHardwareForwardButtonSkips" android:summary="@string/pref_hardwareForwardButtonSkips_sum" android:title="@string/pref_hardwareForwardButtonSkips_title"/> - <de.danoeh.antennapod.preferences.SwitchCompatPreference + <SwitchPreference android:defaultValue="false" android:enabled="true" android:key="prefHardwarePreviousButtonRestarts" @@ -74,25 +74,25 @@ </PreferenceCategory> <PreferenceCategory android:title="@string/queue_label"> - <de.danoeh.antennapod.preferences.SwitchCompatPreference + <SwitchPreference android:defaultValue="true" android:enabled="true" android:key="prefEnqueueDownloaded" android:summary="@string/pref_enqueue_downloaded_summary" android:title="@string/pref_enqueue_downloaded_title" /> - <de.danoeh.antennapod.preferences.SwitchCompatPreference + <SwitchPreference android:defaultValue="false" android:enabled="true" android:key="prefQueueAddToFront" android:summary="@string/pref_queueAddToFront_sum" android:title="@string/pref_queueAddToFront_title"/> - <de.danoeh.antennapod.preferences.SwitchCompatPreference + <SwitchPreference android:defaultValue="true" android:enabled="true" android:key="prefFollowQueue" android:summary="@string/pref_followQueue_sum" android:title="@string/pref_followQueue_title"/> - <com.afollestad.materialdialogs.prefs.MaterialListPreference + <ListPreference android:defaultValue="30" android:entries="@array/smart_mark_as_played_values" android:entryValues="@array/smart_mark_as_played_values" @@ -100,7 +100,7 @@ android:summary="@string/pref_smart_mark_as_played_sum" android:title="@string/pref_smart_mark_as_played_title" app:useStockLayout="true"/> - <de.danoeh.antennapod.preferences.SwitchCompatPreference + <SwitchPreference android:defaultValue="true" android:enabled="true" android:key="prefSkipKeepsEpisode" @@ -109,7 +109,7 @@ </PreferenceCategory> <PreferenceCategory android:title="@string/media_player"> - <com.afollestad.materialdialogs.prefs.MaterialListPreference + <ListPreference android:defaultValue="sonic" android:entries="@array/media_player_options" android:key="prefMediaPlayer" @@ -120,7 +120,7 @@ </PreferenceCategory> <PreferenceCategory android:title="@string/experimental_pref"> - <de.danoeh.antennapod.preferences.SwitchCompatPreference + <SwitchPreference android:defaultValue="false" android:enabled="true" android:key="prefCast" diff --git a/app/src/main/res/xml/preferences_storage.xml b/app/src/main/res/xml/preferences_storage.xml index 091b02ced..fe48cc99c 100644 --- a/app/src/main/res/xml/preferences_storage.xml +++ b/app/src/main/res/xml/preferences_storage.xml @@ -13,13 +13,13 @@ android:key="prefImageCacheSize" android:summary="@string/pref_image_cache_size_sum" android:defaultValue="100"/> - <de.danoeh.antennapod.preferences.SwitchCompatPreference + <SwitchPreference android:defaultValue="false" android:enabled="true" android:key="prefAutoDelete" android:summary="@string/pref_auto_delete_sum" android:title="@string/pref_auto_delete_title"/> - <de.danoeh.antennapod.preferences.SwitchCompatPreference + <SwitchPreference android:defaultValue="true" android:enabled="true" android:key="prefFavoriteKeepsEpisode" diff --git a/app/src/main/res/xml/preferences_user_interface.xml b/app/src/main/res/xml/preferences_user_interface.xml index 7ffa1b00f..da694b844 100644 --- a/app/src/main/res/xml/preferences_user_interface.xml +++ b/app/src/main/res/xml/preferences_user_interface.xml @@ -4,7 +4,7 @@ xmlns:app="http://schemas.android.com/apk/res-auto"> <PreferenceCategory android:title="@string/appearance"> - <com.afollestad.materialdialogs.prefs.MaterialListPreference + <ListPreference android:entryValues="@array/theme_values" android:entries="@array/theme_options" android:title="@string/pref_set_theme_title" @@ -16,7 +16,7 @@ android:key="prefHiddenDrawerItems" android:summary="@string/pref_nav_drawer_items_sum" android:title="@string/pref_nav_drawer_items_title"/> - <com.afollestad.materialdialogs.prefs.MaterialListPreference + <ListPreference android:entryValues="@array/nav_drawer_feed_order_values" android:entries="@array/nav_drawer_feed_order_options" android:title="@string/pref_nav_drawer_feed_order_title" @@ -24,7 +24,7 @@ android:summary="@string/pref_nav_drawer_feed_order_sum" android:defaultValue="0" app:useStockLayout="true"/> - <com.afollestad.materialdialogs.prefs.MaterialListPreference + <ListPreference android:entryValues="@array/nav_drawer_feed_counter_values" android:entries="@array/nav_drawer_feed_counter_options" android:title="@string/pref_nav_drawer_feed_counter_title" @@ -34,13 +34,13 @@ app:useStockLayout="true"/> </PreferenceCategory> <PreferenceCategory android:title="@string/external_elements"> - <de.danoeh.antennapod.preferences.SwitchCompatPreference + <SwitchPreference android:defaultValue="false" android:enabled="true" android:key="prefExpandNotify" android:summary="@string/pref_expandNotify_sum" android:title="@string/pref_expandNotify_title"/> - <de.danoeh.antennapod.preferences.SwitchCompatPreference + <SwitchPreference android:defaultValue="true" android:enabled="true" android:key="prefPersistNotify" @@ -50,7 +50,7 @@ android:key="prefCompactNotificationButtons" android:summary="@string/pref_compact_notification_buttons_sum" android:title="@string/pref_compact_notification_buttons_title"/> - <de.danoeh.antennapod.preferences.SwitchCompatPreference + <SwitchPreference android:defaultValue="true" android:enabled="true" android:key="prefLockscreenBackground" |