Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5c66f6c4dc |
@@ -11,8 +11,8 @@ android {
|
|||||||
applicationId = "com.expapp.trigger"
|
applicationId = "com.expapp.trigger"
|
||||||
minSdk = 24
|
minSdk = 24
|
||||||
targetSdk = 34
|
targetSdk = 34
|
||||||
versionCode = 16
|
versionCode = 17
|
||||||
versionName = "1.2.2"
|
versionName = "1.2.3"
|
||||||
|
|
||||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||||
vectorDrawables {
|
vectorDrawables {
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ class ServerWidgetProvider : AppWidgetProvider() {
|
|||||||
appWidgetManager: AppWidgetManager,
|
appWidgetManager: AppWidgetManager,
|
||||||
appWidgetIds: IntArray
|
appWidgetIds: IntArray
|
||||||
) {
|
) {
|
||||||
|
try {
|
||||||
val repository = DeviceRepository(SharedPrefsStorage(context))
|
val repository = DeviceRepository(SharedPrefsStorage(context))
|
||||||
val devices = repository.getDevices()
|
val devices = repository.getDevices()
|
||||||
|
|
||||||
@@ -67,13 +68,24 @@ class ServerWidgetProvider : AppWidgetProvider() {
|
|||||||
// If device exists, fetch live status asynchronously
|
// If device exists, fetch live status asynchronously
|
||||||
if (device != null && device.statusUrl.isNotBlank()) {
|
if (device != null && device.statusUrl.isNotBlank()) {
|
||||||
executor.execute {
|
executor.execute {
|
||||||
|
try {
|
||||||
val status = TriggerClient().checkStatusSync(device)
|
val status = TriggerClient().checkStatusSync(device)
|
||||||
mainHandler.post {
|
mainHandler.post {
|
||||||
|
try {
|
||||||
renderWidget(context, appWidgetManager, appWidgetId, device, status)
|
renderWidget(context, appWidgetManager, appWidgetId, device, status)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
e.printStackTrace()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
e.printStackTrace()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
e.printStackTrace()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onReceive(context: Context, intent: Intent) {
|
override fun onReceive(context: Context, intent: Intent) {
|
||||||
@@ -131,6 +143,7 @@ class ServerWidgetProvider : AppWidgetProvider() {
|
|||||||
status: NodeStatus?,
|
status: NodeStatus?,
|
||||||
footerOverride: String? = null
|
footerOverride: String? = null
|
||||||
) {
|
) {
|
||||||
|
try {
|
||||||
val views = RemoteViews(context.packageName, R.layout.widget_server_control)
|
val views = RemoteViews(context.packageName, R.layout.widget_server_control)
|
||||||
|
|
||||||
if (device == null) {
|
if (device == null) {
|
||||||
@@ -217,6 +230,9 @@ class ServerWidgetProvider : AppWidgetProvider() {
|
|||||||
)
|
)
|
||||||
|
|
||||||
appWidgetManager.updateAppWidget(appWidgetId, views)
|
appWidgetManager.updateAppWidget(appWidgetId, views)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
e.printStackTrace()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun createTriggerPendingIntent(
|
private fun createTriggerPendingIntent(
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 324 B |
Binary file not shown.
|
After Width: | Height: | Size: 314 B |
@@ -17,7 +17,7 @@
|
|||||||
<ImageView
|
<ImageView
|
||||||
android:layout_width="18dp"
|
android:layout_width="18dp"
|
||||||
android:layout_height="18dp"
|
android:layout_height="18dp"
|
||||||
android:src="@drawable/ic_terminal"
|
android:src="@drawable/widget_ic_terminal"
|
||||||
android:contentDescription="Server" />
|
android:contentDescription="Server" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
@@ -82,14 +82,13 @@
|
|||||||
android:id="@+id/widget_btn_refresh"
|
android:id="@+id/widget_btn_refresh"
|
||||||
android:layout_width="26dp"
|
android:layout_width="26dp"
|
||||||
android:layout_height="26dp"
|
android:layout_height="26dp"
|
||||||
android:background="?android:attr/selectableItemBackgroundBorderless"
|
|
||||||
android:contentDescription="Refresh"
|
android:contentDescription="Refresh"
|
||||||
android:padding="3dp"
|
android:padding="3dp"
|
||||||
android:src="@drawable/ic_refresh" />
|
android:src="@drawable/widget_ic_refresh" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<!-- Spacer / Divider -->
|
<!-- Spacer / Divider (FrameLayout is explicitly whitelisted in RemoteViews) -->
|
||||||
<View
|
<FrameLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="1dp"
|
android:layout_height="1dp"
|
||||||
android:layout_marginTop="8dp"
|
android:layout_marginTop="8dp"
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
|
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:minWidth="250dp"
|
android:minWidth="220dp"
|
||||||
android:minHeight="100dp"
|
android:minHeight="90dp"
|
||||||
|
android:targetCellWidth="3"
|
||||||
|
android:targetCellHeight="2"
|
||||||
|
android:minResizeWidth="180dp"
|
||||||
|
android:minResizeHeight="70dp"
|
||||||
android:updatePeriodMillis="1800000"
|
android:updatePeriodMillis="1800000"
|
||||||
android:initialLayout="@layout/widget_server_control"
|
android:initialLayout="@layout/widget_server_control"
|
||||||
android:resizeMode="horizontal|vertical"
|
android:resizeMode="horizontal|vertical"
|
||||||
|
|||||||
Reference in New Issue
Block a user