Quellcode durchsuchen

Merge remote-tracking branch 'origin/master' into develop

Beautus vor 7 Jahren
Ursprung
Commit
eb614753e4

+ 7 - 5
README.md

@@ -1,11 +1,13 @@
 # Slim launcher
-
 > _All you need is less._
 
-</style>
-<img id="app-logo" src="docs/assets/ic_launcher-web.png">
+[![CircleCI](https://circleci.com/gh/sduduzog/slim-launcher/tree/master.svg?style=svg)](https://circleci.com/gh/sduduzog/slim-launcher/tree/master)
+
+![Slim Launcher Logo](docs/assets/ic_launcher-web.png)
+
+**Now available on Google Play!**
 
-## Now available on Google Play[![Google Play badge](docs/assets/google-play-badge.png)](https://play.google.com/store/apps/details?id=com.sduduzog.slimlauncher)
+[![Google Play badge](docs/assets/google-play-badge.png)](https://play.google.com/store/apps/details?id=com.sduduzog.slimlauncher)
 
 ## Background
 
@@ -13,7 +15,7 @@ This project was inspired by LessPhone [LessPhone](https://play.google.com/store
 
 **But!** I couldn't do with just 3 apps as daily apps so tah-daaa Slim launcher, everyone! with a couple of bells and whistles.
 
-## Milstones
+## Milestones
 
 - [x] Release on Google Play _(release the kraken!)_
 - [x] Variety of themes

+ 2 - 2
app/build.gradle

@@ -12,8 +12,8 @@ android {
         applicationId "com.sduduzog.slimlauncher"
         minSdkVersion 16
         targetSdkVersion 28
-        versionCode 23
-        versionName "2.2.1"
+        versionCode 27
+        versionName "2.2.5"
         testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
         vectorDrawables.useSupportLibrary = true
     }

+ 0 - 1
app/release/output.json

@@ -1 +0,0 @@
-[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":23,"versionName":"2.2.1","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]

+ 0 - 12
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"
@@ -29,17 +28,6 @@
                 <category android:name="android.intent.category.LAUNCHER" />
             </intent-filter>
         </activity>
-        <receiver
-            android:name=".SlimAdminReceiver"
-            android:permission="android.permission.BIND_DEVICE_ADMIN">
-            <meta-data
-                android:name="android.app.device_admin"
-                android:resource="@xml/admin"/>
-
-            <intent-filter>
-                <action android:name="android.app.action.DEVICE_ADMIN_ENABLED"/>
-            </intent-filter>
-        </receiver>
     </application>
 
 </manifest>

+ 0 - 2
app/src/main/java/com/sduduzog/slimlauncher/MainActivity.kt

@@ -16,8 +16,6 @@ import com.sduduzog.slimlauncher.ui.main.MainViewModel
 
 class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceChangeListener, NavController.OnDestinationChangedListener {
 
-    // TODO: Move some apps to bottom sheet.
-
     private lateinit var settings: SharedPreferences
     private val label = "main_fragment"
     private lateinit var currentLabel: String

+ 0 - 5
app/src/main/java/com/sduduzog/slimlauncher/SlimAdminReceiver.kt

@@ -1,5 +0,0 @@
-package com.sduduzog.slimlauncher
-
-import android.app.admin.DeviceAdminReceiver
-
-class SlimAdminReceiver : DeviceAdminReceiver()

+ 28 - 101
app/src/main/java/com/sduduzog/slimlauncher/ui/main/MainFragment.kt

@@ -1,7 +1,5 @@
 package com.sduduzog.slimlauncher.ui.main
 
-import android.annotation.SuppressLint
-import android.app.admin.DevicePolicyManager
 import android.content.*
 import android.net.Uri
 import android.os.Build
@@ -9,7 +7,9 @@ import android.os.Bundle
 import android.provider.AlarmClock
 import android.provider.MediaStore
 import android.provider.Settings
-import android.view.*
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
 import android.widget.FrameLayout
 import androidx.core.app.ActivityOptionsCompat
 import androidx.navigation.Navigation
@@ -18,7 +18,6 @@ import com.google.android.material.bottomsheet.BottomSheetBehavior.STATE_COLLAPS
 import com.google.android.material.bottomsheet.BottomSheetBehavior.STATE_HALF_EXPANDED
 import com.sduduzog.slimlauncher.MainActivity
 import com.sduduzog.slimlauncher.R
-import com.sduduzog.slimlauncher.SlimAdminReceiver
 import kotlinx.android.synthetic.main.main_bottom_sheet.*
 import kotlinx.android.synthetic.main.main_content.*
 import kotlinx.android.synthetic.main.main_fragment.*
@@ -30,7 +29,6 @@ class MainFragment : StatusBarThemeFragment(), MainActivity.OnBackPressedListene
 
     private lateinit var receiver: BroadcastReceiver
     private lateinit var sheetBehavior: BottomSheetBehavior<FrameLayout>
-    private val homeClickListener = HomeDoubleClickListener()
 
     override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
                               savedInstanceState: Bundle?): View {
@@ -92,21 +90,21 @@ class MainFragment : StatusBarThemeFragment(), MainActivity.OnBackPressedListene
 
     private fun setEventListeners() {
 
-        main.setOnClickListener(homeClickListener)
-        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,13 +119,11 @@ 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 :(
             }
         }
 
-        val settings = context!!.getSharedPreferences(getString(R.string.prefs_settings), Context.MODE_PRIVATE)
-        val isChecked = settings.getBoolean(getString(R.string.prefs_settings_key_app_dialer), false)
         ivCall.setOnClickListener {
             try {
                 val intent = Intent(Intent.ACTION_DIAL)
@@ -142,18 +138,16 @@ class MainFragment : StatusBarThemeFragment(), MainActivity.OnBackPressedListene
             }
         }
         ivCall.setOnLongClickListener {
-            if (isChecked) {
-                try {
-                    val intent = Intent(Intent.ACTION_DIAL, null)
-                    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
-                }
+            try {
+                val intent = Intent(Intent.ACTION_DIAL, null)
+                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
             }
             true
         }
@@ -232,38 +226,6 @@ class MainFragment : StatusBarThemeFragment(), MainActivity.OnBackPressedListene
         }
     }
 
-    private fun alternativeClockIntent(): Intent {
-        val alarmClockIntent = Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_LAUNCHER)
-        val pm = activity!!.packageManager
-// Verify clock implementation
-        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
-        }
-
-        return if (foundClockImpl) {
-            alarmClockIntent
-        } 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)
@@ -300,39 +262,4 @@ class MainFragment : StatusBarThemeFragment(), MainActivity.OnBackPressedListene
             updateUi()
         }
     }
