|
|
@@ -71,7 +71,6 @@ class HomeFragment(private val viewModel: MainViewModel) : BaseFragment(), OnLau
|
|
|
})
|
|
|
|
|
|
setEventListeners()
|
|
|
- home_fragment_options.setOnClickListener(Navigation.createNavigateOnClickListener(R.id.action_homeFragment_to_optionsFragment))
|
|
|
|
|
|
// Populate the app drawer
|
|
|
val openAppAdapter = AddAppAdapter(this)
|
|
|
@@ -152,26 +151,40 @@ class HomeFragment(private val viewModel: MainViewModel) : BaseFragment(), OnLau
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- home_fragment_call.setOnClickListener { view ->
|
|
|
- try {
|
|
|
- val pm = context?.packageManager!!
|
|
|
- val intent = Intent(Intent.ACTION_DIAL)
|
|
|
- val componentName = intent.resolveActivity(pm)
|
|
|
- if (componentName == null) launchActivity(view, intent) else
|
|
|
- pm.getLaunchIntentForPackage(componentName.packageName)?.let {
|
|
|
- launchActivity(view, it)
|
|
|
- } ?: run { launchActivity(view, intent) }
|
|
|
- } catch (e: Exception) {
|
|
|
- // Do nothing
|
|
|
+ val leftButtonIcon = getQuickButtonIcon(R.string.prefs_settings_key_quick_button_left_icon_id, R.drawable.ic_call)
|
|
|
+ home_fragment_call.setImageResource(leftButtonIcon)
|
|
|
+ if(leftButtonIcon != R.drawable.ic_empty) {
|
|
|
+ home_fragment_call.setOnClickListener { view ->
|
|
|
+ try {
|
|
|
+ val pm = context?.packageManager!!
|
|
|
+ val intent = Intent(Intent.ACTION_DIAL)
|
|
|
+ val componentName = intent.resolveActivity(pm)
|
|
|
+ if (componentName == null) launchActivity(view, intent) else
|
|
|
+ pm.getLaunchIntentForPackage(componentName.packageName)?.let {
|
|
|
+ launchActivity(view, it)
|
|
|
+ } ?: run { launchActivity(view, intent) }
|
|
|
+ } catch (e: Exception) {
|
|
|
+ // Do nothing
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- home_fragment_camera.setOnClickListener {
|
|
|
- try {
|
|
|
- val intent = Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA)
|
|
|
- launchActivity(it, intent)
|
|
|
- } catch (e: Exception) {
|
|
|
- // Do nothing
|
|
|
+ val centerButtonIcon = getQuickButtonIcon(R.string.prefs_settings_key_quick_button_center_icon_id, R.drawable.ic_cog)
|
|
|
+ home_fragment_options.setImageResource(centerButtonIcon)
|
|
|
+ if(centerButtonIcon != R.drawable.ic_empty) {
|
|
|
+ home_fragment_options.setOnClickListener(Navigation.createNavigateOnClickListener(R.id.action_homeFragment_to_optionsFragment))
|
|
|
+ }
|
|
|
+
|
|
|
+ val rightButtonIcon = getQuickButtonIcon(R.string.prefs_settings_key_quick_button_right_icon_id, R.drawable.ic_photo_camera)
|
|
|
+ home_fragment_camera.setImageResource(rightButtonIcon)
|
|
|
+ if(rightButtonIcon != R.drawable.ic_empty) {
|
|
|
+ home_fragment_camera.setOnClickListener {
|
|
|
+ try {
|
|
|
+ val intent = Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA)
|
|
|
+ launchActivity(it, intent)
|
|
|
+ } catch (e: Exception) {
|
|
|
+ // Do nothing
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -238,6 +251,11 @@ class HomeFragment(private val viewModel: MainViewModel) : BaseFragment(), OnLau
|
|
|
app_drawer_edit_text.clearFocus()
|
|
|
}
|
|
|
|
|
|
+ private fun getQuickButtonIcon(buttonPrefKey: Int, defaultIconId: Int): Int {
|
|
|
+ return context?.getSharedPreferences(getString(R.string.prefs_settings), Context.MODE_PRIVATE)
|
|
|
+ ?.getInt(getString(buttonPrefKey), defaultIconId) ?: defaultIconId
|
|
|
+ }
|
|
|
+
|
|
|
private val onTextChangeListener: TextWatcher = object : TextWatcher {
|
|
|
|
|
|
override fun afterTextChanged(s: Editable?) {
|