Skip to content

Commit

Permalink
Merge ab01b6c into 2bec1d3
Browse files Browse the repository at this point in the history
  • Loading branch information
Steve-Mr authored Nov 17, 2024
2 parents 2bec1d3 + ab01b6c commit 5e43142
Show file tree
Hide file tree
Showing 32 changed files with 361 additions and 116 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,22 @@ jobs:
echo "APK_FILE_X86=$(find app/build/outputs/apk -name '*x86*.apk')" >> $GITHUB_ENV
echo "APK_FILE_X64=$(find app/build/outputs/apk -name '*x64*.apk')" >> $GITHUB_ENV
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v4
name: Upload apk (arm64-v8a)
with:
name: app-arm64-v8a-release
path: ${{ env.APK_FILE }}
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v4
name: Upload apk (armeabi-v7a)
with:
name: app-armeabi-v7a-release
path: ${{ env.APK_FILE_ARMV7 }}
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v4
name: Upload apk (x86_64)
with:
name: app-x86_64-release
path: ${{ env.APK_FILE_X64 }}
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v4
name: Upload apk (x86)
with:
name: app-x86-release
Expand Down Expand Up @@ -130,7 +130,7 @@ jobs:
- telegram-bot-api
steps:
- name: Download Artifacts
uses: actions/download-artifact@v2
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Download Telegram Bot API Binary
Expand Down Expand Up @@ -170,14 +170,14 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Clone Telegram Bot API
run: |
git clone --recursive https://github.com/tdlib/telegram-bot-api.git
git status telegram-bot-api >> telegram-bot-api-status
- name: Cache Bot API Binary
id: cache-bot-api
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: telegram-bot-api-binary
key: CI-telegram-bot-api-${{ hashFiles('telegram-bot-api-status') }}
Expand Down
52 changes: 24 additions & 28 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))

android {
compileSdk = 34
compileSdk = 35
defaultConfig {
applicationId "com.maary.shareas"
minSdkVersion 29
targetSdkVersion 34
versionCode 4
versionName "3.0-alpha-240504"
targetSdkVersion 35
versionCode 5
versionName "3.0-alpha-241117"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildFeatures {
Expand Down Expand Up @@ -80,48 +80,44 @@ android {
print(output.outputFileName)
print("--------")
}
// if (output.outputFileName.contains("x86_64")){
// def newName = output.outputFile.name
// output.outputFileName.replace("x86_64", "x64")
// }
}
}
}

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.13.0'
implementation 'androidx.activity:activity:1.8.2'
implementation "androidx.datastore:datastore-preferences:1.0.0"
implementation 'androidx.appcompat:appcompat:1.7.0'
implementation 'androidx.constraintlayout:constraintlayout:2.2.0'
implementation 'androidx.core:core-ktx:1.15.0'
implementation 'androidx.activity:activity:1.9.3'
implementation "androidx.datastore:datastore-preferences:1.1.1"
// optional - RxJava2 support
implementation "androidx.datastore:datastore-preferences-rxjava2:1.0.0"
implementation "androidx.datastore:datastore-preferences-rxjava2:1.1.1"
// optional - RxJava3 support
implementation "androidx.datastore:datastore-preferences-rxjava3:1.0.0"
implementation "androidx.fragment:fragment-ktx:1.6.2"
implementation "androidx.datastore:datastore-preferences-rxjava3:1.1.1"
implementation "androidx.fragment:fragment-ktx:1.8.5"

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

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

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


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

implementation 'io.github.hokofly:hoko-blur:1.5.3'
implementation 'com.google.android.material:material:1.12.0-rc01'
implementation 'com.google.android.material:material:1.13.0-alpha07'

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 "androidx.lifecycle:lifecycle-viewmodel-ktx:2.8.7"
implementation "androidx.lifecycle:lifecycle-viewmodel-savedstate:2.8.7"
implementation "androidx.activity:activity-ktx:1.9.3"

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

Expand Down
Binary file modified app/src/main/ic_launcher-playstore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
65 changes: 55 additions & 10 deletions app/src/main/java/com/maary/shareas/WallpaperViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,17 @@ class WallpaperViewModel : ViewModel() {
var processHome = true
var processLock = true

private var cropped: Bitmap? = null

private var bitmap: Bitmap? = null
set(value) {
Log.v("WVM", "BITMAP SET")
field = value
bakBitmap.bitmapHome = value
bakBitmap.bitmapLock = value
cropped = value
bakBitmap = bakBitmap.copy(
bitmapHome = value,
bitmapLock = value
)
_viewerState.value = bakBitmap
}

Expand Down Expand Up @@ -248,9 +253,9 @@ class WallpaperViewModel : ViewModel() {
if (processHome && processLock) {
bakBitmap = _viewerState.value
} else if (processHome) {
bakBitmap.bitmapHome = _viewerState.value.bitmapHome
bakBitmap = bakBitmap.copy(bitmapHome = _viewerState.value.bitmapHome)
} else if (processLock) {
bakBitmap.bitmapLock = _viewerState.value.bitmapLock
bakBitmap= bakBitmap.copy(bitmapLock = _viewerState.value.bitmapLock)
}
}

Expand All @@ -275,8 +280,10 @@ class WallpaperViewModel : ViewModel() {
bitmapLock = bitmap
)
}
bakBitmap.bitmapLock = bitmap
bakBitmap.bitmapHome = bitmap
bakBitmap = bakBitmap.copy(
bitmapHome = bitmap,
bitmapLock = bitmap
)
}

