aboutsummaryrefslogtreecommitdiffstats
path: root/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillPreferenceActivity.java
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/com/zeapo/pwdstore/autofill/AutofillPreferenceActivity.java')
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/autofill/AutofillPreferenceActivity.java123
1 files changed, 55 insertions, 68 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 b85a31c7..9fba959a 100644
--- a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillPreferenceActivity.java
+++ b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillPreferenceActivity.java
@@ -8,19 +8,18 @@ import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.os.AsyncTask;
import android.os.Bundle;
-import com.google.android.material.floatingactionbutton.FloatingActionButton;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.View;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.appcompat.widget.SearchView;
import androidx.core.app.NavUtils;
import androidx.core.app.TaskStackBuilder;
import androidx.core.view.MenuItemCompat;
-import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
-import androidx.appcompat.widget.SearchView;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.view.View;
-
+import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.zeapo.pwdstore.R;
import java.util.ArrayList;
@@ -29,9 +28,8 @@ import java.util.Map;
public class AutofillPreferenceActivity extends AppCompatActivity {
- private RecyclerView recyclerView;
AutofillRecyclerAdapter recyclerAdapter; // let fragment have access
-
+ private RecyclerView recyclerView;
private PackageManager pm;
private boolean recreate; // flag for action on up press; origin autofill dialog? different act
@@ -41,7 +39,7 @@ public class AutofillPreferenceActivity extends AppCompatActivity {
super.onCreate(savedInstanceState);
setContentView(R.layout.autofill_recycler_view);
- recyclerView = (RecyclerView) findViewById(R.id.autofill_recycler);
+ recyclerView = findViewById(R.id.autofill_recycler);
RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(this);
recyclerView.setLayoutManager(layoutManager);
@@ -62,64 +60,8 @@ public class AutofillPreferenceActivity extends AppCompatActivity {
setTitle("Autofill Apps");
- final FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
- fab.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- showDialog("", "", true);
- }
- });
- }
-
- private class populateTask extends AsyncTask<Void, Void, Void> {
- @Override
- protected void onPreExecute() {
- runOnUiThread(new Runnable() {
- public void run() {
- findViewById(R.id.progress_bar).setVisibility(View.VISIBLE);
- }
- });
- }
-
- @Override
- protected Void doInBackground(Void... params) {
- Intent intent = new Intent(Intent.ACTION_MAIN);
- intent.addCategory(Intent.CATEGORY_LAUNCHER);
- List<ResolveInfo> allAppsResolveInfo = pm.queryIntentActivities(intent, 0);
- List<AutofillRecyclerAdapter.AppInfo> allApps = new ArrayList<>();
-
- for (ResolveInfo app : allAppsResolveInfo) {
- allApps.add(new AutofillRecyclerAdapter.AppInfo(app.activityInfo.packageName
- , app.loadLabel(pm).toString(), false, app.loadIcon(pm)));
- }
-
- SharedPreferences prefs = getSharedPreferences("autofill_web", Context.MODE_PRIVATE);
- Map<String, ?> prefsMap = prefs.getAll();
- for (String key : prefsMap.keySet()) {
- try {
- allApps.add(new AutofillRecyclerAdapter.AppInfo(key, key, true, pm.getApplicationIcon("com.android.browser")));
- } catch (PackageManager.NameNotFoundException e) {
- allApps.add(new AutofillRecyclerAdapter.AppInfo(key, key, true, null));
- }
- }
-
- recyclerAdapter = new AutofillRecyclerAdapter(allApps, pm, AutofillPreferenceActivity.this);
- return null;
- }
-
- @Override
- protected void onPostExecute(Void aVoid) {
- runOnUiThread(new Runnable() {
- public void run() {
- findViewById(R.id.progress_bar).setVisibility(View.GONE);
- recyclerView.setAdapter(recyclerAdapter);
- Bundle extras = getIntent().getExtras();
- if (extras != null) {
- recyclerView.scrollToPosition(recyclerAdapter.getPosition(extras.getString("appName")));
- }
- }
- });
- }
+ final FloatingActionButton fab = findViewById(R.id.fab);
+ fab.setOnClickListener(v -> showDialog("", "", true));
}
@Override
@@ -175,4 +117,49 @@ public class AutofillPreferenceActivity extends AppCompatActivity {
df.setArguments(args);
df.show(getFragmentManager(), "autofill_dialog");
}
+
+ private class populateTask extends AsyncTask<Void, Void, Void> {
+ @Override
+ protected void onPreExecute() {
+ runOnUiThread(() -> findViewById(R.id.progress_bar).setVisibility(View.VISIBLE));
+ }
+
+ @Override
+ protected Void doInBackground(Void... params) {
+ Intent intent = new Intent(Intent.ACTION_MAIN);
+ intent.addCategory(Intent.CATEGORY_LAUNCHER);
+ List<ResolveInfo> allAppsResolveInfo = pm.queryIntentActivities(intent, 0);
+ List<AutofillRecyclerAdapter.AppInfo> allApps = new ArrayList<>();
+
+ for (ResolveInfo app : allAppsResolveInfo) {
+ allApps.add(new AutofillRecyclerAdapter.AppInfo(app.activityInfo.packageName
+ , app.loadLabel(pm).toString(), false, app.loadIcon(pm)));
+ }
+
+ SharedPreferences prefs = getSharedPreferences("autofill_web", Context.MODE_PRIVATE);
+ Map<String, ?> prefsMap = prefs.getAll();
+ for (String key : prefsMap.keySet()) {
+ try {
+ allApps.add(new AutofillRecyclerAdapter.AppInfo(key, key, true, pm.getApplicationIcon("com.android.browser")));
+ } catch (PackageManager.NameNotFoundException e) {
+ allApps.add(new AutofillRecyclerAdapter.AppInfo(key, key, true, null));
+ }
+ }
+
+ recyclerAdapter = new AutofillRecyclerAdapter(allApps, pm, AutofillPreferenceActivity.this);
+ return null;
+ }
+
+ @Override
+ protected void onPostExecute(Void aVoid) {
+ runOnUiThread(() -> {
+ findViewById(R.id.progress_bar).setVisibility(View.GONE);
+ recyclerView.setAdapter(recyclerAdapter);
+ Bundle extras = getIntent().getExtras();
+ if (extras != null) {
+ recyclerView.scrollToPosition(recyclerAdapter.getPosition(extras.getString("appName")));
+ }
+ });
+ }
+ }
}