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_marginEnd="16dp"/>
|
||||
|
||||
<View
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:focusable="true"
|
||||
android:focusableInTouchMode="true"/>
|
||||
|
||||
<net.osmand.plus.OsmandTextFieldBoxes
|
||||
android:id="@+id/latitude_box"
|
||||
android:layout_width="0dp"
|
||||
|
|
|
@ -70,6 +70,12 @@
|
|||
|
||||
</android.support.v7.widget.Toolbar>
|
||||
|
||||
<View
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:focusable="true"
|
||||
android:focusableInTouchMode="true"/>
|
||||
|
||||
<LinearLayout
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp"
|
||||
|
|
|
@ -35,14 +35,7 @@ public class OsmandTextFieldBoxes extends TextFieldBoxes {
|
|||
this.panel.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if(!OsmandTextFieldBoxes.this.isActivated()) {
|
||||
OsmandTextFieldBoxes.this.activate(true);
|
||||
}
|
||||
|
||||
OsmandTextFieldBoxes.this.setHasFocus(true);
|
||||
if (!useOsmandKeyboard) {
|
||||
OsmandTextFieldBoxes.this.inputMethodManager.showSoftInput(OsmandTextFieldBoxes.this.editText, InputMethodManager.SHOW_IMPLICIT);
|
||||
}
|
||||
select();
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -71,7 +64,7 @@ public class OsmandTextFieldBoxes extends TextFieldBoxes {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void deactivate() {
|
||||
public void deactivate() {
|
||||
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);
|
||||
this.editTextLayout.setVisibility(View.INVISIBLE);
|
||||
|
|
|
@ -207,9 +207,11 @@ public class CoordinateInputBottomSheetDialogFragment extends BottomSheetDialogF
|
|||
super.onStart();
|
||||
if (!portrait) {
|
||||
final Window window = getDialog().getWindow();
|
||||
WindowManager.LayoutParams params = window.getAttributes();
|
||||
params.width = getActivity().getResources().getDimensionPixelSize(R.dimen.landscape_bottom_sheet_dialog_fragment_width);
|
||||
window.setAttributes(params);
|
||||
if (window != null) {
|
||||
WindowManager.LayoutParams params = window.getAttributes();
|
||||
params.width = getActivity().getResources().getDimensionPixelSize(R.dimen.landscape_bottom_sheet_dialog_fragment_width);
|
||||
window.setAttributes(params);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,6 @@ import android.support.v4.widget.TextViewCompat;
|
|||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.PopupMenu;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.text.Editable;
|
||||
import android.text.InputFilter;
|
||||
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.Context.CLIPBOARD_SERVICE;
|
||||
import static net.osmand.plus.MapMarkersHelper.MAP_MARKERS_COLORS_COUNT;
|
||||
|
||||
public class CoordinateInputDialogFragment extends DialogFragment implements OsmAndCompassListener, OsmAndLocationListener {
|
||||
|
||||
|
@ -199,8 +199,6 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
|||
|
||||
registerEditTexts();
|
||||
|
||||
changeKeyboardInBoxes();
|
||||
|
||||
final View mapMarkersLayout = mainView.findViewById(R.id.map_markers_layout);
|
||||
|
||||
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);
|
||||
if (latLon != null) {
|
||||
String name = nameEditText.getText().toString();
|
||||
adapter.addMapMarker(latLon, name);
|
||||
addMapMarker(latLon, name);
|
||||
} else {
|
||||
Toast.makeText(getContext(), getString(R.string.wrong_format), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
@ -311,6 +309,10 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
|||
stopLocationUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(Bundle outState) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
Dialog dialog = getDialog();
|
||||
|
@ -341,6 +343,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
|||
for (OsmandTextFieldBoxes textFieldBox : textFieldBoxes) {
|
||||
textFieldBox.getPanel().setOnTouchListener(textFieldBoxOnTouchListener);
|
||||
}
|
||||
changeKeyboardInBoxes();
|
||||
}
|
||||
|
||||
private void registerEditTexts() {
|
||||
|
@ -431,50 +434,51 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
|||
popupMenu.getMenuInflater().inflate(R.menu.copy_paste_menu, menu);
|
||||
final ClipboardManager clipboardManager = ((ClipboardManager) getContext().getSystemService(CLIPBOARD_SERVICE));
|
||||
MenuItem pasteMenuItem = menu.findItem(R.id.action_paste);
|
||||
if (!(clipboardManager.hasPrimaryClip())) {
|
||||
pasteMenuItem.setEnabled(false);
|
||||
} else if (!(clipboardManager.getPrimaryClipDescription().hasMimeType(MIMETYPE_TEXT_PLAIN))) {
|
||||
if (clipboardManager == null || !clipboardManager.hasPrimaryClip() ||
|
||||
!clipboardManager.getPrimaryClipDescription().hasMimeType(MIMETYPE_TEXT_PLAIN)) {
|
||||
pasteMenuItem.setEnabled(false);
|
||||
} else {
|
||||
pasteMenuItem.setEnabled(true);
|
||||
}
|
||||
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.action_copy:
|
||||
String labelText;
|
||||
switch (view.getId()) {
|
||||
case R.id.latitude_edit_text:
|
||||
labelText = LATITUDE_LABEL;
|
||||
break;
|
||||
case R.id.longitude_edit_text:
|
||||
labelText = LONGITUDE_LABEL;
|
||||
break;
|
||||
case R.id.name_edit_text:
|
||||
labelText = NAME_LABEL;
|
||||
break;
|
||||
default:
|
||||
labelText = "";
|
||||
break;
|
||||
}
|
||||
ClipData clip = ClipData.newPlainText(labelText, editText.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 = editText.getText().toString();
|
||||
editText.setText(str + pasteData.toString());
|
||||
editText.setSelection(editText.getText().length());
|
||||
}
|
||||
return true;
|
||||
if (clipboardManager != null) {
|
||||
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.action_copy:
|
||||
String labelText;
|
||||
switch (view.getId()) {
|
||||
case R.id.latitude_edit_text:
|
||||
labelText = LATITUDE_LABEL;
|
||||
break;
|
||||
case R.id.longitude_edit_text:
|
||||
labelText = LONGITUDE_LABEL;
|
||||
break;
|
||||
case R.id.name_edit_text:
|
||||
labelText = NAME_LABEL;
|
||||
break;
|
||||
default:
|
||||
labelText = "";
|
||||
break;
|
||||
}
|
||||
ClipData clip = ClipData.newPlainText(labelText, editText.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 = editText.getText().toString();
|
||||
editText.setText(str + pasteData.toString());
|
||||
editText.setSelection(editText.getText().length());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
popupMenu.show();
|
||||
});
|
||||
popupMenu.show();
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
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() {
|
||||
return (MapActivity) getActivity();
|
||||
}
|
||||
|
|
|
@ -7,19 +7,15 @@ import android.view.View;
|
|||
import android.view.ViewGroup;
|
||||
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.plus.IconsCache;
|
||||
import net.osmand.plus.MapMarkersHelper.MapMarker;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.dashboard.DashLocationFragment;
|
||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||
import net.osmand.plus.mapmarkers.MapMarkersDbHelper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static net.osmand.plus.MapMarkersHelper.MAP_MARKERS_COLORS_COUNT;
|
||||
|
||||
public class CoordinateInputAdapter extends RecyclerView.Adapter<MapMarkerItemViewHolder> {
|
||||
|
||||
private MapActivity mapActivity;
|
||||
|
@ -118,19 +114,4 @@ public class CoordinateInputAdapter extends RecyclerView.Adapter<MapMarkerItemVi
|
|||
public MapMarker getItem(int 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