Skip to content

Commit

Permalink
Android widgets, transfer balance shortcut
Browse files Browse the repository at this point in the history
Transfer balance app quick shortcut
Ability to select certain accounts for income/expense total on homepage
Fixed budget history limit when watching selected categories
New all spending summary no longer shows on wallet details page
Most common transactions amount properly converted to main currency
Renamed and refactored homepage section settings
Home screen widgets and shortcuts (A)
  • Loading branch information
jameskokoska committed Dec 20, 2023
1 parent c448fe1 commit d50cc56
Show file tree
Hide file tree
Showing 84 changed files with 1,238 additions and 675 deletions.
24 changes: 24 additions & 0 deletions budget/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,30 @@
<action android:name="android.service.notification.NotificationListenerService" />
</intent-filter>
</service>
<receiver android:name="PlusWidgetProvider"
android:exported="true" android:label="Transaction Shortcut">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data android:name="android.appwidget.provider"
android:resource="@xml/plus_widget" />
</receiver>
<receiver android:name="TransferWidgetProvider"
android:exported="true" android:label="Transfer Shortcut">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data android:name="android.appwidget.provider"
android:resource="@xml/transfer_widget" />
</receiver>
<receiver android:name="NetWorthPlusWidgetProvider"
android:exported="true" android:label="Net Total Wide">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data android:name="android.appwidget.provider"
android:resource="@xml/net_worth_plus_widget" />
</receiver>
<receiver android:name="NetWorthWidgetProvider"
android:exported="true" android:label="Net Total">
<intent-filter>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package com.budget.tracker_app

import android.appwidget.AppWidgetManager
import android.content.Context
import android.content.SharedPreferences
import android.graphics.BitmapFactory
import android.net.Uri
import android.view.View
import android.widget.RemoteViews
import es.antonborri.home_widget.HomeWidgetBackgroundIntent
import es.antonborri.home_widget.HomeWidgetLaunchIntent
import es.antonborri.home_widget.HomeWidgetProvider

