Merge pull request #3719 from ByteHamster/removed-unused-code

Removed unused code
This commit is contained in:
H. Lehmann 2020-01-09 20:56:11 +01:00 committed by GitHub
commit 5975f579d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 10 additions and 373 deletions

View File

@ -368,7 +368,6 @@ public class DBReaderTest {
@Test
public void testGetFeedItemlistCheckChaptersFalse() throws Exception {
Context context = InstrumentationRegistry.getTargetContext();
List<Feed> feeds = DBTestUtils.saveFeedlist(10, 10, false, false, 0);
for (Feed feed : feeds) {
for (FeedItem item : feed.getItems()) {

View File

@ -98,15 +98,6 @@ public class UITestUtils {
return String.format("%s/files/%d", server.getBaseUrl(), id);
}
private File newBitmapFile(String name) throws IOException {
File imgFile = new File(destDir, name);
Bitmap bitmap = Bitmap.createBitmap(128, 128, Bitmap.Config.ARGB_8888);
FileOutputStream out = new FileOutputStream(imgFile);
bitmap.compress(Bitmap.CompressFormat.PNG, 1, out);
out.close();
return imgFile;
}
private File newMediaFile(String name) throws IOException {
File mediaFile = new File(hostedMediaDir, name);
if (mediaFile.exists()) {

View File

@ -33,19 +33,6 @@ public class UserInterfacePreferencesFragment extends PreferenceFragmentCompat {
}
private void setupInterfaceScreen() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
// disable expanded notification option on unsupported android versions
findPreference(PREF_EXPANDED_NOTIFICATION).setEnabled(false);
findPreference(PREF_EXPANDED_NOTIFICATION).setOnPreferenceClickListener(
preference -> {
Toast toast = Toast.makeText(getActivity(),
R.string.pref_expand_notify_unsupport_toast, Toast.LENGTH_SHORT);
toast.show();
return true;
}
);
}
findPreference(UserPreferences.PREF_THEME)
.setOnPreferenceChangeListener(
(preference, newValue) -> {

View File

@ -43,7 +43,7 @@
android:textStyle="bold"
android:textColor="@color/status_progress"
android:textSize="24sp"
android:background="@drawable/borderless_button_dark"/>
android:background="?android:attr/selectableItemBackground"/>
<Button
android:id="@+id/butIncSpeed"
@ -57,7 +57,7 @@
android:textStyle="bold"
android:textColor="@color/status_progress"
android:textSize="24sp"
android:background="@drawable/borderless_button_dark"/>
android:background="?android:attr/selectableItemBackground"/>
<SeekBar
android:id="@+id/playback_speed"

View File

@ -17,7 +17,7 @@
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:contentDescription="@string/mr_controller_play"
android:background="?attr/selectableItemBackgroundBorderless"/>
android:background="?android:attr/selectableItemBackground"/>
<LinearLayout android:id="@+id/mrc_control_title_container"
android:orientation="vertical"

View File

@ -159,14 +159,10 @@ public class PlayerWidgetJobService extends SafeJobIntentService {
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));
}
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.setContentDescription(R.id.butPlay, getString(R.string.play_label));
}
views.setOnClickPendingIntent(R.id.butPlay, createMediaButtonIntent());
} else {

View File

@ -25,10 +25,11 @@ import de.danoeh.antennapod.core.preferences.UserPreferences;
import de.danoeh.antennapod.core.receiver.MediaButtonReceiver;
import de.danoeh.antennapod.core.util.Converter;
import de.danoeh.antennapod.core.feed.util.ImageResourceUtils;
import de.danoeh.antennapod.core.util.IntList;
import de.danoeh.antennapod.core.util.TimeSpeedConverter;
import de.danoeh.antennapod.core.util.gui.NotificationUtils;
import de.danoeh.antennapod.core.util.playback.Playable;
import java.util.ArrayList;
import org.apache.commons.lang3.ArrayUtils;
public class PlaybackServiceNotificationBuilder {
private static final String TAG = "PlaybackSrvNotification";
@ -151,7 +152,7 @@ public class PlaybackServiceNotificationBuilder {
private void addActions(NotificationCompat.Builder notification, MediaSessionCompat.Token mediaSessionToken,
PlayerStatus playerStatus, boolean isCasting) {
IntList compactActionList = new IntList();
ArrayList<Integer> compactActionList = new ArrayList<>();
int numActions = 0; // we start and 0 and then increment by 1 for each call to addAction
@ -218,7 +219,7 @@ public class PlaybackServiceNotificationBuilder {
KeyEvent.KEYCODE_MEDIA_STOP, numActions);
notification.setStyle(new androidx.media.app.NotificationCompat.MediaStyle()
.setMediaSession(mediaSessionToken)
.setShowActionsInCompactView(compactActionList.toArray())
.setShowActionsInCompactView(ArrayUtils.toPrimitive(compactActionList.toArray(new Integer[0])))
.setShowCancelButton(true)
.setCancelButtonIntent(stopButtonPendingIntent));
}

View File

@ -507,17 +507,6 @@ public final class DBReader {
}
}
/**
* Loads the download log for a particular feed from the database.
*
* @param feed Feed for which the download log is loaded
* @return A list with DownloadStatus objects that represent the feed's download log,
* newest events first.
*/
public static List<DownloadStatus> getFeedDownloadLog(Feed feed) {
return getFeedDownloadLog(feed.getId());
}
/**
* Loads the download log for a particular feed from the database.
*

View File

@ -379,18 +379,6 @@ public final class DBTasks {
return result;
}
/**
* Loads the queue from the database and checks if the specified FeedItem is in the queue.
* This method should NOT be executed in the GUI thread.
*
* @param context Used for accessing the DB.
* @param feedItemId ID of the FeedItem
*/
public static boolean isInQueue(Context context, final long feedItemId) {
LongList queue = DBReader.getQueueIDList();
return queue.contains(feedItemId);
}
private static Feed searchFeedByIdentifyingValueOrID(PodDBAdapter adapter,
Feed feed) {
if (feed.getId() != 0) {

View File

@ -904,49 +904,6 @@ public class PodDBAdapter {
null, null);
}
/**
* Returns a cursor for a DB query in the FeedImages table for given IDs.
*
* @param imageIds IDs of the images
* @return The cursor of the query
*/
public final Cursor getImageCursor(String... imageIds) {
int length = imageIds.length;
if (length > IN_OPERATOR_MAXIMUM) {
Log.w(TAG, "Length of id array is larger than "
+ IN_OPERATOR_MAXIMUM + ". Creating multiple cursors");
int numCursors = (int) (((double) length) / (IN_OPERATOR_MAXIMUM)) + 1;
Cursor[] cursors = new Cursor[numCursors];
for (int i = 0; i < numCursors; i++) {
int neededLength;
String[] parts;
final int elementsLeft = length - i * IN_OPERATOR_MAXIMUM;
if (elementsLeft >= IN_OPERATOR_MAXIMUM) {
neededLength = IN_OPERATOR_MAXIMUM;
parts = Arrays.copyOfRange(imageIds, i
* IN_OPERATOR_MAXIMUM, (i + 1)
* IN_OPERATOR_MAXIMUM);
} else {
neededLength = elementsLeft;
parts = Arrays.copyOfRange(imageIds, i
* IN_OPERATOR_MAXIMUM, (i * IN_OPERATOR_MAXIMUM)
+ neededLength);
}
cursors[i] = db.rawQuery("SELECT * FROM "
+ TABLE_NAME_FEED_IMAGES + " WHERE " + KEY_ID + " IN "
+ buildInOperator(neededLength), parts);
}
Cursor result = new MergeCursor(cursors);
result.moveToFirst();
return result;
} else {
return db.query(TABLE_NAME_FEED_IMAGES, null, KEY_ID + " IN "
+ buildInOperator(length), imageIds, null, null, null);
}
}
public final Cursor getSimpleChaptersOfFeedItemCursor(final FeedItem item) {
return db.query(TABLE_NAME_SIMPLECHAPTERS, null, KEY_FEEDITEM
+ "=?", new String[]{String.valueOf(item.getId())}, null,

View File

@ -1,240 +0,0 @@
package de.danoeh.antennapod.core.util;
import java.util.Arrays;
/**
* Fast and memory efficient int list
*/
public final class IntList {
private int[] values;
private int size;
/**
* Constructs an empty instance with a default initial capacity.
*/
public IntList() {
this(4);
}
/**
* Constructs an empty instance.
*
* @param initialCapacity {@code >= 0;} initial capacity of the list
*/
private IntList(int initialCapacity) {
if(initialCapacity < 0) {
throw new IllegalArgumentException("initial capacity must be 0 or higher");
}
values = new int[initialCapacity];
size = 0;
}
@Override
public int hashCode() {
int hashCode = 1;
for (int i = 0; i < size; i++) {
int value = values[i];
hashCode = 31 * hashCode + value;
}
return hashCode;
}
@Override
public boolean equals(Object other) {
if (other == this) {
return true;
}
if (! (other instanceof IntList)) {
return false;
}
IntList otherList = (IntList) other;
if (size != otherList.size) {
return false;
}
for (int i = 0; i < size; i++) {
if (values[i] != otherList.values[i]) {
return false;
}
}
return true;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder(size * 5 + 10);
sb.append("IntList{");
for (int i = 0; i < size; i++) {
if (i != 0) {
sb.append(", ");
}
sb.append(values[i]);
}
sb.append("}");
return sb.toString();
}
/**
* Gets the number of elements in this list.
*/
public int size() {
return size;
}
/**
* Gets the indicated value.
*
* @param n {@code >= 0, < size();} which element
* @return the indicated element's value
*/
public int get(int n) {
if (n >= size) {
throw new IndexOutOfBoundsException("n >= size()");
} else if(n < 0) {
throw new IndexOutOfBoundsException("n < 0");
}
return values[n];
}
/**
* Sets the value at the given index.
*
* @param index the index at which to put the specified object.
* @param value the object to add.
* @return the previous element at the index.
*/
public int set(int index, int value) {
if (index >= size) {
throw new IndexOutOfBoundsException("n >= size()");
} else if(index < 0) {
throw new IndexOutOfBoundsException("n < 0");
}
int result = values[index];
values[index] = value;
return result;
}
/**
* Adds an element to the end of the list. This will increase the
* list's capacity if necessary.
*
* @param value the value to add
*/
public void add(int value) {
growIfNeeded();
values[size++] = value;
}
/**
* Inserts element into specified index, moving elements at and above
* that index up one. May not be used to insert at an index beyond the
* current size (that is, insertion as a last element is legal but
* no further).
*
* @param n {@code >= 0, <=size();} index of where to insert
* @param value value to insert
*/
public void insert(int n, int value) {
if (n > size) {
throw new IndexOutOfBoundsException("n > size()");
} else if(n < 0) {
throw new IndexOutOfBoundsException("n < 0");
}
growIfNeeded();
System.arraycopy (values, n, values, n+1, size - n);
values[n] = value;
size++;
}
/**
* Removes value from this list.
*
* @param value value to remove
* return {@code true} if the value was removed, {@code false} otherwise
*/
public boolean remove(int value) {
for (int i = 0; i < size; i++) {
if (values[i] == value) {
size--;
System.arraycopy(values, i+1, values, i, size-i);
return true;
}
}
return false;
}
/**
* Removes an element at a given index, shifting elements at greater
* indicies down one.
*
* @param index index of element to remove
*/
public void removeIndex(int index) {
if (index >= size) {
throw new IndexOutOfBoundsException("n >= size()");
} else if(index < 0) {
throw new IndexOutOfBoundsException("n < 0");
}
size--;
System.arraycopy (values, index + 1, values, index, size - index);
}
/**
* Increases size of array if needed
*/
private void growIfNeeded() {
if (size == values.length) {
// Resize.
int[] newArray = new int[size * 3 / 2 + 10];
System.arraycopy(values, 0, newArray, 0, size);
values = newArray;
}
}
/**
* Returns the index of the given value, or -1 if the value does not
* appear in the list.
*
* @param value value to find
* @return index of value or -1
*/
private int indexOf(int value) {
for (int i = 0; i < size; i++) {
if (values[i] == value) {
return i;
}
}
return -1;
}
/**
* Removes all values from this list.
*/
public void clear() {
values = new int[4];
size = 0;
}
/**
* Returns true if the given value is contained in the list
*
* @param value value to look for
* @return {@code true} if this list contains {@code value}, {@code false} otherwise
*/
public boolean contains(int value) {
return indexOf(value) >= 0;
}
/**
* Returns an array with a copy of this list's values
*
* @return array with a copy of this list's values
*/
public int[] toArray() {
return Arrays.copyOf(values, size);
}
}

View File

@ -1,18 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<shape android:shape="rectangle">
<solid android:color="@color/selection_background_color_dark" />
</shape>
</item>
<item android:state_focused="true">
<shape android:shape="rectangle">
<solid android:color="@color/selection_background_color_dark" />
</shape>
</item>
<item>
<shape android:shape="rectangle">
<solid android:color="@android:color/transparent" />
</shape>
</item>
</selector>

View File

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="selection_background_color_dark">#484B4D</color>
</resources>

View File

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AntennaPod.TextView.Heading" parent="@android:style/TextAppearance.Medium">
<item name="android:textSize">@dimen/text_size_large</item>
<item name="android:textColor">?android:attr/textColorPrimary</item>
<item name="android:fontFamily">sans-serif-light</item>
</style>
</resources>

View File

@ -28,7 +28,6 @@
<attr name="ic_folder" format="reference"/>
<attr name="type_audio" format="reference"/>
<attr name="type_video" format="reference"/>
<attr name="borderless_button" format="reference"/>
<attr name="overlay_drawable" format="reference"/>
<attr name="dragview_background" format="reference"/>
<attr name="dragview_float_background" format="reference"/>

View File

@ -279,6 +279,7 @@
<style name="AntennaPod.TextView.Heading" parent="@android:style/TextAppearance.Medium">
<item name="android:textSize">@dimen/text_size_large</item>
<item name="android:textColor">?android:attr/textColorPrimary</item>
<item name="android:fontFamily">sans-serif-light</item>
</style>
<style name="AntennaPod.TextView.ListItemPrimaryTitle" parent="@android:style/TextAppearance.Small">