|
|
@@ -1,10 +1,12 @@
|
|
|
package com.sduduzog.slimlauncher
|
|
|
|
|
|
+import android.content.Intent
|
|
|
import android.content.SharedPreferences
|
|
|
import android.content.pm.PackageManager
|
|
|
import android.content.res.Resources
|
|
|
import android.os.Bundle
|
|
|
import android.view.View
|
|
|
+import android.widget.Toast
|
|
|
import androidx.appcompat.app.AppCompatActivity
|
|
|
import androidx.lifecycle.ViewModelProviders
|
|
|
import androidx.navigation.NavController
|
|
|
@@ -16,7 +18,6 @@ import com.sduduzog.slimlauncher.ui.main.MainViewModel
|
|
|
class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceChangeListener, NavController.OnDestinationChangedListener {
|
|
|
|
|
|
// TODO: Clickable apps while in preferences, intuitiveness
|
|
|
- // TODO: Lock screen on double tap
|
|
|
// TODO: Move some apps to bottom sheet.
|
|
|
|
|
|
private lateinit var settings: SharedPreferences
|
|
|
@@ -107,7 +108,7 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh
|
|
|
override fun onRequestPermissionsResult(requestCode: Int,
|
|
|
permissions: Array<String>, grantResults: IntArray) {
|
|
|
when (requestCode) {
|
|
|
- REQUEST_PHONE_CALL -> {
|
|
|
+ REQUEST_CODE_PHONE_CALL -> {
|
|
|
// If request is cancelled, the result arrays are empty.
|
|
|
if (grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
|
|
navigator.navigate(R.id.action_mainFragment_to_dialerFragment)
|
|
|
@@ -116,8 +117,19 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh
|
|
|
}
|
|
|
return
|
|
|
}
|
|
|
- }// other 'case' lines to check for other
|
|
|
- // permissions this app might request
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
|
|
+ if (requestCode == REQUEST_CODE_ENABLE_ADMIN) {
|
|
|
+ if (resultCode == RESULT_OK) {
|
|
|
+ Toast.makeText(applicationContext, "Registered As Admin", Toast.LENGTH_SHORT).show()
|
|
|
+ } else {
|
|
|
+ Toast.makeText(applicationContext, "Failed to register as Admin", Toast.LENGTH_SHORT).show()
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private fun showSystemUI() {
|
|
|
@@ -163,7 +175,8 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh
|
|
|
return R.style.AppTheme
|
|
|
}
|
|
|
|
|
|
- const val REQUEST_PHONE_CALL = 1
|
|
|
+ const val REQUEST_CODE_PHONE_CALL = 1
|
|
|
+ const val REQUEST_CODE_ENABLE_ADMIN = 2
|
|
|
}
|
|
|
|
|
|
interface OnBackPressedListener {
|