Search in sources :

Example 26 with AdapterContextMenuInfo

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());
}
Also used : AdapterContextMenuInfo(android.widget.AdapterView.AdapterContextMenuInfo)

Example 27 with AdapterContextMenuInfo

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);
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) AdapterContextMenuInfo(android.widget.AdapterView.AdapterContextMenuInfo) Intent(android.content.Intent) Cursor(android.database.Cursor)

Example 28 with AdapterContextMenuInfo

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);
    }
}
Also used : AdapterContextMenuInfo(android.widget.AdapterView.AdapterContextMenuInfo) Intent(android.content.Intent) Cursor(android.database.Cursor)

Example 29 with AdapterContextMenuInfo

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);
    }
}
Also used : MenuInflater(android.view.MenuInflater) AdapterContextMenuInfo(android.widget.AdapterView.AdapterContextMenuInfo) Cursor(android.database.Cursor)

Example 30 with AdapterContextMenuInfo

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);
    }
}
Also used : AdapterContextMenuInfo(android.widget.AdapterView.AdapterContextMenuInfo)

Aggregations

AdapterContextMenuInfo (android.widget.AdapterView.AdapterContextMenuInfo)32 Intent (android.content.Intent)9 MenuItem (android.view.MenuItem)6 Cursor (android.database.Cursor)5 PrinterInfo (android.print.PrinterInfo)5 MenuInflater (android.view.MenuInflater)4 ContextMenuInfo (android.view.ContextMenu.ContextMenuInfo)2 Account (com.fsck.k9.Account)2 MalformedURLException (java.net.MalformedURLException)2 AlertDialog (android.app.AlertDialog)1 DialogInterface (android.content.DialogInterface)1 ContextMenu (android.view.ContextMenu)1 SubMenu (android.view.SubMenu)1 AdapterView (android.widget.AdapterView)1 carnero.cgeo.filter.cgFilterBySize (carnero.cgeo.filter.cgFilterBySize)1 carnero.cgeo.filter.cgFilterByType (carnero.cgeo.filter.cgFilterByType)1 BaseAccount (com.fsck.k9.BaseAccount)1 Identity (com.fsck.k9.Identity)1 SearchAccount (com.fsck.k9.search.SearchAccount)1 BaseEntity (com.xabber.android.data.entity.BaseEntity)1