Search in sources :

Example 1 with ResourceContactPhoto

use of org.thoughtcrime.securesms.contacts.avatars.ResourceContactPhoto in project Signal-Android by signalapp.

the class GroupCreateActivity method initializeResources.

private void initializeResources() {
    RecipientsEditor recipientsEditor = ViewUtil.findById(this, R.id.recipients_text);
    PushRecipientsPanel recipientsPanel = ViewUtil.findById(this, R.id.recipients);
    lv = ViewUtil.findById(this, R.id.selected_contacts_list);
    avatar = ViewUtil.findById(this, R.id.avatar);
    groupName = ViewUtil.findById(this, R.id.group_name);
    creatingText = ViewUtil.findById(this, R.id.creating_group_text);
    SelectedRecipientsAdapter adapter = new SelectedRecipientsAdapter(this);
    adapter.setOnRecipientDeletedListener(this);
    lv.setAdapter(adapter);
    recipientsEditor.setHint(R.string.recipients_panel__add_members);
    recipientsPanel.setPanelChangeListener(this);
    findViewById(R.id.contacts_button).setOnClickListener(new AddRecipientButtonListener());
    avatar.setImageDrawable(new ResourceContactPhoto(R.drawable.ic_group_white_24dp).asDrawable(this, ContactColors.UNKNOWN_COLOR.toConversationColor(this)));
    avatar.setOnClickListener(view -> Crop.pickImage(GroupCreateActivity.this));
}
Also used : PushRecipientsPanel(org.thoughtcrime.securesms.components.PushRecipientsPanel) ResourceContactPhoto(org.thoughtcrime.securesms.contacts.avatars.ResourceContactPhoto) RecipientsEditor(org.thoughtcrime.securesms.contacts.RecipientsEditor) SelectedRecipientsAdapter(org.thoughtcrime.securesms.util.SelectedRecipientsAdapter)

Example 2 with ResourceContactPhoto

use of org.thoughtcrime.securesms.contacts.avatars.ResourceContactPhoto in project Signal-Android by signalapp.

the class ProfilePreference method refresh.

public void refresh() {
    if (profileNumberView == null)
        return;
    final Address localAddress = Address.fromSerialized(TextSecurePreferences.getLocalNumber(getContext()));
    final String profileName = TextSecurePreferences.getProfileName(getContext());
    GlideApp.with(getContext().getApplicationContext()).load(new ProfileContactPhoto(localAddress, String.valueOf(TextSecurePreferences.getProfileAvatarId(getContext())))).error(new ResourceContactPhoto(R.drawable.ic_camera_alt_white_24dp).asDrawable(getContext(), getContext().getResources().getColor(R.color.grey_400))).circleCrop().diskCacheStrategy(DiskCacheStrategy.ALL).into(avatarView);
    if (!TextUtils.isEmpty(profileName)) {
        profileNameView.setText(profileName);
    }
    profileNumberView.setText(localAddress.toPhoneString());
}
Also used : ProfileContactPhoto(org.thoughtcrime.securesms.contacts.avatars.ProfileContactPhoto) ResourceContactPhoto(org.thoughtcrime.securesms.contacts.avatars.ResourceContactPhoto) Address(org.thoughtcrime.securesms.database.Address)

Example 3 with ResourceContactPhoto

use of org.thoughtcrime.securesms.contacts.avatars.ResourceContactPhoto in project Signal-Android by WhisperSystems.

the class AvatarImageView method initialize.

private void initialize(@NonNull Context context, @Nullable AttributeSet attrs) {
    setScaleType(ScaleType.CENTER_CROP);
    if (attrs != null) {
        TypedArray typedArray = context.getTheme().obtainStyledAttributes(attrs, R.styleable.AvatarImageView, 0, 0);
        inverted = typedArray.getBoolean(R.styleable.AvatarImageView_inverted, false);
        size = typedArray.getInt(R.styleable.AvatarImageView_fallbackImageSize, SIZE_LARGE);
        typedArray.recycle();
    }
    outlinePaint = ThemeUtil.isDarkTheme(context) ? DARK_THEME_OUTLINE_PAINT : LIGHT_THEME_OUTLINE_PAINT;
    unknownRecipientDrawable = new ResourceContactPhoto(R.drawable.ic_profile_outline_40, R.drawable.ic_profile_outline_20).asDrawable(context, AvatarColor.UNKNOWN, inverted);
    blurred = false;
    chatColors = null;
}
Also used : ResourceContactPhoto(org.thoughtcrime.securesms.contacts.avatars.ResourceContactPhoto) TypedArray(android.content.res.TypedArray)

Example 4 with ResourceContactPhoto

use of org.thoughtcrime.securesms.contacts.avatars.ResourceContactPhoto in project Signal-Android by signalapp.

the class CreateProfileActivity method initializeResources.

