use of org.awesomeapp.messenger.tasks.AddContactAsyncTask in project Zom-Android by zom.
the class ServicesActivity method onBotClicked.
@Override
public void onBotClicked(final String jid, final String nickname) {
ImApp app = (ImApp) getApplication();
final ProgressDialog dialog;
dialog = new ProgressDialog(this);
dialog.setMessage(getString(R.string.upgrade_progress_action));
dialog.setCancelable(true);
dialog.show();
new AddContactAsyncTask(app.getDefaultProviderId(), app.getDefaultAccountId(), app) {
@Override
protected void onPostExecute(Integer response) {
super.onPostExecute(response);
if (dialog.isShowing()) {
dialog.dismiss();
}
Intent intent = new Intent(ServicesActivity.this, MainActivity.class);
intent.putExtra("username", jid);
startActivity(intent);
finish();
}
}.execute(jid, null, nickname);
}
use of org.awesomeapp.messenger.tasks.AddContactAsyncTask in project Zom-Android by zom.
the class OnboardingActivity method onActivityResult.
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
ImApp mApp = (ImApp) getApplication();
mApp.initAccountInfo();
if (resultCode == RESULT_OK) {
if (requestCode == OnboardingManager.REQUEST_SCAN) {
showInviteScreen();
ArrayList<String> resultScans = data.getStringArrayListExtra("result");
for (String resultScan : resultScans) {
try {
// parse each string and if they are for a new user then add the user
OnboardingManager.DecodedInviteLink diLink = OnboardingManager.decodeInviteLink(resultScan);
new AddContactAsyncTask(mNewAccount.providerId, mNewAccount.accountId, mApp).execute(diLink.username, diLink.fingerprint, diLink.nickname);
// if they are for a group chat, then add the group
} catch (Exception e) {
Log.w(ImApp.LOG_TAG, "error parsing QR invite link", e);
}
}
if (resultScans.size() > 0) {
showMainScreen();
}
} else if (requestCode == OnboardingManager.REQUEST_CHOOSE_AVATAR) {
Uri imageUri = getPickImageResultUri(data);
if (imageUri == null)
return;
// (CropImageView)view.findViewById(R.id.CropImageView);
mCropImageView = new CropImageView(OnboardingActivity.this);
mCropImageView.setAspectRatio(1, 1);
mCropImageView.setFixedAspectRatio(true);
mCropImageView.setCropShape(CropImageView.CropShape.OVAL);
try {
Bitmap bmpThumbnail = SecureMediaStore.getThumbnailFile(OnboardingActivity.this, imageUri, 512);
mCropImageView.setImageBitmap(bmpThumbnail);
// Use the Builder class for convenient dialog construction
android.support.v7.app.AlertDialog.Builder builder = new android.support.v7.app.AlertDialog.Builder(OnboardingActivity.this);
builder.setView(mCropImageView).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
setAvatar(mCropImageView.getCroppedImage(), mNewAccount);
showInviteScreen();
delete(mOutputFileUri);
}
}).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// User cancelled the dialog
delete(mOutputFileUri);
}
});
// Create the AlertDialog object and return it
android.support.v7.app.AlertDialog dialog = builder.create();
dialog.show();
;
} catch (IOException ioe) {
Log.e(ImApp.LOG_TAG, "couldn't load avatar", ioe);
}
}
}
}
Aggregations