Search in sources :

Example 16 with IImConnection

use of org.awesomeapp.messenger.service.IImConnection in project Zom-Android by zom.

the class ContactsListFragment method archiveContact.

private static void archiveContact(Activity activity, String address, int contactType, long providerId, long accountId) {
    try {
        IImConnection mConn;
        ImApp app = ((ImApp) activity.getApplication());
        mConn = app.getConnection(providerId, accountId);
        // then delete the contact from our list
        IContactListManager manager = mConn.getContactListManager();
        int res = manager.archiveContact(address, contactType, true);
        if (res != ImErrorInfo.NO_ERROR) {
        // mHandler.showAlert(R.string.error,
        // ErrorResUtils.getErrorRes(getResources(), res, address));
        }
    } catch (RemoteException re) {
    }
}
Also used : IImConnection(org.awesomeapp.messenger.service.IImConnection) ImApp(org.awesomeapp.messenger.ImApp) IContactListManager(org.awesomeapp.messenger.service.IContactListManager) RemoteException(android.os.RemoteException) Paint(android.graphics.Paint)

Example 17 with IImConnection

use of org.awesomeapp.messenger.service.IImConnection in project Zom-Android by zom.

the class AddContactAsyncTask method addToContactList.

private int addToContactList(String address, String otrFingperint, String nickname) {
    int res = -1;
    try {
        IImConnection conn = mApp.getConnection(mProviderId, mAccountId);
        if (conn == null)
            conn = mApp.createConnection(mProviderId, mAccountId);
        IContactList list = getContactList(conn);
        if (list != null) {
            res = list.addContact(address, nickname);
            if (res != ImErrorInfo.NO_ERROR) {
            // what to do here?
            }
            if (!TextUtils.isEmpty(otrFingperint)) {
                OtrAndroidKeyManagerImpl.getInstance(mApp).verifyUser(address, otrFingperint);
            }
        }
    } catch (RemoteException re) {
        Log.e(ImApp.LOG_TAG, "error adding contact", re);
    }
    return res;
}
Also used : IImConnection(org.awesomeapp.messenger.service.IImConnection) IContactList(org.awesomeapp.messenger.service.IContactList) RemoteException(android.os.RemoteException)

Example 18 with IImConnection

use of org.awesomeapp.messenger.service.IImConnection in project Zom-Android by zom.

the class AccountActivity method signOut.

void signOut(long providerId, long accountId) {
    try {
        IImConnection conn = mApp.getConnection(providerId, accountId);
        if (conn != null) {
            conn.logout();
        } else {
            // Normally, we can always get the connection when user chose to
            // sign out. However, if the application crash unexpectedly, the
            // status will never be updated. Clear the status in this case
            // to make it recoverable from the crash.
            ContentValues values = new ContentValues(2);
            values.put(Imps.AccountStatusColumns.PRESENCE_STATUS, Imps.CommonPresenceColumns.OFFLINE);
            values.put(Imps.AccountStatusColumns.CONNECTION_STATUS, Imps.ConnectionStatus.OFFLINE);
            String where = Imps.AccountStatusColumns.ACCOUNT + "=?";
            getContentResolver().update(Imps.AccountStatus.CONTENT_URI, values, where, new String[] { Long.toString(accountId) });
        }
    } catch (RemoteException ex) {
        Log.e(ImApp.LOG_TAG, "signout: caught ", ex);
    } finally {
        // Toast.makeText(this,
        // getString(R.string.signed_out_prompt, this.mEditUserAccount.getText()),
        // Toast.LENGTH_SHORT).show();
        isSignedIn = false;
    // mBtnSignIn.setText(getString(R.string.sign_in));
    // mBtnSignIn.setBackgroundResource(R.drawable.btn_green);
    }
}
Also used : IImConnection(org.awesomeapp.messenger.service.IImConnection) ContentValues(android.content.ContentValues) RemoteException(android.os.RemoteException)

Example 19 with IImConnection

use of org.awesomeapp.messenger.service.IImConnection in project Zom-Android by zom.

the class ContactListFilterView method setContactNickname.

