sduduzog пре 7 година
родитељ
комит
f62377975d

+ 2 - 2
app/build.gradle

@@ -12,8 +12,8 @@ android {
         applicationId "com.sduduzog.slimlauncher"
         minSdkVersion 16
         targetSdkVersion 28
-        versionCode 25
-        versionName "2.2.3"
+        versionCode 26
+        versionName "2.2.4"
         testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
         vectorDrawables.useSupportLibrary = true
     }

+ 0 - 1
app/src/main/AndroidManifest.xml

@@ -4,7 +4,6 @@
     package="com.sduduzog.slimlauncher">
 
     <uses-permission android:name="com.android.alarm.permission.SET_ALARM" />
-    <uses-permission android:name="android.permission.CALL_PHONE" />
 
     <application
         android:allowBackup="false"

+ 15 - 48
app/src/main/java/com/sduduzog/slimlauncher/ui/main/MainFragment.kt

@@ -96,17 +96,19 @@ class MainFragment : StatusBarThemeFragment(), MainActivity.OnBackPressedListene
         mainAppsList.setOnTouchListener(homeClickListener)
 
         clockTextView.setOnClickListener {
-            try {
-                val intent = alternativeClockIntent()
-                intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
-                val left = 0
-                val top = 0
-                val width = it.measuredWidth
-                val height = it.measuredHeight
-                val opts = ActivityOptionsCompat.makeClipRevealAnimation(it, left, top, width, height)
-                startActivity(intent, opts.toBundle())
-            } finally {
-                // Do nothing
+            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
+                try {
+                    val intent = Intent(AlarmClock.ACTION_SHOW_ALARMS)
+                    intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
+                    val left = 0
+                    val top = 0
+                    val width = it.measuredWidth
+                    val height = it.measuredHeight
+                    val opts = ActivityOptionsCompat.makeClipRevealAnimation(it, left, top, width, height)
+                    startActivity(intent, opts.toBundle())
+                } catch (e: ActivityNotFoundException) {
+                    // Do nothing, we've failed :(
+                }
             }
         }
 
@@ -121,8 +123,8 @@ class MainFragment : StatusBarThemeFragment(), MainActivity.OnBackPressedListene
                 val height = it.measuredHeight
                 val opts = ActivityOptionsCompat.makeClipRevealAnimation(it, left, top, width, height)
                 startActivity(intent, opts.toBundle())
-            } finally {
-                // Do nothing
+            } catch (e: ActivityNotFoundException) {
+                // Do nothing, we've failed :(
             }
         }
 
@@ -228,41 +230,6 @@ class MainFragment : StatusBarThemeFragment(), MainActivity.OnBackPressedListene
         }
     }
 
-    private fun alternativeClockIntent(): Intent {
-        var intent = Intent()
-        val alarmClockIntent = Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_LAUNCHER)
-        val pm = activity!!.packageManager
-
-        val clockImpls = arrayOf(arrayOf("HTC Alarm Clock", "com.htc.android.worldclock", "com.htc.android.worldclock.WorldClockTabControl"), arrayOf("Standar Alarm Clock", "com.android.deskclock", "com.android.deskclock.AlarmClock"), arrayOf("Froyo Nexus Alarm Clock", "com.google.android.deskclock", "com.android.deskclock.DeskClock"), arrayOf("Moto Blur Alarm Clock", "com.motorola.blur.alarmclock", "com.motorola.blur.alarmclock.AlarmClock"), arrayOf("Samsung Galaxy Clock", "com.sec.android.app.clockpackage", "com.sec.android.app.clockpackage.ClockPackage"), arrayOf("Sony Ericsson Xperia Z", "com.sonyericsson.organizer", "com.sonyericsson.organizer.Organizer_WorldClock"), arrayOf("ASUS Tablets", "com.asus.deskclock", "com.asus.deskclock.DeskClock"))
-
-        var foundClockImpl = false
-
-        for (i in clockImpls.indices) {
-            val packageName = clockImpls[i][1]
-            val className = clockImpls[i][2]
-            val cn = ComponentName(packageName, className)
-            alarmClockIntent.component = cn
-            if (alarmClockIntent.resolveActivity(pm) != null) {
-                foundClockImpl = true
-                intent = alarmClockIntent
-            }
-        }
-
-        return if (foundClockImpl) {
-            intent
-        } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
-            val i = Intent(AlarmClock.ACTION_SHOW_ALARMS)
-            if (alarmClockIntent.resolveActivity(pm) != null) {
-                i
-            } else {
-                throw Exception("No clock activity found for the intent")
-            }
-        } else {
-            throw Exception("No clock activity found for the intent")
-        }
-    }
-
-
     private fun doBounceAnimation(targetView: View) {
         targetView.animate()
                 .setStartDelay(500)

+ 1 - 1
app/src/main/res/values/strings.xml

@@ -51,7 +51,7 @@
     <string name="settings_button_change_theme">Change</string>
     <string name="about_title">Slim launcher</string>
     <string name="about_text">
-    Slim v2.2.3 \u00a9 2019\n\nSource : <a href="https://github.com/sduduzog/slim-launcher">https://github.com/sduduzog/slim-launcher</a>\n\n<a href="mailto:gumedesduduzo@gmail.com">gumedesduduzo@gmail.com</a>\n\nBecome a tester <a href="https://play.google.com/apps/testing/com.sduduzog.slimlauncher">Click here</a>
+    Slim v2.2.4 \u00a9 2019\n\nSource : <a href="https://github.com/sduduzog/slim-launcher">https://github.com/sduduzog/slim-launcher</a>\n\n<a href="mailto:gumedesduduzo@gmail.com">gumedesduduzo@gmail.com</a>\n\nBecome a tester <a href="https://play.google.com/apps/testing/com.sduduzog.slimlauncher">Click here</a>
     </string>
     <string name="theme_chooser_dialog_title">Change theme</string>
     <string name="main_call_icon">call icon</string>