Miscellaneous Bug Fixes
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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
|
||||
@@ -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()
|
||||
|
||||
27
app/src/main/res/drawable/ic_widgets.xml
Normal file
27
app/src/main/res/drawable/ic_widgets.xml
Normal file
@@ -0,0 +1,27 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M2.5,13V17.5C2.5,19.386 2.5,20.328 3.086,20.914C3.672,21.5 4.614,21.5 6.5,21.5C8.386,21.5 9.328,21.5 9.914,20.914C10.5,20.328 10.5,19.386 10.5,17.5V6.5C10.5,4.614 10.5,3.672 9.914,3.086C9.328,2.5 8.386,2.5 6.5,2.5C4.614,2.5 3.672,2.5 3.086,3.086C2.5,3.672 2.5,4.614 2.5,6.5V9"
|
||||
android:strokeWidth="1.5"
|
||||
android:strokeColor="#FFFFFFFF"
|
||||
android:strokeLineCap="round" />
|
||||
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M21.5,18C21.495,19.557 21.446,20.383 20.914,20.914C20.328,21.5 19.386,21.5 17.5,21.5C15.614,21.5 14.672,21.5 14.086,20.914C13.5,20.328 13.5,19.386 13.5,17.5V15.5C13.5,13.614 13.5,12.672 14.086,12.086C14.672,11.5 15.614,11.5 17.5,11.5C19.386,11.5 20.328,11.5 20.914,12.086C21.318,12.49 21.444,13.064 21.483,14"
|
||||
android:strokeWidth="1.5"
|
||||
android:strokeColor="#FFFFFFFF"
|
||||
android:strokeLineCap="round" />
|
||||
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M13.5,5.5C13.5,4.568 13.5,4.102 13.652,3.735C13.855,3.245 14.245,2.855 14.735,2.652C15.102,2.5 15.568,2.5 16.5,2.5H18.5C19.432,2.5 19.898,2.5 20.265,2.652C20.755,2.855 21.145,3.245 21.348,3.735C21.5,4.102 21.5,4.568 21.5,5.5C21.5,6.432 21.5,6.898 21.348,7.265C21.145,7.755 20.755,8.145 20.265,8.348C19.898,8.5 19.432,8.5 18.5,8.5H16.5C15.568,8.5 15.102,8.5 14.735,8.348C14.245,8.145 13.855,7.755 13.652,7.265C13.5,6.898 13.5,6.432 13.5,5.5Z"
|
||||
android:strokeWidth="1.5"
|
||||
android:strokeColor="#FFFFFFFF" />
|
||||
|
||||
</vector>
|
||||
@@ -109,6 +109,41 @@
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/widgetsSettings"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
android:paddingVertical="16dp">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:contentDescription="@string/settings_widgets_title"
|
||||
android:src="@drawable/ic_widgets"
|
||||
app:tint="?attr/colorPrimary" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/settings_widgets_title"
|
||||
android:textSize="18sp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/settings_widgets_description"
|
||||
android:textSize="14sp" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/favoriteApps"
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@@ -7,6 +7,11 @@
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".ui.settings.SettingsFeaturesFragment">
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:id="@+id/nestedScrollView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
@@ -558,4 +563,5 @@
|
||||
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
</FrameLayout>
|
||||
|
||||
@@ -7,6 +7,11 @@
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".ui.settings.SettingsLookFeelFragment">
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:id="@+id/nestedScrollView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
@@ -452,4 +457,5 @@
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
</FrameLayout>
|
||||
|
||||
@@ -13,6 +13,10 @@
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginVertical="20dp" />
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:id="@+id/nestedScrollView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:layout_width="match_parent"
|
||||
@@ -274,4 +278,5 @@
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
</FrameLayout>
|
||||
@@ -14,6 +14,11 @@
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginVertical="20dp" />
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:id="@+id/nestedScrollView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:id="@+id/linearLayoutContainer"
|
||||
android:layout_width="match_parent"
|
||||
@@ -299,4 +304,5 @@
|
||||
</LinearLayout>
|
||||
</RelativeLayout>
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
</FrameLayout>
|
||||
@@ -34,6 +34,12 @@
|
||||
android:label="@string/settings_fragment_label"
|
||||
tools:layout="@layout/fragment_settings_look_feel" />
|
||||
|
||||
<fragment
|
||||
android:id="@+id/SettingsWidgetFragment"
|
||||
android:name="com.github.droidworksstudio.launcher.ui.settings.SettingsWidgetFragment"
|
||||
android:label="@string/widgets_fragment_label"
|
||||
tools:layout="@layout/fragment_settings_widgets" />
|
||||
|
||||
<fragment
|
||||
android:id="@+id/DrawFragment"
|
||||
android:name="com.github.droidworksstudio.launcher.ui.drawer.DrawFragment"
|
||||
@@ -58,10 +64,4 @@
|
||||
android:label="@string/hidden_fragment_label"
|
||||
tools:layout="@layout/fragment_hidden" />
|
||||
|
||||
<fragment
|
||||
android:id="@+id/WidgetsSettingsFragment"
|
||||
android:name="com.github.droidworksstudio.launcher.ui.widgets.settings.SettingsFragment"
|
||||
android:label="@string/widgets_fragment_label"
|
||||
tools:layout="@layout/fragment_settings_widgets" />
|
||||
|
||||
</navigation>
|
||||
@@ -16,6 +16,9 @@
|
||||
<string name="settings_look_feel_title">Look and Feel</string>
|
||||
<string name="settings_look_feel_description">Give your home screen a personal touch.</string>
|
||||
|
||||
<string name="settings_widgets_title">Widgets</string>
|
||||
<string name="settings_widgets_description">Give your home screen some widgets.</string>
|
||||
|
||||
<string name="settings_advanced_title">Advanced</string>
|
||||
|
||||
<!-- Strings used for look And feel settings -->
|
||||
@@ -222,6 +225,8 @@
|
||||
<string name="acra_dont_send">Don\'t Send</string>
|
||||
<string name="acra_mail_body">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</string>
|
||||
|
||||
<string name="admin_permission_message">mLauncher promises to use lock screen permission responsibly. mLauncher does not collect or share any data.</string>
|
||||
|
||||
<string-array name="alignment_options">
|
||||
<item>Left</item>
|
||||
<item>Center</item>
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<accessibility-service xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:accessibilityEventTypes="typeViewClicked"
|
||||
android:accessibilityFeedbackType="feedbackVisual"
|
||||
android:accessibilityFeedbackType="feedbackAllMask"
|
||||
android:accessibilityFlags="flagDefault"
|
||||
android:canPerformGestures="true"
|
||||
android:canRetrieveWindowContent="true"
|
||||
android:description="@string/accessibility_service_desc"
|
||||
android:notificationTimeout="10"
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<device-admin>
|
||||
<uses-policies><force-lock /></uses-policies>
|
||||
<uses-policies>
|
||||
<force-lock />
|
||||
</uses-policies>
|
||||
</device-admin>
|
||||
Reference in New Issue
Block a user