-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpatch_main.diff
More file actions
44 lines (39 loc) · 1.48 KB
/
patch_main.diff
File metadata and controls
44 lines (39 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
--- app/src/main/java/com/leanbitlab/lwidget/MainActivity.kt
+++ app/src/main/java/com/leanbitlab/lwidget/MainActivity.kt
@@ -107,6 +107,7 @@
checkAllPermissions()
setupSections()
+ updateLivePreview()
// Setup Changelog
val versionName = try {
@@ -150,6 +151,7 @@
val fab = findViewById<ExtendedFloatingActionButton>(R.id.fab_update)
fab.setOnClickListener {
updateWidget()
+ updateLivePreview()
}
// Apply navigation bar insets to FAB so it doesn't overlap gesture nav
@@ -187,6 +189,18 @@
})
}
+ private fun updateLivePreview() {
+ val previewContainer = findViewById<android.widget.FrameLayout>(R.id.preview_container)
+ try {
+ val remoteViews = AwidgetProvider.Companion.buildAppWidgetRemoteViews(this, AwidgetProvider.UpdateMode.FULL)
+ val view = remoteViews.apply(this, previewContainer)
+ previewContainer.removeAllViews()
+ previewContainer.addView(view)
+ } catch (e: Exception) {
+ e.printStackTrace()
+ }
+ }
+
private fun checkAllPermissions() {
val cardPermissionList = findViewById<View>(R.id.card_permission_list)
var widgetNeedsUpdate = false
@@ -1493,6 +1507,7 @@
}
private fun updateWidget() {
+ updateLivePreview()
// Animation: Subtle Outline Shine
val fab = findViewById<ExtendedFloatingActionButton>(R.id.fab_update)