diff --git a/app/src/main/java/eu/ottop/yamlauncher/Animations.kt b/app/src/main/java/eu/ottop/yamlauncher/Animations.kt index 05e8d03..2b42064 100644 --- a/app/src/main/java/eu/ottop/yamlauncher/Animations.kt +++ b/app/src/main/java/eu/ottop/yamlauncher/Animations.kt @@ -95,7 +95,7 @@ class Animations () { .setDuration(duration) .setListener(object : AnimatorListenerAdapter() { override fun onAnimationEnd(animation: Animator) { - visibility = View.GONE + visibility = View.INVISIBLE } }) } diff --git a/app/src/main/java/eu/ottop/yamlauncher/AppMenuAdapter.kt b/app/src/main/java/eu/ottop/yamlauncher/AppMenuAdapter.kt index 2843035..3bc6be3 100644 --- a/app/src/main/java/eu/ottop/yamlauncher/AppMenuAdapter.kt +++ b/app/src/main/java/eu/ottop/yamlauncher/AppMenuAdapter.kt @@ -31,7 +31,6 @@ class AppMenuAdapter( ) : RecyclerView.Adapter() { - var menuMode: String = "app" var shortcutTextView: TextView? = null private val sharedPreferenceManager = SharedPreferenceManager() @@ -71,15 +70,15 @@ class AppMenuAdapter( textView.setOnClickListener { val position = bindingAdapterPosition val app = apps[position].first - if (menuMode == "shortcut") { + if (shortcutTextView != null) { shortcutListener.onShortcut(app, apps[position].second.first, textView, apps[position].second.second, shortcutTextView!!) } - else if (menuMode == "app") { + else { itemClickListener.onItemClick(app, apps[position].second.first) } } - if (menuMode == "app") { + if (shortcutTextView == null) { textView.setOnLongClickListener { val position = bindingAdapterPosition diff --git a/app/src/main/java/eu/ottop/yamlauncher/GestureAppsAdapter.kt b/app/src/main/java/eu/ottop/yamlauncher/GestureAppsAdapter.kt new file mode 100644 index 0000000..160ff0a --- /dev/null +++ b/app/src/main/java/eu/ottop/yamlauncher/GestureAppsAdapter.kt @@ -0,0 +1,119 @@ +package eu.ottop.yamlauncher + +import android.annotation.SuppressLint +import android.content.Context +import android.content.pm.ApplicationInfo +import android.content.pm.LauncherActivityInfo +import android.os.UserHandle +import android.view.Gravity +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.EditText +import android.widget.FrameLayout +import android.widget.LinearLayout +import android.widget.TextView +import androidx.core.content.res.ResourcesCompat +import androidx.preference.PreferenceManager +import androidx.recyclerview.widget.RecyclerView +import kotlin.time.Duration.Companion.seconds + +class GestureAppsAdapter( + private val activity: Context, + var apps: MutableList>>, + private val itemClickListener: OnItemClickListener +) : + RecyclerView.Adapter() { + + private val sharedPreferenceManager = SharedPreferenceManager() + private var preferences = PreferenceManager.getDefaultSharedPreferences(activity) + + interface OnItemClickListener { + fun onItemClick(appInfo: LauncherActivityInfo, profile: Int) + } + + inner class AppViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { + private val listItem: FrameLayout = itemView.findViewById(R.id.list_item) + val textView: TextView = listItem.findViewById(R.id.app_name) + private val actionMenuLayout: LinearLayout = listItem.findViewById(R.id.action_menu) + private val editView: LinearLayout = listItem.findViewById(R.id.rename_view) + val editText: EditText = editView.findViewById(R.id.app_name_edit) + + init { + actionMenuLayout.visibility = View.INVISIBLE + editView.visibility = View.INVISIBLE + + textView.setOnClickListener { + val position = bindingAdapterPosition + val app = apps[position].first + itemClickListener.onItemClick(app, apps[position].second.second) + + } + } + } + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): AppViewHolder { + val view = LayoutInflater.from(parent.context) + .inflate(R.layout.app_item_layout, parent, false) + return AppViewHolder(view) + } + + override fun onBindViewHolder(holder: AppViewHolder, position: Int) { + val app = apps[position] + + if (app.second.second != 0) { + holder.textView.setCompoundDrawablesWithIntrinsicBounds(ResourcesCompat.getDrawable(activity.resources, R.drawable.ic_work_app, null),null,null,null) + } + else { + holder.textView.setCompoundDrawablesWithIntrinsicBounds(ResourcesCompat.getDrawable(activity.resources, R.drawable.ic_empty, null),null,null,null) + } + + when (preferences.getString("appMenuAlignment", "left")) { + "left" -> { + holder.textView.setCompoundDrawablesWithIntrinsicBounds(holder.textView.compoundDrawables.filterNotNull().first(),null, null, null) + holder.textView.gravity = Gravity.CENTER_VERTICAL or Gravity.START + } + "center" -> { + holder.textView.setCompoundDrawablesWithIntrinsicBounds(holder.textView.compoundDrawables.filterNotNull().first(),null,holder.textView.compoundDrawables.filterNotNull().first(), null) + holder.textView.gravity = Gravity.CENTER + + } + "right" -> { + holder.textView.setCompoundDrawablesWithIntrinsicBounds(null,null, holder.textView.compoundDrawables.filterNotNull().first(), null) + holder.textView.gravity = Gravity.CENTER_VERTICAL or Gravity.END + } + } + + when (preferences.getString("appMenuSize", "medium")) { + "small" -> { + holder.textView.textSize = 24F + holder.editText.textSize = 24F + } + + "medium" -> { + holder.textView.textSize = 26F + holder.editText.textSize = 26F + } + + "large" -> { + holder.textView.textSize = 28F + holder.editText.textSize = 28F + } + } + + val appInfo = app.first.activityInfo.applicationInfo + holder.textView.text = sharedPreferenceManager.getAppName(activity, app.first.applicationInfo.packageName,app.second.second, holder.itemView.context.packageManager.getApplicationLabel(appInfo)) + + holder.textView.visibility = View.VISIBLE + } + + override fun getItemCount(): Int { + return apps.size + } + + @SuppressLint("NotifyDataSetChanged") + fun updateApps(newApps: List>>) { + apps = newApps.toMutableList() + notifyDataSetChanged() + } +} \ No newline at end of file diff --git a/app/src/main/java/eu/ottop/yamlauncher/GestureAppsFragment.kt b/app/src/main/java/eu/ottop/yamlauncher/GestureAppsFragment.kt new file mode 100644 index 0000000..439992e --- /dev/null +++ b/app/src/main/java/eu/ottop/yamlauncher/GestureAppsFragment.kt @@ -0,0 +1,152 @@ +package eu.ottop.yamlauncher + +import android.app.Activity +import android.app.AlertDialog +import android.content.pm.LauncherActivityInfo +import android.os.Bundle +import android.os.UserHandle +import android.text.Editable +import android.text.TextWatcher +import androidx.fragment.app.Fragment +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.EditText +import android.widget.Toast +import androidx.fragment.app.setFragmentResult +import androidx.preference.Preference +import androidx.recyclerview.widget.RecyclerView +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.launch +import kotlinx.coroutines.withContext + +class GestureAppsFragment : Fragment(), GestureAppsAdapter.OnItemClickListener { + + private var adapter: GestureAppsAdapter? = null + private val sharedPreferenceManager = SharedPreferenceManager() + private var stringUtils = StringUtils() + private val appUtils = AppUtils() + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, + savedInstanceState: Bundle? + ): View? { + // Inflate the layout for this fragment + return inflater.inflate(R.layout.fragment_gesture_apps, container, false) + } + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + + CoroutineScope(Dispatchers.Main).launch { + + withContext(Dispatchers.Default) { + + adapter = GestureAppsAdapter( + requireContext(), + appUtils.getInstalledApps(activity as Activity).toMutableList(), + this@GestureAppsFragment + ) + } + val recyclerView = view.findViewById(R.id.gesture_app_recycler) + val appMenuEdgeFactory = AppMenuEdgeFactory(requireActivity()) + + recyclerView.edgeEffectFactory = appMenuEdgeFactory + recyclerView.adapter = adapter + + recyclerView.scrollToPosition(0) + + val searchView = view.findViewById(R.id.gestureAppSearch) + + recyclerView.addOnLayoutChangeListener { _, _, top, _, bottom, _, oldTop, _, oldBottom -> + + if (bottom - top > oldBottom - oldTop) { + searchView.clearFocus() + } + } + + searchView.addTextChangedListener(object : + TextWatcher { + override fun beforeTextChanged( + s: CharSequence?, + start: Int, + count: Int, + after: Int + ) { + } + + override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) { + + } + + override fun afterTextChanged(s: Editable?) { + + filterItems(searchView.text.toString()) + + } + }) + } + } + + private fun filterItems(query: String?) { + + val cleanQuery = stringUtils.cleanString(query) + val newFilteredApps = mutableListOf>>() + val updatedApps = appUtils.getInstalledApps(requireActivity()) + + getFilteredApps(cleanQuery, newFilteredApps, updatedApps) + + applySearch(newFilteredApps) + + } + + private fun getFilteredApps(cleanQuery: String?, newFilteredApps: MutableList>>, updatedApps: List>>) { + if (cleanQuery.isNullOrEmpty()) { + newFilteredApps.addAll(updatedApps) + } else { + updatedApps.forEach { + val cleanItemText = stringUtils.cleanString(sharedPreferenceManager.getAppName(requireActivity(), it.first.applicationInfo.packageName, it.second.second, requireActivity().packageManager.getApplicationLabel(it.first.applicationInfo)).toString()) + if (cleanItemText != null) { + if (cleanItemText.contains(cleanQuery, ignoreCase = true)) { + newFilteredApps.add(it) + } + } + } + } + } + + private fun applySearch(newFilteredApps: MutableList>>) { + adapter?.updateApps(newFilteredApps) + } + + private fun showConfirmationDialog(appInfo: LauncherActivityInfo, appName: String, profile: Int) { + AlertDialog.Builder(requireContext()).apply { + setTitle("Confirmation") + setMessage("Are you sure you want to set $appName? as the gesture app") + setPositiveButton("Yes") { _, _ -> + // Perform action on confirmation + performConfirmedAction(appInfo, appName, profile) + } + + setNegativeButton("Cancel") { _, _ -> + } + + }.create().show() + } + + private fun performConfirmedAction(appInfo: LauncherActivityInfo, appName: String, profile: Int) { + val result = Bundle().apply { + putString("gesture_app", "$appName-${appInfo.applicationInfo.packageName}-$profile") + } + setFragmentResult("request_key", result) + requireActivity().supportFragmentManager.popBackStack() + } + + + override fun onItemClick(appInfo: LauncherActivityInfo, profile: Int) { + showConfirmationDialog(appInfo, sharedPreferenceManager.getAppName(requireContext(), appInfo.applicationInfo.packageName,profile, requireContext().packageManager.getApplicationLabel(appInfo.applicationInfo)).toString(), profile) + } + + +} \ No newline at end of file diff --git a/app/src/main/java/eu/ottop/yamlauncher/HiddenAppsFragment.kt b/app/src/main/java/eu/ottop/yamlauncher/HiddenAppsFragment.kt index f458fa0..9bb44a7 100644 --- a/app/src/main/java/eu/ottop/yamlauncher/HiddenAppsFragment.kt +++ b/app/src/main/java/eu/ottop/yamlauncher/HiddenAppsFragment.kt @@ -14,34 +14,12 @@ import android.view.ViewGroup import android.widget.EditText import androidx.recyclerview.widget.RecyclerView -// TODO: Rename parameter arguments, choose names that match -// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER -private const val ARG_PARAM1 = "param1" -private const val ARG_PARAM2 = "param2" - -/** - * A simple [Fragment] subclass. - * Use the [HiddenAppsFragment.newInstance] factory method to - * create an instance of this fragment. - */ class HiddenAppsFragment : Fragment(), HiddenAppsAdapter.OnItemClickListener { - // TODO: Rename and change types of parameters - private var param1: String? = null - private var param2: String? = null private val appUtils = AppUtils() private val sharedPreferenceManager = SharedPreferenceManager() private var adapter: HiddenAppsAdapter? = null private var stringUtils = StringUtils() - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - arguments?.let { - param1 = it.getString(ARG_PARAM1) - param2 = it.getString(ARG_PARAM2) - } - - } - override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? @@ -127,14 +105,6 @@ class HiddenAppsFragment : Fragment(), HiddenAppsAdapter.OnItemClickListener { // Perform action on confirmation performConfirmedAction(appInfo, appName, profile) } - setNegativeButton("Cancel") { _, _ -> - // Handle cancellation - handleCancellation() - } - setOnCancelListener { - // Handle dialog cancel - handleCancellation() - } }.create().show() } @@ -147,30 +117,8 @@ class HiddenAppsFragment : Fragment(), HiddenAppsAdapter.OnItemClickListener { // Handle the cancellation of the dialog } - companion object { - /** - * Use this factory method to create a new instance of - * this fragment using the provided parameters. - * - * @param param1 Parameter 1. - * @param param2 Parameter 2. - * @return A new instance of fragment HiddenAppsFragment. - */ - // TODO: Rename and change types and number of parameters - @JvmStatic - fun newInstance(param1: String, param2: String) = - HiddenAppsFragment().apply { - arguments = Bundle().apply { - putString(ARG_PARAM1, param1) - putString(ARG_PARAM2, param2) - } - } - } - override fun onItemClick(appInfo: LauncherActivityInfo, profile: Int) { showConfirmationDialog(appInfo, sharedPreferenceManager.getAppName(requireContext(), appInfo.applicationInfo.packageName,profile, requireContext().packageManager.getApplicationLabel(appInfo.applicationInfo)).toString(), profile) } - - } \ No newline at end of file diff --git a/app/src/main/java/eu/ottop/yamlauncher/LocationFragment.kt b/app/src/main/java/eu/ottop/yamlauncher/LocationFragment.kt index 71886b5..2b92fa1 100644 --- a/app/src/main/java/eu/ottop/yamlauncher/LocationFragment.kt +++ b/app/src/main/java/eu/ottop/yamlauncher/LocationFragment.kt @@ -16,6 +16,7 @@ import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import kotlinx.coroutines.withContext + class LocationFragment : Fragment(), LocationListAdapter.OnItemClickListener { private var adapter: LocationListAdapter? = null diff --git a/app/src/main/java/eu/ottop/yamlauncher/MainActivity.kt b/app/src/main/java/eu/ottop/yamlauncher/MainActivity.kt index 22f1bd1..8b4ab52 100644 --- a/app/src/main/java/eu/ottop/yamlauncher/MainActivity.kt +++ b/app/src/main/java/eu/ottop/yamlauncher/MainActivity.kt @@ -69,8 +69,6 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh private var adapter: AppMenuAdapter? = null private var job: Job? = null private var weatherJob: Job? = null - val cameraIntent = Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA_SECURE) - val phoneIntent = Intent(Intent.ACTION_DIAL) private var batteryReceiver: BatteryReceiver? = null private var appActionMenu = AppActionMenu() @@ -100,6 +98,9 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh private var isBatteryReceiverRegistered = false + private lateinit var leftSwipeActivity: Pair + private lateinit var rightSwipeActivity: Pair + @SuppressLint("ClickableViewAccessibility") override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -119,6 +120,9 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh launcherApps = getSystemService(Context.LAUNCHER_APPS_SERVICE) as LauncherApps + leftSwipeActivity = getSwipeInfo("left") + rightSwipeActivity = getSwipeInfo("right") + gestureDetector = GestureDetector(this, GestureListener()) shortcutGestureDetector = GestureDetector(this, TextGestureListener()) @@ -257,6 +261,14 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh modifyDate("", 3) } } + + "leftSwipeApp" -> { + leftSwipeActivity = getSwipeInfo("left") + } + + "rightSwipeApp" -> { + rightSwipeActivity = getSwipeInfo("right") + } } } @@ -328,8 +340,6 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh @SuppressLint("NotifyDataSetChanged") override fun onResume() { super.onResume() - binding.homeView.visibility = View.VISIBLE - binding.appView.visibility = View.INVISIBLE adapter?.notifyDataSetChanged() } @@ -361,13 +371,23 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh } // Detect swipe left - else if (deltaX < -swipeThreshold && abs(velocityX) > swipeVelocityThreshold && preferences.getBoolean("cameraSwipe", true)){ - startActivity(cameraIntent) + else if (deltaX < -swipeThreshold && abs(velocityX) > swipeVelocityThreshold && preferences.getBoolean("leftSwipe", true)){ + + if (leftSwipeActivity.first != null && leftSwipeActivity.second != null) { + launcherApps.startMainActivity(leftSwipeActivity.first!!.componentName, launcherApps.profiles[leftSwipeActivity.second!!], null, null) + } else { + Toast.makeText(this@MainActivity, "Cannot launch app", Toast.LENGTH_SHORT).show() + } } + // Detect swipe right - else if (deltaX > -swipeThreshold && abs(velocityX) > swipeVelocityThreshold && preferences.getBoolean("phoneSwipe", true)) { - startActivity(phoneIntent) + else if (deltaX > -swipeThreshold && abs(velocityX) > swipeVelocityThreshold && preferences.getBoolean("rightSwipe", true)) { + if (rightSwipeActivity.first != null && rightSwipeActivity.second != null) { + launcherApps.startMainActivity(rightSwipeActivity.first!!.componentName, launcherApps.profiles[rightSwipeActivity.second!!], null, null) + } else { + Toast.makeText(this@MainActivity, "Cannot launch app", Toast.LENGTH_SHORT).show() + } } } return true @@ -386,6 +406,22 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh } } + private fun getSwipeInfo(direction: String): Pair { + val app = preferences.getString("${direction}SwipeApp", "")?.split("-") + + if (app != null) { + if (app.size >= 3) + + return Pair( + launcherApps.getActivityList( + app?.get(1), launcherApps.profiles[app.get(2)!! + .toInt()] + ).firstOrNull(), app[2].toInt() + ) + } + return Pair(null, null) + } + private fun setupApps() { handleListItems() CoroutineScope(Dispatchers.Default).launch { @@ -444,7 +480,6 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh Toast.makeText(this, "Long click to select an app", Toast.LENGTH_SHORT).show() } textView.setOnLongClickListener { - adapter?.menuMode = "shortcut" adapter?.shortcutTextView = textView toAppMenu() @@ -569,7 +604,7 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh } fun openAppMenuActivity() { - adapter?.menuMode = "app" + adapter?.shortcutTextView = null binding.menutitle.visibility = View.GONE toAppMenu() } diff --git a/app/src/main/java/eu/ottop/yamlauncher/SettingsFragment.kt b/app/src/main/java/eu/ottop/yamlauncher/SettingsFragment.kt index 93c0e37..4e1f3cd 100644 --- a/app/src/main/java/eu/ottop/yamlauncher/SettingsFragment.kt +++ b/app/src/main/java/eu/ottop/yamlauncher/SettingsFragment.kt @@ -1,9 +1,11 @@ package eu.ottop.yamlauncher import android.os.Bundle +import androidx.fragment.app.clearFragmentResultListener import androidx.fragment.app.setFragmentResultListener import androidx.preference.Preference import androidx.preference.PreferenceFragmentCompat +import androidx.preference.PreferenceManager import androidx.preference.SwitchPreference class SettingsFragment : PreferenceFragmentCompat() { @@ -18,8 +20,12 @@ class SettingsFragment : PreferenceFragmentCompat() { val gpsLocationPref: SwitchPreference? = findPreference("gps_location") manualLocationPref = findPreference("manual_location") + val leftSwipePref = findPreference("leftSwipeApp") + val rightSwipePref = findPreference("rightSwipeApp") manualLocationPref?.summary = sharedPreferenceManager.getWeatherRegion(requireContext()) + leftSwipePref?.summary = sharedPreferenceManager.getGestureName(requireContext(), "left") + rightSwipePref?.summary = sharedPreferenceManager.getGestureName(requireContext(), "right") if (gpsLocationPref != null && manualLocationPref != null) { // Initial setup @@ -55,10 +61,65 @@ class SettingsFragment : PreferenceFragmentCompat() { .addToBackStack(null) .commit() true } + + leftSwipePref?.onPreferenceClickListener = + Preference.OnPreferenceClickListener { + requireActivity().supportFragmentManager + .beginTransaction() + .replace(R.id.settings_layout, GestureAppsFragment()) + .addToBackStack(null) + .commit() + setFragmentResultListener("request_key") { requestKey, bundle -> + clearFragmentResultListener("request_key") + val result = bundle.getString("gesture_app") + val appDetails = result?.split("-") + if (leftSwipePref != null && result != null) { + setPreference("leftSwipeApp", result) + } + sharedPreferenceManager.setGestures(requireContext(), "left", + appDetails?.get(0), appDetails?.get(1), appDetails?.get(2) + ) + val appName = appDetails?.get(0) + leftSwipePref?.summary = appName + } + true } + + rightSwipePref?.onPreferenceClickListener = + Preference.OnPreferenceClickListener { + requireActivity().supportFragmentManager + .beginTransaction() + .replace(R.id.settings_layout, GestureAppsFragment()) + .addToBackStack(null) + .commit() + setFragmentResultListener("request_key") { requestKey, bundle -> + clearFragmentResultListener("request_key") + val result = bundle.getString("gesture_app") + val appDetails = result?.split("-") + if (rightSwipePref != null && result != null) { + setPreference("rightSwipeApp", result) + } + sharedPreferenceManager.setGestures(requireContext(), "right", + appDetails?.get(0), appDetails?.get(1), appDetails?.get(2) + ) + val appName = appDetails?.get(0) + rightSwipePref?.summary = appName + } + true } } override fun onResume() { super.onResume() manualLocationPref?.summary = sharedPreferenceManager.getWeatherRegion(requireContext()) } + + private fun setPreference(key: String, value: String) { + // Get the SharedPreferences instance + val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(requireContext()) + + // Edit the SharedPreferences to update the value + with(sharedPreferences.edit()) { + putString(key, value) + apply() + } + } } \ No newline at end of file diff --git a/app/src/main/java/eu/ottop/yamlauncher/SharedPreferenceManager.kt b/app/src/main/java/eu/ottop/yamlauncher/SharedPreferenceManager.kt index e2a673b..12c9e69 100644 --- a/app/src/main/java/eu/ottop/yamlauncher/SharedPreferenceManager.kt +++ b/app/src/main/java/eu/ottop/yamlauncher/SharedPreferenceManager.kt @@ -81,4 +81,24 @@ class SharedPreferenceManager { return sharedPreferences.getString(key, "") } + fun setGestures(cont: Context, direction: String, appName: String?, packageName: String?, profile: String?) { + val editor = cont.getSharedPreferences("gestures", AppCompatActivity.MODE_PRIVATE).edit() + val nameKey = "$direction-name" + editor.putString(direction, "$packageName-$profile") + editor.putString(nameKey, appName) + editor.apply() + } + + + fun getGestureApp(cont: Context, direction: String) : String? { + val sharedPreferences = cont.getSharedPreferences("gestures", AppCompatActivity.MODE_PRIVATE) + return sharedPreferences.getString(direction, "") + } + + fun getGestureName(cont: Context, direction: String) : String? { + val sharedPreferences = cont.getSharedPreferences("gestures", AppCompatActivity.MODE_PRIVATE) + val key = "$direction-name" + return sharedPreferences.getString(key, "") + } + } \ No newline at end of file diff --git a/app/src/main/java/eu/ottop/yamlauncher/WeatherSystem.kt b/app/src/main/java/eu/ottop/yamlauncher/WeatherSystem.kt index e560a95..2aa21bd 100644 --- a/app/src/main/java/eu/ottop/yamlauncher/WeatherSystem.kt +++ b/app/src/main/java/eu/ottop/yamlauncher/WeatherSystem.kt @@ -31,9 +31,6 @@ class WeatherSystem { locationManager.removeUpdates(this) } - override fun onFlushComplete(requestCode: Int) { - super.onFlushComplete(requestCode) - } } if (ContextCompat.checkSelfPermission(activity, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { @@ -99,6 +96,7 @@ class WeatherSystem { var currentWeather = "" val location = sharedPreferenceManager.getWeatherLocation(context) + if (location != null) { if (location.isNotEmpty()) { val url = URL("https://api.open-meteo.com/v1/forecast?$location&temperature_unit=${tempUnits}¤t=temperature_2m,weather_code") diff --git a/app/src/main/res/layout/fragment_gesture_apps.xml b/app/src/main/res/layout/fragment_gesture_apps.xml new file mode 100644 index 0000000..5f31259 --- /dev/null +++ b/app/src/main/res/layout/fragment_gesture_apps.xml @@ -0,0 +1,65 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/xml/root_preferences.xml b/app/src/main/res/xml/root_preferences.xml index 53b1dd8..fe28ef3 100644 --- a/app/src/main/res/xml/root_preferences.xml +++ b/app/src/main/res/xml/root_preferences.xml @@ -124,14 +124,28 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:defaultValue="true" - android:title="Camera Swipe Left" - app:key="cameraSwipe" /> + android:title="Swipe Left" + app:key="leftSwipe" /> + + android:title="Swipe Right" + app:key="rightSwipe" /> + - - - + + + \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index a6711ae..616efbf 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,5 +1,5 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. plugins { - id("com.android.application") version "8.2.1" apply false + id("com.android.application") version "8.5.1" apply false id("org.jetbrains.kotlin.android") version "1.9.22" apply false } \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 8b9a72e..386dc13 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Sat May 04 00:30:09 EEST 2024 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists +zipStorePath=wrapper/dists \ No newline at end of file