Add small refactoring to bottom sheet menus
This commit is contained in:
parent
d82920760f
commit
7a98b5304d
4 changed files with 15 additions and 15 deletions
|
@ -4,6 +4,7 @@ import android.app.Activity;
|
|||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.ColorInt;
|
||||
import android.support.annotation.ColorRes;
|
||||
import android.support.annotation.DrawableRes;
|
||||
import android.support.annotation.Nullable;
|
||||
|
@ -69,8 +70,7 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra
|
|||
|
||||
int closeRowDividerColorId = getCloseRowDividerColorId();
|
||||
if (closeRowDividerColorId != -1) {
|
||||
mainView.findViewById(R.id.close_row_divider)
|
||||
.setBackgroundColor(ContextCompat.getColor(getContext(), closeRowDividerColorId));
|
||||
mainView.findViewById(R.id.close_row_divider).setBackgroundColor(getResolvedColor(closeRowDividerColorId));
|
||||
}
|
||||
mainView.findViewById(R.id.close_row).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
@ -123,6 +123,11 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra
|
|||
return getIcon(id, nightMode ? R.color.osmand_orange : R.color.color_myloc_distance);
|
||||
}
|
||||
|
||||
@ColorInt
|
||||
protected int getResolvedColor(@ColorRes int colorId) {
|
||||
return ContextCompat.getColor(getContext(), colorId);
|
||||
}
|
||||
|
||||
protected void setupHeightAndBackground(final View mainView) {
|
||||
final Activity activity = getActivity();
|
||||
final int screenHeight = AndroidUtils.getScreenHeight(activity);
|
||||
|
|
|
@ -790,10 +790,5 @@ public class ImportHelper {
|
|||
.create();
|
||||
items.add(asGpxItem);
|
||||
}
|
||||
|
||||
@ColorInt
|
||||
private int getResolvedColor(@ColorRes int colorId) {
|
||||
return ContextCompat.getColor(getContext(), colorId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ import android.graphics.drawable.Drawable;
|
|||
import android.os.Bundle;
|
||||
import android.support.annotation.ColorRes;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.view.View;
|
||||
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
|
@ -122,7 +121,7 @@ public class CoordinateInputBottomSheetDialogFragment extends MenuBottomSheetDia
|
|||
BaseBottomSheetItem formatItem = new BottomSheetItemWithCompoundButton.Builder()
|
||||
.setChecked(selectedItem)
|
||||
.setButtonTintList(selectedItem
|
||||
? ColorStateList.valueOf(ContextCompat.getColor(context, getActiveColorId()))
|
||||
? ColorStateList.valueOf(getResolvedColor(getActiveColorId()))
|
||||
: null)
|
||||
.setIcon(selectedItem ? getActiveIcon(R.drawable.ic_action_coordinates_latitude) : formatIcon)
|
||||
.setTitle(CoordinateInputFormats.formatToHumanString(context, format))
|
||||
|
|
|
@ -4,7 +4,6 @@ import android.app.Dialog;
|
|||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
|
@ -23,6 +22,7 @@ public class ParkingTypeBottomSheetDialogFragment extends MenuBottomSheetDialogF
|
|||
@Override
|
||||
public void createMenuItems(Bundle savedInstanceState) {
|
||||
items.add(new TitleItem(getString(R.string.parking_options)));
|
||||
|
||||
BaseBottomSheetItem byTypeItem = new SimpleBottomSheetItem.Builder()
|
||||
.setIcon(getContentIcon(R.drawable.ic_action_time_start))
|
||||
.setTitle(getString(R.string.osmand_parking_no_lim_text))
|
||||
|
@ -47,17 +47,18 @@ public class ParkingTypeBottomSheetDialogFragment extends MenuBottomSheetDialogF
|
|||
}
|
||||
})
|
||||
.create();
|
||||
|
||||
items.add(byDateItem);
|
||||
}
|
||||
|
||||
private void addParkingPosition(boolean limited) {
|
||||
Bundle args = getArguments();
|
||||
double latitude = args.getDouble(LAT_KEY);
|
||||
double longitude = args.getDouble(LON_KEY);
|
||||
ParkingPositionPlugin plugin = OsmandPlugin.getEnabledPlugin(ParkingPositionPlugin.class);
|
||||
MapActivity mapActivity = (MapActivity) getActivity();
|
||||
|
||||
if (plugin != null) {
|
||||
MapActivity mapActivity = (MapActivity) getActivity();
|
||||
Bundle args = getArguments();
|
||||
double latitude = args.getDouble(LAT_KEY);
|
||||
double longitude = args.getDouble(LON_KEY);
|
||||
|
||||
if (plugin.isParkingEventAdded()) {
|
||||
plugin.showDeleteEventWarning(mapActivity);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue