Skip to content

Commit

Permalink
Merge pull request #39 from skydoves/agp/8.1.1
Browse files Browse the repository at this point in the history
Bump AGP, Compose, Kotlin, and other androidx dependencies
  • Loading branch information
skydoves authored Oct 1, 2023
2 parents f4d2422 + 9b1c16c commit 764298c
Show file tree
Hide file tree
Showing 29 changed files with 1,386 additions and 1,378 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
root = true
[*]
# Most of the standard properties are supported
indent_size=4
indent_size=2
max_line_length=100
81 changes: 41 additions & 40 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,62 +3,63 @@ import com.github.skydoves.colorpicker.compose.Dependencies
import com.github.skydoves.colorpicker.compose.Versions

plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
}

android {
compileSdkVersion Configuration.compileSdk
defaultConfig {
applicationId "com.github.skydoves.colorpickercomposedemo"
minSdkVersion Configuration.minSdk
targetSdkVersion Configuration.targetSdk
versionCode Configuration.versionCode
versionName Configuration.versionName
}
compileSdk Configuration.compileSdk
namespace "com.github.skydoves.colorpickercomposedemo"
defaultConfig {
applicationId "com.github.skydoves.colorpickercomposedemo"
minSdkVersion Configuration.minSdk
targetSdkVersion Configuration.targetSdk
versionCode Configuration.versionCode
versionName Configuration.versionName
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

kotlinOptions {
jvmTarget = '1.8'
}
kotlinOptions {
jvmTarget = '1.8'
}

composeOptions {
kotlinCompilerExtensionVersion Versions.COMPOSE_COMPILER
}
composeOptions {
kotlinCompilerExtensionVersion Versions.COMPOSE_COMPILER
}

buildFeatures {
compose true
}
buildFeatures {
compose true
}

packagingOptions {
resources {
excludes += '/META-INF/{AL2.0,LGPL2.1}'
}
packagingOptions {
resources {
excludes += '/META-INF/{AL2.0,LGPL2.1}'
}
}

lintOptions {
abortOnError false
}
lintOptions {
abortOnError false
}
}

dependencies {
implementation project(":colorpicker-compose")
implementation project(":colorpicker-compose")

implementation Dependencies.material
implementation Dependencies.material

implementation platform(Dependencies.composeBom)
implementation Dependencies.composeUI
implementation Dependencies.composeMaterial
implementation Dependencies.composeRuntime
implementation Dependencies.composeTooling
implementation Dependencies.composeActivity
implementation Dependencies.composeNavigation
implementation platform(Dependencies.composeBom)
implementation Dependencies.composeUI
implementation Dependencies.composeMaterial
implementation Dependencies.composeRuntime
implementation Dependencies.composeTooling
implementation Dependencies.composeActivity
implementation Dependencies.composeNavigation

implementation Dependencies.photoPicker
implementation Dependencies.photoPicker
}

apply from: "$rootDir/spotless.gradle"
34 changes: 17 additions & 17 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.github.skydoves.colorpickercomposedemo">
package="com.github.skydoves.colorpickercomposedemo">

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.ColorPickerComposeDemo">
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.ColorPickerComposeDemo">
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent

class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

setContent { MainScreen() }
}
setContent { MainScreen() }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,82 +46,82 @@ import com.github.skydoves.colorpickercomposedemo.screens.HsvColorPickerColoredS
import com.github.skydoves.colorpickercomposedemo.screens.ImageColorPickerScreen

sealed class Screen(val route: String, val name: String, @DrawableRes val drawable: Int) {
object ImageColorPicker : Screen("image_picker", "Image", R.drawable.image_24px)
object HsvPicker : Screen("hsv_picker", "HSV", R.drawable.palette_24px)
object ImageColorPicker : Screen("image_picker", "Image", R.drawable.image_24px)
object HsvPicker : Screen("hsv_picker", "HSV", R.drawable.palette_24px)
}

val navigationItems = listOf(
Screen.ImageColorPicker,
Screen.HsvPicker,
Screen.ImageColorPicker,
Screen.HsvPicker,
)

@Composable
fun MainScreen() {
val navController = rememberNavController()
Scaffold(
bottomBar = { BottomBar(navController) },
topBar = { MainToolBar() },
) { innerPadding ->
NavHost(
navController,
startDestination = Screen.ImageColorPicker.route,
Modifier.padding(innerPadding),
) {
composable(Screen.ImageColorPicker.route) {
ImageColorPickerScreen()
}
composable(Screen.HsvPicker.route) {
HsvColorPickerColoredSelectorScreen()
}
}
val navController = rememberNavController()
Scaffold(
bottomBar = { BottomBar(navController) },
topBar = { MainToolBar() },
) { innerPadding ->
NavHost(
navController,
startDestination = Screen.ImageColorPicker.route,
Modifier.padding(innerPadding),
) {
composable(Screen.ImageColorPicker.route) {
ImageColorPickerScreen()
}
composable(Screen.HsvPicker.route) {
HsvColorPickerColoredSelectorScreen()
}
}
}
}

@Composable
fun MainToolBar() {
TopAppBar(
elevation = 6.dp,
backgroundColor = Color(0xFF6200EE),
modifier = Modifier.height(58.dp),
) {
Text(
modifier = Modifier
.padding(8.dp)
.align(Alignment.CenterVertically),
text = stringResource(R.string.app_name),
color = Color.White,
fontSize = 18.sp,
fontWeight = FontWeight.Bold,
)
}
TopAppBar(
elevation = 6.dp,
backgroundColor = Color(0xFF6200EE),
modifier = Modifier.height(58.dp),
) {
Text(
modifier = Modifier
.padding(8.dp)
.align(Alignment.CenterVertically),
text = stringResource(R.string.app_name),
color = Color.White,
fontSize = 18.sp,
fontWeight = FontWeight.Bold,
)
}
}

@Composable
fun BottomBar(navController: NavController) {
BottomNavigation {
val navBackStackEntry by navController.currentBackStackEntryAsState()
val currentDestination = navBackStackEntry?.destination
navigationItems.forEach { screen ->
BottomNavigationItem(
icon = { Icon(painterResource(id = screen.drawable), contentDescription = null) },
label = { Text(screen.name) },
selected = currentDestination?.hierarchy?.any { it.route == screen.route } == true,
onClick = {
navController.navigate(screen.route) {
// Pop up to the start destination of the graph to
// avoid building up a large stack of destinations
// on the back stack as users select items
popUpTo(navController.graph.findStartDestination().id) {
saveState = true
}
// Avoid multiple copies of the same destination when
// reselecting the same item
launchSingleTop = true
// Restore state when reselecting a previously selected item
restoreState = true
}
},
)
}
BottomNavigation {
val navBackStackEntry by navController.currentBackStackEntryAsState()
val currentDestination = navBackStackEntry?.destination
navigationItems.forEach { screen ->
BottomNavigationItem(
icon = { Icon(painterResource(id = screen.drawable), contentDescription = null) },
label = { Text(screen.name) },
selected = currentDestination?.hierarchy?.any { it.route == screen.route } == true,
onClick = {
navController.navigate(screen.route) {
// Pop up to the start destination of the graph to
// avoid building up a large stack of destinations
// on the back stack as users select items
popUpTo(navController.graph.findStartDestination().id) {
saveState = true
}
// Avoid multiple copies of the same destination when
// reselecting the same item
launchSingleTop = true
// Restore state when reselecting a previously selected item
restoreState = true
}
},
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,36 +41,36 @@ import com.google.modernstorage.photopicker.PhotoPicker
@Composable
@SuppressLint("UnsafeOptInUsageError")
fun ColumnScope.PhotoPickerIcon(
controller: ColorPickerController,
controller: ColorPickerController,
) {
val context = LocalContext.current
val photoPicker =
rememberLauncherForActivityResult(PhotoPicker()) { uris ->
val uri = uris.firstOrNull() ?: return@rememberLauncherForActivityResult
val context = LocalContext.current
val photoPicker =
rememberLauncherForActivityResult(PhotoPicker()) { uris ->
val uri = uris.firstOrNull() ?: return@rememberLauncherForActivityResult

val bitmap = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
ImageDecoder.decodeBitmap(ImageDecoder.createSource(context.contentResolver, uri))
} else {
MediaStore.Images.Media.getBitmap(context.contentResolver, uri)
}
val bitmap = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
ImageDecoder.decodeBitmap(ImageDecoder.createSource(context.contentResolver, uri))
} else {
MediaStore.Images.Media.getBitmap(context.contentResolver, uri)
}

controller.setPaletteImageBitmap(bitmap.asImageBitmap())
}

Box(
modifier = Modifier
.padding(horizontal = 16.dp)
.align(Alignment.End),
) {
Image(
modifier = Modifier
.size(42.dp)
.clickable {
// Launch the picker with only one image selectable
photoPicker.launch(PhotoPicker.Args(PhotoPicker.Type.IMAGES_ONLY, 1))
},
imageVector = ImageVector.vectorResource(R.drawable.ic_gallery),
contentDescription = null,
)
controller.setPaletteImageBitmap(bitmap.asImageBitmap())
}

Box(
modifier = Modifier
.padding(horizontal = 16.dp)
.align(Alignment.End),
) {
Image(
modifier = Modifier
.size(42.dp)
.clickable {
// Launch the picker with only one image selectable
photoPicker.launch(PhotoPicker.Args(PhotoPicker.Type.IMAGES_ONLY, 1))
},
imageVector = ImageVector.vectorResource(R.drawable.ic_gallery),
contentDescription = null,
)
}
}
Loading

0 comments on commit 764298c

Please sign in to comment.