Hide quality selector when no images selected.

fork-5.53.8
Cody Henthorne 2021-06-08 12:53:14 -04:00 zatwierdzone przez GitHub
rodzic 0972d8f1e1
commit 9f2d57493d
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
3 zmienionych plików z 33 dodań i 22 usunięć

Wyświetl plik

@ -367,7 +367,6 @@ public class MediaSendActivity extends PassphraseRequiredActivity implements Med
revealButton.setOnClickListener(v -> viewModel.onRevealButtonToggled()); revealButton.setOnClickListener(v -> viewModel.onRevealButtonToggled());
qualityButton.setVisibility(Util.isLowMemory(this) ? View.GONE : View.VISIBLE);
qualityButton.setOnClickListener(v -> QualitySelectorBottomSheetDialog.show(getSupportFragmentManager())); qualityButton.setOnClickListener(v -> QualitySelectorBottomSheetDialog.show(getSupportFragmentManager()));
continueButton.setOnClickListener(v -> { continueButton.setOnClickListener(v -> {
@ -785,6 +784,7 @@ public class MediaSendActivity extends PassphraseRequiredActivity implements Med
} }
}); });
viewModel.getShowMediaQualityToggle().observe(this, show -> qualityButton.setVisibility(show && !Util.isLowMemory(this) ? View.VISIBLE : View.GONE));
viewModel.getSentMediaQuality().observe(this, q -> qualityButton.setImageResource(q == SentMediaQuality.STANDARD ? R.drawable.ic_quality_standard_32 : R.drawable.ic_quality_high_32)); viewModel.getSentMediaQuality().observe(this, q -> qualityButton.setImageResource(q == SentMediaQuality.STANDARD ? R.drawable.ic_quality_standard_32 : R.drawable.ic_quality_high_32));
viewModel.getSelectedMedia().observe(this, media -> { viewModel.getSelectedMedia().observe(this, media -> {

Wyświetl plik

@ -35,6 +35,7 @@ import org.thoughtcrime.securesms.util.MessageUtil;
import org.thoughtcrime.securesms.util.SingleLiveEvent; import org.thoughtcrime.securesms.util.SingleLiveEvent;
import org.thoughtcrime.securesms.util.TextSecurePreferences; import org.thoughtcrime.securesms.util.TextSecurePreferences;
import org.thoughtcrime.securesms.util.Util; import org.thoughtcrime.securesms.util.Util;
import org.thoughtcrime.securesms.util.livedata.LiveDataUtil;
import org.whispersystems.libsignal.util.guava.Optional; import org.whispersystems.libsignal.util.guava.Optional;
import org.whispersystems.libsignal.util.guava.Preconditions; import org.whispersystems.libsignal.util.guava.Preconditions;
@ -67,6 +68,7 @@ class MediaSendViewModel extends ViewModel {
private final SingleLiveEvent<Error> error; private final SingleLiveEvent<Error> error;
private final SingleLiveEvent<Event> event; private final SingleLiveEvent<Event> event;
private final MutableLiveData<SentMediaQuality> sentMediaQuality; private final MutableLiveData<SentMediaQuality> sentMediaQuality;
private final LiveData<Boolean> showMediaQualityToggle;
private final Map<Uri, Object> savedDrawState; private final Map<Uri, Object> savedDrawState;
private TransportOption transport; private TransportOption transport;
@ -93,27 +95,28 @@ class MediaSendViewModel extends ViewModel {
@NonNull MediaRepository repository, @NonNull MediaRepository repository,
@NonNull MediaUploadRepository uploadRepository) @NonNull MediaUploadRepository uploadRepository)
{ {
this.application = application; this.application = application;
this.repository = repository; this.repository = repository;
this.uploadRepository = uploadRepository; this.uploadRepository = uploadRepository;
this.selectedMedia = new MutableLiveData<>(); this.selectedMedia = new MutableLiveData<>();
this.bucketMedia = new MutableLiveData<>(); this.bucketMedia = new MutableLiveData<>();
this.mostRecentMedia = new MutableLiveData<>(); this.mostRecentMedia = new MutableLiveData<>();
this.position = new MutableLiveData<>(); this.position = new MutableLiveData<>();
this.bucketId = new MutableLiveData<>(); this.bucketId = new MutableLiveData<>();
this.folders = new MutableLiveData<>(); this.folders = new MutableLiveData<>();
this.hudState = new MutableLiveData<>(); this.hudState = new MutableLiveData<>();
this.error = new SingleLiveEvent<>(); this.error = new SingleLiveEvent<>();
this.event = new SingleLiveEvent<>(); this.event = new SingleLiveEvent<>();
this.sentMediaQuality = new MutableLiveData<>(SentMediaQuality.STANDARD); this.sentMediaQuality = new MutableLiveData<>(SentMediaQuality.STANDARD);
this.savedDrawState = new HashMap<>(); this.savedDrawState = new HashMap<>();
this.lastCameraCapture = Optional.absent(); this.lastCameraCapture = Optional.absent();
this.body = ""; this.body = "";
this.buttonState = ButtonState.GONE; this.buttonState = ButtonState.GONE;
this.railState = RailState.GONE; this.railState = RailState.GONE;
this.viewOnceState = ViewOnceState.GONE; this.viewOnceState = ViewOnceState.GONE;
this.page = Page.UNKNOWN; this.page = Page.UNKNOWN;
this.preUploadEnabled = true; this.preUploadEnabled = true;
this.showMediaQualityToggle = LiveDataUtil.mapAsync(this.selectedMedia, s -> s.stream().anyMatch(m -> MediaUtil.isImageAndNotGif(m.getMimeType())));
position.setValue(-1); position.setValue(-1);
} }
@ -577,6 +580,10 @@ class MediaSendViewModel extends ViewModel {
return sentMediaQuality; return sentMediaQuality;
} }
@NonNull LiveData<Boolean> getShowMediaQualityToggle() {
return showMediaQualityToggle;
}
@NonNull MediaConstraints getMediaConstraints() { @NonNull MediaConstraints getMediaConstraints() {
return mediaConstraints; return mediaConstraints;
} }

Wyświetl plik

@ -313,6 +313,10 @@ public class MediaUtil {
return isImageType(contentType) || isVideoType(contentType); return isImageType(contentType) || isVideoType(contentType);
} }
public static boolean isImageAndNotGif(@NonNull String contentType) {
return isImageType(contentType) && !isGif(contentType);
}
public static boolean isLongTextType(String contentType) { public static boolean isLongTextType(String contentType) {
return (null != contentType) && contentType.equals(LONG_TEXT); return (null != contentType) && contentType.equals(LONG_TEXT);
} }