-
-    inner class HomeDoubleClickListener : View.OnTouchListener, DoubleClickListener() {
-
-        private val gestureDetector = GestureDetector(context, object : GestureDetector.SimpleOnGestureListener() {
-            override fun onDoubleTap(e: MotionEvent?): Boolean {
-                performLock()
-                return super.onDoubleTap(e)
-            }
-        })
-
-        @SuppressLint("ClickableViewAccessibility")
-        override fun onTouch(p0: View?, p1: MotionEvent?): Boolean {
-            return gestureDetector.onTouchEvent(p1)
-        }
-
-        override fun onDoubleClick(v: View) {
-            performLock()
-        }
-
-        override fun onSingleClick(v: View) {
-
-        }
-
-        private fun performLock() {
-            val mComponentName = ComponentName(context!!, SlimAdminReceiver::class.java)
-            val mDevicePolicyManager = activity!!.getSystemService(
-                    Context.DEVICE_POLICY_SERVICE) as DevicePolicyManager
-            val isAdmin = mDevicePolicyManager.isAdminActive(mComponentName)
-            if (isAdmin) {
-                mDevicePolicyManager.lockNow()
-            } else {
-                MakeSlimAdminDialog().show(childFragmentManager, "Admin Dialog")
-            }
-        }
-    }
 }

+ 0 - 41
app/src/main/java/com/sduduzog/slimlauncher/ui/main/MakeSlimAdminDialog.kt

