Skip to content

Commit

Permalink
Implemented home screen widget.
Browse files Browse the repository at this point in the history
Update widgets when db changes.
  • Loading branch information
codinguser committed Jul 24, 2012
1 parent 4185aa7 commit 567d143
Show file tree
Hide file tree
Showing 78 changed files with 578 additions and 4 deletions.
17 changes: 16 additions & 1 deletion GnucashMobile/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@
</intent-filter>
</activity>
<activity android:name=".ui.settings.SettingsActivity"></activity>
<activity android:name=".ui.widget.Configuration"
android:theme="@style/Theme.Sherlock.Light.Dialog"
android:excludeFromRecents="true">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE"/>
</intent-filter>
</activity>
<receiver android:name=".receivers.TransactionRecorder"
android:label="Records transactions received through intents"
android:permission="org.gnucash.android.permission.RECORD_TRANSACTION">
Expand All @@ -76,13 +83,21 @@
</receiver>
<receiver android:name=".receivers.AccountCreator"
android:label="Creates new accounts"
android:permission="org.gnucash.android.permission.CREATE_ACCOUNT" android:enabled="true" android:exported="true">
android:permission="org.gnucash.android.permission.CREATE_ACCOUNT"
android:enabled="true" android:exported="true">
<intent-filter>
<action android:name="android.intent.action.INSERT" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="vnd.android.cursor.item/vnd.org.gnucash.android.account"/>
</intent-filter>
</receiver>
<receiver android:name=".receivers.TransactionAppWidgetProvider" >
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data android:name="android.appwidget.provider"
android:resource="@xml/transaction_appwidget_info" />
</receiver>
</application>

</manifest>
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.
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.
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.
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.
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.
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.
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.
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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions GnucashMobile/res/drawable/appwidget_bg_clickable.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!--
Copyright 2011 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/appwidget_bg_pressed" android:state_pressed="true" />
<item android:drawable="@drawable/appwidget_bg_focused"
android:state_focused="true"
android:state_enabled="true"
android:state_window_focused="true" />
<item android:drawable="@drawable/appwidget_bg" />
</selector>
25 changes: 25 additions & 0 deletions GnucashMobile/res/drawable/appwidget_button_center.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!--
Copyright 2011 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/appwidget_inner_pressed_c"
android:state_pressed="true" />
<item android:drawable="@drawable/appwidget_inner_focused_c"
android:state_focused="true"
android:state_enabled="true"
android:state_window_focused="true" />
<item android:drawable="@android:color/transparent" />
</selector>
25 changes: 25 additions & 0 deletions GnucashMobile/res/drawable/appwidget_button_left.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!--
Copyright 2011 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/appwidget_inner_pressed_l"
android:state_pressed="true" />
<item android:drawable="@drawable/appwidget_inner_focused_l"
android:state_focused="true"
android:state_enabled="true"
android:state_window_focused="true" />
<item android:drawable="@android:color/transparent" />
</selector>
25 changes: 25 additions & 0 deletions GnucashMobile/res/drawable/appwidget_button_right.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!--
Copyright 2011 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/appwidget_inner_pressed_r"
android:state_pressed="true" />
<item android:drawable="@drawable/appwidget_inner_focused_r"
android:state_focused="true"
android:state_enabled="true"
android:state_window_focused="true" />
<item android:drawable="@android:color/transparent" />
</selector>
24 changes: 24 additions & 0 deletions GnucashMobile/res/drawable/appwidget_dark_bg_clickable.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!--
Copyright 2011 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/appwidget_bg_pressed" android:state_pressed="true" />
<item android:drawable="@drawable/appwidget_dark_bg_focused"
android:state_focused="true"
android:state_enabled="true"
android:state_window_focused="true" />
<item android:drawable="@drawable/appwidget_dark_bg" />
</selector>
25 changes: 25 additions & 0 deletions GnucashMobile/res/layout/default_buttons.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:orientation="horizontal" >

<Button
android:id="@+id/btn_cancel"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:padding="14dp"
android:layout_weight="1"
android:drawableLeft="@drawable/navigation_cancel"
android:text="@string/btn_cancel" />

<Button
android:id="@+id/btn_save"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:padding="14dp"
android:layout_weight="1"
android:drawableLeft="@drawable/navigation_accept"
android:text="@string/btn_save" />
</LinearLayout>
66 changes: 66 additions & 0 deletions GnucashMobile/res/layout/widget_4x1.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Written By: Ngewi Fet <ngewif@gmail.com>
Copyright (c) 2012 Ngewi Fet
This file is part of Gnucash for Android
Gnucash for Android is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of
the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, contact:
Free Software Foundation Voice: +1-617-542-5942
51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
Boston, MA 02110-1301, USA gnu@gnu.org
-->

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="@dimen/widget_margin">

