rename changeContinueButtonEnabled and clear resources

This commit is contained in:
Chumva 2018-07-09 16:17:39 +03:00
parent 7d0f4d314c
commit cab3ef3f72
3 changed files with 16 additions and 24 deletions

View file

@ -17,7 +17,7 @@
<shape android:shape="rectangle"> <shape android:shape="rectangle">
<solid android:color="@null" /> <solid android:color="@null" />
<corners android:radius="@dimen/dialog_button_radius" /> <corners android:radius="@dimen/dialog_button_radius" />
<stroke android:width="1dp" android:color="#f0f0f0" /> <stroke android:width="1dp" android:color="@color/ctrl_light" />
</shape> </shape>
</item> </item>

View file

@ -1,5 +1,4 @@
<resources> <resources>
<string name="versionFeatures">+play_market -amazon -blackberry</string>
<string name="get_telegram_title">Registration in Telegram</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_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> <string name="get_telegram_description_continue">If you want to continue, please install the Telegram from Google Play and register your account.</string>

View file

@ -132,10 +132,7 @@ class LoginDialogFragment : DialogFragment() {
showWelcomeDialog = args.getBoolean(SHOW_WELCOME_DIALOG_PARAM_KEY, false) showWelcomeDialog = args.getBoolean(SHOW_WELCOME_DIALOG_PARAM_KEY, false)
} }
val view = inflater.inflate(R.layout.login_dialog, container) val view = inflater.inflate(R.layout.login_dialog, container)
val button = view?.findViewById<Button>(R.id.continue_button) continueButton = view.findViewById(R.id.continue_button)
if (button != null) {
continueButton = button
}
buildDialog(view) buildDialog(view)
view.viewTreeObserver.addOnGlobalLayoutListener { view.viewTreeObserver.addOnGlobalLayoutListener {
@ -146,27 +143,24 @@ class LoginDialogFragment : DialogFragment() {
val softKeyboardVisible = keypadHeight > screenHeight * SOFT_KEYBOARD_MIN_DETECTION_SIZE val softKeyboardVisible = keypadHeight > screenHeight * SOFT_KEYBOARD_MIN_DETECTION_SIZE
if (!softKeyboardShown && softKeyboardVisible) { if (!softKeyboardShown && softKeyboardVisible) {
softKeyboardShown = softKeyboardVisible softKeyboardShown = softKeyboardVisible
setContinueButtonSize(true) transformContinueButton(true)
} else if (softKeyboardShown && !softKeyboardVisible) { } else if (softKeyboardShown && !softKeyboardVisible) {
setContinueButtonSize(false) transformContinueButton(false)
} }
softKeyboardShown = softKeyboardVisible softKeyboardShown = softKeyboardVisible
} }
return view return view
} }
private fun setContinueButtonSize(isWide: Boolean) { private fun transformContinueButton(expanded: Boolean) {
val params = continueButton.layoutParams val params = continueButton.layoutParams as ViewGroup.MarginLayoutParams
if (params is ViewGroup.MarginLayoutParams) { val margin = if (expanded) 16f else 40f
if (isWide) { val width = if (expanded) ViewGroup.LayoutParams.MATCH_PARENT else ViewGroup.LayoutParams.WRAP_CONTENT
params.setMargins(params.leftMargin, params.topMargin, params.rightMargin, AndroidUtils.dpToPx(context!!, 16F)) params.apply {
params.width = ViewGroup.LayoutParams.MATCH_PARENT setMargins(leftMargin, topMargin, rightMargin, AndroidUtils.dpToPx(context!!, margin))
} else { this.width = width
params.setMargins(params.leftMargin, params.topMargin, params.rightMargin, AndroidUtils.dpToPx(context!!, 40F))
params.width = ViewGroup.LayoutParams.WRAP_CONTENT
}
continueButton.requestLayout()
} }
continueButton.requestLayout()
} }
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
@ -385,11 +379,10 @@ class LoginDialogFragment : DialogFragment() {
} }
private fun changeContinueButtonEnabled(enabled: Boolean) { private fun changeContinueButtonEnabled(enabled: Boolean) {
if (enabled) { if (enabled != continueButton.isEnabled) {
continueButton.setTextColor(ContextCompat.getColor(context!!, R.color.white)) val color = if (enabled) R.color.white else R.color.secondary_text_light
} else { continueButton.setTextColor(ContextCompat.getColor(context!!, color))
continueButton.setTextColor(ContextCompat.getColor(context!!, R.color.secondary_text_light)) continueButton.isEnabled = enabled
} }
continueButton.isEnabled = enabled
} }
} }