Loading app/src/main/java/foundation/e/apps/updates/UpdatesNotifier.kt +19 −3 Original line number Diff line number Diff line Loading @@ -31,7 +31,11 @@ import foundation.e.apps.R import foundation.e.apps.utils.Constants class UpdatesNotifier { private fun getNotification(context: Context, numberOfApps: Int, installAutomatically: Boolean): private fun getNotification(context: Context, numberOfApps: Int, installAutomatically: Boolean, unmeteredNetworkOnly: Boolean, isConnectedToUnmeteredNetwork: Boolean): Notification { val notificationBuilder = NotificationCompat.Builder(context, Constants.UPDATES_NOTIFICATION_CHANNEL_ID) Loading @@ -51,6 +55,10 @@ class UpdatesNotifier { if (installAutomatically) { notificationBuilder.setContentText(context.getString(R.string.updates_notification_text, Constants.AUTOMATICALLY_INSTALL_UPDATES)) if (unmeteredNetworkOnly && !isConnectedToUnmeteredNetwork) { notificationBuilder.setSubText(context .getString(R.string.updates_notification_unmetered_network_warning)) } } else { notificationBuilder.setContentText(context.getString(R.string.updates_notification_text, Constants.MANUALLY_INSTALL_UPDATES)) Loading Loading @@ -82,11 +90,19 @@ class UpdatesNotifier { } } fun showNotification(context: Context, numberOfApps: Int, installAutomatically: Boolean) { fun showNotification(context: Context, numberOfApps: Int, installAutomatically: Boolean, unmeteredNetworkOnly: Boolean, isConnectedToUnmeteredNetwork: Boolean) { with(NotificationManagerCompat.from(context)) { createNotificationChannel(context) notify(Constants.UPDATES_NOTIFICATION_ID, getNotification(context, numberOfApps, installAutomatically)) getNotification(context, numberOfApps, installAutomatically, unmeteredNetworkOnly, isConnectedToUnmeteredNetwork)) } } } app/src/main/java/foundation/e/apps/updates/model/UpdatesWorker.kt +6 −3 Original line number Diff line number Diff line Loading @@ -62,7 +62,7 @@ class UpdatesWorker(context: Context, params: WorkerParameters) : Worker(context R.string.pref_update_install_automatically_key), true) wifiOnly = preferences.getBoolean(applicationContext.getString( R.string.pref_update_wifi_only_key), false) R.string.pref_update_wifi_only_key), true) } private fun loadOutdatedApplications(applicationManager: ApplicationManager) { Loading @@ -85,15 +85,18 @@ class UpdatesWorker(context: Context, params: WorkerParameters) : Worker(context } it.close() } val isConnectedToUnmeteredNetwork = isConnectedToUnmeteredNetwork(applicationContext) if (notifyAvailable) { UpdatesNotifier().showNotification( applicationContext, applications.size, installAutomatically) installAutomatically, wifiOnly, isConnectedToUnmeteredNetwork) } if (installAutomatically && canWriteStorage(applicationContext)) { if (wifiOnly) { if (isConnectedToUnmeteredNetwork(applicationContext)) { if (isConnectedToUnmeteredNetwork) { applications.forEach { if (it.state == State.NOT_UPDATED) { Log.i(TAG, "Updating ${it.packageName}") Loading app/src/main/res/values/strings.xml +1 −0 Original line number Diff line number Diff line Loading @@ -84,6 +84,7 @@ <item quantity="other">%1$d app updates are available</item> </plurals> <string name="updates_notification_text">App updates %1$s be installed automatically</string> <string name="updates_notification_unmetered_network_warning">Waiting for un-metered network</string> <!-- Settings Fragment --> <string name="preference_updates_title">Updates</string> Loading app/src/main/res/xml/preferences.xml +1 −1 Original line number Diff line number Diff line Loading @@ -45,7 +45,7 @@ android:title="@string/preference_update_install_automatically_title" /> <CheckBoxPreference android:defaultValue="false" android:defaultValue="true" android:key="@string/pref_update_wifi_only_key" android:summary="@string/preference_update_wifi_only_description" android:title="@string/preference_update_wifi_only_title" /> Loading build.gradle +1 −1 Original line number Diff line number Diff line Loading @@ -7,7 +7,7 @@ buildscript { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:3.4.0' classpath 'com.android.tools.build:gradle:3.4.1' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" // NOTE: Do not place your application dependencies here; they belong Loading Loading
app/src/main/java/foundation/e/apps/updates/UpdatesNotifier.kt +19 −3 Original line number Diff line number Diff line Loading @@ -31,7 +31,11 @@ import foundation.e.apps.R import foundation.e.apps.utils.Constants class UpdatesNotifier { private fun getNotification(context: Context, numberOfApps: Int, installAutomatically: Boolean): private fun getNotification(context: Context, numberOfApps: Int, installAutomatically: Boolean, unmeteredNetworkOnly: Boolean, isConnectedToUnmeteredNetwork: Boolean): Notification { val notificationBuilder = NotificationCompat.Builder(context, Constants.UPDATES_NOTIFICATION_CHANNEL_ID) Loading @@ -51,6 +55,10 @@ class UpdatesNotifier { if (installAutomatically) { notificationBuilder.setContentText(context.getString(R.string.updates_notification_text, Constants.AUTOMATICALLY_INSTALL_UPDATES)) if (unmeteredNetworkOnly && !isConnectedToUnmeteredNetwork) { notificationBuilder.setSubText(context .getString(R.string.updates_notification_unmetered_network_warning)) } } else { notificationBuilder.setContentText(context.getString(R.string.updates_notification_text, Constants.MANUALLY_INSTALL_UPDATES)) Loading Loading @@ -82,11 +90,19 @@ class UpdatesNotifier { } } fun showNotification(context: Context, numberOfApps: Int, installAutomatically: Boolean) { fun showNotification(context: Context, numberOfApps: Int, installAutomatically: Boolean, unmeteredNetworkOnly: Boolean, isConnectedToUnmeteredNetwork: Boolean) { with(NotificationManagerCompat.from(context)) { createNotificationChannel(context) notify(Constants.UPDATES_NOTIFICATION_ID, getNotification(context, numberOfApps, installAutomatically)) getNotification(context, numberOfApps, installAutomatically, unmeteredNetworkOnly, isConnectedToUnmeteredNetwork)) } } }
app/src/main/java/foundation/e/apps/updates/model/UpdatesWorker.kt +6 −3 Original line number Diff line number Diff line Loading @@ -62,7 +62,7 @@ class UpdatesWorker(context: Context, params: WorkerParameters) : Worker(context R.string.pref_update_install_automatically_key), true) wifiOnly = preferences.getBoolean(applicationContext.getString( R.string.pref_update_wifi_only_key), false) R.string.pref_update_wifi_only_key), true) } private fun loadOutdatedApplications(applicationManager: ApplicationManager) { Loading @@ -85,15 +85,18 @@ class UpdatesWorker(context: Context, params: WorkerParameters) : Worker(context } it.close() } val isConnectedToUnmeteredNetwork = isConnectedToUnmeteredNetwork(applicationContext) if (notifyAvailable) { UpdatesNotifier().showNotification( applicationContext, applications.size, installAutomatically) installAutomatically, wifiOnly, isConnectedToUnmeteredNetwork) } if (installAutomatically && canWriteStorage(applicationContext)) { if (wifiOnly) { if (isConnectedToUnmeteredNetwork(applicationContext)) { if (isConnectedToUnmeteredNetwork) { applications.forEach { if (it.state == State.NOT_UPDATED) { Log.i(TAG, "Updating ${it.packageName}") Loading
app/src/main/res/values/strings.xml +1 −0 Original line number Diff line number Diff line Loading @@ -84,6 +84,7 @@ <item quantity="other">%1$d app updates are available</item> </plurals> <string name="updates_notification_text">App updates %1$s be installed automatically</string> <string name="updates_notification_unmetered_network_warning">Waiting for un-metered network</string> <!-- Settings Fragment --> <string name="preference_updates_title">Updates</string> Loading
app/src/main/res/xml/preferences.xml +1 −1 Original line number Diff line number Diff line Loading @@ -45,7 +45,7 @@ android:title="@string/preference_update_install_automatically_title" /> <CheckBoxPreference android:defaultValue="false" android:defaultValue="true" android:key="@string/pref_update_wifi_only_key" android:summary="@string/preference_update_wifi_only_description" android:title="@string/preference_update_wifi_only_title" /> Loading
build.gradle +1 −1 Original line number Diff line number Diff line Loading @@ -7,7 +7,7 @@ buildscript { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:3.4.0' classpath 'com.android.tools.build:gradle:3.4.1' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" // NOTE: Do not place your application dependencies here; they belong Loading