rename changeContinueButtonEnabled and clear resources
This commit is contained in:
parent
7d0f4d314c
commit
cab3ef3f72
3 changed files with 16 additions and 24 deletions
|
@ -17,7 +17,7 @@
|
|||
<shape android:shape="rectangle">
|
||||
<solid android:color="@null" />
|
||||
<corners android:radius="@dimen/dialog_button_radius" />
|
||||
<stroke android:width="1dp" android:color="#f0f0f0" />
|
||||
<stroke android:width="1dp" android:color="@color/ctrl_light" />
|
||||
</shape>
|
||||
</item>
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
<resources>
|
||||
<string name="versionFeatures">+play_market -amazon -blackberry</string>
|
||||
<string name="get_telegram_title">Registration in Telegram</string>
|
||||
<string name="get_telegram_account_first">You need an account in Telegram to use the capabilities of OsmAnd Location Sharing.</string>
|
||||
<string name="get_telegram_description_continue">If you want to continue, please install the Telegram from Google Play and register your account.</string>
|
||||
|
|
|
@ -132,10 +132,7 @@ class LoginDialogFragment : DialogFragment() {
|
|||
showWelcomeDialog = args.getBoolean(SHOW_WELCOME_DIALOG_PARAM_KEY, false)
|
||||
}
|
||||
val view = inflater.inflate(R.layout.login_dialog, container)
|
||||
val button = view?.findViewById<Button>(R.id.continue_button)
|
||||
if (button != null) {
|
||||
continueButton = button
|
||||
}
|
||||
continueButton = view.findViewById(R.id.continue_button)
|
||||
|
||||
buildDialog(view)
|
||||
view.viewTreeObserver.addOnGlobalLayoutListener {
|
||||
|
@ -146,28 +143,25 @@ class LoginDialogFragment : DialogFragment() {
|
|||
val softKeyboardVisible = keypadHeight > screenHeight * SOFT_KEYBOARD_MIN_DETECTION_SIZE
|
||||
if (!softKeyboardShown && softKeyboardVisible) {
|
||||
softKeyboardShown = softKeyboardVisible
|
||||
setContinueButtonSize(true)
|
||||
transformContinueButton(true)
|
||||
} else if (softKeyboardShown && !softKeyboardVisible) {
|
||||
setContinueButtonSize(false)
|
||||
transformContinueButton(false)
|
||||
}
|
||||
softKeyboardShown = softKeyboardVisible
|
||||
}
|
||||
return view
|
||||
}
|
||||
|
||||
private fun setContinueButtonSize(isWide: Boolean) {
|
||||
val params = continueButton.layoutParams
|
||||
if (params is ViewGroup.MarginLayoutParams) {
|
||||
if (isWide) {
|
||||
params.setMargins(params.leftMargin, params.topMargin, params.rightMargin, AndroidUtils.dpToPx(context!!, 16F))
|
||||
params.width = ViewGroup.LayoutParams.MATCH_PARENT
|
||||
} else {
|
||||
params.setMargins(params.leftMargin, params.topMargin, params.rightMargin, AndroidUtils.dpToPx(context!!, 40F))
|
||||
params.width = ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
private fun transformContinueButton(expanded: Boolean) {
|
||||
val params = continueButton.layoutParams as ViewGroup.MarginLayoutParams
|
||||
val margin = if (expanded) 16f else 40f
|
||||
val width = if (expanded) ViewGroup.LayoutParams.MATCH_PARENT else ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
params.apply {
|
||||
setMargins(leftMargin, topMargin, rightMargin, AndroidUtils.dpToPx(context!!, margin))
|
||||
this.width = width
|
||||
}
|
||||
continueButton.requestLayout()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
return object : Dialog(requireActivity(), theme) {
|
||||
|
@ -385,11 +379,10 @@ class LoginDialogFragment : DialogFragment() {
|
|||
}
|
||||
|
||||
private fun changeContinueButtonEnabled(enabled: Boolean) {
|
||||
if (enabled) {
|
||||
continueButton.setTextColor(ContextCompat.getColor(context!!, R.color.white))
|
||||
} else {
|
||||
continueButton.setTextColor(ContextCompat.getColor(context!!, R.color.secondary_text_light))
|
||||
}
|
||||
if (enabled != continueButton.isEnabled) {
|
||||
val color = if (enabled) R.color.white else R.color.secondary_text_light
|
||||
continueButton.setTextColor(ContextCompat.getColor(context!!, color))
|
||||
continueButton.isEnabled = enabled
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue