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
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
int position = -1;
switch (item.getItemId()) {
case R.id.action_track:
position = 0;
break;
case R.id.action_points:
position = 1;
break;
int i = item.getItemId();
if (i == R.id.action_track) {
position = 0;
} else if (i == R.id.action_points) {
position = 1;
}
if (position != -1 && position != viewPager.getCurrentItem()) {
viewPager.setCurrentItem(position);

View file

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

View file

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

View file

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

View file

@ -758,37 +758,37 @@ public class TrackSegmentFragment extends OsmAndListFragment implements TrackBit
generalPopupMenu.setOnMenuItemClickListener(new IconPopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
switch (item.getItemId()) {
case R.id.action_edit:
TrkSegment segment = getTrkSegment();
if (segment != null && fragmentAdapter != null) {
fragmentAdapter.addNewGpxData(NewGpxData.ActionType.EDIT_SEGMENT, segment);
}
return true;
case R.id.action_delete:
TrackActivity activity = getTrackActivity();
if (activity != null) {
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.setMessage(R.string.recording_delete_confirm);
builder.setPositiveButton(R.string.shared_string_yes, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
TrackActivity trackActivity = getTrackActivity();
if (trackActivity != null && deleteSegment()) {
GPXFile gpx = getGpx();
if (gpx != null && fragmentAdapter != null) {
boolean showOnMap = fragmentAdapter.isShowOnMap();
SelectedGpxFile sf = app.getSelectedGpxHelper().selectGpxFile(gpx, showOnMap, false);
new SaveGpxAsyncTask(trackActivity, TrackSegmentFragment.this, gpx, showOnMap ? sf : null)
.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
int i = item.getItemId();
if (i == R.id.action_edit) {
TrkSegment segment = getTrkSegment();
if (segment != null && fragmentAdapter != null) {
fragmentAdapter.addNewGpxData(NewGpxData.ActionType.EDIT_SEGMENT, segment);
}
return true;
} else if (i == R.id.action_delete) {
TrackActivity activity = getTrackActivity();
if (activity != null) {
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.setMessage(R.string.recording_delete_confirm);
builder.setPositiveButton(R.string.shared_string_yes, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
TrackActivity trackActivity = getTrackActivity();
if (trackActivity != null && deleteSegment()) {
GPXFile gpx = getGpx();
if (gpx != null && fragmentAdapter != null) {
boolean showOnMap = fragmentAdapter.isShowOnMap();
SelectedGpxFile sf = app.getSelectedGpxHelper().selectGpxFile(gpx, showOnMap, false);
new SaveGpxAsyncTask(trackActivity, TrackSegmentFragment.this, gpx, showOnMap ? sf : null)
.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
}
});
builder.setNegativeButton(R.string.shared_string_cancel, null);
builder.show();
}
return true;
}
});
builder.setNegativeButton(R.string.shared_string_cancel, null);
builder.show();
}
return true;
}
return false;
}
@ -870,25 +870,25 @@ public class TrackSegmentFragment extends OsmAndListFragment implements TrackBit
altitudePopupMenu.setOnMenuItemClickListener(new IconPopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
switch (item.getItemId()) {
case R.id.action_edit:
TrkSegment segment = getTrkSegment();
if (segment != null && fragmentAdapter != null) {
fragmentAdapter.addNewGpxData(NewGpxData.ActionType.EDIT_SEGMENT, segment);
int i = item.getItemId();
if (i == R.id.action_edit) {
TrkSegment segment = getTrkSegment();
if (segment != null && fragmentAdapter != null) {
fragmentAdapter.addNewGpxData(NewGpxData.ActionType.EDIT_SEGMENT, segment);
}
return true;
} else if (i == R.id.action_delete) {
TrackActivity trackActivity = getTrackActivity();
if (trackActivity != null && deleteSegment()) {
GPXFile gpx = getGpx();
if (gpx != null && fragmentAdapter != null) {
boolean showOnMap = fragmentAdapter.isShowOnMap();
SelectedGpxFile sf = app.getSelectedGpxHelper().selectGpxFile(gpx, showOnMap, false);
new SaveGpxAsyncTask(trackActivity, TrackSegmentFragment.this, gpx, showOnMap ? sf : null)
.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
return true;
case R.id.action_delete:
TrackActivity trackActivity = getTrackActivity();
if (trackActivity != null && deleteSegment()) {
GPXFile gpx = getGpx();
if (gpx != null && fragmentAdapter != null) {
boolean showOnMap = fragmentAdapter.isShowOnMap();
SelectedGpxFile sf = app.getSelectedGpxHelper().selectGpxFile(gpx, showOnMap, false);
new SaveGpxAsyncTask(trackActivity, TrackSegmentFragment.this, gpx, showOnMap ? sf : null)
.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
}
return true;
}
return true;
}
return false;
}
@ -969,25 +969,25 @@ public class TrackSegmentFragment extends OsmAndListFragment implements TrackBit
popupMenu.setOnMenuItemClickListener(new IconPopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
switch (item.getItemId()) {
case R.id.action_edit:
TrkSegment segment = getTrkSegment();
if (segment != null && fragmentAdapter != null) {
fragmentAdapter.addNewGpxData(NewGpxData.ActionType.EDIT_SEGMENT, segment);
int i = item.getItemId();
if (i == R.id.action_edit) {
TrkSegment segment = getTrkSegment();
if (segment != null && fragmentAdapter != null) {
fragmentAdapter.addNewGpxData(NewGpxData.ActionType.EDIT_SEGMENT, segment);
}
return true;
} else if (i == R.id.action_delete) {
TrackActivity trackActivity = getTrackActivity();
if (trackActivity != null && deleteSegment()) {
GPXFile gpx = getGpx();
if (gpx != null && fragmentAdapter != null) {
boolean showOnMap = fragmentAdapter.isShowOnMap();
SelectedGpxFile sf = app.getSelectedGpxHelper().selectGpxFile(gpx, showOnMap, false);
new SaveGpxAsyncTask(trackActivity, TrackSegmentFragment.this, gpx, showOnMap ? sf : null)
.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
return true;
case R.id.action_delete:
TrackActivity trackActivity = getTrackActivity();
if (trackActivity != null && deleteSegment()) {
GPXFile gpx = getGpx();
if (gpx != null && fragmentAdapter != null) {
boolean showOnMap = fragmentAdapter.isShowOnMap();
SelectedGpxFile sf = app.getSelectedGpxHelper().selectGpxFile(gpx, showOnMap, false);
new SaveGpxAsyncTask(trackActivity, TrackSegmentFragment.this, gpx, showOnMap ? sf : null)
.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
}
return true;
}
return true;
}
return false;
}

View file

@ -272,53 +272,52 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
@Override
public boolean onContextMenuClick(final ArrayAdapter<ContextMenuItem> adapter, int itemId, final int pos, boolean isChecked, int[] viewCoordinates) {
final OsmandSettings settings = mapActivity.getMyApplication().getSettings();
switch (itemId) {
case R.string.layer_overlay:
toggleUnderlayState(mapActivity, RasterMapType.OVERLAY,
new OnMapSelectedCallback() {
@Override
public void onMapSelected(boolean canceled) {
ContextMenuItem item = adapter.getItem(pos);
if (itemId == R.string.layer_overlay) {
toggleUnderlayState(mapActivity, RasterMapType.OVERLAY,
new OnMapSelectedCallback() {
@Override
public void onMapSelected(boolean canceled) {
ContextMenuItem item = adapter.getItem(pos);
String overlayMapDescr = settings.MAP_OVERLAY.get();
String overlayMapDescr = settings.MAP_OVERLAY.get();
boolean hasOverlayDescription = overlayMapDescr != null;
overlayMapDescr = hasOverlayDescription ? overlayMapDescr
: mapActivity.getString(R.string.shared_string_none);
boolean hasOverlayDescription = overlayMapDescr != null;
overlayMapDescr = hasOverlayDescription ? overlayMapDescr
: mapActivity.getString(R.string.shared_string_none);
item.setDescription(overlayMapDescr);
item.setSelected(hasOverlayDescription);
item.setColorRes(hasOverlayDescription ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
adapter.notifyDataSetChanged();
}
});
return false;
case R.string.layer_underlay:
toggleUnderlayState(mapActivity, RasterMapType.UNDERLAY,
new OnMapSelectedCallback() {
@Override
public void onMapSelected(boolean canceled) {
ContextMenuItem item = adapter.getItem(pos);
item.setDescription(overlayMapDescr);
item.setSelected(hasOverlayDescription);
item.setColorRes(hasOverlayDescription ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
adapter.notifyDataSetChanged();
}
});
return false;
} else if (itemId == R.string.layer_underlay) {
toggleUnderlayState(mapActivity, RasterMapType.UNDERLAY,
new OnMapSelectedCallback() {
@Override
public void onMapSelected(boolean canceled) {
ContextMenuItem item = adapter.getItem(pos);
String underlayMapDescr = settings.MAP_UNDERLAY.get();
String underlayMapDescr = settings.MAP_UNDERLAY.get();
boolean hasUnderlayDescription = underlayMapDescr != null;
underlayMapDescr = hasUnderlayDescription ? underlayMapDescr
: mapActivity.getString(R.string.shared_string_none);
boolean hasUnderlayDescription = underlayMapDescr != null;
underlayMapDescr = hasUnderlayDescription ? underlayMapDescr
: mapActivity.getString(R.string.shared_string_none);
item.setDescription(underlayMapDescr);
item.setSelected(hasUnderlayDescription);
item.setColorRes(hasUnderlayDescription ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
item.setDescription(underlayMapDescr);
item.setSelected(hasUnderlayDescription);
item.setColorRes(hasUnderlayDescription ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
adapter.notifyDataSetChanged();
adapter.notifyDataSetChanged();
final OsmandSettings.CommonPreference<Boolean> hidePolygonsPref =
mapActivity.getMyApplication().getSettings().getCustomRenderBooleanProperty("noPolygons");
hidePolygonsPref.set(hasUnderlayDescription);
RasterMapMenu.refreshMapComplete(mapActivity);
}
});
return false;
final CommonPreference<Boolean> hidePolygonsPref =
mapActivity.getMyApplication().getSettings().getCustomRenderBooleanProperty("noPolygons");
hidePolygonsPref.set(hasUnderlayDescription);
RasterMapMenu.refreshMapComplete(mapActivity);
}
});
return false;
}
return true;
}

View file

@ -519,37 +519,37 @@ public class MapWidgetRegistry {
@Override
public boolean onMenuItemClick(MenuItem menuItem) {
switch (menuItem.getItemId()) {
case R.id.action_show:
setVisibility(adapter, pos, true, false);
return true;
case R.id.action_hide:
setVisibility(adapter, pos, false, false);
return true;
case R.id.action_collapse:
setVisibility(adapter, pos, true, true);
return true;
default:
if (menuItemIds != null) {
for (int menuItemId : menuItemIds) {
if (menuItem.getItemId() == menuItemId) {
r.changeState(menuItemId);
MapInfoLayer mil = mapActivity.getMapLayers().getMapInfoLayer();
if (mil != null) {
mil.recreateControls();
}
ContextMenuItem item = adapter.getItem(pos);
item.setIcon(r.getDrawableMenu());
if (r.getMessage() != null) {
item.setTitle(r.getMessage());
} else {
item.setTitle(mapActivity.getResources().getString(r.getMessageId()));
}
adapter.notifyDataSetChanged();
return true;
int i = menuItem.getItemId();
if (i == R.id.action_show) {
setVisibility(adapter, pos, true, false);
return true;
} else if (i == R.id.action_hide) {
setVisibility(adapter, pos, false, false);
return true;
} else if (i == R.id.action_collapse) {
setVisibility(adapter, pos, true, true);
return true;
} else {
if (menuItemIds != null) {
for (int menuItemId : menuItemIds) {
if (menuItem.getItemId() == menuItemId) {
r.changeState(menuItemId);
MapInfoLayer mil = mapActivity.getMapLayers().getMapInfoLayer();
if (mil != null) {
mil.recreateControls();
}
ContextMenuItem item = adapter.getItem(pos);
item.setIcon(r.getDrawableMenu());
if (r.getMessage() != null) {
item.setTitle(r.getMessage());
} else {
item.setTitle(mapActivity.getResources().getString(r.getMessageId()));
}
adapter.notifyDataSetChanged();
return true;
}
}
}
}
return false;
}

View file

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