diff --git a/app/build.gradle b/app/build.gradle index bcd7a381d..cbe5c33fa 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -14,6 +14,7 @@ android { minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion multiDexEnabled true + vectorDrawables.useSupportLibrary true // consider to use pngs instead // Version code schema: // "1.2.3-SNAPSHOT" -> 1020300 // "1.2.3-RC4" -> 1020304 @@ -158,6 +159,7 @@ dependencies { } implementation "com.github.shts:TriangleLabelView:$triangleLabelViewVersion" + implementation 'com.leinardi.android:speed-dial:1.0.2' // 1.0.2 uses support 27.1.1 ; newer versions use 28.0.0; implementation "com.github.AntennaPod:AntennaPod-AudioPlayer:$audioPlayerVersion" diff --git a/app/src/main/java/de/danoeh/antennapod/dialog/EpisodesApplyActionFragment.java b/app/src/main/java/de/danoeh/antennapod/dialog/EpisodesApplyActionFragment.java index 07a64cde8..c456dc41a 100644 --- a/app/src/main/java/de/danoeh/antennapod/dialog/EpisodesApplyActionFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/dialog/EpisodesApplyActionFragment.java @@ -7,17 +7,22 @@ import android.os.Bundle; import android.support.v4.app.ActivityCompat; import android.support.v4.app.Fragment; import android.support.v4.util.ArrayMap; +import android.support.v7.app.ActionBar; +import android.support.v7.app.AppCompatActivity; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; +import android.widget.AbsListView; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.ListView; import android.widget.Toast; +import com.leinardi.android.speeddial.SpeedDialView; + import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -51,6 +56,7 @@ public class EpisodesApplyActionFragment extends Fragment { private Button btnMarkAsUnplayed; private Button btnDownload; private Button btnDelete; + private SpeedDialView mSpeedDialView; private final Map idMap = new ArrayMap<>(); private final List episodes = new ArrayList<>(); @@ -118,15 +124,28 @@ public class EpisodesApplyActionFragment extends Fragment { }).show(); return true; }); + mListView.setOnScrollListener(new AbsListView.OnScrollListener() { + @Override + public void onScrollStateChanged(AbsListView view, int scrollState) { + if (AbsListView.OnScrollListener.SCROLL_STATE_IDLE == scrollState) { + showSpeedDialIfAnyChecked(); + } else { + hideSpeedDial(); + } + } + + @Override + public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {} + }); for(FeedItem episode : episodes) { titles.add(episode.getTitle()); } mAdapter = new ArrayAdapter<>(getActivity(), - android.R.layout.simple_list_item_multiple_choice, titles); + R.layout.simple_list_item_multiple_choice_on_start, titles); mListView.setAdapter(mAdapter); - checkAll(); + /// checkAll(); // TODO: no longer check all by default int lastVisibleDiv = 0; btnAddToQueue = view.findViewById(R.id.btnAddToQueue); @@ -171,8 +190,21 @@ public class EpisodesApplyActionFragment extends Fragment { } } + // replacement for the buttons + mSpeedDialView = view.findViewById(R.id.fabSD); + mSpeedDialView.inflate(R.menu.episodes_apply_action_speeddial); + showSpeedDialIfAnyChecked(); + return view; } + + private void showSpeedDialIfAnyChecked() { + mSpeedDialView.setVisibility(checkedIds.size() > 0 ? View.VISIBLE : View.GONE); + } + + private void hideSpeedDial() { + mSpeedDialView.setVisibility(View.GONE); + } @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { @@ -410,6 +442,13 @@ public class EpisodesApplyActionFragment extends Fragment { mListView.setItemChecked(i, checked); } ActivityCompat.invalidateOptionsMenu(EpisodesApplyActionFragment.this.getActivity()); + showSpeedDialIfAnyChecked(); + + ActionBar actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar(); + if (actionBar != null) { + String title = checkedIds.size() > 0 ? checkedIds.size() + " selected" : ""; // TODO: restore to the original title + actionBar.setTitle(title); + } } private void queueChecked() { diff --git a/app/src/main/res/layout/episodes_apply_action_fragment.xml b/app/src/main/res/layout/episodes_apply_action_fragment.xml index e9a2e2e23..1bbe7e61f 100644 --- a/app/src/main/res/layout/episodes_apply_action_fragment.xml +++ b/app/src/main/res/layout/episodes_apply_action_fragment.xml @@ -1,11 +1,13 @@ + + + android:layout_alignParentTop="true"/> diff --git a/app/src/main/res/layout/simple_list_item_multiple_choice_on_start.xml b/app/src/main/res/layout/simple_list_item_multiple_choice_on_start.xml new file mode 100644 index 000000000..3c03f71ea --- /dev/null +++ b/app/src/main/res/layout/simple_list_item_multiple_choice_on_start.xml @@ -0,0 +1,33 @@ + + + + + diff --git a/app/src/main/res/menu/episodes_apply_action_speeddial.xml b/app/src/main/res/menu/episodes_apply_action_speeddial.xml new file mode 100644 index 000000000..09c05695f --- /dev/null +++ b/app/src/main/res/menu/episodes_apply_action_speeddial.xml @@ -0,0 +1,30 @@ + + + + + + + + + + diff --git a/core/src/main/res/drawable/ic_fab_edit.xml b/core/src/main/res/drawable/ic_fab_edit.xml new file mode 100644 index 000000000..cb2e394b0 --- /dev/null +++ b/core/src/main/res/drawable/ic_fab_edit.xml @@ -0,0 +1,5 @@ + + + diff --git a/core/src/main/res/drawable/ic_remove_grey600.xml b/core/src/main/res/drawable/ic_remove_grey600.xml new file mode 100644 index 000000000..5a6b2af6b --- /dev/null +++ b/core/src/main/res/drawable/ic_remove_grey600.xml @@ -0,0 +1,5 @@ + + +