Skip to content

Commit

Permalink
Added ui elements to hide layer and show list of Explore places points
Browse files Browse the repository at this point in the history
  • Loading branch information
Corwin-Kh committed Feb 26, 2025
1 parent f32ac38 commit 967fecd
Show file tree
Hide file tree
Showing 5 changed files with 169 additions and 69 deletions.
152 changes: 111 additions & 41 deletions OsmAnd/res/layout/fragment_nearby_places.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/activity_background_color"
android:background="@null"
android:orientation="vertical">

<com.google.android.material.appbar.AppBarLayout
Expand All @@ -23,57 +23,127 @@
android:visibility="visible"
app:title="@string/popular_places_nearby" />

<!-- <LinearLayout-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="@dimen/context_menu_buttons_bottom_height"-->
<!-- android:background="?attr/activity_background_color"-->
<!-- android:orientation="horizontal">-->

<!-- <ImageView-->
<!-- android:id="@+id/location_icon"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_gravity="center_vertical"-->
<!-- android:layout_marginStart="@dimen/content_padding"-->
<!-- android:src="@drawable/ic_action_marker_dark" />-->

<!-- <net.osmand.plus.widgets.TextViewEx-->
<!-- android:id="@+id/show_on_map"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_gravity="center_vertical|start"-->
<!-- android:layout_marginStart="@dimen/content_padding"-->
<!-- android:paddingTop="@dimen/list_header_padding"-->
<!-- android:paddingBottom="@dimen/list_header_padding"-->
<!-- android:text="@string/shared_string_show_on_map"-->
<!-- android:textAllCaps="true"-->
<!-- android:textColor="?attr/active_color_basic"-->
<!-- android:textSize="@dimen/default_desc_text_size"-->
<!-- app:typefaceWeight="medium"-->
<!-- tools:text="SHOW ALL"-->
<!-- tools:visibility="visible" />-->

<!-- </LinearLayout>-->

</com.google.android.material.appbar.AppBarLayout>

<FrameLayout
android:id="@+id/frame_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">

<LinearLayout
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="@dimen/context_menu_buttons_bottom_height"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="?attr/activity_background_color"
android:orientation="horizontal">
android:orientation="vertical">

<ImageView
android:id="@+id/location_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="@dimen/content_padding"
android:src="@drawable/ic_action_marker_dark" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="@dimen/context_menu_buttons_bottom_height"
android:background="?attr/activity_background_color"
android:orientation="horizontal">

<net.osmand.plus.widgets.TextViewEx
android:id="@+id/show_on_map"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|start"
android:layout_marginStart="@dimen/content_padding"
android:paddingTop="@dimen/list_header_padding"
android:paddingBottom="@dimen/list_header_padding"
android:text="@string/shared_string_show_on_map"
android:textAllCaps="true"
android:textColor="?attr/active_color_basic"
android:textSize="@dimen/default_desc_text_size"
app:typefaceWeight="medium"
tools:text="SHOW ALL"
tools:visibility="visible" />
<ImageView
android:id="@+id/location_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="@dimen/content_padding"
android:src="@drawable/ic_action_marker_dark" />

</LinearLayout>
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/show_on_map"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|start"
android:layout_marginStart="@dimen/content_padding"
android:paddingTop="@dimen/list_header_padding"
android:paddingBottom="@dimen/list_header_padding"
android:text="@string/shared_string_show_on_map"
android:textAllCaps="true"
android:textColor="?attr/active_color_basic"
android:textSize="@dimen/default_desc_text_size"
app:typefaceWeight="medium"
tools:text="SHOW ALL"
tools:visibility="visible" />
</LinearLayout>

</com.google.android.material.appbar.AppBarLayout>
<LinearLayout
android:id="@+id/main_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
tools:ignore="UselessParent">

<LinearLayout
android:id="@+id/main_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:orientation="vertical"
tools:ignore="UselessParent">
<include layout="@layout/card_bottom_divider" />

<include layout="@layout/card_bottom_divider" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/vertical_nearby_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:paddingTop="@dimen/content_padding" />
</LinearLayout>
</LinearLayout>

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/vertical_nearby_list"
<!-- Show list button -->
<FrameLayout
android:id="@+id/show_list_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:paddingTop="@dimen/content_padding" />
android:layout_height="wrap_content"
android:layout_gravity="bottom|start"
android:background="?attr/list_background_color"
android:visibility="gone">

