From 3350188abe8b3629ec4b291e3e2aab0edce17810 Mon Sep 17 00:00:00 2001 From: Sanket Padawe Date: Wed, 19 Apr 2017 18:30:09 -0700 Subject: Fix crash in stk app. Use alertdialog recommended by Material design and remove old dialog for ToneDialog activity style. Test: manual Bug: 37198947 Change-Id: I07da028fb606b3b3af817ca26e03c344aabcd449 --- src/com/android/stk/ToneDialog.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'src/com/android/stk/ToneDialog.java') diff --git a/src/com/android/stk/ToneDialog.java b/src/com/android/stk/ToneDialog.java index 834d575..fa6e9d3 100755 --- a/src/com/android/stk/ToneDialog.java +++ b/src/com/android/stk/ToneDialog.java @@ -17,12 +17,14 @@ package com.android.stk; import android.app.Activity; +import android.app.AlertDialog; import android.content.Intent; import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.os.Vibrator; import android.view.KeyEvent; +import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; import android.widget.ImageView; @@ -73,14 +75,13 @@ public class ToneDialog extends Activity { initFromIntent(getIntent()); - // remove window title - View title = findViewById(com.android.internal.R.id.title); - title.setVisibility(View.GONE); - // set customized content view - setContentView(R.layout.stk_tone_dialog); + AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this); + LayoutInflater inflater = this.getLayoutInflater(); + View dialogView = inflater.inflate(R.layout.stk_tone_dialog, null); + alertDialogBuilder.setView(dialogView); - TextView tv = (TextView) findViewById(R.id.message); - ImageView iv = (ImageView) findViewById(R.id.icon); + TextView tv = (TextView) dialogView.findViewById(R.id.message); + ImageView iv = (ImageView) dialogView.findViewById(R.id.icon); // set text and icon if ((null == toneMsg) || (null == toneMsg.text) || (toneMsg.text.equals(""))) { @@ -116,6 +117,8 @@ public class ToneDialog extends Activity { if (settings.vibrate && mVibrator != null) { mVibrator.vibrate(timeout); } + + alertDialogBuilder.create().show(); } @Override -- cgit v1.2.3