Skip to content

Commit

Permalink
TIRAMISU
Browse files Browse the repository at this point in the history
  • Loading branch information
7449 committed Jun 13, 2023
1 parent b2a360d commit 6ee8940
Show file tree
Hide file tree
Showing 20 changed files with 100 additions and 55 deletions.
26 changes: 10 additions & 16 deletions buildSrc/src/main/kotlin/Version.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
@file:Suppress("MemberVisibilityCanBePrivate")

object Plugin {
const val androidVersion = "7.4.0"
const val kotlinVersion = "1.7.20"
const val androidVersion = "8.0.2"
const val kotlinVersion = "1.8.20"
const val application = "com.android.application"
const val library = "com.android.library"
const val kotlin_android = "android"
Expand All @@ -26,25 +26,19 @@ object Args {
object Dep {
const val kotlin = "org.jetbrains.kotlin:kotlin-stdlib:${Plugin.kotlinVersion}"

const val compat = "com.github.7449.Album:compat:v1.1.1"
const val core = "com.github.7449.Album:core:v1.1.1"
const val scan = "com.github.7449.Album:scan:v1.1.1"
const val material_ui = "com.github.7449.Album:material:v1.1.1"
const val wechat_ui = "com.github.7449.Album:wechat:v1.1.1"

const val appcompat = "androidx.appcompat:appcompat:1.6.0"
const val fragment = "androidx.fragment:fragment:1.5.5"
const val activity = "androidx.activity:activity-ktx:1.6.1"
const val recyclerView = "androidx.recyclerview:recyclerview:1.2.1"
const val viewPager2 = "androidx.viewpager2:viewpager2:1.1.0-beta01"
const val material = "com.google.android.material:material:1.8.0"
const val appcompat = "androidx.appcompat:appcompat:1.6.1"
const val activity = "androidx.activity:activity-ktx:1.7.2"
const val fragment = "androidx.fragment:fragment:1.6.0"
const val recyclerView = "androidx.recyclerview:recyclerview:1.3.0"
const val viewPager2 = "androidx.viewpager2:viewpager2:1.1.0-beta02"
const val material = "com.google.android.material:material:1.9.0"

const val cameraview = "com.otaliastudios:cameraview:2.7.2"
const val cropper = "com.theartofdev.edmodo:android-image-cropper:2.8.0"
const val glide = "com.github.bumptech.glide:glide:4.14.2"
const val glide = "com.github.bumptech.glide:glide:4.15.1"

const val color = "com.github.QuadFlask:colorpicker:0.0.15"
const val flex = "com.google.android.flexbox:flexbox:3.0.0"
const val banner = "com.github.7449.BannerLayout:banner:v2.0.3"
const val ucrop = "com.github.yalantis:ucrop:2.2.6"
const val ucrop = "com.github.yalantis:ucrop:2.2.8"
}
5 changes: 5 additions & 0 deletions compat/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ android {
}
compileOptions {
kotlinOptions.freeCompilerArgs += listOf(Args.moduleName, Args.prefix.plus(project.name))
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlin {
jvmToolchain(17)
}
}
dependencies {
Expand Down
5 changes: 5 additions & 0 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ android {
}
compileOptions {
kotlinOptions.freeCompilerArgs += listOf(Args.moduleName, Args.prefix.plus(project.name))
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlin {
jvmToolchain(17)
}
}
dependencies {
Expand Down
4 changes: 4 additions & 0 deletions core/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />

<queries>
<intent>
Expand All @@ -14,4 +17,5 @@
<action android:name="android.media.action.IMAGE_CAPTURE_SECURE" />
</intent>
</queries>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import develop.file.gallery.extensions.ContextCompat.openVideo
import develop.file.gallery.extensions.ContextCompat.takePictureUri
import develop.file.gallery.extensions.FileCompat.scanFile
import develop.file.gallery.extensions.PermissionCompat.checkPermissionAndRequestCamera
import develop.file.gallery.extensions.PermissionCompat.checkPermissionAndRequestWrite
import develop.file.gallery.extensions.PermissionCompat.checkPermissionAndRequestRead
import develop.file.gallery.extensions.ResultCompat.orEmpty
import develop.file.gallery.extensions.ResultCompat.toScanEntity
import develop.file.gallery.extensions.UriCompat.delete
Expand Down Expand Up @@ -254,7 +254,7 @@ class ScanDelegateImpl(
}

override fun onScanGallery(parent: Long, isCamera: Boolean) {
if (!fragment.checkPermissionAndRequestWrite(readPermissionLauncher)) {
if (!fragment.checkPermissionAndRequestRead(readPermissionLauncher)) {
return
}
this.parentId = parent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,28 @@ package develop.file.gallery.extensions
import android.Manifest
import android.content.Context
import android.content.pm.PackageManager
import android.os.Build
import androidx.activity.result.ActivityResultLauncher
import androidx.annotation.RequiresApi
import androidx.core.content.ContextCompat
import androidx.fragment.app.Fragment

internal object PermissionCompat {

internal fun Fragment.checkPermissionAndRequestWrite(launcher: ActivityResultLauncher<String>): Boolean {
@RequiresApi(Build.VERSION_CODES.TIRAMISU)
internal fun Fragment.checkPermissionAndRequestMediaImages(launcher: ActivityResultLauncher<String>): Boolean {
return if (!checkMediaImagesPermission()) {
launcher.launch(Manifest.permission.READ_MEDIA_IMAGES)
false
} else {
true
}
}

internal fun Fragment.checkPermissionAndRequestRead(launcher: ActivityResultLauncher<String>): Boolean {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
return checkPermissionAndRequestMediaImages(launcher)
}
return if (!checkReadPermission()) {
launcher.launch(Manifest.permission.READ_EXTERNAL_STORAGE)
false
Expand All @@ -33,6 +48,10 @@ internal object PermissionCompat {
private fun Fragment.checkReadPermission() =
requireContext().checkSelfPermissions(Manifest.permission.READ_EXTERNAL_STORAGE)

@RequiresApi(Build.VERSION_CODES.TIRAMISU)
private fun Fragment.checkMediaImagesPermission() =
requireContext().checkSelfPermissions(Manifest.permission.READ_MEDIA_IMAGES)

private fun Context.checkSelfPermissions(name: String) =
ContextCompat.checkSelfPermission(this, name) == PackageManager.PERMISSION_GRANTED

Expand Down
3 changes: 1 addition & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
android.useAndroidX=true
android.enableJetifier=true
android.disableAutomaticComponentCreation=true
android.enableJetifier=true
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Tue Nov 22 17:13:45 CST 2022
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
5 changes: 5 additions & 0 deletions material/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ android {
viewBinding { enable = true }
compileOptions {
kotlinOptions.freeCompilerArgs += listOf(Args.moduleName, Args.prefix.plus(project.name))
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlin {
jvmToolchain(17)
}
}
dependencies {
Expand Down
5 changes: 5 additions & 0 deletions media/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ android {
}
compileOptions {
kotlinOptions.freeCompilerArgs += listOf(Args.moduleName, Args.prefix.plus(project.name))
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlin {
jvmToolchain(17)
}
}
dependencies {
Expand Down
13 changes: 7 additions & 6 deletions sample/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ android {
versionName = Version.versionName
}
viewBinding { enable = true }
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlin {
jvmToolchain(17)
}
}
dependencies {
implementation(project(":media"))
Expand All @@ -22,12 +29,6 @@ dependencies {
implementation(project(":material"))
implementation(project(":wechat"))

// implementation(Dep.scan)
// implementation(Dep.core)
// implementation(Dep.compat)
// implementation(Dep.material_ui)
// implementation(Dep.wechat_ui)

implementation(Dep.material)
implementation(Dep.fragment)
implementation(Dep.activity)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.Glide
import com.bumptech.glide.request.RequestOptions
import develop.file.gallery.compat.fragment.GalleryGridFragment
import develop.file.gallery.compat.extensions.callbacks.SimpleGalleryCallback
import develop.file.gallery.compat.widget.GalleryImageView
import develop.file.gallery.args.GalleryConfigs
import develop.file.gallery.args.GridConfig
import develop.file.gallery.callback.IGalleryImageLoader
import develop.file.gallery.compat.extensions.callbacks.SimpleGalleryCallback
import develop.file.gallery.compat.fragment.GalleryGridFragment
import develop.file.gallery.compat.widget.GalleryImageView
import develop.file.gallery.entity.ScanEntity
import develop.file.media.Types

Expand Down
8 changes: 4 additions & 4 deletions sample/src/main/java/com/gallery/sample/SampleActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ import com.gallery.sample.callbacks.SimpleGalleryListener
import com.gallery.sample.camera.SimpleGalleryCameraActivity
import com.gallery.sample.databinding.SimpleActivityMainBinding
import com.gallery.sample.layout.LayoutActivity
import develop.file.gallery.ui.material.activity.MaterialGalleryActivity
import develop.file.gallery.ui.material.args.MaterialGalleryConfig
import develop.file.gallery.ui.wechat.result.WeChatGalleryResultCallback
import develop.file.gallery.ui.wechat.weChatGallery
import develop.file.gallery.args.GalleryConfigs
import develop.file.gallery.compat.Gallery.Companion.startGallery
import develop.file.gallery.compat.extensions.callbacks.GalleryResultCallback
import develop.file.gallery.entity.ScanEntity
import develop.file.gallery.ui.material.activity.MaterialGalleryActivity
import develop.file.gallery.ui.material.args.MaterialGalleryConfig
import develop.file.gallery.ui.wechat.result.WeChatGalleryResultCallback
import develop.file.gallery.ui.wechat.weChatGallery

class SampleActivity : GalleryListActivity() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import android.content.Intent
import android.net.Uri
import androidx.activity.result.contract.ActivityResultContracts
import androidx.core.os.bundleOf
import develop.file.gallery.ui.material.activity.MaterialGalleryActivity
import develop.file.gallery.compat.extensions.ActivityCompat.requireGalleryFragment
import develop.file.gallery.ui.material.activity.MaterialGalleryActivity

class SimpleGalleryCameraActivity : MaterialGalleryActivity() {

Expand Down
2 changes: 1 addition & 1 deletion sample/src/main/java/com/gallery/sample/layout/Layout.kt
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class LayoutActivity : MaterialGalleryActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val adViewRoot = View.inflate(this, R.layout.simple_layout_ad_view, null)
val viewGroup = findViewById<ViewGroup>(R.id.galleryRootView)
val viewGroup = findViewById<ViewGroup>(com.gallery.ui.material.R.id.galleryRootView)
viewGroup.addView(adViewRoot, 1)
viewGroup.findViewById<BannerLayout>(R.id.banner)
.setOnBannerImageLoader(GlideImageLoader())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ class GalleryConfigsSettingView @JvmOverloads constructor(
private const val DEFAULT_TEXT_SIZE_MAX = 16F
private const val DEFAULT_TEXT_SIZE_MIN = 12F

private const val DEFAULT_EMPTY_AND_CAMERA_ICON = R.drawable.ic_default_camera_drawable
private val DEFAULT_EMPTY_AND_CAMERA_ICON =
com.gallery.core.R.drawable.ic_default_camera_drawable
}

private val viewBinding: SimpleLayoutGallerySettingBinding =
Expand Down Expand Up @@ -96,8 +97,8 @@ class GalleryConfigsSettingView @JvmOverloads constructor(
R.id.radio_accent -> R.drawable.simple_app_selector_gallery_item_check
R.id.radio_box -> R.drawable.simple_default_selector_rb_check
R.id.radio_blue -> R.drawable.simple_blue_selector_gallery_item_check
R.id.radio_default -> R.drawable.selector_default_gallery_item_check
else -> R.drawable.selector_default_gallery_item_check
R.id.radio_default -> com.gallery.core.R.drawable.selector_default_gallery_item_check
else -> com.gallery.core.R.drawable.selector_default_gallery_item_check
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ class GallerySelectIconAdapter(private val action: (item: Pair<String, Int>) ->

private val items = arrayListOf<Pair<String, Int>>().apply {
add("ic_launcher" to R.mipmap.ic_launcher)
add("ic_default_camera_drawable" to R.drawable.ic_default_camera_drawable)
add("ic_default_camera_drawable" to com.gallery.core.R.drawable.ic_default_camera_drawable)
add("ic_simple_camera_2" to R.drawable.ic_simple_camera_2)
add("ic_material_gallery_back" to R.drawable.ic_material_gallery_back)
add("ic_material_gallery_finder" to R.drawable.ic_material_gallery_finder)
add("ic_wechat_gallery_finder_action" to R.drawable.ic_wechat_gallery_finder_action)
add("ic_wechat_gallery_finder_check" to R.drawable.ic_wechat_gallery_finder_check)
add("ic_wechat_gallery_item_checkbox_true" to R.drawable.ic_wechat_gallery_item_checkbox_true)
add("ic_wechat_gallery_item_gif" to R.drawable.ic_wechat_gallery_item_gif)
add("ic_wechat_gallery_item_video" to R.drawable.ic_wechat_gallery_item_video)
add("ic_wechat_gallery_prev_play" to R.drawable.ic_wechat_gallery_prev_play)
add("ic_wechat_gallery_toolbar_back" to R.drawable.ic_wechat_gallery_toolbar_back)
add("ic_material_gallery_finder" to R.drawable.ic_material_gallery_finder)
add("ic_material_gallery_back" to com.gallery.ui.material.R.drawable.ic_material_gallery_back)
add("ic_material_gallery_finder" to com.gallery.ui.material.R.drawable.ic_material_gallery_finder)
add("ic_wechat_gallery_finder_action" to com.gallery.ui.wechat.R.drawable.ic_wechat_gallery_finder_action)
add("ic_wechat_gallery_finder_check" to com.gallery.ui.wechat.R.drawable.ic_wechat_gallery_finder_check)
add("ic_wechat_gallery_item_checkbox_true" to com.gallery.ui.wechat.R.drawable.ic_wechat_gallery_item_checkbox_true)
add("ic_wechat_gallery_item_gif" to com.gallery.ui.wechat.R.drawable.ic_wechat_gallery_item_gif)
add("ic_wechat_gallery_item_video" to com.gallery.ui.wechat.R.drawable.ic_wechat_gallery_item_video)
add("ic_wechat_gallery_prev_play" to com.gallery.ui.wechat.R.drawable.ic_wechat_gallery_prev_play)
add("ic_wechat_gallery_toolbar_back" to com.gallery.ui.wechat.R.drawable.ic_wechat_gallery_toolbar_back)
add("ic_material_gallery_finder" to com.gallery.ui.material.R.drawable.ic_material_gallery_finder)
}

override fun onCreateViewHolder(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import android.view.LayoutInflater
import android.widget.Button
import android.widget.EditText
import android.widget.FrameLayout
import com.gallery.sample.R
import com.gallery.sample.clickSelectIcon
import com.gallery.sample.clickShowColorPicker
import com.gallery.sample.databinding.SimpleLayoutGalleryUiSettingBinding
Expand All @@ -31,8 +30,10 @@ class GalleryUiSettingView @JvmOverloads constructor(
private const val DEFAULT_TEXT_SIZE_MIN = 12F
private const val DEFAULT_TOOLBAR_TEXT = "图片选择"
private const val DEFAULT_TOOLBAR_ELEVATION = 4F
private const val DEFAULT_TOOLBAR_BACK_ICON = R.drawable.ic_material_gallery_back
private const val DEFAULT_HOME_FINDER_ICON = R.drawable.ic_material_gallery_finder
private val DEFAULT_TOOLBAR_BACK_ICON =
com.gallery.ui.material.R.drawable.ic_material_gallery_back
private val DEFAULT_HOME_FINDER_ICON =
com.gallery.ui.material.R.drawable.ic_material_gallery_finder
private const val DEFAULT_HOME_FINDER_PREV_TEXT = "预览"
private const val DEFAULT_HOME_FINDER_OK_TEXT = "确定"
private const val DEFAULT_HOME_FINDER_WIDTH = 600
Expand Down
5 changes: 5 additions & 0 deletions wechat/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ android {
viewBinding { enable = true }
compileOptions {
kotlinOptions.freeCompilerArgs += listOf(Args.moduleName, Args.prefix.plus(project.name))
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlin {
jvmToolchain(17)
}
}
dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,8 @@ internal class WeChatGalleryPrevActivity : PrevCompatActivity(),
updateSelectItemVisible()
selectAdapter.updateSelect(if (config.isPrev) prevCompatArgs.prevArgs.selectList else delegate.selectItem)
selectAdapter.refreshItem(delegate.currentItem)
delegate.rootView.findViewById<View>(R.id.gallery_prev_checkbox)?.visibility = View.GONE
delegate.rootView.findViewById<View>(com.gallery.compat.R.id.gallery_prev_checkbox)?.visibility =
View.GONE
delegate.rootView.setBackgroundColor(colorBlack)
}

Expand Down

0 comments on commit 6ee8940

Please sign in to comment.