aboutsummaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/java/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java4
-rw-r--r--app/src/main/java/github/daneren2005/dsub/adapter/EntryGridAdapter.java13
-rw-r--r--app/src/main/java/github/daneren2005/dsub/adapter/SectionAdapter.java86
-rw-r--r--app/src/main/java/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java13
-rw-r--r--app/src/main/java/github/daneren2005/dsub/view/SongView.java16
-rw-r--r--app/src/main/java/github/daneren2005/dsub/view/UpdateView.java4
-rw-r--r--app/src/main/res/menu/select_song_context.xml31
-rw-r--r--app/src/main/res/menu/select_song_context_offline.xml21
-rw-r--r--app/src/main/res/values-de/strings.xml3
-rw-r--r--app/src/main/res/values-es/strings.xml3
-rw-r--r--app/src/main/res/values-fr/strings.xml3
-rw-r--r--app/src/main/res/values-hu/strings.xml3
-rw-r--r--app/src/main/res/values-ru/strings.xml1
-rw-r--r--app/src/main/res/values/strings.xml5
-rw-r--r--app/src/main/res/values/themes.xml3
15 files changed, 108 insertions, 101 deletions
diff --git a/app/src/main/java/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java b/app/src/main/java/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java
index 43bd15c7..0e9101f8 100644
--- a/app/src/main/java/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java
+++ b/app/src/main/java/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java
@@ -838,4 +838,8 @@ public class SubsonicFragmentActivity extends SubsonicActivity {
}
}
}
+
+ public Toolbar getActiveToolbar() {
+ return slideUpPanel.getPanelState() == SlidingUpPanelLayout.PanelState.EXPANDED ? nowPlayingToolbar : mainToolbar;
+ }
}
diff --git a/app/src/main/java/github/daneren2005/dsub/adapter/EntryGridAdapter.java b/app/src/main/java/github/daneren2005/dsub/adapter/EntryGridAdapter.java
index 48b278ec..0c699b89 100644
--- a/app/src/main/java/github/daneren2005/dsub/adapter/EntryGridAdapter.java
+++ b/app/src/main/java/github/daneren2005/dsub/adapter/EntryGridAdapter.java
@@ -41,7 +41,6 @@ public class EntryGridAdapter extends SectionAdapter<Entry> {
private ImageLoader imageLoader;
private boolean largeAlbums;
private boolean showArtist = false;
- private boolean checkable = true;
private View header;
public EntryGridAdapter(Context context, List<Entry> entries, ImageLoader imageLoader, boolean largeCell) {
@@ -83,14 +82,7 @@ public class EntryGridAdapter extends SectionAdapter<Entry> {
albumView.setObject(entry, imageLoader);
} else if(viewType == VIEW_TYPE_SONG) {
SongView songView = (SongView) view;
- songView.setObject(entry, checkable && !entry.isVideo());
- }
- }
-
- @Override
- public void setChecked(UpdateView updateView, boolean checked) {
- if(updateView instanceof SongView) {
- ((SongView) updateView).setChecked(checked);
+ songView.setObject(entry, checkable && !entry.isVideo() && currentActionMode != null);
}
}
@@ -122,9 +114,6 @@ public class EntryGridAdapter extends SectionAdapter<Entry> {
public void setShowArtist(boolean showArtist) {
this.showArtist = showArtist;
}
- public void setCheckable(boolean checkable) {
- this.checkable = checkable;
- }
public void removeAt(int index) {
sections.get(0).remove(index);
diff --git a/app/src/main/java/github/daneren2005/dsub/adapter/SectionAdapter.java b/app/src/main/java/github/daneren2005/dsub/adapter/SectionAdapter.java
index 6f5def3e..b5592520 100644
--- a/app/src/main/java/github/daneren2005/dsub/adapter/SectionAdapter.java
+++ b/app/src/main/java/github/daneren2005/dsub/adapter/SectionAdapter.java
@@ -18,7 +18,9 @@ package github.daneren2005.dsub.adapter;
import android.content.Context;
import android.support.v7.widget.PopupMenu;
import android.support.v7.widget.RecyclerView;
+import android.support.v7.widget.Toolbar;
import android.util.Log;
+import android.view.ActionMode;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
@@ -30,6 +32,7 @@ import java.util.Arrays;
import java.util.List;
import github.daneren2005.dsub.R;
+import github.daneren2005.dsub.activity.SubsonicFragmentActivity;
import github.daneren2005.dsub.view.BasicHeaderView;
import github.daneren2005.dsub.view.UpdateView;
import github.daneren2005.dsub.view.UpdateView.UpdateViewHolder;
@@ -43,7 +46,9 @@ public abstract class SectionAdapter<T> extends RecyclerView.Adapter<UpdateViewH
protected List<List<T>> sections;
protected boolean singleSectionHeader;
protected OnItemClickedListener<T> onItemClickedListener;
- private List<T> selected = new ArrayList<>();
+ protected List<T> selected = new ArrayList<>();
+ protected ActionMode currentActionMode;
+ protected boolean checkable = true;
protected SectionAdapter() {}
public SectionAdapter(Context context, List<T> section) {
@@ -80,7 +85,7 @@ public abstract class SectionAdapter<T> extends RecyclerView.Adapter<UpdateViewH
public void onClick(View v) {
T item = holder.getItem();
updateView.onClick();
- if (updateView.isCheckable()) {
+ if (updateView.isCheckable() && currentActionMode != null) {
if (selected.contains(item)) {
selected.remove(item);
setChecked(updateView, false);
@@ -88,6 +93,12 @@ public abstract class SectionAdapter<T> extends RecyclerView.Adapter<UpdateViewH
selected.add(item);
setChecked(updateView, true);
}
+
+ if(selected.isEmpty()) {
+ currentActionMode.finish();
+ } else {
+ currentActionMode.setTitle(context.getResources().getString(R.string.select_album_n_selected, selected.size()));
+ }
} else if (onItemClickedListener != null) {
onItemClickedListener.onItemClicked(item);
}
@@ -118,15 +129,15 @@ public abstract class SectionAdapter<T> extends RecyclerView.Adapter<UpdateViewH
}
});
- /*updateView.getChildAt(0).setOnLongClickListener(new View.OnLongClickListener() {
- @Override
- public boolean onLongClick(View v) {
- T item = holder.getItem();
- setContextItem(updateView, item);
- v.showContextMenu();
- return false;
- }
- });*/
+ if(checkable) {
+ updateView.getChildAt(0).setOnLongClickListener(new View.OnLongClickListener() {
+ @Override
+ public boolean onLongClick(View v) {
+ startActionMode(holder);
+ return true;
+ }
+ });
+ }
}
}
@@ -321,7 +332,58 @@ public abstract class SectionAdapter<T> extends RecyclerView.Adapter<UpdateViewH
public abstract UpdateView.UpdateViewHolder onCreateSectionViewHolder(ViewGroup parent, int viewType);
public abstract void onBindViewHolder(UpdateViewHolder holder, T item, int viewType);
public abstract int getItemViewType(T item);
- public void setChecked(UpdateView updateView, boolean checked) {}
+ public void setCheckable(boolean checkable) {
+ this.checkable = checkable;
+ }
+ public void setChecked(UpdateView updateView, boolean checked) {
+ updateView.setChecked(checked);
+ }
+
+ private void startActionMode(final UpdateView.UpdateViewHolder<T> holder) {
+ final UpdateView<T> updateView = holder.getUpdateView();
+ if (context instanceof SubsonicFragmentActivity && currentActionMode == null) {
+ final SubsonicFragmentActivity fragmentActivity = (SubsonicFragmentActivity) context;
+ Toolbar toolbar = fragmentActivity.getActiveToolbar();
+
+ toolbar.startActionMode(new ActionMode.Callback() {
+ @Override
+ public boolean onCreateActionMode(ActionMode mode, Menu menu) {
+ currentActionMode = mode;
+ fragmentActivity.onCreateOptionsMenu(menu);
+
+ T item = holder.getItem();
+ selected.add(item);
+ setChecked(updateView, true);
+
+ notifyDataSetChanged();
+ mode.setTitle(context.getResources().getString(R.string.select_album_n_selected, selected.size()));
+ return true;
+ }
+
+ @Override
+ public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
+ return false;
+ }
+
+ @Override
+ public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
+ if (fragmentActivity.onOptionsItemSelected(item)) {
+ currentActionMode.finish();
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public void onDestroyActionMode(ActionMode mode) {
+ currentActionMode = null;
+ selected.clear();
+ notifyDataSetChanged();
+ }
+ });
+ }
+ }
public interface OnItemClickedListener<T> {
void onItemClicked(T item);
diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java
index 9f66a27e..ed6afd46 100644
--- a/app/src/main/java/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java
+++ b/app/src/main/java/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java
@@ -420,6 +420,19 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Section
}
playNow(Arrays.asList(entry));
+ } else {
+ List<Entry> songs = new ArrayList<Entry>();
+
+ if(Util.getPreferences(context).getBoolean(Constants.PREFERENCES_KEY_PLAY_NOW_AFTER, false)) {
+ Iterator it = entries.listIterator(entries.indexOf(entry));
+ while(it.hasNext()) {
+ songs.add((Entry) it.next());
+ }
+ } else {
+ songs.add(entry);
+ }
+
+ playNow(songs);
}
}
diff --git a/app/src/main/java/github/daneren2005/dsub/view/SongView.java b/app/src/main/java/github/daneren2005/dsub/view/SongView.java
index fadf100e..e789c5de 100644
--- a/app/src/main/java/github/daneren2005/dsub/view/SongView.java
+++ b/app/src/main/java/github/daneren2005/dsub/view/SongView.java
@@ -38,7 +38,7 @@ import java.io.File;
*
* @author Sindre Mehus
*/
-public class SongView extends UpdateView2<MusicDirectory.Entry, Boolean> implements Checkable {
+public class SongView extends UpdateView2<MusicDirectory.Entry, Boolean> {
private static final String TAG = SongView.class.getSimpleName();
private CheckedTextView checkedTextView;
@@ -290,18 +290,8 @@ public class SongView extends UpdateView2<MusicDirectory.Entry, Boolean> impleme
}
@Override
- public void setChecked(boolean b) {
- checkedTextView.setChecked(b);
- }
-
- @Override
- public boolean isChecked() {
- return checkedTextView.isChecked();
- }
-
- @Override
- public void toggle() {
- checkedTextView.toggle();
+ public void setChecked(boolean checked) {
+ checkedTextView.setChecked(checked);
}
public MusicDirectory.Entry getEntry() {
diff --git a/app/src/main/java/github/daneren2005/dsub/view/UpdateView.java b/app/src/main/java/github/daneren2005/dsub/view/UpdateView.java
index 8e1029df..5043e7bc 100644
--- a/app/src/main/java/github/daneren2005/dsub/view/UpdateView.java
+++ b/app/src/main/java/github/daneren2005/dsub/view/UpdateView.java
@@ -27,6 +27,7 @@ import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView;
+import android.widget.Checkable;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
@@ -265,6 +266,9 @@ public abstract class UpdateView<T> extends LinearLayout {
public boolean isCheckable() {
return checkable;
}
+ public void setChecked(boolean checked) {
+
+ }
public void onClick() {
diff --git a/app/src/main/res/menu/select_song_context.xml b/app/src/main/res/menu/select_song_context.xml
index d8fc211c..eae8a8bc 100644
--- a/app/src/main/res/menu/select_song_context.xml
+++ b/app/src/main/res/menu/select_song_context.xml
@@ -6,37 +6,6 @@
android:id="@+id/song_menu_info"
android:title="@string/common.info"
/>
-
- <item
- android:id="@+id/song_menu_play_now"
- android:title="@string/common.play_now"
- />
-
- <group android:id="@+id/hide_play_next">
- <item
- android:id="@+id/song_menu_play_next"
- android:title="@string/common.play_next"/>
- </group>
-
- <group android:id="@+id/hide_play_last">
- <item
- android:id="@+id/song_menu_play_last"
- android:title="@string/common.play_last"/>
- </group>
-
- <item
- android:id="@+id/song_menu_download"
- android:title="@string/common.download"
- />
-
- <item
- android:id="@+id/song_menu_pin"
- android:title="@string/common.pin"
- />
-
- <item
- android:id="@+id/song_menu_delete"
- android:title="@string/menu.delete_cache"/>
<group android:id="@+id/server_1.8">
<item
diff --git a/app/src/main/res/menu/select_song_context_offline.xml b/app/src/main/res/menu/select_song_context_offline.xml
index 49445876..77903fb0 100644
--- a/app/src/main/res/menu/select_song_context_offline.xml
+++ b/app/src/main/res/menu/select_song_context_offline.xml
@@ -6,27 +6,6 @@
android:id="@+id/song_menu_info"
android:title="@string/common.info"
/>
-
- <item
- android:id="@+id/song_menu_play_now"
- android:title="@string/common.play_now"
- />
-
- <group android:id="@+id/hide_play_next">
- <item
- android:id="@+id/song_menu_play_next"
- android:title="@string/common.play_next"/>
- </group>
-
- <group android:id="@+id/hide_play_last">
- <item
- android:id="@+id/song_menu_play_last"
- android:title="@string/common.play_last"/>
- </group>
-
- <item
- android:id="@+id/song_menu_delete"
- android:title="@string/menu.delete_cache"/>
<item
android:id="@+id/song_menu_star"
diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml
index e77d0aa7..cd387b65 100644
--- a/app/src/main/res/values-de/strings.xml
+++ b/app/src/main/res/values-de/strings.xml
@@ -142,8 +142,7 @@
<string name="select_album.select">Alle auswählen</string>
<string name="select_album.n_selected">%d Lieder ausgewählt.</string>
- <string name="select_album.n_unselected">%d Lieder deselektiert.</string>
- <string name="select_album.more">Mehr</string>
+ <string name="select_album.more">Mehr</string>
<string name="select_album.offline">Offline</string>
<string name="select_album.searching">Suche...</string>
<string name="select_album.no_sdcard">Fehler: Keine SD-Karte verfügbar.</string>
diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml
index b91bc929..3c2593e2 100644
--- a/app/src/main/res/values-es/strings.xml
+++ b/app/src/main/res/values-es/strings.xml
@@ -130,8 +130,7 @@
<string name="select_album.select">Seleccionar todo</string>
<string name="select_album.n_selected">Seleccionadas %d canciones</string>
- <string name="select_album.n_unselected">%d canciones deseleccionadas</string>
- <string name="select_album.more">Más</string>
+ <string name="select_album.more">Más</string>
<string name="select_album.offline">Offline</string>
<string name="select_album.searching">Buscando...</string>
<string name="select_album.no_sdcard">Error: No hay tarjeta SD disponible</string>
diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml
index d547a261..cea3c77d 100644
--- a/app/src/main/res/values-fr/strings.xml
+++ b/app/src/main/res/values-fr/strings.xml
@@ -129,8 +129,7 @@
<string name="select_album.select">Tout sélectionner</string>
<string name="select_album.n_selected">%d pistes sélectionnées.</string>
- <string name="select_album.n_unselected">%d pistes désélectionnées.</string>
- <string name="select_album.more">Plus</string>
+ <string name="select_album.more">Plus</string>
<string name="select_album.offline">Déconnecté</string>
<string name="select_album.searching">Recherche en cours...</string>
<string name="select_album.no_sdcard">Erreur : Aucune carte SD card disponible.</string>
diff --git a/app/src/main/res/values-hu/strings.xml b/app/src/main/res/values-hu/strings.xml
index 6a28c051..816e605a 100644
--- a/app/src/main/res/values-hu/strings.xml
+++ b/app/src/main/res/values-hu/strings.xml
@@ -139,8 +139,7 @@
<string name="select_album.select">Összes jelölése be/ki</string>
<string name="select_album.n_selected">%d dal kijelölve.</string>
- <string name="select_album.n_unselected">%d dal visszavonva.</string>
- <string name="select_album.more">Továbbiak</string>
+ <string name="select_album.more">Továbbiak</string>
<string name="select_album.offline">Offline</string>
<string name="select_album.searching">Keresés...</string>
<string name="select_album.no_sdcard">Hiba: SD kártya nem áll rendelkezésre!</string>
diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml
index a3bb71be..0f904d95 100644
--- a/app/src/main/res/values-ru/strings.xml
+++ b/app/src/main/res/values-ru/strings.xml
@@ -89,7 +89,6 @@
<string name="select_album.select">Выбрать все</string>
<string name="select_album.n_selected">%d композиций выбрано.</string>
- <string name="select_album.n_unselected">Выбор снят с %d композиций.</string>
<string name="select_album.more">Еще</string>
<string name="select_album.offline">Оффлайн</string>
<string name="select_album.searching">Выполняется поиск...</string>
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 877b510f..f7c91da3 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -141,9 +141,8 @@
<string name="music_library.label_offline">Offline media</string>
<string name="select_album.select">Select all</string>
- <string name="select_album.n_selected">%d tracks selected.</string>
- <string name="select_album.n_unselected">%d tracks unselected.</string>
- <string name="select_album.more">More</string>
+ <string name="select_album.n_selected">%d selected.</string>
+ <string name="select_album.more">More</string>
<string name="select_album.offline">Offline</string>
<string name="select_album.searching">Searching...</string>
<string name="select_album.no_sdcard">Error: No SD card available.</string>
diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml
index fb47af81..76f0250c 100644
--- a/app/src/main/res/values/themes.xml
+++ b/app/src/main/res/values/themes.xml
@@ -51,6 +51,7 @@
<item name="actionbarSubtitleStyle">@style/TextAppearance.AppCompat.Widget.ActionBar.Subtitle.Inverse</item>
<item name="actionbarPopupStyle">@style/ThemeOverlay.AppCompat.Light</item>
<item name="android:spinnerItemStyle">@style/DarkSpinnerItem</item>
+ <item name="windowActionModeOverlay">true</item>
</style>
<style name="Theme.DSub.Dark.Base" parent="@style/Theme.AppCompat">
<item name="offline_icon">@drawable/main_offline_dark</item>
@@ -102,6 +103,8 @@
<item name="actionbarTitleStyle">@style/TextAppearance.AppCompat.Widget.ActionBar.Title</item>
<item name="actionbarSubtitleStyle">@style/TextAppearance.AppCompat.Widget.ActionBar.Subtitle</item>
<item name="actionbarPopupStyle">@style/ThemeOverlay.AppCompat.Dark</item>
+ <item name="windowActionModeOverlay">true</item>
+ <item name="actionModeBackground">?attr/colorPrimary</item>
</style>
<style name="Theme.DSub.Light" parent="Theme.DSub.Light.Base">
</style>