mirror of
https://github.com/hmalik144/Weather-apps.git
synced 2025-12-10 02:05:20 +00:00
- All committed to main
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:background="@android:color/black"
|
||||
tools:layout_height="160dp">
|
||||
tools:layout_height="110dp">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
@@ -137,14 +137,14 @@
|
||||
|
||||
<GridView
|
||||
android:id="@+id/widget_listview"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/central"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_centerInParent="true"
|
||||
android:adjustViewBounds="true"
|
||||
android:numColumns="5"
|
||||
tools:listitem="@layout/widget_item">
|
||||
|
||||
</GridView>
|
||||
tools:listitem="@layout/widget_item"/>
|
||||
|
||||
|
||||
</RelativeLayout>
|
||||
@@ -3,8 +3,9 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/widget_item_layout"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="82dp"
|
||||
android:orientation="vertical">
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:minHeight="55dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/widget_item_day"
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
android:minResizeWidth="350.0dp"
|
||||
android:minResizeHeight="110.0dp"
|
||||
android:previewImage="@drawable/widget_screenshot"
|
||||
android:updatePeriodMillis="3600000"
|
||||
android:updatePeriodMillis="1800000"
|
||||
android:resizeMode="vertical"
|
||||
android:widgetCategory="home_screen">
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.pm.PackageManager
|
||||
import android.net.Uri
|
||||
import android.os.PowerManager
|
||||
import android.widget.RemoteViews
|
||||
import androidx.core.app.ActivityCompat
|
||||
import com.appttude.h_mal.atlas_weather.R
|
||||
@@ -30,13 +31,24 @@ import java.time.format.DateTimeFormatter
|
||||
class WidgetJobServiceIntent : BaseWidgetServiceIntentClass() {
|
||||
|
||||
override fun onHandleWork(intent: Intent) {
|
||||
setKodein(this)
|
||||
// We have received work to do. The system or framework is already
|
||||
// holding a wake lock for us at this point, so we can just go.
|
||||
|
||||
val pm = getSystemService(POWER_SERVICE) as PowerManager
|
||||
val isScreenOn = pm.isInteractive
|
||||
|
||||
// If screen is on then update widget or do nothing
|
||||
if (isScreenOn) executeWidgetUpdate()
|
||||
}
|
||||
|
||||
private fun executeWidgetUpdate(){
|
||||
setKodein(this)
|
||||
|
||||
val appWidgetManager = AppWidgetManager.getInstance(this)
|
||||
val thisAppWidget = ComponentName(packageName, NewAppWidget::class.java.name)
|
||||
val appWidgetIds = appWidgetManager.getAppWidgetIds(thisAppWidget)
|
||||
|
||||
// Check if we have an active connection and permissions granted
|
||||
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION)
|
||||
!= PackageManager.PERMISSION_GRANTED || !isInternetAvailable(this.applicationContext)) {
|
||||
for (appWidgetId in appWidgetIds) {
|
||||
|
||||
Reference in New Issue
Block a user