diff options
author | Ryuto Sawada <ryuto.sawada@sony.com> | 2017-10-19 15:36:11 +0900 |
---|---|---|
committer | Yoshiaki Naka <yoshiaki.naka@sony.com> | 2017-10-19 15:37:01 +0900 |
commit | cf98c7c7f99240fbe4b37a75a93ec006caf370b1 (patch) | |
tree | fa907c054aacdcef97515b09fd6319fd5a501019 /src/com/android/stk/ToneDialog.java | |
parent | 82be71e1c4dda887acbf656ce39534da74ec7c01 (diff) | |
download | Stk-cf98c7c7f99240fbe4b37a75a93ec006caf370b1.tar.gz |
The activity should also be finished when the alert dialog is closed
User can close the alert dialog if the screen or the back key is
touched, but the activity remains in the foreground unexpectedly. The
activity should also be finished when the alert dialog is canceled.
Bug: 63282488
Test: manual
Change-Id: I4152a917d82417e677e78f5d39cd1caa70cc1bf8
Diffstat (limited to 'src/com/android/stk/ToneDialog.java')
-rwxr-xr-x | src/com/android/stk/ToneDialog.java | 40 |
1 files changed, 17 insertions, 23 deletions
diff --git a/src/com/android/stk/ToneDialog.java b/src/com/android/stk/ToneDialog.java index f9b8754..1c5fca6 100755 --- a/src/com/android/stk/ToneDialog.java +++ b/src/com/android/stk/ToneDialog.java @@ -20,14 +20,13 @@ import android.app.Activity; import android.app.AlertDialog; import android.content.BroadcastReceiver; import android.content.Context; +import android.content.DialogInterface; import android.content.Intent; import android.content.IntentFilter; import android.os.Bundle; import android.os.Handler; import android.os.Message; -import android.view.KeyEvent; import android.view.LayoutInflater; -import android.view.MotionEvent; import android.view.View; import android.widget.ImageView; import android.widget.TextView; @@ -42,6 +41,7 @@ import com.android.internal.telephony.cat.CatLog; public class ToneDialog extends Activity { TextMessage toneMsg = null; int mSlotId = -1; + private AlertDialog mAlertDialog; private static final String LOG_TAG = new Object(){}.getClass().getEnclosingClass().getName(); @@ -80,36 +80,30 @@ public class ToneDialog extends Activity { if (toneMsg.iconSelfExplanatory && toneMsg.icon != null) { tv.setVisibility(View.GONE); } + + alertDialogBuilder.setOnCancelListener(new DialogInterface.OnCancelListener() { + @Override + public void onCancel(DialogInterface dialog) { + sendStopTone(); + finish(); + } + }); + + mAlertDialog = alertDialogBuilder.create(); + mAlertDialog.show(); } @Override protected void onDestroy() { CatLog.d(LOG_TAG, "onDestroy"); - // Unregister receiver - unregisterReceiver(mFinishActivityReceiver); super.onDestroy(); - } - @Override - public boolean onKeyDown(int keyCode, KeyEvent event) { - switch (keyCode) { - case KeyEvent.KEYCODE_BACK: - sendStopTone(); - finish(); - break; - } - return false; - } + unregisterReceiver(mFinishActivityReceiver); - @Override - public boolean onTouchEvent(MotionEvent event) { - switch (event.getAction()) { - case MotionEvent.ACTION_DOWN: - sendStopTone(); - finish(); - return true; + if (mAlertDialog != null && mAlertDialog.isShowing()) { + mAlertDialog.dismiss(); + mAlertDialog = null; } - return super.onTouchEvent(event); } private BroadcastReceiver mFinishActivityReceiver = new BroadcastReceiver() { |