Skip to content

Commit

Permalink
Merge 666126c into e6eef12
Browse files Browse the repository at this point in the history
  • Loading branch information
Steve-Mr authored Apr 19, 2024
2 parents e6eef12 + 666126c commit 897c1f4
Show file tree
Hide file tree
Showing 54 changed files with 2,854 additions and 847 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ Share image to WallpaperTunnel to set it as wallpaper.

- Provide a simple method for setting images as wallpapers.
- Allow adjustment of image brightness and blur intensity.
- Fill images with solid color or blurred images.
- Image Super-Resolution. (Beta)
- Maintain a history of wallpapers set through this app.
- Retrieve and modify the current wallpaper (static wallpapers only).

Expand Down
27 changes: 17 additions & 10 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ android {
minSdkVersion 29
targetSdkVersion 34
versionCode 4
versionName "2.5-alpha-240411"
versionName "3.0-alpha-240419"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildFeatures {
Expand Down Expand Up @@ -59,11 +59,11 @@ android {
universalApk false
}
}
task wrapper(type: Wrapper) {
tasks.register('wrapper', Wrapper) {
gradleVersion = '8.0'
}
namespace 'com.maary.shareas'
applicationVariants.all { variant ->
applicationVariants.configureEach { variant ->
variant.outputs.each { output ->
def newName = output.outputFileName
print(newName)
Expand Down Expand Up @@ -92,14 +92,25 @@ 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.12.0'
implementation 'androidx.core:core-ktx:1.12.0'
implementation 'androidx.core:core-ktx:1.13.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"
implementation "androidx.fragment:fragment-ktx:1.6.2"

implementation 'com.microsoft.onnxruntime:onnxruntime-android:1.17.3'
implementation 'com.microsoft.onnxruntime:onnxruntime-extensions-android:0.9.0'

implementation("androidx.transition:transition:1.5.0-rc02")
implementation("androidx.transition:transition-ktx:1.5.0-rc02")

implementation "androidx.fragment:fragment:1.7.0-rc02"
// Kotlin
implementation "androidx.fragment:fragment-ktx:1.7.0-rc02"


testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
Expand All @@ -114,9 +125,5 @@ dependencies {

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

//noinspection GradleCompatible
implementation 'com.android.support:palette-v7:28.0.0'


//TODO: implement monet for photo imported
implementation 'androidx.palette:palette:1.0.0'
}
16 changes: 8 additions & 8 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,9 @@
<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_IMAGES" />
<uses-permission android:name="android.permission.READ_MEDIA_VISUAL_USER_SELECTED" />


<application
android:allowBackup="true"
android:enableOnBackInvokedCallback="true"
Expand All @@ -28,8 +25,7 @@
tools:targetApi="tiramisu">
<activity
android:name=".activity.WelcomeActivity"
android:exported="true">
</activity>
android:exported="true"/>
<activity
android:name=".activity.HistoryActivity"
android:configChanges="uiMode"
Expand All @@ -39,7 +35,9 @@
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.SEND" />

<category android:name="android.intent.category.DEFAULT" />

<data android:mimeType="image/*" />
</intent-filter>
</activity>
Expand All @@ -48,11 +46,13 @@
android:exported="true">
<intent-filter>
<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" />

<meta-data
android:name="android.app.shortcuts"
android:resource="@xml/shortcuts" />
</activity>

<service
Expand Down
47 changes: 8 additions & 39 deletions app/src/main/java/com/maary/shareas/HistoryActivityViewModel.kt
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package com.maary.shareas

import android.annotation.SuppressLint
import android.app.Activity
import android.app.Application
import android.app.RecoverableSecurityException
import android.content.*
import android.content.ContentProvider
import android.content.ContentResolver
import android.content.ContentUris
import android.content.IntentSender
import android.database.ContentObserver
import android.database.Cursor
import android.net.Uri
Expand All @@ -18,13 +19,12 @@ import androidx.lifecycle.AndroidViewModel
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.viewModelScope
import com.maary.shareas.data.MediaStoreImage
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import java.text.SimpleDateFormat
import java.util.*
import java.util.Date
import java.util.concurrent.TimeUnit
import kotlin.collections.ArrayList

class HistoryActivityViewModel(application: Application) : AndroidViewModel(application) {
private val _images = MutableLiveData<List<MediaStoreImage>>()
Expand Down Expand Up @@ -55,17 +55,6 @@ class HistoryActivityViewModel(application: Application) : AndroidViewModel(appl
}
}

fun getUriList(): ArrayList<Uri> {
val uriList = ArrayList<Uri>()
viewModelScope.launch {
val images = queryImages()

for (image in images) uriList.add(image.contentUri)

}
return uriList
}

@RequiresApi(Build.VERSION_CODES.R)
fun deleteImage(image: MediaStoreImage) {
viewModelScope.launch {
Expand Down Expand Up @@ -215,7 +204,7 @@ class HistoryActivityViewModel(application: Application) : AndroidViewModel(appl
Log.i(TAG, "Found ${cursor.count} images")
while (cursor.moveToNext()) {

// Here we'll use the column indexs that we found above.
// Here we'll use the column index that we found above.
val id = cursor.getLong(idColumn)
val dateModified =
Date(TimeUnit.SECONDS.toMillis(cursor.getLong(dateModifiedColumn)))
Expand Down Expand Up @@ -292,14 +281,8 @@ class HistoryActivityViewModel(application: Application) : AndroidViewModel(appl
* so it can be either updated or deleted.
*/

val pendingIntent = MediaStore.createDeleteRequest(getApplication<Application>().contentResolver, arrayListOf(image.contentUri))
// getApplication<Activity>().startIntentSenderForResult(pendingIntent.intentSender, null, 0, 0, 0)
MediaStore.createDeleteRequest(getApplication<Application>().contentResolver, arrayListOf(image.contentUri))

// getApplication<Application>().contentResolver.delete(
// image.contentUri,
// "${MediaStore.Images.Media._ID} = ?",
// arrayOf(image.id.toString())
// )
} catch (securityException: SecurityException) {
val recoverableSecurityException =
securityException as? RecoverableSecurityException
Expand All @@ -315,20 +298,6 @@ class HistoryActivityViewModel(application: Application) : AndroidViewModel(appl
}
}

/**
* Convenience method to convert a day/month/year date into a UNIX timestamp.
*
* We're suppressing the lint warning because we're not actually using the date formatter
* to format the date to display, just to specify a format to use to parse it, and so the
* locale warning doesn't apply.
*/
@Suppress("SameParameterValue")
@SuppressLint("SimpleDateFormat")
private fun dateToTimestamp(day: Int, month: Int, year: Int): Long =
SimpleDateFormat("dd.MM.yyyy").let { formatter ->
TimeUnit.MICROSECONDS.toSeconds(formatter.parse("$day.$month.$year")?.time ?: 0)
}

/**
* Since we register a [ContentObserver], we want to unregister this when the `ViewModel`
* is being released.
Expand Down
Loading

0 comments on commit 897c1f4

Please sign in to comment.