Search in sources :

Example 21 with IImConnection

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

the class ContactListFilterView method removeContact.

void removeContact(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 = manager.removeContact(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_delete_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)

Example 22 with IImConnection

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

the class SignInHelper method signInAccountAsync.

private void signInAccountAsync(String password, long providerId, String providerName, long accountId) throws RemoteException {
    boolean autoLoadContacts = true;
    boolean autoRetryLogin = true;
    IImConnection conn = null;
    conn = mApp.getConnection(providerId, accountId);
    if (conn != null) {
        connections.add(conn);
        conn.registerConnectionListener(mListener);
        int state = conn.getState();
        if (mSignInListener != null)
            mSignInListener.stateChanged(state, accountId);
        if (state != ImConnection.DISCONNECTED) {
            // already signed in or in the process
            if (state == ImConnection.LOGGED_IN) {
                connections.remove(conn);
                conn.unregisterConnectionListener(mListener);
            }
            handleConnectionEvent(conn, state, null);
            return;
        }
    } else {
        conn = mApp.createConnection(providerId, accountId);
        if (conn == null) {
            // This can happen when service did not come up for any reason
            return;
        }
        connections.add(conn);
        conn.registerConnectionListener(mListener);
    }
    conn.login(password, autoLoadContacts, autoRetryLogin);
/*
            if (mApp.isNetworkAvailableAndConnected()) {

            } else {
             //   promptForBackgroundDataSetting(providerName);
                return;
            }*/
}
Also used : IImConnection(org.awesomeapp.messenger.service.IImConnection)

Example 23 with IImConnection

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

the class ImApp method deleteAccount.

public static void deleteAccount(ContentResolver resolver, long accountId, long providerId) {
    IImConnection conn = getConnection(providerId, accountId);
    Uri accountUri = ContentUris.withAppendedId(Imps.Account.CONTENT_URI, accountId);
    resolver.delete(accountUri, null, null);
    Uri providerUri = ContentUris.withAppendedId(Imps.Provider.CONTENT_URI, providerId);
    resolver.delete(providerUri, null, null);
    Uri.Builder builder = Imps.Contacts.CONTENT_URI_CONTACTS_BY.buildUpon();
    ContentUris.appendId(builder, providerId);
    ContentUris.appendId(builder, accountId);
    resolver.delete(builder.build(), null, null);
}
Also used : IImConnection(org.awesomeapp.messenger.service.IImConnection) Uri(android.net.Uri)

Example 24 with IImConnection

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

the class ImApp method getChatSession.

public IChatSession getChatSession(long providerId, long accountId, String remoteAddress) {
    IImConnection conn = getConnection(providerId, accountId);
    IChatSessionManager chatSessionManager = null;
    if (conn != null) {
        try {
            chatSessionManager = conn.getChatSessionManager();
        } catch (RemoteException e) {
            Log.e(LOG_TAG, "error in getting ChatSessionManager", e);
        }
    }
    if (chatSessionManager != null) {
        try {
            return chatSessionManager.getChatSession(remoteAddress);
        } catch (RemoteException e) {
            Log.e(LOG_TAG, "error in getting ChatSession", e);
        }
    }
    return null;
}
Also used : IImConnection(org.awesomeapp.messenger.service.IImConnection) IChatSessionManager(org.awesomeapp.messenger.service.IChatSessionManager) RemoteException(android.os.RemoteException)

Example 25 with IImConnection

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

the class MainActivity method showGroupChatDialog.

public void showGroupChatDialog() {
    // This example shows how to add a custom layout to an AlertDialog
    LayoutInflater factory = LayoutInflater.from(this);
    final View dialogGroup = factory.inflate(R.layout.alert_dialog_group_chat, null);
    // TextView tvServer = (TextView) dialogGroup.findViewById(R.id.chat_server);
    // tvServer.setText(ImApp.DEFAULT_GROUPCHAT_SERVER);// need to make this a list
    // final Spinner listAccounts = (Spinner) dialogGroup.findViewById(R.id.choose_list);
    // setupAccountSpinner(listAccounts);
    AlertDialog dialog = new AlertDialog.Builder(this).setTitle(R.string.create_group).setView(dialogGroup).setPositiveButton(R.string.connect, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int whichButton) {
            /* User clicked OK so do some stuff */
            String chatRoom = null;
            String chatServer = "";
            String nickname = "";
            TextView tv = (TextView) dialogGroup.findViewById(R.id.chat_room);
            chatRoom = tv.getText().toString();
            try {
                IImConnection conn = mApp.getConnection(mApp.getDefaultProviderId(), mApp.getDefaultAccountId());
                if (conn.getState() == ImConnection.LOGGED_IN)
                    startGroupChat(chatRoom, chatServer, nickname, null, conn);
            } catch (RemoteException re) {
            }
            dialog.dismiss();
        }
    }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int whichButton) {
            /* User clicked cancel so do some stuff */
            dialog.dismiss();
        }
    }).create();
    dialog.show();
    Typeface typeface;
    if ((typeface = CustomTypefaceManager.getCurrentTypeface(this)) != null) {
        TextView textView = (TextView) dialog.findViewById(android.R.id.message);
        if (textView != null)
            textView.setTypeface(typeface);
        textView = (TextView) dialog.findViewById(R.id.alertTitle);
        if (textView != null)
            textView.setTypeface(typeface);
        Button btn = (Button) dialog.findViewById(android.R.id.button1);
        if (btn != null)
            btn.setTypeface(typeface);
        btn = (Button) dialog.findViewById(android.R.id.button2);
        if (btn != null)
            btn.setTypeface(typeface);
        btn = (Button) dialog.findViewById(android.R.id.button3);
        if (btn != null)
            btn.setTypeface(typeface);
    }
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) Typeface(android.graphics.Typeface) SearchView(android.support.v7.widget.SearchView) View(android.view.View) TextView(android.widget.TextView) IImConnection(org.awesomeapp.messenger.service.IImConnection) Button(android.widget.Button) FloatingActionButton(android.support.design.widget.FloatingActionButton) LayoutInflater(android.view.LayoutInflater) TextView(android.widget.TextView) 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