UI Prototype for Batch Edit Episodes rework (from #1145)

This commit is contained in:
orionlee 2019-03-18 17:08:13 -07:00
parent 56de034c7c
commit 737f7571ab
7 changed files with 137 additions and 3 deletions

View File

@ -14,6 +14,7 @@ android {
minSdkVersion rootProject.ext.minSdkVersion minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion
multiDexEnabled true multiDexEnabled true
vectorDrawables.useSupportLibrary true // consider to use pngs instead
// Version code schema: // Version code schema:
// "1.2.3-SNAPSHOT" -> 1020300 // "1.2.3-SNAPSHOT" -> 1020300
// "1.2.3-RC4" -> 1020304 // "1.2.3-RC4" -> 1020304
@ -158,6 +159,7 @@ dependencies {
} }
implementation "com.github.shts:TriangleLabelView:$triangleLabelViewVersion" 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" implementation "com.github.AntennaPod:AntennaPod-AudioPlayer:$audioPlayerVersion"

View File

@ -7,17 +7,22 @@ import android.os.Bundle;
import android.support.v4.app.ActivityCompat; import android.support.v4.app.ActivityCompat;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.util.ArrayMap; 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.LayoutInflater;
import android.view.Menu; import android.view.Menu;
import android.view.MenuInflater; import android.view.MenuInflater;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.Button; import android.widget.Button;
import android.widget.ListView; import android.widget.ListView;
import android.widget.Toast; import android.widget.Toast;
import com.leinardi.android.speeddial.SpeedDialView;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@ -51,6 +56,7 @@ public class EpisodesApplyActionFragment extends Fragment {
private Button btnMarkAsUnplayed; private Button btnMarkAsUnplayed;
private Button btnDownload; private Button btnDownload;
private Button btnDelete; private Button btnDelete;
private SpeedDialView mSpeedDialView;
private final Map<Long,FeedItem> idMap = new ArrayMap<>(); private final Map<Long,FeedItem> idMap = new ArrayMap<>();
private final List<FeedItem> episodes = new ArrayList<>(); private final List<FeedItem> episodes = new ArrayList<>();
@ -118,15 +124,28 @@ public class EpisodesApplyActionFragment extends Fragment {
}).show(); }).show();
return true; 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) { for(FeedItem episode : episodes) {
titles.add(episode.getTitle()); titles.add(episode.getTitle());
} }
mAdapter = new ArrayAdapter<>(getActivity(), 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); mListView.setAdapter(mAdapter);
checkAll(); /// checkAll(); // TODO: no longer check all by default
int lastVisibleDiv = 0; int lastVisibleDiv = 0;
btnAddToQueue = view.findViewById(R.id.btnAddToQueue); btnAddToQueue = view.findViewById(R.id.btnAddToQueue);
@ -171,9 +190,22 @@ 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; return view;
} }
private void showSpeedDialIfAnyChecked() {
mSpeedDialView.setVisibility(checkedIds.size() > 0 ? View.VISIBLE : View.GONE);
}
private void hideSpeedDial() {
mSpeedDialView.setVisibility(View.GONE);
}
@Override @Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater); super.onCreateOptionsMenu(menu, inflater);
@ -410,6 +442,13 @@ public class EpisodesApplyActionFragment extends Fragment {
mListView.setItemChecked(i, checked); mListView.setItemChecked(i, checked);
} }
ActivityCompat.invalidateOptionsMenu(EpisodesApplyActionFragment.this.getActivity()); 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() { private void queueChecked() {

View File

@ -1,11 +1,13 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<LinearLayout <LinearLayout
android:id="@+id/bottomBar" android:id="@+id/bottomBar"
android:visibility="gone"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="68dp" android:layout_height="68dp"
android:layout_alignParentBottom="true" android:layout_alignParentBottom="true"
@ -97,7 +99,25 @@
</LinearLayout> </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 <View
android:visibility="gone"
android:id="@+id/divider" android:id="@+id/divider"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="1dp" android:layout_height="1dp"
@ -110,6 +130,6 @@
android:id="@android:id/list" android:id="@android:id/list"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_above="@id/divider"/> android:layout_alignParentTop="true"/>
</RelativeLayout> </RelativeLayout>

View File

@ -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"
/>

View File

@ -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>

View File

@ -0,0 +1,5 @@
<vector android:height="24dp"
android:viewportHeight="24.0" android:viewportWidth="24.0"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FFFFFFFF" android:pathData="M3,17.25V21h3.75L17.81,9.94l-3.75,-3.75L3,17.25zM20.71,7.04c0.39,-0.39 0.39,-1.02 0,-1.41l-2.34,-2.34c-0.39,-0.39 -1.02,-0.39 -1.41,0l-1.83,1.83 3.75,3.75 1.83,-1.83z"/>
</vector>

View File

@ -0,0 +1,5 @@
<vector android:height="24dp"
android:viewportHeight="24.0" android:viewportWidth="24.0"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF757575" android:pathData="M19,13H5v-2h14v2z"/>
</vector>