use of android.widget.AdapterView.AdapterContextMenuInfo in project Conversations by siacs.
the class ManageAccountActivity method onCreateContextMenu.
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
ManageAccountActivity.this.getMenuInflater().inflate(R.menu.manageaccounts_context, menu);
AdapterContextMenuInfo acmi = (AdapterContextMenuInfo) menuInfo;
this.selectedAccount = accountList.get(acmi.position);
if (this.selectedAccount.isOptionSet(Account.OPTION_DISABLED)) {
menu.findItem(R.id.mgmt_account_disable).setVisible(false);
menu.findItem(R.id.mgmt_account_announce_pgp).setVisible(false);
menu.findItem(R.id.mgmt_account_publish_avatar).setVisible(false);
menu.findItem(R.id.mgmt_account_change_presence).setVisible(false);
} else {
menu.findItem(R.id.mgmt_account_enable).setVisible(false);
menu.findItem(R.id.mgmt_account_announce_pgp).setVisible(Config.supportOpenPgp());
menu.findItem(R.id.mgmt_account_change_presence).setVisible(manuallyChangePresence());
}
menu.setHeaderTitle(this.selectedAccount.getJid().toBareJid().toString());
}
use of android.widget.AdapterView.AdapterContextMenuInfo in project K6nele by Kaljurand.
the class GrammarListActivity method onContextItemSelected.
@Override
public boolean onContextItemSelected(MenuItem item) {
final AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
Cursor cursor = (Cursor) getListView().getItemAtPosition(info.position);
final long key = cursor.getLong(cursor.getColumnIndex(Grammar.Columns._ID));
String name = cursor.getString(cursor.getColumnIndex(Grammar.Columns.NAME));
String grammarName = cursor.getString(cursor.getColumnIndex(Grammar.Columns.NAME));
String grammarLang = cursor.getString(cursor.getColumnIndex(Grammar.Columns.LANG));
String grammarUrl = cursor.getString(cursor.getColumnIndex(Grammar.Columns.URL));
switch(item.getItemId()) {
case R.id.cmGrammarView:
Intent intentView = new Intent();
intentView.setAction(Intent.ACTION_VIEW);
intentView.setDataAndType(Uri.parse(grammarUrl), "text/plain");
startActivity(intentView);
return true;
case R.id.cmGrammarEditName:
Utils.getTextEntryDialog(this, getString(R.string.dialogTitleChangeGrammarName), grammarName, new ExecutableString() {
public void execute(String name) {
if (name != null && name.length() == 0) {
name = null;
}
update(CONTENT_URI, key, Grammar.Columns.NAME, name);
}
}).show();
return true;
case R.id.cmGrammarEditLang:
Utils.getTextEntryDialog(this, getString(R.string.dialogTitleChangeGrammarLang), grammarLang, new ExecutableString() {
public void execute(String lang) {
if (lang != null && lang.length() == 0) {
lang = null;
}
update(CONTENT_URI, key, Grammar.Columns.LANG, lang);
}
}).show();
return true;
case R.id.cmGrammarEditUrl:
Utils.getTextEntryDialog(this, getString(R.string.dialogTitleChangeGrammarUrl), grammarUrl, new ExecutableString() {
public void execute(String newUrl) {
try {
updateUrl(CONTENT_URI, key, Grammar.Columns.URL, newUrl);
} catch (MalformedURLException e) {
toast(getString(R.string.exceptionMalformedUrl));
}
}
}).show();
return true;
case R.id.cmGrammarDelete:
Utils.getYesNoDialog(this, String.format(getString(R.string.confirmDeleteEntry), name), new Executable() {
public void execute() {
delete(CONTENT_URI, key);
}
}).show();
return true;
default:
return super.onContextItemSelected(item);
}
}
use of android.widget.AdapterView.AdapterContextMenuInfo in project K6nele by Kaljurand.
the class AppListActivity method onContextItemSelected.
@Override
public boolean onContextItemSelected(MenuItem item) {
final AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
Cursor cursor = (Cursor) getListView().getItemAtPosition(info.position);
final long key = cursor.getLong(cursor.getColumnIndex(App.Columns._ID));
String fname = cursor.getString(cursor.getColumnIndex(App.Columns.FNAME));
mCurrentAppId = key;
switch(item.getItemId()) {
case R.id.cmAppAssignGrammar:
Intent pickSpeakerIntent = new Intent(AppListActivity.this, GrammarListActivity.class);
startActivityForResult(pickSpeakerIntent, ACTIVITY_SELECT_GRAMMAR_URL);
return true;
case R.id.cmAppRemoveGrammar:
Utils.getYesNoDialog(this, getString(R.string.confirmRemoveGrammar), new Executable() {
public void execute() {
removeApp(key, App.Columns.GRAMMAR);
}
}).show();
return true;
case R.id.cmAppAssignServer:
Intent intentServer = new Intent(AppListActivity.this, ServerListActivity.class);
startActivityForResult(intentServer, ACTIVITY_SELECT_SERVER_URL);
return true;
case R.id.cmAppRemoveServer:
Utils.getYesNoDialog(this, getString(R.string.confirmRemoveServer), new Executable() {
public void execute() {
removeApp(key, App.Columns.SERVER);
}
}).show();
return true;
case R.id.cmAppDelete:
Utils.getYesNoDialog(this, String.format(getString(R.string.confirmDeleteEntry), fname), new Executable() {
public void execute() {
delete(CONTENT_URI, key);
}
}).show();
return true;
default:
return super.onContextItemSelected(item);
}
}
use of android.widget.AdapterView.AdapterContextMenuInfo in project K6nele by Kaljurand.
the class AppListActivity method onCreateContextMenu.
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.cm_app, menu);
// Disable some menu items if they do not make sense in this context.
// We could also remove them but this might be confusing for the user.
final AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
Cursor c = (Cursor) getListView().getItemAtPosition(info.position);
long grammarId = c.getLong(c.getColumnIndex(App.Columns.GRAMMAR));
long serverId = c.getLong(c.getColumnIndex(App.Columns.SERVER));
if (grammarId == 0) {
menu.findItem(R.id.cmAppRemoveGrammar).setEnabled(false);
}
if (serverId == 0) {
menu.findItem(R.id.cmAppRemoveServer).setEnabled(false);
}
}
use of android.widget.AdapterView.AdapterContextMenuInfo in project UltimateAndroid by cymcsg.
the class TeamList method onContextItemSelected.
public boolean onContextItemSelected(MenuItem item) {
AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
switch(item.getItemId()) {
case R.id.delete_team:
positionOfTeamToDelete = info.position;
showDialog(CONFIRM_DELETE_DIALOG);
return true;
default:
return super.onContextItemSelected(item);
}
}
Aggregations