Amazfit Bip: implement deletion and select all actions

Also add white-on-black icons for all the actions
This commit is contained in:
Daniele Gobbetti
2018-04-05 22:41:03 +02:00
parent 80addd3454
commit 74dcec730c
5 changed files with 51 additions and 11 deletions
@@ -38,8 +38,6 @@ import nodomain.freeyourgadget.gadgetbridge.util.GB;
public class ActivitySummariesActivity extends AbstractListActivity<BaseActivitySummary> { public class ActivitySummariesActivity extends AbstractListActivity<BaseActivitySummary> {
private int selectedIndex;
private GBDevice mGBDevice; private GBDevice mGBDevice;
private SwipeRefreshLayout swipeLayout; private SwipeRefreshLayout swipeLayout;
@@ -125,7 +123,13 @@ public class ActivitySummariesActivity extends AbstractListActivity<BaseActivity
SparseBooleanArray checked = getItemListView().getCheckedItemPositions(); SparseBooleanArray checked = getItemListView().getCheckedItemPositions();
switch (menuItem.getItemId()) { switch (menuItem.getItemId()) {
case R.id.activity_action_delete: case R.id.activity_action_delete:
GB.toast(getBaseContext(), "TODO, delete activities :-)", Toast.LENGTH_LONG, GB.INFO); List<BaseActivitySummary> toDelete = new ArrayList<>();
for(int i = 0; i< checked.size(); i++) {
if (checked.valueAt(i)) {
toDelete.add(getItemAdapter().getItem(checked.keyAt(i)));
}
}
deleteItems(toDelete);
processed = true; processed = true;
break; break;
case R.id.activity_action_export: case R.id.activity_action_export:
@@ -146,12 +150,16 @@ public class ActivitySummariesActivity extends AbstractListActivity<BaseActivity
} }
} }
} }
shareMultiple(paths); shareMultiple(paths);
processed = true; processed = true;
break;
case R.id.activity_action_select_all:
for ( int i=0; i < getItemListView().getCount(); i++) {
getItemListView().setItemChecked(i, true);
}
return true; //don't finish actionmode in this case!
default: default:
break; break;
} }
actionMode.finish(); actionMode.finish();
return processed; return processed;
@@ -186,13 +194,12 @@ public class ActivitySummariesActivity extends AbstractListActivity<BaseActivity
super.onDestroy(); super.onDestroy();
} }
private void deleteItemAt(int position) { private void deleteItems(List<BaseActivitySummary> items) {
BaseActivitySummary item = getItemAdapter().getItem(position); for(BaseActivitySummary item : items) {
if (item != null) {
item.delete(); item.delete();
getItemAdapter().remove(item); getItemAdapter().remove(item);
refresh();
} }
refresh();
} }
private void showTrack(String gpxTrack) { private void showTrack(String gpxTrack) {
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FFFFFFFF"
android:pathData="M6,19c0,1.1 0.9,2 2,2h8c1.1,0 2,-0.9 2,-2L18,7L6,7v12zM8.46,11.88l1.41,-1.41L12,12.59l2.12,-2.12 1.41,1.41L13.41,14l2.12,2.12 -1.41,1.41L12,15.41l-2.12,2.12 -1.41,-1.41L10.59,14l-2.13,-2.12zM15.5,4l-1,-1h-5l-1,1L5,4v2h14L19,4z"/>
</vector>
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FFFFFFFF"
android:pathData="M3,5h2L5,3c-1.1,0 -2,0.9 -2,2zM3,13h2v-2L3,11v2zM7,21h2v-2L7,19v2zM3,9h2L5,7L3,7v2zM13,3h-2v2h2L13,3zM19,3v2h2c0,-1.1 -0.9,-2 -2,-2zM5,21v-2L3,19c0,1.1 0.9,2 2,2zM3,17h2v-2L3,15v2zM9,3L7,3v2h2L9,3zM11,21h2v-2h-2v2zM19,13h2v-2h-2v2zM19,21c1.1,0 2,-0.9 2,-2h-2v2zM19,9h2L21,7h-2v2zM19,17h2v-2h-2v2zM15,21h2v-2h-2v2zM15,5h2L17,3h-2v2zM7,17h10L17,7L7,7v10zM9,9h6v6L9,15L9,9z"/>
</vector>
+9
View File
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FFFFFFFF"
android:pathData="M18,16.08c-0.76,0 -1.44,0.3 -1.96,0.77L8.91,12.7c0.05,-0.23 0.09,-0.46 0.09,-0.7s-0.04,-0.47 -0.09,-0.7l7.05,-4.11c0.54,0.5 1.25,0.81 2.04,0.81 1.66,0 3,-1.34 3,-3s-1.34,-3 -3,-3 -3,1.34 -3,3c0,0.24 0.04,0.47 0.09,0.7L8.04,9.81C7.5,9.31 6.79,9 6,9c-1.66,0 -3,1.34 -3,3s1.34,3 3,3c0.79,0 1.5,-0.31 2.04,-0.81l7.12,4.16c-0.05,0.21 -0.08,0.43 -0.08,0.65 0,1.61 1.31,2.92 2.92,2.92 1.61,0 2.92,-1.31 2.92,-2.92s-1.31,-2.92 -2.92,-2.92z"/>
</vector>
+8 -2
View File
@@ -3,15 +3,21 @@
xmlns:app="http://schemas.android.com/apk/res-auto"> xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/activity_action_select_all"
android:icon="@drawable/ic_select_all"
android:title="SELECT ALL"
app:showAsAction="ifRoom" />
<item <item
android:id="@+id/activity_action_export" android:id="@+id/activity_action_export"
android:icon="@android:drawable/ic_menu_share" android:icon="@drawable/ic_share"
android:title="EXPORT" android:title="EXPORT"
app:showAsAction="ifRoom" /> app:showAsAction="ifRoom" />
<item <item
android:id="@+id/activity_action_delete" android:id="@+id/activity_action_delete"
android:icon="@android:drawable/ic_menu_delete" android:icon="@drawable/ic_delete_cross"
android:title="@string/Delete" android:title="@string/Delete"
app:showAsAction="always"/> app:showAsAction="always"/>