diff options
| author | Harsh Shandilya <msfjarvis@gmail.com> | 2019-01-02 22:44:52 +0530 |
|---|---|---|
| committer | حسين <zidhussein@gmail.com> | 2019-01-02 17:14:52 +0000 |
| commit | c200566bcaec971e1756afe5ebf96baf09e88816 (patch) | |
| tree | 15e692cdaffe08861df40849e31154409be96b46 /app/src/main/java/com/zeapo/pwdstore/autofill/AutofillPreferenceActivity.java | |
| parent | d5e589d7e48d4f44a052ecbf2817f5051bd1005f (diff) | |
| download | HardenedPass-c200566bcaec971e1756afe5ebf96baf09e88816.tar.gz HardenedPass-c200566bcaec971e1756afe5ebf96baf09e88816.zip | |
Bump minSdk to 21 (#466)
* Bump minSdk to 21
Signed-off-by: Harsh Shandilya <msfjarvis@gmail.com>
* PasswordGenerator: Constify things
Signed-off-by: Harsh Shandilya <msfjarvis@gmail.com>
* Deprecate PRNG fixes
The problem being fixed doesn't exist on SDK 21 and above.
Signed-off-by: Harsh Shandilya <msfjarvis@gmail.com>
* treewide: Switch to lambdas
Signed-off-by: Harsh Shandilya <msfjarvis@gmail.com>
* treewide: Formatting fixes
Signed-off-by: Harsh Shandilya <msfjarvis@gmail.com>
* treewide: Remove useless casts and add missing annotations
Signed-off-by: Harsh Shandilya <msfjarvis@gmail.com>
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.java | 123 |
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"))); + } + }); + } + } } |
