Add bottom buttons for context menu

This commit is contained in:
PavelRatushny 2017-11-28 16:36:20 +02:00
parent 92b431d643
commit 6dfe75cdd9
4 changed files with 68 additions and 33 deletions

View file

@ -5,7 +5,8 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent">
android:background="@android:color/transparent"
xmlns:osmand="http://schemas.android.com/apk/res-auto">
<LinearLayout
android:id="@+id/context_menu_main"
@ -369,12 +370,6 @@
android:scaleType="center"
android:src="@drawable/map_action_fav_dark"/>
<View
android:id="@+id/divider_hor_1"
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="?attr/dashboard_divider"/>
<ImageButton
android:id="@+id/context_menu_route_button"
android:layout_width="match_parent"
@ -385,12 +380,6 @@
android:scaleType="center"
android:src="@drawable/map_action_flag_dark"/>
<View
android:id="@+id/divider_hor_2"
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="?attr/dashboard_divider"/>
<ImageButton
android:id="@+id/context_menu_share_button"
android:contentDescription="@string/context_menu_item_share_location"
@ -402,12 +391,6 @@
android:scaleType="center"
android:src="@drawable/map_action_gshare_dark"/>
<View
android:id="@+id/divider_hor_3"
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="?attr/dashboard_divider"/>
<ImageButton
android:id="@+id/context_menu_more_button"
android:contentDescription="@string/shared_string_more"
@ -421,6 +404,51 @@
</LinearLayout>
<View
android:id="@+id/buttons_bottom_border"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?attr/dashboard_divider"/>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="@dimen/context_menu_action_buttons_h">
<net.osmand.plus.widgets.TextViewEx
android:background="?attr/selectableItemBackground"
android:id="@+id/context_menu_details_button"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:gravity="start|center_vertical"
android:textColor="?attr/contextMenuButtonColor"
android:textSize="@dimen/default_desc_text_size"
osmand:textAllCapsCompat="true"
osmand:typeface="@string/font_roboto_medium"
android:text="@string/description"/>
<net.osmand.plus.widgets.TextViewEx
android:background="?attr/selectableItemBackground"
android:id="@+id/context_menu_directions_button"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:gravity="end|center_vertical"
tools:drawableEnd="@drawable/map_directions"
android:drawablePadding="8dp"
android:textColor="?attr/contextMenuButtonColor"
android:textSize="@dimen/default_desc_text_size"
osmand:textAllCapsCompat="true"
osmand:typeface="@string/font_roboto_medium"
android:text="@string/get_directions"/>
</LinearLayout>
</LinearLayout>
<FrameLayout

View file

@ -746,8 +746,8 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
}
}
public void fabPressed() {
mapActivity.getMapLayers().getMapControlsLayer().navigateFab();
public void navigateButtonPressed() {
mapActivity.getMapLayers().getMapControlsLayer().navigateButton();
}
public boolean zoomInPressed() {

View file

@ -30,12 +30,9 @@ import android.widget.TextView;
import net.osmand.AndroidUtils;
import net.osmand.Location;
import net.osmand.data.FavouritePoint;
import net.osmand.data.LatLon;
import net.osmand.data.QuadPoint;
import net.osmand.data.RotatedTileBox;
import net.osmand.plus.GPXUtilities.WptPt;
import net.osmand.plus.MapMarkersHelper;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
@ -412,13 +409,6 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
buttons.setVisibility(View.GONE);
}
AndroidUtils.setBackground(getMapActivity(), mainView.findViewById(R.id.divider_hor_1), nightMode,
R.color.dashboard_divider_light, R.color.dashboard_divider_dark);
AndroidUtils.setBackground(getMapActivity(), mainView.findViewById(R.id.divider_hor_2), nightMode,
R.color.dashboard_divider_light, R.color.dashboard_divider_dark);
AndroidUtils.setBackground(getMapActivity(), mainView.findViewById(R.id.divider_hor_3), nightMode,
R.color.dashboard_divider_light, R.color.dashboard_divider_dark);
// Action buttons
final ImageButton buttonFavorite = (ImageButton) view.findViewById(R.id.context_menu_fav_button);
buttonFavorite.setImageDrawable(getIcon(menu.getFavActionIconId(),
@ -470,6 +460,23 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
}
});
TextView detailsButton = (TextView) view.findViewById(R.id.context_menu_details_button);
detailsButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
}
});
TextView directionsButton = (TextView) view.findViewById(R.id.context_menu_directions_button);
Drawable drawable = getIcon(R.drawable.map_directions, nightMode ? R.color.osmand_orange : R.color.map_widget_blue);
directionsButton.setCompoundDrawablesWithIntrinsicBounds(null, null, drawable, null);
directionsButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
menu.navigateButtonPressed();
}
});
buildBottomView();
view.findViewById(R.id.context_menu_bottom_scroll).setBackgroundColor(nightMode ?

View file

@ -474,7 +474,7 @@ public class MapControlsLayer extends OsmandMapLayer {
hasTargets = false;
}
public void navigateFab() {
public void navigateButton() {
if (!OsmAndLocationProvider.isLocationPermissionAvailable(mapActivity)) {
ActivityCompat.requestPermissions(mapActivity,
new String[]{Manifest.permission.ACCESS_FINE_LOCATION},
@ -1302,7 +1302,7 @@ public class MapControlsLayer extends OsmandMapLayer {
} else if (requestCode == REQUEST_LOCATION_FOR_NAVIGATION_FAB_PERMISSION
&& grantResults.length > 0
&& grantResults[0] == PackageManager.PERMISSION_GRANTED) {
navigateFab();
navigateButton();
} else if (requestCode == REQUEST_LOCATION_FOR_ADD_DESTINATION_PERMISSION
&& grantResults.length > 0
&& grantResults[0] == PackageManager.PERMISSION_GRANTED) {