Video trimming behind feature flag.

This commit is contained in:
Alan Evans
2020-02-13 14:22:21 -04:00
committed by Greyson Parrelli
parent 7f867a6185
commit 40fd7ca332
41 changed files with 1966 additions and 268 deletions

View File

@@ -54,6 +54,7 @@ public final class FeatureFlags {
private static final String PINS_FOR_ALL = generateKey("pinsForAll");
private static final String PINS_MEGAPHONE_KILL_SWITCH = generateKey("pinsMegaphoneKillSwitch");
private static final String PROFILE_NAMES_MEGAPHONE_ENABLED = generateKey("profileNamesMegaphoneEnabled");
private static final String VIDEO_TRIMMING = generateKey("videoTrimming");
/**
* We will only store remote values for flags in this set. If you want a flag to be controllable
@@ -61,6 +62,7 @@ public final class FeatureFlags {
*/
private static final Set<String> REMOTE_CAPABLE = Sets.newHashSet(
VIDEO_TRIMMING,
PINS_FOR_ALL,
PINS_MEGAPHONE_KILL_SWITCH,
PROFILE_NAMES_MEGAPHONE_ENABLED
@@ -84,6 +86,7 @@ public final class FeatureFlags {
* more burden on the reader to ensure that the app experience remains consistent.
*/
private static final Set<String> HOT_SWAPPABLE = Sets.newHashSet(
VIDEO_TRIMMING,
PINS_MEGAPHONE_KILL_SWITCH
);
@@ -174,6 +177,11 @@ public final class FeatureFlags {
TextSecurePreferences.getFirstInstallVersion(ApplicationDependencies.getApplication()) < 600;
}
/** Allow trimming videos. */
public static boolean videoTrimming() {
return getValue(VIDEO_TRIMMING, false);
}
/** Only for rendering debug info. */
public static synchronized @NonNull Map<String, Boolean> getMemoryValues() {
return new TreeMap<>(REMOTE_VALUES);

View File

@@ -300,7 +300,7 @@ public class MediaUtil {
}
@WorkerThread
public static @Nullable Bitmap getVideoThumbnail(Context context, Uri uri) {
public static @Nullable Bitmap getVideoThumbnail(Context context, Uri uri, long timeUs) {
if ("com.android.providers.media.documents".equals(uri.getAuthority())) {
long videoId = Long.parseLong(uri.getLastPathSegment().split(":")[1]);
@@ -327,7 +327,7 @@ public class MediaUtil {
MediaMetadataRetriever mediaMetadataRetriever = new MediaMetadataRetriever();
MediaMetadataRetrieverUtil.setDataSource(mediaMetadataRetriever, mediaDataSource);
return mediaMetadataRetriever.getFrameAtTime(1000);
return mediaMetadataRetriever.getFrameAtTime(timeUs);
} catch (IOException e) {
Log.w(TAG, "failed to get thumbnail for video blob uri: " + uri, e);
return null;