Search in sources :

Example 1 with SHOW_TOOLBAR

use of org.thoughtcrime.securesms.profiles.edit.EditProfileActivity.SHOW_TOOLBAR in project Signal-Android by WhisperSystems.

the class EditProfileFragment method initializeResources.

private void initializeResources(@NonNull View view, @Nullable GroupId groupId) {
    Bundle arguments = requireArguments();
    boolean isEditingGroup = groupId != null;
    this.toolbar = view.findViewById(R.id.toolbar);
    this.title = view.findViewById(R.id.title);
    this.avatar = view.findViewById(R.id.avatar);
    this.givenName = view.findViewById(R.id.given_name);
    this.familyName = view.findViewById(R.id.family_name);
    this.finishButton = view.findViewById(R.id.finish_button);
    this.reveal = view.findViewById(R.id.reveal);
    this.preview = view.findViewById(R.id.name_preview);
    this.avatarPreviewBackground = view.findViewById(R.id.avatar_background);
    this.avatarPreview = view.findViewById(R.id.avatar_placeholder);
    this.nextIntent = arguments.getParcelable(NEXT_INTENT);
    this.avatar.setOnClickListener(v -> startAvatarSelection());
    view.findViewById(R.id.mms_group_hint).setVisibility(isEditingGroup && groupId.isMms() ? View.VISIBLE : View.GONE);
    if (isEditingGroup) {
        EditTextUtil.addGraphemeClusterLimitFilter(givenName, FeatureFlags.getMaxGroupNameGraphemeLength());
        givenName.addTextChangedListener(new AfterTextChanged(s -> viewModel.setGivenName(s.toString())));
        givenName.setHint(R.string.EditProfileFragment__group_name);
        givenName.requestFocus();
        toolbar.setTitle(R.string.EditProfileFragment__edit_group);
        preview.setVisibility(View.GONE);
        if (groupId.isV2()) {
            EditTextUtil.addGraphemeClusterLimitFilter(familyName, MAX_DESCRIPTION_GLYPHS);
            familyName.addTextChangedListener(new AfterTextChanged(s -> {
                EditProfileNameFragment.trimFieldToMaxByteLength(s, MAX_DESCRIPTION_BYTES);
                viewModel.setFamilyName(s.toString());
            }));
            familyName.setHint(R.string.EditProfileFragment__group_description);
            familyName.setSingleLine(false);
            familyName.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);
            LearnMoreTextView descriptionText = view.findViewById(R.id.description_text);
            descriptionText.setLearnMoreVisible(false);
            descriptionText.setText(R.string.CreateProfileActivity_group_descriptions_will_be_visible_to_members_of_this_group_and_people_who_have_been_invited);
        } else {
            familyName.setVisibility(View.GONE);
            familyName.setEnabled(false);
            view.findViewById(R.id.description_text).setVisibility(View.GONE);
        }
        view.<ImageView>findViewById(R.id.avatar_placeholder).setImageResource(R.drawable.ic_group_outline_40);
    } else {
        EditTextUtil.addGraphemeClusterLimitFilter(givenName, EditProfileNameFragment.NAME_MAX_GLYPHS);
        EditTextUtil.addGraphemeClusterLimitFilter(familyName, EditProfileNameFragment.NAME_MAX_GLYPHS);
        this.givenName.addTextChangedListener(new AfterTextChanged(s -> {
            EditProfileNameFragment.trimFieldToMaxByteLength(s);
            viewModel.setGivenName(s.toString());
        }));
        this.familyName.addTextChangedListener(new AfterTextChanged(s -> {
            EditProfileNameFragment.trimFieldToMaxByteLength(s);
            viewModel.setFamilyName(s.toString());
        }));
        LearnMoreTextView descriptionText = view.findViewById(R.id.description_text);
        descriptionText.setLearnMoreVisible(true);
        descriptionText.setOnLinkClickListener(v -> CommunicationActions.openBrowserLink(requireContext(), getString(R.string.EditProfileFragment__support_link)));
    }
    this.finishButton.setOnClickListener(v -> {
        this.finishButton.setIndeterminateProgressMode(true);
        this.finishButton.setProgress(50);
        handleUpload();
    });
    this.finishButton.setText(arguments.getInt(NEXT_BUTTON_TEXT, R.string.CreateProfileActivity_next));
    if (arguments.getBoolean(SHOW_TOOLBAR, true)) {
        this.toolbar.setVisibility(View.VISIBLE);
        this.toolbar.setNavigationOnClickListener(v -> requireActivity().finish());
        this.title.setVisibility(View.GONE);
    }
}
Also used : RequiresApi(androidx.annotation.RequiresApi) AvatarColor(org.thoughtcrime.securesms.conversation.colors.AvatarColor) Bundle(android.os.Bundle) EditTextUtil(org.signal.core.util.EditTextUtil) NonNull(androidx.annotation.NonNull) AvatarPickerFragment(org.thoughtcrime.securesms.avatar.picker.AvatarPickerFragment) ImageView(android.widget.ImageView) SHOW_TOOLBAR(org.thoughtcrime.securesms.profiles.edit.EditProfileActivity.SHOW_TOOLBAR) Animator(android.animation.Animator) R(org.thoughtcrime.securesms.R) SafeNavigation(org.thoughtcrime.securesms.util.navigation.SafeNavigation) Media(org.thoughtcrime.securesms.mediasend.Media) View(android.view.View) ViewModelProviders(androidx.lifecycle.ViewModelProviders) SimpleColorFilter(com.airbnb.lottie.SimpleColorFilter) Avatars(org.thoughtcrime.securesms.avatar.Avatars) ParcelableGroupId(org.thoughtcrime.securesms.groups.ParcelableGroupId) InputType(android.text.InputType) ViewAnimationUtils(android.view.ViewAnimationUtils) ViewGroup(android.view.ViewGroup) Log(org.signal.core.util.logging.Log) FeatureFlags(org.thoughtcrime.securesms.util.FeatureFlags) TextView(android.widget.TextView) Nullable(androidx.annotation.Nullable) ResourceContactPhoto(org.thoughtcrime.securesms.contacts.avatars.ResourceContactPhoto) EXCLUDE_SYSTEM(org.thoughtcrime.securesms.profiles.edit.EditProfileActivity.EXCLUDE_SYSTEM) GroupId(org.thoughtcrime.securesms.groups.GroupId) Toolbar(androidx.appcompat.widget.Toolbar) GROUP_ID(org.thoughtcrime.securesms.profiles.edit.EditProfileActivity.GROUP_ID) GlideApp(org.thoughtcrime.securesms.mms.GlideApp) Context(android.content.Context) NEXT_BUTTON_TEXT(org.thoughtcrime.securesms.profiles.edit.EditProfileActivity.NEXT_BUTTON_TEXT) Intent(android.content.Intent) Toast(android.widget.Toast) DiskCacheStrategy(com.bumptech.glide.load.engine.DiskCacheStrategy) Build(android.os.Build) NEXT_INTENT(org.thoughtcrime.securesms.profiles.edit.EditProfileActivity.NEXT_INTENT) SimpleTask(org.thoughtcrime.securesms.util.concurrent.SimpleTask) CircularProgressButton(com.dd.CircularProgressButton) Parcelable(android.os.Parcelable) LayoutInflater(android.view.LayoutInflater) AfterTextChanged(org.thoughtcrime.securesms.util.text.AfterTextChanged) StreamUtil(org.signal.core.util.StreamUtil) BlobProvider(org.thoughtcrime.securesms.providers.BlobProvider) IOException(java.io.IOException) CommunicationActions(org.thoughtcrime.securesms.util.CommunicationActions) LearnMoreTextView(org.thoughtcrime.securesms.util.views.LearnMoreTextView) Navigation(androidx.navigation.Navigation) LoggingFragment(org.thoughtcrime.securesms.LoggingFragment) EditText(android.widget.EditText) EditProfileNameFragment(org.thoughtcrime.securesms.profiles.manage.EditProfileNameFragment) InputStream(java.io.InputStream) Bundle(android.os.Bundle) LearnMoreTextView(org.thoughtcrime.securesms.util.views.LearnMoreTextView) AfterTextChanged(org.thoughtcrime.securesms.util.text.AfterTextChanged)

