mirror of
https://github.com/SimpleMobileTools/Simple-Contacts.git
synced 2025-06-05 21:59:27 +02:00
removing the DialPad activity, launch DIAL intent on click
This commit is contained in:
@ -6,7 +6,6 @@ import android.app.SearchManager
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.pm.ShortcutInfo
|
||||
import android.content.pm.ShortcutManager
|
||||
import android.graphics.drawable.ColorDrawable
|
||||
import android.graphics.drawable.Icon
|
||||
import android.graphics.drawable.LayerDrawable
|
||||
@ -294,35 +293,16 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
|
||||
private fun checkShortcuts() {
|
||||
val appIconColor = config.appIconColor
|
||||
if (isNougatMR1Plus() && config.lastHandledShortcutColor != appIconColor) {
|
||||
val launchDialpad = getLaunchDialpadShortcut(appIconColor)
|
||||
val createNewContact = getCreateNewContactShortcut(appIconColor)
|
||||
|
||||
val manager = getSystemService(ShortcutManager::class.java)
|
||||
try {
|
||||
manager.dynamicShortcuts = Arrays.asList(launchDialpad, createNewContact)
|
||||
shortcutManager.dynamicShortcuts = Arrays.asList(createNewContact)
|
||||
config.lastHandledShortcutColor = appIconColor
|
||||
} catch (ignored: Exception) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
private fun getLaunchDialpadShortcut(appIconColor: Int): ShortcutInfo {
|
||||
val newEvent = getString(R.string.dialpad)
|
||||
val drawable = resources.getDrawable(R.drawable.shortcut_dialpad)
|
||||
(drawable as LayerDrawable).findDrawableByLayerId(R.id.shortcut_dialpad_background).applyColorFilter(appIconColor)
|
||||
val bmp = drawable.convertToBitmap()
|
||||
|
||||
val intent = Intent(this, DialpadActivity::class.java)
|
||||
intent.action = Intent.ACTION_VIEW
|
||||
return ShortcutInfo.Builder(this, "launch_dialpad")
|
||||
.setShortLabel(newEvent)
|
||||
.setLongLabel(newEvent)
|
||||
.setIcon(Icon.createWithBitmap(bmp))
|
||||
.setIntent(intent)
|
||||
.build()
|
||||
}
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
private fun getCreateNewContactShortcut(appIconColor: Int): ShortcutInfo {
|
||||
val newEvent = getString(R.string.create_new_contact)
|
||||
@ -459,8 +439,9 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
|
||||
}
|
||||
|
||||
private fun launchDialpad() {
|
||||
val intent = Intent(applicationContext, DialpadActivity::class.java)
|
||||
startActivity(intent)
|
||||
Intent(Intent.ACTION_DIAL).apply {
|
||||
startActivity(this)
|
||||
}
|
||||
}
|
||||
|
||||
private fun tryImportContacts() {
|
||||
|
Reference in New Issue
Block a user