Skip to content

Commit b87023b

Browse files
update: res selector popup backgroundcolor issue
1 parent 2d65871 commit b87023b

File tree

2 files changed

+13
-22
lines changed

2 files changed

+13
-22
lines changed

library/src/main/java/com/gowtham/library/utils/VideoRes.kt

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package com.gowtham.library.utils
22

33
import android.app.Activity
44
import android.net.Uri
5+
import android.util.Log
56

67
enum class VideoRes(val displayName: String, val res: Int) {
78
LOWER_SD("<360p", -1), SD_360("360p", 360),
@@ -26,36 +27,27 @@ fun getVideoResNames(context: Activity, inputUri: Uri): List<String> {
2627
list.add(res.displayName)
2728
}
2829
}
29-
return list
30+
return list.reversed()
3031
}
3132
}
3233

33-
/*
34-
fun downScaleResolution(
34+
fun getDownScaleRatio(
3535
context: Activity,
3636
fileUri: Uri,
3737
targetRes: VideoRes
3838
): Float {
39-
val wh = TrimmerUtils.getVideoRes(context, fileUri)
39+
val widthHeightPair = TrimmerUtils.getVideoRes(context, fileUri)
4040

41-
val resolution = wh.first.coerceAtLeast(wh.second)
42-
43-
if (resolution >= 1920) {
44-
if(targetRes== VideoRes.FULL_HD){
45-
46-
}
47-
} else if (resolution >= 1280) {
48-
return VideoRes.HD;
49-
} else if (resolution >= 854) {
50-
return VideoRes.SD;
51-
} else if (resolution >= 640) { // 640x360
52-
return VideoRes.SD_360;
53-
} else {
54-
return VideoRes.LOWER_SD;
41+
val resolution = widthHeightPair.first.coerceAtMost(widthHeightPair.second)
42+
Log.e("TAG", "trimVideo: resolution: "+resolution);
43+
Log.e("TAG", "trimVideo: targetRes: "+targetRes.res);
44+
if (resolution== targetRes.res){
45+
return 1f
46+
}else{
47+
val value= resolution-targetRes.res.toFloat()
48+
return (value/ resolution).coerceIn(0f, 1f)
5549
}
56-
return scaleFactorHeight
5750
}
58-
*/
5951

6052

6153
//

library/src/main/res/values/styles.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@
2121
<style name="AppTheme.PopupMenu" parent="Widget.AppCompat.PopupMenu.Overflow">
2222
<!-- For AndroidX AppCompat Popups -->
2323
<item name="android:textColor">@color/colorWhite</item>
24-
<!-- You might also need to set the background if it's not picking up correctly -->
25-
<!-- <item name="android:background">@color/popup_menu_background_dark</item> -->
24+
<item name="android:background">@color/popup_menu_background_dark</item>
2625
</style>
2726

2827
<style name="AppTheme.PopupMenu.Old" parent="Widget.AppCompat.Light.PopupMenu.Overflow">

0 commit comments

Comments
 (0)