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();
}
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;
}*/
}
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);
}
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;
}
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);
}
}
Aggregations