diff --git a/app/src/main/java/com/github/droidworksstudio/launcher/accessibility/ActionService.kt b/app/src/main/java/com/github/droidworksstudio/launcher/accessibility/ActionService.kt
index 41e96df..fe974fb 100644
--- a/app/src/main/java/com/github/droidworksstudio/launcher/accessibility/ActionService.kt
+++ b/app/src/main/java/com/github/droidworksstudio/launcher/accessibility/ActionService.kt
@@ -2,6 +2,8 @@ package com.github.droidworksstudio.launcher.accessibility
import android.accessibilityservice.AccessibilityService
import android.accessibilityservice.AccessibilityServiceInfo
+import android.app.admin.DevicePolicyManager
+import android.content.ComponentName
import android.content.Context
import android.content.Intent
import android.os.Build
@@ -9,8 +11,8 @@ import android.os.Handler
import android.os.Looper
import android.provider.Settings
import android.view.accessibility.AccessibilityEvent
-import androidx.annotation.RequiresApi
import com.github.droidworksstudio.launcher.R
+import com.github.droidworksstudio.launcher.listener.DeviceAdmin
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import java.lang.ref.WeakReference
@@ -43,37 +45,57 @@ class ActionService : AccessibilityService() {
override fun onAccessibilityEvent(event: AccessibilityEvent?) {}
- @RequiresApi(Build.VERSION_CODES.P)
fun lockScreen(): Boolean {
- return performGlobalAction(GLOBAL_ACTION_LOCK_SCREEN)
+ return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
+ performGlobalAction(GLOBAL_ACTION_LOCK_SCREEN)
+ } else {
+ val devicePolicyManager =
+ this.getSystemService(DEVICE_POLICY_SERVICE) as DevicePolicyManager
+ val componentName = ComponentName(this, DeviceAdmin::class.java)
+
+ if (devicePolicyManager.isAdminActive(componentName)) {
+ devicePolicyManager.lockNow()
+ true
+ } else {
+ requestDeviceAdmin()
+ false
+ }
+ }
}
- @RequiresApi(Build.VERSION_CODES.P)
+ fun requestDeviceAdmin() {
+ val componentName = ComponentName(this, DeviceAdmin::class.java)
+ val intent = Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN)
+ intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, componentName)
+ intent.putExtra(DevicePolicyManager.EXTRA_ADD_EXPLANATION, getString(R.string.admin_permission_message))
+ this.startActivity(intent)
+ }
+
+
fun showRecents(): Boolean {
return performGlobalAction(GLOBAL_ACTION_RECENTS)
}
- @RequiresApi(Build.VERSION_CODES.P)
fun openNotifications(): Boolean {
return performGlobalAction(GLOBAL_ACTION_NOTIFICATIONS)
}
- @RequiresApi(Build.VERSION_CODES.P)
fun openQuickSettings(): Boolean {
return performGlobalAction(GLOBAL_ACTION_QUICK_SETTINGS)
}
- @RequiresApi(Build.VERSION_CODES.P)
fun openPowerDialog(): Boolean {
return performGlobalAction(GLOBAL_ACTION_POWER_DIALOG)
}
- @RequiresApi(Build.VERSION_CODES.P)
fun takeScreenShot(): Boolean {
- return performGlobalAction(GLOBAL_ACTION_TAKE_SCREENSHOT)
+ return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
+ performGlobalAction(GLOBAL_ACTION_TAKE_SCREENSHOT)
+ } else {
+ false
+ }
}
- @RequiresApi(Build.VERSION_CODES.P)
fun toggleSplitScreen(): Boolean {
return performGlobalAction(GLOBAL_ACTION_TOGGLE_SPLIT_SCREEN)
}
diff --git a/app/src/main/java/com/github/droidworksstudio/launcher/ui/home/HomeFragment.kt b/app/src/main/java/com/github/droidworksstudio/launcher/ui/home/HomeFragment.kt
index 22691d4..5e9577c 100644
--- a/app/src/main/java/com/github/droidworksstudio/launcher/ui/home/HomeFragment.kt
+++ b/app/src/main/java/com/github/droidworksstudio/launcher/ui/home/HomeFragment.kt
@@ -424,6 +424,7 @@ class HomeFragment : Fragment(),
}
Constants.Action.ShowNotification -> {
+ ActionService.runAccessibilityMode(context)
appHelper.expandNotificationDrawer(context)
}
@@ -472,6 +473,7 @@ class HomeFragment : Fragment(),
}
Constants.Action.OpenQuickSettings -> {
+ ActionService.runAccessibilityMode(context)
appHelper.expandQuickSettings(context)
}
diff --git a/app/src/main/java/com/github/droidworksstudio/launcher/ui/settings/SettingsFragment.kt b/app/src/main/java/com/github/droidworksstudio/launcher/ui/settings/SettingsFragment.kt
index 3a9391c..8e38355 100644
--- a/app/src/main/java/com/github/droidworksstudio/launcher/ui/settings/SettingsFragment.kt
+++ b/app/src/main/java/com/github/droidworksstudio/launcher/ui/settings/SettingsFragment.kt
@@ -70,6 +70,11 @@ class SettingsFragment : Fragment(),
navController.navigate(R.id.SettingsLookFeelFragment)
}
+ widgetsSettings
+ .setOnClickListener {
+ navController.navigate(R.id.SettingsWidgetFragment)
+ }
+
favoriteApps.setOnClickListener {
navController.navigate(R.id.FavoriteFragment)
}
diff --git a/app/src/main/java/com/github/droidworksstudio/launcher/ui/widgets/settings/SettingsFragment.kt b/app/src/main/java/com/github/droidworksstudio/launcher/ui/settings/SettingsWidgetFragment.kt
similarity index 98%
rename from app/src/main/java/com/github/droidworksstudio/launcher/ui/widgets/settings/SettingsFragment.kt
rename to app/src/main/java/com/github/droidworksstudio/launcher/ui/settings/SettingsWidgetFragment.kt
index 4feb218..0dbdecd 100644
--- a/app/src/main/java/com/github/droidworksstudio/launcher/ui/widgets/settings/SettingsFragment.kt
+++ b/app/src/main/java/com/github/droidworksstudio/launcher/ui/settings/SettingsWidgetFragment.kt
@@ -1,4 +1,4 @@
-package com.github.droidworksstudio.launcher.ui.widgets.settings
+package com.github.droidworksstudio.launcher.ui.settings
import android.annotation.SuppressLint
import android.content.Context
@@ -30,7 +30,7 @@ import dagger.hilt.android.AndroidEntryPoint
import javax.inject.Inject
@AndroidEntryPoint
-class SettingsFragment : Fragment(),
+class SettingsWidgetFragment : Fragment(),
ScrollEventListener {
private var _binding: FragmentSettingsWidgetsBinding? = null
diff --git a/app/src/main/java/com/github/droidworksstudio/launcher/ui/widgets/WidgetFragment.kt b/app/src/main/java/com/github/droidworksstudio/launcher/ui/widgets/WidgetFragment.kt
index 94ae65c..3312839 100644
--- a/app/src/main/java/com/github/droidworksstudio/launcher/ui/widgets/WidgetFragment.kt
+++ b/app/src/main/java/com/github/droidworksstudio/launcher/ui/widgets/WidgetFragment.kt
@@ -1,6 +1,5 @@
package com.github.droidworksstudio.launcher.ui.widgets
-import android.annotation.SuppressLint
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
@@ -12,8 +11,6 @@ import android.graphics.drawable.GradientDrawable
import android.os.BatteryManager
import android.os.Build
import android.os.Bundle
-import android.os.Handler
-import android.os.Looper
import android.util.Log
import android.view.LayoutInflater
import android.view.View
@@ -23,7 +20,6 @@ import androidx.core.content.res.ResourcesCompat
import androidx.fragment.app.Fragment
import androidx.lifecycle.lifecycleScope
import androidx.navigation.NavController
-import androidx.navigation.NavOptions
import androidx.navigation.fragment.findNavController
import com.github.droidworksstudio.common.capitalizeEachWord
import com.github.droidworksstudio.common.hasInternetPermission
@@ -33,7 +29,6 @@ import com.github.droidworksstudio.launcher.R
import com.github.droidworksstudio.launcher.databinding.FragmentWidgetsBinding
import com.github.droidworksstudio.launcher.helper.AppHelper
import com.github.droidworksstudio.launcher.helper.PreferenceHelper
-import com.github.droidworksstudio.launcher.listener.OnSwipeTouchListener
import com.github.droidworksstudio.launcher.listener.ScrollEventListener
import com.github.droidworksstudio.launcher.utils.Constants
import dagger.hilt.android.AndroidEntryPoint
@@ -86,7 +81,6 @@ class WidgetFragment : Fragment(),
orderWidgetsBySettings()
setupWeatherWidget()
setupBatteryWidget()
- observeSwipeTouchListener()
observeClickListener()
}
@@ -377,61 +371,6 @@ class WidgetFragment : Fragment(),
}
}
-
- @SuppressLint("ClickableViewAccessibility")
- private fun observeSwipeTouchListener() {
- binding.touchArea.setOnTouchListener(getSwipeGestureListener(context))
- }
-
- private fun getSwipeGestureListener(context: Context): View.OnTouchListener {
- return object : OnSwipeTouchListener(context, preferenceHelper) {
- override fun onLongClick() {
- super.onLongClick()
- val actionTypeNavOptions: NavOptions? =
- if (preferenceHelper.disableAnimations) null
- else appHelper.getActionType(Constants.Swipe.DoubleTap)
-
- Handler(Looper.getMainLooper()).post {
- findNavController().navigate(
- R.id.WidgetsSettingsFragment,
- null,
- actionTypeNavOptions
- )
- }
- }
-
- override fun onSwipeLeft() {
- super.onSwipeLeft()
- val actionTypeNavOptions: NavOptions? =
- if (preferenceHelper.disableAnimations) null
- else appHelper.getActionType(Constants.Swipe.Left)
-
- Handler(Looper.getMainLooper()).post {
- findNavController().navigate(
- R.id.HomeFragment,
- null,
- actionTypeNavOptions
- )
- }
- }
-
- override fun onSwipeRight() {
- super.onSwipeRight()
- val actionTypeNavOptions: NavOptions? =
- if (preferenceHelper.disableAnimations) null
- else appHelper.getActionType(Constants.Swipe.Right)
-
- Handler(Looper.getMainLooper()).post {
- findNavController().navigate(
- R.id.HomeFragment,
- null,
- actionTypeNavOptions
- )
- }
- }
- }
- }
-
private fun observeClickListener() {
binding.weatherRefresh.setOnClickListener {
setupWeatherWidget()
diff --git a/app/src/main/res/drawable/ic_widgets.xml b/app/src/main/res/drawable/ic_widgets.xml
new file mode 100644
index 0000000..ce04d8c
--- /dev/null
+++ b/app/src/main/res/drawable/ic_widgets.xml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/fragment_settings.xml b/app/src/main/res/layout/fragment_settings.xml
index 32e4cad..e29d05f 100644
--- a/app/src/main/res/layout/fragment_settings.xml
+++ b/app/src/main/res/layout/fragment_settings.xml
@@ -109,6 +109,41 @@
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
+ android:layout_height="match_parent">
+ android:layout_marginVertical="52dp"
+ android:gravity="center_horizontal"
+ android:orientation="vertical">
-
+
+
+ android:layout_gravity="center_horizontal"
+ android:layout_marginBottom="24dp"
+ android:text="@string/features_settings_title"
+ android:textSize="24sp"
+ android:textStyle="bold" />
+ android:text="@string/settings_title_home_behavior_preferences"
+ android:textColor="@color/icon_200"
+ android:textSize="@dimen/text_large" />
-
+ android:orientation="horizontal"
+ tools:ignore="MissingConstraints">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
+ android:text="@string/settings_title_miscellaneous"
+ android:textColor="@color/icon_200"
+ android:textSize="@dimen/text_large" />
-
+ android:layout_marginVertical="10dp"
+ android:orientation="horizontal"
+ tools:ignore="MissingConstraints">
-
+
-
+
-
+
+
+ android:layout_marginVertical="10dp"
+ android:orientation="horizontal"
+ tools:ignore="MissingConstraints">
-
+
+
+
+
+
+
+ android:layout_marginVertical="10dp"
+ android:orientation="horizontal"
+ tools:ignore="MissingConstraints">
-
+
-
+
-
+
+
+ android:layout_marginVertical="10dp"
+ android:orientation="horizontal"
+ tools:ignore="MissingConstraints">
-
+
-
+
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
diff --git a/app/src/main/res/layout/fragment_settings_look_feel.xml b/app/src/main/res/layout/fragment_settings_look_feel.xml
index fad40ea..b3f3dc6 100644
--- a/app/src/main/res/layout/fragment_settings_look_feel.xml
+++ b/app/src/main/res/layout/fragment_settings_look_feel.xml
@@ -7,449 +7,455 @@
android:layout_height="match_parent"
tools:context=".ui.settings.SettingsLookFeelFragment">
-
-
-
-
-
+ android:layout_height="match_parent">
+ android:layout_marginVertical="52dp"
+ android:gravity="center_horizontal"
+ android:orientation="vertical">
-
+
+
+ android:layout_gravity="center_horizontal"
+ android:layout_marginBottom="24dp"
+ android:text="@string/look_feel_settings_title"
+ android:textSize="24sp"
+ android:textStyle="bold" />
+ android:text="@string/settings_title_home_display_preferences"
+ android:textColor="@color/icon_200"
+ android:textSize="@dimen/text_large" />
-
+ android:orientation="horizontal"
+ tools:ignore="MissingConstraints">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+ android:text="@string/settings_title_home_appearance_preferences"
+ android:textColor="@color/icon_200"
+ android:textSize="@dimen/text_large" />
-
-
-
-
-
+ android:layout_marginVertical="10dp"
+ android:orientation="horizontal"
+ tools:ignore="MissingConstraints">
-
+
+
+
+
+ android:layout_marginVertical="10dp"
+ android:orientation="horizontal"
+ tools:ignore="MissingConstraints">
-
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ android:layout_marginVertical="10dp"
+ android:orientation="horizontal"
+ tools:ignore="MissingConstraints">
-
+
+
+
+
+
+
+ android:layout_marginVertical="10dp"
+ android:orientation="horizontal"
+ tools:ignore="MissingConstraints">
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
diff --git a/app/src/main/res/layout/fragment_settings_widgets.xml b/app/src/main/res/layout/fragment_settings_widgets.xml
index 500222e..c6c2768 100644
--- a/app/src/main/res/layout/fragment_settings_widgets.xml
+++ b/app/src/main/res/layout/fragment_settings_widgets.xml
@@ -13,28 +13,16 @@
android:layout_height="match_parent"
android:layout_marginVertical="20dp" />
-
-
-
-
+ android:layout_height="match_parent">
@@ -42,236 +30,253 @@
style="@style/TextDefaultStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_margin="20dp"
- android:text="@string/widgets_settings_show_weather"
+ android:layout_marginHorizontal="20dp"
+ android:layout_marginTop="48dp"
+ android:text="@string/settings_widgets_name"
android:textSize="@dimen/text_super_large" />
+ android:layout_margin="20dp"
+ android:text="@string/widgets_settings_show_weather"
+ android:textSize="@dimen/text_super_large" />
-
+ android:layout_marginHorizontal="20dp"
+ android:orientation="horizontal"
+ tools:ignore="MissingConstraints">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ android:layout_margin="20dp"
+ android:text="@string/widgets_settings_show_battery"
+ android:textSize="@dimen/text_super_large" />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_widgets.xml b/app/src/main/res/layout/fragment_widgets.xml
index dc30518..1b4d6c4 100644
--- a/app/src/main/res/layout/fragment_widgets.xml
+++ b/app/src/main/res/layout/fragment_widgets.xml
@@ -14,289 +14,295 @@
android:layout_height="match_parent"
android:layout_marginVertical="20dp" />
-
+ android:layout_height="match_parent">
-
+ android:layout_marginVertical="50dp"
+ android:orientation="vertical">
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ android:layout_alignParentStart="true"
+ android:orientation="horizontal">
-
-
-
-
+ android:layout_weight="3"
+ android:ellipsize="end"
+ android:gravity="start"
+ android:lines="1"
+ android:textSize="16sp"
+ tools:text="London, GB" />
+
+
+
+
+
-
+ android:layout_height="match_parent"
+ android:layout_below="@id/topHeaderWeather"
+ android:gravity="center_vertical"
+ android:orientation="horizontal"
+ android:paddingStart="8dp"
+ android:paddingLeft="8dp"
+ android:paddingEnd="8dp"
+ android:paddingRight="8dp">
-
-
-
+
+
+
+
+
+
+
+
+
+
-
+
+
-
+
+
-
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ android:visibility="gone">
-
+ android:layout_alignParentStart="true"
+ android:orientation="vertical"
+ tools:ignore="UselessParent">
-
+
-
+
-
+
-
+
-
+
-
-
-
-
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/navigation/nav_graph.xml b/app/src/main/res/navigation/nav_graph.xml
index 9a5ef3a..7d4a4a4 100644
--- a/app/src/main/res/navigation/nav_graph.xml
+++ b/app/src/main/res/navigation/nav_graph.xml
@@ -34,6 +34,12 @@
android:label="@string/settings_fragment_label"
tools:layout="@layout/fragment_settings_look_feel" />
+
+
-
-
\ 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 35eec19..afbf5b8 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -16,6 +16,9 @@
Look and Feel
Give your home screen a personal touch.
+ Widgets
+ Give your home screen some widgets.
+
Advanced
@@ -222,6 +225,8 @@
Don\'t Send
A crash has occurred in the application.\n\nBelow are the details of the device. The error log has been attached as a file for your reference. We would appreciate your assistance in resolving this issue.\n\nDevice Information: \n[PLEASE fill in the information below also removing anything between the square brackets or this will be ignored.]\n\n- App Version: [11.11.11]\n- Android Version: [Apple 1.16]\n- Device Name: [Android Apple Phone 69]\n- Install Location: [Github, Fdroid, Obtanium, Tesla Space Station]\n\nYour prompt attention to this matter is greatly appreciated.\n\nThank you.\n
+ mLauncher promises to use lock screen permission responsibly. mLauncher does not collect or share any data.
+
- Left
- Center
diff --git a/app/src/main/res/xml/accessibility_service.xml b/app/src/main/res/xml/accessibility_service.xml
index e6c106b..cbe0cb3 100644
--- a/app/src/main/res/xml/accessibility_service.xml
+++ b/app/src/main/res/xml/accessibility_service.xml
@@ -1,8 +1,9 @@
-
-
\ No newline at end of file
+
+
+
+