Replace the list with a fragment

This commit is contained in:
Alexander Sytnyk 2017-06-23 19:01:08 +03:00
parent 5dc71040b2
commit 30c3cc4fa9
4 changed files with 384 additions and 8 deletions

View file

@ -0,0 +1,337 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/mapillary_filters_linear_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/bg_color"
android:minHeight="60dp"
tools:layout_height="60dp">
<android.support.v7.widget.AppCompatImageView
android:id="@+id/display_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
tools:src="@drawable/ic_action_gabout_dark" />
<android.support.v7.widget.SwitchCompat
android:id="@+id/display_toggle"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginEnd="16dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginStart="16dp"
android:focusable="false" />
<android.support.v7.widget.AppCompatTextView
android:id="@+id/display_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:layout_toEndOf="@+id/display_icon"
android:layout_toLeftOf="@id/display_toggle"
android:layout_toRightOf="@+id/display_icon"
android:layout_toStartOf="@id/display_toggle"
android:textAppearance="@style/TextAppearance.ListItemTitle"
tools:text="Some title text" />
</RelativeLayout>
<LinearLayout xmlns:osmand="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="false"
android:minHeight="64dp"
android:orientation="vertical">
<include layout="@layout/card_bottom_divider" />
<View
android:layout_width="match_parent"
android:layout_height="6dp" />
<include layout="@layout/card_top_divider" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="?attr/bg_color"
android:gravity="center"
android:minHeight="48dp"
android:orientation="vertical"
android:paddingLeft="16dp"
android:paddingRight="16dp">
<net.osmand.plus.widgets.TextViewEx
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="10dp"
android:text="@string/search_poi_filter"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_sub_text_size"
osmand:typeface="@string/font_roboto_medium" />
<net.osmand.plus.widgets.TextViewEx
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="10dp"
android:paddingTop="4dp"
android:text="@string/mapillary_menu_filter_description"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_sub_text_size" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?attr/dashboard_divider" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/bg_color"
android:minHeight="60dp">
<android.support.v7.widget.AppCompatImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:src="@drawable/ic_action_user" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:minHeight="60dp"
android:orientation="vertical"
android:paddingBottom="12dp"
android:paddingTop="10dp">
<android.support.v7.widget.AppCompatTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/mapillary_menu_title_username"
android:textAppearance="@style/TextAppearance.ListItemTitle" />
<android.support.v7.widget.AppCompatTextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:ellipsize="end"
android:lines="1"
android:text="@string/mapillary_menu_descr_username"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_desc_text_size" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/bg_color"
android:orientation="vertical"
android:paddingLeft="52dp"
android:paddingStart="52dp">
<net.osmand.plus.views.controls.DelayAutoCompleteTextView
android:id="@+id/auto_complete_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:completionThreshold="1"
android:hint="@string/mapillary_menu_edit_text_hint"
android:inputType="text"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size"
tools:text="Username" />
<LinearLayout
android:id="@+id/warning_linear_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:visibility="gone">
<ImageView
android:id="@+id/warning_image_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"
android:text="@string/wrong_user_name"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_sub_text_size"
tools:text="Wrong user name!" />
</LinearLayout>
<View
android:layout_width="wrap_content"
android:layout_height="1dp"
android:layout_marginTop="12dp"
android:background="?attr/dashboard_divider" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/bg_color"
android:minHeight="60dp">
<android.support.v7.widget.AppCompatImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:src="@drawable/ic_action_data" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:minHeight="60dp"
android:orientation="vertical"
android:paddingBottom="12dp"
android:paddingTop="10dp">
<android.support.v7.widget.AppCompatTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/mapillary_menu_title_dates"
android:textAppearance="@style/TextAppearance.ListItemTitle" />
<android.support.v7.widget.AppCompatTextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:ellipsize="end"
android:lines="1"
android:text="@string/mapillary_menu_descr_dates"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_desc_text_size" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/bg_color"
android:orientation="vertical"
android:paddingLeft="52dp"
android:paddingStart="52dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp">
<android.support.design.widget.TextInputLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="12dp"
android:layout_marginRight="12dp"
android:layout_weight="1">
<EditText
android:id="@+id/date_from_edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusable="false"
android:hint="@string/mapillary_menu_date_from"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size"
tools:text="From" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:layout_marginStart="12dp"
android:layout_weight="1">
<EditText
android:id="@+id/date_to_edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusable="false"
android:hint="@string/shared_string_to"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size"
tools:text="To" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
<View
android:layout_width="wrap_content"
android:layout_height="1dp"
android:layout_marginTop="16dp"
android:background="?attr/dashboard_divider" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/bg_color">
<Button
android:id="@+id/button_apply"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="32dp"
android:layout_marginStart="32dp"
android:background="?attr/selectableItemBackground"
android:text="@string/shared_string_apply"
android:textColor="?attr/color_dialog_buttons" />
<Button
android:id="@+id/button_clear"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:background="?attr/selectableItemBackground"
android:text="@string/shared_string_clear"
android:textColor="?attr/color_dialog_buttons" />
</RelativeLayout>
<include layout="@layout/card_bottom_divider" />
<View
android:layout_width="match_parent"
android:layout_height="18dp" />
</LinearLayout>
</LinearLayout>

