Make a row with toggle clickable; swap apply and clear; hide dashboard on apply click

This commit is contained in:
Alexander Sytnyk 2017-06-27 13:55:02 +03:00
parent 10fea91f14
commit 0757860f61
2 changed files with 14 additions and 17 deletions

View file

@ -370,7 +370,7 @@
android:background="?attr/bg_color">
<Button
android:id="@+id/button_apply"
android:id="@+id/button_clear"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
@ -378,17 +378,17 @@
android:layout_marginLeft="32dp"
android:layout_marginStart="32dp"
android:background="?attr/selectableItemBackground"
android:text="@string/shared_string_apply"
android:text="@string/shared_string_clear"
android:textColor="?attr/color_dialog_buttons" />
<Button
android:id="@+id/button_clear"
android:id="@+id/button_apply"
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:text="@string/shared_string_apply"
android:textColor="?attr/color_dialog_buttons" />
</RelativeLayout>

View file

@ -61,12 +61,6 @@ public class MapillaryFiltersFragment extends BaseOsmAndFragment {
final View toggleRow = view.findViewById(R.id.toggle_row);
toggleRow.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
showOrHideMapillaryLayers(settings, plugin, mapActivity);
}
});
final boolean selected = settings.SHOW_MAPILLARY.get();
final int toggleActionStringId = selected ? R.string.shared_string_enabled : R.string.shared_string_disabled;
int toggleIconColorId;
@ -86,7 +80,15 @@ public class MapillaryFiltersFragment extends BaseOsmAndFragment {
toggle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
showOrHideMapillaryLayers(settings, plugin, mapActivity);
settings.SHOW_MAPILLARY.set(!settings.SHOW_MAPILLARY.get());
plugin.updateLayers(mapActivity.getMapView(), mapActivity);
mapActivity.getDashboard().refreshContent(true);
}
});
toggleRow.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
toggle.setChecked(!toggle.isChecked());
}
});
@ -239,6 +241,7 @@ public class MapillaryFiltersFragment extends BaseOsmAndFragment {
changeButtonState(apply, .5f, false);
plugin.updateLayers(mapActivity.getMapView(), mapActivity);
mapActivity.getDashboard().hideDashboard();
}
});
@ -265,12 +268,6 @@ public class MapillaryFiltersFragment extends BaseOsmAndFragment {
return view;
}
private void showOrHideMapillaryLayers(OsmandSettings settings, MapillaryPlugin plugin, MapActivity mapActivity) {
settings.SHOW_MAPILLARY.set(!settings.SHOW_MAPILLARY.get());
plugin.updateLayers(mapActivity.getMapView(), mapActivity);
mapActivity.getDashboard().refreshContent(true);
}
private void changeButtonState(Button button, float alpha, boolean enabled) {
button.setAlpha(alpha);
button.setEnabled(enabled);