class NetWorthPlusWidgetProvider : HomeWidgetProvider() {

override fun onUpdate(context: Context, appWidgetManager: AppWidgetManager, appWidgetIds: IntArray, widgetData: SharedPreferences) {
appWidgetIds.forEach { widgetId ->

val views = RemoteViews(context.packageName, R.layout.net_worth_plus_widget_layout).apply {
try {
setTextViewText(R.id.net_worth_amount, widgetData.getString("netWorthAmount", null)
?: "0.00")

setTextViewText(R.id.net_worth_transactions_number, widgetData.getString("netWorthTransactionsNumber", null)
?: "0 transactions")
}catch (e: Exception){}

try {
setInt(R.id.widget_background, "setColorFilter", android.graphics.Color.parseColor(widgetData.getString("widgetColorBackground", null)
?: "#FFFFFF"));
}catch (e: Exception){}

try {
setInt(R.id.net_worth_amount, "setTextColor", android.graphics.Color.parseColor(widgetData.getString("widgetColorText", null)
?: "#FFFFFF"))
setInt(R.id.net_worth_transactions_number, "setTextColor", android.graphics.Color.parseColor(widgetData.getString("widgetColorText", null)
?: "#FFFFFF"))
}catch (e: Exception){}

try {
val plusButtonIntent = HomeWidgetLaunchIntent.getActivity(
context,
MainActivity::class.java,
Uri.parse("addTransaction"))
setOnClickPendingIntent(R.id.plus_button, plusButtonIntent)

val pendingIntentWithData = HomeWidgetLaunchIntent.getActivity(
context,
MainActivity::class.java,
Uri.parse("netWorthLaunch"))
setOnClickPendingIntent(R.id.widget_container, pendingIntentWithData)
}catch (e: Exception){}

}

appWidgetManager.updateAppWidget(widgetId, views)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,41 @@ class NetWorthWidgetProvider : HomeWidgetProvider() {
appWidgetIds.forEach { widgetId ->

val views = RemoteViews(context.packageName, R.layout.net_worth_widget_layout).apply {

setTextViewText(R.id.net_worth_title, widgetData.getString("netWorthTitle", null)
?: "Net Worth")

setTextViewText(R.id.net_worth_amount, widgetData.getString("netWorthAmount", null)
?: "0.00")

setTextViewText(R.id.net_worth_transactions_number, widgetData.getString("netWorthTransactionsNumber", null)
?: "0 transactions")

// Detect App opened via Click inside Flutter
val pendingIntentWithData = HomeWidgetLaunchIntent.getActivity(
context,
MainActivity::class.java,
Uri.parse("launch,${widgetId}"))
setOnClickPendingIntent(R.id.widget_container, pendingIntentWithData)
try {
setTextViewText(R.id.net_worth_title, widgetData.getString("netWorthTitle", null)
?: "Net Worth")

setTextViewText(R.id.net_worth_amount, widgetData.getString("netWorthAmount", null)
?: "0.00")

setTextViewText(R.id.net_worth_transactions_number, widgetData.getString("netWorthTransactionsNumber", null)
?: "0 transactions")
}catch (e: Exception){}

try {
setInt(R.id.widget_background, "setColorFilter", android.graphics.Color.parseColor(widgetData.getString("widgetColorBackground", null)
?: "#FFFFFF"));
}catch (e: Exception){}

try {
setInt(R.id.net_worth_title, "setTextColor", android.graphics.Color.parseColor(widgetData.getString("widgetColorText", null)
?: "#FFFFFF"))
setInt(R.id.net_worth_amount, "setTextColor", android.graphics.Color.parseColor(widgetData.getString("widgetColorText", null)
?: "#FFFFFF"))
setInt(R.id.net_worth_transactions_number, "setTextColor", android.graphics.Color.parseColor(widgetData.getString("widgetColorText", null)
?: "#FFFFFF"))
}catch (e: Exception){}

try {
val pendingIntentWithData = HomeWidgetLaunchIntent.getActivity(
context,
MainActivity::class.java,
Uri.parse("addTransaction"))
setOnClickPendingIntent(R.id.widget_container, pendingIntentWithData)
}catch (e: Exception){}

}

appWidgetManager.updateAppWidget(widgetId, views)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.budget.tracker_app

import android.appwidget.AppWidgetManager
import android.content.Context
import android.content.SharedPreferences
import android.graphics.BitmapFactory
import android.net.Uri
import android.view.View
import android.widget.RemoteViews
import es.antonborri.home_widget.HomeWidgetBackgroundIntent
import es.antonborri.home_widget.HomeWidgetLaunchIntent
import es.antonborri.home_widget.HomeWidgetProvider

class PlusWidgetProvider : HomeWidgetProvider() {

override fun onUpdate(context: Context, appWidgetManager: AppWidgetManager, appWidgetIds: IntArray, widgetData: SharedPreferences) {
appWidgetIds.forEach { widgetId ->

val views = RemoteViews(context.packageName, R.layout.plus_widget_layout).apply {

try {
setInt(R.id.widget_background, "setColorFilter", android.graphics.Color.parseColor(widgetData.getString("widgetColorBackground", null)
?: "#FFFFFF"));
}catch (e: Exception){}

try {
setInt(R.id.plus_title, "setTextColor", android.graphics.Color.parseColor(widgetData.getString("widgetColorText", null)
?: "#FFFFFF"))
}catch (e: Exception){}

try {
val pendingIntentWithData = HomeWidgetLaunchIntent.getActivity(
context,
MainActivity::class.java,
Uri.parse("addTransaction"))
setOnClickPendingIntent(R.id.widget_container, pendingIntentWithData)
}catch (e: Exception){}

}

appWidgetManager.updateAppWidget(widgetId, views)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.budget.tracker_app

import android.appwidget.AppWidgetManager
import android.content.Context
import android.content.SharedPreferences
import android.graphics.BitmapFactory
import android.net.Uri
import android.view.View
import android.widget.RemoteViews
import es.antonborri.home_widget.HomeWidgetBackgroundIntent
import es.antonborri.home_widget.HomeWidgetLaunchIntent
import es.antonborri.home_widget.HomeWidgetProvider

class TransferWidgetProvider : HomeWidgetProvider() {

override fun onUpdate(context: Context, appWidgetManager: AppWidgetManager, appWidgetIds: IntArray, widgetData: SharedPreferences) {
appWidgetIds.forEach { widgetId ->

val views = RemoteViews(context.packageName, R.layout.transfer_widget_layout).apply {

try {
setInt(R.id.widget_background, "setColorFilter", android.graphics.Color.parseColor(widgetData.getString("widgetColorBackground", null)
?: "#FFFFFF"));
}catch (e: Exception){}

try {
setInt(R.id.transfer_image, "setColorFilter", android.graphics.Color.parseColor(widgetData.getString("widgetColorText", null)
?: "#FFFFFF"));
}catch (e: Exception){}

try {
val pendingIntentWithData = HomeWidgetLaunchIntent.getActivity(
context,
MainActivity::class.java,
Uri.parse("transferTransaction"))
setOnClickPendingIntent(R.id.widget_container, pendingIntentWithData)
}catch (e: Exception){}

}

appWidgetManager.updateAppWidget(widgetId, views)
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions budget/android/app/src/main/res/drawable/rounded_button.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#80A0A0A0"/>
<corners android:radius="20dp"/>
</shape>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#FFFFFFFF"/>
<corners android:radius="20dp"/>
</shape>
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/widget_container"
android:layout_margin="6dp">
<ImageView
android:id="@+id/widget_background"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="fitXY"
android:src="@drawable/widget_background"
/>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:gravity="center_vertical"
android:paddingLeft="20dp"
android:paddingRight="18dp"
android:paddingVertical="5dp">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="@+id/net_worth_amount"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text=""
android:gravity="start|center_vertical"
android:padding="3dp"
android:textSize="25sp"
android:textStyle="bold"
android:textColor="#000000"
/>
<TextView
android:id="@+id/net_worth_transactions_number"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="start|center_vertical"
android:padding="3dp"
android:text="Tap to configure widget"
android:textSize="13sp"
android:textColor="#000000"
/>
</LinearLayout>
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button
android:id="@+id/plus_button"
android:layout_width="56dp"
android:layout_height="56dp"
android:text="+"
android:textSize="28sp"
android:gravity="center"
android:textColor="#FFFFFF"
android:textStyle="bold"
android:padding="10dp"
android:background="@drawable/rounded_button"
/>
</FrameLayout>
</LinearLayout>
</FrameLayout>
Loading

1 comment on commit d50cc56

@ngocanhtve
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to add widget strings to the Google Sheet that can be translated as strings in the app?

Please sign in to comment.