private void setContactNickname(int aPosition) {
    Cursor cursor = (Cursor) mFilterList.getItemAtPosition(aPosition);
    final IImConnection conn = getConnection(cursor);
    final String address = cursor.getString(cursor.getColumnIndexOrThrow(Imps.Contacts.USERNAME));
    final String nickname = cursor.getString(cursor.getColumnIndexOrThrow(Imps.Contacts.NICKNAME));
    final View view = LayoutInflater.from(mContext).inflate(R.layout.alert_dialog_contact_nickname, null);
    ((TextView) view.findViewById(R.id.contact_address_textview)).setText(address);
    ((EditText) view.findViewById(R.id.contact_nickname_edittext)).setText(nickname);
    new AlertDialog.Builder(mContext).setTitle(mContext.getString(R.string.menu_contact_nickname, nickname)).setView(view).setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
            final String newNickname = ((EditText) view.findViewById(R.id.contact_nickname_edittext)).getText().toString();
            new Handler().postDelayed(new Runnable() {

                @Override
                public void run() {
                    setContactNickname(address, newNickname, conn);
                }
            }, 500);
        }
    }).setNegativeButton(R.string.cancel, null).show();
}
Also used : EditText(android.widget.EditText) AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) Handler(android.os.Handler) Cursor(android.database.Cursor) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) AbsListView(android.widget.AbsListView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) ListView(android.widget.ListView) IImConnection(org.awesomeapp.messenger.service.IImConnection) TextView(android.widget.TextView)

Example 20 with IImConnection

use of org.awesomeapp.messenger.service.IImConnection in project Zom-Android by zom.

the class ContactListFilterView method blockContact.

void blockContact(Cursor c) {
    final IImConnection conn = getConnection(c);
    String nickname = c.getString(c.getColumnIndexOrThrow(Imps.Contacts.NICKNAME));
    final String address = c.getString(c.getColumnIndexOrThrow(Imps.Contacts.USERNAME));
    DialogInterface.OnClickListener confirmListener = new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int whichButton) {
            try {
                IContactListManager manager = conn.getContactListManager();
                int res = -1;
                if (manager.isBlocked(address))
                    res = manager.unBlockContact(address);
                else {
                    res = manager.blockContact(address);
                    if (res != ImErrorInfo.NO_ERROR) {
                        mHandler.showAlert(R.string.error, ErrorResUtils.getErrorRes(getResources(), res, address));
                    }
                }
            } catch (RemoteException e) {
                mHandler.showServiceErrorAlert(e.getLocalizedMessage());
                LogCleaner.error(ImApp.LOG_TAG, "remote error", e);
            }
        }
    };
    Resources r = getResources();
    new AlertDialog.Builder(mContext).setTitle(R.string.confirm).setMessage(r.getString(R.string.confirm_block_contact, nickname)).setPositiveButton(R.string.yes, // default button
    confirmListener).setNegativeButton(R.string.no, null).setCancelable(false).show();
}
Also used : IImConnection(org.awesomeapp.messenger.service.IImConnection) DialogInterface(android.content.DialogInterface) Resources(android.content.res.Resources) IContactListManager(org.awesomeapp.messenger.service.IContactListManager) RemoteException(android.os.RemoteException)

Aggregations

IImConnection (org.awesomeapp.messenger.service.IImConnection)25 RemoteException (android.os.RemoteException)21 IContactListManager (org.awesomeapp.messenger.service.IContactListManager)9 ImApp (org.awesomeapp.messenger.ImApp)8 Activity (android.app.Activity)4 ContentValues (android.content.ContentValues)4 DialogInterface (android.content.DialogInterface)4 Cursor (android.database.Cursor)3 Paint (android.graphics.Paint)3 Uri (android.net.Uri)3 View (android.view.View)3 TextView (android.widget.TextView)3 IChatSession (org.awesomeapp.messenger.service.IChatSession)3 AlertDialog (android.app.AlertDialog)2 Resources (android.content.res.Resources)2 SearchView (android.support.v7.widget.SearchView)2 Contact (org.awesomeapp.messenger.model.Contact)2 XmppAddress (org.awesomeapp.messenger.plugin.xmpp.XmppAddress)2 Imps (org.awesomeapp.messenger.provider.Imps)2 IChatSessionManager (org.awesomeapp.messenger.service.IChatSessionManager)2