Skip to content

Commit

Permalink
refactor: update packages
Browse files Browse the repository at this point in the history
  • Loading branch information
Tommy-Geenexus committed Aug 4, 2024
1 parent 7920086 commit 73f1547
Show file tree
Hide file tree
Showing 69 changed files with 309 additions and 179 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ import androidx.test.ext.junit.runners.AndroidJUnit4
import app.cash.turbine.test
import com.none.tom.exiferaser.R
import com.none.tom.exiferaser.UserImageSelectionProto
import com.none.tom.exiferaser.imageProcessing.data.ImageMetadataSnapshot
import com.none.tom.exiferaser.imageProcessing.data.ImageProcessingProgress
import com.none.tom.exiferaser.core.image.ImageMetadataSnapshot
import com.none.tom.exiferaser.core.image.ImageProcessingProgress
import com.none.tom.exiferaser.core.image.ImageProcessingStep
import com.none.tom.exiferaser.core.image.ImageProcessingSummary
import com.none.tom.exiferaser.core.provider.CameraFileProvider
import com.none.tom.exiferaser.imageProcessing.data.ImageProcessingRepository
import com.none.tom.exiferaser.imageProcessing.data.ImageProcessingStep
import com.none.tom.exiferaser.imageProcessing.data.ImageProcessingSummary
import com.none.tom.exiferaser.main.data.CameraFileProvider
import java.io.File
import java.io.FileOutputStream
import kotlinx.coroutines.CoroutineDispatcher
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
</activity>

<provider
android:name=".main.data.CameraFileProvider"
android:name=".core.provider.CameraFileProvider"
android:authorities="com.none.tom.exiferaser.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ import androidx.navigation.fragment.NavHostFragment
import androidx.window.core.layout.WindowSizeClass
import androidx.window.core.layout.WindowWidthSizeClass
import androidx.window.layout.WindowMetricsCalculator
import com.none.tom.exiferaser.core.extension.supportedImageUrisToList
import com.none.tom.exiferaser.core.util.INTENT_ACTION_CHOOSE_IMAGE
import com.none.tom.exiferaser.core.util.INTENT_ACTION_CHOOSE_IMAGES
import com.none.tom.exiferaser.core.util.INTENT_ACTION_CHOOSE_IMAGE_DIR
import com.none.tom.exiferaser.core.util.INTENT_ACTION_LAUNCH_CAM
import com.none.tom.exiferaser.core.util.INTENT_EXTRA_CONSUMED
import com.none.tom.exiferaser.databinding.ActivityExifEraserBinding
import dagger.hilt.android.AndroidEntryPoint

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

package com.none.tom.exiferaser.imageProcessing.ui
package com.none.tom.exiferaser.core.contract

import android.app.Activity
import android.content.Context
import android.content.Intent
import android.net.Uri
import androidx.activity.result.contract.ActivityResultContract
import com.none.tom.exiferaser.MIME_TYPE_IMAGE
import com.none.tom.exiferaser.core.util.MIME_TYPE_IMAGE

class ActivityResultContractShareImages :
ActivityResultContract<Pair<String, ArrayList<Uri>>, Boolean>() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

package com.none.tom.exiferaser.main.ui
package com.none.tom.exiferaser.core.contract

import android.content.Context
import android.content.Intent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

package com.none.tom.exiferaser.main.ui
package com.none.tom.exiferaser.core.contract

import android.app.Activity
import android.content.Context
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

package com.none.tom.exiferaser.di
package com.none.tom.exiferaser.core.di

import android.content.ContentResolver
import android.content.Context
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

package com.none.tom.exiferaser.di
package com.none.tom.exiferaser.core.di

import dagger.Module
import dagger.Provides
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

package com.none.tom.exiferaser.di
package com.none.tom.exiferaser.core.di

import android.content.Context
import androidx.datastore.dataStore
import androidx.datastore.preferences.SharedPreferencesMigration
import androidx.datastore.preferences.preferencesDataStore
import com.none.tom.exiferaser.main.data.ImageSourcesSerializer
import com.none.tom.exiferaser.main.data.SelectionSerializer
import com.none.tom.exiferaser.core.serializer.ImageSourcesSerializer
import com.none.tom.exiferaser.core.serializer.SelectionSerializer
import com.none.tom.exiferaser.settings.data.SettingsRepository
import dagger.Module
import dagger.Provides
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018-2024, Tom Geiselmann (tomgapplicationsdevelopment@gmail.com)
* Copyright (c) 2024, Tom Geiselmann (tomgapplicationsdevelopment@gmail.com)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
* and associated documentation files (the "Software"), to deal in the Software without restriction,
Expand All @@ -18,14 +18,12 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

package com.none.tom.exiferaser
package com.none.tom.exiferaser.core.extension

import android.content.ClipData
import android.net.Uri
import com.none.tom.exiferaser.main.data.supportedImageFormats
import kotlin.contracts.contract
import kotlin.coroutines.CoroutineContext
import kotlinx.coroutines.ensureActive
import com.none.tom.exiferaser.core.image.supportedImageFormats
import com.none.tom.exiferaser.core.util.MIME_TYPE_IMAGE

