Methods Summary |
---|
private void | confirmDeleteDialog(android.content.DialogInterface.OnClickListener listener, int messageId)
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.confirm_dialog_title);
builder.setIcon(android.R.drawable.ic_dialog_alert);
builder.setCancelable(true);
builder.setPositiveButton(R.string.yes, listener);
builder.setNegativeButton(R.string.no, null);
builder.setMessage(messageId);
builder.show();
|
private void | copyToPhoneMemory(android.database.Cursor cursor)
String address = cursor.getString(
cursor.getColumnIndexOrThrow("address"));
String body = cursor.getString(cursor.getColumnIndexOrThrow("body"));
Long date = cursor.getLong(cursor.getColumnIndexOrThrow("date"));
try {
if (isIncomingMessage(cursor)) {
Sms.Inbox.addMessage(mContentResolver, address, body, null, date, true);
} else {
Sms.Sent.addMessage(mContentResolver, address, body, null, date);
}
} catch (SQLiteException e) {
SqliteWrapper.checkSQLiteException(this, e);
}
|
private void | deleteAllFromSim()
Cursor cursor = (Cursor) mListAdapter.getCursor();
if (cursor != null) {
if (cursor.moveToFirst()) {
int count = cursor.getCount();
for (int i = 0; i < count; ++i) {
deleteFromSim(cursor);
cursor.moveToNext();
}
}
}
|
private void | deleteFromSim(android.database.Cursor cursor)
String messageIndexString =
cursor.getString(cursor.getColumnIndexOrThrow("index_on_sim"));
Uri simUri = SIM_URI.buildUpon().appendPath(messageIndexString).build();
SqliteWrapper.delete(this, mContentResolver, simUri, null, null);
|
private void | init()
MessagingNotification.cancelNotification(getApplicationContext(),
SIM_FULL_NOTIFICATION_ID);
updateState(SHOW_BUSY);
startQuery();
|
private boolean | isIncomingMessage(android.database.Cursor cursor)
int messageStatus = cursor.getInt(
cursor.getColumnIndexOrThrow("status"));
return (messageStatus == SmsManager.STATUS_ON_SIM_READ) ||
(messageStatus == SmsManager.STATUS_ON_SIM_UNREAD);
|
public boolean | onContextItemSelected(android.view.MenuItem item)
AdapterView.AdapterContextMenuInfo info;
try {
info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
} catch (ClassCastException exception) {
Log.e(TAG, "Bad menuInfo.", exception);
return false;
}
final Cursor cursor = (Cursor) mListAdapter.getItem(info.position);
switch (item.getItemId()) {
case MENU_COPY_TO_PHONE_MEMORY:
copyToPhoneMemory(cursor);
return true;
case MENU_DELETE_FROM_SIM:
confirmDeleteDialog(new OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
updateState(SHOW_BUSY);
deleteFromSim(cursor);
}
}, R.string.confirm_delete_SIM_message);
return true;
case MENU_VIEW:
viewMessage(cursor);
return true;
}
return super.onContextItemSelected(item);
|
protected void | onCreate(android.os.Bundle icicle)
super.onCreate(icicle);
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
mContentResolver = getContentResolver();
mQueryHandler = new QueryHandler(mContentResolver, this);
setContentView(R.layout.sim_list);
mSimList = (ListView) findViewById(R.id.messages);
mMessage = (TextView) findViewById(R.id.empty_message);
init();
|
public void | onCreateContextMenu(android.view.ContextMenu menu, android.view.View v, ContextMenu.ContextMenuInfo menuInfo)
menu.add(0, MENU_COPY_TO_PHONE_MEMORY, 0,
R.string.sim_copy_to_phone_memory);
menu.add(0, MENU_DELETE_FROM_SIM, 0, R.string.sim_delete);
// TODO: Enable this once viewMessage is written.
// menu.add(0, MENU_VIEW, 0, R.string.sim_view);
|
protected void | onNewIntent(android.content.Intent intent)
setIntent(intent);
init();
|
public boolean | onOptionsItemSelected(android.view.MenuItem item)
switch (item.getItemId()) {
case OPTION_MENU_DELETE_ALL:
confirmDeleteDialog(new OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
updateState(SHOW_BUSY);
deleteAllFromSim();
}
}, R.string.confirm_delete_all_SIM_messages);
break;
}
return true;
|
public void | onPause()
super.onPause();
mContentResolver.unregisterContentObserver(simChangeObserver);
|
public boolean | onPrepareOptionsMenu(android.view.Menu menu)
menu.clear();
if ((null != mCursor) && (mCursor.getCount() > 0) && mState == SHOW_LIST) {
menu.add(0, OPTION_MENU_DELETE_ALL, 0, R.string.menu_delete_messages).setIcon(
android.R.drawable.ic_menu_delete);
}
return true;
|
public void | onResume()
super.onResume();
registerSimChangeObserver();
|
private void | refreshMessageList()
updateState(SHOW_BUSY);
if (mCursor != null) {
stopManagingCursor(mCursor);
mCursor.close();
}
startQuery();
|
private void | registerSimChangeObserver()
mContentResolver.registerContentObserver(
SIM_URI, true, simChangeObserver);
|
private void | startQuery()
try {
mQueryHandler.startQuery(0, null, SIM_URI, null, null, null, null);
} catch (SQLiteException e) {
SqliteWrapper.checkSQLiteException(this, e);
}
|
private void | updateState(int state)
if (mState == state) {
return;
}
mState = state;
switch (state) {
case SHOW_LIST:
mSimList.setVisibility(View.VISIBLE);
mMessage.setVisibility(View.GONE);
setTitle(getString(R.string.sim_manage_messages_title));
setProgressBarIndeterminateVisibility(false);
break;
case SHOW_EMPTY:
mSimList.setVisibility(View.GONE);
mMessage.setVisibility(View.VISIBLE);
setTitle(getString(R.string.sim_manage_messages_title));
setProgressBarIndeterminateVisibility(false);
break;
case SHOW_BUSY:
mSimList.setVisibility(View.GONE);
mMessage.setVisibility(View.GONE);
setTitle(getString(R.string.refreshing));
setProgressBarIndeterminateVisibility(true);
break;
default:
Log.e(TAG, "Invalid State");
}
|
private void | viewMessage(android.database.Cursor cursor)
// TODO: Add this.
|