Example 2 with SHOW_TOOLBAR

use of org.thoughtcrime.securesms.profiles.edit.EditProfileActivity.SHOW_TOOLBAR in project Signal-Android by signalapp.

the class EditProfileFragment method initializeResources.

private void initializeResources(@NonNull View view, @Nullable GroupId groupId) {
    Bundle arguments = requireArguments();
    boolean isEditingGroup = groupId != null;
    this.toolbar = view.findViewById(R.id.toolbar);
    this.title = view.findViewById(R.id.title);
    this.avatar = view.findViewById(R.id.avatar);
    this.givenName = view.findViewById(R.id.given_name);
    this.familyName = view.findViewById(R.id.family_name);
    this.finishButton = view.findViewById(R.id.finish_button);
    this.reveal = view.findViewById(R.id.reveal);
    this.preview = view.findViewById(R.id.name_preview);
    this.avatarPreviewBackground = view.findViewById(R.id.avatar_background);
    this.avatarPreview = view.findViewById(R.id.avatar_placeholder);
    this.nextIntent = arguments.getParcelable(NEXT_INTENT);
    this.avatar.setOnClickListener(v -> startAvatarSelection());
    view.findViewById(R.id.mms_group_hint).setVisibility(isEditingGroup && groupId.isMms() ? View.VISIBLE : View.GONE);
    if (isEditingGroup) {
        EditTextUtil.addGraphemeClusterLimitFilter(givenName, FeatureFlags.getMaxGroupNameGraphemeLength());
        givenName.addTextChangedListener(new AfterTextChanged(s -> viewModel.setGivenName(s.toString())));
        givenName.setHint(R.string.EditProfileFragment__group_name);
        givenName.requestFocus();
        toolbar.setTitle(R.string.EditProfileFragment__edit_group);
        preview.setVisibility(View.GONE);
        if (groupId.isV2()) {
            EditTextUtil.addGraphemeClusterLimitFilter(familyName, MAX_DESCRIPTION_GLYPHS);
            familyName.addTextChangedListener(new AfterTextChanged(s -> {
                EditProfileNameFragment.trimFieldToMaxByteLength(s, MAX_DESCRIPTION_BYTES);
                viewModel.setFamilyName(s.toString());
            }));
            familyName.setHint(R.string.EditProfileFragment__group_description);
            familyName.setSingleLine(false);
            familyName.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);
            LearnMoreTextView descriptionText = view.findViewById(R.id.description_text);
            descriptionText.setLearnMoreVisible(false);
            descriptionText.setText(R.string.CreateProfileActivity_group_descriptions_will_be_visible_to_members_of_this_group_and_people_who_have_been_invited);
        } else {
            familyName.setVisibility(View.GONE);
            familyName.setEnabled(false);
            view.findViewById(R.id.description_text).setVisibility(View.GONE);
        }
        view.<ImageView>findViewById(R.id.avatar_placeholder).setImageResource(R.drawable.ic_group_outline_40);
    } else {
        EditTextUtil.addGraphemeClusterLimitFilter(givenName, EditProfileNameFragment.NAME_MAX_GLYPHS);
        EditTextUtil.addGraphemeClusterLimitFilter(familyName, EditProfileNameFragment.NAME_MAX_GLYPHS);
        this.givenName.addTextChangedListener(new AfterTextChanged(s -> {
            EditProfileNameFragment.trimFieldToMaxByteLength(s);
            viewModel.setGivenName(s.toString());
        }));
        this.familyName.addTextChangedListener(new AfterTextChanged(s -> {
            EditProfileNameFragment.trimFieldToMaxByteLength(s);
            viewModel.setFamilyName(s.toString());
        }));
        LearnMoreTextView descriptionText = view.findViewById(R.id.description_text);
        descriptionText.setLearnMoreVisible(true);
        descriptionText.setOnLinkClickListener(v -> CommunicationActions.openBrowserLink(requireContext(), getString(R.string.EditProfileFragment__support_link)));
    }
    this.finishButton.setOnClickListener(v -> {
        this.finishButton.setIndeterminateProgressMode(true);
        this.finishButton.setProgress(50);
        handleUpload();
    });
    this.finishButton.setText(arguments.getInt(NEXT_BUTTON_TEXT, R.string.CreateProfileActivity_next));
    if (arguments.getBoolean(SHOW_TOOLBAR, true)) {
        this.toolbar.setVisibility(View.VISIBLE);
        this.toolbar.setNavigationOnClickListener(v -> requireActivity().finish());
        this.title.setVisibility(View.GONE);
    }
}
Also used : RequiresApi(androidx.annotation.RequiresApi) AvatarColor(org.thoughtcrime.securesms.conversation.colors.AvatarColor) Bundle(android.os.Bundle) EditTextUtil(org.signal.core.util.EditTextUtil) NonNull(androidx.annotation.NonNull) AvatarPickerFragment(org.thoughtcrime.securesms.avatar.picker.AvatarPickerFragment) ImageView(android.widget.ImageView) SHOW_TOOLBAR(org.thoughtcrime.securesms.profiles.edit.EditProfileActivity.SHOW_TOOLBAR) Animator(android.animation.Animator) R(org.thoughtcrime.securesms.R) SafeNavigation(org.thoughtcrime.securesms.util.navigation.SafeNavigation) Media(org.thoughtcrime.securesms.mediasend.Media) View(android.view.View) ViewModelProviders(androidx.lifecycle.ViewModelProviders) SimpleColorFilter(com.airbnb.lottie.SimpleColorFilter) Avatars(org.thoughtcrime.securesms.avatar.Avatars) ParcelableGroupId(org.thoughtcrime.securesms.groups.ParcelableGroupId) InputType(android.text.InputType) ViewAnimationUtils(android.view.ViewAnimationUtils) ViewGroup(android.view.ViewGroup) Log(org.signal.core.util.logging.Log) FeatureFlags(org.thoughtcrime.securesms.util.FeatureFlags) TextView(android.widget.TextView) Nullable(androidx.annotation.Nullable) ResourceContactPhoto(org.thoughtcrime.securesms.contacts.avatars.ResourceContactPhoto) EXCLUDE_SYSTEM(org.thoughtcrime.securesms.profiles.edit.EditProfileActivity.EXCLUDE_SYSTEM) GroupId(org.thoughtcrime.securesms.groups.GroupId) Toolbar(androidx.appcompat.widget.Toolbar) GROUP_ID(org.thoughtcrime.securesms.profiles.edit.EditProfileActivity.GROUP_ID) GlideApp(org.thoughtcrime.securesms.mms.GlideApp) Context(android.content.Context) NEXT_BUTTON_TEXT(org.thoughtcrime.securesms.profiles.edit.EditProfileActivity.NEXT_BUTTON_TEXT) Intent(android.content.Intent) Toast(android.widget.Toast) DiskCacheStrategy(com.bumptech.glide.load.engine.DiskCacheStrategy) Build(android.os.Build) NEXT_INTENT(org.thoughtcrime.securesms.profiles.edit.EditProfileActivity.NEXT_INTENT) SimpleTask(org.thoughtcrime.securesms.util.concurrent.SimpleTask) CircularProgressButton(com.dd.CircularProgressButton) Parcelable(android.os.Parcelable) LayoutInflater(android.view.LayoutInflater) AfterTextChanged(org.thoughtcrime.securesms.util.text.AfterTextChanged) StreamUtil(org.signal.core.util.StreamUtil) BlobProvider(org.thoughtcrime.securesms.providers.BlobProvider) IOException(java.io.IOException) CommunicationActions(org.thoughtcrime.securesms.util.CommunicationActions) LearnMoreTextView(org.thoughtcrime.securesms.util.views.LearnMoreTextView) Navigation(androidx.navigation.Navigation) LoggingFragment(org.thoughtcrime.securesms.LoggingFragment) EditText(android.widget.EditText) EditProfileNameFragment(org.thoughtcrime.securesms.profiles.manage.EditProfileNameFragment) InputStream(java.io.InputStream) Bundle(android.os.Bundle) LearnMoreTextView(org.thoughtcrime.securesms.util.views.LearnMoreTextView) AfterTextChanged(org.thoughtcrime.securesms.util.text.AfterTextChanged)

Aggregations

Animator (android.animation.Animator)2 Context (android.content.Context)2 Intent (android.content.Intent)2 Build (android.os.Build)2 Bundle (android.os.Bundle)2 Parcelable (android.os.Parcelable)2 InputType (android.text.InputType)2 LayoutInflater (android.view.LayoutInflater)2 View (android.view.View)2 ViewAnimationUtils (android.view.ViewAnimationUtils)2 ViewGroup (android.view.ViewGroup)2 EditText (android.widget.EditText)2 ImageView (android.widget.ImageView)2 TextView (android.widget.TextView)2 Toast (android.widget.Toast)2 NonNull (androidx.annotation.NonNull)2 Nullable (androidx.annotation.Nullable)2 RequiresApi (androidx.annotation.RequiresApi)2 Toolbar (androidx.appcompat.widget.Toolbar)2 ViewModelProviders (androidx.lifecycle.ViewModelProviders)2