Merge pull request #5992 from osmandapp/TelegramUiImprovements
Ui improvements
This commit is contained in:
commit
8f3f00de88
8 changed files with 202 additions and 17 deletions
86
OsmAnd-telegram/res/layout/bottom_sheet_logout.xml
Normal file
86
OsmAnd-telegram/res/layout/bottom_sheet_logout.xml
Normal file
|
@ -0,0 +1,86 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
tools:layout_gravity="bottom">
|
||||
|
||||
<android.support.design.widget.CoordinatorLayout
|
||||
android:id="@+id/scroll_view_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<android.support.v4.widget.NestedScrollView
|
||||
android:id="@+id/scroll_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:behavior_hideable="true"
|
||||
app:behavior_peekHeight="@dimen/bottom_sheet_peek_height"
|
||||
app:layout_behavior="@string/bottom_sheet_behavior">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/card_bg_color"
|
||||
android:orientation="vertical">
|
||||
|
||||
<net.osmand.telegram.ui.views.TextViewEx
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="@dimen/content_padding_standard"
|
||||
android:paddingRight="@dimen/content_padding_standard"
|
||||
android:text="@string/logout_from_osmand_telegram"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:textSize="@dimen/list_item_title_text_size"
|
||||
app:firstBaselineToTopHeight="28sp"
|
||||
app:typeface="@string/font_roboto_medium" />
|
||||
|
||||
<net.osmand.telegram.ui.views.TextViewEx
|
||||
android:id="@+id/description"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="@dimen/content_padding_standard"
|
||||
android:paddingRight="@dimen/content_padding_standard"
|
||||
android:text="@string/logout_from_osmand_telegram_descr"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:textSize="@dimen/list_item_description_text_size"
|
||||
app:firstBaselineToTopHeight="28sp"
|
||||
app:lastBaselineToBottomHeight="16sp"
|
||||
app:typeface="@string/font_roboto_regular" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</android.support.v4.widget.NestedScrollView>
|
||||
|
||||
</android.support.design.widget.CoordinatorLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/buttons_bottom_bar_height"
|
||||
android:background="?attr/card_bg_color"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingLeft="@dimen/content_padding_half"
|
||||
android:paddingRight="@dimen/content_padding_half">
|
||||
|
||||
<include
|
||||
layout="@layout/secondary_btn"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1" />
|
||||
|
||||
<View
|
||||
android:layout_width="@dimen/content_padding_half"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
<include
|
||||
layout="@layout/primary_btn"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
|
@ -250,9 +250,9 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom|center_horizontal"
|
||||
android:background="@drawable/extended_fab_bg"
|
||||
android:drawableLeft="@drawable/ic_group"
|
||||
android:drawableLeft="@drawable/ic_action_share_location"
|
||||
android:drawablePadding="@dimen/content_padding_half"
|
||||
android:drawableStart="@drawable/ic_group"
|
||||
android:drawableStart="@drawable/ic_action_share_location"
|
||||
android:gravity="center"
|
||||
android:paddingLeft="32dp"
|
||||
android:paddingRight="32dp"
|
||||
|
|
|
@ -20,8 +20,8 @@
|
|||
<dimen name="dialog_button_height">36dp</dimen>
|
||||
<dimen name="dialog_button_radius">4dp</dimen>
|
||||
<dimen name="dialog_button_bottom_padding">40dp</dimen>
|
||||
<dimen name="dialog_welcome_title_bottom_padding">70dp</dimen>
|
||||
<dimen name="dialog_welcome_title_top_margin">85dp</dimen>
|
||||
<dimen name="dialog_welcome_title_bottom_padding">78dp</dimen>
|
||||
<dimen name="dialog_welcome_title_top_margin">89dp</dimen>
|
||||
|
||||
<dimen name="list_header_height">48dp</dimen>
|
||||
|
||||
|
@ -70,7 +70,7 @@
|
|||
<dimen name="dialog_title_text_size">22sp</dimen>
|
||||
|
||||
<dimen name="title_text_size">18sp</dimen>
|
||||
<dimen name="title_login_text_size">20sp</dimen>
|
||||
<dimen name="title_login_text_size">22sp</dimen>
|
||||
<dimen name="title_welcome_text_size">32sp</dimen>
|
||||
<dimen name="descr_text_size">16sp</dimen>
|
||||
<dimen name="hint_text_size">14sp</dimen>
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<resources>
|
||||
<string name="logout_from_osmand_telegram_descr">Are you sure you want to log out of OsmAnd Telegram? After that, you will not be able to send your position and see the locations of your contacts on the map in OsmAnd.</string>
|
||||
<string name="logout_from_osmand_telegram">Logout from OsmAnd Telegram?</string>
|
||||
<string name="shared_string_name">Name</string>
|
||||
<string name="by_distance">By distance</string>
|
||||
<string name="by_name">By name</string>
|
||||
|
|
|
@ -327,16 +327,23 @@ class LoginDialogFragment : BaseDialogFragment() {
|
|||
val cancelButton: AppCompatImageView? = view?.findViewById(R.id.back_button)
|
||||
cancelButton?.visibility = if (showWelcomeDialog) View.INVISIBLE else View.VISIBLE
|
||||
cancelButton?.setOnClickListener {
|
||||
if (loginDialogActiveType == LoginDialogType.ENTER_PHONE_NUMBER) {
|
||||
showWelcomeDialog = true
|
||||
val focusedView = dialog.currentFocus
|
||||
if (focusedView != null) {
|
||||
AndroidUtils.hideSoftKeyboard(activity!!, focusedView)
|
||||
when (loginDialogActiveType) {
|
||||
LoginDialogType.ENTER_PHONE_NUMBER -> {
|
||||
showWelcomeDialog = true
|
||||
val focusedView = dialog.currentFocus
|
||||
if (focusedView != null) {
|
||||
AndroidUtils.hideSoftKeyboard(activity!!, focusedView)
|
||||
}
|
||||
buildDialog(view)
|
||||
}
|
||||
LoginDialogType.GET_TELEGRAM -> {
|
||||
this.loginDialogActiveType = LoginDialogType.ENTER_PHONE_NUMBER
|
||||
buildDialog(view)
|
||||
}
|
||||
else -> {
|
||||
showProgress()
|
||||
getMainActivity()?.loginTelegram()
|
||||
}
|
||||
buildDialog(view)
|
||||
} else {
|
||||
showProgress()
|
||||
getMainActivity()?.loginTelegram()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,76 @@
|
|||
package net.osmand.telegram.ui
|
||||
|
||||
import android.os.Bundle
|
||||
import android.support.design.widget.BottomSheetBehavior
|
||||
import android.support.v4.app.DialogFragment
|
||||
import android.support.v4.app.Fragment
|
||||
import android.support.v4.app.FragmentManager
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.TextView
|
||||
import net.osmand.telegram.R
|
||||
import net.osmand.telegram.ui.views.BottomSheetDialog
|
||||
|
||||
class LogoutBottomSheet : DialogFragment() {
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?) = BottomSheetDialog(context!!)
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
val mainView = inflater.inflate(R.layout.bottom_sheet_logout, container, false)
|
||||
|
||||
mainView.findViewById<View>(R.id.scroll_view_container).setOnClickListener { dismiss() }
|
||||
|
||||
BottomSheetBehavior.from(mainView.findViewById<View>(R.id.scroll_view))
|
||||
.setBottomSheetCallback(object : BottomSheetBehavior.BottomSheetCallback() {
|
||||
|
||||
override fun onStateChanged(bottomSheet: View, newState: Int) {
|
||||
if (newState == BottomSheetBehavior.STATE_HIDDEN) {
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onSlide(bottomSheet: View, slideOffset: Float) {}
|
||||
})
|
||||
|
||||
mainView.findViewById<TextView>(R.id.secondary_btn).apply {
|
||||
setText(R.string.shared_string_cancel)
|
||||
setOnClickListener { dismiss() }
|
||||
}
|
||||
|
||||
mainView.findViewById<TextView>(R.id.primary_btn).apply {
|
||||
setText(R.string.shared_string_logout)
|
||||
setOnClickListener {
|
||||
targetFragment?.also { target ->
|
||||
target.onActivityResult(targetRequestCode, LOGOUT_REQUEST_CODE, null)
|
||||
}
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
|
||||
return mainView
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
const val LOGOUT_REQUEST_CODE = 4
|
||||
|
||||
private const val TAG = "DisableSharingBottomSheet"
|
||||
|
||||
fun showInstance(fm: FragmentManager, target: Fragment): Boolean {
|
||||
return try {
|
||||
LogoutBottomSheet().apply {
|
||||
setTargetFragment(target, LOGOUT_REQUEST_CODE)
|
||||
show(fm, TAG)
|
||||
}
|
||||
true
|
||||
} catch (e: RuntimeException) {
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package net.osmand.telegram.ui
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.support.v4.app.FragmentManager
|
||||
import android.support.v7.widget.ListPopupWindow
|
||||
|
@ -108,8 +109,10 @@ class SettingsDialogFragment : BaseDialogFragment() {
|
|||
}
|
||||
|
||||
mainView.findViewById<View>(R.id.logout_btn).setOnClickListener {
|
||||
logoutTelegram()
|
||||
dismiss()
|
||||
fragmentManager?.also { fm ->
|
||||
LogoutBottomSheet.showInstance(fm, this)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
mainView.findViewById<ImageView>(R.id.help_icon)
|
||||
|
@ -121,6 +124,16 @@ class SettingsDialogFragment : BaseDialogFragment() {
|
|||
return mainView
|
||||
}
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
when (requestCode) {
|
||||
LogoutBottomSheet.LOGOUT_REQUEST_CODE -> {
|
||||
logoutTelegram()
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun showPopupMenu(pref: DurationPref, valueView: TextView) {
|
||||
val menuList = pref.getMenuItems()
|
||||
val ctx = valueView.context
|
||||
|
|
|
@ -223,7 +223,8 @@ public class OsmEditingPlugin extends OsmandPlugin {
|
|||
isEditable = !amenity.getType().isWiki() && poiType !=null && !poiType.isNotEditableOsm();
|
||||
} else if (selectedObj instanceof MapObject) {
|
||||
Long objectId = ((MapObject) selectedObj).getId();
|
||||
isEditable = objectId != null && objectId > 0 && (objectId % 2 == 1 || (objectId >> 7) < Integer.MAX_VALUE);
|
||||
isEditable = objectId != null && objectId > 0 && (objectId % 2 == MapObject.AMENITY_ID_RIGHT_SHIFT
|
||||
|| (objectId >> MapObject.NON_AMENITY_ID_RIGHT_SHIFT) < Integer.MAX_VALUE);
|
||||
}
|
||||
if (isEditable) {
|
||||
adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.poi_context_menu_modify, mapActivity)
|
||||
|
|
Loading…
Reference in a new issue