<LinearLayout android:id="@+id/widget_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:background="@drawable/appwidget_dark_bg_clickable"
android:orientation="horizontal">

<TextView android:id="@+id/account_name"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:singleLine="true"
android:ellipsize="end"
android:layout_marginLeft="@dimen/edge_padding"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="@string/label_account_name" />

<TextView android:id="@+id/transactions_summary"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:singleLine="true"
style="@style/ListItemText"
android:layout_marginLeft="@dimen/widget_margin"
android:layout_marginRight="@dimen/widget_margin" />

<ImageButton android:id="@+id/btn_new_transaction"
android:layout_width="48dp"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/edge_padding"
android:layout_marginLeft="@dimen/edge_padding"
android:src="@drawable/content_new"
android:background="@drawable/appwidget_bg_clickable"
android:contentDescription="@string/add_transaction_icon_description"/>
</LinearLayout>
</FrameLayout>
22 changes: 22 additions & 0 deletions GnucashMobile/res/layout/widget_configuration.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<TextView
android:id="@+id/label_account"
android:text="@string/label_display_account"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_marginBottom="-8dp"
android:layout_marginTop="8dp"
style="@style/TextAppearance.EditTransaction_LabelSmall" />
<Spinner
android:id="@+id/input_accounts_spinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?android:attr/listPreferredItemHeight" />

<include layout="@layout/default_buttons"/>
</LinearLayout>
28 changes: 28 additions & 0 deletions GnucashMobile/res/values-v14/dimens.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Written By: Ngewi Fet <ngewif@gmail.com>
Copyright (c) 2012 Ngewi Fet
This file is part of Gnucash for Android
Gnucash for Android is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of
the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, contact:
Free Software Foundation Voice: +1-617-542-5942
51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
Boston, MA 02110-1301, USA gnu@gnu.org
-->

<resources>
<dimen name="widget_margin">0dp</dimen>
</resources>
1 change: 1 addition & 0 deletions GnucashMobile/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@
<dimen name="text_size_medium">18sp</dimen>
<dimen name="text_size_large">18sp</dimen>
<dimen name="edge_padding">12dp</dimen>
<dimen name="widget_margin">8dp</dimen>
</resources>
2 changes: 2 additions & 0 deletions GnucashMobile/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
<string name="description_permission_group">Record transactions in GnuCash, read GnuCash data</string>
<string name="label_permission_record_transaction">record transactions</string>
<string name="label_permission_create_account">create accounts</string>
<string name="label_display_account">Display account</string>
<string-array name="currency_names">
<item>Afghani</item>
<item>Algerian Dinar</item>
Expand Down Expand Up @@ -444,5 +445,6 @@
<item>ZWL</item>
<item>PLN</item>
</string-array>


</resources>
34 changes: 34 additions & 0 deletions GnucashMobile/res/xml/transaction_appwidget_info.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Written By: Ngewi Fet <ngewif@gmail.com>
Copyright (c) 2012 Ngewi Fet
This file is part of Gnucash for Android
Gnucash for Android is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of
the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, contact:
Free Software Foundation Voice: +1-617-542-5942
51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
Boston, MA 02110-1301, USA gnu@gnu.org
-->

<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:minWidth="270dp"
android:minHeight="56dp"
android:updatePeriodMillis="86400000"
android:previewImage="@drawable/widget_preview"
android:initialLayout="@layout/widget_4x1"
android:configure="org.gnucash.android.ui.widget.Configuration"
android:resizeMode="horizontal">
</appwidget-provider>
3 changes: 2 additions & 1 deletion GnucashMobile/src/org/gnucash/android/data/Account.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

package org.gnucash.android.data;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Currency;
import java.util.List;
Expand Down Expand Up @@ -222,7 +223,7 @@ public boolean hasUnexportedTransactions(){
* @return Aggregate amount of all transactions in account.
*/
public Money getBalance(){
Money balance = new Money();
Money balance = new Money(new BigDecimal(0), this.mCurrency);
for (Transaction transx : mTransactionsList) {
balance = balance.add(transx.getAmount());
}
Expand Down
Loading

0 comments on commit 567d143

Please sign in to comment.