@@ -1,41 +0,0 @@
-@file:Suppress("unused")
-
-package com.sduduzog.slimlauncher.ui.main
-
-import android.app.AlertDialog
-import android.app.Dialog
-import android.app.admin.DevicePolicyManager
-import android.content.ComponentName
-import android.content.Intent
-import android.os.Bundle
-import androidx.fragment.app.DialogFragment
-import com.sduduzog.slimlauncher.MainActivity.Companion.REQUEST_CODE_ENABLE_ADMIN
-import com.sduduzog.slimlauncher.R
-import com.sduduzog.slimlauncher.SlimAdminReceiver
-
-
-class MakeSlimAdminDialog : DialogFragment() {
-
-    private var mComponentName: ComponentName? = null
-
-    override fun onCreate(savedInstanceState: Bundle?) {
-        super.onCreate(savedInstanceState)
-        mComponentName = ComponentName(context!!, SlimAdminReceiver::class.java)
-    }
-
-    override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
-
-        val builder = AlertDialog.Builder(context!!)
-
-        builder.setTitle(getString(R.string.main_admin_title))
-        builder.setMessage(getString(R.string.main_admin_message))
-        builder.setNegativeButton("no, thanks") { _, _ -> }
-        builder.setPositiveButton("activate") { _, _ ->
-            val intent = Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN)
-            intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, mComponentName)
-            intent.putExtra(DevicePolicyManager.EXTRA_ADD_EXPLANATION, getString(R.string.main_admin_message))
-            startActivityForResult(intent, REQUEST_CODE_ENABLE_ADMIN)
-        }
-        return builder.create()
-    }
-}

+ 0 - 7
app/src/main/java/com/sduduzog/slimlauncher/ui/main/settings/SettingsFragment.kt

@@ -90,13 +90,6 @@ class SettingsFragment : StatusBarThemeFragment() {
             }
         }
 