View file

@ -16,7 +16,6 @@ import android.util.TypedValue;
import android.view.Gravity;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
@ -75,7 +74,7 @@ import net.osmand.plus.helpers.WaypointHelper.LocationPointWrapper;
import net.osmand.plus.mapcontextmenu.other.MapRouteInfoMenu;
import net.osmand.plus.mapcontextmenu.other.RoutePreferencesMenu;
import net.osmand.plus.mapcontextmenu.other.RoutePreferencesMenu.LocalRoutingParameter;
import net.osmand.plus.mapillary.MapillaryMenu;
import net.osmand.plus.mapillary.MapillaryFiltersFragment;
import net.osmand.plus.mapillary.MapillaryPlugin.MapillaryFirstDialogFragment;
import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin;
import net.osmand.plus.routing.RoutingHelper;
@ -465,7 +464,6 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
} else if (visibleType == DashboardType.MAP_MARKERS_SELECTION) {
tv.setText(R.string.select_map_markers);
} else if (visibleType == DashboardType.MAPILLARY) {
listView.setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS);
tv.setText(R.string.mapillary);
} else if (visibleType == DashboardType.CONTOUR_LINES) {
tv.setText(R.string.srtm_plugin_name);
@ -817,8 +815,14 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
updateDownloadBtn();
View listViewLayout = dashboardView.findViewById(R.id.dash_list_view_layout);
ScrollView scrollView = (ScrollView) dashboardView.findViewById(R.id.main_scroll);
if (visibleType == DashboardType.DASHBOARD || visibleType == DashboardType.MAPILLARY) {
if (visibleType == DashboardType.DASHBOARD) {
addOrUpdateDashboardFragments();
} else {
mapActivity.getSupportFragmentManager().beginTransaction()
.replace(R.id.content, new MapillaryFiltersFragment(), MapillaryFiltersFragment.TAG)
.commit();
}
scrollView.setVisibility(View.VISIBLE);
scrollView.scrollTo(0, 0);
listViewLayout.setVisibility(View.GONE);
@ -908,7 +912,6 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
&& visibleType != DashboardType.MAP_MARKERS_SELECTION
&& visibleType != DashboardType.CONFIGURE_SCREEN
&& visibleType != DashboardType.CONFIGURE_MAP
&& visibleType != DashboardType.MAPILLARY
&& visibleType != DashboardType.CONTOUR_LINES
&& visibleType != DashboardType.HILLSHADE) {
listView.setDivider(dividerDrawable);
@ -986,8 +989,6 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
cm = RasterMapMenu.createListAdapter(mapActivity, OsmandRasterMapsPlugin.RasterMapType.UNDERLAY);
} else if (visibleType == DashboardType.OVERLAY_MAP) {
cm = RasterMapMenu.createListAdapter(mapActivity, OsmandRasterMapsPlugin.RasterMapType.OVERLAY);
} else if (visibleType == DashboardType.MAPILLARY) {
cm = MapillaryMenu.createListAdapter(mapActivity);
} else if (visibleType == DashboardType.CONTOUR_LINES) {
cm = ContourLinesMenu.createListAdapter(mapActivity);
} else if (visibleType == DashboardType.HILLSHADE) {

View file

@ -1,5 +1,6 @@
package net.osmand.plus.dashboard.tools;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.util.Log;
@ -8,6 +9,7 @@ import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.dashboard.DashBaseFragment;
import net.osmand.plus.mapillary.MapillaryFiltersFragment;
import java.util.ArrayList;
import java.util.Arrays;
@ -50,6 +52,10 @@ public final class TransactionBuilder {
public FragmentTransaction getFragmentTransaction() {
FragmentTransaction fragmentTransaction = manager.beginTransaction();
Fragment frag = manager.findFragmentByTag(MapillaryFiltersFragment.TAG);
if (frag != null) {
fragmentTransaction.remove(frag);
}
Collections.sort(fragments);
for (DashFragmentData dashFragmentData : fragments) {
DashBaseFragment fragment =

View file

@ -0,0 +1,32 @@
package net.osmand.plus.mapillary;
import android.os.Bundle;
import android.support.v4.content.ContextCompat;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import net.osmand.plus.R;
import net.osmand.plus.base.BaseOsmAndFragment;
public class MapillaryFiltersFragment extends BaseOsmAndFragment {
public static final String TAG = "MAPILLARY_FILTERS_FRAGMENT";
public MapillaryFiltersFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_mapillary_filters, container, false);
boolean nightMode = getMyApplication().getDaynightHelper().isNightModeForMapControls();
final int backgroundColor = ContextCompat.getColor(getActivity(),
nightMode ? R.color.ctx_menu_info_view_bg_dark : R.color.ctx_menu_info_view_bg_light);
view.setBackgroundColor(backgroundColor);
return view;
}
}