Search in sources :

Example 6 with ImApp

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

the class ContactsListFragment method unarchiveContact.

private static void unarchiveContact(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, false);
        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 7 with ImApp

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

the class ContactsListFragment method deleteContact.

private static void deleteContact(Activity activity, long itemId, String address, long providerId, long accountId) {
    try {
        IImConnection mConn;
        ImApp app = ((ImApp) activity.getApplication());
        mConn = app.getConnection(providerId, accountId);
        // first leave, delete an existing chat session
        IChatSessionManager sessionMgr = mConn.getChatSessionManager();
        if (sessionMgr != null) {
            IChatSession session = sessionMgr.getChatSession(Address.stripResource(address));
        }
        // then delete the contact from our list
        IContactListManager manager = mConn.getContactListManager();
        int res = manager.removeContact(address);
        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) IChatSessionManager(org.awesomeapp.messenger.service.IChatSessionManager) ImApp(org.awesomeapp.messenger.ImApp) IContactListManager(org.awesomeapp.messenger.service.IContactListManager) RemoteException(android.os.RemoteException) IChatSession(org.awesomeapp.messenger.service.IChatSession) Paint(android.graphics.Paint)

Example 8 with ImApp

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

the class ContactsPickerActivity method onCreate.

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    getSupportActionBar().setDisplayShowHomeEnabled(true);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    ((ImApp) getApplication()).setAppTheme(this);
    setContentView(R.layout.contacts_picker_activity);
    if (getIntent().getData() != null)
        mUri = getIntent().getData();
    mLayoutContactSelect = findViewById(R.id.layoutContactSelect);
    mLayoutGroupSelect = findViewById(R.id.layoutGroupSelect);
    mSelectedContacts = (FlowLayout) findViewById(R.id.flSelectedContacts);
    mSelectedContacts.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {

        @Override
        public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
            // When the tag view grows we don't want the list to jump around, so
            // compensate for this by trying to scroll the list.
            final int diff = bottom - oldBottom;
            ListViewCompat.scrollListBy(mListView, diff);
        }
    });
    boolean isGroupOnlyMode = isGroupOnlyMode();
    excludedContacts = getIntent().getStringArrayListExtra(EXTRA_EXCLUDED_CONTACTS);
    mShowGroups = getIntent().getBooleanExtra(EXTRA_SHOW_GROUPS, false);
    View btnCreateGroup = findViewById(R.id.btnCreateGroup);
    btnCreateGroup.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            setGroupMode(true);
        }
    });
    btnCreateGroup.setVisibility(isGroupOnlyMode ? View.GONE : View.VISIBLE);
    View btnAddContact = findViewById(R.id.btnAddFriend);
    btnAddContact.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent i = new Intent(ContactsPickerActivity.this, AddContactActivity.class);
            startActivityForResult(i, REQUEST_CODE_ADD_CONTACT);
        }
    });
    btnAddContact.setVisibility(isGroupOnlyMode ? View.GONE : View.VISIBLE);
    // Make sure the tag view can not be more than a third of the screen
    View root = findViewById(R.id.llRoot);
    if (root != null) {
        root.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {

            @Override
            public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
                if ((bottom - top) != (oldBottom - oldTop)) {
                    ViewGroup.LayoutParams lp = mSelectedContacts.getLayoutParams();
                    lp.height = (bottom - top) / 3;
                    mSelectedContacts.setLayoutParams(lp);
                }
            }
        });
    }
    mListView = (ListView) findViewById(R.id.contactsList);
    setGroupMode(isGroupOnlyMode);
    mListView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(AdapterView<?> adapterView, View view, int i, long l) {
            multiStart(i);
            return true;
        }
    });
    // Uncomment this to set as list view header instead.
    // ((ViewGroup)mSelectedContacts.getParent()).removeView(mSelectedContacts);
    // mSelectedContacts.setLayoutParams(new AbsListView.LayoutParams(AbsListView.LayoutParams.MATCH_PARENT, AbsListView.LayoutParams.WRAP_CONTENT));
    // mListView.addHeaderView(mSelectedContacts);
    mListView.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, int position, long id) {
            if (mListView.getChoiceMode() == ListView.CHOICE_MODE_MULTIPLE) {
                if (isSelected(id)) {
                    unselect(id);
                } else {
                    select(position);
                }
            } else {
                Cursor cursor = (Cursor) mAdapter.getItem(position);
                Intent data = new Intent();
                data.putExtra(EXTRA_RESULT_USERNAME, cursor.getString(ContactListItem.COLUMN_CONTACT_USERNAME));
                data.putExtra(EXTRA_RESULT_PROVIDER, cursor.getLong(ContactListItem.COLUMN_CONTACT_PROVIDER));
                data.putExtra(EXTRA_RESULT_ACCOUNT, cursor.getLong(ContactListItem.COLUMN_CONTACT_ACCOUNT));
                setResult(RESULT_OK, data);
                finish();
            }
        }
    });
    doFilterAsync("");
}
Also used : OnItemClickListener(android.widget.AdapterView.OnItemClickListener) ImApp(org.awesomeapp.messenger.ImApp) Intent(android.content.Intent) Cursor(android.database.Cursor) SearchView(android.support.v7.widget.SearchView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) AdapterView(android.widget.AdapterView)

