Search in sources :

Example 6 with AddContactAsyncTask

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);
}
Also used : AddContactAsyncTask(org.awesomeapp.messenger.tasks.AddContactAsyncTask) ImApp(org.awesomeapp.messenger.ImApp) Intent(android.content.Intent) MainActivity(org.awesomeapp.messenger.MainActivity) ProgressDialog(android.app.ProgressDialog)

Example 7 with AddContactAsyncTask

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);
            }
        }
    }
}
Also used : AlertDialog(android.app.AlertDialog) AddContactAsyncTask(org.awesomeapp.messenger.tasks.AddContactAsyncTask) DialogInterface(android.content.DialogInterface) ImApp(org.awesomeapp.messenger.ImApp) IOException(java.io.IOException) Uri(android.net.Uri) IOException(java.io.IOException) Bitmap(android.graphics.Bitmap) OnClickListener(android.view.View.OnClickListener) CropImageView(com.theartofdev.edmodo.cropper.CropImageView)

Aggregations

AddContactAsyncTask (org.awesomeapp.messenger.tasks.AddContactAsyncTask)7 Intent (android.content.Intent)5 OnboardingManager (org.awesomeapp.messenger.ui.onboarding.OnboardingManager)4 RemoteException (android.os.RemoteException)3 IOException (java.io.IOException)3 Uri (android.net.Uri)2 ImApp (org.awesomeapp.messenger.ImApp)2 AlertDialog (android.app.AlertDialog)1 ProgressDialog (android.app.ProgressDialog)1 DialogInterface (android.content.DialogInterface)1 Bitmap (android.graphics.Bitmap)1 Rfc822Token (android.text.util.Rfc822Token)1 OnClickListener (android.view.View.OnClickListener)1 CropImageView (com.theartofdev.edmodo.cropper.CropImageView)1 FileNotFoundException (java.io.FileNotFoundException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 Pattern (java.util.regex.Pattern)1 MainActivity (org.awesomeapp.messenger.MainActivity)1