Clean code and add towncrier file.
This commit is contained in:
parent
1ff0a0d435
commit
1bb32eff45
|
@ -0,0 +1 @@
|
||||||
|
Some improvements on DialPad (cursor edition, paste number, small fixes).
|
|
@ -17,7 +17,6 @@
|
||||||
package im.vector.app.features.call.dialpad
|
package im.vector.app.features.call.dialpad
|
||||||
|
|
||||||
import android.content.ClipboardManager
|
import android.content.ClipboardManager
|
||||||
import android.content.Context
|
|
||||||
import android.content.res.ColorStateList
|
import android.content.res.ColorStateList
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.telephony.PhoneNumberFormattingTextWatcher
|
import android.telephony.PhoneNumberFormattingTextWatcher
|
||||||
|
@ -31,6 +30,7 @@ import android.view.KeyEvent
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import androidx.core.content.getSystemService
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import androidx.core.widget.ImageViewCompat
|
import androidx.core.widget.ImageViewCompat
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
|
@ -59,6 +59,7 @@ class DialPadFragment : Fragment(), TextWatcher {
|
||||||
savedInstanceState: Bundle?): View {
|
savedInstanceState: Bundle?): View {
|
||||||
initArgs(savedInstanceState)
|
initArgs(savedInstanceState)
|
||||||
val view = inflater.inflate(R.layout.dialpad_fragment, container, false)
|
val view = inflater.inflate(R.layout.dialpad_fragment, container, false)
|
||||||
|
view.setBackgroundColor(ThemeUtils.getColor(requireContext(), R.attr.backgroundColor))
|
||||||
val dialpadView = view.findViewById<View>(R.id.dialpad_view) as DialpadView
|
val dialpadView = view.findViewById<View>(R.id.dialpad_view) as DialpadView
|
||||||
dialpadView.findViewById<View>(R.id.dialpad_key_voicemail).isVisible = false
|
dialpadView.findViewById<View>(R.id.dialpad_key_voicemail).isVisible = false
|
||||||
digits = dialpadView.digits as DigitsEditText
|
digits = dialpadView.digits as DigitsEditText
|
||||||
|
@ -69,22 +70,22 @@ class DialPadFragment : Fragment(), TextWatcher {
|
||||||
digits.addTextChangedListener(PhoneNumberFormattingTextWatcher(if (formatAsYouType) regionCode else ""))
|
digits.addTextChangedListener(PhoneNumberFormattingTextWatcher(if (formatAsYouType) regionCode else ""))
|
||||||
digits.addTextChangedListener(this)
|
digits.addTextChangedListener(this)
|
||||||
dialpadView.findViewById<View>(R.id.zero).setOnClickListener { keyPressed(KeyEvent.KEYCODE_0, "0") }
|
dialpadView.findViewById<View>(R.id.zero).setOnClickListener { keyPressed(KeyEvent.KEYCODE_0, "0") }
|
||||||
dialpadView.findViewById<View>(R.id.one).setOnClickListener { keyPressed(KeyEvent.KEYCODE_1,"1") }
|
dialpadView.findViewById<View>(R.id.one).setOnClickListener { keyPressed(KeyEvent.KEYCODE_1, "1") }
|
||||||
dialpadView.findViewById<View>(R.id.two).setOnClickListener { keyPressed(KeyEvent.KEYCODE_2,"2") }
|
dialpadView.findViewById<View>(R.id.two).setOnClickListener { keyPressed(KeyEvent.KEYCODE_2, "2") }
|
||||||
dialpadView.findViewById<View>(R.id.three).setOnClickListener { keyPressed(KeyEvent.KEYCODE_3,"3") }
|
dialpadView.findViewById<View>(R.id.three).setOnClickListener { keyPressed(KeyEvent.KEYCODE_3, "3") }
|
||||||
dialpadView.findViewById<View>(R.id.four).setOnClickListener { keyPressed(KeyEvent.KEYCODE_4,"4") }
|
dialpadView.findViewById<View>(R.id.four).setOnClickListener { keyPressed(KeyEvent.KEYCODE_4, "4") }
|
||||||
dialpadView.findViewById<View>(R.id.five).setOnClickListener { keyPressed(KeyEvent.KEYCODE_5,"5") }
|
dialpadView.findViewById<View>(R.id.five).setOnClickListener { keyPressed(KeyEvent.KEYCODE_5, "5") }
|
||||||
dialpadView.findViewById<View>(R.id.six).setOnClickListener { keyPressed(KeyEvent.KEYCODE_6,"6") }
|
dialpadView.findViewById<View>(R.id.six).setOnClickListener { keyPressed(KeyEvent.KEYCODE_6, "6") }
|
||||||
dialpadView.findViewById<View>(R.id.seven).setOnClickListener { keyPressed(KeyEvent.KEYCODE_7,"7") }
|
dialpadView.findViewById<View>(R.id.seven).setOnClickListener { keyPressed(KeyEvent.KEYCODE_7, "7") }
|
||||||
dialpadView.findViewById<View>(R.id.eight).setOnClickListener { keyPressed(KeyEvent.KEYCODE_8,"8") }
|
dialpadView.findViewById<View>(R.id.eight).setOnClickListener { keyPressed(KeyEvent.KEYCODE_8, "8") }
|
||||||
dialpadView.findViewById<View>(R.id.nine).setOnClickListener { keyPressed(KeyEvent.KEYCODE_9,"9") }
|
dialpadView.findViewById<View>(R.id.nine).setOnClickListener { keyPressed(KeyEvent.KEYCODE_9, "9") }
|
||||||
if (enableStar) {
|
if (enableStar) {
|
||||||
dialpadView.findViewById<View>(R.id.star).setOnClickListener { keyPressed(KeyEvent.KEYCODE_STAR,"*") }
|
dialpadView.findViewById<View>(R.id.star).setOnClickListener { keyPressed(KeyEvent.KEYCODE_STAR, "*") }
|
||||||
} else {
|
} else {
|
||||||
dialpadView.findViewById<View>(R.id.star).isVisible = false
|
dialpadView.findViewById<View>(R.id.star).isVisible = false
|
||||||
}
|
}
|
||||||
if (enablePound) {
|
if (enablePound) {
|
||||||
dialpadView.findViewById<View>(R.id.pound).setOnClickListener { keyPressed(KeyEvent.KEYCODE_POUND,"#") }
|
dialpadView.findViewById<View>(R.id.pound).setOnClickListener { keyPressed(KeyEvent.KEYCODE_POUND, "#") }
|
||||||
} else {
|
} else {
|
||||||
dialpadView.findViewById<View>(R.id.pound).isVisible = false
|
dialpadView.findViewById<View>(R.id.pound).isVisible = false
|
||||||
}
|
}
|
||||||
|
@ -117,7 +118,7 @@ class DialPadFragment : Fragment(), TextWatcher {
|
||||||
private fun onOkClicked() {
|
private fun onOkClicked() {
|
||||||
val rawInput = getRawInput()
|
val rawInput = getRawInput()
|
||||||
if (rawInput.isEmpty()) {
|
if (rawInput.isEmpty()) {
|
||||||
val clipboard = (requireContext().getSystemService(Context.CLIPBOARD_SERVICE)) as? ClipboardManager
|
val clipboard = requireContext().getSystemService<ClipboardManager>()
|
||||||
val textToPaste = clipboard?.primaryClip?.getItemAt(0)?.text ?: return
|
val textToPaste = clipboard?.primaryClip?.getItemAt(0)?.text ?: return
|
||||||
val formatted = formatNumber(textToPaste.toString())
|
val formatted = formatNumber(textToPaste.toString())
|
||||||
digits.setText(formatted)
|
digits.setText(formatted)
|
||||||
|
@ -174,19 +175,14 @@ class DialPadFragment : Fragment(), TextWatcher {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun formatNumber(dialString: String): String {
|
private fun formatNumber(dialString: String): String {
|
||||||
var number = PhoneNumberUtils.extractNetworkPortion(dialString)
|
val networkPortion = PhoneNumberUtils.extractNetworkPortion(dialString)
|
||||||
// Also retrieve the post dial portion of the provided data, so that the entire dial
|
if (TextUtils.isEmpty(networkPortion)) {
|
||||||
// string can be reconstituted later.
|
|
||||||
val postDial = PhoneNumberUtils.extractPostDialPortion(dialString)
|
|
||||||
if (TextUtils.isEmpty(number)) {
|
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
number = PhoneNumberUtils.formatNumber(number, null, regionCode) ?: number
|
val number = PhoneNumberUtils.formatNumber(networkPortion, null, regionCode) ?: networkPortion
|
||||||
return if (TextUtils.isEmpty(postDial)) {
|
// Also retrieve the post dial portion of the provided data, so that the entire dial string can be reconstituted
|
||||||
number
|
val postDial = PhoneNumberUtils.extractPostDialPortion(dialString)
|
||||||
} else {
|
return number + postDial
|
||||||
number + postDial
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Callback {
|
interface Callback {
|
||||||
|
@ -210,11 +206,11 @@ class DialPadFragment : Fragment(), TextWatcher {
|
||||||
// Text watcher
|
// Text watcher
|
||||||
|
|
||||||
override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {
|
override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {
|
||||||
//Noop
|
// Noop
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {
|
override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {
|
||||||
//Noop
|
// Noop
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun afterTextChanged(s: Editable) {
|
override fun afterTextChanged(s: Editable) {
|
||||||
|
@ -222,5 +218,4 @@ class DialPadFragment : Fragment(), TextWatcher {
|
||||||
digits.clearFocus()
|
digits.clearFocus()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,6 @@ import androidx.fragment.app.Fragment
|
||||||
import androidx.fragment.app.FragmentActivity
|
import androidx.fragment.app.FragmentActivity
|
||||||
import androidx.viewpager2.adapter.FragmentStateAdapter
|
import androidx.viewpager2.adapter.FragmentStateAdapter
|
||||||
import im.vector.app.core.extensions.toMvRxBundle
|
import im.vector.app.core.extensions.toMvRxBundle
|
||||||
import im.vector.app.core.platform.Restorable
|
|
||||||
import im.vector.app.features.call.dialpad.DialPadFragment
|
import im.vector.app.features.call.dialpad.DialPadFragment
|
||||||
import im.vector.app.features.settings.VectorLocale
|
import im.vector.app.features.settings.VectorLocale
|
||||||
import im.vector.app.features.userdirectory.UserListFragment
|
import im.vector.app.features.userdirectory.UserListFragment
|
||||||
|
@ -71,6 +70,4 @@ class CallTransferPagerAdapter(
|
||||||
private fun findFragmentAtPosition(position: Int): Fragment? {
|
private fun findFragmentAtPosition(position: Int): Fragment? {
|
||||||
return fragmentActivity.supportFragmentManager.findFragmentByTag("f$position")
|
return fragmentActivity.supportFragmentManager.findFragmentByTag("f$position")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -140,7 +140,6 @@
|
||||||
android:id="@+id/roomListContainer"
|
android:id="@+id/roomListContainer"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:background="?vctr_list_separator_system"
|
|
||||||
app:layout_constraintBottom_toTopOf="@+id/bottomNavigationView"
|
app:layout_constraintBottom_toTopOf="@+id/bottomNavigationView"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/activeCallView" />
|
app:layout_constraintTop_toBottomOf="@+id/activeCallView" />
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue