From 485b621b042041fb92f9b1c0765ef2edd83745f4 Mon Sep 17 00:00:00 2001 From: Matthew Wong Date: Tue, 28 Jul 2015 11:48:42 -0400 Subject: Change dialog appearance, smaller (wraps content) --- .../java/com/zeapo/pwdstore/AutofillService.java | 25 +++++++++++----------- app/src/main/res/layout/autofill_layout.xml | 12 ----------- 2 files changed, 12 insertions(+), 25 deletions(-) delete mode 100644 app/src/main/res/layout/autofill_layout.xml diff --git a/app/src/main/java/com/zeapo/pwdstore/AutofillService.java b/app/src/main/java/com/zeapo/pwdstore/AutofillService.java index 1636702a..5093dac3 100644 --- a/app/src/main/java/com/zeapo/pwdstore/AutofillService.java +++ b/app/src/main/java/com/zeapo/pwdstore/AutofillService.java @@ -5,6 +5,7 @@ import android.app.PendingIntent; import android.content.ClipData; import android.content.ClipboardManager; import android.content.Context; +import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; import android.content.pm.ApplicationInfo; @@ -14,11 +15,9 @@ import android.os.Bundle; import android.preference.PreferenceManager; import android.support.v7.app.AlertDialog; import android.util.Log; -import android.view.View; import android.view.WindowManager; import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityNodeInfo; -import android.widget.Button; import android.widget.Toast; import com.zeapo.pwdstore.utils.PasswordItem; @@ -96,24 +95,24 @@ public class AutofillService extends AccessibilityService { } if (dialog == null) { - AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.Theme_AppCompat_Light_Dialog_Alert); + AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.Theme_AppCompat_Dialog); builder.setNegativeButton("Cancel", null); - builder.setView(R.layout.autofill_layout); + builder.setPositiveButton("Fill", new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + decryptAndVerify(); + } + }); dialog = builder.create(); - dialog.setTitle("Fill with Password Store"); + dialog.setIcon(R.drawable.ic_launcher); + dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); dialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE); dialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); } + dialog.setTitle(items.get(0).getName()); dialog.show(); - ((Button) dialog.findViewById(R.id.button)).setText(items.get(0).getName()); - dialog.findViewById(R.id.button).setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - decryptAndVerify(); - dialog.dismiss(); - } - }); + dialog.getWindow().setLayout(WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT); } private ArrayList recursiveFilter(String filter, File dir) { diff --git a/app/src/main/res/layout/autofill_layout.xml b/app/src/main/res/layout/autofill_layout.xml deleted file mode 100644 index 0108160d..00000000 --- a/app/src/main/res/layout/autofill_layout.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - -