Skip to content
This repository has been archived by the owner on Jan 11, 2024. It is now read-only.

Feat 318: Added new Widget support for Creating Customer #181

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 22 additions & 14 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,6 @@
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:targetApi="n">

<provider
android:name="androidx.core.content.FileProvider"
android:authorities="org.apache.fineract.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/filepaths" />
</provider>

<activity
android:name=".ui.online.SplashActivity"
android:theme="@style/SplashTheme">
Expand Down Expand Up @@ -94,6 +83,28 @@
<activity
android:name=".ui.online.groups.creategroup.CreateGroupActivity"
android:windowSoftInputMode="adjustResize|stateHidden" />
<meta-data
android:name="preloaded_fonts"
android:resource="@array/preloaded_fonts" />
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="org.apache.fineract.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/filepaths" />
</provider>

<receiver android:name=".utils.CustomerWidget">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>

<meta-data
android:name="android.appwidget.provider"
android:resource="@xml/customer_widget_info" />
</receiver>

<receiver
android:name=".jobs.JobsReceiver"
Expand All @@ -102,9 +113,6 @@
<action android:name="org.apache.fineract.JobsReceiver" />
</intent-filter>
</receiver>
<meta-data
android:name="preloaded_fonts"
android:resource="@array/preloaded_fonts" />
</application>

</manifest>
43 changes: 43 additions & 0 deletions app/src/main/java/org/apache/fineract/utils/CustomerWidget.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package org.apache.fineract.utils

import android.app.PendingIntent
import android.appwidget.AppWidgetManager
import android.appwidget.AppWidgetProvider
import android.content.Context
import android.content.Intent
import android.widget.RemoteViews
import org.apache.fineract.R
import org.apache.fineract.ui.online.customers.createcustomer.CustomerAction
import org.apache.fineract.ui.online.customers.createcustomer.customeractivity.CreateCustomerActivity

/**
* Implementation of App Widget functionality.
*/
class CustomerWidget : AppWidgetProvider() {
override fun onUpdate(context: Context, appWidgetManager: AppWidgetManager, appWidgetIds: IntArray) {
// There may be multiple widgets active, so update all of them
for (appWidgetId in appWidgetIds) {
updateAppWidget(context, appWidgetManager, appWidgetId)
}
}

override fun onEnabled(context: Context) {
// Enter relevant functionality for when the first widget is created
}

override fun onDisabled(context: Context) {
// Enter relevant functionality for when the last widget is disabled
}
}

internal fun updateAppWidget(context: Context, appWidgetManager: AppWidgetManager, appWidgetId: Int) {
val intent = Intent(context, CreateCustomerActivity::class.java)
intent.putExtra(ConstantKeys.CUSTOMER_ACTION, CustomerAction.CREATE)
val pendingIntent = PendingIntent.getActivity(context, 0, intent, 0)
val views = RemoteViews(context.packageName, R.layout.customer_widget)

views.setImageViewResource(R.id.appwidget_img, R.drawable.ic_widget_48dp)
views.setOnClickPendingIntent(R.id.appwidget_img, pendingIntent)

appWidgetManager.updateAppWidget(appWidgetId, views)
}
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
@@ -1,5 +1,5 @@
<vector android:autoMirrored="true" android:height="24dp"
<vector android:autoMirrored="true" android:height="48dp"
android:viewportHeight="24.0" android:viewportWidth="24.0"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
android:width="48dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FFFFFFFF" android:pathData="M19,13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/>
</vector>
5 changes: 5 additions & 0 deletions app/src/main/res/drawable/ic_widget_48dp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/circle_bg_tap" />
<item android:drawable="@drawable/ic_add_white_48dp" />
</layer-list>
17 changes: 17 additions & 0 deletions app/src/main/res/layout/customer_widget.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:gravity="center_horizontal">

<ImageView
android:id="@+id/appwidget_img"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
app:srcCompat="@drawable/ic_widget_48dp"
android:layout_alignParentTop="true"/>

</RelativeLayout>
2 changes: 1 addition & 1 deletion app/src/main/res/layout/fragment_customer_deposit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@
android:layout_margin="@dimen/layout_padding_16dp"
android:layout_width="wrap_content"
app:layout_behavior="org.apache.fineract.utils.ScrollFabBehavior"
app:srcCompat="@drawable/ic_add_black_24dp"/>
app:srcCompat="@drawable/ic_add_white_48dp"/>

</androidx.coordinatorlayout.widget.CoordinatorLayout>
2 changes: 1 addition & 1 deletion app/src/main/res/layout/fragment_customer_list.xml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,6 @@
android:layout_margin="@dimen/layout_padding_16dp"
android:layout_width="wrap_content"
app:layout_behavior="org.apache.fineract.utils.ScrollFabBehavior"
app:srcCompat="@drawable/ic_add_black_24dp"/>
app:srcCompat="@drawable/ic_add_white_48dp"/>

</androidx.coordinatorlayout.widget.CoordinatorLayout>
2 changes: 1 addition & 1 deletion app/src/main/res/layout/fragment_customer_loans.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@
android:layout_margin="@dimen/fab_margin"
android:layout_width="wrap_content"
app:layout_behavior="org.apache.fineract.utils.ScrollFabBehavior"
app:srcCompat="@drawable/ic_add_black_24dp"/>
app:srcCompat="@drawable/ic_add_white_48dp"/>

</androidx.coordinatorlayout.widget.CoordinatorLayout>
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
android:clickable="true"
android:focusable="true"
android:tint="@color/white"
app:srcCompat="@drawable/ic_add_black_24dp" />
app:srcCompat="@drawable/ic_add_white_48dp" />

</androidx.coordinatorlayout.widget.CoordinatorLayout>
2 changes: 1 addition & 1 deletion app/src/main/res/layout/fragment_group_list.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
app:layout_anchor="@id/rvGroups"
app:layout_anchorGravity="bottom|right"
app:layout_behavior="org.apache.fineract.utils.ScrollFabBehavior"
app:srcCompat="@drawable/ic_add_black_24dp" />
app:srcCompat="@drawable/ic_add_white_48dp" />

</androidx.coordinatorlayout.widget.CoordinatorLayout>
2 changes: 1 addition & 1 deletion app/src/main/res/layout/fragment_identification_list.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@
android:layout_margin="@dimen/layout_padding_16dp"
android:layout_width="wrap_content"
app:layout_behavior="org.apache.fineract.utils.ScrollFabBehavior"
app:srcCompat="@drawable/ic_add_black_24dp"/>
app:srcCompat="@drawable/ic_add_white_48dp"/>

</androidx.coordinatorlayout.widget.CoordinatorLayout>
2 changes: 1 addition & 1 deletion app/src/main/res/layout/fragment_roles_list.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
android:layout_margin="@dimen/layout_padding_16dp"
android:layout_width="wrap_content"
app:layout_behavior="org.apache.fineract.utils.ScrollFabBehavior"
app:srcCompat="@drawable/ic_add_black_24dp"/>
app:srcCompat="@drawable/ic_add_white_48dp"/>
<include
layout="@layout/layout_sweet_exception_handler"
android:id="@+id/layout_error"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/fragment_step_add_group_leader.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
app:srcCompat="@drawable/ic_add_black_24dp" />
app:srcCompat="@drawable/ic_add_white_48dp" />

</LinearLayout>

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/fragment_step_add_group_member.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
app:srcCompat="@drawable/ic_add_black_24dp" />
app:srcCompat="@drawable/ic_add_white_48dp" />


</LinearLayout>
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/res/values-night/themes.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<resources>
<style name="ThemeOverlay.Fineractcnmobile.AppWidgetContainer" parent="">
<item name="appWidgetBackgroundColor">@color/light_blue_900</item>
<item name="appWidgetTextColor">@color/light_blue_200</item>
</style>
</resources>
6 changes: 6 additions & 0 deletions app/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<resources>
<declare-styleable name="AppWidgetAttrs">
<attr name="appWidgetBackgroundColor" format="color" />
<attr name="appWidgetTextColor" format="color" />
</declare-styleable>
</resources>
54 changes: 29 additions & 25 deletions app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
@@ -1,66 +1,70 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<array name="swipeRefreshColors">
<item>@color/blue_light</item>
<item>@color/green_light</item>
<item>@color/red_light</item>
<item>@color/orange_light</item>
</array>
<color name="colorPrimary">#009688</color>
<color name="colorPrimaryDark">#00796B</color>
<color name="colorPrimaryText">#212121</color>
<color name="colorSecondaryText">#757575</color>
<color name="colorAccent">#FF4081</color>

