Skip to content

Commit

Permalink
Add compact style goal card (#80)
Browse files Browse the repository at this point in the history
Adds a new compact styled goal card with goal icon instead of image for home screen.
---------
Signed-off-by: starry-shivam <krshivam24@proton.me>
  • Loading branch information
starry-shivam authored Mar 27, 2024
1 parent 85c2546 commit 6971d97
Show file tree
Hide file tree
Showing 51 changed files with 3,570 additions and 385 deletions.
15 changes: 14 additions & 1 deletion .idea/deploymentTargetDropDown.xml

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

2 changes: 2 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ dependencies {
implementation 'com.google.android.material:material:1.11.0'
// Android 12+ splash API.
implementation 'androidx.core:core-splashscreen:1.0.1'
// Material icons.
implementation 'androidx.compose.material:material-icons-extended:1.6.4'
// Room database
implementation "androidx.room:room-ktx:$room_version"
ksp "androidx.room:room-compiler:$room_version"
Expand Down
5 changes: 4 additions & 1 deletion app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,7 @@
-keep class * implements com.google.gson.TypeAdapter
-keep class * implements com.google.gson.TypeAdapterFactory
-keep class * implements com.google.gson.JsonSerializer
-keep class * implements com.google.gson.JsonDeserializer
-keep class * implements com.google.gson.JsonDeserializer

# Prevent R8 from removing icons used in goal icon picker.
-keep class androidx.compose.material.icons.filled.** { *; }
183 changes: 183 additions & 0 deletions app/schemas/com.starry.greenstash.database.core.AppDatabase/5.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
{
"formatVersion": 1,
"database": {
"version": 5,
"identityHash": "408d5f8908a86fdfad63bd093e27d230",
"entities": [
{
"tableName": "saving_goal",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`title` TEXT NOT NULL, `targetAmount` REAL NOT NULL, `deadline` TEXT NOT NULL, `goalImage` BLOB, `additionalNotes` TEXT NOT NULL, `priority` INTEGER NOT NULL DEFAULT 2, `reminder` INTEGER NOT NULL DEFAULT false, `goalIconId` TEXT DEFAULT 'Image', `goalId` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL)",
"fields": [
{
"fieldPath": "title",
"columnName": "title",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "targetAmount",
"columnName": "targetAmount",
"affinity": "REAL",
"notNull": true
},
{
"fieldPath": "deadline",
"columnName": "deadline",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "goalImage",
"columnName": "goalImage",
"affinity": "BLOB",
"notNull": false
},
{
"fieldPath": "additionalNotes",
"columnName": "additionalNotes",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "priority",
"columnName": "priority",
"affinity": "INTEGER",
"notNull": true,
"defaultValue": "2"
},
{
"fieldPath": "reminder",
"columnName": "reminder",
"affinity": "INTEGER",
"notNull": true,
"defaultValue": "false"
},
{
"fieldPath": "goalIconId",
"columnName": "goalIconId",
"affinity": "TEXT",
"notNull": false,
"defaultValue": "'Image'"
},
{
"fieldPath": "goalId",
"columnName": "goalId",
"affinity": "INTEGER",
"notNull": true
}
],
"primaryKey": {
"autoGenerate": true,
"columnNames": [
"goalId"
]
},
"indices": [],
"foreignKeys": []
},
{
"tableName": "transaction",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`ownerGoalId` INTEGER NOT NULL, `type` INTEGER NOT NULL, `timeStamp` INTEGER NOT NULL, `amount` REAL NOT NULL, `notes` TEXT NOT NULL, `transactionId` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, FOREIGN KEY(`ownerGoalId`) REFERENCES `saving_goal`(`goalId`) ON UPDATE NO ACTION ON DELETE CASCADE )",
"fields": [
{
"fieldPath": "ownerGoalId",
"columnName": "ownerGoalId",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "type",
"columnName": "type",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "timeStamp",
"columnName": "timeStamp",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "amount",
"columnName": "amount",
"affinity": "REAL",
"notNull": true
},
{
"fieldPath": "notes",
"columnName": "notes",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "transactionId",
"columnName": "transactionId",
"affinity": "INTEGER",
"notNull": true
}
],
"primaryKey": {
"autoGenerate": true,
"columnNames": [
"transactionId"
]
},
"indices": [
{
"name": "index_transaction_ownerGoalId",
"unique": false,
"columnNames": [
"ownerGoalId"
],
"orders": [],
"createSql": "CREATE INDEX IF NOT EXISTS `index_transaction_ownerGoalId` ON `${TABLE_NAME}` (`ownerGoalId`)"
}
],
"foreignKeys": [
{
"table": "saving_goal",
"onDelete": "CASCADE",
"onUpdate": "NO ACTION",
"columns": [
"ownerGoalId"
],
"referencedColumns": [
"goalId"
]
}
]
},
{
"tableName": "widget_data",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`appWidgetId` INTEGER NOT NULL, `goalId` INTEGER NOT NULL, PRIMARY KEY(`appWidgetId`))",
"fields": [
{
"fieldPath": "appWidgetId",
"columnName": "appWidgetId",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "goalId",
"columnName": "goalId",
"affinity": "INTEGER",
"notNull": true
}
],
"primaryKey": {
"autoGenerate": false,
"columnNames": [
"appWidgetId"
]
},
"indices": [],
"foreignKeys": []
}
],
"views": [],
"setupQueries": [
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '408d5f8908a86fdfad63bd093e27d230')"
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,13 @@ import com.starry.greenstash.database.widget.WidgetData

@Database(
entities = [Goal::class, Transaction::class, WidgetData::class],
version = 4,
version = 5,
exportSchema = true,
autoMigrations = [
AutoMigration(from = 1, to = 2),
AutoMigration(from = 2, to = 3),
AutoMigration(from = 3, to = 4)
AutoMigration(from = 3, to = 4),
AutoMigration(from = 4, to = 5)
]
)
@TypeConverters(Converters::class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,17 @@ import java.io.ByteArrayOutputStream
class Converters {

@TypeConverter
fun fromBitmap(bitmap: Bitmap?): ByteArray? {
if (bitmap != null) {
val outputStream = ByteArrayOutputStream()
bitmap.compress(Bitmap.CompressFormat.PNG, 100, outputStream)
return outputStream.toByteArray()
fun fromBitmap(bitmap: Bitmap?): ByteArray? =
bitmap?.let { bmp ->
ByteArrayOutputStream().apply {
bmp.compress(Bitmap.CompressFormat.PNG, 100, this)
}.toByteArray()
}
return null
}


@TypeConverter
fun toBitmap(byteArray: ByteArray?): Bitmap? {
if (byteArray != null) {
return BitmapFactory.decodeByteArray(byteArray, 0, byteArray.size)
}
return null
}
fun toBitmap(byteArray: ByteArray?): Bitmap? =
byteArray?.let { BitmapFactory.decodeByteArray(it, 0, it.size) }

@TypeConverter
fun fromTransactionType(value: TransactionType) = value.ordinal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ data class Goal(
val priority: GoalPriority,
// Added in database schema v4
@ColumnInfo(defaultValue = "false")
val reminder: Boolean
val reminder: Boolean,
// Added in database schema v5
@ColumnInfo(defaultValue = "Image")
val goalIconId: String?
) {
@PrimaryKey(autoGenerate = true)
var goalId: Long = 0L
Expand Down
Loading

0 comments on commit 6971d97

Please sign in to comment.