Skip to content

Commit

Permalink
Only show video tooltip if capable.
Browse files Browse the repository at this point in the history
  • Loading branch information
greyson-signal committed Oct 18, 2019
1 parent ef585eb commit 44dba4b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/org/thoughtcrime/securesms/mediasend/CameraXFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@
@RequiresApi(21)
public class CameraXFragment extends Fragment implements CameraFragment {

private static final String TAG = Log.tag(CameraXFragment.class);
private static final String HAS_DISMISSED_VIDEO_RECORDING_TOOLTIP = "camerax.fragment.has.dismissed.video.recording.tooltip";
private static final String TAG = Log.tag(CameraXFragment.class);

private CameraXView camera;
private ViewGroup controlsContainer;
Expand Down Expand Up @@ -283,11 +282,11 @@ private void displayVideoRecordingTooltipIfNecessary(CameraButtonView captureBut
}

private boolean shouldDisplayVideoRecordingTooltip() {
return !TextSecurePreferences.getBooleanPreference(requireContext(), HAS_DISMISSED_VIDEO_RECORDING_TOOLTIP, false);
return !TextSecurePreferences.hasSeenVideoRecordingTooltip(requireContext()) && MediaConstraints.isVideoTranscodeAvailable();
}

private void neverDisplayVideoRecordingTooltipAgain() {
TextSecurePreferences.setBooleanPreference(requireContext(), HAS_DISMISSED_VIDEO_RECORDING_TOOLTIP, true);
TextSecurePreferences.setHasSeenVideoRecordingTooltip(requireContext(), true);
}

private void hideAndDisableControlsForVideoRecording(@NonNull View captureButton,
Expand Down
10 changes: 10 additions & 0 deletions src/org/thoughtcrime/securesms/util/TextSecurePreferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ public class TextSecurePreferences {

private static final String HAS_SEEN_SWIPE_TO_REPLY = "pref_has_seen_swipe_to_reply";

private static final String HAS_SEEN_VIDEO_RECORDING_TOOLTIP = "camerax.fragment.has.dismissed.video.recording.tooltip";

public static boolean isScreenLockEnabled(@NonNull Context context) {
return getBooleanPreference(context, SCREEN_LOCK, false);
}
Expand Down Expand Up @@ -1158,6 +1160,14 @@ public static void setHasSeenSwipeToReplyTooltip(Context context, boolean value)
setBooleanPreference(context, HAS_SEEN_SWIPE_TO_REPLY, value);
}

public static boolean hasSeenVideoRecordingTooltip(Context context) {
return getBooleanPreference(context, HAS_SEEN_VIDEO_RECORDING_TOOLTIP, false);
}

public static void setHasSeenVideoRecordingTooltip(Context context, boolean value) {
setBooleanPreference(context, HAS_SEEN_VIDEO_RECORDING_TOOLTIP, value);
}

public static void setBooleanPreference(Context context, String key, boolean value) {
PreferenceManager.getDefaultSharedPreferences(context).edit().putBoolean(key, value).apply();
}
Expand Down

0 comments on commit 44dba4b

Please sign in to comment.