Fixes
This commit is contained in:
parent
7eb1f932cd
commit
2dbf04b7da
6 changed files with 81 additions and 74 deletions
|
@ -37,6 +37,12 @@
|
||||||
android:layout_marginRight="16dp"
|
android:layout_marginRight="16dp"
|
||||||
android:layout_marginEnd="16dp"/>
|
android:layout_marginEnd="16dp"/>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:focusable="true"
|
||||||
|
android:focusableInTouchMode="true"/>
|
||||||
|
|
||||||
<net.osmand.plus.OsmandTextFieldBoxes
|
<net.osmand.plus.OsmandTextFieldBoxes
|
||||||
android:id="@+id/latitude_box"
|
android:id="@+id/latitude_box"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
|
|
|
@ -70,6 +70,12 @@
|
||||||
|
|
||||||
</android.support.v7.widget.Toolbar>
|
</android.support.v7.widget.Toolbar>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:focusable="true"
|
||||||
|
android:focusableInTouchMode="true"/>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:paddingLeft="16dp"
|
android:paddingLeft="16dp"
|
||||||
android:paddingRight="16dp"
|
android:paddingRight="16dp"
|
||||||
|
|
|
@ -35,14 +35,7 @@ public class OsmandTextFieldBoxes extends TextFieldBoxes {
|
||||||
this.panel.setOnClickListener(new OnClickListener() {
|
this.panel.setOnClickListener(new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
if(!OsmandTextFieldBoxes.this.isActivated()) {
|
select();
|
||||||
OsmandTextFieldBoxes.this.activate(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
OsmandTextFieldBoxes.this.setHasFocus(true);
|
|
||||||
if (!useOsmandKeyboard) {
|
|
||||||
OsmandTextFieldBoxes.this.inputMethodManager.showSoftInput(OsmandTextFieldBoxes.this.editText, InputMethodManager.SHOW_IMPLICIT);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -71,7 +64,7 @@ public class OsmandTextFieldBoxes extends TextFieldBoxes {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void deactivate() {
|
public void deactivate() {
|
||||||
if(this.editText.getText().toString().isEmpty()) {
|
if(this.editText.getText().toString().isEmpty()) {
|
||||||
ViewCompat.animate(this.floatingLabel).alpha(1.0F).scaleX(1.0F).scaleY(1.0F).translationY(0.0F).setDuration((long)this.ANIMATION_DURATION);
|
ViewCompat.animate(this.floatingLabel).alpha(1.0F).scaleX(1.0F).scaleY(1.0F).translationY(0.0F).setDuration((long)this.ANIMATION_DURATION);
|
||||||
this.editTextLayout.setVisibility(View.INVISIBLE);
|
this.editTextLayout.setVisibility(View.INVISIBLE);
|
||||||
|
|
|
@ -207,11 +207,13 @@ public class CoordinateInputBottomSheetDialogFragment extends BottomSheetDialogF
|
||||||
super.onStart();
|
super.onStart();
|
||||||
if (!portrait) {
|
if (!portrait) {
|
||||||
final Window window = getDialog().getWindow();
|
final Window window = getDialog().getWindow();
|
||||||
|
if (window != null) {
|
||||||
WindowManager.LayoutParams params = window.getAttributes();
|
WindowManager.LayoutParams params = window.getAttributes();
|
||||||
params.width = getActivity().getResources().getDimensionPixelSize(R.dimen.landscape_bottom_sheet_dialog_fragment_width);
|
params.width = getActivity().getResources().getDimensionPixelSize(R.dimen.landscape_bottom_sheet_dialog_fragment_width);
|
||||||
window.setAttributes(params);
|
window.setAttributes(params);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCancel(DialogInterface dialog) {
|
public void onCancel(DialogInterface dialog) {
|
||||||
|
|
|
@ -13,7 +13,6 @@ import android.support.v4.widget.TextViewCompat;
|
||||||
import android.support.v7.widget.LinearLayoutManager;
|
import android.support.v7.widget.LinearLayoutManager;
|
||||||
import android.support.v7.widget.PopupMenu;
|
import android.support.v7.widget.PopupMenu;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.support.v7.widget.Toolbar;
|
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
import android.text.InputFilter;
|
import android.text.InputFilter;
|
||||||
import android.text.InputType;
|
import android.text.InputType;
|
||||||
|
@ -60,6 +59,7 @@ import studio.carbonylgroup.textfieldboxes.ExtendedEditText;
|
||||||
|
|
||||||
import static android.content.ClipDescription.MIMETYPE_TEXT_PLAIN;
|
import static android.content.ClipDescription.MIMETYPE_TEXT_PLAIN;
|
||||||
import static android.content.Context.CLIPBOARD_SERVICE;
|
import static android.content.Context.CLIPBOARD_SERVICE;
|
||||||
|
import static net.osmand.plus.MapMarkersHelper.MAP_MARKERS_COLORS_COUNT;
|
||||||
|
|
||||||
public class CoordinateInputDialogFragment extends DialogFragment implements OsmAndCompassListener, OsmAndLocationListener {
|
public class CoordinateInputDialogFragment extends DialogFragment implements OsmAndCompassListener, OsmAndLocationListener {
|
||||||
|
|
||||||
|
@ -199,8 +199,6 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
||||||
|
|
||||||
registerEditTexts();
|
registerEditTexts();
|
||||||
|
|
||||||
changeKeyboardInBoxes();
|
|
||||||
|
|
||||||
final View mapMarkersLayout = mainView.findViewById(R.id.map_markers_layout);
|
final View mapMarkersLayout = mainView.findViewById(R.id.map_markers_layout);
|
||||||
|
|
||||||
RecyclerView recyclerView = (RecyclerView) mainView.findViewById(R.id.markers_recycler_view);
|
RecyclerView recyclerView = (RecyclerView) mainView.findViewById(R.id.markers_recycler_view);
|
||||||
|
@ -233,7 +231,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
||||||
LatLon latLon = MapUtils.parseLocation(locPhrase);
|
LatLon latLon = MapUtils.parseLocation(locPhrase);
|
||||||
if (latLon != null) {
|
if (latLon != null) {
|
||||||
String name = nameEditText.getText().toString();
|
String name = nameEditText.getText().toString();
|
||||||
adapter.addMapMarker(latLon, name);
|
addMapMarker(latLon, name);
|
||||||
} else {
|
} else {
|
||||||
Toast.makeText(getContext(), getString(R.string.wrong_format), Toast.LENGTH_SHORT).show();
|
Toast.makeText(getContext(), getString(R.string.wrong_format), Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
|
@ -311,6 +309,10 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
||||||
stopLocationUpdate();
|
stopLocationUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSaveInstanceState(Bundle outState) {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroyView() {
|
public void onDestroyView() {
|
||||||
Dialog dialog = getDialog();
|
Dialog dialog = getDialog();
|
||||||
|
@ -341,6 +343,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
||||||
for (OsmandTextFieldBoxes textFieldBox : textFieldBoxes) {
|
for (OsmandTextFieldBoxes textFieldBox : textFieldBoxes) {
|
||||||
textFieldBox.getPanel().setOnTouchListener(textFieldBoxOnTouchListener);
|
textFieldBox.getPanel().setOnTouchListener(textFieldBoxOnTouchListener);
|
||||||
}
|
}
|
||||||
|
changeKeyboardInBoxes();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void registerEditTexts() {
|
private void registerEditTexts() {
|
||||||
|
@ -431,13 +434,13 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
||||||
popupMenu.getMenuInflater().inflate(R.menu.copy_paste_menu, menu);
|
popupMenu.getMenuInflater().inflate(R.menu.copy_paste_menu, menu);
|
||||||
final ClipboardManager clipboardManager = ((ClipboardManager) getContext().getSystemService(CLIPBOARD_SERVICE));
|
final ClipboardManager clipboardManager = ((ClipboardManager) getContext().getSystemService(CLIPBOARD_SERVICE));
|
||||||
MenuItem pasteMenuItem = menu.findItem(R.id.action_paste);
|
MenuItem pasteMenuItem = menu.findItem(R.id.action_paste);
|
||||||
if (!(clipboardManager.hasPrimaryClip())) {
|
if (clipboardManager == null || !clipboardManager.hasPrimaryClip() ||
|
||||||
pasteMenuItem.setEnabled(false);
|
!clipboardManager.getPrimaryClipDescription().hasMimeType(MIMETYPE_TEXT_PLAIN)) {
|
||||||
} else if (!(clipboardManager.getPrimaryClipDescription().hasMimeType(MIMETYPE_TEXT_PLAIN))) {
|
|
||||||
pasteMenuItem.setEnabled(false);
|
pasteMenuItem.setEnabled(false);
|
||||||
} else {
|
} else {
|
||||||
pasteMenuItem.setEnabled(true);
|
pasteMenuItem.setEnabled(true);
|
||||||
}
|
}
|
||||||
|
if (clipboardManager != null) {
|
||||||
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
|
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onMenuItemClick(MenuItem item) {
|
public boolean onMenuItemClick(MenuItem item) {
|
||||||
|
@ -475,6 +478,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
popupMenu.show();
|
popupMenu.show();
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
@ -599,6 +603,21 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addMapMarker(LatLon latLon, String name) {
|
||||||
|
PointDescription pointDescription = new PointDescription(PointDescription.POINT_TYPE_MAP_MARKER, name);
|
||||||
|
int colorIndex = mapMarkers.size() > 0 ? mapMarkers.get(mapMarkers.size() - 1).colorIndex : -1;
|
||||||
|
if (colorIndex == -1) {
|
||||||
|
colorIndex = 0;
|
||||||
|
} else {
|
||||||
|
colorIndex = (colorIndex + 1) % MAP_MARKERS_COLORS_COUNT;
|
||||||
|
}
|
||||||
|
MapMarker mapMarker = new MapMarker(latLon, pointDescription, colorIndex, false, 0);
|
||||||
|
mapMarker.history = false;
|
||||||
|
mapMarker.nextKey = MapMarkersDbHelper.TAIL_NEXT_VALUE;
|
||||||
|
mapMarkers.add(mapMarker);
|
||||||
|
adapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
|
||||||
private MapActivity getMapActivity() {
|
private MapActivity getMapActivity() {
|
||||||
return (MapActivity) getActivity();
|
return (MapActivity) getActivity();
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,19 +7,15 @@ import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
import net.osmand.data.LatLon;
|
import net.osmand.data.LatLon;
|
||||||
import net.osmand.data.PointDescription;
|
|
||||||
import net.osmand.plus.IconsCache;
|
import net.osmand.plus.IconsCache;
|
||||||
import net.osmand.plus.MapMarkersHelper.MapMarker;
|
import net.osmand.plus.MapMarkersHelper.MapMarker;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.dashboard.DashLocationFragment;
|
import net.osmand.plus.dashboard.DashLocationFragment;
|
||||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||||
import net.osmand.plus.mapmarkers.MapMarkersDbHelper;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static net.osmand.plus.MapMarkersHelper.MAP_MARKERS_COLORS_COUNT;
|
|
||||||
|
|
||||||
public class CoordinateInputAdapter extends RecyclerView.Adapter<MapMarkerItemViewHolder> {
|
public class CoordinateInputAdapter extends RecyclerView.Adapter<MapMarkerItemViewHolder> {
|
||||||
|
|
||||||
private MapActivity mapActivity;
|
private MapActivity mapActivity;
|
||||||
|
@ -118,19 +114,4 @@ public class CoordinateInputAdapter extends RecyclerView.Adapter<MapMarkerItemVi
|
||||||
public MapMarker getItem(int position) {
|
public MapMarker getItem(int position) {
|
||||||
return mapMarkers.get(position);
|
return mapMarkers.get(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addMapMarker(LatLon latLon, String name) {
|
|
||||||
PointDescription pointDescription = new PointDescription(PointDescription.POINT_TYPE_MAP_MARKER, name);
|
|
||||||
int colorIndex = mapMarkers.size() > 0 ? mapMarkers.get(mapMarkers.size() - 1).colorIndex : -1;
|
|
||||||
if (colorIndex == -1) {
|
|
||||||
colorIndex = 0;
|
|
||||||
} else {
|
|
||||||
colorIndex = (colorIndex + 1) % MAP_MARKERS_COLORS_COUNT;
|
|
||||||
}
|
|
||||||
MapMarker mapMarker = new MapMarker(latLon, pointDescription, colorIndex, false, 0);
|
|
||||||
mapMarker.history = false;
|
|
||||||
mapMarker.nextKey = MapMarkersDbHelper.TAIL_NEXT_VALUE;
|
|
||||||
mapMarkers.add(mapMarker);
|
|
||||||
notifyDataSetChanged();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue