New group avatar and name selection screen.

This commit is contained in:
Alex Hart
2020-04-28 13:27:09 -03:00
committed by Greyson Parrelli
parent 12b7d6c0e3
commit 5eb663aa1b
22 changed files with 493 additions and 189 deletions

View File

@@ -19,7 +19,9 @@ import androidx.recyclerview.widget.RecyclerView;
import com.annimon.stream.Stream;
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
import org.thoughtcrime.securesms.ClearProfileAvatarActivity;
import org.thoughtcrime.securesms.R;
import org.thoughtcrime.securesms.groups.GroupId;
import org.thoughtcrime.securesms.util.ThemeUtil;
import java.util.ArrayList;
@@ -29,8 +31,9 @@ public class AvatarSelectionBottomSheetDialogFragment extends BottomSheetDialogF
private static final String ARG_OPTIONS = "options";
private static final String ARG_REQUEST_CODE = "request_code";
private static final String ARG_IS_GROUP = "is_group";
public static DialogFragment create(boolean includeClear, boolean includeCamera, short resultCode) {
public static DialogFragment create(boolean includeClear, boolean includeCamera, short resultCode, boolean isGroup) {
DialogFragment fragment = new AvatarSelectionBottomSheetDialogFragment();
List<SelectionOption> selectionOptions = new ArrayList<>(3);
Bundle args = new Bundle();
@@ -51,6 +54,7 @@ public class AvatarSelectionBottomSheetDialogFragment extends BottomSheetDialogF
args.putStringArray(ARG_OPTIONS, options);
args.putShort(ARG_REQUEST_CODE, resultCode);
args.putBoolean(ARG_IS_GROUP, isGroup);
fragment.setArguments(args);
return fragment;
@@ -93,7 +97,7 @@ public class AvatarSelectionBottomSheetDialogFragment extends BottomSheetDialogF
}
private void launchOptionAndDismiss(@NonNull SelectionOption option) {
Intent intent = createIntent(requireContext(), option);
Intent intent = createIntent(requireContext(), option, requireArguments().getBoolean(ARG_IS_GROUP));
int requestCode = requireArguments().getShort(ARG_REQUEST_CODE);
if (getParentFragment() != null) {
@@ -105,14 +109,15 @@ public class AvatarSelectionBottomSheetDialogFragment extends BottomSheetDialogF
dismiss();
}
private static Intent createIntent(@NonNull Context context, @NonNull SelectionOption selectionOption) {
private static Intent createIntent(@NonNull Context context, @NonNull SelectionOption selectionOption, boolean isGroup) {
switch (selectionOption) {
case CAPTURE:
return AvatarSelectionActivity.getIntentForCameraCapture(context);
case GALLERY:
return AvatarSelectionActivity.getIntentForGallery(context);
case DELETE:
return new Intent("org.thoughtcrime.securesms.action.CLEAR_PROFILE_PHOTO");
return isGroup ? ClearProfileAvatarActivity.createForGroupProfilePhoto()
: ClearProfileAvatarActivity.createForUserProfilePhoto();
default:
throw new IllegalStateException("Unknown option: " + selectionOption);
}