Merge pull request #6959 from brainbeanapps/LibraryCompilationFixes

Library compilation fixes
This commit is contained in:
vshcherb 2019-05-20 21:55:44 +02:00 committed by GitHub
commit 5578f07c35
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 236 additions and 256 deletions

View file

@ -393,13 +393,11 @@ public class TrackActivity extends TabActivity {
@Override @Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) { public boolean onNavigationItemSelected(@NonNull MenuItem item) {
int position = -1; int position = -1;
switch (item.getItemId()) { int i = item.getItemId();
case R.id.action_track: if (i == R.id.action_track) {
position = 0; position = 0;
break; } else if (i == R.id.action_points) {
case R.id.action_points:
position = 1; position = 1;
break;
} }
if (position != -1 && position != viewPager.getCurrentItem()) { if (position != -1 && position != viewPager.getCurrentItem()) {
viewPager.setCurrentItem(position); viewPager.setCurrentItem(position);

View file

@ -465,11 +465,9 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
if (focusedView != null && focusedView instanceof EditText) { if (focusedView != null && focusedView instanceof EditText) {
EditText focusedEditText = (EditText) focusedView; EditText focusedEditText = (EditText) focusedView;
int id = v.getId(); int id = v.getId();
switch (id) { if (id == R.id.keyboard_item_clear) {
case R.id.keyboard_item_clear:
focusedEditText.setText(""); focusedEditText.setText("");
break; } else if (id == R.id.keyboard_item_backspace) {
case R.id.keyboard_item_backspace:
String str = focusedEditText.getText().toString(); String str = focusedEditText.getText().toString();
if (str.length() > 0) { if (str.length() > 0) {
str = str.substring(0, str.length() - 1); str = str.substring(0, str.length() - 1);
@ -478,14 +476,11 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
} else { } else {
switchEditText(focusedEditText.getId(), false); switchEditText(focusedEditText.getId(), false);
} }
break; } else if (id == R.id.keyboard_item_next_field) {
case R.id.keyboard_item_next_field:
switchEditText(focusedEditText.getId(), true); switchEditText(focusedEditText.getId(), true);
break; } else if (id == R.id.keyboard_item_hide) {
case R.id.keyboard_item_hide:
changeOsmandKeyboardVisibility(false); changeOsmandKeyboardVisibility(false);
break; } else {
default:
focusedEditText.setText(focusedEditText.getText().toString() + getItemObjectById(id)); focusedEditText.setText(focusedEditText.getText().toString() + getItemObjectById(id));
focusedEditText.setSelection(focusedEditText.getText().length()); focusedEditText.setSelection(focusedEditText.getText().length());
} }
@ -653,34 +648,33 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
} }
private Object getItemObjectById(@IdRes int id) { private Object getItemObjectById(@IdRes int id) {
switch (id) { if (id == R.id.keyboard_item_0) {
case R.id.keyboard_item_0:
return "0"; return "0";
case R.id.keyboard_item_1: } else if (id == R.id.keyboard_item_1) {
return "1"; return "1";
case R.id.keyboard_item_2: } else if (id == R.id.keyboard_item_2) {
return "2"; return "2";
case R.id.keyboard_item_3: } else if (id == R.id.keyboard_item_3) {
return "3"; return "3";
case R.id.keyboard_item_4: } else if (id == R.id.keyboard_item_4) {
return "4"; return "4";
case R.id.keyboard_item_5: } else if (id == R.id.keyboard_item_5) {
return "5"; return "5";
case R.id.keyboard_item_6: } else if (id == R.id.keyboard_item_6) {
return "6"; return "6";
case R.id.keyboard_item_7: } else if (id == R.id.keyboard_item_7) {
return "7"; return "7";
case R.id.keyboard_item_8: } else if (id == R.id.keyboard_item_8) {
return "8"; return "8";
case R.id.keyboard_item_9: } else if (id == R.id.keyboard_item_9) {
return "9"; return "9";
case R.id.keyboard_item_clear: } else if (id == R.id.keyboard_item_clear) {
return getString(R.string.shared_string_clear); return getString(R.string.shared_string_clear);
case R.id.keyboard_item_next_field: } else if (id == R.id.keyboard_item_next_field) {
return R.drawable.ic_keyboard_next_field; return R.drawable.ic_keyboard_next_field;
case R.id.keyboard_item_backspace: } else if (id == R.id.keyboard_item_backspace) {
return R.drawable.ic_keyboard_backspace; return R.drawable.ic_keyboard_backspace;
case R.id.keyboard_item_hide: } else if (id == R.id.keyboard_item_hide) {
return R.drawable.ic_action_keyboard_hide; return R.drawable.ic_action_keyboard_hide;
} }
return -1; return -1;
@ -887,12 +881,12 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override @Override
public boolean onMenuItemClick(MenuItem item) { public boolean onMenuItemClick(MenuItem item) {
switch (item.getItemId()) { int i = item.getItemId();
case R.id.action_copy: if (i == R.id.action_copy) {
ClipData clip = ClipData.newPlainText("", inputEditText.getText().toString()); ClipData clip = ClipData.newPlainText("", inputEditText.getText().toString());
clipboardManager.setPrimaryClip(clip); clipboardManager.setPrimaryClip(clip);
return true; return true;
case R.id.action_paste: } else if (i == R.id.action_paste) {
ClipData.Item pasteItem = clipboardManager.getPrimaryClip().getItemAt(0); ClipData.Item pasteItem = clipboardManager.getPrimaryClip().getItemAt(0);
CharSequence pasteData = pasteItem.getText(); CharSequence pasteData = pasteItem.getText();
if (pasteData != null) { if (pasteData != null) {
@ -901,9 +895,8 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
inputEditText.setSelection(inputEditText.getText().length()); inputEditText.setSelection(inputEditText.getText().length());
} }
return true; return true;
default:
return false;
} }
return false;
} }
}); });
popupMenu.show(); popupMenu.show();

View file

@ -180,20 +180,20 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm
bottomNav.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() { bottomNav.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
@Override @Override
public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) { public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) {
switch (menuItem.getItemId()) { int i = menuItem.getItemId();
case R.id.action_active: if (i == R.id.action_active) {
setupLocationUpdate(true, false); setupLocationUpdate(true, false);
setupActiveFragment(ACTIVE_MARKERS_POSITION); setupActiveFragment(ACTIVE_MARKERS_POSITION);
return true; return true;
case R.id.action_groups: } else if (i == R.id.action_groups) {
setupLocationUpdate(false, true); setupLocationUpdate(false, true);
setupActiveFragment(GROUPS_POSITION); setupActiveFragment(GROUPS_POSITION);
return true; return true;
case R.id.action_history: } else if (i == R.id.action_history) {
setupLocationUpdate(false, false); setupLocationUpdate(false, false);
setupActiveFragment(HISTORY_MARKERS_POSITION); setupActiveFragment(HISTORY_MARKERS_POSITION);
return true; return true;
case R.id.action_more: } else if (i == R.id.action_more) {
showOptionsMenuFragment(); showOptionsMenuFragment();
return true; return true;
} }

View file

@ -853,12 +853,11 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener {
private View.OnClickListener onFabClickListener = new View.OnClickListener() { private View.OnClickListener onFabClickListener = new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
switch (view.getId()) { int i = view.getId();
case R.id.overlay_view: if (i == R.id.overlay_view) {
hideTransparentOverlay(); hideTransparentOverlay();
closeFabMenu(view.getContext()); closeFabMenu(view.getContext());
break; } else if (i == R.id.menu_fab) {
case R.id.menu_fab:
if (fabMenuOpened) { if (fabMenuOpened) {
hideTransparentOverlay(); hideTransparentOverlay();
closeFabMenu(view.getContext()); closeFabMenu(view.getContext());
@ -866,21 +865,14 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener {
showTransparentOverlay(); showTransparentOverlay();
openFabMenu(view.getContext()); openFabMenu(view.getContext());
} }
break; } else if (i == R.id.waypoint_text_layout || i == R.id.waypoint_fab) {
case R.id.waypoint_text_layout:
case R.id.waypoint_fab:
PointDescription pointWptDescription = PointDescription pointWptDescription =
new PointDescription(PointDescription.POINT_TYPE_WPT, app.getString(R.string.add_waypoint)); new PointDescription(PointDescription.POINT_TYPE_WPT, app.getString(R.string.add_waypoint));
addPoint(pointWptDescription); addPoint(pointWptDescription);
break; } else if (i == R.id.route_text_layout || i == R.id.route_fab) {
case R.id.route_text_layout:
case R.id.route_fab:
addNewGpxData(NewGpxData.ActionType.ADD_ROUTE_POINTS); addNewGpxData(NewGpxData.ActionType.ADD_ROUTE_POINTS);
break; } else if (i == R.id.line_text_layout || i == R.id.line_fab) {
case R.id.line_text_layout:
case R.id.line_fab:
addNewGpxData(NewGpxData.ActionType.ADD_SEGMENT); addNewGpxData(NewGpxData.ActionType.ADD_SEGMENT);
break;
} }
} }
}; };

View file

@ -758,14 +758,14 @@ public class TrackSegmentFragment extends OsmAndListFragment implements TrackBit
generalPopupMenu.setOnMenuItemClickListener(new IconPopupMenu.OnMenuItemClickListener() { generalPopupMenu.setOnMenuItemClickListener(new IconPopupMenu.OnMenuItemClickListener() {
@Override @Override
public boolean onMenuItemClick(MenuItem item) { public boolean onMenuItemClick(MenuItem item) {
switch (item.getItemId()) { int i = item.getItemId();
case R.id.action_edit: if (i == R.id.action_edit) {
TrkSegment segment = getTrkSegment(); TrkSegment segment = getTrkSegment();
if (segment != null && fragmentAdapter != null) { if (segment != null && fragmentAdapter != null) {
fragmentAdapter.addNewGpxData(NewGpxData.ActionType.EDIT_SEGMENT, segment); fragmentAdapter.addNewGpxData(NewGpxData.ActionType.EDIT_SEGMENT, segment);
} }
return true; return true;
case R.id.action_delete: } else if (i == R.id.action_delete) {
TrackActivity activity = getTrackActivity(); TrackActivity activity = getTrackActivity();
if (activity != null) { if (activity != null) {
AlertDialog.Builder builder = new AlertDialog.Builder(activity); AlertDialog.Builder builder = new AlertDialog.Builder(activity);
@ -870,14 +870,14 @@ public class TrackSegmentFragment extends OsmAndListFragment implements TrackBit
altitudePopupMenu.setOnMenuItemClickListener(new IconPopupMenu.OnMenuItemClickListener() { altitudePopupMenu.setOnMenuItemClickListener(new IconPopupMenu.OnMenuItemClickListener() {
@Override @Override
public boolean onMenuItemClick(MenuItem item) { public boolean onMenuItemClick(MenuItem item) {
switch (item.getItemId()) { int i = item.getItemId();
case R.id.action_edit: if (i == R.id.action_edit) {
TrkSegment segment = getTrkSegment(); TrkSegment segment = getTrkSegment();
if (segment != null && fragmentAdapter != null) { if (segment != null && fragmentAdapter != null) {
fragmentAdapter.addNewGpxData(NewGpxData.ActionType.EDIT_SEGMENT, segment); fragmentAdapter.addNewGpxData(NewGpxData.ActionType.EDIT_SEGMENT, segment);
} }
return true; return true;
case R.id.action_delete: } else if (i == R.id.action_delete) {
TrackActivity trackActivity = getTrackActivity(); TrackActivity trackActivity = getTrackActivity();
if (trackActivity != null && deleteSegment()) { if (trackActivity != null && deleteSegment()) {
GPXFile gpx = getGpx(); GPXFile gpx = getGpx();
@ -969,14 +969,14 @@ public class TrackSegmentFragment extends OsmAndListFragment implements TrackBit
popupMenu.setOnMenuItemClickListener(new IconPopupMenu.OnMenuItemClickListener() { popupMenu.setOnMenuItemClickListener(new IconPopupMenu.OnMenuItemClickListener() {
@Override @Override
public boolean onMenuItemClick(MenuItem item) { public boolean onMenuItemClick(MenuItem item) {
switch (item.getItemId()) { int i = item.getItemId();
case R.id.action_edit: if (i == R.id.action_edit) {
TrkSegment segment = getTrkSegment(); TrkSegment segment = getTrkSegment();
if (segment != null && fragmentAdapter != null) { if (segment != null && fragmentAdapter != null) {
fragmentAdapter.addNewGpxData(NewGpxData.ActionType.EDIT_SEGMENT, segment); fragmentAdapter.addNewGpxData(NewGpxData.ActionType.EDIT_SEGMENT, segment);
} }
return true; return true;
case R.id.action_delete: } else if (i == R.id.action_delete) {
TrackActivity trackActivity = getTrackActivity(); TrackActivity trackActivity = getTrackActivity();
if (trackActivity != null && deleteSegment()) { if (trackActivity != null && deleteSegment()) {
GPXFile gpx = getGpx(); GPXFile gpx = getGpx();

View file

@ -272,8 +272,7 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
@Override @Override
public boolean onContextMenuClick(final ArrayAdapter<ContextMenuItem> adapter, int itemId, final int pos, boolean isChecked, int[] viewCoordinates) { public boolean onContextMenuClick(final ArrayAdapter<ContextMenuItem> adapter, int itemId, final int pos, boolean isChecked, int[] viewCoordinates) {
final OsmandSettings settings = mapActivity.getMyApplication().getSettings(); final OsmandSettings settings = mapActivity.getMyApplication().getSettings();
switch (itemId) { if (itemId == R.string.layer_overlay) {
case R.string.layer_overlay:
toggleUnderlayState(mapActivity, RasterMapType.OVERLAY, toggleUnderlayState(mapActivity, RasterMapType.OVERLAY,
new OnMapSelectedCallback() { new OnMapSelectedCallback() {
@Override @Override
@ -293,7 +292,7 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
} }
}); });
return false; return false;
case R.string.layer_underlay: } else if (itemId == R.string.layer_underlay) {
toggleUnderlayState(mapActivity, RasterMapType.UNDERLAY, toggleUnderlayState(mapActivity, RasterMapType.UNDERLAY,
new OnMapSelectedCallback() { new OnMapSelectedCallback() {
@Override @Override
@ -312,7 +311,7 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
adapter.notifyDataSetChanged(); adapter.notifyDataSetChanged();
final OsmandSettings.CommonPreference<Boolean> hidePolygonsPref = final CommonPreference<Boolean> hidePolygonsPref =
mapActivity.getMyApplication().getSettings().getCustomRenderBooleanProperty("noPolygons"); mapActivity.getMyApplication().getSettings().getCustomRenderBooleanProperty("noPolygons");
hidePolygonsPref.set(hasUnderlayDescription); hidePolygonsPref.set(hasUnderlayDescription);
RasterMapMenu.refreshMapComplete(mapActivity); RasterMapMenu.refreshMapComplete(mapActivity);

View file

@ -519,17 +519,17 @@ public class MapWidgetRegistry {
@Override @Override
public boolean onMenuItemClick(MenuItem menuItem) { public boolean onMenuItemClick(MenuItem menuItem) {
switch (menuItem.getItemId()) { int i = menuItem.getItemId();
case R.id.action_show: if (i == R.id.action_show) {
setVisibility(adapter, pos, true, false); setVisibility(adapter, pos, true, false);
return true; return true;
case R.id.action_hide: } else if (i == R.id.action_hide) {
setVisibility(adapter, pos, false, false); setVisibility(adapter, pos, false, false);
return true; return true;
case R.id.action_collapse: } else if (i == R.id.action_collapse) {
setVisibility(adapter, pos, true, true); setVisibility(adapter, pos, true, true);
return true; return true;
default: } else {
if (menuItemIds != null) { if (menuItemIds != null) {
for (int menuItemId : menuItemIds) { for (int menuItemId : menuItemIds) {
if (menuItem.getItemId() == menuItemId) { if (menuItem.getItemId() == menuItemId) {

View file

@ -135,13 +135,11 @@ public class WikivoyageExploreActivity extends TabActivity implements DownloadEv
@Override @Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) { public boolean onNavigationItemSelected(@NonNull MenuItem item) {
int position = -1; int position = -1;
switch (item.getItemId()) { int i = item.getItemId();
case R.id.action_explore: if (i == R.id.action_explore) {
position = EXPLORE_POSITION; position = EXPLORE_POSITION;
break; } else if (i == R.id.action_saved_articles) {
case R.id.action_saved_articles:
position = SAVED_ARTICLES_POSITION; position = SAVED_ARTICLES_POSITION;
break;
} }
if (position != -1 && position != viewPager.getCurrentItem()) { if (position != -1 && position != viewPager.getCurrentItem()) {
viewPager.setCurrentItem(position); viewPager.setCurrentItem(position);