aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java')
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/autofill/AutofillPreferenceActivity.java64
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/autofill/AutofillRecyclerAdapter.java7
2 files changed, 49 insertions, 22 deletions
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 6f507fa5..788442a0 100644
--- a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillPreferenceActivity.java
+++ b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillPreferenceActivity.java
@@ -4,6 +4,7 @@ import android.app.DialogFragment;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
+import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v4.app.NavUtils;
import android.support.v4.app.TaskStackBuilder;
@@ -14,6 +15,7 @@ import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.SearchView;
import android.view.Menu;
import android.view.MenuItem;
+import android.view.View;
import com.zeapo.pwdstore.R;
@@ -28,6 +30,8 @@ public class AutofillPreferenceActivity extends AppCompatActivity {
AutofillRecyclerAdapter recyclerAdapter; // let fragment have access
private RecyclerView.LayoutManager layoutManager;
+ private PackageManager pm;
+
private boolean recreate;
@Override
@@ -41,27 +45,47 @@ public class AutofillPreferenceActivity extends AppCompatActivity {
recyclerView.setLayoutManager(layoutManager);
recyclerView.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL_LIST));
- Intent intent = new Intent(Intent.ACTION_MAIN);
- intent.addCategory(Intent.CATEGORY_LAUNCHER);
- List<ResolveInfo> allApps = getPackageManager().queryIntentActivities(intent, 0);
- final PackageManager pm = getPackageManager();
- Collections.sort(allApps, new Comparator<ResolveInfo>() {
- @Override
- public int compare(ResolveInfo lhs, ResolveInfo rhs) {
- return lhs.loadLabel(pm).toString().compareTo(rhs.loadLabel(pm).toString());
- }
- });
- recyclerAdapter = new AutofillRecyclerAdapter(new ArrayList<>(allApps), pm, this);
- recyclerView.setAdapter(recyclerAdapter);
+ pm = getPackageManager();
+
+ new populateTask().execute();
setTitle("Autofill Apps");
+ }
+
+ private class populateTask extends AsyncTask<Void, Void, List<ResolveInfo>> {
+ @Override
+ protected void onPreExecute() {
+ findViewById(R.id.progress_bar).setVisibility(View.VISIBLE);
+ }
- recreate = false;
- Bundle extras = getIntent().getExtras();
- if (extras != null) {
- recreate = true;
- recyclerView.scrollToPosition(recyclerAdapter.getPosition(extras.getString("packageName")));
- showDialog(extras.getString("packageName"), extras.getString("appName"));
+ @Override
+ protected List<ResolveInfo> doInBackground(Void... params) {
+ Intent intent = new Intent(Intent.ACTION_MAIN);
+ intent.addCategory(Intent.CATEGORY_LAUNCHER);
+ List<ResolveInfo> allApps = pm.queryIntentActivities(intent, 0);
+ Collections.sort(allApps, new Comparator<ResolveInfo>() {
+ @Override
+ public int compare(ResolveInfo lhs, ResolveInfo rhs) {
+ return lhs.loadLabel(pm).toString().compareTo(rhs.loadLabel(pm).toString());
+ }
+ });
+ return allApps;
+ }
+
+ @Override
+ protected void onPostExecute(List<ResolveInfo> allApps) {
+ findViewById(R.id.progress_bar).setVisibility(View.GONE);
+
+ recyclerAdapter = new AutofillRecyclerAdapter(new ArrayList<>(allApps), pm, AutofillPreferenceActivity.this);
+ recyclerView.setAdapter(recyclerAdapter);
+
+ recreate = false;
+ Bundle extras = getIntent().getExtras();
+ if (extras != null) {
+ recreate = true;
+ recyclerView.scrollToPosition(recyclerAdapter.getPosition(extras.getString("packageName")));
+ showDialog(extras.getString("packageName"), extras.getString("appName"));
+ }
}
}
@@ -75,11 +99,12 @@ public class AutofillPreferenceActivity extends AppCompatActivity {
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String s) {
- return true;
+ return false;
}
@Override
public boolean onQueryTextChange(String s) {
+ recyclerAdapter.filter(s);
return true;
}
});
@@ -99,6 +124,7 @@ public class AutofillPreferenceActivity extends AppCompatActivity {
});
return super.onCreateOptionsMenu(menu);
}
+
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
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 7c735f18..485ef288 100644
--- a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillRecyclerAdapter.java
+++ b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillRecyclerAdapter.java
@@ -4,7 +4,6 @@ import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
-import android.support.v7.view.ActionMode;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
@@ -20,7 +19,6 @@ public class AutofillRecyclerAdapter extends RecyclerView.Adapter<AutofillRecycl
private ArrayList<ResolveInfo> apps;
private PackageManager pm;
private AutofillPreferenceActivity activity;
- private ActionMode actionMode;
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
public View view;
@@ -61,7 +59,7 @@ public class AutofillRecyclerAdapter extends RecyclerView.Adapter<AutofillRecycl
@Override
public void onBindViewHolder(AutofillRecyclerAdapter.ViewHolder holder, int position) {
ResolveInfo app = apps.get(position);
- holder.name.setText(app.loadLabel(pm));
+ holder.name.setText(app.loadLabel(pm)); // 'No package identifier when getting value for resource number 0x00000000' 5+
holder.icon.setImageDrawable(app.loadIcon(pm));
holder.packageName = app.activityInfo.packageName;
@@ -103,4 +101,7 @@ public class AutofillRecyclerAdapter extends RecyclerView.Adapter<AutofillRecycl
return -1;
}
+ public void filter(String s) {
+
+ }
}