mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-28 05:13:53 +01:00
Explore: Add 'Show in Nearby' 3-dots menu item. Only visible when Map tab is selected
This commit is contained in:
parent
a7da455ca4
commit
9a6f68374c
3 changed files with 46 additions and 3 deletions
|
|
@ -1,5 +1,7 @@
|
||||||
package fr.free.nrw.commons.explore;
|
package fr.free.nrw.commons.explore;
|
||||||
|
|
||||||
|
import static androidx.viewpager.widget.ViewPager.SCROLL_STATE_IDLE;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
|
|
@ -157,8 +159,8 @@ public class ExploreFragment extends CommonsDaggerSupportFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if fragment arguments contain data from Nearby map, indicating that the user navigated
|
* Checks if fragment arguments contain data from Nearby map. if present, then the user
|
||||||
* from Nearby using 'Show in Explore'.
|
* navigated from Nearby using 'Show in Explore'.
|
||||||
*
|
*
|
||||||
* @return true if user navigated from Nearby map
|
* @return true if user navigated from Nearby map
|
||||||
**/
|
**/
|
||||||
|
|
@ -194,7 +196,28 @@ public class ExploreFragment extends CommonsDaggerSupportFragment {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||||
inflater.inflate(R.menu.menu_search, menu);
|
inflater.inflate(R.menu.explore_fragment_menu, menu);
|
||||||
|
|
||||||
|
// if on Map tab, show all menu options, else only show search
|
||||||
|
binding.viewPager.addOnPageChangeListener(new OnPageChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onPageScrolled(int position, float positionOffset,
|
||||||
|
int positionOffsetPixels) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPageSelected(int position) {
|
||||||
|
MenuItem other = menu.findItem(R.id.list_item_show_in_nearby);
|
||||||
|
other.setVisible((position == 2));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPageScrollStateChanged(int state) {
|
||||||
|
if (state == SCROLL_STATE_IDLE && binding.viewPager.getCurrentItem() == 2) {
|
||||||
|
onPageSelected(2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
super.onCreateOptionsMenu(menu, inflater);
|
super.onCreateOptionsMenu(menu, inflater);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
19
app/src/main/res/menu/explore_fragment_menu.xml
Normal file
19
app/src/main/res/menu/explore_fragment_menu.xml
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
>
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_search"
|
||||||
|
android:title="@string/menu_search_button"
|
||||||
|
android:icon="?attr/search_icon"
|
||||||
|
android:orderInCategory="1"
|
||||||
|
app:showAsAction="ifRoom"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<item android:id="@+id/list_item_show_in_nearby"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:title="@string/show_in_nearby"
|
||||||
|
android:visible="false"
|
||||||
|
/>
|
||||||
|
</menu>
|
||||||
|
|
@ -870,4 +870,5 @@ Upload your first media by tapping on the add button.</string>
|
||||||
<string name="congratulations_all_pictures_in_this_album_have_been_either_uploaded_or_marked_as_not_for_upload">Congratulations, all pictures in this album have been either uploaded or marked as not for upload.</string>
|
<string name="congratulations_all_pictures_in_this_album_have_been_either_uploaded_or_marked_as_not_for_upload">Congratulations, all pictures in this album have been either uploaded or marked as not for upload.</string>
|
||||||
|
|
||||||
<string name="show_in_explore">Show in Explore</string>
|
<string name="show_in_explore">Show in Explore</string>
|
||||||
|
<string name="show_in_nearby">Show in Nearby</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue