Merge pull request #6870 from osmandapp/TrackerSearchImprovements
Tracker search UI improvements
This commit is contained in:
commit
73a91757ea
6 changed files with 89 additions and 25 deletions
|
@ -5,6 +5,7 @@
|
|||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true"
|
||||
android:orientation="vertical">
|
||||
|
||||
<android.support.design.widget.AppBarLayout
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true"
|
||||
android:orientation="vertical">
|
||||
|
||||
<android.support.design.widget.AppBarLayout
|
||||
|
|
|
@ -217,8 +217,13 @@ class LoginDialogFragment : BaseDialogFragment() {
|
|||
welcomeImage?.visibility = View.GONE
|
||||
}
|
||||
|
||||
val continueButton = view?.findViewById<Button>(R.id.welcome_continue_button)
|
||||
continueButton?.setOnClickListener {
|
||||
view?.findViewById<Button>(R.id.welcome_continue_button)?.apply {
|
||||
val params = layoutParams as ViewGroup.MarginLayoutParams
|
||||
val bottomMargin = AndroidUtils.getNavBarHeight(context) + resources.getDimensionPixelSize(R.dimen.dialog_button_bottom_padding)
|
||||
params.apply {
|
||||
setMargins(leftMargin, topMargin, rightMargin, bottomMargin)
|
||||
}
|
||||
setOnClickListener {
|
||||
showWelcomeDialog = false
|
||||
if (!privacyPolicyAgreed) {
|
||||
loginDialogActiveType = LoginDialogType.PRIVACY_POLICY
|
||||
|
@ -229,6 +234,7 @@ class LoginDialogFragment : BaseDialogFragment() {
|
|||
}
|
||||
buildDialog(view)
|
||||
}
|
||||
}
|
||||
view?.findViewById<View>(R.id.login_layout)?.visibility = View.GONE
|
||||
view?.findViewById<View>(R.id.welcome_layout)?.visibility = View.VISIBLE
|
||||
} else {
|
||||
|
|
|
@ -2,9 +2,11 @@ package net.osmand.telegram.ui
|
|||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Intent
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.support.v4.app.Fragment
|
||||
import android.support.v4.app.FragmentManager
|
||||
import android.support.v4.content.ContextCompat
|
||||
import android.support.v7.widget.LinearLayoutManager
|
||||
import android.support.v7.widget.RecyclerView
|
||||
import android.support.v7.widget.Toolbar
|
||||
|
@ -64,14 +66,14 @@ class SearchDialogFragment : BaseDialogFragment(), TelegramHelper.TelegramSearch
|
|||
): View {
|
||||
val mainView = inflater.inflate(R.layout.fragment_search_dialog, parent)
|
||||
|
||||
val appBarLayout = mainView.findViewById<View>(R.id.app_bar_layout)
|
||||
AndroidUtils.addStatusBarPadding19v(context!!, appBarLayout)
|
||||
|
||||
mainView.findViewById<Toolbar>(R.id.toolbar).apply {
|
||||
navigationIcon = uiUtils.getThemedIcon(R.drawable.ic_arrow_back)
|
||||
setNavigationOnClickListener { dismiss() }
|
||||
}
|
||||
|
||||
val window = dialog.window
|
||||
if (window != null && Build.VERSION.SDK_INT >= 21) {
|
||||
window.statusBarColor = ContextCompat.getColor(app, R.color.card_bg_light)
|
||||
}
|
||||
searchEditText = mainView.findViewById<EditText>(R.id.searchEditText).apply {
|
||||
addTextChangedListener(object : TextWatcher {
|
||||
|
||||
|
@ -104,7 +106,11 @@ class SearchDialogFragment : BaseDialogFragment(), TelegramHelper.TelegramSearch
|
|||
addOnScrollListener(object : RecyclerView.OnScrollListener() {
|
||||
override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) {
|
||||
super.onScrollStateChanged(recyclerView, newState)
|
||||
locationUiUpdateAllowed = newState == RecyclerView.SCROLL_STATE_IDLE
|
||||
val scrolling = newState != RecyclerView.SCROLL_STATE_IDLE
|
||||
locationUiUpdateAllowed = !scrolling
|
||||
if (scrolling) {
|
||||
hideKeyboard()
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -127,6 +133,13 @@ class SearchDialogFragment : BaseDialogFragment(), TelegramHelper.TelegramSearch
|
|||
return mainView
|
||||
}
|
||||
|
||||
private fun hideKeyboard() {
|
||||
val mainActivity = activity
|
||||
if (mainActivity != null && searchEditText.hasFocus()) {
|
||||
AndroidUtils.hideSoftKeyboard(mainActivity, searchEditText)
|
||||
}
|
||||
}
|
||||
|
||||
private fun clearSearchedItems() {
|
||||
searchedChatsIds.clear()
|
||||
searchedPublicChatsIds.clear()
|
||||
|
@ -200,7 +213,7 @@ class SearchDialogFragment : BaseDialogFragment(), TelegramHelper.TelegramSearch
|
|||
|
||||
private fun updateLocationUi() {
|
||||
if (locationUiUpdateAllowed) {
|
||||
app.runInUIThread { updateList() }
|
||||
app.runInUIThread { adapter.notifyDataSetChanged() }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -211,9 +224,28 @@ class SearchDialogFragment : BaseDialogFragment(), TelegramHelper.TelegramSearch
|
|||
val users: MutableList<TdApi.User> = mutableListOf()
|
||||
val currentUserId = telegramHelper.getCurrentUserId()
|
||||
|
||||
searchedChatsIds.forEach {
|
||||
selectedChats.forEach {
|
||||
val chat = telegramHelper.getChat(it)
|
||||
if (chat != null) {
|
||||
if (!telegramHelper.isChannel(chat) && telegramHelper.getUserIdFromChatType(chat.type) != currentUserId) {
|
||||
items.add(chat)
|
||||
}
|
||||
} else {
|
||||
telegramHelper.requestChat(it)
|
||||
}
|
||||
}
|
||||
selectedUsers.forEach {
|
||||
val user = telegramHelper.getUser(it.toInt())
|
||||
if (user != null) {
|
||||
if (user.id != currentUserId)
|
||||
items.add(user)
|
||||
} else {
|
||||
telegramHelper.requestUser(it.toInt())
|
||||
}
|
||||
}
|
||||
searchedChatsIds.forEach {
|
||||
val chat = telegramHelper.getChat(it)
|
||||
if (chat != null && !selectedChats.contains(it)) {
|
||||
if (!telegramHelper.isChannel(chat) && telegramHelper.getUserIdFromChatType(chat.type) != currentUserId) {
|
||||
chats.add(chat)
|
||||
}
|
||||
|
@ -225,7 +257,7 @@ class SearchDialogFragment : BaseDialogFragment(), TelegramHelper.TelegramSearch
|
|||
|
||||
searchedContactsIds.forEach { userId ->
|
||||
val user = telegramHelper.getUser(userId)
|
||||
if (user != null) {
|
||||
if (user != null && !selectedUsers.contains(userId.toLong())) {
|
||||
if (user.id != currentUserId && !chats.any { telegramHelper.getUserIdFromChatType(it.type) == user.id })
|
||||
users.add(user)
|
||||
} else {
|
||||
|
@ -236,9 +268,8 @@ class SearchDialogFragment : BaseDialogFragment(), TelegramHelper.TelegramSearch
|
|||
|
||||
searchedPublicChatsIds.forEach {
|
||||
val chat = telegramHelper.getChat(it)
|
||||
if (chat != null) {
|
||||
if (!telegramHelper.isChannel(chat) && !chats.contains(chat)
|
||||
&& telegramHelper.getUserIdFromChatType(chat.type) != currentUserId) {
|
||||
if (chat != null && !selectedChats.contains(it) && !searchedChatsIds.contains(it)) {
|
||||
if (!telegramHelper.isChannel(chat) && telegramHelper.getUserIdFromChatType(chat.type) != currentUserId) {
|
||||
publicChats.add(chat)
|
||||
}
|
||||
} else {
|
||||
|
@ -370,6 +401,9 @@ class SearchDialogFragment : BaseDialogFragment(), TelegramHelper.TelegramSearch
|
|||
} else {
|
||||
selectedUsers.remove(itemId)
|
||||
}
|
||||
if (!(searchedChatsIds.contains(itemId) || searchedPublicChatsIds.contains(itemId) || searchedContactsIds.contains(itemId.toInt()))) {
|
||||
updateList()
|
||||
}
|
||||
}
|
||||
switchButtonsVisibility(selectedChats.isNotEmpty() || selectedUsers.isNotEmpty())
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import android.graphics.drawable.Drawable
|
|||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.support.v4.app.FragmentManager
|
||||
import android.support.v4.content.ContextCompat
|
||||
import android.support.v7.widget.ListPopupWindow
|
||||
import android.support.v7.widget.Toolbar
|
||||
import android.text.SpannableStringBuilder
|
||||
|
@ -39,14 +40,14 @@ class SettingsDialogFragment : BaseDialogFragment() {
|
|||
): View {
|
||||
val mainView = inflater.inflate(R.layout.fragement_settings_dialog, parent)
|
||||
|
||||
val appBarLayout = mainView.findViewById<View>(R.id.app_bar_layout)
|
||||
AndroidUtils.addStatusBarPadding19v(context!!, appBarLayout)
|
||||
|
||||
mainView.findViewById<Toolbar>(R.id.toolbar).apply {
|
||||
navigationIcon = uiUtils.getThemedIcon(R.drawable.ic_arrow_back)
|
||||
setNavigationOnClickListener { dismiss() }
|
||||
}
|
||||
|
||||
val window = dialog.window
|
||||
if (window != null && Build.VERSION.SDK_INT >= 21) {
|
||||
window.statusBarColor = ContextCompat.getColor(app, R.color.card_bg_light)
|
||||
}
|
||||
var container = mainView.findViewById<ViewGroup>(R.id.gps_and_loc_container)
|
||||
for (pref in settings.gpsAndLocPrefs) {
|
||||
inflater.inflate(R.layout.item_with_desc_and_right_value, container, false).apply {
|
||||
|
|
|
@ -106,6 +106,27 @@ object AndroidUtils {
|
|||
}
|
||||
}
|
||||
|
||||
fun getNavBarHeight(ctx: Context): Int {
|
||||
if (!hasNavBar(ctx)) {
|
||||
return 0
|
||||
}
|
||||
val landscape = ctx.resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE
|
||||
val isSmartphone = ctx.resources.configuration.smallestScreenWidthDp < 600
|
||||
if (isSmartphone && landscape) {
|
||||
return 0
|
||||
}
|
||||
val name = if (landscape) "navigation_bar_height_landscape" else "navigation_bar_height"
|
||||
val id = ctx.resources.getIdentifier(name, "dimen", "android")
|
||||
return if (id > 0) {
|
||||
ctx.resources.getDimensionPixelSize(id)
|
||||
} else 0
|
||||
}
|
||||
|
||||
fun hasNavBar(ctx: Context): Boolean {
|
||||
val id = ctx.resources.getIdentifier("config_showNavigationBar", "bool", "android")
|
||||
return id > 0 && ctx.resources.getBoolean(id)
|
||||
}
|
||||
|
||||
fun enterToTransparentFullScreen(activity: Activity) {
|
||||
if (Build.VERSION.SDK_INT >= 23) {
|
||||
val window = activity.window
|
||||
|
|
Loading…
Reference in a new issue