Example 9 with ImApp

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

the class ConversationListItem method getEncryptionState.

private void getEncryptionState(long providerId, long accountId, String address, ConversationViewHolder holder) {
    try {
        ImApp app = ((ImApp) ((Activity) getContext()).getApplication());
        IImConnection conn = app.getConnection(providerId, accountId);
        if (conn == null || conn.getChatSessionManager() == null)
            return;
        IChatSession chatSession = conn.getChatSessionManager().getChatSession(address);
        if (chatSession != null) {
            if (chatSession.isEncrypted()) {
                holder.mStatusIcon.setImageDrawable(getResources().getDrawable(R.drawable.ic_encrypted_grey));
                holder.mStatusIcon.setVisibility(View.VISIBLE);
            }
        }
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
// mCurrentChatSession.getOtrChatSession();
}
Also used : IImConnection(org.awesomeapp.messenger.service.IImConnection) Activity(android.app.Activity) ImApp(org.awesomeapp.messenger.ImApp) IChatSession(org.awesomeapp.messenger.service.IChatSession)

Example 10 with ImApp

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

the class SimpleAlertHandler method unregisterForBroadcastEvents.

public void unregisterForBroadcastEvents() {
    ImApp app = (ImApp) mActivity.getApplication();
    app.unregisterForBroadcastEvent(ImApp.EVENT_CONNECTION_DISCONNECTED, this);
}
Also used : ImApp(org.awesomeapp.messenger.ImApp)

Aggregations

ImApp (org.awesomeapp.messenger.ImApp)21 RemoteException (android.os.RemoteException)10 IImConnection (org.awesomeapp.messenger.service.IImConnection)8 IContactListManager (org.awesomeapp.messenger.service.IContactListManager)6 IOException (java.io.IOException)5 Activity (android.app.Activity)4 Intent (android.content.Intent)4 View (android.view.View)4 Cursor (android.database.Cursor)3 Paint (android.graphics.Paint)3 TextView (android.widget.TextView)3 XmppAddress (org.awesomeapp.messenger.plugin.xmpp.XmppAddress)3 IChatSession (org.awesomeapp.messenger.service.IChatSession)3 BitmapDrawable (android.graphics.drawable.BitmapDrawable)2 CropImageView (com.theartofdev.edmodo.cropper.CropImageView)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 Contact (org.awesomeapp.messenger.model.Contact)2 Imps (org.awesomeapp.messenger.provider.Imps)2 AddContactAsyncTask (org.awesomeapp.messenger.tasks.AddContactAsyncTask)2 AlertDialog (android.app.AlertDialog)1