</LinearLayout>
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/show_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/text_margin_small"
android:layout_marginTop="@dimen/content_padding_small_half"
android:layout_marginBottom="@dimen/content_padding_small_half"
android:background="?attr/list_background_color"
android:padding="@dimen/content_padding_half"
android:text="@string/show_list"
android:textColor="?attr/active_color_basic"
android:textSize="@dimen/default_desc_text_size"

app:typefaceWeight="medium"
tools:text="Show list" />

</FrameLayout>
</FrameLayout>
</LinearLayout>
1 change: 1 addition & 0 deletions OsmAnd/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- For wording and consistency, please note https://docs.osmand.net/docs/technical/contributions/translating-osmand
Thx - Hardy
-->
<string name="show_list">Show list</string>
<string name="save_favorite_default_appearance">Apply changes to the existing points in the folder or only to new ones?</string>
<string name="original_color_description">Each point would keep its own color.</string>
<string name="original_icon_description">Each point would keep its own icon.</string>
Expand Down
69 changes: 46 additions & 23 deletions OsmAnd/src/net/osmand/plus/exploreplaces/ExplorePlacesFragment.kt
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
package net.osmand.plus.exploreplaces

import android.os.Bundle
import android.view.Gravity
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.animation.AccelerateInterpolator
import android.widget.FrameLayout
import android.widget.ImageView
import android.widget.LinearLayout
import androidx.annotation.ColorRes
import androidx.appcompat.widget.Toolbar
import androidx.fragment.app.FragmentManager
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import androidx.transition.Slide
import androidx.transition.TransitionManager
import net.osmand.Location
import net.osmand.PlatformUtil
import net.osmand.data.ExploreTopPlacePoint
Expand All @@ -24,17 +30,24 @@ import net.osmand.plus.helpers.AndroidUiHelper
import net.osmand.plus.search.NearbyPlacesAdapter
import net.osmand.plus.utils.AndroidUtils
import net.osmand.plus.utils.ColorUtilities
import net.osmand.plus.widgets.TextViewEx
import org.apache.commons.logging.Log