-        dialerSwitch.isChecked = settings.getBoolean(getString(R.string.prefs_settings_key_app_dialer), false)
-        dialerSwitch.setOnCheckedChangeListener { _, b ->
-            settings.edit {
-                putBoolean(getString(R.string.prefs_settings_key_app_dialer), b)
-            }
-        }
-
         statusBarSwitch.isChecked = settings.getBoolean(getString(R.string.prefs_settings_key_hide_status_bar), false)
         statusBarSwitch.setOnCheckedChangeListener { _, b ->
             settings.edit {

+ 1 - 1
app/src/main/java/com/sduduzog/slimlauncher/ui/main/settings/SettingsListAdapter.kt

@@ -60,7 +60,7 @@ class SettingsListAdapter(private val fragment: Fragment) : RecyclerView.Adapter
             }
 
             holder.itemView.setOnClickListener {
-                val snackbar = Snackbar.make(it, "You're still in preferences, silly. Go back to the main screen to start this app", Snackbar.LENGTH_LONG)
+                val snackbar = Snackbar.make(it, "You're still in preferences, silly. Go back to the home screen to start this app", Snackbar.LENGTH_LONG)
                 snackbar.show()
             }
 

+ 7 - 40
app/src/main/res/layout/settings_fragment.xml

@@ -104,52 +104,18 @@
         app:layout_constraintEnd_toEndOf="parent"
         app:layout_constraintTop_toTopOf="@+id/textView2" />
 
-    <TextView
-        android:id="@+id/textView9"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:layout_marginStart="16dp"
-        android:layout_marginTop="16dp"
-        android:text="@string/settings_use_slim_s_built_in_dialer"
-        android:textAppearance="@style/TextAppearance.AppCompat"
-        android:textSize="18sp"
-        app:layout_constraintStart_toStartOf="parent"
-        app:layout_constraintTop_toBottomOf="@+id/textView4"
-        android:layout_marginLeft="16dp" />
-
-    <TextView
-        android:id="@+id/textView10"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:text="@string/settings_faster_shortcut_to_your_calls"
-        app:layout_constraintStart_toStartOf="@+id/textView9"
-        app:layout_constraintTop_toBottomOf="@+id/textView9" />
-
-    <Switch
-        android:id="@+id/dialerSwitch"
-        android:layout_width="wrap_content"
-        android:layout_height="48dp"
-        android:layout_marginTop="8dp"
-        android:layout_marginEnd="24dp"
-        android:layout_marginRight="24dp"
-        android:layout_marginBottom="8dp"
-        android:padding="4dp"
-        app:layout_constraintBottom_toBottomOf="@+id/textView10"
-        app:layout_constraintEnd_toEndOf="parent"
-        app:layout_constraintTop_toTopOf="@+id/textView9" />
-
     <TextView
         android:id="@+id/changeThemeText"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_marginStart="16dp"
+        android:layout_marginLeft="16dp"
         android:layout_marginTop="16dp"
         android:text="@string/main_options_change_theme"
         android:textAppearance="@style/TextAppearance.AppCompat"
         android:textSize="18sp"
         app:layout_constraintStart_toStartOf="parent"
-        app:layout_constraintTop_toBottomOf="@+id/textView10"
-        android:layout_marginLeft="16dp" />
+        app:layout_constraintTop_toBottomOf="@+id/textView4" />
 
     <TextView
         android:id="@+id/textView7"
@@ -194,6 +160,7 @@
         app:layout_constraintEnd_toEndOf="parent"
         app:layout_constraintStart_toStartOf="parent"
         app:layout_constraintTop_toBottomOf="@+id/divider2"
+        tools:itemCount="5"
         tools:listitem="@layout/settings_list_item" />
 
     <androidx.appcompat.widget.AppCompatCheckBox
@@ -203,11 +170,11 @@
         android:layout_height="wrap_content"
         android:layout_marginTop="8dp"
         android:layout_marginEnd="24dp"
+        android:layout_marginRight="24dp"
         android:textAppearance="@style/TextAppearance.AppCompat"
         android:visibility="gone"
         app:layout_constraintEnd_toEndOf="parent"
-        app:layout_constraintTop_toTopOf="@+id/textView2"
-        android:layout_marginRight="24dp" />
+        app:layout_constraintTop_toTopOf="@+id/textView2" />
 
     <Button
         android:id="@+id/buttonChangeTheme"
@@ -216,11 +183,11 @@
         android:layout_height="wrap_content"
         android:layout_marginTop="8dp"
         android:layout_marginEnd="16dp"
+        android:layout_marginRight="16dp"
         android:layout_marginBottom="8dp"
         android:text="@string/settings_button_change_theme"
         app:layout_constraintBottom_toBottomOf="@+id/textView7"
         app:layout_constraintEnd_toEndOf="parent"
-        app:layout_constraintTop_toTopOf="@+id/changeThemeText"
-        android:layout_marginRight="16dp" />
+        app:layout_constraintTop_toTopOf="@+id/changeThemeText" />
 
 </androidx.constraintlayout.widget.ConstraintLayout>

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

@@ -16,7 +16,6 @@
     <string name="prefs_settings_key_theme">key_theme</string>
     <string name="prefs_settings_key_clock_type">clock_type</string>
     <string name="prefs_settings_key_hide_status_bar">hide_status_bar</string>
-    <string name="prefs_settings_key_app_dialer">app_dialer</string>
     <string name="prefs_settings_key_fresh_install_setup">key_fresh_install_setup</string>
 
     <!--main package strings-->
@@ -52,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.1 \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>

+ 1 - 1
build.gradle

@@ -8,7 +8,7 @@ buildscript {
     }
     dependencies {
         //noinspection GradleDependency
-        classpath 'com.android.tools.build:gradle:3.3.0-alpha11'
+        classpath 'com.android.tools.build:gradle:3.3.0'
         classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
 
         // NOTE: Do not place your application dependencies here; they belong

+ 1 - 0
gradle.properties

@@ -9,6 +9,7 @@
 org.gradle.jvmargs=-Xmx1536m
 android.useAndroidX=true
 android.enableJetifier=true
+android.enableR8=true
 # When configured, Gradle will run in incubating parallel mode.
 # This option should only be used with decoupled projects. More details, visit
 # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects