From 35c63c62f0fda5bfb9396700a59ed7e8859d79c8 Mon Sep 17 00:00:00 2001 From: Arnaud Barisain-Monrose Date: Fri, 5 Dec 2014 00:28:35 +0100 Subject: [PATCH 01/35] We can now log exceptions with crashlytics --- .../namelessdev/mpdroid/closedbits/CrashlyticsWrapper.java | 4 ++++ .../namelessdev/mpdroid/closedbits/CrashlyticsWrapper.java | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/MPDroid/src/closedbits/java/com/namelessdev/mpdroid/closedbits/CrashlyticsWrapper.java b/MPDroid/src/closedbits/java/com/namelessdev/mpdroid/closedbits/CrashlyticsWrapper.java index 98f2b4e5cc..a61ff8c454 100644 --- a/MPDroid/src/closedbits/java/com/namelessdev/mpdroid/closedbits/CrashlyticsWrapper.java +++ b/MPDroid/src/closedbits/java/com/namelessdev/mpdroid/closedbits/CrashlyticsWrapper.java @@ -25,4 +25,8 @@ public class CrashlyticsWrapper { public static void start(Context context) { Crashlytics.start(context); } + + public static void logException(final Exception exception) { + Crashlytics.logException(exception); + } } diff --git a/MPDroid/src/foss/java/com/namelessdev/mpdroid/closedbits/CrashlyticsWrapper.java b/MPDroid/src/foss/java/com/namelessdev/mpdroid/closedbits/CrashlyticsWrapper.java index 201a71b2bc..a7d3954164 100644 --- a/MPDroid/src/foss/java/com/namelessdev/mpdroid/closedbits/CrashlyticsWrapper.java +++ b/MPDroid/src/foss/java/com/namelessdev/mpdroid/closedbits/CrashlyticsWrapper.java @@ -24,4 +24,8 @@ public class CrashlyticsWrapper { public static void start(final Context context) { // Stub } + + public static void logException(final Exception exception) { + // Stub + } } From 21f14b92f8a042f48431758cf525dad0b07895f5 Mon Sep 17 00:00:00 2001 From: Avuton Olrich Date: Mon, 1 Dec 2014 18:54:05 -0800 Subject: [PATCH 02/35] NowPlayingFragment: When showing kHz, show a slight more accurate. --- .../com/namelessdev/mpdroid/fragments/NowPlayingFragment.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MPDroid/src/main/java/com/namelessdev/mpdroid/fragments/NowPlayingFragment.java b/MPDroid/src/main/java/com/namelessdev/mpdroid/fragments/NowPlayingFragment.java index 8cc1f57b84..3fd23ae56a 100644 --- a/MPDroid/src/main/java/com/namelessdev/mpdroid/fragments/NowPlayingFragment.java +++ b/MPDroid/src/main/java/com/namelessdev/mpdroid/fragments/NowPlayingFragment.java @@ -1053,7 +1053,7 @@ private void updateAudioNameText(final MPDStatus status) { if (optionalTrackInfo.length() > 0) { optionalTrackInfo.append(separator); } - optionalTrackInfo.append(sampleRate / 1000); + optionalTrackInfo.append(Math.abs(sampleRate / 1000.0f)); optionalTrackInfo.append("kHz"); } From 9b8cc0d75fad1aee3818f86bf2d3902aa42fd60a Mon Sep 17 00:00:00 2001 From: Avuton Olrich Date: Mon, 1 Dec 2014 18:52:45 -0800 Subject: [PATCH 03/35] NowPlayingFragment: Update AudioNameText only after status & track changes. --- .../com/namelessdev/mpdroid/fragments/NowPlayingFragment.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MPDroid/src/main/java/com/namelessdev/mpdroid/fragments/NowPlayingFragment.java b/MPDroid/src/main/java/com/namelessdev/mpdroid/fragments/NowPlayingFragment.java index 3fd23ae56a..2112a144c9 100644 --- a/MPDroid/src/main/java/com/namelessdev/mpdroid/fragments/NowPlayingFragment.java +++ b/MPDroid/src/main/java/com/namelessdev/mpdroid/fragments/NowPlayingFragment.java @@ -856,6 +856,7 @@ public final void onTrackInfoUpdate(final Music updatedSong, final float trackRa mSongNameText.setText(title); mSongRating.setRating(trackRating); mYearNameText.setText(date); + updateAudioNameText(mApp.oMPDAsyncHelper.oMPD.getStatus()); } @Override @@ -926,6 +927,7 @@ private void startPosTimer(final long start, final long total) { public void stateChanged(final MPDStatus mpdStatus, final int oldState) { if (mActivity != null) { updateStatus(mpdStatus); + updateAudioNameText(mpdStatus); } } @@ -1084,8 +1086,6 @@ private void updateStatus(final MPDStatus status) { mPlayPauseButton.setImageResource(getPlayPauseResource(status.getState())); - updateAudioNameText(status); - View.OnTouchListener currentListener = null; if (mCurrentSong != null) { if (mCurrentSong.isStream()) { From a08273ec579e0a23baaa95ea41caadb446051221 Mon Sep 17 00:00:00 2001 From: Avuton Olrich Date: Wed, 3 Dec 2014 17:13:10 -0800 Subject: [PATCH 04/35] dmix: Update AS gradle plugin. --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 2a73b9d73f..5070464cef 100644 --- a/build.gradle +++ b/build.gradle @@ -7,6 +7,6 @@ buildscript { mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:0.14.1' + classpath 'com.android.tools.build:gradle:1.0.0-rc4' } } From cc2d0e8698b9449b1cadd76542e9499995cbaebd Mon Sep 17 00:00:00 2001 From: Arnaud Barisain-Monrose Date: Sat, 6 Dec 2014 00:40:33 +0100 Subject: [PATCH 05/35] Remove the google play death warning, but keep the variable --- .../com/namelessdev/mpdroid/MPDApplication.java | 11 +++-------- .../com/namelessdev/mpdroid/MainMenuActivity.java | 14 -------------- MPDroid/src/main/res/values/strings.xml | 3 --- 3 files changed, 3 insertions(+), 25 deletions(-) diff --git a/MPDroid/src/main/java/com/namelessdev/mpdroid/MPDApplication.java b/MPDroid/src/main/java/com/namelessdev/mpdroid/MPDApplication.java index f62cca5fd7..a7458acbb7 100644 --- a/MPDroid/src/main/java/com/namelessdev/mpdroid/MPDApplication.java +++ b/MPDroid/src/main/java/com/namelessdev/mpdroid/MPDApplication.java @@ -29,7 +29,6 @@ import org.a0z.mpd.MPDStatusMonitor; -import android.annotation.SuppressLint; import android.app.Activity; import android.app.AlertDialog; import android.app.Application; @@ -398,13 +397,9 @@ public final boolean isTabletUiEnabled() { && mSettings.getBoolean("tabletUI", true); } - public final boolean shouldDisplayGooglePlayDeathWarning() { - return !mSettings.getBoolean("googlePlayDeathWarningShown", false); - } - - @SuppressLint("CommitPrefEdits") - public final void markGooglePlayDeathWarningAsRead() { - mSettings.edit().putBoolean("googlePlayDeathWarningShown", true).commit(); + @SuppressWarnings("unused") + public final boolean hasGooglePlayDeathWarningBeenDisplayed() { + return mSettings.getBoolean("googlePlayDeathWarningShown", false); } /** diff --git a/MPDroid/src/main/java/com/namelessdev/mpdroid/MainMenuActivity.java b/MPDroid/src/main/java/com/namelessdev/mpdroid/MainMenuActivity.java index 3b8437d65a..32cd46465d 100644 --- a/MPDroid/src/main/java/com/namelessdev/mpdroid/MainMenuActivity.java +++ b/MPDroid/src/main/java/com/namelessdev/mpdroid/MainMenuActivity.java @@ -474,20 +474,6 @@ public void onConfigurationChanged(final Configuration newConfig) { public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); - if (mApp.shouldDisplayGooglePlayDeathWarning()) { - new AlertDialog.Builder(this) - .setTitle(getString(R.string.gpDeathTitle)) - .setMessage(getResources().getString(R.string.gpDeathMessage)) - .setNegativeButton(getString(R.string.ok), new DialogInterface.OnClickListener() { - @Override - public void onClick(final DialogInterface dialogInterface, final int i) { - mApp.markGooglePlayDeathWarningAsRead(); - } - }) - .setCancelable(false) - .show(); - } - mApp.setupServiceBinder(); if (mApp.isTabletUiEnabled()) { diff --git a/MPDroid/src/main/res/values/strings.xml b/MPDroid/src/main/res/values/strings.xml index 6a959f40b8..adf4fb6caa 100644 --- a/MPDroid/src/main/res/values/strings.xml +++ b/MPDroid/src/main/res/values/strings.xml @@ -299,7 +299,4 @@ Media framework does not support stream codec. - Please read - It is with great disappointment that I\'m using this space to announce that Google made the harsh decision to remove MPDroid from the Play Store.\n\nIf they remove it, as they told me they will, 1.07 will be the last update you will get automatically from the Play Store.\n\nFor information, Google removed MPDroid for \'Copyright infringement\' without telling us what we did wrong, and we lost the appeal without being able to speak to a human.\n\nI have not decided yet if I will continue maintaining MPDroid or not, but it will still be available for download in F-Droid and at http://github.com/abarisain/dmix . More info, please go to http://nlss.fr/mpdroid . I will put an explanation page and a form so that I can update you about MPDroid\'s future via email, if you want.\n\nThanks for your time, and please enjoy this release we\'ve worked really hard on ! - From 6093d78621691401ca2b4bfe85b09843c265db61 Mon Sep 17 00:00:00 2001 From: Avuton Olrich Date: Fri, 5 Dec 2014 17:43:11 -0800 Subject: [PATCH 06/35] MPDApplication: Use a synchronized collection for connection locks. --- .../src/main/java/com/namelessdev/mpdroid/MPDApplication.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/MPDroid/src/main/java/com/namelessdev/mpdroid/MPDApplication.java b/MPDroid/src/main/java/com/namelessdev/mpdroid/MPDApplication.java index a7458acbb7..acc3feea17 100644 --- a/MPDroid/src/main/java/com/namelessdev/mpdroid/MPDApplication.java +++ b/MPDroid/src/main/java/com/namelessdev/mpdroid/MPDApplication.java @@ -49,6 +49,7 @@ import android.view.WindowManager.BadTokenException; import java.util.Collection; +import java.util.Collections; import java.util.LinkedList; import java.util.Timer; import java.util.TimerTask; @@ -68,7 +69,8 @@ public class MPDApplication extends Application implements private static MPDApplication sInstance; - private final Collection mConnectionLocks = new LinkedList<>(); + private final Collection mConnectionLocks = + Collections.synchronizedCollection(new LinkedList<>()); public MPDAsyncHelper oMPDAsyncHelper = null; From 5492bbc8427f131095ed4595cdbc8942a6a850a4 Mon Sep 17 00:00:00 2001 From: Avuton Olrich Date: Sat, 6 Dec 2014 06:57:23 -0800 Subject: [PATCH 07/35] CachedMPD: Don't try to get details for an empty album list. --- .../com/namelessdev/mpdroid/helpers/CachedMPD.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/MPDroid/src/main/java/com/namelessdev/mpdroid/helpers/CachedMPD.java b/MPDroid/src/main/java/com/namelessdev/mpdroid/helpers/CachedMPD.java index 8aabf0c07e..1ee8cb5a9f 100644 --- a/MPDroid/src/main/java/com/namelessdev/mpdroid/helpers/CachedMPD.java +++ b/MPDroid/src/main/java/com/namelessdev/mpdroid/helpers/CachedMPD.java @@ -172,9 +172,14 @@ public List getAllAlbums(final boolean trackCountNeeded) albums.add(album); } - allAlbums = new ArrayList<>(albums); - Collections.sort(allAlbums); - getAlbumDetails(allAlbums, true); + + if (albums.isEmpty()) { + allAlbums = Collections.emptyList(); + } else { + allAlbums = new ArrayList<>(albums); + Collections.sort(allAlbums); + getAlbumDetails(allAlbums, true); + } } else { allAlbums = super.getAllAlbums(trackCountNeeded); } From d4816d772b99b6b933c98616b8e2fed6cc78a742 Mon Sep 17 00:00:00 2001 From: Avuton Olrich Date: Sat, 6 Dec 2014 08:01:16 -0800 Subject: [PATCH 08/35] MPD: Fix album list with either empty list or invalid list response. We've been getting automated crash reports where the album key is not included in a list response line, this is probably due to an empty list or possibly an invalid server response line. During repair, I noticed we're doing a lot of unnecessary work with regard to album listing, so this patch fixes that at the same time. --- JMPDComm/src/main/java/org/a0z/mpd/MPD.java | 59 ++++--------------- .../mpdroid/helpers/CachedMPD.java | 7 +-- 2 files changed, 13 insertions(+), 53 deletions(-) diff --git a/JMPDComm/src/main/java/org/a0z/mpd/MPD.java b/JMPDComm/src/main/java/org/a0z/mpd/MPD.java index 635383b24e..48b108f94d 100644 --- a/JMPDComm/src/main/java/org/a0z/mpd/MPD.java +++ b/JMPDComm/src/main/java/org/a0z/mpd/MPD.java @@ -1216,34 +1216,7 @@ public List listAlbumArtists(final List albums) * @throws MPDException Thrown if an error occurs as a result of command execution. */ public List listAlbums() throws IOException, MPDException { - return listAlbums(null, false, true); - } - - /** - * List all albums from database. - * - * @param useAlbumArtist use AlbumArtist instead of Artist - * @return {@code Collection} with all album names from database. - * @throws IOException Thrown upon a communication error with the server. - * @throws MPDException Thrown if an error occurs as a result of command execution. - */ - public List listAlbums(final boolean useAlbumArtist) throws IOException, MPDException { - return listAlbums(null, useAlbumArtist, true); - } - - /** - * List all albums from a given artist, including an entry for songs with no - * album tag. - * - * @param artist artist to list albums - * @param useAlbumArtist use AlbumArtist instead of Artist - * @return {@code Collection} with all album names from database. - * @throws IOException Thrown upon a communication error with the server. - * @throws MPDException Thrown if an error occurs as a result of command execution. - */ - public List listAlbums(final String artist, final boolean useAlbumArtist) - throws IOException, MPDException { - return listAlbums(artist, useAlbumArtist, true); + return listAlbums(null, false); } /** @@ -1251,36 +1224,24 @@ public List listAlbums(final String artist, final boolean useAlbumArtist * * @param artist artist to list albums * @param useAlbumArtist use AlbumArtist instead of Artist - * @param includeUnknownAlbum include an entry for songs with no album tag * @return {@code Collection} with all album names from the given * artist present in database. * @throws IOException Thrown upon a communication error with the server. * @throws MPDException Thrown if an error occurs as a result of command execution. */ - public List listAlbums(final String artist, final boolean useAlbumArtist, - final boolean includeUnknownAlbum) throws IOException, MPDException { - boolean foundSongWithoutAlbum = false; - + public List listAlbums(final String artist, final boolean useAlbumArtist) + throws IOException, MPDException { final List response = - mConnection.sendCommand - (listAlbumsCommand(artist, useAlbumArtist)); - - final List result = new ArrayList<>(response.size()); - for (final String line : response) { - final String name = line.substring("Album: ".length()); - if (name.isEmpty()) { - foundSongWithoutAlbum = true; - } else { - result.add(name); - } - } + mConnection.sendCommand(listAlbumsCommand(artist, useAlbumArtist)); + final List result; - // add a single blank entry to host all songs without an album set - if (includeUnknownAlbum && foundSongWithoutAlbum) { - result.add(""); + if (response.isEmpty()) { + result = Collections.emptyList(); + } else { + result = Tools.parseResponse(response, "Album"); + Collections.sort(result); } - Collections.sort(result); return result; } diff --git a/MPDroid/src/main/java/com/namelessdev/mpdroid/helpers/CachedMPD.java b/MPDroid/src/main/java/com/namelessdev/mpdroid/helpers/CachedMPD.java index 1ee8cb5a9f..1049edb08d 100644 --- a/MPDroid/src/main/java/com/namelessdev/mpdroid/helpers/CachedMPD.java +++ b/MPDroid/src/main/java/com/namelessdev/mpdroid/helpers/CachedMPD.java @@ -231,20 +231,19 @@ public List listAlbumArtists(final List albums) * * @param artist artist to list albums * @param useAlbumArtist use AlbumArtist instead of Artist - * @param includeUnknownAlbum include an entry for songs with no album tag * @return List of albums. * @throws IOException Thrown upon a communication error with the server. * @throws MPDException Thrown if an error occurs as a result of command execution. */ @Override - public List listAlbums(final String artist, final boolean useAlbumArtist, - final boolean includeUnknownAlbum) throws IOException, MPDException { + public List listAlbums(final String artist, final boolean useAlbumArtist) + throws IOException, MPDException { final List albums; if (isCached()) { albums = new ArrayList(mCache.getAlbums(artist, useAlbumArtist)); } else { - albums = super.listAlbums(artist, useAlbumArtist, includeUnknownAlbum); + albums = super.listAlbums(artist, useAlbumArtist); } return albums; From 534801eb1dbf13ab5899fbacb833ba3a885422bc Mon Sep 17 00:00:00 2001 From: Avuton Olrich Date: Sat, 6 Dec 2014 08:26:08 -0800 Subject: [PATCH 09/35] MusicList: If songPos was not included in the plchanges, reload the playlist. We've received a crash report showing that upon playlist changes response that a songPos was not received with an entry. This is a protocol error. This patch works around that behaviour for if it ever happens we'll simply reload the entire playlist. --- JMPDComm/src/main/java/org/a0z/mpd/MusicList.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/JMPDComm/src/main/java/org/a0z/mpd/MusicList.java b/JMPDComm/src/main/java/org/a0z/mpd/MusicList.java index 12e2d89f0e..ede8243e7f 100644 --- a/JMPDComm/src/main/java/org/a0z/mpd/MusicList.java +++ b/JMPDComm/src/main/java/org/a0z/mpd/MusicList.java @@ -97,6 +97,12 @@ private void add(final Music music) { mSongID.add(null); } + if (songPos == -1) { + throw new IllegalStateException("Media server protocol error: songPos not " + + "included with the playlist changes included with the following " + + "music. Path:" + music.getFullPath() + " Name: " + music.getName()); + } + mList.set(songPos, music); mSongID.set(songPos, music.getSongId()); } From 5f7150989c2edd9ab45b094e923abb400fe1db2a Mon Sep 17 00:00:00 2001 From: Arnaud Barisain-Monrose Date: Sun, 7 Dec 2014 14:36:36 +0100 Subject: [PATCH 10/35] Remove the useless bonjour activity --- MPDroid/src/main/AndroidManifest.xml | 3 -- .../mpdroid/MPDroidActivities.java | 12 ------- .../namelessdev/mpdroid/MainMenuActivity.java | 3 -- .../mpdroid/ServerListActivity.java | 31 ------------------- 4 files changed, 49 deletions(-) delete mode 100644 MPDroid/src/main/java/com/namelessdev/mpdroid/ServerListActivity.java diff --git a/MPDroid/src/main/AndroidManifest.xml b/MPDroid/src/main/AndroidManifest.xml index 547d908351..4085c59177 100644 --- a/MPDroid/src/main/AndroidManifest.xml +++ b/MPDroid/src/main/AndroidManifest.xml @@ -85,9 +85,6 @@ android:name="com.namelessdev.mpdroid.library.LibraryTabsSettings" android:label="@string/libraryTabsSettings" android:theme="@style/AppTheme.Settings" /> - Date: Sun, 7 Dec 2014 14:54:16 +0100 Subject: [PATCH 11/35] Remove ListActivity. Not supported by support v7 --- .../mpdroid/MPDroidActivities.java | 15 +----- .../namelessdev/mpdroid/MainMenuActivity.java | 6 +-- .../mpdroid/library/PlaylistEditActivity.java | 51 +++++++++++-------- .../library/SimpleLibraryActivity.java | 4 +- 4 files changed, 34 insertions(+), 42 deletions(-) diff --git a/MPDroid/src/main/java/com/namelessdev/mpdroid/MPDroidActivities.java b/MPDroid/src/main/java/com/namelessdev/mpdroid/MPDroidActivities.java index ac2dabe322..aeb4bf00c4 100644 --- a/MPDroid/src/main/java/com/namelessdev/mpdroid/MPDroidActivities.java +++ b/MPDroid/src/main/java/com/namelessdev/mpdroid/MPDroidActivities.java @@ -22,6 +22,7 @@ import android.os.Bundle; import android.preference.PreferenceManager; import android.support.v4.app.FragmentActivity; +import android.support.v7.app.ActionBarActivity; public class MPDroidActivities { @@ -55,19 +56,7 @@ private static void applyTheme(final Activity activity) { } @SuppressLint("Registered") - public static class MPDroidActivity extends Activity { - - protected final MPDApplication mApp = MPDApplication.getInstance(); - - @Override - protected void onCreate(final Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - applyTheme(this); - } - } - - @SuppressLint("Registered") - public static class MPDroidFragmentActivity extends FragmentActivity { + public static class MPDroidActivity extends ActionBarActivity { protected final MPDApplication mApp = MPDApplication.getInstance(); diff --git a/MPDroid/src/main/java/com/namelessdev/mpdroid/MainMenuActivity.java b/MPDroid/src/main/java/com/namelessdev/mpdroid/MainMenuActivity.java index 0a0f132f37..ed099c1289 100644 --- a/MPDroid/src/main/java/com/namelessdev/mpdroid/MainMenuActivity.java +++ b/MPDroid/src/main/java/com/namelessdev/mpdroid/MainMenuActivity.java @@ -16,7 +16,6 @@ package com.namelessdev.mpdroid; -import com.namelessdev.mpdroid.MPDroidActivities.MPDroidFragmentActivity; import com.namelessdev.mpdroid.fragments.BrowseFragment; import com.namelessdev.mpdroid.fragments.LibraryFragment; import com.namelessdev.mpdroid.fragments.OutputsFragment; @@ -34,10 +33,7 @@ import android.app.ActionBar; import android.app.ActionBar.OnNavigationListener; -import android.app.AlertDialog; -import android.app.ProgressDialog; import android.content.Context; -import android.content.DialogInterface; import android.content.Intent; import android.content.IntentFilter; import android.content.SharedPreferences; @@ -73,7 +69,7 @@ import java.util.Collections; import java.util.List; -public class MainMenuActivity extends MPDroidFragmentActivity implements OnNavigationListener, +public class MainMenuActivity extends MPDroidActivities.MPDroidActivity implements OnNavigationListener, ILibraryFragmentActivity, ILibraryTabActivity, OnBackStackChangedListener, PopupMenu.OnMenuItemClickListener { diff --git a/MPDroid/src/main/java/com/namelessdev/mpdroid/library/PlaylistEditActivity.java b/MPDroid/src/main/java/com/namelessdev/mpdroid/library/PlaylistEditActivity.java index 6faa58d8ba..a4c32ae600 100644 --- a/MPDroid/src/main/java/com/namelessdev/mpdroid/library/PlaylistEditActivity.java +++ b/MPDroid/src/main/java/com/namelessdev/mpdroid/library/PlaylistEditActivity.java @@ -18,7 +18,7 @@ import com.mobeta.android.dslv.DragSortController; import com.mobeta.android.dslv.DragSortListView; -import com.namelessdev.mpdroid.MPDroidActivities.MPDroidListActivity; +import com.namelessdev.mpdroid.MPDroidActivities; import com.namelessdev.mpdroid.R; import com.namelessdev.mpdroid.tools.Tools; @@ -33,6 +33,7 @@ import android.view.MenuItem; import android.view.View; import android.view.View.OnClickListener; +import android.widget.AdapterView; import android.widget.BaseAdapter; import android.widget.Button; import android.widget.ListAdapter; @@ -47,8 +48,8 @@ import java.util.LinkedList; import java.util.List; -public class PlaylistEditActivity extends MPDroidListActivity implements StatusChangeListener, - OnClickListener { +public class PlaylistEditActivity extends MPDroidActivities.MPDroidActivity implements StatusChangeListener, + OnClickListener, AdapterView.OnItemClickListener { private static final String TAG = "PlaylistEditActivity"; @@ -66,6 +67,8 @@ public void remove(final int which) { private String mPlaylistName = null; + private ListView listView; + private final DragSortListView.DropListener mDropListener = new DragSortListView.DropListener() { @Override @@ -125,7 +128,7 @@ public void onClick(final View v) { mApp.oMPDAsyncHelper.oMPD.removeFromPlaylist(mPlaylistName, positions); } if (copy.size() != mSongList.size()) { - ((BaseAdapter) getListAdapter()).notifyDataSetChanged(); + ((BaseAdapter) listView.getAdapter()).notifyDataSetChanged(); } Tools.notifyUser(R.string.removeCountSongs, count); } catch (final Exception e) { @@ -151,7 +154,10 @@ public void onCreate(final Bundle savedInstanceState) { update(); mApp.oMPDAsyncHelper.addStatusChangeListener(this); - final DragSortListView trackList = (DragSortListView) getListView(); + listView = (ListView) findViewById(android.R.id.list); + listView.setOnItemClickListener(this); + + final DragSortListView trackList = (DragSortListView) listView; trackList.setOnCreateContextMenuListener(this); trackList.setDropListener(mDropListener); @@ -182,10 +188,9 @@ public void onDestroy() { * Marks the selected item for deletion */ @Override - protected void onListItemClick(final ListView l, final View v, final int position, - final long id) { - super.onListItemClick(l, v, position, id); - final AbstractMap item = mSongList.get(position); + public void onItemClick(final AdapterView adapterView, final View view, final int i, + final long l) { + final AbstractMap item = mSongList.get(i); item.get("marked"); if (item.get("marked").equals(true)) { item.put("marked", false); @@ -193,7 +198,7 @@ protected void onListItemClick(final ListView l, final View v, final int positio item.put("marked", true); } - ((BaseAdapter) getListAdapter()).notifyDataSetChanged(); + ((BaseAdapter) listView.getAdapter()).notifyDataSetChanged(); } @Override @@ -254,7 +259,7 @@ public void trackChanged(final MPDStatus mpdStatus, final int oldTrack) { song.put("play", 0); } } - final SimpleAdapter adapter = (SimpleAdapter) getListAdapter(); + final SimpleAdapter adapter = (SimpleAdapter) listView.getAdapter(); if (adapter != null) { adapter.notifyDataSetChanged(); } @@ -273,8 +278,8 @@ protected void update() { } mSongList = new ArrayList<>(); final int playingID = mApp.oMPDAsyncHelper.oMPD.getStatus().getSongId(); - final int pos = null == getListView() ? -1 : getListView().getFirstVisiblePosition(); - final View view = null == getListView() ? null : getListView().getChildAt(0); + final int pos = null == listView ? -1 : listView.getFirstVisiblePosition(); + final View view = null == listView ? null : listView.getChildAt(0); final int top = null == view ? -1 : view.getTop(); int listPlayingId = 0; int playlistPosition = 0; @@ -306,15 +311,17 @@ protected void update() { R.id.picture, android.R.id.text1, android.R.id.text2, R.id.removeCBox }); - setListAdapter(songs); - if (mIsFirstRefresh) { - mIsFirstRefresh = false; - if (listPlayingId > 0) { - setSelection(listPlayingId); - } - } else { - if (-1 != pos && -1 != top) { - getListView().setSelectionFromTop(pos, top); + if (listView != null) { + listView.setAdapter(songs); + if (mIsFirstRefresh) { + mIsFirstRefresh = false; + if (listPlayingId > 0) { + listView.setSelection(listPlayingId); + } + } else { + if (-1 != pos && -1 != top) { + listView.setSelectionFromTop(pos, top); + } } } diff --git a/MPDroid/src/main/java/com/namelessdev/mpdroid/library/SimpleLibraryActivity.java b/MPDroid/src/main/java/com/namelessdev/mpdroid/library/SimpleLibraryActivity.java index 48f9ae594b..991208f897 100644 --- a/MPDroid/src/main/java/com/namelessdev/mpdroid/library/SimpleLibraryActivity.java +++ b/MPDroid/src/main/java/com/namelessdev/mpdroid/library/SimpleLibraryActivity.java @@ -16,7 +16,7 @@ package com.namelessdev.mpdroid.library; -import com.namelessdev.mpdroid.MPDroidActivities.MPDroidFragmentActivity; +import com.namelessdev.mpdroid.MPDroidActivities; import com.namelessdev.mpdroid.R; import com.namelessdev.mpdroid.fragments.AlbumsFragment; import com.namelessdev.mpdroid.fragments.AlbumsGridFragment; @@ -46,7 +46,7 @@ import android.view.MenuItem; import android.widget.TextView; -public class SimpleLibraryActivity extends MPDroidFragmentActivity implements +public class SimpleLibraryActivity extends MPDroidActivities.MPDroidActivity implements ILibraryFragmentActivity, OnBackStackChangedListener { private static final String EXTRA_ALBUM = "album"; From 4804acb05a82d0d5fa40ba6950e42cbd4f158686 Mon Sep 17 00:00:00 2001 From: Arnaud Barisain-Monrose Date: Sun, 7 Dec 2014 14:56:36 +0100 Subject: [PATCH 12/35] Useless unboxing. --- .../com/namelessdev/mpdroid/library/PlaylistEditActivity.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MPDroid/src/main/java/com/namelessdev/mpdroid/library/PlaylistEditActivity.java b/MPDroid/src/main/java/com/namelessdev/mpdroid/library/PlaylistEditActivity.java index a4c32ae600..678640bc13 100644 --- a/MPDroid/src/main/java/com/namelessdev/mpdroid/library/PlaylistEditActivity.java +++ b/MPDroid/src/main/java/com/namelessdev/mpdroid/library/PlaylistEditActivity.java @@ -253,7 +253,7 @@ public void trackChanged(final MPDStatus mpdStatus, final int oldTrack) { if (mIsPlayQueue) { // Mark running track... for (final AbstractMap song : mSongList) { - if (((Integer) song.get("songid")).intValue() == mpdStatus.getSongId()) { + if (((Integer) song.get("songid")) == mpdStatus.getSongId()) { song.put("play", android.R.drawable.ic_media_play); } else { song.put("play", 0); From 961a57f7ef29b5bc0d5d3131a7523de22b93e3d0 Mon Sep 17 00:00:00 2001 From: Arnaud Barisain-Monrose Date: Sun, 7 Dec 2014 15:23:38 +0100 Subject: [PATCH 13/35] Support actionbar --- .../namelessdev/mpdroid/MainMenuActivity.java | 14 ++++++------ .../namelessdev/mpdroid/SearchActivity.java | 22 +++++++++---------- .../mpdroid/fragments/BrowseFragment.java | 8 +++---- .../mpdroid/library/PlaylistEditActivity.java | 2 +- .../library/SimpleLibraryActivity.java | 4 ++-- 5 files changed, 24 insertions(+), 26 deletions(-) diff --git a/MPDroid/src/main/java/com/namelessdev/mpdroid/MainMenuActivity.java b/MPDroid/src/main/java/com/namelessdev/mpdroid/MainMenuActivity.java index ed099c1289..02636c8b07 100644 --- a/MPDroid/src/main/java/com/namelessdev/mpdroid/MainMenuActivity.java +++ b/MPDroid/src/main/java/com/namelessdev/mpdroid/MainMenuActivity.java @@ -31,8 +31,6 @@ import org.a0z.mpd.MPD; import org.a0z.mpd.MPDStatus; -import android.app.ActionBar; -import android.app.ActionBar.OnNavigationListener; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; @@ -52,6 +50,7 @@ import android.support.v4.view.ViewPager; import android.support.v4.widget.DrawerLayout; import android.support.v4.widget.PopupMenuCompat; +import android.support.v7.app.ActionBar; import android.support.v7.app.ActionBarDrawerToggle; import android.view.KeyEvent; import android.view.LayoutInflater; @@ -69,7 +68,8 @@ import java.util.Collections; import java.util.List; -public class MainMenuActivity extends MPDroidActivities.MPDroidActivity implements OnNavigationListener, +public class MainMenuActivity extends MPDroidActivities.MPDroidActivity implements + ActionBar.OnNavigationListener, ILibraryFragmentActivity, ILibraryTabActivity, OnBackStackChangedListener, PopupMenu.OnMenuItemClickListener { @@ -185,7 +185,7 @@ private ActionBarDrawerToggle initializeDrawerToggle() { final int drawerImageRes; // Set up the action bar. - final ActionBar actionBar = getActionBar(); + final ActionBar actionBar = getSupportActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setHomeButtonEnabled(true); actionBar.setCustomView(mTextView); @@ -393,7 +393,7 @@ public void onPanelHidden(final View view) { @Override public void onPanelSlide(final View panel, final float slideOffset) { - final ActionBar actionBar = getActionBar(); + final ActionBar actionBar = getSupportActionBar(); if (slideOffset > 0.3f) { if (actionBar.isShowing()) { @@ -703,7 +703,7 @@ public void onStop() { @Override public void pageChanged(final int position) { - final ActionBar actionBar = getActionBar(); + final ActionBar actionBar = getSupportActionBar(); if (mCurrentDisplayMode == DisplayMode.MODE_LIBRARY && actionBar.getNavigationMode() == ActionBar.NAVIGATION_MODE_LIST) { actionBar.setSelectedNavigationItem(position); @@ -775,7 +775,7 @@ public void pushLibraryFragment(final Fragment fragment, final String label) { */ private void refreshActionBarTitle() { - final ActionBar actionBar = getActionBar(); + final ActionBar actionBar = getSupportActionBar(); actionBar.setDisplayShowCustomEnabled(true); if (mCurrentDisplayMode == DisplayMode.MODE_OUTPUTS) { diff --git a/MPDroid/src/main/java/com/namelessdev/mpdroid/SearchActivity.java b/MPDroid/src/main/java/com/namelessdev/mpdroid/SearchActivity.java index 8d572ea2c4..2b928fb4c7 100644 --- a/MPDroid/src/main/java/com/namelessdev/mpdroid/SearchActivity.java +++ b/MPDroid/src/main/java/com/namelessdev/mpdroid/SearchActivity.java @@ -29,18 +29,16 @@ import org.a0z.mpd.item.Item; import org.a0z.mpd.item.Music; -import android.app.ActionBar; -import android.app.ActionBar.Tab; -import android.app.ActionBar.TabListener; -import android.app.FragmentTransaction; import android.app.SearchManager; import android.content.Intent; import android.os.Bundle; import android.os.Parcelable; import android.provider.SearchRecentSuggestions; import android.support.annotation.StringRes; +import android.support.v4.app.FragmentTransaction; import android.support.v4.view.PagerAdapter; import android.support.v4.view.ViewPager; +import android.support.v7.app.ActionBar; import android.util.Log; import android.view.ContextMenu; import android.view.Menu; @@ -60,7 +58,7 @@ import java.util.List; public class SearchActivity extends MPDroidActivity implements OnMenuItemClickListener, - AsyncExecListener, OnItemClickListener, TabListener { + AsyncExecListener, OnItemClickListener, ActionBar.TabListener { public static final int ADD = 0; @@ -119,11 +117,11 @@ public class SearchActivity extends MPDroidActivity implements OnMenuItemClickLi private String mSearchKeywords = null; - private Tab mTabAlbums; + private ActionBar.Tab mTabAlbums; - private Tab mTabArtists; + private ActionBar.Tab mTabArtists; - private Tab mTabSongs; + private ActionBar.Tab mTabSongs; public SearchActivity() { super(); @@ -279,7 +277,7 @@ protected void onCreate(final Bundle savedInstanceState) { setContentView(R.layout.search_results); final SearchResultsPagerAdapter adapter = new SearchResultsPagerAdapter(); - final ActionBar actionBar = getActionBar(); + final ActionBar actionBar = getSupportActionBar(); mPager = (ViewPager) findViewById(R.id.pager); mPager.setAdapter(adapter); @@ -510,16 +508,16 @@ public void onStop() { } @Override - public void onTabReselected(final Tab tab, final FragmentTransaction ft) { + public void onTabReselected(final ActionBar.Tab tab, final FragmentTransaction ft) { } @Override - public void onTabSelected(final Tab tab, final FragmentTransaction ft) { + public void onTabSelected(final ActionBar.Tab tab, final FragmentTransaction ft) { mPager.setCurrentItem(tab.getPosition()); } @Override - public void onTabUnselected(final Tab tab, final FragmentTransaction ft) { + public void onTabUnselected(final ActionBar.Tab tab, final FragmentTransaction ft) { } private void setContextForObject(final Object object) { diff --git a/MPDroid/src/main/java/com/namelessdev/mpdroid/fragments/BrowseFragment.java b/MPDroid/src/main/java/com/namelessdev/mpdroid/fragments/BrowseFragment.java index f56772197c..1db4d0c825 100644 --- a/MPDroid/src/main/java/com/namelessdev/mpdroid/fragments/BrowseFragment.java +++ b/MPDroid/src/main/java/com/namelessdev/mpdroid/fragments/BrowseFragment.java @@ -33,8 +33,6 @@ import org.a0z.mpd.item.Item; import org.a0z.mpd.item.Music; -import android.app.ActionBar; -import android.app.Activity; import android.app.AlertDialog; import android.content.DialogInterface; import android.content.Intent; @@ -42,6 +40,8 @@ import android.os.Bundle; import android.support.annotation.StringRes; import android.support.v4.app.Fragment; +import android.support.v7.app.ActionBar; +import android.support.v7.app.ActionBarActivity; import android.util.Log; import android.view.ContextMenu; import android.view.LayoutInflater; @@ -252,9 +252,9 @@ public String getTitle() { @Override public void onActivityCreated(final Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); - final Activity activity = getActivity(); + final ActionBarActivity activity = (ActionBarActivity) getActivity(); if (activity != null) { - final ActionBar actionBar = activity.getActionBar(); + final ActionBar actionBar = activity.getSupportActionBar(); if (actionBar != null) { actionBar.setDisplayHomeAsUpEnabled(true); } diff --git a/MPDroid/src/main/java/com/namelessdev/mpdroid/library/PlaylistEditActivity.java b/MPDroid/src/main/java/com/namelessdev/mpdroid/library/PlaylistEditActivity.java index 678640bc13..b571f65f95 100644 --- a/MPDroid/src/main/java/com/namelessdev/mpdroid/library/PlaylistEditActivity.java +++ b/MPDroid/src/main/java/com/namelessdev/mpdroid/library/PlaylistEditActivity.java @@ -175,7 +175,7 @@ public void onCreate(final Bundle savedInstanceState) { final Button button = (Button) findViewById(R.id.Remove); button.setOnClickListener(this); - getActionBar().setDisplayHomeAsUpEnabled(true); + getSupportActionBar().setDisplayHomeAsUpEnabled(true); } @Override diff --git a/MPDroid/src/main/java/com/namelessdev/mpdroid/library/SimpleLibraryActivity.java b/MPDroid/src/main/java/com/namelessdev/mpdroid/library/SimpleLibraryActivity.java index 991208f897..6f55654509 100644 --- a/MPDroid/src/main/java/com/namelessdev/mpdroid/library/SimpleLibraryActivity.java +++ b/MPDroid/src/main/java/com/namelessdev/mpdroid/library/SimpleLibraryActivity.java @@ -30,7 +30,6 @@ import org.a0z.mpd.item.Album; import org.a0z.mpd.item.Artist; -import android.app.ActionBar; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; @@ -41,6 +40,7 @@ import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentManager.OnBackStackChangedListener; import android.support.v4.app.FragmentTransaction; +import android.support.v7.app.ActionBar; import android.view.KeyEvent; import android.view.LayoutInflater; import android.view.MenuItem; @@ -117,7 +117,7 @@ protected void onCreate(final Bundle savedInstanceState) { mTitleView.setSelected(true); mTitleView.requestFocus(); - final ActionBar actionBar = getActionBar(); + final ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setCustomView(mTitleView); actionBar.setDisplayShowTitleEnabled(false); From 4b291be4082e25e3c7b7bbddefdfaaafafb1055b Mon Sep 17 00:00:00 2001 From: Arnaud Barisain-Monrose Date: Sun, 7 Dec 2014 15:51:08 +0100 Subject: [PATCH 14/35] Theme fixes --- .../mpdroid/MPDroidActivities.java | 2 +- .../namelessdev/mpdroid/SettingsActivity.java | 3 ++- MPDroid/src/main/res/values/styles.xml | 25 ++++++++++++++----- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/MPDroid/src/main/java/com/namelessdev/mpdroid/MPDroidActivities.java b/MPDroid/src/main/java/com/namelessdev/mpdroid/MPDroidActivities.java index aeb4bf00c4..f5c806112f 100644 --- a/MPDroid/src/main/java/com/namelessdev/mpdroid/MPDroidActivities.java +++ b/MPDroid/src/main/java/com/namelessdev/mpdroid/MPDroidActivities.java @@ -62,8 +62,8 @@ public static class MPDroidActivity extends ActionBarActivity { @Override protected void onCreate(final Bundle savedInstanceState) { - super.onCreate(savedInstanceState); applyTheme(this); + super.onCreate(savedInstanceState); } } diff --git a/MPDroid/src/main/java/com/namelessdev/mpdroid/SettingsActivity.java b/MPDroid/src/main/java/com/namelessdev/mpdroid/SettingsActivity.java index 06c8fcc462..0e3afac043 100644 --- a/MPDroid/src/main/java/com/namelessdev/mpdroid/SettingsActivity.java +++ b/MPDroid/src/main/java/com/namelessdev/mpdroid/SettingsActivity.java @@ -20,8 +20,9 @@ import android.app.Activity; import android.os.Bundle; +import android.support.v7.app.ActionBarActivity; -public class SettingsActivity extends Activity implements StatusChangeListener { +public class SettingsActivity extends ActionBarActivity implements StatusChangeListener { private final MPDApplication mApp = MPDApplication.getInstance(); diff --git a/MPDroid/src/main/res/values/styles.xml b/MPDroid/src/main/res/values/styles.xml index 592b652256..41913b6193 100644 --- a/MPDroid/src/main/res/values/styles.xml +++ b/MPDroid/src/main/res/values/styles.xml @@ -17,31 +17,40 @@ --> - - - - - From f6c7b75bc50e5084388ae36ab519fa9dfa23d312 Mon Sep 17 00:00:00 2001 From: Arnaud Barisain-Monrose Date: Sun, 7 Dec 2014 16:05:25 +0100 Subject: [PATCH 17/35] Fix lollipop builds --- MPDroid/src/main/res/values-v21/styles.xml | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/MPDroid/src/main/res/values-v21/styles.xml b/MPDroid/src/main/res/values-v21/styles.xml index 796c428ace..86f07ac958 100644 --- a/MPDroid/src/main/res/values-v21/styles.xml +++ b/MPDroid/src/main/res/values-v21/styles.xml @@ -16,31 +16,41 @@ - - - - - - - - - - +