fun ClipData.supportedImageUrisToList(): List<Uri> {
for (i in 0 until description.mimeTypeCount) {
Expand All @@ -45,27 +43,3 @@ fun ClipData.supportedImageUrisToList(): List<Uri> {
}
return uris.toList()
}

suspend fun <T> CoroutineContext.suspendRunCatching(block: suspend () -> T): Result<T> = try {
Result.success(block())
} catch (exception: Exception) {
ensureActive()
Result.failure(exception)
}

fun <E> MutableList<E>.addOrShift(element: E, shiftAtSize: Int): List<E> {
if (size >= shiftAtSize) {
removeFirstOrNull() ?: return this
}
add(element)
return this
}

fun Uri.isNotEmpty() = this != Uri.EMPTY

fun Uri?.isNotNullOrEmpty(): Boolean {
contract {
returns(true) implies (this@isNotNullOrEmpty != null)
}
return this != null && isNotEmpty()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright (c) 2024, Tom Geiselmann (tomgapplicationsdevelopment@gmail.com)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
* and associated documentation files (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge, publish, distribute,
* sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or
* substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY,WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

package com.none.tom.exiferaser.core.extension

import kotlinx.coroutines.ensureActive
import kotlin.coroutines.CoroutineContext

suspend fun <T> CoroutineContext.suspendRunCatching(block: suspend () -> T): Result<T> = try {
Result.success(block())
} catch (exception: Exception) {
ensureActive()
Result.failure(exception)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright (c) 2018-2024, Tom Geiselmann (tomgapplicationsdevelopment@gmail.com)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
* and associated documentation files (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge, publish, distribute,
* sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or
* substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY,WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

package com.none.tom.exiferaser.core.extension

fun <E> MutableList<E>.addOrShift(element: E, shiftAtSize: Int): List<E> {
if (size >= shiftAtSize) {
removeFirstOrNull() ?: return this
}
add(element)
return this
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright (c) 2024, Tom Geiselmann (tomgapplicationsdevelopment@gmail.com)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
* and associated documentation files (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge, publish, distribute,
* sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or
* substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY,WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

package com.none.tom.exiferaser.core.extension

import android.net.Uri
import kotlin.contracts.contract

fun Uri.isNotEmpty() = this != Uri.EMPTY

fun Uri?.isNotNullOrEmpty(): Boolean {
contract {
returns(true) implies (this@isNotNullOrEmpty != null)
}
return this != null && isNotEmpty()
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

package com.none.tom.exiferaser.main.data
package com.none.tom.exiferaser.core.image

import android.os.Parcelable
import kotlinx.parcelize.Parcelize
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

package com.none.tom.exiferaser.imageProcessing.data
package com.none.tom.exiferaser.core.image

import android.os.Parcelable
import kotlinx.parcelize.Parcelize
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

package com.none.tom.exiferaser.imageProcessing.data
package com.none.tom.exiferaser.core.image

import android.os.Parcelable
import kotlinx.parcelize.Parcelize
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

package com.none.tom.exiferaser.imageProcessing.data
package com.none.tom.exiferaser.core.image

import android.os.Parcelable
import kotlinx.parcelize.Parcelize
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

package com.none.tom.exiferaser.imageProcessing.data
package com.none.tom.exiferaser.core.image

import android.net.Uri
import android.os.Parcelable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

package com.none.tom.exiferaser.main.data
package com.none.tom.exiferaser.core.provider

import android.content.Context
import android.net.Uri
import androidx.core.content.FileProvider
import com.none.tom.exiferaser.R
import com.none.tom.exiferaser.TOP_LEVEL_PACKAGE_NAME
import com.none.tom.exiferaser.core.util.TOP_LEVEL_PACKAGE_NAME
import java.io.File

class CameraFileProvider : FileProvider(R.xml.file_paths) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

package com.none.tom.exiferaser.main.ui
package com.none.tom.exiferaser.core.receiver

import android.net.Uri
import android.view.View
import androidx.core.view.ContentInfoCompat
import androidx.core.view.OnReceiveContentListener
import com.none.tom.exiferaser.supportedImageUrisToList
import com.none.tom.exiferaser.core.extension.supportedImageUrisToList

class MainContentReceiver(
class DragAndDropContentReceiver(
private val onUrisReceived: (List<Uri>) -> Unit
) : OnReceiveContentListener {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

package com.none.tom.exiferaser.main.data
package com.none.tom.exiferaser.core.serializer

import androidx.datastore.core.Serializer
import com.none.tom.exiferaser.ImageSourcesProto
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

package com.none.tom.exiferaser.main.data
package com.none.tom.exiferaser.core.serializer

import androidx.datastore.core.Serializer
import com.none.tom.exiferaser.SelectionProto
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

package com.none.tom.exiferaser
package com.none.tom.exiferaser.core.ui

import android.os.Build
import android.os.Bundle
Expand All @@ -31,6 +31,7 @@ import androidx.navigation.fragment.findNavController
import androidx.viewbinding.ViewBinding
import com.google.android.material.bottomsheet.BottomSheetBehavior
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import com.none.tom.exiferaser.R
import curtains.phoneWindow

abstract class BaseBottomSheetDialogFragment<B : ViewBinding> : BottomSheetDialogFragment() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

package com.none.tom.exiferaser
package com.none.tom.exiferaser.core.ui

import android.os.Bundle
import android.view.View
Expand All @@ -33,6 +33,8 @@ import androidx.fragment.app.Fragment
import androidx.navigation.NavDirections
import androidx.navigation.fragment.findNavController
import androidx.viewbinding.ViewBinding
import com.none.tom.exiferaser.ExifEraserActivity
import com.none.tom.exiferaser.R

abstract class BaseFragment<B : ViewBinding>(
@LayoutRes layoutRes: Int
Expand Down
Loading

0 comments on commit 73f1547

Please sign in to comment.