summaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/java/de/danoeh/antennapod/dialog/EpisodesApplyActionFragment.java43
-rw-r--r--app/src/main/res/layout/episodes_apply_action_fragment.xml22
-rw-r--r--app/src/main/res/layout/simple_list_item_multiple_choice_on_start.xml33
-rw-r--r--app/src/main/res/menu/episodes_apply_action_speeddial.xml30
4 files changed, 125 insertions, 3 deletions
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<Long,FeedItem> idMap = new ArrayMap<>();
private final List<FeedItem> 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 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/bottomBar"
+ android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="68dp"
android:layout_alignParentBottom="true"
@@ -97,7 +99,25 @@
</LinearLayout>
+ <com.leinardi.android.speeddial.SpeedDialOverlayLayout
+ android:id="@+id/fabSDOverlay"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
+ <com.leinardi.android.speeddial.SpeedDialView
+ android:id="@+id/fabSD"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ app:sdMainFabClosedSrc="@drawable/ic_fab_edit"
+ app:sdOverlayLayout="@id/fabSDOverlay"
+ android:layout_alignParentBottom="true"
+ android:layout_alignParentEnd="true"
+ android:layout_alignParentRight="true"
+ android:layout_marginEnd="16dp"
+ android:layout_marginRight="16dp"
+ android:layout_marginBottom="16dp"
+ />
<View
+ android:visibility="gone"
android:id="@+id/divider"
android:layout_width="match_parent"
android:layout_height="1dp"
@@ -110,6 +130,6 @@
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_above="@id/divider"/>
+ android:layout_alignParentTop="true"/>
</RelativeLayout>
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 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Based on simple_list_item_multiple_choice.xml
+ from The Android Open Source Project
+ This one puts the check box at the start of the view (rather than at the end).
+ -->
+<!-- Copyright (C) 2008 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@android:id/text1"
+ android:layout_width="match_parent"
+ android:layout_height="?android:attr/listPreferredItemHeightSmall"
+ android:textAppearance="?android:attr/textAppearanceListItemSmall"
+ android:gravity="center_vertical"
+ android:drawableStart="?android:attr/listChoiceIndicatorMultiple"
+ android:drawableLeft="?android:attr/listChoiceIndicatorMultiple"
+ android:paddingStart="?android:attr/listPreferredItemPaddingStart"
+ android:paddingLeft="?android:attr/listPreferredItemPaddingLeft"
+ android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
+ android:paddingRight="?android:attr/listPreferredItemPaddingRight"
+ />
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 @@
+<?xml version="1.0" encoding="utf-8"?>
+<menu xmlns:android="http://schemas.android.com/apk/res/android">
+
+ <item
+ android:id="@+id/addToQueue"
+ android:icon="?attr/content_new"
+ android:title="@string/add_to_queue_label"
+ />
+ <item android:id="@+id/remove_from_queue_item"
+ android:icon="@drawable/ic_remove_grey600"
+ android:title="@string/remove_from_queue_label"
+ />
+ <item
+ android:id="@+id/markAsPlayed"
+ android:icon="?attr/navigation_accept"
+ android:title="@string/mark_read_label"
+ />
+ <item android:id="@+id/markAsUnplayed"
+ android:icon="?attr/navigation_cancel"
+ android:title="@string/mark_unread_label"
+ />
+ <item android:id="@+id/download"
+ android:icon="?attr/av_download"
+ android:title="@string/download_label"
+ />
+ <item android:id="@+id/delete"
+ android:icon="?attr/content_discard"
+ android:title="@string/remove_episode_lable"
+ />
+</menu>