class ExplorePlacesFragment : BaseOsmAndFragment(), NearbyPlacesAdapter.NearbyItemClickListener, OsmAndLocationListener, OsmAndCompassListener {
class ExplorePlacesFragment : BaseOsmAndFragment(), NearbyPlacesAdapter.NearbyItemClickListener,
OsmAndLocationListener, OsmAndCompassListener {

private val HIDE_LIST_DURATION = 150L
private val SHOW_LIST_DURATION = 150L
private lateinit var visiblePlacesRect: QuadRect
private val log: Log = PlatformUtil.getLog(
ExplorePlacesFragment::class.java)

private lateinit var verticalNearbyAdapter: NearbyPlacesAdapter
private var location: Location? = null
private var heading: Float? = null
private var mainContent: LinearLayout? = null
private var showListContainer: View? = null
private var frameLayout: FrameLayout? = null

override fun getContentStatusBarNightMode(): Boolean {
return nightMode
Expand All @@ -59,6 +72,9 @@ class ExplorePlacesFragment : BaseOsmAndFragment(), NearbyPlacesAdapter.NearbyIt
val bottom = it.getDouble("bottom")
visiblePlacesRect = QuadRect(left, top, right, bottom) // Create QuadRect
}
mainContent = view.findViewById(R.id.main_content)
showListContainer = view.findViewById(R.id.show_list_container)
frameLayout = view.findViewById(R.id.frame_layout)
setupShowAll(view)
setupToolBar(view)
setupVerticalNearbyList(view)
Expand All @@ -67,23 +83,16 @@ class ExplorePlacesFragment : BaseOsmAndFragment(), NearbyPlacesAdapter.NearbyIt
}

fun onBackPress(): Boolean {
if (isHidden) {
if (mapActivity?.contextMenu?.isVisible == true) {
mapActivity?.contextMenu?.hideMenus()
} else {
activity?.supportFragmentManager?.beginTransaction()
?.show(this@ExplorePlacesFragment)
?.commit()
}
return true
if (mainContent?.visibility == View.GONE) {
showList()
} else {
val quickSearchFragment = mapActivity?.fragmentsHelper?.quickSearchDialogFragment
quickSearchFragment?.show()
activity?.supportFragmentManager?.beginTransaction()
?.remove(this@ExplorePlacesFragment)
?.commit()
return true
}
return true
}

override fun onResume() {
Expand Down Expand Up @@ -113,10 +122,13 @@ class ExplorePlacesFragment : BaseOsmAndFragment(), NearbyPlacesAdapter.NearbyIt
private fun setupShowAll(view: View) {
view.findViewById<ImageView>(R.id.location_icon)
.setImageDrawable(uiUtilities.getIcon(R.drawable.ic_action_marker_dark, nightMode))

val showList = view.findViewById<TextViewEx>(R.id.show_list)
view.findViewById<View>(R.id.show_on_map).setOnClickListener {
app.osmandMap.mapLayers.explorePlacesLayer.enableLayer(true)
hide()
hideList()
}
showList.setOnClickListener {
showList()
}
}

Expand All @@ -133,12 +145,7 @@ class ExplorePlacesFragment : BaseOsmAndFragment(), NearbyPlacesAdapter.NearbyIt
getIcon(R.drawable.ic_arrow_back, ColorUtilities.getPrimaryIconColorId(nightMode))
toolbar.setNavigationContentDescription(R.string.shared_string_close)
toolbar.setNavigationOnClickListener { v: View? ->
val mapActivity = mapActivity
requireActivity().onBackPressed()
if (mapActivity != null) {
val searchDialog = mapActivity.fragmentsHelper.quickSearchDialogFragment
searchDialog?.show()
}
}
}

Expand Down Expand Up @@ -182,13 +189,29 @@ class ExplorePlacesFragment : BaseOsmAndFragment(), NearbyPlacesAdapter.NearbyIt
override fun onNearbyItemClicked(item: ExploreTopPlacePoint) {
mapActivity?.let {
app.explorePlacesProvider.showPointInContextMenu(it, item)
hide()
hideList()
}
}

fun hide() {
val transaction = activity?.supportFragmentManager?.beginTransaction()
transaction?.hide(this)
transaction?.commit()
private fun hideList() {
frameLayout?.let {
TransitionManager.beginDelayedTransition(it, Slide(Gravity.BOTTOM).apply {
duration = HIDE_LIST_DURATION
interpolator = AccelerateInterpolator()
})
}
mainContent?.visibility = View.GONE
showListContainer?.visibility = View.VISIBLE
}

private fun showList() {
frameLayout?.let {
TransitionManager.beginDelayedTransition(it, Slide(Gravity.BOTTOM).apply {
duration = SHOW_LIST_DURATION
interpolator = AccelerateInterpolator()
})
}
mainContent?.visibility = View.VISIBLE
showListContainer?.visibility = View.GONE
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@
import java.util.List;
import java.util.Set;

// TODO use gzip in loading
// TODO errors shouldn'go with empty response "" into cache!
// TODO remove checks poi type subtype null
// TODO use gzip in loading +
// TODO errors shouldn'go with empty response "" into cache! +
// TODO remove checks poi type subtype null +
// TODO display all data downloaded even if maps are not loaded
// TODO: why recreate provider when new points are loaded? that causes blinking
// TODO: scheduleImageRefreshes in layer is incorrect it starts downloading all images and stops interacting
// TODO images shouldn't be queried if they are not visible in all lists! size doesn't matter !
// TODO show on map close button is not visible
// TODO layer sometimes becomes non-interactive - MAP FPS drops
// TODO Context menu doesn't work correctly and duplicates actual POI
// TODO compass is not rotating
// TODO Context menu doesn't work correctly and duplicates actual POI +
// TODO compass is not rotating +
// Extra: display new categories from web
public class ExplorePlacesProviderJava implements ExplorePlacesProvider {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ public void onCreate(SQLiteDatabase db) {
db.execSQL(CREATE_TABLE_PLACES);
}

@Override
public void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.execSQL("DROP TABLE IF EXISTS " + TABLE_PLACES);
onCreate(db);
}

@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
if (oldVersion < 2) {
Expand Down

0 comments on commit 967fecd

Please sign in to comment.