batch edit - replace the bottom button UI with FAB Speed Dial (no new actions yet)
This commit is contained in:
parent
9f854fbd3b
commit
9925830fff
|
@ -10,6 +10,7 @@ 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.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
|
@ -18,7 +19,6 @@ 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;
|
||||
|
||||
|
@ -46,17 +46,13 @@ public class EpisodesApplyActionFragment extends Fragment {
|
|||
private static final int ACTION_MARK_UNPLAYED = 4;
|
||||
private static final int ACTION_DOWNLOAD = 8;
|
||||
public static final int ACTION_REMOVE = 16;
|
||||
public static final int ACTION_REMOVE_FROM_QUEUE = 32;
|
||||
private static final int ACTION_ALL = ACTION_QUEUE | ACTION_MARK_PLAYED | ACTION_MARK_UNPLAYED
|
||||
| ACTION_DOWNLOAD | ACTION_REMOVE;
|
||||
|
||||
private ListView mListView;
|
||||
private ArrayAdapter<String> mAdapter;
|
||||
|
||||
private Button btnAddToQueue;
|
||||
private Button btnMarkAsPlayed;
|
||||
private Button btnMarkAsUnplayed;
|
||||
private Button btnDownload;
|
||||
private Button btnDelete;
|
||||
private SpeedDialView mSpeedDialView;
|
||||
|
||||
private final Map<Long,FeedItem> idMap = new ArrayMap<>();
|
||||
|
@ -148,56 +144,55 @@ public class EpisodesApplyActionFragment extends Fragment {
|
|||
mListView.setAdapter(mAdapter);
|
||||
/// checkAll(); // TODO: no longer check all by default
|
||||
|
||||
int lastVisibleDiv = 0;
|
||||
btnAddToQueue = view.findViewById(R.id.btnAddToQueue);
|
||||
if((actions & ACTION_QUEUE) != 0) {
|
||||
btnAddToQueue.setOnClickListener(v -> queueChecked());
|
||||
lastVisibleDiv = R.id.divider1;
|
||||
} else {
|
||||
btnAddToQueue.setVisibility(View.GONE);
|
||||
view.findViewById(R.id.divider1).setVisibility(View.GONE);
|
||||
}
|
||||
btnMarkAsPlayed = view.findViewById(R.id.btnMarkAsPlayed);
|
||||
if((actions & ACTION_MARK_PLAYED) != 0) {
|
||||
btnMarkAsPlayed.setOnClickListener(v -> markedCheckedPlayed());
|
||||
lastVisibleDiv = R.id.divider2;
|
||||
} else {
|
||||
btnMarkAsPlayed.setVisibility(View.GONE);
|
||||
view.findViewById(R.id.divider2).setVisibility(View.GONE);
|
||||
}
|
||||
btnMarkAsUnplayed = view.findViewById(R.id.btnMarkAsUnplayed);
|
||||
if((actions & ACTION_MARK_UNPLAYED) != 0) {
|
||||
btnMarkAsUnplayed.setOnClickListener(v -> markedCheckedUnplayed());
|
||||
lastVisibleDiv = R.id.divider3;
|
||||
} else {
|
||||
btnMarkAsUnplayed.setVisibility(View.GONE);
|
||||
view.findViewById(R.id.divider3).setVisibility(View.GONE);
|
||||
}
|
||||
btnDownload = view.findViewById(R.id.btnDownload);
|
||||
if((actions & ACTION_DOWNLOAD) != 0) {
|
||||
btnDownload.setOnClickListener(v -> downloadChecked());
|
||||
lastVisibleDiv = R.id.divider4;
|
||||
} else {
|
||||
btnDownload.setVisibility(View.GONE);
|
||||
view.findViewById(R.id.divider4).setVisibility(View.GONE);
|
||||
}
|
||||
btnDelete = view.findViewById(R.id.btnDelete);
|
||||
if((actions & ACTION_REMOVE) != 0) {
|
||||
btnDelete.setOnClickListener(v -> deleteChecked());
|
||||
} else {
|
||||
btnDelete.setVisibility(View.GONE);
|
||||
if(lastVisibleDiv > 0) {
|
||||
view.findViewById(lastVisibleDiv).setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
// replacement for the buttons
|
||||
mSpeedDialView = view.findViewById(R.id.fabSD);
|
||||
mSpeedDialView.inflate(R.menu.episodes_apply_action_speeddial);
|
||||
|
||||
// show only specified actions, and bind speed dial UIs to the actual logic
|
||||
if((actions & ACTION_QUEUE) == 0) {
|
||||
mSpeedDialView.removeActionItemById(R.id.addToQueue);
|
||||
}
|
||||
if((actions & ACTION_REMOVE_FROM_QUEUE) == 0) {
|
||||
mSpeedDialView.removeActionItemById(R.id.removeFromQueue);
|
||||
}
|
||||
if((actions & ACTION_MARK_PLAYED) == 0) {
|
||||
mSpeedDialView.removeActionItemById(R.id.markAsPlayed);
|
||||
}
|
||||
if((actions & ACTION_MARK_UNPLAYED) == 0) {
|
||||
mSpeedDialView.removeActionItemById(R.id.markAsUnplayed);
|
||||
}
|
||||
if((actions & ACTION_DOWNLOAD) == 0) {
|
||||
mSpeedDialView.removeActionItemById(R.id.download);
|
||||
}
|
||||
if((actions & ACTION_REMOVE) == 0) {
|
||||
mSpeedDialView.removeActionItemById(R.id.delete);
|
||||
}
|
||||
mSpeedDialView.setOnActionSelectedListener(actionItem -> {
|
||||
Toast.makeText(getContext(), "" + actionItem.getLabel() + " clicked", Toast.LENGTH_SHORT).show();
|
||||
switch(actionItem.getId()) {
|
||||
case R.id.addToQueue:
|
||||
queueChecked();
|
||||
break;
|
||||
case R.id.removeFromQueue:
|
||||
Toast.makeText(getContext(), "To implement: remove from queue", Toast.LENGTH_SHORT).show();
|
||||
break;
|
||||
case R.id.markAsPlayed:
|
||||
markedCheckedPlayed();
|
||||
break;
|
||||
case R.id.markAsUnplayed:
|
||||
markedCheckedUnplayed();
|
||||
break;
|
||||
case R.id.download:
|
||||
downloadChecked();
|
||||
break;
|
||||
case R.id.delete:
|
||||
deleteChecked();
|
||||
break;
|
||||
default:
|
||||
Log.e(TAG, "Unrecognized speed dial action item. Do nothing. id=" + actionItem.getId());
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
showSpeedDialIfAnyChecked();
|
||||
|
||||
return view;
|
||||
|
|
|
@ -1,104 +1,9 @@
|
|||
<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"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
android:padding="4dp">
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnAddToQueue"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:background="@android:color/transparent"
|
||||
android:drawableTop="?attr/content_new"
|
||||
android:text="@string/add_to_queue_label"
|
||||
android:textSize="10sp" />
|
||||
|
||||
<View
|
||||
android:id="@+id/divider1"
|
||||
android:layout_width="1dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_margin="4dp"
|
||||
android:background="?android:attr/listDivider"
|
||||
tools:background="@android:color/holo_red_dark" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnMarkAsPlayed"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:background="@android:color/transparent"
|
||||
android:drawableTop="?attr/navigation_accept"
|
||||
android:text="@string/mark_read_label"
|
||||
android:textSize="10sp" />
|
||||
|
||||
<View
|
||||
android:id="@+id/divider2"
|
||||
android:layout_width="1dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_margin="4dp"
|
||||
android:background="?android:attr/listDivider"
|
||||
tools:background="@android:color/holo_red_dark" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnMarkAsUnplayed"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:background="@android:color/transparent"
|
||||
android:drawableTop="?attr/navigation_cancel"
|
||||
android:text="@string/mark_unread_label"
|
||||
android:textSize="10sp" />
|
||||
|
||||
<View
|
||||
android:id="@+id/divider3"
|
||||
android:layout_width="1dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_margin="4dp"
|
||||
android:background="?android:attr/listDivider"
|
||||
tools:background="@android:color/holo_red_dark" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnDownload"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:background="@android:color/transparent"
|
||||
android:drawableTop="?attr/av_download"
|
||||
android:text="@string/download_label"
|
||||
android:textSize="10sp" />
|
||||
|
||||
<View
|
||||
android:id="@+id/divider4"
|
||||
android:layout_width="1dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_margin="4dp"
|
||||
android:background="?android:attr/listDivider"
|
||||
tools:background="@android:color/holo_red_dark" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnDelete"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:background="@android:color/transparent"
|
||||
android:drawableTop="?attr/content_discard"
|
||||
android:text="@string/remove_episode_lable"
|
||||
android:textSize="10sp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<com.leinardi.android.speeddial.SpeedDialOverlayLayout
|
||||
android:id="@+id/fabSDOverlay"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -123,15 +28,6 @@
|
|||
android:layout_marginBottom="16dp"
|
||||
/>
|
||||
</ScrollView>
|
||||
<View
|
||||
android:visibility="gone"
|
||||
android:id="@+id/divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_above="@id/bottomBar"
|
||||
android:background="?android:attr/listDivider"
|
||||
android:paddingBottom="4dp"
|
||||
tools:background="@android:color/holo_red_dark" />
|
||||
|
||||
<ListView
|
||||
android:id="@android:id/list"
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
android:icon="?attr/navigation_accept"
|
||||
android:title="@string/mark_read_label"
|
||||
/>
|
||||
<item android:id="@+id/remove_from_queue_item"
|
||||
<item android:id="@+id/removeFromQueue"
|
||||
android:icon="@drawable/ic_remove_grey600"
|
||||
android:title="@string/remove_from_queue_label"
|
||||
/>
|
||||
|
|
Loading…
Reference in New Issue