Bump to minimum SDK version 19 (Android 4.4)

This commit is contained in:
ByteHamster 2021-11-02 21:26:13 +01:00
parent b00e14545d
commit 3f81e22eed
10 changed files with 54 additions and 100 deletions

View File

@ -73,7 +73,6 @@
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.APP_MUSIC" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<meta-data

View File

@ -6,7 +6,6 @@ import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.LightingColorFilter;
import android.os.Build;
import android.os.Bundle;
import android.text.Spannable;
import android.text.SpannableString;
@ -451,8 +450,7 @@ public class OnlineFeedViewActivity extends AppCompatActivity {
final int MAX_LINES_COLLAPSED = 10;
description.setMaxLines(MAX_LINES_COLLAPSED);
description.setOnClickListener(v -> {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN
&& description.getMaxLines() > MAX_LINES_COLLAPSED) {
if (description.getMaxLines() > MAX_LINES_COLLAPSED) {
description.setMaxLines(MAX_LINES_COLLAPSED);
} else {
description.setMaxLines(2000);

View File

@ -1,6 +1,5 @@
package de.danoeh.antennapod.dialog;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
@ -118,9 +117,7 @@ public class VariableSpeedDialog extends BottomSheetDialogFragment {
@NonNull
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
Chip chip = new Chip(getContext());
if (Build.VERSION.SDK_INT >= 17) {
chip.setTextAlignment(View.TEXT_ALIGNMENT_CENTER);
}
chip.setTextAlignment(View.TEXT_ALIGNMENT_CENTER);
return new ViewHolder(chip);
}

View File

@ -195,18 +195,10 @@ public class ImportExportPreferencesFragment extends PreferenceFragmentCompat {
// add a button
builder.setNegativeButton(R.string.no, null);
builder.setPositiveButton(R.string.confirm_label, (dialog, which) -> {
if (Build.VERSION.SDK_INT >= 19) {
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
intent.setType("*/*");
restoreDatabaseLauncher.launch(intent);
} else {
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("*/*");
restoreDatabaseLauncher.launch(Intent.createChooser(intent,
getString(R.string.import_select_file)));
}
}
);
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
intent.setType("*/*");
restoreDatabaseLauncher.launch(intent);
});
// create and show the alert dialog
builder.show();
@ -318,20 +310,18 @@ public class ImportExportPreferencesFragment extends PreferenceFragmentCompat {
private void openExportPathPicker(String contentType, String title,
final ActivityResultLauncher<Intent> result, ExportWriter writer) {
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN_MR2) {
Intent intentPickAction = new Intent(Intent.ACTION_CREATE_DOCUMENT)
.addCategory(Intent.CATEGORY_OPENABLE)
.setType(contentType)
.putExtra(Intent.EXTRA_TITLE, title);
Intent intentPickAction = new Intent(Intent.ACTION_CREATE_DOCUMENT)
.addCategory(Intent.CATEGORY_OPENABLE)
.setType(contentType)
.putExtra(Intent.EXTRA_TITLE, title);
// Creates an implicit intent to launch a file manager which lets
// the user choose a specific directory to export to.
try {
result.launch(intentPickAction);
return;
} catch (ActivityNotFoundException e) {
Log.e(TAG, "No activity found. Should never happen...");
}
// Creates an implicit intent to launch a file manager which lets
// the user choose a specific directory to export to.
try {
result.launch(intentPickAction);
return;
} catch (ActivityNotFoundException e) {
Log.e(TAG, "No activity found. Should never happen...");
}
// If we are using a SDK lower than API 21 or the implicit intent failed

View File

@ -2,7 +2,7 @@ android {
compileSdkVersion 31
defaultConfig {
minSdkVersion 16
minSdkVersion 19
targetSdkVersion 30
multiDexEnabled false

View File

@ -815,9 +815,8 @@ public class PlaybackService extends MediaBrowserServiceCompat {
taskManager.startChapterLoader(newInfo.playable);
break;
case PAUSED:
if ((UserPreferences.isPersistNotify() || isCasting) &&
android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
// do not remove notification on pause based on user pref and whether android version supports expanded notifications
if (UserPreferences.isPersistNotify() || isCasting) {
// do not remove notification on pause based on user pref
// Change [Play] button to [Pause]
updateNotificationAndMediaSession(newInfo.playable);
} else if (!UserPreferences.isPersistNotify() && !isCasting) {
@ -1967,11 +1966,8 @@ public class PlaybackService extends MediaBrowserServiceCompat {
PlaybackService.this.updateNotificationAndMediaSession(info.playable);
} else {
PlayerStatus status = info.playerStatus;
if ((status == PlayerStatus.PLAYING ||
status == PlayerStatus.SEEKING ||
status == PlayerStatus.PREPARING ||
UserPreferences.isPersistNotify()) &&
android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
if (status == PlayerStatus.PLAYING || status == PlayerStatus.SEEKING
|| status == PlayerStatus.PREPARING || UserPreferences.isPersistNotify()) {
PlaybackService.this.updateNotificationAndMediaSession(info.playable);
} else if (!UserPreferences.isPersistNotify()) {
stateManager.stopForeground(true);

View File

@ -1,7 +1,6 @@
package de.danoeh.antennapod.core.util;
import android.app.Activity;
import android.os.Build;
import android.os.StatFs;
import android.util.Log;
@ -63,29 +62,15 @@ public class StorageUtils {
*/
public static long getFreeSpaceAvailable(String path) {
StatFs stat = new StatFs(path);
long availableBlocks;
long blockSize;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
availableBlocks = stat.getAvailableBlocksLong();
blockSize = stat.getBlockSizeLong();
} else {
availableBlocks = stat.getAvailableBlocks();
blockSize = stat.getBlockSize();
}
long availableBlocks = stat.getAvailableBlocksLong();
long blockSize = stat.getBlockSizeLong();
return availableBlocks * blockSize;
}
public static long getTotalSpaceAvailable(String path) {
StatFs stat = new StatFs(path);
long blockCount;
long blockSize;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
blockCount = stat.getBlockCountLong();
blockSize = stat.getBlockSizeLong();
} else {
blockCount = stat.getBlockCount();
blockSize = stat.getBlockSize();
}
long blockCount = stat.getBlockCountLong();
long blockSize = stat.getBlockSizeLong();
return blockCount * blockSize;
}
}

View File

@ -69,9 +69,6 @@ public abstract class WidgetUpdater {
if (!PlayerWidget.isEnabled(context) || widgetState == null) {
return;
}
ComponentName playerWidget = new ComponentName(context, PlayerWidget.class);
AppWidgetManager manager = AppWidgetManager.getInstance(context);
int[] widgetIds = manager.getAppWidgetIds(playerWidget);
PendingIntent startMediaPlayer;
if (widgetState.media != null && widgetState.media.getMediaType() == MediaType.VIDEO
@ -158,36 +155,36 @@ public abstract class WidgetUpdater {
views.setImageViewResource(R.id.butPlayExtended, R.drawable.ic_widget_play);
}
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN) {
for (int id : widgetIds) {
Bundle options = manager.getAppWidgetOptions(id);
SharedPreferences prefs = context.getSharedPreferences(PlayerWidget.PREFS_NAME, Context.MODE_PRIVATE);
int minWidth = options.getInt(AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH);
int columns = getCellsForSize(minWidth);
if (columns < 3) {
views.setViewVisibility(R.id.layout_center, View.INVISIBLE);
} else {
views.setViewVisibility(R.id.layout_center, View.VISIBLE);
}
boolean showRewind = prefs.getBoolean(PlayerWidget.KEY_WIDGET_REWIND + id, false);
boolean showFastForward = prefs.getBoolean(PlayerWidget.KEY_WIDGET_FAST_FORWARD + id, false);
boolean showSkip = prefs.getBoolean(PlayerWidget.KEY_WIDGET_SKIP + id, false);
ComponentName playerWidget = new ComponentName(context, PlayerWidget.class);
AppWidgetManager manager = AppWidgetManager.getInstance(context);
int[] widgetIds = manager.getAppWidgetIds(playerWidget);
if (showRewind || showSkip || showFastForward) {
views.setInt(R.id.extendedButtonsContainer, "setVisibility", View.VISIBLE);
views.setInt(R.id.butPlay, "setVisibility", View.GONE);
views.setInt(R.id.butRew, "setVisibility", showRewind ? View.VISIBLE : View.GONE);
views.setInt(R.id.butFastForward, "setVisibility", showFastForward ? View.VISIBLE : View.GONE);
views.setInt(R.id.butSkip, "setVisibility", showSkip ? View.VISIBLE : View.GONE);
}
int backgroundColor = prefs.getInt(PlayerWidget.KEY_WIDGET_COLOR + id, PlayerWidget.DEFAULT_COLOR);
views.setInt(R.id.widgetLayout, "setBackgroundColor", backgroundColor);
manager.updateAppWidget(id, views);
for (int id : widgetIds) {
Bundle options = manager.getAppWidgetOptions(id);
SharedPreferences prefs = context.getSharedPreferences(PlayerWidget.PREFS_NAME, Context.MODE_PRIVATE);
int minWidth = options.getInt(AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH);
int columns = getCellsForSize(minWidth);
if (columns < 3) {
views.setViewVisibility(R.id.layout_center, View.INVISIBLE);
} else {
views.setViewVisibility(R.id.layout_center, View.VISIBLE);
}
} else {
manager.updateAppWidget(playerWidget, views);
boolean showRewind = prefs.getBoolean(PlayerWidget.KEY_WIDGET_REWIND + id, false);
boolean showFastForward = prefs.getBoolean(PlayerWidget.KEY_WIDGET_FAST_FORWARD + id, false);
boolean showSkip = prefs.getBoolean(PlayerWidget.KEY_WIDGET_SKIP + id, false);
if (showRewind || showSkip || showFastForward) {
views.setInt(R.id.extendedButtonsContainer, "setVisibility", View.VISIBLE);
views.setInt(R.id.butPlay, "setVisibility", View.GONE);
views.setInt(R.id.butRew, "setVisibility", showRewind ? View.VISIBLE : View.GONE);
views.setInt(R.id.butFastForward, "setVisibility", showFastForward ? View.VISIBLE : View.GONE);
views.setInt(R.id.butSkip, "setVisibility", showSkip ? View.VISIBLE : View.GONE);
}
int backgroundColor = prefs.getInt(PlayerWidget.KEY_WIDGET_COLOR + id, PlayerWidget.DEFAULT_COLOR);
views.setInt(R.id.widgetLayout, "setBackgroundColor", backgroundColor);
manager.updateAppWidget(id, views);
}
}

View File

@ -19,7 +19,6 @@
android:layout_width="@android:dimen/app_icon_size"
android:layout_height="match_parent"
android:contentDescription="@string/play_label"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_margin="12dp"
android:background="?android:attr/selectableItemBackground"
@ -31,9 +30,7 @@
android:id="@+id/layout_left"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_toLeftOf="@id/butPlay"
android:layout_toStartOf="@id/butPlay"
android:background="@android:color/transparent"
android:gravity="fill_horizontal"
@ -97,7 +94,6 @@
android:layout_height="36dp"
android:background="?android:attr/selectableItemBackground"
android:contentDescription="@string/rewind_label"
android:layout_marginRight="2dp"
android:layout_marginEnd="2dp"
android:scaleType="fitXY"
android:src="@drawable/ic_widget_fast_rewind" />
@ -108,7 +104,6 @@
android:layout_height="36dp"
android:background="?android:attr/selectableItemBackground"
android:contentDescription="@string/play_label"
android:layout_marginRight="2dp"
android:layout_marginEnd="2dp"
android:scaleType="fitXY"
android:src="@drawable/ic_widget_play" />
@ -119,7 +114,6 @@
android:layout_height="36dp"
android:background="?android:attr/selectableItemBackground"
android:contentDescription="@string/fast_forward_label"
android:layout_marginRight="2dp"
android:layout_marginEnd="2dp"
android:scaleType="fitXY"
android:src="@drawable/ic_widget_fast_forward" />
@ -130,7 +124,6 @@
android:layout_height="36dp"
android:background="?android:attr/selectableItemBackground"
android:contentDescription="@string/skip_episode_label"
android:layout_marginRight="2dp"
android:layout_marginEnd="2dp"
android:scaleType="fitXY"
android:src="@drawable/ic_widget_skip" />

View File

@ -597,7 +597,6 @@
<string name="export_success_title">Export successful</string>
<string name="export_success_sum">The exported file was written to:\n\n%1$s</string>
<string name="opml_import_ask_read_permission">Access to external storage is required to read the OPML file</string>
<string name="import_select_file">Select file to import</string>
<string name="successful_import_label">Import successful</string>
<string name="import_ok">Please press OK to restart AntennaPod</string>
<string name="import_no_downgrade">This database was exported with a newer version of AntennaPod. Your current installation does not yet know how to handle this file.</string>