From f4c0ee607e909caaacf52367901652ea89b16581 Mon Sep 17 00:00:00 2001 From: Matthew Wong Date: Tue, 11 Aug 2015 19:56:32 -0400 Subject: Multi-select deletion of apps in settings page --- .../autofill/AutofillPreferenceActivity.java | 2 - .../pwdstore/autofill/AutofillRecyclerAdapter.java | 92 +++++++++++++++++++++- .../main/res/drawable/autofill_row_background.xml | 5 ++ app/src/main/res/layout/autofill_row_layout.xml | 2 +- 4 files changed, 96 insertions(+), 5 deletions(-) create mode 100644 app/src/main/res/drawable/autofill_row_background.xml diff --git a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillPreferenceActivity.java b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillPreferenceActivity.java index 10684f45..54f0ade4 100644 --- a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillPreferenceActivity.java +++ b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillPreferenceActivity.java @@ -8,7 +8,6 @@ import android.content.pm.PackageManager; import android.database.Cursor; import android.database.MatrixCursor; import android.os.Bundle; -import android.preference.PreferenceManager; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; @@ -149,7 +148,6 @@ public class AutofillPreferenceActivity extends AppCompatActivity { args.putInt("position", recyclerAdapter.getPosition(packageName)); df.setArguments(args); df.show(getFragmentManager(), "autofill_dialog"); - // TODO if called from dialog 'Settings' button, should activity finish at OK? } } diff --git a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillRecyclerAdapter.java b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillRecyclerAdapter.java index bd2835e5..14530879 100644 --- a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillRecyclerAdapter.java +++ b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillRecyclerAdapter.java @@ -5,8 +5,11 @@ import android.content.SharedPreferences; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.preference.PreferenceManager; +import android.support.v7.view.ActionMode; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; +import android.view.Menu; +import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; @@ -15,13 +18,19 @@ import android.widget.TextView; import com.zeapo.pwdstore.R; import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.Set; +import java.util.TreeSet; public class AutofillRecyclerAdapter extends RecyclerView.Adapter { private ArrayList apps; private PackageManager pm; private AutofillPreferenceActivity activity; + private final Set selectedItems; + private ActionMode actionMode; - public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { + public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener { public View view; public TextView name; public TextView secondary; @@ -35,11 +44,30 @@ public class AutofillRecyclerAdapter extends RecyclerView.Adapter(Collections.reverseOrder()); } @Override @@ -80,6 +109,8 @@ public class AutofillRecyclerAdapter extends RecyclerView.Adapter + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/autofill_row_layout.xml b/app/src/main/res/layout/autofill_row_layout.xml index 3f94a8ad..354f9181 100644 --- a/app/src/main/res/layout/autofill_row_layout.xml +++ b/app/src/main/res/layout/autofill_row_layout.xml @@ -3,7 +3,7 @@ android:orientation="vertical" android:layout_width="match_parent" android:layout_height="64dp" - android:background="@color/grey_white_1000"> + android:background="@drawable/autofill_row_background">