private void initializeResources() {
    TextView skipButton = ViewUtil.findById(this, R.id.skip_button);
    TextView informationLabel = ViewUtil.findById(this, R.id.information_label);
    this.avatar = ViewUtil.findById(this, R.id.avatar);
    this.name = ViewUtil.findById(this, R.id.name);
    this.emojiToggle = ViewUtil.findById(this, R.id.emoji_toggle);
    this.emojiDrawer = ViewUtil.findById(this, R.id.emoji_drawer);
    this.container = ViewUtil.findById(this, R.id.container);
    this.finishButton = ViewUtil.findById(this, R.id.finish_button);
    this.reveal = ViewUtil.findById(this, R.id.reveal);
    this.nextIntent = getIntent().getParcelableExtra(NEXT_INTENT);
    this.avatar.setImageDrawable(new ResourceContactPhoto(R.drawable.ic_camera_alt_white_24dp).asDrawable(this, getResources().getColor(R.color.grey_400)));
    this.avatar.setOnClickListener(view -> Permissions.with(this).request(Manifest.permission.CAMERA, Manifest.permission.WRITE_EXTERNAL_STORAGE).ifNecessary().onAnyResult(this::handleAvatarSelectionWithPermissions).execute());
    this.name.addTextChangedListener(new TextWatcher() {

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
        }

        @Override
        public void afterTextChanged(Editable s) {
            if (s.toString().getBytes().length > ProfileCipher.NAME_PADDED_LENGTH) {
                name.setError(getString(R.string.CreateProfileActivity_too_long));
                finishButton.setEnabled(false);
            } else if (name.getError() != null || !finishButton.isEnabled()) {
                name.setError(null);
                finishButton.setEnabled(true);
            }
        }
    });
    this.finishButton.setOnClickListener(view -> {
        this.finishButton.setIndeterminateProgressMode(true);
        this.finishButton.setProgress(50);
        handleUpload();
    });
    skipButton.setOnClickListener(view -> {
        if (nextIntent != null)
            startActivity(nextIntent);
        finish();
    });
    informationLabel.setOnClickListener(view -> {
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setData(Uri.parse("https://support.signal.org/hc/en-us/articles/115001434171"));
        if (getPackageManager().queryIntentActivities(intent, 0).size() > 0) {
            startActivity(intent);
        }
    });
}
Also used : ResourceContactPhoto(org.thoughtcrime.securesms.contacts.avatars.ResourceContactPhoto) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) TextView(android.widget.TextView) Intent(android.content.Intent) SuppressLint(android.annotation.SuppressLint)

Example 5 with ResourceContactPhoto

use of org.thoughtcrime.securesms.contacts.avatars.ResourceContactPhoto in project Signal-Android by signalapp.

the class CreateProfileActivity method onActivityResult.

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    switch(requestCode) {
        case REQUEST_CODE_AVATAR:
            if (resultCode == Activity.RESULT_OK) {
                Uri outputFile = Uri.fromFile(new File(getCacheDir(), "cropped"));
                Uri inputFile = (data != null ? data.getData() : null);
                if (inputFile == null && captureFile != null) {
                    inputFile = Uri.fromFile(captureFile);
                }
                if (data != null && data.getBooleanExtra("delete", false)) {
                    avatarBytes = null;
                    avatar.setImageDrawable(new ResourceContactPhoto(R.drawable.ic_camera_alt_white_24dp).asDrawable(this, getResources().getColor(R.color.grey_400)));
                } else {
                    new Crop(inputFile).output(outputFile).asSquare().start(this);
                }
            }
            break;
        case Crop.REQUEST_CROP:
            if (resultCode == Activity.RESULT_OK) {
                new AsyncTask<Void, Void, byte[]>() {

                    @Override
                    protected byte[] doInBackground(Void... params) {
                        try {
                            return BitmapUtil.createScaledBytes(CreateProfileActivity.this, Crop.getOutput(data), new ProfileMediaConstraints());
                        } catch (BitmapDecodingException e) {
                            Log.w(TAG, e);
                            return null;
                        }
                    }

                    @Override
                    protected void onPostExecute(byte[] result) {
                        if (result != null) {
                            avatarBytes = result;
                            GlideApp.with(CreateProfileActivity.this).load(avatarBytes).skipMemoryCache(true).diskCacheStrategy(DiskCacheStrategy.NONE).circleCrop().into(avatar);
                        } else {
                            Toast.makeText(CreateProfileActivity.this, R.string.CreateProfileActivity_error_setting_profile_photo, Toast.LENGTH_LONG).show();
                        }
                    }
                }.execute();
            }
            break;
    }
}
Also used : Crop(com.soundcloud.android.crop.Crop) ResourceContactPhoto(org.thoughtcrime.securesms.contacts.avatars.ResourceContactPhoto) ProfileMediaConstraints(org.thoughtcrime.securesms.profiles.ProfileMediaConstraints) Uri(android.net.Uri) File(java.io.File) BitmapDecodingException(org.thoughtcrime.securesms.util.BitmapDecodingException)

Aggregations

ResourceContactPhoto (org.thoughtcrime.securesms.contacts.avatars.ResourceContactPhoto)6 ProfileContactPhoto (org.thoughtcrime.securesms.contacts.avatars.ProfileContactPhoto)2 SuppressLint (android.annotation.SuppressLint)1 Context (android.content.Context)1 Intent (android.content.Intent)1 Resources (android.content.res.Resources)1 TypedArray (android.content.res.TypedArray)1 Bitmap (android.graphics.Bitmap)1 Drawable (android.graphics.drawable.Drawable)1 Uri (android.net.Uri)1 Editable (android.text.Editable)1 TextWatcher (android.text.TextWatcher)1 TransitionInflater (android.transition.TransitionInflater)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 Nullable (androidx.annotation.Nullable)1 Toolbar (androidx.appcompat.widget.Toolbar)1 DataSource (com.bumptech.glide.load.DataSource)1 GlideException (com.bumptech.glide.load.engine.GlideException)1 RequestListener (com.bumptech.glide.request.RequestListener)1