Skip to content

Commit 9a0cb2a

Browse files
author
fengpeng
committed
bugfix
1 parent ef0b134 commit 9a0cb2a

9 files changed

Lines changed: 53 additions & 23 deletions

File tree

app/src/main/res/layout/activity_main.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
android:layout_marginStart="@dimen/pick_media_activity_margin"
4949
android:layout_marginTop="25dp"
5050
android:layout_marginBottom="@dimen/pick_media_activity_margin"
51-
android:text="@string/pick_sigle_photo"
51+
android:text="@string/pick_single_photo"
5252
android:textColor="@color/pick_chose_text_color"
5353
android:textSize="18sp" />
5454

app/src/main/res/values/strings.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
<string name="app_name">MEDIA PICKER</string>
33
<string name="file_provider">pizzk.media.picker.demo.file.provider</string>
44
<string name="pick_demo_show">选择照片演示</string>
5-
<string name="pick_sigle_photo">选取单张图片</string>
5+
<string name="pick_single_photo">选取单张图片</string>
66
</resources>

picker/src/main/java/pizzk/media/picker/adapter/PreviewPhotoAdapter.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ class PreviewPhotoAdapter(private val context: Context, private val source: IMed
3737
views.removeAt(0)
3838
}
3939
container.addView(view, lp)
40-
view.setOnClickListener(clickBlock)
4140
//
4241
val vPhoto = view.findViewById<PhotoView>(R.id.vPhoto)
4342
vPhoto.setOnScaleChangeListener { _, _, _ -> scaleBlock() }
43+
vPhoto.setOnClickListener(clickBlock)
4444
val vVideo = view.findViewById<VideoView>(R.id.video)
4545
val vPause = view.findViewById<View>(R.id.vPause)
4646
//
@@ -91,7 +91,7 @@ class PreviewPhotoAdapter(private val context: Context, private val source: IMed
9191
fun resetScale() {
9292
val view = vCurrent ?: return
9393
val vPhoto = view.findViewById<PhotoView>(R.id.vPhoto)
94-
if (vPhoto.scale != 1.0f) vPhoto.scale = 1.0f
94+
vPhoto.scale = 1.0f
9595
}
9696

9797
fun stopPlay() {

picker/src/main/java/pizzk/media/picker/arch/PickControl.kt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ class PickControl private constructor() {
3131
private val disableFilter: (Uri?, String) -> Boolean = { _, _ -> false }
3232
private val dCallback: PickCallback = PickCallback()
3333

34+
//原图标志
35+
private var originQuality: Boolean = false
3436
private val picker: PickControl = PickControl()
3537

3638
fun obtain(clean: Boolean): PickControl = if (clean) picker.clean() else picker
@@ -42,6 +44,12 @@ class PickControl private constructor() {
4244
fun authority() = authority
4345

4446
fun imageLoad() = imageLoad
47+
48+
fun originQuality() = originQuality
49+
50+
internal fun setOriginQuality(value: Boolean) {
51+
originQuality = value
52+
}
4553
}
4654

4755
private var action: Int = ACTION_NONE
@@ -60,6 +68,9 @@ class PickControl private constructor() {
6068
//拍照
6169
private var cameraFile: File? = null
6270

71+
//标题
72+
private var title: String = ""
73+
6374
/**
6475
* 重置配置属性
6576
*/
@@ -68,6 +79,7 @@ class PickControl private constructor() {
6879
filter = disableFilter
6980
crop = null
7081
limit = 1
82+
title = ""
7183
callback = dCallback
7284
selects = emptyList()
7385
index = 0
@@ -98,6 +110,11 @@ class PickControl private constructor() {
98110
return this
99111
}
100112

113+
fun title(value: String): PickControl {
114+
this.title = value
115+
return this
116+
}
117+
101118
/**
102119
* 通过URI和MIME过滤
103120
*/
@@ -164,6 +181,11 @@ class PickControl private constructor() {
164181
*/
165182
internal fun limit(): Int = limit
166183

184+
/**
185+
* 获取标题名称
186+
*/
187+
internal fun title(): String = title
188+
167189
/**
168190
* 获取回调函数
169191
*/

picker/src/main/java/pizzk/media/picker/utils/PickUtils.kt

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -307,14 +307,9 @@ object PickUtils {
307307
fun hideSystemStatusBar(activity: Activity?): Boolean {
308308
activity ?: return false
309309
val decorView: View = activity.window.decorView
310-
val flag: Boolean =
311-
0 == (decorView.systemUiVisibility and View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION)
312-
activity.intent.putExtra(KEY_NAVIGATION_FLAG, flag)
313310
decorView.systemUiVisibility = (View.SYSTEM_UI_FLAG_LAYOUT_STABLE
314311
or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
315-
or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
316-
or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar
317-
or View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
312+
or View.SYSTEM_UI_FLAG_FULLSCREEN
318313
or View.SYSTEM_UI_FLAG_IMMERSIVE)
319314
return true
320315
}
@@ -323,12 +318,8 @@ object PickUtils {
323318
fun showSystemStatusBar(activity: Activity?): Boolean {
324319
activity ?: return false
325320
val decorView: View = activity.window.decorView
326-
decorView.systemUiVisibility = (View.SYSTEM_UI_FLAG_LAYOUT_STABLE
327-
or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN)
328-
if (!activity.intent.getBooleanExtra(KEY_NAVIGATION_FLAG, false)) {
329-
decorView.systemUiVisibility =
330-
decorView.systemUiVisibility or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
331-
}
321+
decorView.systemUiVisibility =
322+
(View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN)
332323
return true
333324
}
334325

picker/src/main/java/pizzk/media/picker/view/AlbumActivity.kt

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import androidx.recyclerview.widget.SimpleItemAnimator
2424
import pizzk.media.picker.R
2525
import pizzk.media.picker.adapter.AlbumBucketAdapter
2626
import pizzk.media.picker.adapter.AlbumPhotoAdapter
27+
import pizzk.media.picker.arch.PickControl
2728
import pizzk.media.picker.arch.PickLiveSource
2829
import pizzk.media.picker.entity.AlbumBucket
2930
import pizzk.media.picker.source.IMedia
@@ -63,7 +64,6 @@ class AlbumActivity : AppCompatActivity() {
6364
private lateinit var bucketAdapter: AlbumBucketAdapter
6465

6566
//标志位
66-
private var useOriginPhoto: Boolean = false
6767
private var finishFlag: Boolean = false
6868

6969
//动画
@@ -129,7 +129,10 @@ class AlbumActivity : AppCompatActivity() {
129129
private fun initViews() {
130130
//标题栏
131131
toolbar = findViewById(R.id.toolbar)
132-
toolbar.title = getString(R.string.pick_media_select_picture)
132+
toolbar.title = PickControl.obtain(clean = false).title()
133+
if (toolbar.title.isNullOrEmpty()) {
134+
toolbar.title = getString(R.string.pick_media_select_picture)
135+
}
133136
toolbar.setNavigationOnClickListener { finish() }
134137
//提交按钮
135138
doneButton = PickActionMenu(toolbar) {
@@ -148,7 +151,7 @@ class AlbumActivity : AppCompatActivity() {
148151
tvSection = findViewById(R.id.tvSection)
149152
tvSection.setOnClickListener(::onWidgetClick)
150153
vCenter = findViewById(R.id.vCenter)
151-
changeOriginState()
154+
updateOriginState()
152155
llCenter = findViewById(R.id.llCenter)
153156
llCenter.setOnClickListener(::onWidgetClick)
154157
tvPreview = findViewById(R.id.tvPreview)
@@ -171,8 +174,8 @@ class AlbumActivity : AppCompatActivity() {
171174
showSectionView(View.VISIBLE != sectionMask.visibility)
172175
}
173176
llCenter -> {
174-
useOriginPhoto = !useOriginPhoto
175-
changeOriginState()
177+
PickControl.setOriginQuality(!PickControl.originQuality())
178+
updateOriginState()
176179
}
177180
tvPreview -> {
178181
val selects: List<String> = photoAdapter.getSelectList()
@@ -252,7 +255,8 @@ class AlbumActivity : AppCompatActivity() {
252255
}
253256

254257
//调整原图选中状态
255-
private fun changeOriginState(check: Boolean = useOriginPhoto) {
258+
private fun updateOriginState() {
259+
val check = PickControl.originQuality()
256260
val res: Int = if (check) R.drawable.pick_radio_checked else R.drawable.pick_radio_normal
257261
vCenter.background = ContextCompat.getDrawable(baseContext, res)
258262
}

picker/src/main/java/pizzk/media/picker/view/PreviewActivity.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ import android.annotation.SuppressLint
44
import android.app.Activity
55
import android.content.Intent
66
import android.net.Uri
7+
import android.os.Build
78
import android.os.Bundle
89
import android.view.View
910
import android.view.ViewGroup
11+
import android.view.WindowManager
1012
import android.view.animation.AlphaAnimation
1113
import android.view.animation.Animation
1214
import android.widget.ImageView
@@ -127,6 +129,12 @@ class PreviewActivity : AppCompatActivity() {
127129
} else {
128130
systemUiVisibility = -1
129131
}
132+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
133+
val lp: WindowManager.LayoutParams = window.attributes
134+
val mode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES
135+
lp.layoutInDisplayCutoutMode = mode
136+
window.attributes = lp
137+
}
130138
//标题栏
131139
toolbar = findViewById(R.id.toolbar)
132140
toolbar.title = ""

picker/src/main/res/values/strings.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<string name="open_camera_permission">请前往设置打开相机权限</string>
77
<string name="open_external_storage_permission">请前往设置打开外部存储读写权限</string>
88
<string name="pick_media_most_select_limit">最多只能选择%1$d张图片</string>
9-
<string name="pick_media_all_picture">所有图片</string>
9+
<string name="pick_media_all_picture">全部</string>
1010
<string name="pick_media_edit">编辑</string>
1111
<string name="pick_media_origin_picture">原图</string>
1212
<string name="pick_media_preview">预览</string>

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99
<item name="android:background">@color/pick_accent_color</item>
1010
<item name="navigationIcon">@drawable/pick_title_back</item>
1111
<item name="titleTextColor">@color/pick_title_color</item>
12+
<item name="titleTextAppearance">@style/PickToolbarTitle</item>
13+
</style>
14+
15+
<style name="PickToolbarTitle">
16+
<item name="android:textSize">16sp</item>
1217
</style>
1318

1419
<style name="PickToolbarTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">

0 commit comments

Comments
 (0)