Methods Summary |
---|
private void | cancelTimeOut()
mTimeoutHandler.removeMessages(MSG_ID_TIMEOUT);
|
private void | displayMenu()
if (mStkMenu != null) {
// Display title & title icon
if (mStkMenu.titleIcon != null) {
mTitleIconView.setImageBitmap(mStkMenu.titleIcon);
mTitleIconView.setVisibility(View.VISIBLE);
} else {
mTitleIconView.setVisibility(View.GONE);
}
if (!mStkMenu.titleIconSelfExplanatory) {
mTitleTextView.setVisibility(View.VISIBLE);
if (mStkMenu.title == null) {
mTitleTextView.setText(R.string.app_name);
} else {
mTitleTextView.setText(mStkMenu.title);
}
} else {
mTitleTextView.setVisibility(View.INVISIBLE);
}
// create an array adapter for the menu list
StkMenuAdapter adapter = new StkMenuAdapter(this,
mStkMenu.items, mStkMenu.itemsIconSelfExplanatory);
// Bind menu list to the new adapter.
setListAdapter(adapter);
// Set default item
setSelection(mStkMenu.defaultItem);
}
|
private com.android.internal.telephony.gsm.stk.Item | getSelectedItem(int position)
Item item = null;
if (mStkMenu != null) {
try {
item = mStkMenu.items.get(position);
} catch (IndexOutOfBoundsException e) {
if (StkApp.DBG) {
StkLog.d(this, "Invalid menu");
}
} catch (NullPointerException e) {
if (StkApp.DBG) {
StkLog.d(this, "Invalid menu");
}
}
}
return item;
|
private void | initFromIntent(android.content.Intent intent)
if (intent != null) {
mState = intent.getIntExtra("STATE", STATE_MAIN);
} else {
finish();
}
|
public void | onCreate(android.os.Bundle icicle)
super.onCreate(icicle);
StkLog.d(this, "onCreate");
// Remove the default title, customized one is used.
requestWindowFeature(Window.FEATURE_NO_TITLE);
// Set the layout for this activity.
setContentView(R.layout.stk_menu_list);
mTitleTextView = (TextView) findViewById(R.id.title_text);
mTitleIconView = (ImageView) findViewById(R.id.title_icon);
mProgressView = (ProgressBar) findViewById(R.id.progress_bar);
mContext = getBaseContext();
initFromIntent(getIntent());
mAcceptUsersInput = true;
|
public boolean | onCreateOptionsMenu(android.view.Menu menu)
super.onCreateOptionsMenu(menu);
menu.add(0, StkApp.MENU_ID_END_SESSION, 1, R.string.menu_end_session);
menu.add(0, StkApp.MENU_ID_HELP, 2, R.string.help);
return true;
|
public void | onDestroy()
super.onDestroy();
StkLog.d(this, "onDestroy");
|
public boolean | onKeyDown(int keyCode, android.view.KeyEvent event)
if (!mAcceptUsersInput) {
return true;
}
switch (keyCode) {
case KeyEvent.KEYCODE_BACK:
switch (mState) {
case STATE_SECONDARY:
cancelTimeOut();
mAcceptUsersInput = false;
sendResponse(StkAppService.RES_ID_BACKWARD);
return true;
case STATE_MAIN:
break;
}
break;
}
return super.onKeyDown(keyCode, event);
|
protected void | onListItemClick(android.widget.ListView l, android.view.View v, int position, long id)
super.onListItemClick(l, v, position, id);
if (!mAcceptUsersInput) {
return;
}
Item item = getSelectedItem(position);
if (item == null) {
return;
}
sendResponse(StkAppService.RES_ID_MENU_SELECTION, item.id, false);
mAcceptUsersInput = false;
mProgressView.setVisibility(View.VISIBLE);
mProgressView.setIndeterminate(true);
|
protected void | onNewIntent(android.content.Intent intent)
super.onNewIntent(intent);
StkLog.d(this, "onNewIntent");
initFromIntent(intent);
mAcceptUsersInput = true;
|
public boolean | onOptionsItemSelected(android.view.MenuItem item)
if (!mAcceptUsersInput) {
return true;
}
switch (item.getItemId()) {
case StkApp.MENU_ID_END_SESSION:
cancelTimeOut();
mAcceptUsersInput = false;
// send session end response.
sendResponse(StkAppService.RES_ID_END_SESSION);
return true;
case StkApp.MENU_ID_HELP:
cancelTimeOut();
mAcceptUsersInput = false;
int position = getSelectedItemPosition();
Item stkItem = getSelectedItem(position);
if (stkItem == null) {
break;
}
// send help needed response.
sendResponse(StkAppService.RES_ID_MENU_SELECTION, stkItem.id, true);
return true;
}
return super.onOptionsItemSelected(item);
|
public void | onPause()
super.onPause();
appService.indicateMenuVisibility(false);
cancelTimeOut();
|
public boolean | onPrepareOptionsMenu(android.view.Menu menu)
super.onPrepareOptionsMenu(menu);
boolean helpVisible = false;
boolean mainVisible = false;
if (mState == STATE_SECONDARY) {
mainVisible = true;
}
if (mStkMenu != null) {
helpVisible = mStkMenu.helpAvailable;
}
menu.findItem(StkApp.MENU_ID_END_SESSION).setVisible(mainVisible);
menu.findItem(StkApp.MENU_ID_HELP).setVisible(helpVisible);
return true;
|
protected void | onRestoreInstanceState(android.os.Bundle savedInstanceState)
mState = savedInstanceState.getInt("STATE");
mStkMenu = savedInstanceState.getParcelable("MENU");
|
public void | onResume()
super.onResume();
appService.indicateMenuVisibility(true);
mStkMenu = appService.getMenu();
if (mStkMenu == null) {
finish();
return;
}
displayMenu();
startTimeOut();
// whenever this activity is resumed after a sub activity was invoked
// (Browser, In call screen) switch back to main state and enable
// user's input;
if (!mAcceptUsersInput) {
mState = STATE_MAIN;
mAcceptUsersInput = true;
}
// make sure the progress bar is not shown.
mProgressView.setIndeterminate(false);
mProgressView.setVisibility(View.GONE);
|
protected void | onSaveInstanceState(android.os.Bundle outState)
outState.putInt("STATE", mState);
outState.putParcelable("MENU", mStkMenu);
|
private void | sendResponse(int resId)
sendResponse(resId, 0, false);
|
private void | sendResponse(int resId, int itemId, boolean help)
Bundle args = new Bundle();
args.putInt(StkAppService.OPCODE, StkAppService.OP_RESPONSE);
args.putInt(StkAppService.RES_ID, resId);
args.putInt(StkAppService.MENU_SELECTION, itemId);
args.putBoolean(StkAppService.HELP, help);
mContext.startService(new Intent(mContext, StkAppService.class)
.putExtras(args));
|
private void | startTimeOut()
if (mState == STATE_SECONDARY) {
// Reset timeout.
cancelTimeOut();
mTimeoutHandler.sendMessageDelayed(mTimeoutHandler
.obtainMessage(MSG_ID_TIMEOUT), StkApp.UI_TIMEOUT);
}
|