Skip to content

Commit

Permalink
Merge pull request #21 from Steve-Mr/wheel
Browse files Browse the repository at this point in the history
界面更新
  • Loading branch information
Steve-Mr authored Apr 11, 2024
2 parents bc76777 + 2352207 commit adcac1f
Show file tree
Hide file tree
Showing 37 changed files with 1,736 additions and 199 deletions.
30 changes: 18 additions & 12 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@ def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))

android {
compileSdkVersion 33
buildToolsVersion '31.0.0'
compileSdk = 34
defaultConfig {
applicationId "com.maary.shareas"
minSdkVersion 29
targetSdkVersion 32
targetSdkVersion 34
versionCode 4
versionName "2.2_beta_230625"
versionName "2.5-alpha-240411"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildFeatures {
Expand Down Expand Up @@ -93,21 +92,28 @@ dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.core:core-ktx:1.10.1'
implementation 'androidx.core:core-ktx:1.10.1'
implementation 'androidx.core:core-ktx:1.12.0'
implementation 'androidx.core:core-ktx:1.12.0'
implementation 'androidx.activity:activity:1.8.2'
implementation "androidx.datastore:datastore-preferences:1.0.0"
// optional - RxJava2 support
implementation "androidx.datastore:datastore-preferences-rxjava2:1.0.0"
// optional - RxJava3 support
implementation "androidx.datastore:datastore-preferences-rxjava3:1.0.0"

testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'

// implementation 'com.hoko:hoko-blur:1.3.5'
implementation 'io.github.hokofly:hoko-blur:1.5.1'
implementation 'com.google.android.material:material:1.9.0'
implementation 'io.github.hokofly:hoko-blur:1.5.3'
implementation 'com.google.android.material:material:1.11.0'

implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.1"
implementation "androidx.lifecycle:lifecycle-viewmodel-savedstate:2.6.1"
implementation "androidx.activity:activity-ktx:1.7.2"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.7.0"
implementation "androidx.lifecycle:lifecycle-viewmodel-savedstate:2.7.0"
implementation "androidx.activity:activity-ktx:1.8.2"

implementation 'com.github.bumptech.glide:glide:4.15.1'
implementation 'com.github.bumptech.glide:glide:4.16.0'

//noinspection GradleCompatible
implementation 'com.android.support:palette-v7:28.0.0'
Expand Down
57 changes: 38 additions & 19 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,57 +4,76 @@

<uses-permission android:name="android.permission.SET_WALLPAPER" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.MANAGE_MEDIA"
<uses-permission
android:name="android.permission.MANAGE_MEDIA"
tools:ignore="ProtectedPermissions" />
<uses-permission
android:name="android.permission.MANAGE_EXTERNAL_STORAGE"
tools:ignore="ScopedStorage" />
<uses-permission
android:name="android.permission.READ_MEDIA_IMAGES"/>

<uses-permission android:name="android.permission.READ_MEDIA_VISUAL_USER_SELECTED" />


<application
android:allowBackup="true"
android:enableOnBackInvokedCallback="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:enableOnBackInvokedCallback="true"
tools:ignore="GoogleAppIndexingWarning"
tools:targetApi="tiramisu">
<activity
android:name=".HistoryActivity"
android:exported="true"
android:configChanges="uiMode" />
android:name=".activity.WelcomeActivity"
android:exported="true">
</activity>
<activity
android:name=".activity.HistoryActivity"
android:configChanges="uiMode"
android:exported="true" />
<activity
android:name=".MainActivity"
android:name=".activity.MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
</activity>

<service android:name=".QSTileService"
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"
android:icon="@drawable/ic_history"
<activity
android:name=".activity.StartActivity"
android:exported="true">

<intent-filter>
<action android:name="android.service.quicksettings.action.QS_TILE"/>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data android:name="android.app.shortcuts"
android:resource="@xml/shortcuts" />

</activity>

<service
android:name=".QSTileService"
android:exported="true"
android:icon="@drawable/ic_history"
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
<intent-filter>
<action android:name="android.service.quicksettings.action.QS_TILE" />
</intent-filter>
</service>

<receiver
android:name=".MainActivity$ShareReceiver"
android:name=".activity.MainActivity$ShareReceiver"
android:exported="false" />

<provider
android:name="androidx.core.content.FileProvider"
android:authorities="com.maary.shareas.provider"
android:grantUriPermissions="true"
android:exported="false">
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/filepaths" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ import android.database.Cursor
import android.net.Uri
import android.os.Build
import android.os.Handler
import android.os.Looper
import android.provider.MediaStore
import android.util.Log
import androidx.annotation.RequiresApi
import androidx.lifecycle.AndroidViewModel
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
Expand Down Expand Up @@ -64,12 +66,14 @@ class HistoryActivityViewModel(application: Application) : AndroidViewModel(appl
return uriList
}

@RequiresApi(Build.VERSION_CODES.R)
fun deleteImage(image: MediaStoreImage) {
viewModelScope.launch {
performDeleteImage(image)
}
}

@RequiresApi(Build.VERSION_CODES.R)
fun deletePendingImage() {
pendingDeleteImage?.let { image ->
pendingDeleteImage = null
Expand Down Expand Up @@ -250,7 +254,7 @@ class HistoryActivityViewModel(application: Application) : AndroidViewModel(appl

val image = MediaStoreImage(id, displayName, dateModified, contentUri, width = width, height = height)

Log.v("WLAP", width.toString() + " " + height.toString())
Log.v("WLAP", "$width $height")
images += image

// For debugging, we'll output the image objects we create to logcat.
Expand All @@ -263,6 +267,7 @@ class HistoryActivityViewModel(application: Application) : AndroidViewModel(appl
return images
}

@RequiresApi(Build.VERSION_CODES.R)
private suspend fun performDeleteImage(image: MediaStoreImage) {
withContext(Dispatchers.IO) {
try {
Expand Down Expand Up @@ -342,7 +347,7 @@ private fun ContentResolver.registerObserver(
uri: Uri,
observer: (selfChange: Boolean) -> Unit
): ContentObserver {
val contentObserver = object : ContentObserver(Handler()) {
val contentObserver = object : ContentObserver(Handler(Looper.getMainLooper())) {
override fun onChange(selfChange: Boolean) {
observer(selfChange)
}
Expand Down
16 changes: 15 additions & 1 deletion app/src/main/java/com/maary/shareas/QSTileService.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package com.maary.shareas

import android.app.PendingIntent
import android.content.Intent
import android.content.Intent.FLAG_ACTIVITY_NEW_TASK
import android.os.Build
import android.service.quicksettings.TileService
import com.maary.shareas.activity.HistoryActivity

class QSTileService: TileService() {
override fun onClick() {
Expand All @@ -11,6 +14,17 @@ class QSTileService: TileService() {
val intent = Intent(this, HistoryActivity::class.java)
.addFlags(FLAG_ACTIVITY_NEW_TASK)

startActivityAndCollapse(intent)
val pendingIntent = PendingIntent.getActivity(
this,
0,
intent,
PendingIntent.FLAG_UPDATE_CURRENT or
PendingIntent.FLAG_IMMUTABLE)

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE){
startActivityAndCollapse(pendingIntent)
}else {
startActivityAndCollapse(intent)
}
}
}
13 changes: 0 additions & 13 deletions app/src/main/java/com/maary/shareas/WallpaperAdapter.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.maary.shareas
package com.maary.shareas.activity

import android.Manifest
import android.app.Activity
Expand All @@ -19,19 +19,23 @@ import android.view.WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS
import android.widget.ImageView
import androidx.activity.result.IntentSenderRequest
import androidx.activity.viewModels
import androidx.annotation.RequiresApi
import androidx.appcompat.app.AppCompatActivity
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat
import androidx.core.view.*
import androidx.databinding.DataBindingUtil
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.Glide
import com.google.android.material.color.DynamicColors
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.maary.shareas.HistoryActivityViewModel
import com.maary.shareas.MediaStoreImage
import com.maary.shareas.R
import com.maary.shareas.helper.Util
import com.maary.shareas.databinding.ActivityHistoryBinding
import kotlinx.coroutines.*

Expand Down Expand Up @@ -101,11 +105,6 @@ class HistoryActivity : AppCompatActivity(){

}

// val galleryAdapter = GalleryAdapter (
// onClick = {image -> openImage(image)},
// onLongClick = {image -> deleteImage(image)}
// )

binding.gallery.also { view ->
view.layoutManager = GridLayoutManager(this, 3)
view.adapter = galleryAdapter
Expand Down Expand Up @@ -202,6 +201,7 @@ class HistoryActivity : AppCompatActivity(){
}
}

@RequiresApi(Build.VERSION_CODES.R)
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (resultCode == Activity.RESULT_OK && requestCode == DELETE_PERMISSION_REQUEST) {
Expand Down Expand Up @@ -256,9 +256,18 @@ class HistoryActivity : AppCompatActivity(){
if (!haveStoragePermission()) {
val permissions = arrayOf(
Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.WRITE_EXTERNAL_STORAGE
// Manifest.permission.WRITE_EXTERNAL_STORAGE,
)

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU){
val permissionsT = arrayOf(
Manifest.permission.READ_MEDIA_IMAGES,
// Manifest.permission.WRITE_EXTERNAL_STORAGE,
)
ActivityCompat.requestPermissions(this, permissionsT, READ_EXTERNAL_STORAGE_REQUEST)
}else{
ActivityCompat.requestPermissions(this, permissions, READ_EXTERNAL_STORAGE_REQUEST)
}
}
}

Expand Down Expand Up @@ -358,7 +367,6 @@ class HistoryActivity : AppCompatActivity(){

Glide.with(holder.imageView)
.load(mediaStoreImage.contentUri)
.thumbnail(0.33f)
.centerCrop()
.into(holder.imageView)
}
Expand Down
Loading

0 comments on commit adcac1f

Please sign in to comment.