Skip to content

Commit

Permalink
Merge pull request #35 from manununhez/test/release/latest-changes
Browse files Browse the repository at this point in the history
test/release/latest-changes
  • Loading branch information
manununhez authored Apr 15, 2024
2 parents 54b8da0 + d86bfbf commit 05494f2
Show file tree
Hide file tree
Showing 55 changed files with 539 additions and 327 deletions.
13 changes: 6 additions & 7 deletions .github/workflows/cd-android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,23 @@ jobs:
cache: gradle

- name: Decode keystore and create jks
run: echo "${{ secrets.KEY_KEYSTORE_BASE64 }}" | base64 --decode > app/purrfect-pics-key.jks
run: echo "${{ secrets.KEY_KEYSTORE_BASE64 }}" | base64 --decode > app/keystore.jks

- name: Generate keystore.properties
run: |
cat <<EOF > keystore.properties
PEXELS_API_KEY:${{ secrets.PEXELS_API_KEY }}
KEYSTORE_PASSWORD:${{ secrets.KEYSTORE_PASSWORD }}
KEY_PASSWORD:${{ secrets.KEY_PASSWORD }}
KEY_ALIAS:${{ secrets.KEY_ALIAS }}
KEYSTORE_FILE:${{ secrets.KEYSTORE_FILE }}
PEXELS_API_KEY=${{ secrets.PEXELS_API_KEY }}
KEY_PASSWORD=${{ secrets.KEY_PASSWORD }}
KEY_ALIAS=${{ secrets.KEY_ALIAS }}
KEYSTORE_FILE=${{ secrets.KEYSTORE_FILE }}
EOF
- name: Generate file name env var
run: |
DATE=$(date +'%d.%m.%Y')
BRANCH_NAME=${GITHUB_REF##*/}
MESSAGE=$(cat << EOF
AppName-release-${BRANCH_NAME}-${DATE}
PurrfectPics-release-${BRANCH_NAME}-${DATE}
EOF)
echo OUTPUT_NAME=$MESSAGE >> $GITHUB_ENV
Expand Down
39 changes: 29 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,21 @@ heart.
- **Share:** Share delightful cat images with friends, family, and fellow cat enthusiasts with just
a tap.
- **Save Favorites:** (Coming soon) Save your favorite cat images to easily revisit them later and
create your
personalized collection.
create your personalized collection.
- **Splash Screen:** Engage users with a captivating splash screen animation while the app loads. (
Note: There is a known issue with the splash screen not showing on Android 12. A temporary
solution is to **open the app from the app tray**, as
indicated [here](https://stackoverflow.com/questions/69812590/android-12-splash-screen-icon-not-displaying))

## Considerations

- FREE Cat APIs used in this version: [Cataas](https://cataas.com/)
and [Pexels](https://www.pexels.com/). In particular, Pexels API
is [rate-limited](https://www.pexels.com/api/documentation/#guidelines), in case of errors for
this, a new API key will be necessary to be generated.
- Not persisted in DB or preferences because this API has dynamic and frequently updated data. On
the other hand, Coil image lib does use disk and memory cache to smooth image loading.
- KtfmtFormat plugin applied for code formatting.

## Tools/Libraries

Expand Down Expand Up @@ -52,14 +65,21 @@ heart.

To get started with PurrfectPics, follow these steps:

1. Clone the repository to your local machine:
git clone [email protected]:manununhez/purrfect-pics.git


1. Clone the repository to your local
machine: `git clone [email protected]:manununhez/purrfect-pics.git`
2. Open the project in Android Studio.

3. Build and run the app on your device or emulator.

## Branching Strategy

- **Main Branch:** The primary branch of the project, reflecting the latest stable release.
- **Feature Branches:** Used for developing new features. Branch names should be descriptive of the
feature being developed.
- **Epic Branches:** Used for grouping related features or significant enhancements. Branch names
should reflect the overarching theme of the epic.
- **Release Branches:** Used for preparing releases. Branch names should follow the
pattern `release/v<MAJOR>/<MAJOR>.<MINOR>.<PATCH>`.

## Contributing

We welcome contributions from the open-source community to help improve PurrfectPics. Whether you're
Expand All @@ -76,6 +96,5 @@ PurrfectPics is licensed under the [MIT License](LICENSE).

## About

PurrfectPics is developed and maintained by [Manuel Nuñez]. For inquiries, please
contact [[email protected]].

PurrfectPics is developed and maintained by [Manuel Nuñez](mailto:[email protected]). For
inquiries, please contact [[email protected]].
30 changes: 14 additions & 16 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ android {
namespace = "com.manuelnunez.apps"
compileSdk = 34

compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

defaultConfig {
applicationId = "com.manuelnunez.apps.purrfectpics"
minSdk = 21
Expand All @@ -31,12 +36,20 @@ android {
storeFile = file(getProperty("KEYSTORE_FILE"))
keyAlias = getProperty("KEY_ALIAS")
keyPassword = getProperty("KEY_PASSWORD")
storePassword = getProperty("KEYSTORE_PASSWORD")
storePassword = getProperty("KEY_PASSWORD")
}
}
}
}

buildFeatures { compose = true }

composeOptions { kotlinCompilerExtensionVersion = libs.versions.androidxComposeCompiler.get() }

tasks.withType<Test> { useJUnitPlatform() }

packaging { resources { excludes.add("META-INF/{LICENSE-notice.md,LICENSE.md}") } }

buildTypes {
getByName("release") {
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
Expand All @@ -53,21 +66,6 @@ android {
proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro")
}
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

kotlinOptions { jvmTarget = JavaVersion.VERSION_17.toString() }

buildFeatures { compose = true }

composeOptions { kotlinCompilerExtensionVersion = libs.versions.androidxComposeCompiler.get() }

tasks.withType<Test> { useJUnitPlatform() }

packaging { resources { excludes.add("META-INF/{LICENSE-notice.md,LICENSE.md}") } }
}

dependencies {
Expand Down
6 changes: 2 additions & 4 deletions core/common-ui/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ android {
namespace = "com.manuelnunez.apps.core.ui"
compileSdk = 34

defaultConfig { minSdk = 21 }

compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

defaultConfig { minSdk = 21 }

kotlinOptions { jvmTarget = JavaVersion.VERSION_17.toString() }

buildFeatures { compose = true }
Expand All @@ -29,8 +29,6 @@ dependencies {

implementation(libs.coil.kt.compose)

implementation(libs.androidx.navigation.compose)

// Compose
val composeBom = platform(libs.androidx.compose.bom)
implementation(composeBom)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
package com.manuelnunez.apps.core.ui.component

import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material3.Card
import androidx.compose.material3.Icon
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.Layout
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import com.manuelnunez.apps.core.ui.R
import com.manuelnunez.apps.core.ui.theme.MainTheme
import com.manuelnunez.apps.core.ui.utils.ThemePreviews
import kotlin.math.roundToInt

@Composable
Expand All @@ -28,3 +40,49 @@ data class AdaptableVerticalGridDecoration(
val itemWidth: Dp,
val itemHorizontalMargin: Dp,
)

/** A simple grid which lays elements out vertically in evenly sized [columns]. */
@Composable
fun VerticalGrid(modifier: Modifier = Modifier, columns: Int = 2, content: @Composable () -> Unit) {
Layout(content = content, modifier = modifier) { measurables, constraints ->
val itemWidth = constraints.maxWidth / columns
// Keep given height constraints, but set an exact width
val itemConstraints = constraints.copy(minWidth = itemWidth, maxWidth = itemWidth)
// Measure each item with these constraints
val placeables = measurables.map { it.measure(itemConstraints) }
// Track each columns height so we can calculate the overall height
val columnHeights = Array(columns) { 0 }
placeables.forEachIndexed { index, placeable ->
val column = index % columns
columnHeights[column] += placeable.height
}
val height =
(columnHeights.maxOrNull() ?: constraints.minHeight).coerceAtMost(constraints.maxHeight)
layout(width = constraints.maxWidth, height = height) {
// Track the Y co-ord per column we have placed up to
val columnY = Array(columns) { 0 }
placeables.forEachIndexed { index, placeable ->
val column = index % columns
placeable.placeRelative(x = column * itemWidth, y = columnY[column])
columnY[column] += placeable.height
}
}
}
}

@ThemePreviews
@Composable
fun AdaptableVerticalGridPreview() {
MainTheme {
AdaptableVerticalGrid(decoration = AdaptableVerticalGridDecoration(20.dp, 25.dp, 55.dp)) {
List(10) {
Card(Modifier.size(50.dp, 80.dp).padding(horizontal = 10.dp).padding(bottom = 20.dp)) {
Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
Icon(
painter = painterResource(id = R.drawable.ic_broken_image), contentDescription = "")
}
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.graphics.vector.ImageVector
import com.manuelnunez.apps.core.ui.theme.MainTheme
import com.manuelnunez.apps.core.ui.utils.ThemePreviews

@Composable
fun ErrorDialog(dialogTitle: String, dialogText: String, onConfirmation: () -> Unit) {
Expand Down Expand Up @@ -46,3 +48,14 @@ fun ErrorAlertDialog(
confirmButton = { TextButton(onClick = { onConfirmation() }) { Text("Confirm") } },
dismissButton = { TextButton(onClick = { onDismissRequest() }) { Text("Dismiss") } })
}

@ThemePreviews
@Composable
fun ErrorDialogPreview() {
MainTheme {
ErrorDialog(
onConfirmation = {},
dialogTitle = "Title",
dialogText = "https://picsum.photos/id/237/200/300")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.manuelnunez.apps.core.ui.component
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.material3.Card
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.MaterialTheme
Expand All @@ -12,6 +13,7 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.text.style.TextAlign
import com.manuelnunez.apps.core.ui.theme.MainTheme
import com.manuelnunez.apps.core.ui.utils.ThemePreviews

Expand All @@ -20,12 +22,13 @@ fun TextCard(modifier: Modifier = Modifier, text: String, onClick: () -> Unit) {
Card(
colors =
CardDefaults.cardColors().copy(containerColor = MaterialTheme.colorScheme.onBackground),
modifier =
modifier.clickable(onClick = { onClick.invoke() }).semantics {
contentDescription = text
}) {
modifier = modifier.clickable(onClick = onClick).semantics { contentDescription = text }) {
Box(contentAlignment = Alignment.Center, modifier = Modifier.fillMaxSize()) {
Text(text = text, color = MaterialTheme.colorScheme.background)
Text(
modifier = Modifier.fillMaxWidth(),
textAlign = TextAlign.Center,
text = text,
color = MaterialTheme.colorScheme.background)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,24 @@ fun TitleText(modifier: Modifier = Modifier, title: String, textAlign: TextAlign
style = MaterialTheme.typography.titleLarge)
}

@Composable
fun ErrorText(modifier: Modifier = Modifier, title: String, textAlign: TextAlign? = null) {
Text(
modifier = modifier,
text = title,
textAlign = textAlign,
color = MaterialTheme.colorScheme.onSurface,
style = MaterialTheme.typography.titleSmall)
}

@ThemePreviews
@Composable
fun TitleTextPreview() {
MainTheme { TitleText(title = "See more") }
}

@ThemePreviews
@Composable
fun ErrorTextPreview() {
MainTheme { ErrorText(title = "See more") }
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@ annotation class DevicePreviews
*/
@Preview(
name = "Small font",
group = "font scales",
group = "Font scaling",
fontScale = 0.5f,
showBackground = true,
)
@Preview(
name = "Large font",
group = "font scales",
fontScale = 2f,
group = "Font scaling",
fontScale = 2.5f,
showBackground = true,
)
@Preview(
name = "Normal font",
group = "font scales",
group = "Font scaling",
backgroundColor = 0xFFFFFFFF,
showBackground = true,
)
Expand Down
2 changes: 2 additions & 0 deletions core/common-ui/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="section_feature">Featured</string>
<string name="section_popular">Popular</string>
<string name="button_back">Go back</string>
<string name="alert_error_try_again">An Error has occurred. Please try again.</string>
<string name="alert_error">An Error has occurred</string>
Expand Down
Loading

0 comments on commit 05494f2

Please sign in to comment.