<color name="white">#ffffff</color>
<color name="colorAccent">#FF4081</color>
<!-- A light Holo shade of blue -->
<color name="blue_light">#ff33b5e5</color>
<color name="white">#ffffff</color>
<!-- A light Holo shade of gray -->
<color name="gray_light">#33999999</color>
<color name="blue_light">#ff33b5e5</color>
<!-- A dark Holo shade of gray -->
<color name="gray_dark">#BB666666</color>
<color name="gray_light">#33999999</color>
<!-- A light Holo shade of green -->
<color name="green_light">#ff99cc00</color>
<color name="gray_dark">#BB666666</color>
<!-- A light Holo shade of red -->
<color name="red_light">#ffff4444</color>
<color name="green_light">#ff99cc00</color>
<!-- A dark Holo shade of blue -->
<color name="blue_dark">#ff0099cc</color>
<color name="red_light">#ffff4444</color>
<!-- A dark Holo shade of green -->
<color name="green_dark">#ff669900</color>
<color name="blue_dark">#ff0099cc</color>
<!-- A dark Holo shade of red -->
<color name="red_dark">#ffcc0000</color>
<color name="green_dark">#ff669900</color>
<!-- A Holo shade of purple -->
<color name="purple">#ffaa66cc</color>
<color name="red_dark">#ffcc0000</color>
<!-- A light Holo shade of orange -->
<color name="orange_light">#ffffbb33</color>
<color name="purple">#ffaa66cc</color>
<!-- A dark Holo shade of orange -->
<color name="orange_dark">#ffff8800</color>
<color name="orange_light">#ffffbb33</color>
<!-- A really bright Holo shade of blue -->
<color name="blue_bright">#ff00ddff</color>
<color name="orange_dark">#ffff8800</color>
<!-- A really bright Holo shade of gray -->
<color name="blue_bright">#ff00ddff</color>

<color name="gray_bright">#33CCCCCC</color>

<color name="blue">#0a46b1</color>

<color name="blue_light_alert_background">#c9d8e9</color>
<!--Black-->
<color name="blue_light_alert_background">#c9d8e9</color>
<color name="black">#000000</color>
<color name="light_grey">#ffd1d1d1</color>

<color name="light_grey">#ffd1d1d1</color>
<color name="deposit_green">#ff14c416</color>
<color name="light_green">#ff8bf98a</color>
<color name="light_yellow">#fff9ac06</color>
<color name="light_blue">#FF87DBF9</color>
<color name="light_red">#fff9393c</color>

<color name="light_red">#fff9393c</color>
<color name="collapse_image">#bbbbbb</color>
<color name="grey_500">#9e9e9e</color>
<color name="icon_image_background">#E9E2E2</color>
<color name="status">#049314</color>
<color name="icon_color">#787171</color>
<color name="base10">#eaeaea</color>
<color name="base30">#c1c1c1</color>


<!--Swipe Refresh Colors-->
<array name="swipeRefreshColors">
<item>@color/blue_light</item>
<item>@color/green_light</item>
<item>@color/red_light</item>
<item>@color/orange_light</item>
</array>
<color name="base30">#c1c1c1</color>
<color name="light_blue_50">#FFE1F5FE</color>
<color name="light_blue_200">#FF81D4FA</color>
<color name="light_blue_600">#FF039BE5</color>
<color name="light_blue_900">#FF01579B</color>
</resources>
6 changes: 6 additions & 0 deletions app/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<resources>
<style name="ThemeOverlay.Fineractcnmobile.AppWidgetContainer" parent="">
<item name="appWidgetBackgroundColor">@color/light_blue_600</item>
<item name="appWidgetTextColor">@color/light_blue_50</item>
</style>
</resources>
10 changes: 10 additions & 0 deletions app/src/main/res/xml/customer_widget_info.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:initialKeyguardLayout="@layout/customer_widget"
android:initialLayout="@layout/customer_widget"
android:minHeight="40dp"
android:minWidth="40dp"
android:previewImage="@drawable/widget_preview"
android:resizeMode="none"
android:updatePeriodMillis="86400000"
android:widgetCategory="home_screen" />