Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 1.0.1 #16

Merged
merged 5 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
/.idea/appInsightsSettings.xml
/.idea/deploymentTargetDropDown.xml
.DS_Store
/build
/captures
Expand Down
2 changes: 1 addition & 1 deletion .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 10 additions & 5 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import java.io.FileInputStream
import java.util.Properties

plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.androidApplication)
alias(libs.plugins.kotlinAndroid)
}

val keystorePropertiesFile = rootProject.file("key.properties")
Expand All @@ -23,8 +23,8 @@ android {
minSdk = 26
//noinspection OldTargetApi
targetSdk = 33
versionCode = 14
versionName = "1.0.0"
versionCode = 15
versionName = "1.0.1"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down Expand Up @@ -73,7 +73,12 @@ android {
compose = true
}
composeOptions {
kotlinCompilerExtensionVersion = "1.5.7"
kotlinCompilerExtensionVersion = libs.versions.kotlinComposeCompiler.get()
}
packaging {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.material3.windowsizeclass.ExperimentalMaterial3WindowSizeClassApi
import androidx.compose.material3.windowsizeclass.WindowHeightSizeClass
import androidx.compose.material3.windowsizeclass.WindowSizeClass
Expand All @@ -72,14 +71,14 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.tooling.preview.PreviewParameter
import androidx.compose.ui.unit.dp
import androidx.documentfile.provider.DocumentFile
import androidx.preference.PreferenceManager
import com.mateusrodcosta.apps.share2storage.model.SampleUriDataProvider
import com.mateusrodcosta.apps.share2storage.model.UriData
import com.mateusrodcosta.apps.share2storage.ui.theme.AppTheme
import com.mateusrodcosta.apps.share2storage.utils.AppBasicDivider
import com.mateusrodcosta.apps.share2storage.utils.CreateDocumentWithInitialUri
import com.mateusrodcosta.apps.share2storage.utils.SharedPreferenceKeys
import com.mateusrodcosta.apps.share2storage.utils.appTopAppBarColors
import com.mateusrodcosta.apps.share2storage.utils.getUriData
import com.mateusrodcosta.apps.share2storage.utils.saveFile

Expand All @@ -99,13 +98,10 @@ class DetailsActivity : ComponentActivity() {
val defaultSaveLocationRaw =
sharedPreferences.getString(SharedPreferenceKeys.defaultSaveLocationKey, null)
Log.d("details] defaultSaveLocationRaw", defaultSaveLocationRaw.toString())
val defaultSaveLocation = if (defaultSaveLocationRaw != null) {
val parsedUri = Uri.parse(defaultSaveLocationRaw)
val file = DocumentFile.fromTreeUri(this, parsedUri)
file?.uri
} else {
null
}
val defaultSaveLocation =
if (defaultSaveLocationRaw != null) Uri.parse(defaultSaveLocationRaw)
else null

Log.d("details] defaultSaveLocation", defaultSaveLocation.toString())

var uriData: UriData? = null
Expand Down Expand Up @@ -158,12 +154,7 @@ class DetailsActivity : ComponentActivity() {
Scaffold(topBar = {
TopAppBar(
title = { Text(stringResource(R.string.file_details)) },
colors = TopAppBarDefaults.topAppBarColors(
containerColor = MaterialTheme.colorScheme.primary,
titleContentColor = MaterialTheme.colorScheme.onPrimary,
navigationIconContentColor = MaterialTheme.colorScheme.onPrimary,
actionIconContentColor = MaterialTheme.colorScheme.onPrimary,
),
colors = appTopAppBarColors(),
)
}, floatingActionButton =

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.scale
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalUriHandler
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
Expand All @@ -59,6 +59,7 @@ import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.mateusrodcosta.apps.share2storage.ui.theme.AppTheme
import com.mateusrodcosta.apps.share2storage.utils.AppBasicDivider
import com.mateusrodcosta.apps.share2storage.utils.appTopAppBarColors

class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
Expand All @@ -71,25 +72,20 @@ class MainActivity : ComponentActivity() {
@Composable
@Preview
fun MainScreen() {
val context = this
val context = LocalContext.current
AppTheme {
Scaffold(topBar = {
TopAppBar(
title = { Text(stringResource(R.string.app_name)) },
actions = {
IconButton(onClick = {
val i = Intent(context, SettingsActivity::class.java)
startActivity(i)
val intent = Intent(context, SettingsActivity::class.java)
context.startActivity(intent)
}) {
Icon(Icons.Rounded.Settings, stringResource(id = R.string.settings))
}
},
colors = TopAppBarDefaults.topAppBarColors(
containerColor = MaterialTheme.colorScheme.primary,
titleContentColor = MaterialTheme.colorScheme.onPrimary,
navigationIconContentColor = MaterialTheme.colorScheme.onPrimary,
actionIconContentColor = MaterialTheme.colorScheme.onPrimary,
),
colors = appTopAppBarColors(),
)
}) { paddingValues ->
Box(modifier = Modifier.padding(paddingValues)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ import androidx.compose.material3.Scaffold
import androidx.compose.material3.Switch
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
Expand All @@ -65,6 +64,7 @@ import androidx.core.content.edit
import androidx.preference.PreferenceManager
import com.mateusrodcosta.apps.share2storage.ui.theme.AppTheme
import com.mateusrodcosta.apps.share2storage.utils.SharedPreferenceKeys
import com.mateusrodcosta.apps.share2storage.utils.appTopAppBarColors


class SettingsActivity : ComponentActivity() {
Expand Down Expand Up @@ -136,15 +136,21 @@ class SettingsActivity : ComponentActivity() {
if (spDefaultSaveLocation != null) {
val curDefaultSaveLocation = spDefaultSaveLocation!!
contentResolver.persistedUriPermissions.forEach {
if (it.uri == curDefaultSaveLocation) contentResolver.releasePersistableUriPermission(
curDefaultSaveLocation,
FLAG_GRANT_READ_URI_PERMISSION or FLAG_GRANT_WRITE_URI_PERMISSION
)
if (it.uri == curDefaultSaveLocation) {
val isRead = if (it.isReadPermission) FLAG_GRANT_READ_URI_PERMISSION
else 0
val isWrite = if (it.isWritePermission) FLAG_GRANT_WRITE_URI_PERMISSION
else 0

contentResolver.releasePersistableUriPermission(
curDefaultSaveLocation, isRead or isWrite
)
}
}
}
if (value != null) {
contentResolver.takePersistableUriPermission(
value, FLAG_GRANT_READ_URI_PERMISSION or FLAG_GRANT_WRITE_URI_PERMISSION
value, FLAG_GRANT_WRITE_URI_PERMISSION
)
}
defaultSaveLocation = value
Expand All @@ -153,12 +159,7 @@ class SettingsActivity : ComponentActivity() {
AppTheme {
Scaffold(topBar = {
TopAppBar(title = { Text(stringResource(R.string.settings)) },
colors = TopAppBarDefaults.topAppBarColors(
containerColor = MaterialTheme.colorScheme.primary,
titleContentColor = MaterialTheme.colorScheme.onPrimary,
navigationIconContentColor = MaterialTheme.colorScheme.onPrimary,
actionIconContentColor = MaterialTheme.colorScheme.onPrimary,
),
colors = appTopAppBarColors(),
navigationIcon = {
IconButton(onClick = { finish() }) {
Icon(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package com.mateusrodcosta.apps.share2storage.utils
import android.content.Context
import android.content.Intent
import android.net.Uri
import android.provider.DocumentsContract
import android.provider.DocumentsContract.EXTRA_INITIAL_URI
import android.util.Log
import androidx.activity.result.contract.ActivityResultContracts.CreateDocument
Expand All @@ -31,7 +32,12 @@ class CreateDocumentWithInitialUri(
override fun createIntent(context: Context, input: String): Intent {
return super.createIntent(context, input).also { i ->
Log.d("CreateDocumentWithInitialUri] initialUri", initialUri.toString())
if (initialUri != null) i.putExtra(EXTRA_INITIAL_URI, initialUri)
if (initialUri != null)
{
val documentUri = DocumentsContract.buildDocumentUriUsingTree(initialUri, DocumentsContract.getTreeDocumentId(initialUri))
Log.d("CreateDocumentWithInitialUri] documentUri", documentUri.toString())
i.putExtra(EXTRA_INITIAL_URI, documentUri)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ package com.mateusrodcosta.apps.share2storage.utils

import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Divider
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.TopAppBarColors
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.Dp
Expand All @@ -27,4 +31,15 @@ import androidx.compose.ui.unit.dp
@Composable
fun AppBasicDivider() {
Divider(modifier = Modifier.padding(horizontal = 16.dp), thickness = Dp.Hairline)
}

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun appTopAppBarColors(): TopAppBarColors {
return TopAppBarDefaults.topAppBarColors(
containerColor = MaterialTheme.colorScheme.primary,
titleContentColor = MaterialTheme.colorScheme.onPrimary,
navigationIconContentColor = MaterialTheme.colorScheme.onPrimary,
actionIconContentColor = MaterialTheme.colorScheme.onPrimary,
)
}
5 changes: 2 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
plugins {
alias(libs.plugins.android.application) apply false
alias(libs.plugins.android.library) apply false
alias(libs.plugins.kotlin.android) apply false
alias(libs.plugins.androidApplication) apply false
alias(libs.plugins.kotlinAndroid) apply false
}
1 change: 1 addition & 0 deletions fastlane/metadata/android/en-US/changelogs/15.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Several improvements to app code quality
1 change: 1 addition & 0 deletions fastlane/metadata/android/pt-BR/changelogs/15.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Várias melhorias na qualidade do código do app
5 changes: 3 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
org.gradle.jvmargs=-Xmx2048M -Dkotlin.daemon.jvm.options\="-Xmx2048M"
org.gradle.jvmargs=-Xmx4096M -Dfile.encoding=UTF-8 -XX:+UseParallelGC -Dkotlin.daemon.jvm.options="-Xmx4096M"
android.useAndroidX=true
org.gradle.caching=true
org.gradle.configuration-cache=true
org.gradle.parallel=true
org.gradle.parallel=true
kotlin.code.style=official
10 changes: 5 additions & 5 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[versions]
androidGradlePlugin = "8.2.1"
kotlin = "1.9.21"
agp = "8.2.1"
kotlin = "1.9.22"
kotlinComposeCompiler = "1.5.8"
ktx = "1.12.0"
preference-ktx = "1.2.1"
composeBom = "2023.10.01"
Expand Down Expand Up @@ -35,6 +36,5 @@ testing = ["junit.junit"]
ui-testing = ["androidx.test.runner", "androidx.test.rules", "compose.ui.test.junit4"]

[plugins]
android-application = { id = "com.android.application", version.ref = "androidGradlePlugin" }
android-library = { id = "com.android.library", version.ref = "androidGradlePlugin" }
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
androidApplication = { id = "com.android.application", version.ref = "agp" }
kotlinAndroid = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
gradlePluginPortal()
}
}
dependencyResolutionManagement {
Expand Down