update
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 3cdb9b3..6f1e495 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -3,15 +3,46 @@
<component name="DesignSurface">
<option name="filePathToZoomLevelMap">
<map>
+ <entry key="../../../../layout/custom_preview.xml" value="0.2526041666666667" />
+ <entry key="app/src/main/res/drawable-v24/ic_launcher_foreground.xml" value="0.3067708333333333" />
+ <entry key="app/src/main/res/drawable/applist_icon.xml" value="0.30885416666666665" />
+ <entry key="app/src/main/res/drawable/bottom_navigation_selector.xml" value="0.3067708333333333" />
+ <entry key="app/src/main/res/drawable/grid_item_background.xml" value="0.30833333333333335" />
+ <entry key="app/src/main/res/drawable/grid_item_background_shape.xml" value="0.3104166666666667" />
+ <entry key="app/src/main/res/drawable/ic_bars_tile.xml" value="0.30885416666666665" />
+ <entry key="app/src/main/res/drawable/ic_homepage_bars.xml" value="0.5109375" />
+ <entry key="app/src/main/res/drawable/ic_launcher_background.xml" value="0.3067708333333333" />
+ <entry key="app/src/main/res/drawable/ic_launcher_foreground.xml" value="0.2869791666666667" />
+ <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_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" />
+ <entry key="app/src/main/res/layout/grid_item.xml" value="0.29270833333333335" />
<entry key="app/src/main/res/layout/settings_activity.xml" value="0.259375" />
+ <entry key="app/src/main/res/menu/bottom_navbar.xml" value="0.23541666666666666" />
+ <entry key="app/src/main/res/menu/bottom_navigation.xml" value="0.2375" />
+ <entry key="app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml" value="0.3067708333333333" />
+ <entry key="app/src/main/res/xml/applist_preferences.xml" value="0.4979166666666667" />
+ <entry key="app/src/main/res/xml/bars_settings_preferences.xml" value="0.3098958333333333" />
+ <entry key="app/src/main/res/xml/bottom_navigation.xml" value="0.2375" />
+ <entry key="app/src/main/res/xml/button_settings_preferences.xml" value="0.4979166666666667" />
+ <entry key="app/src/main/res/xml/more_settings_preferences.xml" value="0.29375" />
<entry key="app/src/main/res/xml/root_preferences.xml" value="0.4979166666666667" />
+ <entry key="app/src/main/res/xml/settings_preferences.xml" value="0.23541666666666666" />
</map>
</option>
</component>
+ <component name="ProjectPlainTextFileTypeManager">
+ <file url="file://$PROJECT_DIR$/app/src/main/res/xml/bars_settings_preferences.xml" />
+ </component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
<option name="id" value="Android" />
</component>
+ <component name="SuppressKotlinCodeStyleNotification">
+ <option name="disableForAll" value="true" />
+ </component>
</project>
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..94a25f7
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+ <component name="VcsDirectoryMappings">
+ <mapping directory="$PROJECT_DIR$" vcs="Git" />
+ </component>
+</project>
\ No newline at end of file
diff --git a/Android.bp b/Android.bp
new file mode 100644
index 0000000..60c1d6c
--- /dev/null
+++ b/Android.bp
@@ -0,0 +1,29 @@
+android_app {
+ name: "OmniControl",
+ manifest: "app/src/main/AndroidManifest.xml",
+ platform_apis: true,
+ certificate: "platform",
+ privileged: true,
+
+ srcs: [
+ "app/src/main/**/*.kt",
+ "app/src/main/**/*.java",
+ ],
+
+ resource_dirs: [
+ "app/src/main/res/",
+ ],
+
+ static_libs: [
+ "androidx.core_core",
+ "androidx.appcompat_appcompat",
+ "androidx.preference_preference",
+ "com.google.android.material_material",
+ ],
+
+ kotlincflags: ["-Xjvm-default=enable"],
+
+ optimize: {
+ enabled: false,
+ },
+}
\ No newline at end of file
diff --git a/app/build.gradle b/app/build.gradle
index 42243f7..cb09029 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -21,6 +21,10 @@
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
+ debug {
+ applicationIdSuffix '.debug'
+ versionNameSuffix ' DEBUG'
+ }
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
diff --git a/app/src/debug/res/values/strings.xml b/app/src/debug/res/values/strings.xml
new file mode 100644
index 0000000..399e1fd
--- /dev/null
+++ b/app/src/debug/res/values/strings.xml
@@ -0,0 +1,3 @@
+<resources>
+ <string name="app_name">OmniControl DEBUG</string>
+</resources>
\ No newline at end of file
diff --git a/app/src/main/java/org/omnirom/control/AppListFragment.kt b/app/src/main/java/org/omnirom/control/AppListFragment.kt
index 5c37ff4..d2fcdb2 100644
--- a/app/src/main/java/org/omnirom/control/AppListFragment.kt
+++ b/app/src/main/java/org/omnirom/control/AppListFragment.kt
@@ -1,31 +1,35 @@
+/*
+ * Copyright (C) 2021 The OmniROM Project
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
package org.omnirom.control
import android.content.Intent
-import android.content.pm.PackageManager
import android.os.Bundle
-import android.provider.Settings
import androidx.appcompat.app.AppCompatActivity
import androidx.preference.Preference
import androidx.preference.PreferenceCategory
import androidx.preference.PreferenceFragmentCompat
class AppListFragment : PreferenceFragmentCompat() {
- val KEY_APPS_LIST = "apps_list"
- val OMNISTORE_APP_PKG = "org.omnirom.omnistore"
- val OMNISTORE_INSTALL_PKG = "org.omnirom.omnistoreinstaller"
+ 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
- fun isAvailableApp(packageName: String): Boolean {
- val pm: PackageManager = requireContext().getPackageManager()
- return try {
- val enabled = pm.getApplicationEnabledSetting(packageName)
- enabled != PackageManager.COMPONENT_ENABLED_STATE_DISABLED &&
- enabled != PackageManager.COMPONENT_ENABLED_STATE_DISABLED_USER
- } catch (e: Exception) {
- false
- }
- }
-
override fun onResume() {
super.onResume()
(activity as? AppCompatActivity)?.supportActionBar?.setDisplayHomeAsUpEnabled(true)
@@ -86,32 +90,32 @@
resources.getString(R.string.omnistore_summary)
)
- appManager.addApp(
+ /*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)
+ "org.omnirom.device",
+ "org.omnirom.device.DeviceSettings",
+ getString(R.string.device_settings_title),
+ getString(R.string.device_settings_summary)
)
createAppList()
}
- fun createAppList() {
+ private fun createAppList() {
var appCategory: PreferenceCategory? = findPreference(KEY_APPS_LIST)
if (appCategory != null) {
appCategory.removeAll()
for (app in appManager.mAppList) {
- if (!isAvailableApp(app.mPackage)) {
+ if (!Utils.isAvailableApp(requireContext(), app.mPackage)) {
continue
}
- if (app.mPackage.equals(OMNISTORE_INSTALL_PKG) && isAvailableApp(
- OMNISTORE_APP_PKG
+ if (app.mPackage.equals(OMNISTORE_INSTALL_PKG) && Utils.isAvailableApp(
+ requireContext(), OMNISTORE_APP_PKG
)
) {
continue
@@ -129,6 +133,7 @@
}
}
}
+
override fun onPreferenceTreeClick(preference: Preference?): Boolean {
if (preference?.key != null) {
var app: Application? = appManager.getAppOfPackage(preference.key)
diff --git a/app/src/main/java/org/omnirom/control/Application.kt b/app/src/main/java/org/omnirom/control/Application.kt
index 16e246c..f75c98c 100644
--- a/app/src/main/java/org/omnirom/control/Application.kt
+++ b/app/src/main/java/org/omnirom/control/Application.kt
@@ -1,19 +1,30 @@
+/*
+ * Copyright (C) 2021 The OmniROM Project
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
package org.omnirom.control
import android.content.ComponentName
-class Application {
- val mPackage: String
- val mActivity:String
- val mTitle: String
- val mSummary: String
+class Application(packageName: String, activity: String, title: String, summary: String) {
+ val mPackage: String = packageName
+ val mActivity:String = activity
+ val mTitle: String = title
+ val mSummary: String = summary
- constructor(packageName: String, activity: String, title: String, summary: String){
- mActivity=activity
- mPackage=packageName
- mTitle=title
- mSummary=summary
- }
fun getComponentName() : ComponentName{
return ComponentName(mPackage, mActivity)
}
diff --git a/app/src/main/java/org/omnirom/control/ApplicationManager.kt b/app/src/main/java/org/omnirom/control/ApplicationManager.kt
index b281d8a..8e13000 100644
--- a/app/src/main/java/org/omnirom/control/ApplicationManager.kt
+++ b/app/src/main/java/org/omnirom/control/ApplicationManager.kt
@@ -1,5 +1,21 @@
package org.omnirom.control
-
+/*
+ * Copyright (C) 2021 The OmniROM Project
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager
@@ -15,16 +31,10 @@
-class ApplicationManager {
-
- val mContext: Context
+class ApplicationManager(context: Context) {
+ private val mContext: Context = context
val mAppList: ArrayList<Application> = ArrayList()
- val mIconSize: Int
-
- constructor(context: Context) {
- mContext = context
- mIconSize = mContext.resources.getDimensionPixelSize(R.dimen.applist_icon_size)
- }
+ private val mIconSize: Int = mContext.resources.getDimensionPixelSize(R.dimen.applist_icon_size)
fun getAppIcon(app: Application): Drawable {
val pm: PackageManager = mContext.getPackageManager()
@@ -41,7 +51,6 @@
try {
mContext.startActivity(intent)
} catch (e: Exception) {
-
}
}
@@ -51,30 +60,17 @@
fun getAppOfPackage(packageName: String): Application? {
for (app in mAppList) {
- if (app.mPackage.equals(packageName)) return app
+ if (app.mPackage == packageName) return app
}
return null
}
- fun isAvailableApp(app: Application): Boolean {
- val pm: PackageManager = mContext.getPackageManager()
- return try {
- val enabled = pm.getApplicationEnabledSetting(app.mPackage)
- enabled != PackageManager.COMPONENT_ENABLED_STATE_DISABLED &&
- enabled != PackageManager.COMPONENT_ENABLED_STATE_DISABLED_USER
- } catch (e: PackageManager.NameNotFoundException) {
- false
- }
- }
-
- fun resizeAppIcon(image: Drawable,
- size: Int, border: Int): Drawable {
+ private fun resizeAppIcon(image: Drawable,
+ size: Int, border: Int): Drawable {
val canvas = Canvas()
- canvas.setDrawFilter(
- PaintFlagsDrawFilter(
- Paint.ANTI_ALIAS_FLAG,
- Paint.FILTER_BITMAP_FLAG
- )
+ canvas.drawFilter = PaintFlagsDrawFilter(
+ Paint.ANTI_ALIAS_FLAG,
+ Paint.FILTER_BITMAP_FLAG
)
val bmResult = Bitmap.createBitmap(
size + border, size + border,
diff --git a/app/src/main/java/org/omnirom/control/BarsSettingsFragment.kt b/app/src/main/java/org/omnirom/control/BarsSettingsFragment.kt
index c0b4c6f..dd475bb 100644
--- a/app/src/main/java/org/omnirom/control/BarsSettingsFragment.kt
+++ b/app/src/main/java/org/omnirom/control/BarsSettingsFragment.kt
@@ -1,3 +1,20 @@
+/*
+ * Copyright (C) 2021 The OmniROM Project
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
package org.omnirom.control
import android.os.Bundle
diff --git a/app/src/main/java/org/omnirom/control/ButtonSettingsFragment.kt b/app/src/main/java/org/omnirom/control/ButtonSettingsFragment.kt
new file mode 100644
index 0000000..ebb9a9e
--- /dev/null
+++ b/app/src/main/java/org/omnirom/control/ButtonSettingsFragment.kt
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2021 The OmniROM Project
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package org.omnirom.control
+
+import android.os.Bundle
+import android.provider.Settings
+import androidx.appcompat.app.AppCompatActivity
+import androidx.preference.Preference
+import androidx.preference.PreferenceFragmentCompat
+
+
+class ButtonSettingsFragment : PreferenceFragmentCompat() {
+
+ override fun onResume() {
+ super.onResume()
+ (activity as? AppCompatActivity)?.supportActionBar?.setDisplayHomeAsUpEnabled(true)
+ (activity as? SettingsActivity)?.updateFragmentTitle(resources.getString(R.string.button_settings_title))
+ }
+
+ override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
+ setPreferencesFromResource(R.xml.button_settings_preferences, rootKey)
+ }
+
+ override fun onPreferenceTreeClick(preference: Preference?): Boolean {
+ return super.onPreferenceTreeClick(preference)
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/org/omnirom/control/GridViewFragment.kt b/app/src/main/java/org/omnirom/control/GridViewFragment.kt
index e86c197..91cef18 100644
--- a/app/src/main/java/org/omnirom/control/GridViewFragment.kt
+++ b/app/src/main/java/org/omnirom/control/GridViewFragment.kt
@@ -1,6 +1,25 @@
+/*
+ * Copyright (C) 2021 The OmniROM Project
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
package org.omnirom.control
+import android.content.ComponentName
import android.content.Context
+import android.content.Intent
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
@@ -11,71 +30,100 @@
class GridViewFragment() : Fragment() {
- lateinit var gridView: GridView
- val gridItems: ArrayList<GridItem>
+ private lateinit var gridView: GridView
+ private val gridItems: ArrayList<GridItem> = ArrayList()
- init {
- this.gridItems = ArrayList<GridItem>()
- gridItems.add(
- GridItem(
- R.string.applist_settings_title,
- R.drawable.applist_icon,
- AppListFragment()
- )
- )
- gridItems.add(
- GridItem(
- R.string.bars_settings_title,
- R.drawable.ic_bars_tile,
- BarsSettingsFragment()
- )
- )
- gridItems.add(
- GridItem(
- R.string.more_settings_title,
- R.drawable.ic_settings_more,
- MoreSettingsFragment()
- )
- )
+ abstract class GridItem(title: Int, summary: Int, icon: Int) {
+ val gridTitle: Int = title
+ val gridSummary: Int = summary
+ val gridIcon: Int = icon
}
- class GridItem(text: Int, icon: Int, fragment: Fragment) {
- val gridText: Int
- val gridIcon: Int
- val gridFragment: Fragment
+ class FragmentGridItem(title: Int, summary: Int, icon: Int, fragment: Fragment) :
+ GridItem(title, summary, icon) {
+ val gridFragment: Fragment = fragment
+ }
- init {
- gridText = text
- gridIcon = icon
- gridFragment = fragment
- }
+ class IntentGridItem(title: Int, summary: Int, icon: Int, intent: Intent) :
+ GridItem(title, summary, icon) {
+ val gridIntent: Intent = intent
}
class GridViewAdapter(context: Context, gridItems: List<GridItem>) :
ArrayAdapter<GridItem>(context, 0, gridItems) {
- val vi: LayoutInflater
-
- init {
- this.vi = context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
- }
+ private val vi: LayoutInflater = context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
override fun getView(position: Int, convertView: View?, parent: ViewGroup): View {
- val viewItem: View = if (convertView == null) {
- vi.inflate(R.layout.grid_item, null)
- } else {
- convertView
- }
+ val viewItem: View = convertView ?: vi.inflate(R.layout.grid_item, null)
- val gridItem: GridItem? = getItem(position)
- viewItem.findViewById<TextView>(R.id.grid_item_text).setText(gridItem?.gridText!!)
+ val gridItem: GridItem = getItem(position)!!
+
+ viewItem.findViewById<TextView>(R.id.grid_item_title).setText(gridItem.gridTitle)
viewItem.findViewById<ImageView>(R.id.grid_item_icon)
- .setImageResource(gridItem?.gridIcon!!)
-
+ .setImageResource(gridItem.gridIcon)
+ val summary = context.resources.getString(gridItem.gridSummary)
+ if (summary.isNotEmpty())
+ viewItem.findViewById<TextView>(R.id.grid_item_summary)
+ .setText(gridItem.gridSummary)
+ else
+ viewItem.findViewById<TextView>(R.id.grid_item_summary).visibility = View.GONE
return viewItem
}
}
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+
+ gridItems.add(
+ FragmentGridItem(
+ R.string.applist_settings_title,
+ R.string.applist_settings_summary,
+ R.drawable.applist_icon,
+ AppListFragment()
+ )
+ )
+ gridItems.add(
+ FragmentGridItem(
+ R.string.bars_settings_title,
+ R.string.bars_settings_summary,
+ R.drawable.ic_bars_tile,
+ BarsSettingsFragment()
+ )
+ )
+ gridItems.add(
+ FragmentGridItem(
+ R.string.button_settings_title,
+ R.string.button_settings_summary,
+ R.drawable.ic_settings_buttons,
+ ButtonSettingsFragment()
+ )
+ )
+ if (Utils.isAvailableApp(requireContext(), "org.omnirom.omnistyle")) {
+ val wallpaperIntent = Intent()
+ wallpaperIntent.component = ComponentName(
+ "org.omnirom.omnistyle",
+ "org.omnirom.omnistyle.WallpaperActivity"
+ )
+ gridItems.add(
+ IntentGridItem(
+ R.string.wallpaper_title,
+ R.string.wallpaper_summary,
+ R.drawable.ic_wallpaper,
+ wallpaperIntent
+ )
+ )
+ }
+ gridItems.add(
+ FragmentGridItem(
+ R.string.more_settings_title,
+ R.string.more_settings_summary,
+ R.drawable.ic_settings_more,
+ MoreSettingsFragment()
+ )
+ )
+ }
+
override fun onResume() {
super.onResume()
(activity as? AppCompatActivity)?.supportActionBar?.setDisplayHomeAsUpEnabled(false)
@@ -93,17 +141,19 @@
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
gridView = view.findViewById(R.id.grid_view)
-
+ gridView.numColumns = resources.getInteger(R.integer.grid_view_columns)
gridView.adapter = GridViewAdapter(requireContext(), gridItems)
-
gridView.onItemClickListener =
- AdapterView.OnItemClickListener { parent, view, position, id ->
+ AdapterView.OnItemClickListener { _, _, position, _ ->
val gridItem: GridItem = gridItems.get(position)
- requireActivity().supportFragmentManager
- .beginTransaction()
- .replace(R.id.settings, gridItem.gridFragment)
- .addToBackStack(null)
- .commit()
+ if (gridItem is FragmentGridItem)
+ requireActivity().supportFragmentManager
+ .beginTransaction()
+ .replace(R.id.settings, gridItem.gridFragment)
+ .addToBackStack(null)
+ .commit()
+ else if (gridItem is IntentGridItem)
+ requireActivity().startActivity(gridItem.gridIntent)
}
}
diff --git a/app/src/main/java/org/omnirom/control/MoreSettingsFragment.kt b/app/src/main/java/org/omnirom/control/MoreSettingsFragment.kt
index c7dea2f..77a337c 100644
--- a/app/src/main/java/org/omnirom/control/MoreSettingsFragment.kt
+++ b/app/src/main/java/org/omnirom/control/MoreSettingsFragment.kt
@@ -1,3 +1,20 @@
+/*
+ * Copyright (C) 2021 The OmniROM Project
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
package org.omnirom.control
import android.os.Bundle
diff --git a/app/src/main/java/org/omnirom/control/SettingsActivity.kt b/app/src/main/java/org/omnirom/control/SettingsActivity.kt
index 6fa9ada..c628e9e 100644
--- a/app/src/main/java/org/omnirom/control/SettingsActivity.kt
+++ b/app/src/main/java/org/omnirom/control/SettingsActivity.kt
@@ -1,3 +1,20 @@
+/*
+ * Copyright (C) 2021 The OmniROM Project
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
package org.omnirom.control
import android.os.Bundle
@@ -5,38 +22,50 @@
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.widget.Toolbar
-import com.google.android.material.bottomnavigation.BottomNavigationView
-import org.w3c.dom.Text
+import androidx.fragment.app.Fragment
class SettingsActivity : AppCompatActivity() {
lateinit var titleView: TextView
+ private val CURRENT_FRAGMENT = "current_fragment"
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.settings_activity)
- if (savedInstanceState == null) {
- supportFragmentManager
- .beginTransaction()
- .replace(R.id.settings, GridViewFragment())
- .commit()
+
+ var fragment: Fragment = GridViewFragment()
+ if (savedInstanceState != null) {
+ val savedFragment =
+ supportFragmentManager.getFragment(savedInstanceState, CURRENT_FRAGMENT);
+ if (savedFragment != null)
+ fragment = savedFragment
}
+ supportFragmentManager.beginTransaction()
+ .replace(R.id.settings, fragment)
+ .commit()
+
val toolbar: Toolbar = findViewById(R.id.toolbar)
- toolbar.setTitle("")
+ toolbar.title = ""
setSupportActionBar(toolbar)
- titleView = findViewById<TextView>(R.id.fragment_title)
+ titleView = findViewById(R.id.fragment_title)
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
- when (item.getItemId()) {
+ when (item.itemId) {
android.R.id.home -> onBackPressed()
}
return super.onOptionsItemSelected(item)
}
fun updateFragmentTitle(title: String) {
- titleView.setText(title)
+ titleView.text = title
+ }
+
+ override fun onSaveInstanceState(outState: Bundle) {
+ super.onSaveInstanceState(outState)
+ val currentFragment = supportFragmentManager.fragments.last()
+ supportFragmentManager.putFragment(outState, CURRENT_FRAGMENT, currentFragment)
}
}
\ No newline at end of file
diff --git a/app/src/main/java/org/omnirom/control/Utils.kt b/app/src/main/java/org/omnirom/control/Utils.kt
new file mode 100644
index 0000000..bb4e9bf
--- /dev/null
+++ b/app/src/main/java/org/omnirom/control/Utils.kt
@@ -0,0 +1,17 @@
+package org.omnirom.control;
+
+import android.content.Context
+import android.content.pm.PackageManager
+
+object Utils {
+ fun isAvailableApp(context: Context, packageName: String): Boolean {
+ val pm: PackageManager = context.getPackageManager()
+ return try {
+ val enabled = pm.getApplicationEnabledSetting(packageName)
+ enabled != PackageManager.COMPONENT_ENABLED_STATE_DISABLED &&
+ enabled != PackageManager.COMPONENT_ENABLED_STATE_DISABLED_USER
+ } catch (e: PackageManager.NameNotFoundException) {
+ false
+ }
+ }
+}
diff --git a/app/src/main/res/drawable/grid_item_background_shape.xml b/app/src/main/res/drawable/grid_item_background_shape.xml
index 15d518c..5321c0e 100644
--- a/app/src/main/res/drawable/grid_item_background_shape.xml
+++ b/app/src/main/res/drawable/grid_item_background_shape.xml
@@ -17,5 +17,5 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="@dimen/grid_item_corner_radius" />
- <solid android:color="?android:colorAccent" />
+ <solid android:color="@color/colorPrimary" />
</shape>
\ No newline at end of file
diff --git a/app/src/main/res/drawable/ic_settings_buttons.xml b/app/src/main/res/drawable/ic_settings_buttons.xml
new file mode 100644
index 0000000..de85da8
--- /dev/null
+++ b/app/src/main/res/drawable/ic_settings_buttons.xml
@@ -0,0 +1,26 @@
+<!--
+ Copyright (C) 2016 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:viewportWidth="24"
+ android:tint="?android:textColorPrimary"
+
+ android:viewportHeight="24">
+ <path
+ android:fillColor="@android:color/white"
+ android:pathData="M4,5A2,2 0 0,0 2,7V17A2,2 0 0,0 4,19H20A2,2 0 0,0 22,17V7A2,2 0 0,0 20,5H4M4,7H20V17H4V7M5,8V10H7V8H5M8,8V10H10V8H8M11,8V10H13V8H11M14,8V10H16V8H14M17,8V10H19V8H17M5,11V13H7V11H5M8,11V13H10V11H8M11,11V13H13V11H11M14,11V13H16V11H14M17,11V13H19V11H17M8,14V16H16V14H8Z" />
+</vector>
diff --git a/app/src/main/res/drawable/ic_wallpaper.xml b/app/src/main/res/drawable/ic_wallpaper.xml
new file mode 100644
index 0000000..c0e41a6
--- /dev/null
+++ b/app/src/main/res/drawable/ic_wallpaper.xml
@@ -0,0 +1,10 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:tint="?android:textColorPrimary"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
+ <path
+ android:fillColor="@android:color/white"
+ android:pathData="M4,4h7L11,2L4,2c-1.1,0 -2,0.9 -2,2v7h2L4,4zM10,13l-4,5h12l-3,-4 -2.03,2.71L10,13zM17,8.5c0,-0.83 -0.67,-1.5 -1.5,-1.5S14,7.67 14,8.5s0.67,1.5 1.5,1.5S17,9.33 17,8.5zM20,2h-7v2h7v7h2L22,4c0,-1.1 -0.9,-2 -2,-2zM20,20h-7v2h7c1.1,0 2,-0.9 2,-2v-7h-2v7zM4,13L2,13v7c0,1.1 0.9,2 2,2h7v-2L4,20v-7z" />
+</vector>
diff --git a/app/src/main/res/layout/grid_fragment.xml b/app/src/main/res/layout/grid_fragment.xml
index 2555dde..a5f25e3 100644
--- a/app/src/main/res/layout/grid_fragment.xml
+++ b/app/src/main/res/layout/grid_fragment.xml
@@ -8,10 +8,9 @@
android:id="@+id/grid_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:numColumns="auto_fit"
+ android:numColumns="@integer/grid_view_columns"
android:verticalSpacing="@dimen/grip_view_spacing"
android:horizontalSpacing="@dimen/grip_view_spacing"
android:stretchMode="columnWidth"
- android:columnWidth="200dp"
android:gravity="center" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
diff --git a/app/src/main/res/layout/grid_item.xml b/app/src/main/res/layout/grid_item.xml
index ae3852d..11cfddb 100644
--- a/app/src/main/res/layout/grid_item.xml
+++ b/app/src/main/res/layout/grid_item.xml
@@ -7,7 +7,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="20dp"
- android:orientation="vertical">
+ android:orientation="horizontal">
<ImageView
android:id="@+id/grid_item_icon"
@@ -15,12 +15,31 @@
android:layout_height="48dp"
android:layout_gravity="center" />
- <TextView
- android:id="@+id/grid_item_text"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:textAlignment="center" />
+ <LinearLayout
+ android:layout_width="0dp"
+ android:layout_height="match_parent"
+ android:layout_gravity="start|center_vertical"
+ android:layout_marginStart="20dp"
+ android:layout_weight="1"
+ android:orientation="vertical">
+ <TextView
+ android:id="@+id/grid_item_title"
+ android:layout_width="match_parent"
+ android:layout_height="0dp"
+ android:text="foo"
+ android:layout_weight="1"
+ android:gravity="center_vertical"
+ android:textAppearance="@style/TextAppearance.MaterialComponents.Body1"/>
+
+ <TextView
+ android:id="@+id/grid_item_summary"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="bar"
+ android:gravity="center_vertical"
+ android:textAppearance="@style/TextAppearance.MaterialComponents.Body2"/>
+
+ </LinearLayout>
</LinearLayout>
-
</FrameLayout>
\ No newline at end of file
diff --git a/app/src/main/res/values-land/config.xml b/app/src/main/res/values-land/config.xml
new file mode 100644
index 0000000..93ab955
--- /dev/null
+++ b/app/src/main/res/values-land/config.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <integer name="grid_view_columns">2</integer>
+</resources>
\ No newline at end of file
diff --git a/app/src/main/res/values-land/dimens.xml b/app/src/main/res/values-land/dimens.xml
new file mode 100644
index 0000000..55344e5
--- /dev/null
+++ b/app/src/main/res/values-land/dimens.xml
@@ -0,0 +1,3 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+</resources>
\ No newline at end of file
diff --git a/app/src/main/res/values/config.xml b/app/src/main/res/values/config.xml
new file mode 100644
index 0000000..517aa97
--- /dev/null
+++ b/app/src/main/res/values/config.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <integer name="grid_view_columns">1</integer>
+</resources>
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 8622e01..9abf480 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -24,8 +24,11 @@
<string name="device_settings_summary">Advanced device specific settings</string>
<string name="bars_settings_title">Bars</string>
+ <string name="bars_settings_summary">Status bar options</string>
<string name="more_settings_title">More</string>
+ <string name="more_settings_summary"></string>
<string name="applist_settings_title">Applications</string>
+ <string name="applist_settings_summary">OmniROM applications</string>
<string name="navigationbar_title">Navigation bar</string>
<string name="navigation_bar_show_title">Show navigation bar</string>
@@ -35,4 +38,9 @@
<string name="status_bar_clock_seconds_title">Show clock seconds</string>
<string name="status_bar_clock_seconds_summary">Show seconds on status bar clock</string>
+ <string name="button_settings_title">Buttons</string>
+ <string name="button_settings_summary"></string>
+ <string name="global_actions_power_title">Power</string>
+ <string name="global_actions_advanced_reboot_title">Enable advanced restart</string>
+ <string name="global_actions_advanced_reboot_summary_new">Show more options in restart menu if not locked</string>
</resources>
\ No newline at end of file
diff --git a/app/src/main/res/xml/button_settings_preferences.xml b/app/src/main/res/xml/button_settings_preferences.xml
new file mode 100644
index 0000000..fd0e52d
--- /dev/null
+++ b/app/src/main/res/xml/button_settings_preferences.xml
@@ -0,0 +1,18 @@
+<PreferenceScreen
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:key="button_settings"
+ android:title="@string/button_settings_title" >
+
+ <PreferenceCategory
+ android:key="button_power"
+ android:title="@string/global_actions_power_title" >
+
+ <org.omnirom.control.preference.SystemSettingSwitchPreference
+ android:key="advanced_reboot"
+ android:title="@string/global_actions_advanced_reboot_title"
+ android:summary="@string/global_actions_advanced_reboot_summary_new"
+ android:defaultValue="false" />
+
+ </PreferenceCategory>
+
+</PreferenceScreen>
diff --git a/app/src/main/res/xml/more_settings_preferences.xml b/app/src/main/res/xml/more_settings_preferences.xml
index 7123145..0a14d53 100644
--- a/app/src/main/res/xml/more_settings_preferences.xml
+++ b/app/src/main/res/xml/more_settings_preferences.xml
@@ -4,4 +4,10 @@
<Preference
android:key="bar"
android:title="bar" />
+
+ <ListPreference
+ android:entries="@array/reply_entries"
+ android:entryValues="@array/reply_values"
+ android:key="list"
+ android:title="list" />
</PreferenceScreen>