/**
Expand Down Expand Up @@ -843,15 +850,18 @@ class WallpaperViewModel : ViewModel() {

val resultWidth = originalWidth * scale
val resultHeight = originalHeight * scale
var resultBitmap = Bitmap.createBitmap(resultWidth, resultHeight, bitmapRaw!!.config)
val canvas = Canvas(resultBitmap)
var resultBitmap =
bitmapRaw?.config?.let { Bitmap.createBitmap(resultWidth, resultHeight, it) }
val canvas = resultBitmap?.let { Canvas(it) }
var currentX = 0
var currentY = 0

for (processedTileDeferred in processedTilesDeferred) {
val processedTile = processedTileDeferred.await()
if (processedTile != null) {
canvas.drawBitmap(processedTile, currentX.toFloat(), currentY.toFloat(), null)
if (canvas != null) {
canvas.drawBitmap(processedTile, currentX.toFloat(), currentY.toFloat(), null)
}
currentX += processedTile.width
if (currentX >= resultWidth) {
currentX = 0
Expand All @@ -860,7 +870,7 @@ class WallpaperViewModel : ViewModel() {
}
}

resultBitmap = fitBitmapToScreen(resultBitmap, context)
resultBitmap = resultBitmap?.let { fitBitmapToScreen(it, context) }

_viewerState.update { current ->
current.copy(
Expand Down Expand Up @@ -892,4 +902,39 @@ class WallpaperViewModel : ViewModel() {
}
return false
}

fun scrollToStart(): Triple<Int, Int, Int> {
return Triple(
ScrollableImageView.HORIZONTAL,
0,
0
)
}

fun scrollToEnd(): Triple<Int, Int, Int> {
return Triple(
ScrollableImageView.HORIZONTAL,
bitmap!!.width,
0
)
}

fun crop(
start: Int = 0,
end: Int = cropped!!.width) {
val safeStart = start.coerceAtLeast(0) // 起始点不能小于 0
val safeEnd = end.coerceAtMost(cropped!!.width) // 终止点不能超过 bitmap 的宽度
if (safeStart >= safeEnd) {
throw IllegalArgumentException("Start must be less than end")
}

// 计算裁剪的宽度和高度
val width = safeEnd - safeStart
val height = cropped!!.height

// 裁剪 bitmap
cropped = Bitmap.createBitmap(cropped!!, safeStart, 0, width, height)
// bitmap = cropped
updateViewerState(cropped, cropped)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,15 @@ protected void onCreate(Bundle savedInstanceState) {
//setup the fab click listener
binding.fab.setOnClickListener(view -> {
cord = binding.mainView.getVisibleRect();
builder.setTitle(R.string.setAs);
binding.bottomAppBar.getMenu().getItem(MENU_RESET).setEnabled(true);
AlertDialog dialog = builder.create();
dialog.show();
});

binding.fab.setOnLongClickListener(view -> {
cord = null;
builder.setTitle(R.string.setFullAs);
AlertDialog dialog = builder.create();
dialog.show();
return false;
Expand Down Expand Up @@ -202,7 +204,7 @@ public void onColorsChanged(@Nullable WallpaperColors colors, int which) {

//setup AlertDialog builder
builder = new MaterialAlertDialogBuilder(context);
builder.setTitle(R.string.setAs);
// builder.setTitle(R.string.setAs);

String[] options = {
getResources().getString(R.string.home),
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/com/maary/shareas/data/ViewerBitmap.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ package com.maary.shareas.data
import android.graphics.Bitmap

data class ViewerBitmap(
var bitmapHome: Bitmap? = null,
var bitmapLock: Bitmap? = null
val bitmapHome: Bitmap? = null,
val bitmapLock: Bitmap? = null
)
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import com.maary.shareas.WallpaperViewModel
import com.maary.shareas.databinding.FragmentEditorBinding
import com.maary.shareas.fragment.editor.BlurFragment
import com.maary.shareas.fragment.editor.BrightnessFragment
import com.maary.shareas.fragment.editor.CropFragment
import com.maary.shareas.fragment.editor.PaintFragment
import com.maary.shareas.fragment.editor.UpscaleFragment
import kotlinx.coroutines.launch
Expand Down Expand Up @@ -75,6 +76,7 @@ class EditorFragment : Fragment() {
binding.editorButtonBlur.backgroundTintList = colorStateList
binding.editorButtonBrightness.backgroundTintList = colorStateList
binding.editorButtonFill.backgroundTintList = colorStateList
binding.editorButtonCrop.backgroundTintList = colorStateList
binding.editorButtonUpscale.backgroundTintList = colorStateList
binding.appbarButtonCancel.setBackgroundColor(viewModel.getSecondaryColor(requireContext()))
binding.appbarButtonConfirm.setBackgroundColor(viewModel.getSecondaryColor(requireContext()))
Expand Down Expand Up @@ -177,6 +179,10 @@ class EditorFragment : Fragment() {
loadFragment(PaintFragment())
}

binding.editorButtonCrop.setOnClickListener {
loadFragment(CropFragment())
}

binding.editorButtonUpscale.setOnClickListener {
loadFragment(UpscaleFragment())
}
Expand Down
Loading

0 comments on commit 5e43142

Please sign in to comment.