add top level grid item for OpenDelta
diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml
deleted file mode 100644
index e84ff8f..0000000
--- a/.idea/deploymentTargetDropDown.xml
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project version="4">
- <component name="deploymentTargetDropDown">
- <runningDeviceTargetSelectedWithDropDown>
- <Target>
- <type value="RUNNING_DEVICE_TARGET" />
- <deviceKey>
- <Key>
- <type value="SERIAL_NUMBER" />
- <value value="C86314713FC5" />
- </Key>
- </deviceKey>
- </Target>
- </runningDeviceTargetSelectedWithDropDown>
- <timeTargetWasSelectedWithDropDown value="2021-11-07T15:04:02.322808Z" />
- </component>
-</project>
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 42fdea8..c4f3df4 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -17,6 +17,7 @@
<entry key="app/src/main/res/drawable/ic_settings_buttons.xml" value="0.3078125" />
<entry key="app/src/main/res/drawable/ic_settings_more.xml" value="0.30885416666666665" />
<entry key="app/src/main/res/drawable/ic_settings_omnigears.xml" value="0.3098958333333333" />
+ <entry key="app/src/main/res/drawable/ic_system_update.xml" value="0.2786458333333333" />
<entry key="app/src/main/res/drawable/ic_wallpaper.xml" value="0.3098958333333333" />
<entry key="app/src/main/res/drawable/settings_icon.xml" value="0.30885416666666665" />
<entry key="app/src/main/res/layout/grid_fragment.xml" value="0.3020833333333333" />
diff --git a/app/src/main/java/org/omnirom/control/AppListFragment.kt b/app/src/main/java/org/omnirom/control/AppListFragment.kt
index f2a513d..c2abc9f 100644
--- a/app/src/main/java/org/omnirom/control/AppListFragment.kt
+++ b/app/src/main/java/org/omnirom/control/AppListFragment.kt
@@ -17,17 +17,18 @@
*/
package org.omnirom.control
+import android.content.ComponentName
import android.content.Intent
import android.os.Bundle
+import androidx.appcompat.app.AppCompatActivity
import androidx.preference.Preference
import androidx.preference.PreferenceCategory
// TODO maybe better to use a GridView
class AppListFragment : AbstractSettingsFragment() {
private val KEY_APPS_LIST = "apps_list"
- private val OMNISTORE_APP_PKG = "org.omnirom.omnistore"
- private val OMNISTORE_INSTALL_PKG = "org.omnirom.omnistoreinstaller"
lateinit var appManager: ApplicationManager
+ var updateAppList: Boolean = false
override fun getFragmentTitle(): String {
return resources.getString(R.string.applist_settings_title)
@@ -88,26 +89,6 @@
resources.getString(R.string.omnistore_summary)
)
- appManager.addApp(
- "org.omnirom.omnistoreinstaller",
- "org.omnirom.omnistoreinstaller.MainActivity",
- resources.getString(R.string.omnistore_title),
- resources.getString(R.string.omnistore_summary)
- )
-
- /*appManager.addApp(
- "org.omnirom.omnistyle",
- "org.omnirom.omnistyle.WallpaperActivity",
- getString(R.string.wallpaper_title),
- getString(R.string.wallpaper_summary)
- )*/
-
- /*appManager.addApp(
- "org.omnirom.device",
- "org.omnirom.device.DeviceSettings",
- getString(R.string.device_settings_title),
- getString(R.string.device_settings_summary)
- )*/
createAppList()
}
@@ -116,15 +97,13 @@
if (appCategory != null) {
appCategory.removeAll()
for (app in appManager.mAppList) {
- if (!Utils.isAvailableApp(requireContext(), app.mPackage)) {
- continue
+ // store is always visible cause installer is always there
+ if (app.mPackage != "org.omnirom.omnistore") {
+ if (!Utils.isAvailableApp(requireContext(), app.mPackage)) {
+ continue
+ }
}
- if (app.mPackage.equals(OMNISTORE_INSTALL_PKG) && Utils.isAvailableApp(
- requireContext(), OMNISTORE_APP_PKG
- )
- ) {
- continue
- }
+
val preference = Preference(requireContext())
preference.key = app.mPackage
preference.title = app.mTitle
@@ -136,6 +115,7 @@
appCategory.addPreference(preference)
}
+ updateAppList = false
}
}
@@ -143,10 +123,25 @@
if (preference?.key != null) {
var app: Application? = appManager.getAppOfPackage(preference.key)
if (app != null) {
+ if (app.mPackage == "org.omnirom.omnistore") {
+ if (!Utils.isAvailableApp(requireContext(), app.mPackage)) {
+ // start installer instead
+ appManager.startApp(ComponentName("org.omnirom.omnistoreinstaller",
+ "org.omnirom.omnistoreinstaller.MainActivity"))
+ updateAppList = true
+ return true
+ }
+ }
appManager.startApp(app)
return true
}
}
return super.onPreferenceTreeClick(preference)
}
+
+ override fun onResume() {
+ super.onResume()
+ if (updateAppList)
+ createAppList()
+ }
}
\ No newline at end of file
diff --git a/app/src/main/java/org/omnirom/control/ApplicationManager.kt b/app/src/main/java/org/omnirom/control/ApplicationManager.kt
index 8e13000..0ac3f98 100644
--- a/app/src/main/java/org/omnirom/control/ApplicationManager.kt
+++ b/app/src/main/java/org/omnirom/control/ApplicationManager.kt
@@ -16,6 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
+import android.content.ComponentName
import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager
@@ -39,7 +40,14 @@
fun getAppIcon(app: Application): Drawable {
val pm: PackageManager = mContext.getPackageManager()
return try {
- resizeAppIcon(pm.getApplicationIcon(app.mPackage), mIconSize, 0)
+ var packageName = app.mPackage;
+ if (packageName.equals("org.omnirom.omnistore")) {
+ if (!Utils.isAvailableApp(mContext, packageName)) {
+ // get icon from installer
+ packageName = "org.omnirom.omnistoreinstaller"
+ }
+ }
+ resizeAppIcon(pm.getApplicationIcon(packageName), mIconSize, 0)
} catch (e: PackageManager.NameNotFoundException) {
pm.defaultActivityIcon
}
@@ -54,6 +62,15 @@
}
}
+ fun startApp(component: ComponentName) {
+ val intent = Intent()
+ intent.component = component
+ try {
+ mContext.startActivity(intent)
+ } catch (e: Exception) {
+ }
+ }
+
fun addApp(packageName: String, activity: String, title: String, summary: String) {
mAppList.add(Application(packageName, activity, title, summary))
}
diff --git a/app/src/main/java/org/omnirom/control/GridViewFragment.kt b/app/src/main/java/org/omnirom/control/GridViewFragment.kt
index 33cda82..e9bd7fd 100644
--- a/app/src/main/java/org/omnirom/control/GridViewFragment.kt
+++ b/app/src/main/java/org/omnirom/control/GridViewFragment.kt
@@ -122,6 +122,21 @@
)
)
}
+ if (Utils.isAvailableApp(requireContext(), "eu.chainfire.opendelta")) {
+ val wallpaperIntent = Intent()
+ wallpaperIntent.component = ComponentName(
+ "eu.chainfire.opendelta",
+ "eu.chainfire.opendelta.MainActivity"
+ )
+ gridItems.add(
+ IntentGridItem(
+ R.string.system_update_title,
+ R.string.system_update_summary,
+ R.drawable.ic_system_update,
+ wallpaperIntent
+ )
+ )
+ }
if (Utils.isAvailableApp(requireContext(), "org.omnirom.device")) {
val deviceIntent = Intent()
deviceIntent.component = ComponentName(
diff --git a/app/src/main/res/drawable/ic_system_update.xml b/app/src/main/res/drawable/ic_system_update.xml
new file mode 100644
index 0000000..199e038
--- /dev/null
+++ b/app/src/main/res/drawable/ic_system_update.xml
@@ -0,0 +1,25 @@
+<!--
+ Copyright (C) 2017 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:tint="?android:textColorPrimary"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0">
+ <path
+ android:fillColor="@android:color/white"
+ android:pathData="M17,1.01L7,1C5.9,1 5,1.9 5,3v18c0,1.1 0.9,2 2,2h10c1.1,0 2,-0.9 2,-2V3C19,1.9 18.1,1.01 17,1.01zM17,21H7l0,-1h10V21zM17,18H7V6h10V18zM7,4V3h10v1H7zM16,12.5l-4,4l-4,-4l1.41,-1.41L11,12.67V8.5V8h2v0.5v4.17l1.59,-1.59L16,12.5z" />
+</vector>
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index b38495e..ff4c01d 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -49,4 +49,9 @@
<string name="lockscreen_weather_title">Show weather condition</string>
<string name="lockscreen_weather_summary">Show current weather condition and temperature</string>
<string name="lockscreen_weather_enabled_info">Requires enablement of weather service</string>
+
+ <string name="system_update_title">System updates</string>
+ <string name="system_update_summary">Download and install OmniROM updates</string>
+
+
</resources>
\ No newline at end of file