-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#285] [NF] Screen Widgets. View preset
- Loading branch information
Showing
11 changed files
with
139 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.tercad.fingrom | ||
|
||
data class PaymentItem( | ||
val type: String, | ||
val amount: String, | ||
val interval: String, | ||
val color: String // Hex color string | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
android/app/src/main/java/com/tercad/fingrom/PaymentsWidgetFactory.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.tercad.fingrom | ||
|
||
import android.content.Context | ||
import android.widget.RemoteViews | ||
import android.widget.RemoteViewsService | ||
import androidx.core.graphics.ColorUtils | ||
import android.graphics.Color | ||
|
||
class PaymentsWidgetFactory(private val context: Context) : RemoteViewsService.RemoteViewsFactory { | ||
|
||
private val items = mutableListOf<PaymentItem>() | ||
|
||
override fun onCreate() { | ||
// Initial data, including color in hex format | ||
items.add(PaymentItem("Bill:", "-$100.00", "monthly", "#FFD700")) // Yellow for Bill | ||
items.add(PaymentItem("Invoice:", "+$50.00", "weekly", "#FF0000")) // Red for Invoice | ||
items.add(PaymentItem("Bill:", "-$20.00", "monthly", "#0000FF")) // Blue for Bill | ||
} | ||
|
||
override fun onDataSetChanged() { | ||
// Refresh or update data if needed | ||
} | ||
|
||
override fun onDestroy() { | ||
items.clear() | ||
} | ||
|
||
override fun getCount(): Int = items.size | ||
|
||
override fun getViewAt(position: Int): RemoteViews { | ||
val item = items[position] | ||
|
||
val rv = RemoteViews(context.packageName, R.layout.payment_list_item) | ||
rv.setTextViewText(R.id.item_type, item.type) | ||
rv.setTextViewText(R.id.item_amount, item.amount) | ||
rv.setTextViewText(R.id.item_interval, item.interval) | ||
|
||
// Set background color directly using Color.parseColor | ||
rv.setInt(R.id.color_bar, "setBackgroundColor", Color.parseColor(item.color)) | ||
|
||
return rv | ||
} | ||
|
||
override fun getLoadingView(): RemoteViews? = null | ||
|
||
override fun getViewTypeCount(): Int = 1 | ||
|
||
override fun getItemId(position: Int): Long = position.toLong() | ||
|
||
override fun hasStableIds(): Boolean = true | ||
} |
10 changes: 10 additions & 0 deletions
10
android/app/src/main/java/com/tercad/fingrom/PaymentsWidgetService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.tercad.fingrom | ||
|
||
import android.content.Intent | ||
import android.widget.RemoteViewsService | ||
|
||
class PaymentsWidgetService : RemoteViewsService() { | ||
override fun onGetViewFactory(intent: Intent): RemoteViewsFactory { | ||
return PaymentsWidgetFactory(applicationContext) | ||
} | ||
} |
Binary file removed
BIN
-3.44 KB
android/app/src/main/res/drawable-nodpi/example_appwidget_preview.png
Binary file not shown.
Binary file added
BIN
+3.14 KB
android/app/src/main/res/drawable-nodpi/payments_appwidget_preview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content"> | ||
|
||
<!-- Color bar for each item --> | ||
<View | ||
android:id="@+id/color_bar" | ||
android:layout_width="match_parent" | ||
android:layout_height="10dp" /> | ||
|
||
<!-- Title of the payment item (Bill/Invoice) --> | ||
<TextView | ||
android:id="@+id/item_type" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="Bill:" | ||
android:textColor="@android:color/black" | ||
android:layout_marginTop="5dp" | ||
android:layout_below="@id/color_bar" /> | ||
|
||
<!-- Amount for the payment item --> | ||
<TextView | ||
android:id="@+id/item_amount" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="-$100.00" | ||
android:textColor="@android:color/black" | ||
android:layout_marginTop="5dp" | ||
android:layout_below="@id/item_type" /> | ||
|
||
<!-- Interval for the payment item (monthly/weekly) --> | ||
<TextView | ||
android:id="@+id/item_interval" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="monthly" | ||
android:textColor="@android:color/black" | ||
android:layout_marginTop="5dp" | ||
android:layout_below="@id/item_amount" /> | ||
|
||
</RelativeLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters