Remove the menu title from the screen for GET INPUT and DISPLAY TEXT
There is a thought that the title of the main menu should not be
displayed on the screen shown for GET INPUT command and on the dialog
shown for DISPLAY TEXT command.
Bug: 64379095
Test: Manual - Verified the original behavior and the changed behavior
Change-Id: I093c8943b62837ac9e7f8cc5ba8a9d526c97e1f9
diff --git a/src/com/android/stk/StkInputActivity.java b/src/com/android/stk/StkInputActivity.java
index 3b0f210..ae59a8f 100755
--- a/src/com/android/stk/StkInputActivity.java
+++ b/src/com/android/stk/StkInputActivity.java
@@ -20,6 +20,7 @@
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
+import android.content.res.Configuration;
import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
import android.os.Handler;
@@ -31,11 +32,13 @@
import android.text.TextWatcher;
import android.text.method.PasswordTransformationMethod;
import android.view.KeyEvent;
+import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.ImageView;
+import android.widget.PopupMenu;
import android.widget.TextView;
import android.widget.EditText;
import android.widget.TextView.BufferType;
@@ -54,6 +57,8 @@
private Context mContext;
private EditText mTextIn = null;
private TextView mPromptView = null;
+ private View mMoreOptions = null;
+ private PopupMenu mPopupMenu = null;
private View mYesNoLayout = null;
private View mNormalLayout = null;
@@ -124,6 +129,28 @@
mAcceptUsersInput = false;
input = NO_STR_RESPONSE;
break;
+ case R.id.more:
+ if (mPopupMenu == null) {
+ mPopupMenu = new PopupMenu(this, v);
+ Menu menu = mPopupMenu.getMenu();
+ createOptionsMenuInternal(menu);
+ prepareOptionsMenuInternal(menu);
+ mPopupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
+ public boolean onMenuItemClick(MenuItem item) {
+ optionsItemSelectedInternal(item);
+ return true;
+ }
+ });
+ mPopupMenu.setOnDismissListener(new PopupMenu.OnDismissListener() {
+ public void onDismiss(PopupMenu menu) {
+ mPopupMenu = null;
+ }
+ });
+ mPopupMenu.show();
+ }
+ return;
+ default:
+ break;
}
CatLog.d(LOG_TAG, "handleClick, ready to response");
cancelTimeOut();
@@ -145,13 +172,23 @@
return;
}
- ActionBar actionBar = getActionBar();
- actionBar.setCustomView(R.layout.stk_title);
- actionBar.setDisplayShowCustomEnabled(true);
+ ActionBar actionBar = null;
+ if (getResources().getBoolean(R.bool.show_menu_title_only_on_menu)) {
+ actionBar = getActionBar();
+ if (actionBar != null) {
+ actionBar.hide();
+ }
+ }
// Set the layout for this activity.
setContentView(R.layout.stk_input);
+ if (actionBar != null) {
+ mMoreOptions = findViewById(R.id.more);
+ mMoreOptions.setVisibility(View.VISIBLE);
+ mMoreOptions.setOnClickListener(this);
+ }
+
// Initialize members
mTextIn = (EditText) this.findViewById(R.id.in_text);
mPromptView = (TextView) this.findViewById(R.id.prompt);
@@ -196,6 +233,9 @@
public void onPause() {
super.onPause();
CatLog.d(LOG_TAG, "onPause - mIsResponseSent[" + mIsResponseSent + "]");
+ if (mPopupMenu != null) {
+ mPopupMenu.dismiss();
+ }
}
@Override
@@ -229,6 +269,14 @@
}
@Override
+ public void onConfigurationChanged(Configuration newConfig) {
+ super.onConfigurationChanged(newConfig);
+ if (mPopupMenu != null) {
+ mPopupMenu.dismiss();
+ }
+ }
+
+ @Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (!mAcceptUsersInput) {
CatLog.d(LOG_TAG, "mAcceptUsersInput:false");
@@ -262,6 +310,10 @@
return;
}
+ if (mMoreOptions != null) {
+ mMoreOptions.setVisibility(View.INVISIBLE);
+ }
+
CatLog.d(LOG_TAG, "sendResponse resID[" + resId + "] input[*****] help["
+ help + "]");
mIsResponseSent = true;
@@ -280,24 +332,36 @@
@Override
public boolean onCreateOptionsMenu(android.view.Menu menu) {
super.onCreateOptionsMenu(menu);
- menu.add(android.view.Menu.NONE, StkApp.MENU_ID_END_SESSION, 1,
- R.string.menu_end_session);
- menu.add(0, StkApp.MENU_ID_HELP, 2, R.string.help);
-
+ createOptionsMenuInternal(menu);
return true;
}
+ private void createOptionsMenuInternal(Menu menu) {
+ menu.add(Menu.NONE, StkApp.MENU_ID_END_SESSION, 1, R.string.menu_end_session);
+ menu.add(0, StkApp.MENU_ID_HELP, 2, R.string.help);
+ }
+
@Override
public boolean onPrepareOptionsMenu(android.view.Menu menu) {
super.onPrepareOptionsMenu(menu);
+ prepareOptionsMenuInternal(menu);
+ return true;
+ }
+
+ private void prepareOptionsMenuInternal(Menu menu) {
menu.findItem(StkApp.MENU_ID_END_SESSION).setVisible(true);
menu.findItem(StkApp.MENU_ID_HELP).setVisible(mStkInput.helpAvailable);
-
- return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
+ if (optionsItemSelectedInternal(item)) {
+ return true;
+ }
+ return super.onOptionsItemSelected(item);
+ }
+
+ private boolean optionsItemSelectedInternal(MenuItem item) {
if (!mAcceptUsersInput) {
CatLog.d(LOG_TAG, "mAcceptUsersInput:false");
return true;
@@ -316,7 +380,7 @@
finish();
return true;
}
- return super.onOptionsItemSelected(item);
+ return false;
}
@Override
@@ -329,6 +393,9 @@
protected void onRestoreInstanceState(Bundle savedInstanceState) {
CatLog.d(LOG_TAG, "onRestoreInstanceState: " + mSlotId);
mAcceptUsersInput = savedInstanceState.getBoolean("ACCEPT_USERS_INPUT");
+ if ((mAcceptUsersInput == false) && (mMoreOptions != null)) {
+ mMoreOptions.setVisibility(View.INVISIBLE);
+ }
}
public void beforeTextChanged(CharSequence s, int start, int count,
@@ -387,8 +454,7 @@
}
inTypeView.setText(inTypeId);
- TextView textView = (TextView) this.findViewById(R.id.title_text);
- textView.setText(R.string.app_name);
+ setTitle(R.string.app_name);
if (mStkInput.icon != null) {
ImageView imageView = (ImageView) findViewById(R.id.icon);