Merge pull request #4702 from osmandapp/coordinate_input_screen

Coordinate input screen
This commit is contained in:
Alexey 2017-11-08 16:32:10 +03:00 committed by GitHub
commit 1cdd5f5346
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
42 changed files with 1962 additions and 975 deletions

View file

@ -31,6 +31,7 @@ import net.osmand.search.core.SearchPhrase.SearchPhraseDataType;
import net.osmand.util.Algorithms; import net.osmand.util.Algorithms;
import net.osmand.util.GeoPointParserUtil; import net.osmand.util.GeoPointParserUtil;
import net.osmand.util.GeoPointParserUtil.GeoParsedPoint; import net.osmand.util.GeoPointParserUtil.GeoParsedPoint;
import net.osmand.util.LocationParser;
import net.osmand.util.MapUtils; import net.osmand.util.MapUtils;
import java.io.IOException; import java.io.IOException;
@ -1127,279 +1128,17 @@ public class SearchCoreFactory {
List<Double> d = new ArrayList<>(); List<Double> d = new ArrayList<>();
List<Object> all = new ArrayList<>(); List<Object> all = new ArrayList<>();
List<String> strings = new ArrayList<>(); List<String> strings = new ArrayList<>();
splitObjects(s, d, all, strings); LocationParser.splitObjects(s, d, all, strings);
if (d.size() == 0) { if (d.size() == 0) {
return null; return null;
} }
double lat = parse1Coordinate(all, 0, all.size()); double lat = LocationParser.parse1Coordinate(all, 0, all.size());
return new LatLon(lat, 0); return new LatLon(lat, 0);
} }
LatLon parseLocation(String s) {
s = s.trim();
// detect OLC first
// avoid throwing exceptions by carefully checking exceptions
if (s.length() > 0 && OpenLocationCode.isValidCode(s)) {
OpenLocationCode olc = new OpenLocationCode(s);
if (olc.isFull()) {
OpenLocationCode.CodeArea codeArea = olc.decode();
return new LatLon(codeArea.getCenterLatitude(), codeArea.getCenterLongitude());
}
}
if (s.length() == 0 || !(s.charAt(0) == '-' || Character.isDigit(s.charAt(0))
|| s.charAt(0) == 'S' || s.charAt(0) == 's'
|| s.charAt(0) == 'N' || s.charAt(0) == 'n'
|| s.contains("://"))) {
return null;
}
List<Double> d = new ArrayList<>();
List<Object> all = new ArrayList<>();
List<String> strings = new ArrayList<>();
splitObjects(s, d, all, strings);
if (d.size() == 0) {
return null;
}
// detect UTM
if (all.size() == 4 && d.size() == 3 && all.get(1) instanceof String) {
char ch = all.get(1).toString().charAt(0);
if (Character.isLetter(ch)) {
UTMPoint upoint = new UTMPoint(d.get(2), d.get(1), d.get(0).intValue(), ch);
LatLonPoint ll = upoint.toLatLonPoint();
return new LatLon(ll.getLatitude(), ll.getLongitude());
}
}
if (all.size() == 3 && d.size() == 2 && all.get(1) instanceof String) {
char ch = all.get(1).toString().charAt(0);
String combined = strings.get(2);
if (Character.isLetter(ch)) {
try {
String east = combined.substring(0, combined.length() / 2);
String north = combined.substring(combined.length() / 2, combined.length());
UTMPoint upoint = new UTMPoint(Double.parseDouble(north), Double.parseDouble(east), d.get(0)
.intValue(), ch);
LatLonPoint ll = upoint.toLatLonPoint();
return new LatLon(ll.getLatitude(), ll.getLongitude());
} catch (NumberFormatException e) {
}
}
}
// try to find split lat/lon position
int jointNumbers = 0;
int lastJoin = 0;
int degSplit = -1;
int degType = -1; // 0 - degree, 1 - minutes, 2 - seconds
boolean finishDegSplit = false;
int northSplit = -1;
int eastSplit = -1;
for (int i = 1; i < all.size(); i++ ) {
if (all.get(i - 1) instanceof Double && all.get(i) instanceof Double) {
jointNumbers ++;
lastJoin = i;
}
if (all.get(i).equals("n") || all.get(i).equals("s") ||
all.get(i).equals("N") || all.get(i).equals("S")) {
northSplit = i + 1;
}
if (all.get(i).equals("e") || all.get(i).equals("w") ||
all.get(i).equals("E") || all.get(i).equals("W")) {
eastSplit = i;
}
int dg = -1;
if (all.get(i).equals("°")) {
dg = 0;
} else if (all.get(i).equals("\'") || all.get(i).equals("")) {
dg = 1;
} else if (all.get(i).equals("") || all.get(i).equals("\"")) {
dg = 2;
}
if (dg != -1) {
if (!finishDegSplit) {
if (degType < dg) {
degSplit = i + 1;
degType = dg;
} else {
finishDegSplit = true;
degType = dg;
}
} else {
if (degType < dg) {
degType = dg;
} else {
// reject delimiter
degSplit = -1;
}
}
}
}
int split = -1;
if (jointNumbers == 1) {
split = lastJoin;
}
if (northSplit != -1 && northSplit < all.size() -1) {
split = northSplit;
} else if (eastSplit != -1 && eastSplit < all.size() -1) {
split = eastSplit;
} else if (degSplit != -1 && degSplit < all.size() -1) {
split = degSplit;
}
if (split != -1) {
double lat = parse1Coordinate(all, 0, split);
double lon = parse1Coordinate(all, split, all.size());
return new LatLon(lat, lon);
}
if (d.size() == 2) {
return new LatLon(d.get(0), d.get(1));
}
// simple url case
if (s.contains("://")) {
double lat = 0;
double lon = 0;
boolean only2decimals = true;
for (int i = 0; i < d.size(); i++) {
if (d.get(i).doubleValue() != d.get(i).intValue()) {
if (lat == 0) {
lat = d.get(i);
} else if (lon == 0) {
lon = d.get(i);
} else {
only2decimals = false;
}
}
}
if (lat != 0 && lon != 0 && only2decimals) {
return new LatLon(lat, lon);
}
}
// split by equal number of digits
if (d.size() > 2 && d.size() % 2 == 0) {
int ind = d.size() / 2 + 1;
int splitEq = -1;
for (int i = 0; i < all.size(); i++) {
if (all.get(i) instanceof Double) {
ind --;
}
if (ind == 0) {
splitEq = i;
break;
}
}
if (splitEq != -1) {
double lat = parse1Coordinate(all, 0, splitEq);
double lon = parse1Coordinate(all, splitEq, all.size());
return new LatLon(lat, lon);
}
}
return null;
}
public double parse1Coordinate(List<Object> all, int begin, int end) {
boolean neg = false;
double d = 0;
int type = 0; // degree - 0, minutes - 1, seconds = 2
Double prevDouble = null;
for (int i = begin; i <= end; i++) {
Object o = i == end ? "" : all.get(i);
if(o.equals("S") || o.equals("W")) {
neg = !neg;
}
if (prevDouble != null) {
if (o.equals("°")) {
type = 0;
} else if (o.equals("") /*o.equals("'")*/) {
// ' can be used as delimeter ignore it
type = 1;
} else if (o.equals("\"") || o.equals("")) {
type = 2;
}
if (type == 0) {
double ld = prevDouble.doubleValue();
if (ld < 0) {
ld = -ld;
neg = true;
}
d += ld;
} else if (type == 1) {
d += prevDouble.doubleValue() / 60.f;
} else /*if (type == 1) */ {
d += prevDouble.doubleValue() / 3600.f;
}
type++;
}
if (o instanceof Double) {
prevDouble = (Double) o;
} else {
prevDouble = null;
}
}
if (neg) {
d = -d;
}
return d;
}
private void splitObjects(String s, List<Double> d, List<Object> all, List<String> strings) {
boolean digit = false;
int word = -1;
for (int i = 0; i <= s.length(); i++) {
char ch = i == s.length() ? ' ' : s.charAt(i);
boolean dg = Character.isDigit(ch);
boolean nonwh = ch != ',' && ch != ' ' && ch != ';';
if (ch == '.' || dg || ch == '-' ) {
if (!digit) {
if (word != -1) {
all.add(s.substring(word, i));
strings.add(s.substring(word, i));
}
digit = true;
word = i;
} else {
if(word == -1) {
word = i;
}
// if digit
// continue
}
} else {
if (digit){
try {
double dl = Double.parseDouble(s.substring(word, i));
d.add(dl);
all.add(dl);
strings.add(s.substring(word, i));
digit = false;
word = -1;
} catch (NumberFormatException e) {
}
}
if (nonwh) {
if(!Character.isLetter(ch)) {
if(word != -1) {
all.add(s.substring(word, i));
strings.add(s.substring(word, i));
}
all.add(s.substring(i, i + 1));
strings.add(s.substring(i, i +1));
word = -1;
} else if(word == -1) {
word = i;
}
} else {
if (word != -1) {
all.add(s.substring(word, i));
strings.add(s.substring(word, i));
}
word = -1;
}
}
}
}
private void parseLocation(SearchPhrase phrase, SearchResultMatcher resultMatcher) { private void parseLocation(SearchPhrase phrase, SearchResultMatcher resultMatcher) {
String lw = phrase.getUnknownSearchPhrase(); String lw = phrase.getUnknownSearchPhrase();
LatLon l = parseLocation(lw); LatLon l = LocationParser.parseLocation(lw);
if (l != null) { if (l != null) {
if (phrase.isSearchTypeAllowed(ObjectType.LOCATION)) { if (phrase.isSearchTypeAllowed(ObjectType.LOCATION)) {
SearchResult sp = new SearchResult(phrase); SearchResult sp = new SearchResult(phrase);

View file

@ -0,0 +1,275 @@
package net.osmand.util;
import com.google.openlocationcode.OpenLocationCode;
import com.jwetherell.openmap.common.LatLonPoint;
import com.jwetherell.openmap.common.UTMPoint;
import net.osmand.data.LatLon;
import java.util.ArrayList;
import java.util.List;
public class LocationParser {
public static LatLon parseLocation(String locPhrase) {
locPhrase = locPhrase.trim();
// detect OLC first
// avoid throwing exceptions by carefully checking exceptions
if (locPhrase.length() > 0 && OpenLocationCode.isValidCode(locPhrase)) {
OpenLocationCode olc = new OpenLocationCode(locPhrase);
if (olc.isFull()) {
OpenLocationCode.CodeArea codeArea = olc.decode();
return new LatLon(codeArea.getCenterLatitude(), codeArea.getCenterLongitude());
}
}
if (locPhrase.length() == 0 || !(locPhrase.charAt(0) == '-' || Character.isDigit(locPhrase.charAt(0))
|| locPhrase.charAt(0) == 'S' || locPhrase.charAt(0) == 's'
|| locPhrase.charAt(0) == 'N' || locPhrase.charAt(0) == 'n'
|| locPhrase.contains("://"))) {
return null;
}
List<Double> d = new ArrayList<>();
List<Object> all = new ArrayList<>();
List<String> strings = new ArrayList<>();
splitObjects(locPhrase, d, all, strings);
if (d.size() == 0) {
return null;
}
// detect UTM
if (all.size() == 4 && d.size() == 3 && all.get(1) instanceof String) {
char ch = all.get(1).toString().charAt(0);
if (Character.isLetter(ch)) {
UTMPoint upoint = new UTMPoint(d.get(2), d.get(1), d.get(0).intValue(), ch);
LatLonPoint ll = upoint.toLatLonPoint();
return new LatLon(ll.getLatitude(), ll.getLongitude());
}
}
if (all.size() == 3 && d.size() == 2 && all.get(1) instanceof String) {
char ch = all.get(1).toString().charAt(0);
String combined = strings.get(2);
if (Character.isLetter(ch)) {
try {
String east = combined.substring(0, combined.length() / 2);
String north = combined.substring(combined.length() / 2, combined.length());
UTMPoint upoint = new UTMPoint(Double.parseDouble(north), Double.parseDouble(east), d.get(0)
.intValue(), ch);
LatLonPoint ll = upoint.toLatLonPoint();
return new LatLon(ll.getLatitude(), ll.getLongitude());
} catch (NumberFormatException e) {
}
}
}
// try to find split lat/lon position
int jointNumbers = 0;
int lastJoin = 0;
int degSplit = -1;
int degType = -1; // 0 - degree, 1 - minutes, 2 - seconds
boolean finishDegSplit = false;
int northSplit = -1;
int eastSplit = -1;
for (int i = 1; i < all.size(); i++ ) {
if (all.get(i - 1) instanceof Double && all.get(i) instanceof Double) {
jointNumbers ++;
lastJoin = i;
}
if (all.get(i).equals("n") || all.get(i).equals("s") ||
all.get(i).equals("N") || all.get(i).equals("S")) {
northSplit = i + 1;
}
if (all.get(i).equals("e") || all.get(i).equals("w") ||
all.get(i).equals("E") || all.get(i).equals("W")) {
eastSplit = i;
}
int dg = -1;
if (all.get(i).equals("°")) {
dg = 0;
} else if (all.get(i).equals("\'") || all.get(i).equals("")) {
dg = 1;
} else if (all.get(i).equals("") || all.get(i).equals("\"")) {
dg = 2;
}
if (dg != -1) {
if (!finishDegSplit) {
if (degType < dg) {
degSplit = i + 1;
degType = dg;
} else {
finishDegSplit = true;
degType = dg;
}
} else {
if (degType < dg) {
degType = dg;
} else {
// reject delimiter
degSplit = -1;
}
}
}
}
int split = -1;
if (jointNumbers == 1) {
split = lastJoin;
}
if (northSplit != -1 && northSplit < all.size() -1) {
split = northSplit;
} else if (eastSplit != -1 && eastSplit < all.size() -1) {
split = eastSplit;
} else if (degSplit != -1 && degSplit < all.size() -1) {
split = degSplit;
}
if (split != -1) {
double lat = parse1Coordinate(all, 0, split);
double lon = parse1Coordinate(all, split, all.size());
return new LatLon(lat, lon);
}
if (d.size() == 2) {
return new LatLon(d.get(0), d.get(1));
}
// simple url case
if (locPhrase.contains("://")) {
double lat = 0;
double lon = 0;
boolean only2decimals = true;
for (int i = 0; i < d.size(); i++) {
if (d.get(i).doubleValue() != d.get(i).intValue()) {
if (lat == 0) {
lat = d.get(i);
} else if (lon == 0) {
lon = d.get(i);
} else {
only2decimals = false;
}
}
}
if (lat != 0 && lon != 0 && only2decimals) {
return new LatLon(lat, lon);
}
}
// split by equal number of digits
if (d.size() > 2 && d.size() % 2 == 0) {
int ind = d.size() / 2 + 1;
int splitEq = -1;
for (int i = 0; i < all.size(); i++) {
if (all.get(i) instanceof Double) {
ind --;
}
if (ind == 0) {
splitEq = i;
break;
}
}
if (splitEq != -1) {
double lat = parse1Coordinate(all, 0, splitEq);
double lon = parse1Coordinate(all, splitEq, all.size());
return new LatLon(lat, lon);
}
}
return null;
}
public static double parse1Coordinate(List<Object> all, int begin, int end) {
boolean neg = false;
double d = 0;
int type = 0; // degree - 0, minutes - 1, seconds = 2
Double prevDouble = null;
for (int i = begin; i <= end; i++) {
Object o = i == end ? "" : all.get(i);
if(o.equals("S") || o.equals("W")) {
neg = !neg;
}
if (prevDouble != null) {
if (o.equals("°")) {
type = 0;
} else if (o.equals("") /*o.equals("'")*/) {
// ' can be used as delimeter ignore it
type = 1;
} else if (o.equals("\"") || o.equals("")) {
type = 2;
}
if (type == 0) {
double ld = prevDouble.doubleValue();
if (ld < 0) {
ld = -ld;
neg = true;
}
d += ld;
} else if (type == 1) {
d += prevDouble.doubleValue() / 60.f;
} else /*if (type == 1) */ {
d += prevDouble.doubleValue() / 3600.f;
}
type++;
}
if (o instanceof Double) {
prevDouble = (Double) o;
} else {
prevDouble = null;
}
}
if (neg) {
d = -d;
}
return d;
}
public static void splitObjects(String s, List<Double> d, List<Object> all, List<String> strings) {
boolean digit = false;
int word = -1;
for (int i = 0; i <= s.length(); i++) {
char ch = i == s.length() ? ' ' : s.charAt(i);
boolean dg = Character.isDigit(ch);
boolean nonwh = ch != ',' && ch != ' ' && ch != ';';
if (ch == '.' || dg || ch == '-' ) {
if (!digit) {
if (word != -1) {
all.add(s.substring(word, i));
strings.add(s.substring(word, i));
}
digit = true;
word = i;
} else {
if(word == -1) {
word = i;
}
// if digit
// continue
}
} else {
if (digit){
if (word != -1) {
try {
double dl = Double.parseDouble(s.substring(word, i));
d.add(dl);
all.add(dl);
strings.add(s.substring(word, i));
digit = false;
word = -1;
} catch (NumberFormatException e) {
}
}
}
if (nonwh) {
if(!Character.isLetter(ch)) {
if(word != -1) {
all.add(s.substring(word, i));
strings.add(s.substring(word, i));
}
all.add(s.substring(i, i + 1));
strings.add(s.substring(i, i +1));
word = -1;
} else if(word == -1) {
word = i;
}
} else {
if (word != -1) {
all.add(s.substring(word, i));
strings.add(s.substring(word, i));
}
word = -1;
}
}
}
}
}

View file

@ -1,11 +1,9 @@
package net.osmand.util; package net.osmand.util;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
import net.osmand.binary.BinaryMapIndexReader.SearchRequest;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.data.MapObject; import net.osmand.data.MapObject;
import net.osmand.data.QuadPoint; import net.osmand.data.QuadPoint;

View file

@ -399,7 +399,7 @@ dependencies {
exclude group: 'com.android.support' exclude group: 'com.android.support'
} }
compile 'com.github.PhilJay:MPAndroidChart:v3.0.1' compile 'com.github.PhilJay:MPAndroidChart:v3.0.1'
compile ("com.github.HITGIF:TextFieldBoxes:1.3.2"){ compile ("com.github.HITGIF:TextFieldBoxes:1.3.5"){
exclude group: 'com.android.support' exclude group: 'com.android.support'
} }
} }

View file

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/ic_action_backspace_fill" android:state_pressed="true"/>
<item android:drawable="@drawable/ic_action_backspace_stroke"/>
</selector>

View file

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/ic_action_next_field_fill" android:state_pressed="true"/>
<item android:drawable="@drawable/ic_action_next_field_stroke"/>
</selector>

View file

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/keyboard_item_add_button_dark_bg_pressed" android:state_pressed="true"/>
<item android:drawable="@color/keyboard_item_add_button_dark_bg"/>
</selector>

View file

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/keyboard_item_add_button_light_bg_pressed" android:state_pressed="true"/>
<item android:drawable="@color/keyboard_item_add_button_light_bg"/>
</selector>

View file

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/keyboard_item_control_dark_bg_pressed" android:state_pressed="true"/>
<item android:drawable="@color/keyboard_item_control_dark_bg"/>
</selector>

View file

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/keyboard_item_control_light_bg_pressed" android:state_pressed="true"/>
<item android:drawable="@color/keyboard_item_control_light_bg"/>
</selector>

View file

@ -1,7 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android"> <selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/keyboard_item_dark_bg_pressed" android:state_pressed="true"/>
<item android:color="@color/map_widget_blue" android:state_pressed="true"/> <item android:drawable="@color/keyboard_item_dark_bg"/>
<item android:color="@color/bg_color_dark"/>
</selector> </selector>

View file

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/keyboard_item_divider_control_color_light_pressed" android:state_pressed="true"/>
<item android:color="@color/keyboard_item_divider_control_color_light"/>
</selector>

View file

@ -1,7 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android"> <selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/keyboard_item_light_bg_pressed" android:state_pressed="true"/>
<item android:drawable="@color/map_widget_blue" android:state_pressed="true"/> <item android:drawable="@color/keyboard_item_light_bg"/>
<item android:drawable="@color/bg_color_light"/>
</selector> </selector>

View file

@ -0,0 +1,131 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:osmand="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="@+id/coordinate_input_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="12dp"
android:paddingTop="12dp"
osmand:contentInsetLeft="4dp"
osmand:contentInsetStart="4dp"
osmand:contentInsetRight="16dp"
osmand:contentInsetEnd="16dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageButton
android:id="@+id/back_button"
style="@style/Widget.AppCompat.ActionButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_arrow_back"
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.widgets.OsmandTextFieldBoxes
android:theme="@style/OsmandTextFieldBoxes"
android:id="@+id/latitude_box"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
osmand:labelText="@string/navigate_point_latitude"
android:layout_marginEnd="12dp"
android:layout_marginRight="12dp">
<studio.carbonylgroup.textfieldboxes.ExtendedEditText
android:textColor="@color/color_white"
android:textColorHint="@color/white_50_transparent"
android:inputType="numberSigned|numberDecimal"
android:imeOptions="actionNext"
android:id="@+id/latitude_edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</net.osmand.plus.widgets.OsmandTextFieldBoxes>
<net.osmand.plus.widgets.OsmandTextFieldBoxes
android:theme="@style/OsmandTextFieldBoxes"
android:id="@+id/longitude_box"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
osmand:labelText="@string/navigate_point_longitude"
android:layout_marginEnd="12dp"
android:layout_marginRight="12dp">
<studio.carbonylgroup.textfieldboxes.ExtendedEditText
android:textColor="@color/color_white"
android:textColorHint="@color/white_50_transparent"
android:inputType="numberSigned|numberDecimal"
android:imeOptions="actionNext"
android:id="@+id/longitude_edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</net.osmand.plus.widgets.OsmandTextFieldBoxes>
<net.osmand.plus.widgets.OsmandTextFieldBoxes
android:theme="@style/OsmandTextFieldBoxes"
android:id="@+id/name_box"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
osmand:labelText="@string/shared_string_name"
android:layout_marginEnd="10dp"
android:layout_marginRight="10dp">
<studio.carbonylgroup.textfieldboxes.ExtendedEditText
android:textColor="@color/color_white"
android:textColorHint="@color/white_50_transparent"
android:inputType="text"
android:imeOptions="actionDone"
android:id="@+id/name_edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/access_hint_enter_name"/>
</net.osmand.plus.widgets.OsmandTextFieldBoxes>
<ImageButton
android:id="@+id/options_button"
style="@style/Widget.AppCompat.ActionButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_overflow_menu_white"/>
</LinearLayout>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<LinearLayout
android:id="@+id/hand_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
</LinearLayout>
</LinearLayout>

View file

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<View
android:id="@+id/keyboard_item_top_spacing"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.35"/>
<android.support.v7.widget.AppCompatTextView
android:id="@+id/keyboard_item_text"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.3"
android:gravity="center"
android:textAllCaps="true"
tools:text="3"/>
<View
android:id="@+id/keyboard_item_bottom_spacing"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.35"/>
<ImageView
android:id="@+id/keyboard_item_image"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="center"
android:layout_weight="1"
android:scaleType="center"
tools:src="@drawable/ic_action_backspace_fill"/>
</LinearLayout>

View file

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView
android:layout_weight="0.55"
android:layout_width="0dp"
android:layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:osmand="http://schemas.android.com/apk/res-auto">
<LinearLayout
android:id="@+id/map_markers_layout"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<View
android:layout_width="match_parent"
android:layout_height="8dp"/>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="match_parent"
osmand:cardUseCompatPadding="true"
osmand:cardCornerRadius="2dp">
<android.support.v7.widget.RecyclerView
android:nestedScrollingEnabled="false"
android:id="@+id/markers_recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</android.support.v7.widget.CardView>
<View
android:layout_width="match_parent"
android:layout_height="8dp"/>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>

View file

@ -0,0 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
android:layout_weight="0.45"
android:id="@+id/keyboard_layout"
android:layout_width="0dp"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<GridView
android:id="@+id/keyboard_grid_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="53dp"
android:horizontalSpacing="1dp"
android:numColumns="4"
android:stretchMode="columnWidth"
android:verticalSpacing="1dp"/>
<LinearLayout
android:orientation="vertical"
android:layout_gravity="bottom"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<View
android:id="@+id/keyboard_divider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?attr/keyboard_controls_divider"/>
<android.support.v7.widget.AppCompatTextView
android:id="@+id/add_marker_button"
android:layout_width="match_parent"
android:layout_height="52dp"
android:ellipsize="end"
android:gravity="center"
android:maxLines="1"
android:text="@string/shared_string_add"
android:textAllCaps="true"
android:textColor="@color/keyboard_item_button_text_color"
android:textSize="@dimen/default_list_text_size"/>
</LinearLayout>
</FrameLayout>

View file

@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<FrameLayout <FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:osmand="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
xmlns:osmand="http://schemas.android.com/tools"> xmlns:tools="http://schemas.android.com/tools">
<LinearLayout <LinearLayout
android:orientation="vertical" android:orientation="vertical"
@ -12,8 +12,8 @@
android:layout_height="match_parent"> android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout <android.support.design.widget.AppBarLayout
android:id="@+id/app_bar"
android:orientation="vertical" android:orientation="vertical"
android:background="@color/map_widget_blue"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
@ -21,8 +21,10 @@
android:id="@+id/coordinate_input_toolbar" android:id="@+id/coordinate_input_toolbar"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/dashboard_map_toolbar" android:layout_height="@dimen/dashboard_map_toolbar"
app:contentInsetLeft="54dp" osmand:contentInsetLeft="4dp"
app:contentInsetStart="54dp"> osmand:contentInsetStart="4dp"
osmand:contentInsetRight="0dp"
osmand:contentInsetEnd="0dp">
<LinearLayout <LinearLayout
android:orientation="horizontal" android:orientation="horizontal"
@ -30,6 +32,15 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:gravity="center_vertical"> android:gravity="center_vertical">
<ImageButton
android:id="@+id/back_button"
style="@style/Widget.AppCompat.ActionButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_arrow_back"
android:layout_marginRight="16dp"
android:layout_marginEnd="16dp"/>
<net.osmand.plus.widgets.TextViewEx <net.osmand.plus.widgets.TextViewEx
android:layout_width="0dp" android:layout_width="0dp"
android:layout_weight="1" android:layout_weight="1"
@ -43,14 +54,14 @@
android:textSize="@dimen/dialog_header_text_size"/> android:textSize="@dimen/dialog_header_text_size"/>
<net.osmand.plus.widgets.TextViewEx <net.osmand.plus.widgets.TextViewEx
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:id="@+id/options_button" android:id="@+id/options_button"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="match_parent"
android:gravity="center_vertical" android:gravity="center_vertical"
android:ellipsize="end" android:ellipsize="end"
android:maxLines="1" android:maxLines="1"
android:paddingRight="16dp"
android:paddingLeft="16dp"
android:text="@string/shared_string_options" android:text="@string/shared_string_options"
osmand:typeface="@string/font_roboto_regular" osmand:typeface="@string/font_roboto_regular"
android:textAllCaps="true" android:textAllCaps="true"
@ -61,6 +72,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"
@ -68,39 +85,45 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<net.osmand.plus.OsmandTextFieldBoxes <net.osmand.plus.widgets.OsmandTextFieldBoxes
android:theme="@style/OsmandTextFieldBoxes"
android:id="@+id/latitude_box" android:id="@+id/latitude_box"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_weight="1" android:layout_weight="1"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:labelText="@string/navigate_point_latitude"> osmand:labelText="@string/navigate_point_latitude"
android:layout_marginRight="16dp"
android:layout_marginEnd="16dp">
<studio.carbonylgroup.textfieldboxes.ExtendedEditText <studio.carbonylgroup.textfieldboxes.ExtendedEditText
android:hint="50:00.0000" android:textColor="@color/color_white"
android:textColorHint="@color/white_50_transparent"
android:inputType="numberSigned|numberDecimal"
android:imeOptions="actionNext"
android:id="@+id/latitude_edit_text" android:id="@+id/latitude_edit_text"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"/> android:layout_height="wrap_content"/>
</net.osmand.plus.OsmandTextFieldBoxes> </net.osmand.plus.widgets.OsmandTextFieldBoxes>
<View <net.osmand.plus.widgets.OsmandTextFieldBoxes
android:layout_width="16dp" android:theme="@style/OsmandTextFieldBoxes"
android:layout_height="match_parent"/>
<net.osmand.plus.OsmandTextFieldBoxes
android:id="@+id/longitude_box" android:id="@+id/longitude_box"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_weight="1" android:layout_weight="1"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:labelText="@string/navigate_point_longitude"> osmand:labelText="@string/navigate_point_longitude">
<studio.carbonylgroup.textfieldboxes.ExtendedEditText <studio.carbonylgroup.textfieldboxes.ExtendedEditText
android:hint="50:00.0000" android:textColor="@color/color_white"
android:textColorHint="@color/white_50_transparent"
android:inputType="numberSigned|numberDecimal"
android:imeOptions="actionNext"
android:id="@+id/longitude_edit_text" android:id="@+id/longitude_edit_text"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"/> android:layout_height="wrap_content"/>
</net.osmand.plus.OsmandTextFieldBoxes> </net.osmand.plus.widgets.OsmandTextFieldBoxes>
</LinearLayout> </LinearLayout>
@ -110,24 +133,27 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<net.osmand.plus.OsmandTextFieldBoxes <net.osmand.plus.widgets.OsmandTextFieldBoxes
android:theme="@style/OsmandTextFieldBoxes"
android:id="@+id/name_box" android:id="@+id/name_box"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_weight="1" android:layout_weight="1"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:labelText="@string/shared_string_name"> osmand:labelText="@string/shared_string_name"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp">
<studio.carbonylgroup.textfieldboxes.ExtendedEditText <studio.carbonylgroup.textfieldboxes.ExtendedEditText
android:textColor="@color/color_white"
android:textColorHint="@color/white_50_transparent"
android:inputType="text"
android:imeOptions="actionDone"
android:hint="@string/access_hint_enter_name" android:hint="@string/access_hint_enter_name"
android:id="@+id/name_edit_text" android:id="@+id/name_edit_text"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"/> android:layout_height="wrap_content"/>
</net.osmand.plus.OsmandTextFieldBoxes> </net.osmand.plus.widgets.OsmandTextFieldBoxes>
<View
android:layout_width="16dp"
android:layout_height="match_parent"/>
<View <View
android:layout_width="0dp" android:layout_width="0dp"
@ -139,6 +165,10 @@
</android.support.design.widget.AppBarLayout> </android.support.design.widget.AppBarLayout>
<android.support.v7.widget.RecyclerView <android.support.v7.widget.RecyclerView
android:paddingTop="16dp"
android:paddingBottom="72dp"
android:id="@+id/markers_recycler_view"
android:clipToPadding="false"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"/> android:layout_height="match_parent"/>
@ -155,50 +185,48 @@
android:id="@+id/keyboard_grid_view" android:id="@+id/keyboard_grid_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="?attr/dashboard_divider"
android:horizontalSpacing="1dp" android:horizontalSpacing="1dp"
android:verticalSpacing="1dp" android:verticalSpacing="1dp"
android:stretchMode="columnWidth" android:stretchMode="columnWidth"
android:numColumns="3"/> android:numColumns="4"/>
<View <View
android:id="@+id/keyboard_divider" android:id="@+id/keyboard_divider"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="1dp" android:layout_height="1dp"
android:background="?attr/dashboard_divider"/> android:background="?attr/keyboard_controls_divider"/>
<LinearLayout <LinearLayout
android:background="?attr/bg_color"
android:orientation="horizontal" android:orientation="horizontal"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="56dp"> android:layout_height="56dp">
<ImageView <android.support.v7.widget.AppCompatTextView
android:id="@+id/show_hide_keyboard_icon" android:maxLines="1"
android:padding="@dimen/content_padding" android:ellipsize="end"
android:background="?attr/selectableItemBackground" android:id="@+id/add_marker_button"
android:layout_gravity="center_vertical" android:textAllCaps="true"
android:layout_width="wrap_content" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_weight="3"
osmand:src="@drawable/ic_action_arrow_down"/> android:layout_height="match_parent"
android:gravity="center"
android:textColor="@color/keyboard_item_button_text_color"
android:textSize="@dimen/default_list_text_size"
android:text="@string/shared_string_add"/>
<View <View
android:layout_width="1dp" android:layout_width="1dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="?attr/dashboard_divider"/> android:background="?attr/keyboard_controls_divider"/>
<net.osmand.plus.widgets.TextViewEx <ImageView
android:maxLines="1" android:id="@+id/show_hide_keyboard_icon"
android:ellipsize="end" android:layout_gravity="center_vertical"
android:id="@+id/add_marker"
android:textAllCaps="true"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_weight="1" android:layout_weight="1"
android:layout_height="match_parent" android:layout_height="match_parent"
android:gravity="center" android:scaleType="center"
android:textColor="@color/keyboard_color" tools:src="@drawable/ic_action_arrow_down"/>
osmand:typeface="@string/font_roboto_regular"
android:text="@string/shared_string_add"/>
</LinearLayout> </LinearLayout>

View file

@ -1,73 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:osmand="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/bg_color"
android:orientation="vertical">
<ScrollView
android:id="@+id/marker_coordinate_input_scroll_view"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="@dimen/bottom_sheet_content_padding_small">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/coordinate_input_title"
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_title_height"
android:gravity="center_vertical"
android:paddingEnd="@dimen/content_padding"
android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding"
android:paddingStart="@dimen/content_padding"
android:text="@string/fast_coordinates_input"
android:textAppearance="@style/TextAppearance.ListItemTitle"
osmand:typeface="@string/font_roboto_medium"/>
<TextView
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_descr_height"
android:paddingEnd="@dimen/content_padding"
android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding"
android:paddingStart="@dimen/content_padding"
android:text="@string/fast_coordinates_input_descr"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_desc_text_size"/>
<include layout="@layout/marker_coordinate_formats"/>
</LinearLayout>
</ScrollView>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?attr/dashboard_divider"/>
<FrameLayout
android:id="@+id/cancel_row"
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_cancel_button_height"
android:background="?attr/selectableItemBackground">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/shared_string_close"
android:textAllCaps="true"
android:textColor="?attr/color_dialog_buttons"
android:textSize="@dimen/default_desc_text_size"
android:textStyle="bold"/>
</FrameLayout>
</LinearLayout>

View file

@ -1,120 +1,249 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:osmand="http://schemas.android.com/apk/res-auto" xmlns:osmand="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/bg_color" android:background="?attr/bg_color"
android:orientation="vertical"> android:orientation="vertical">
<ScrollView <ScrollView
android:id="@+id/marker_coordinate_input_scroll_view" android:id="@+id/marker_coordinate_input_scroll_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:orientation="vertical"
android:paddingBottom="@dimen/bottom_sheet_content_padding_small"> android:paddingBottom="@dimen/bottom_sheet_content_padding_small">
<net.osmand.plus.widgets.TextViewEx <net.osmand.plus.widgets.TextViewEx
android:id="@+id/coordinate_input_title" android:id="@+id/coordinate_input_title"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_title_height" android:layout_height="@dimen/bottom_sheet_title_height"
android:gravity="center_vertical" android:gravity="center_vertical"
android:paddingEnd="@dimen/content_padding" android:paddingEnd="@dimen/content_padding"
android:paddingLeft="@dimen/content_padding" android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding" android:paddingRight="@dimen/content_padding"
android:paddingStart="@dimen/content_padding" android:paddingStart="@dimen/content_padding"
android:text="@string/shared_string_options" android:text="@string/shared_string_options"
android:textAppearance="@style/TextAppearance.ListItemTitle" android:textAppearance="@style/TextAppearance.ListItemTitle"
osmand:typeface="@string/font_roboto_medium"/> osmand:typeface="@string/font_roboto_medium"/>
<LinearLayout <LinearLayout
android:id="@+id/use_system_keyboard_row" android:id="@+id/use_system_keyboard_row"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_list_item_height" android:layout_height="@dimen/bottom_sheet_list_item_height"
android:background="?attr/selectableItemBackground" android:background="?attr/selectableItemBackground"
android:descendantFocusability="blocksDescendants" android:descendantFocusability="blocksDescendants"
android:minHeight="@dimen/bottom_sheet_list_item_height" android:minHeight="@dimen/bottom_sheet_list_item_height"
android:paddingLeft="@dimen/content_padding" android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding"> android:paddingRight="@dimen/content_padding">
<ImageView <ImageView
android:layout_gravity="center_vertical" android:id="@+id/use_system_keyboard_icon"
android:id="@+id/use_system_keyboard_icon" android:layout_width="wrap_content"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_height="wrap_content" android:layout_gravity="center_vertical"
android:layout_marginEnd="@dimen/bottom_sheet_icon_margin" android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
android:layout_marginRight="@dimen/bottom_sheet_icon_margin" android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
tools:src="@drawable/ic_action_keyboard"/> tools:src="@drawable/ic_action_keyboard"/>
<TextView <TextView
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:layout_weight="1" android:layout_weight="1"
android:ellipsize="end" android:ellipsize="end"
android:maxLines="1" android:maxLines="1"
android:text="@string/use_system_keyboard" android:text="@string/use_system_keyboard"
android:textAppearance="@style/TextAppearance.ListItemTitle"/> android:textAppearance="@style/TextAppearance.ListItemTitle"/>
<android.support.v7.widget.SwitchCompat <android.support.v7.widget.SwitchCompat
android:id="@+id/use_system_keyboard_switch" android:id="@+id/use_system_keyboard_switch"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical|end" android:layout_gravity="center_vertical|end"
android:background="@null" android:background="@null"
android:clickable="false" android:clickable="false"
android:focusable="false" android:focusable="false"
android:focusableInTouchMode="false"/> android:focusableInTouchMode="false"/>
</LinearLayout> </LinearLayout>
<View <LinearLayout
android:layout_width="match_parent" android:id="@+id/hand_row"
android:layout_height="1dp" android:layout_width="match_parent"
android:background="?attr/dashboard_divider"/> android:layout_height="@dimen/bottom_sheet_list_item_height"
android:background="?attr/selectableItemBackground"
android:descendantFocusability="blocksDescendants"
android:minHeight="@dimen/bottom_sheet_list_item_height"
android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding">
<TextView <ImageView
android:textColor="?android:textColorSecondary" android:id="@+id/hand_icon"
android:ellipsize="end" android:layout_width="wrap_content"
android:maxLines="1" android:layout_height="wrap_content"
android:textAllCaps="true" android:layout_gravity="center_vertical"
android:paddingTop="@dimen/bottom_sheet_content_padding_small" android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
android:paddingBottom="@dimen/bottom_sheet_content_padding_small" android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
android:paddingLeft="@dimen/content_padding" tools:src="@drawable/ic_action_show_keypad_right"/>
android:paddingRight="@dimen/content_padding"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/coordinates_format"/>
<include layout="@layout/marker_coordinate_formats"/> <TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:ellipsize="end"
android:maxLines="1"
android:text="@string/show_number_pad"
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
</LinearLayout> <net.osmand.plus.widgets.TextViewEx
osmand:typeface="@string/font_roboto_medium"
android:id="@+id/hand_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|end"
android:maxLines="1"
android:textSize="@dimen/default_list_text_size"
tools:textColor="@color/map_widget_blue_pressed"
tools:text="Right"/>
</LinearLayout>
</ScrollView> <View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?attr/dashboard_divider"/>
<View <LinearLayout
android:layout_width="match_parent" android:id="@+id/go_to_next_field_row"
android:layout_height="1dp" android:layout_width="match_parent"
android:background="?attr/dashboard_divider"/> android:layout_height="@dimen/bottom_sheet_list_item_height"
android:background="?attr/selectableItemBackground"
android:descendantFocusability="blocksDescendants"
android:minHeight="@dimen/bottom_sheet_list_item_height"
android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding">
<FrameLayout <ImageView
android:id="@+id/cancel_row" android:id="@+id/go_to_next_field_icon"
android:layout_width="match_parent" android:layout_width="wrap_content"
android:layout_height="@dimen/bottom_sheet_cancel_button_height" android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"> android:layout_gravity="center_vertical"
android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
tools:src="@drawable/ic_action_keyboard"/>
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="center_vertical"
android:text="@string/shared_string_close" android:layout_weight="1"
android:textAllCaps="true" android:ellipsize="end"
android:textColor="?attr/color_dialog_buttons" android:maxLines="1"
android:textSize="@dimen/default_desc_text_size" android:text="@string/go_to_next_field"
android:textStyle="bold"/> android:textAppearance="@style/TextAppearance.ListItemTitle"/>
</FrameLayout>
<android.support.v7.widget.SwitchCompat
android:id="@+id/go_to_next_field_switch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|end"
android:background="@null"
android:clickable="false"
android:focusable="false"
android:focusableInTouchMode="false"/>
</LinearLayout>
<TextView
android:id="@+id/coordinate_input_accuracy_descr"
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_descr_height"
android:paddingEnd="@dimen/content_padding"
android:paddingLeft="@dimen/bottom_sheet_divider_margin_start"
android:paddingRight="@dimen/content_padding"
android:paddingStart="@dimen/bottom_sheet_divider_margin_start"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_desc_text_size"
tools:text="@string/coordinate_input_accuracy_description"/>
<LinearLayout
android:id="@+id/accuracy_row"
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_list_item_height"
android:background="?attr/selectableItemBackground"
android:gravity="center_vertical"
android:minHeight="@dimen/bottom_sheet_list_item_height"
android:paddingEnd="@dimen/content_padding"
android:paddingLeft="@dimen/bottom_sheet_divider_margin_start"
android:paddingRight="@dimen/content_padding"
android:paddingStart="@dimen/bottom_sheet_divider_margin_start">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:ellipsize="end"
android:textAppearance="@style/TextAppearance.ListItemTitle"
android:text="@string/digits_quantity"/>
<TextView
android:id="@+id/selected_accuracy_hint"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text="00:00.0"/>
</LinearLayout>
<TextView
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:textAppearance="@style/TextAppearance.ListItemTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/selected_accuracy"
tools:text="1"/>
<ImageView
android:id="@+id/accuracy_arrow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:src="@drawable/ic_action_arrow_drop_down"/>
</LinearLayout>
</LinearLayout>
</ScrollView>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?attr/dashboard_divider"/>
<FrameLayout
android:id="@+id/cancel_row"
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_cancel_button_height"
android:background="?attr/selectableItemBackground">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/shared_string_close"
android:textAllCaps="true"
android:textColor="?attr/color_dialog_buttons"
android:textSize="@dimen/default_desc_text_size"
android:textStyle="bold"/>
</FrameLayout>
</LinearLayout> </LinearLayout>

View file

@ -112,7 +112,6 @@
android:background="?attr/dashboard_divider"/> android:background="?attr/dashboard_divider"/>
<LinearLayout <LinearLayout
android:visibility="gone"
android:id="@+id/coordinate_input_row" android:id="@+id/coordinate_input_row"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_list_item_height" android:layout_height="@dimen/bottom_sheet_list_item_height"

View file

@ -1,19 +1,38 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
xmlns:osmand="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="56dp" android:layout_height="56dp"
android:orientation="vertical"> android:orientation="vertical">
<net.osmand.plus.widgets.TextViewEx <View
android:id="@+id/keyboard_item" android:id="@+id/keyboard_item_top_spacing"
android:textAllCaps="true"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="0dp"
android:layout_weight="0.25"/>
<android.support.v7.widget.AppCompatTextView
android:id="@+id/keyboard_item_text"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.5"
android:gravity="center" android:gravity="center"
android:textColor="@color/keyboard_color" android:textAllCaps="true"
osmand:typeface="@string/font_roboto_regular"
tools:text="3"/> tools:text="3"/>
<View
android:id="@+id/keyboard_item_bottom_spacing"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.25"/>
<ImageView
android:id="@+id/keyboard_item_image"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="center"
android:layout_weight="1"
android:scaleType="center"
tools:src="@drawable/ic_action_backspace_fill"/>
</LinearLayout> </LinearLayout>

View file

@ -28,6 +28,17 @@
android:layout_height="@dimen/map_button_shadow_width" android:layout_height="@dimen/map_button_shadow_width"
android:background="?attr/selectableItemBackground"> android:background="?attr/selectableItemBackground">
<android.support.v7.widget.AppCompatTextView
android:textSize="@dimen/default_list_text_size"
tools:text="3"
android:gravity="center"
android:id="@+id/map_marker_number_text_view"
android:layout_width="@dimen/map_button_shadow_width"
android:layout_height="@dimen/map_button_shadow_width"
android:layout_gravity="center_vertical"
android:visibility="gone"
tools:visibility="visible"/>
<android.support.v7.widget.AppCompatImageView <android.support.v7.widget.AppCompatImageView
android:id="@+id/map_marker_reorder_icon" android:id="@+id/map_marker_reorder_icon"
android:layout_width="@dimen/map_button_shadow_width" android:layout_width="@dimen/map_button_shadow_width"

View file

@ -1,123 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/degrees_row"
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_list_item_height"
android:background="?attr/selectableItemBackground"
android:gravity="center_vertical"
android:minHeight="@dimen/bottom_sheet_list_item_height"
android:paddingEnd="@dimen/content_padding"
android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding"
android:paddingStart="@dimen/content_padding">
<ImageView
android:id="@+id/degrees_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
tools:src="@drawable/ic_action_coordinates_latitude"/>
<TextView
android:id="@+id/degrees_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:maxLines="1"
android:textAppearance="@style/TextAppearance.ListItemTitle"
tools:text="DDD.DD"/>
<RadioButton
android:id="@+id/degrees_radio_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
android:clickable="false"
android:focusable="false"/>
</LinearLayout>
<LinearLayout
android:id="@+id/minutes_row"
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_list_item_height"
android:background="?attr/selectableItemBackground"
android:gravity="center_vertical"
android:minHeight="@dimen/bottom_sheet_list_item_height"
android:paddingEnd="@dimen/content_padding"
android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding"
android:paddingStart="@dimen/content_padding">
<ImageView
android:id="@+id/minutes_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
tools:src="@drawable/ic_action_coordinates_latitude"/>
<TextView
android:id="@+id/minutes_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:maxLines="1"
android:textAppearance="@style/TextAppearance.ListItemTitle"
tools:text="DDD MM.MM"/>
<RadioButton
android:id="@+id/minutes_radio_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
android:clickable="false"
android:focusable="false"/>
</LinearLayout>
<LinearLayout
android:id="@+id/seconds_row"
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_list_item_height"
android:background="?attr/selectableItemBackground"
android:gravity="center_vertical"
android:minHeight="@dimen/bottom_sheet_list_item_height"
android:paddingEnd="@dimen/content_padding"
android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding"
android:paddingStart="@dimen/content_padding">
<ImageView
android:id="@+id/seconds_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
tools:src="@drawable/ic_action_coordinates_latitude"/>
<TextView
android:id="@+id/seconds_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:maxLines="1"
android:textAppearance="@style/TextAppearance.ListItemTitle"
tools:text="DDD MM SS.SS"/>
<RadioButton
android:id="@+id/seconds_radio_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
android:clickable="false"
android:focusable="false"/>
</LinearLayout>
</LinearLayout>

View file

@ -11,7 +11,7 @@
android:focusable="true" android:focusable="true"
android:focusableInTouchMode="true"/> android:focusableInTouchMode="true"/>
<net.osmand.plus.OsmandTextFieldBoxes <net.osmand.plus.widgets.OsmandTextFieldBoxes
android:id="@+id/name_text_box" android:id="@+id/name_text_box"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@ -26,6 +26,6 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"/> android:layout_height="wrap_content"/>
</net.osmand.plus.OsmandTextFieldBoxes> </net.osmand.plus.widgets.OsmandTextFieldBoxes>
</LinearLayout> </LinearLayout>

View file

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/action_copy"
android:title="@string/shared_string_copy"/>
<item
android:id="@+id/action_paste"
android:title="@string/shared_string_paste"/>
</menu>

View file

@ -7,6 +7,7 @@
<attr name="mapBackground" format="reference"/> <attr name="mapBackground" format="reference"/>
<attr name="routeParameterTitleColor" format="color"/> <attr name="routeParameterTitleColor" format="color"/>
<attr name="chart_marker_background" format="reference" /> <attr name="chart_marker_background" format="reference" />
<attr name="keyboard_controls_divider" format="color"/>
<!-- list colors --> <!-- list colors -->
<attr name="ctx_menu_info_divider" format="color"/> <attr name="ctx_menu_info_divider" format="color"/>
<attr name="searchbar_text" format="color"/> <attr name="searchbar_text" format="color"/>

View file

@ -274,6 +274,35 @@
<color name="marker_circle_button_color_dark">#525e66</color> <color name="marker_circle_button_color_dark">#525e66</color>
<color name="keyboard_color">#545454</color> <color name="keyboard_item_divider_control_color_light">#727272</color>
<color name="keyboard_item_divider_control_color_light_pressed">#ffffff</color>
<color name="keyboard_item_divider_control_color_dark">#8899a6</color>
<color name="keyboard_item_text_color_light">#333333</color>
<color name="keyboard_item_text_color_light_pressed">#ffffff</color>
<color name="keyboard_item_text_color_dark">#ffffff</color>
<color name="keyboard_item_light_bg">#fff</color>
<color name="keyboard_item_light_bg_pressed">#536dfe</color>
<color name="keyboard_item_dark_bg">#1f2326</color>
<color name="keyboard_item_dark_bg_pressed">#536dfe</color>
<color name="keyboard_item_control_light_bg">#f2f2f2</color>
<color name="keyboard_item_control_light_bg_pressed">#536dfe</color>
<color name="keyboard_item_control_dark_bg">#191c1e</color>
<color name="keyboard_item_control_dark_bg_pressed">#536dfe</color>
<color name="keyboard_item_add_button_light_bg">#536dfe</color>
<color name="keyboard_item_add_button_light_bg_pressed">#4b62e3</color>
<color name="keyboard_item_add_button_dark_bg">#2d3980</color>
<color name="keyboard_item_add_button_dark_bg_pressed">#4b62e3</color>
<color name="keyboard_item_button_text_color">#ffffff</color>
<color name="keyboard_item_add_button_divider_light">#4b62e3</color>
<color name="keyboard_item_add_button_divider_dark">#121733</color>
<color name="keyboard_divider_light">#e6e6e6</color>
<color name="keyboard_divider_dark">#2a2f33</color>
<color name="coordinate_input_status_bar_color_light">#4257c9</color>
<color name="coordinate_input_status_bar_color_dark">#1b224d</color>
<color name="coordinate_input_app_bar_color_light">#536dfe</color>
<color name="coordinate_input_app_bar_color_dark">#2d3980</color>
<color name="coordinate_input_keyboard_icon_color">#9fadfc</color>
<color name="coordinate_input_error_color">#ed5421</color>
</resources> </resources>

View file

@ -9,6 +9,14 @@
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated). 3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
--> -->
<string name="digits_quantity">Digits quantity</string>
<string name="shared_string_right">Right</string>
<string name="shared_string_left">Left</string>
<string name="show_number_pad">Show number pad</string>
<string name="shared_string_paste">Paste</string>
<string name="coordinate_input_accuracy_description">Automatically switch to the next field after entering %1$d digits after the decimal point</string>
<string name="coordinate_input_accuracy">%1$d digits</string>
<string name="go_to_next_field">Go to next field</string>
<string name="rename_marker">Rename marker</string> <string name="rename_marker">Rename marker</string>
<string name="tap_on_map_to_hide_interface_descr">A tap on the map toggles the control buttons and widgets.</string> <string name="tap_on_map_to_hide_interface_descr">A tap on the map toggles the control buttons and widgets.</string>
<string name="tap_on_map_to_hide_interface">Full screen mode</string> <string name="tap_on_map_to_hide_interface">Full screen mode</string>

View file

@ -86,6 +86,12 @@
<item name="android:windowBackground">@drawable/first_splash_screen_free_dev</item> <item name="android:windowBackground">@drawable/first_splash_screen_free_dev</item>
</style> </style>
<style name="OsmandTextFieldBoxes" parent="OsmandDarkTheme">
<item name="android:textColorTertiary">@color/white_50_transparent</item>
<item name="primaryColor">@color/white_50_transparent</item>
<item name="errorColor">@color/coordinate_input_error_color</item>
</style>
<style name="OsmandLightThemeWithLightStatusBar" parent="OsmandLightTheme"> <style name="OsmandLightThemeWithLightStatusBar" parent="OsmandLightTheme">
<item name="android:statusBarColor">@color/status_bar_route_light</item> <item name="android:statusBarColor">@color/status_bar_route_light</item>
</style> </style>
@ -176,6 +182,8 @@
<item name="color_dialog_buttons">@color/color_dialog_buttons_light</item> <item name="color_dialog_buttons">@color/color_dialog_buttons_light</item>
<item name="popupMenuStyle">@style/PopupMenuLight</item> <item name="popupMenuStyle">@style/PopupMenuLight</item>
<item name="keyboard_controls_divider">@color/keyboard_item_add_button_divider_light</item>
</style> </style>
<style name="OverflowMenuButton" parent="@style/Widget.AppCompat.ActionButton.Overflow"> <style name="OverflowMenuButton" parent="@style/Widget.AppCompat.ActionButton.Overflow">
@ -347,6 +355,8 @@
<item name="color_dialog_buttons">@color/color_dialog_buttons_dark</item> <item name="color_dialog_buttons">@color/color_dialog_buttons_dark</item>
<item name="popupMenuStyle">@style/PopupMenuDark</item> <item name="popupMenuStyle">@style/PopupMenuDark</item>
<item name="keyboard_controls_divider">@color/keyboard_item_add_button_divider_dark</item>
</style> </style>
<style name="FreeVersionBanner" parent="OsmandDarkTheme"> <style name="FreeVersionBanner" parent="OsmandDarkTheme">

View file

@ -50,15 +50,19 @@ public class AndroidUtils {
@Override @Override
public void run() { public void run() {
if (!isHardwareKeyboardAvailable(view.getContext())) { if (!isHardwareKeyboardAvailable(view.getContext())) {
InputMethodManager imm = (InputMethodManager) view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE); showSoftKeyboard(view);
if (imm != null) {
imm.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT);
}
} }
} }
}); });
} }
public static void showSoftKeyboard(final View view) {
InputMethodManager imm = (InputMethodManager) view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm != null) {
imm.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT);
}
}
public static void hideSoftKeyboard(final Activity activity, final View input) { public static void hideSoftKeyboard(final Activity activity, final View input) {
InputMethodManager inputMethodManager = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE); InputMethodManager inputMethodManager = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
if (inputMethodManager != null) { if (inputMethodManager != null) {

View file

@ -477,6 +477,18 @@ public class MapMarkersHelper {
} }
} }
public void addMarkers(List<MapMarker> markers) {
if (markers != null) {
markersDbHelper.addMarkers(markers);
mapMarkers.addAll(markers);
reorderActiveMarkersIfNeeded();
for (MapMarker marker : markers) {
addMarkerToGroup(marker);
}
refresh();
}
}
public void addMarker(MapMarker marker) { public void addMarker(MapMarker marker) {
if (marker != null) { if (marker != null) {
markersDbHelper.addMarker(marker); markersDbHelper.addMarker(marker);

View file

@ -1,32 +1,40 @@
package net.osmand.plus.mapmarkers; package net.osmand.plus.mapmarkers;
import android.content.DialogInterface;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat; import android.support.v4.content.ContextCompat;
import android.support.v7.widget.ListPopupWindow;
import android.view.ContextThemeWrapper; import android.view.ContextThemeWrapper;
import android.view.Gravity;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.CompoundButton; import android.widget.CompoundButton;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.RadioButton;
import android.widget.TextView; import android.widget.TextView;
import net.osmand.data.PointDescription; import net.osmand.AndroidUtils;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.base.MenuBottomSheetDialogFragment; import net.osmand.plus.base.MenuBottomSheetDialogFragment;
import net.osmand.plus.helpers.AndroidUiHelper;
import static net.osmand.plus.mapmarkers.CoordinateInputDialogFragment.ACCURACY;
import static net.osmand.plus.mapmarkers.CoordinateInputDialogFragment.GO_TO_NEXT_FIELD;
import static net.osmand.plus.mapmarkers.CoordinateInputDialogFragment.RIGHT_HAND;
import static net.osmand.plus.mapmarkers.CoordinateInputDialogFragment.USE_OSMAND_KEYBOARD;
public class CoordinateInputBottomSheetDialogFragment extends MenuBottomSheetDialogFragment { public class CoordinateInputBottomSheetDialogFragment extends MenuBottomSheetDialogFragment {
public final static String TAG = "CoordinateInputBottomSheetDialogFragment"; public final static String TAG = "CoordinateInputBottomSheetDialogFragment";
private View mainView; private View mainView;
private int coordinateFormat = -1; private boolean useOsmandKeyboard;
private boolean useOsmandKeyboard = true; private boolean rightHand;
private boolean goToNextField;
private int accuracy;
private CoordinateInputFormatChangeListener listener; private CoordinateInputFormatChangeListener listener;
private boolean shouldClose;
public void setListener(CoordinateInputFormatChangeListener listener) { public void setListener(CoordinateInputFormatChangeListener listener) {
this.listener = listener; this.listener = listener;
@ -35,115 +43,113 @@ public class CoordinateInputBottomSheetDialogFragment extends MenuBottomSheetDia
@Override @Override
public void onCreate(@Nullable Bundle savedInstanceState) { public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
Bundle args = getArguments(); if (savedInstanceState == null) {
if (args != null) { Bundle args = getArguments();
coordinateFormat = args.getInt(CoordinateInputDialogFragment.COORDINATE_FORMAT); if (args != null) {
useOsmandKeyboard = args.getBoolean(CoordinateInputDialogFragment.USE_OSMAND_KEYBOARD); useOsmandKeyboard = args.getBoolean(USE_OSMAND_KEYBOARD);
rightHand = args.getBoolean(RIGHT_HAND);
goToNextField = args.getBoolean(GO_TO_NEXT_FIELD);
accuracy = args.getInt(ACCURACY);
}
} else { } else {
shouldClose = true; useOsmandKeyboard = savedInstanceState.getBoolean(USE_OSMAND_KEYBOARD);
rightHand = savedInstanceState.getBoolean(RIGHT_HAND);
goToNextField = savedInstanceState.getBoolean(GO_TO_NEXT_FIELD);
accuracy = savedInstanceState.getInt(ACCURACY);
} }
} }
@Nullable @Nullable
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final MapActivity mapActivity = (MapActivity) getActivity();
final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme; final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
boolean portrait = AndroidUiHelper.isOrientationPortrait(getActivity());
mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), coordinateFormat == -1 ? mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_marker_coordinate_input_options_bottom_sheet_helper, container);
R.layout.fragment_marker_coordinate_input_bottom_sheet_dialog : R.layout.fragment_marker_coordinate_input_options_bottom_sheet_helper, container);
if (nightMode) { if (nightMode) {
((TextView) mainView.findViewById(R.id.coordinate_input_title)).setTextColor(getResources().getColor(R.color.ctx_menu_info_text_dark)); ((TextView) mainView.findViewById(R.id.coordinate_input_title)).setTextColor(getResources().getColor(R.color.ctx_menu_info_text_dark));
} }
ImageView degreesIcon = (ImageView) mainView.findViewById(R.id.degrees_icon); ((TextView) mainView.findViewById(R.id.coordinate_input_accuracy_descr)).setText(getString(R.string.coordinate_input_accuracy_description, accuracy));
TextView degreesText = (TextView) mainView.findViewById(R.id.degrees_text);
if (coordinateFormat == PointDescription.FORMAT_DEGREES) {
degreesIcon.setImageDrawable(getIcon(R.drawable.ic_action_coordinates_latitude, R.color.dashboard_blue));
degreesText.setTextColor(ContextCompat.getColor(mapActivity, R.color.dashboard_blue));
((RadioButton) mainView.findViewById(R.id.degrees_radio_button)).setChecked(true);
} else {
degreesIcon.setImageDrawable(getContentIcon(R.drawable.ic_action_coordinates_latitude));
}
degreesText.setText(PointDescription.formatToHumanString(getContext(), PointDescription.FORMAT_DEGREES));
ImageView minutesIcon = (ImageView) mainView.findViewById(R.id.minutes_icon); ((CompoundButton) mainView.findViewById(R.id.use_system_keyboard_switch)).setChecked(!useOsmandKeyboard);
TextView minutesText = (TextView) mainView.findViewById(R.id.minutes_text); ((ImageView) mainView.findViewById(R.id.use_system_keyboard_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_keyboard));
if (coordinateFormat == PointDescription.FORMAT_MINUTES) { mainView.findViewById(R.id.use_system_keyboard_row).setOnClickListener(new View.OnClickListener() {
minutesIcon.setImageDrawable(getIcon(R.drawable.ic_action_coordinates_latitude, R.color.dashboard_blue)); @Override
minutesText.setTextColor(ContextCompat.getColor(mapActivity, R.color.dashboard_blue)); public void onClick(View view) {
((RadioButton) mainView.findViewById(R.id.minutes_radio_button)).setChecked(true); useOsmandKeyboard = !useOsmandKeyboard;
} else { ((CompoundButton) mainView.findViewById(R.id.use_system_keyboard_switch)).setChecked(!useOsmandKeyboard);
minutesIcon.setImageDrawable(getContentIcon(R.drawable.ic_action_coordinates_latitude)); if (listener != null) {
} listener.onKeyboardChanged(useOsmandKeyboard);
minutesText.setText(PointDescription.formatToHumanString(getContext(), PointDescription.FORMAT_MINUTES)); }
}
});
ImageView secondsIcon = (ImageView) mainView.findViewById(R.id.seconds_icon); View handRow = mainView.findViewById(R.id.hand_row);
TextView secondsText = (TextView) mainView.findViewById(R.id.seconds_text); if (portrait) {
if (coordinateFormat == PointDescription.FORMAT_SECONDS) { handRow.setVisibility(View.GONE);
secondsIcon.setImageDrawable(getIcon(R.drawable.ic_action_coordinates_latitude, R.color.dashboard_blue));
secondsText.setTextColor(ContextCompat.getColor(mapActivity, R.color.dashboard_blue));
((RadioButton) mainView.findViewById(R.id.seconds_radio_button)).setChecked(true);
} else { } else {
secondsIcon.setImageDrawable(getContentIcon(R.drawable.ic_action_coordinates_latitude)); handRow.setOnClickListener(new View.OnClickListener() {
}
secondsText.setText(PointDescription.formatToHumanString(getContext(), PointDescription.FORMAT_SECONDS));
if (coordinateFormat != -1) {
((CompoundButton) mainView.findViewById(R.id.use_system_keyboard_switch)).setChecked(!useOsmandKeyboard);
((ImageView) mainView.findViewById(R.id.use_system_keyboard_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_keyboard));
mainView.findViewById(R.id.use_system_keyboard_row).setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
useOsmandKeyboard = !useOsmandKeyboard; rightHand = !rightHand;
((CompoundButton) mainView.findViewById(R.id.use_system_keyboard_switch)).setChecked(!useOsmandKeyboard); populateChangeHandRow();
if (listener != null) { if (listener != null) {
listener.onKeyboardChanged(useOsmandKeyboard); listener.onHandChanged(rightHand);
} }
} }
}); });
highlightSelectedItem(true); populateChangeHandRow();
} }
View.OnClickListener formatChangeListener = new View.OnClickListener() { ((CompoundButton) mainView.findViewById(R.id.go_to_next_field_switch)).setChecked(goToNextField);
((ImageView) mainView.findViewById(R.id.go_to_next_field_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_next_field_stroke));
mainView.findViewById(R.id.go_to_next_field_row).setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
highlightSelectedItem(false); goToNextField = !goToNextField;
switch (view.getId()) { ((CompoundButton) mainView.findViewById(R.id.go_to_next_field_switch)).setChecked(goToNextField);
case R.id.degrees_row: switchSelectedAccuracy();
coordinateFormat = PointDescription.FORMAT_DEGREES;
break;
case R.id.minutes_row:
coordinateFormat = PointDescription.FORMAT_MINUTES;
break;
case R.id.seconds_row:
coordinateFormat = PointDescription.FORMAT_SECONDS;
break;
default:
throw new IllegalArgumentException("Unsupported format");
}
highlightSelectedItem(true);
if (listener != null) { if (listener != null) {
listener.onCoordinateFormatChanged(coordinateFormat); listener.onGoToNextFieldChanged(goToNextField);
}
if (shouldClose) {
dismiss();
} }
} }
}; });
mainView.findViewById(R.id.degrees_row).setOnClickListener(formatChangeListener); switchSelectedAccuracy();
mainView.findViewById(R.id.minutes_row).setOnClickListener(formatChangeListener); populateSelectedAccuracy();
mainView.findViewById(R.id.seconds_row).setOnClickListener(formatChangeListener);
mainView.findViewById(R.id.accuracy_row).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (goToNextField) {
final ListPopupWindow listPopupWindow = new ListPopupWindow(getContext());
listPopupWindow.setAnchorView(view);
listPopupWindow.setContentWidth(AndroidUtils.dpToPx(getMyApplication(), 100));
listPopupWindow.setModal(true);
listPopupWindow.setDropDownGravity(Gravity.END | Gravity.TOP);
listPopupWindow.setAdapter(new ArrayAdapter<>(getContext(), R.layout.popup_list_text_item, new Integer[]{0, 1, 2, 3, 4, 5, 6}));
listPopupWindow.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
accuracy = i;
populateSelectedAccuracy();
if (listener != null) {
listener.onAccuracyChanged(accuracy);
}
listPopupWindow.dismiss();
}
});
listPopupWindow.show();
}
}
});
mainView.findViewById(R.id.cancel_row).setOnClickListener(new View.OnClickListener() { mainView.findViewById(R.id.cancel_row).setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
dismiss(); dismiss();
if (shouldClose && listener != null) {
listener.onCancel();
}
} }
}); });
@ -153,41 +159,39 @@ public class CoordinateInputBottomSheetDialogFragment extends MenuBottomSheetDia
} }
@Override @Override
public void onCancel(DialogInterface dialog) { public void onSaveInstanceState(Bundle outState) {
super.onCancel(dialog); outState.putBoolean(USE_OSMAND_KEYBOARD, useOsmandKeyboard);
if (shouldClose && listener != null) { outState.putBoolean(RIGHT_HAND, rightHand);
listener.onCancel(); outState.putBoolean(GO_TO_NEXT_FIELD, goToNextField);
} outState.putInt(ACCURACY, accuracy);
super.onSaveInstanceState(outState);
} }
private void highlightSelectedItem(boolean check) { private void populateChangeHandRow() {
int iconColor = check ? R.color.dashboard_blue : nightMode ? R.color.ctx_menu_info_text_dark : R.color.on_map_icon_color; ((ImageView) mainView.findViewById(R.id.hand_icon)).setImageDrawable(getContentIcon(rightHand ? R.drawable.ic_action_show_keypad_right : R.drawable.ic_action_show_keypad_left));
int textColor = ContextCompat.getColor(getContext(), check ? (nightMode ? R.color.color_dialog_buttons_dark : R.color.dashboard_blue) : nightMode ? R.color.color_white : R.color.color_black); ((TextView) mainView.findViewById(R.id.hand_text_view)).setText(getString(rightHand ? R.string.shared_string_right : R.string.shared_string_left));
switch (coordinateFormat) { ((TextView) mainView.findViewById(R.id.hand_text_view)).setTextColor(ContextCompat.getColor(getContext(), nightMode ? R.color.color_dialog_buttons_dark : R.color.map_widget_blue_pressed));
case PointDescription.FORMAT_DEGREES: }
((TextView) mainView.findViewById(R.id.degrees_text)).setTextColor(textColor);
((ImageView) mainView.findViewById(R.id.degrees_icon)).setImageDrawable((getIcon(R.drawable.ic_action_coordinates_latitude, iconColor))); private void populateSelectedAccuracy() {
((RadioButton) mainView.findViewById(R.id.degrees_radio_button)).setChecked(check); ((TextView) mainView.findViewById(R.id.selected_accuracy)).setText(String.valueOf(accuracy));
break; ((TextView) mainView.findViewById(R.id.selected_accuracy_hint)).setText("00:00." + new String(new char[accuracy]).replace("\0", "0"));
case PointDescription.FORMAT_MINUTES: }
((TextView) mainView.findViewById(R.id.minutes_text)).setTextColor(textColor);
((ImageView) mainView.findViewById(R.id.minutes_icon)).setImageDrawable((getIcon(R.drawable.ic_action_coordinates_latitude, iconColor))); private void switchSelectedAccuracy() {
((RadioButton) mainView.findViewById(R.id.minutes_radio_button)).setChecked(check); ((TextView) mainView.findViewById(R.id.selected_accuracy)).setTextColor(ContextCompat.getColor(getContext(), goToNextField ? R.color.map_widget_blue : android.R.color.darker_gray));
break; ((ImageView) mainView.findViewById(R.id.accuracy_arrow)).setImageDrawable(goToNextField ? getContentIcon(R.drawable.ic_action_arrow_drop_down) : getIcon(R.drawable.ic_action_arrow_drop_down, android.R.color.darker_gray));
case PointDescription.FORMAT_SECONDS:
((TextView) mainView.findViewById(R.id.seconds_text)).setTextColor(textColor);
((ImageView) mainView.findViewById(R.id.seconds_icon)).setImageDrawable((getIcon(R.drawable.ic_action_coordinates_latitude, iconColor)));
((RadioButton) mainView.findViewById(R.id.seconds_radio_button)).setChecked(check);
break;
}
} }
interface CoordinateInputFormatChangeListener { interface CoordinateInputFormatChangeListener {
void onCoordinateFormatChanged(int format);
void onKeyboardChanged(boolean useOsmandKeyboard); void onKeyboardChanged(boolean useOsmandKeyboard);
void onCancel(); void onHandChanged(boolean rightHand);
void onGoToNextFieldChanged(boolean goToNextField);
void onAccuracyChanged(int accuracy);
} }
} }

View file

@ -287,6 +287,19 @@ public class MapMarkersDbHelper {
} }
} }
public void addMarkers(List<MapMarker> markers) {
SQLiteConnection db = openConnection(false);
if (db != null) {
try {
for (MapMarker marker : markers) {
insertLast(db, marker, false);
}
} finally {
db.close();
}
}
}
public void addMarker(MapMarker marker) { public void addMarker(MapMarker marker) {
addMarker(marker, false); addMarker(marker, false);
} }

View file

@ -26,6 +26,7 @@ import net.osmand.plus.OsmandSettings.MapMarkersOrderByMode;
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.activities.TrackActivity; import net.osmand.plus.activities.TrackActivity;
import net.osmand.plus.mapmarkers.CoordinateInputDialogFragment.OnMapMarkersSavedListener;
import net.osmand.plus.mapmarkers.OptionsBottomSheetDialogFragment.MarkerOptionsFragmentListener; import net.osmand.plus.mapmarkers.OptionsBottomSheetDialogFragment.MarkerOptionsFragmentListener;
import net.osmand.plus.mapmarkers.OrderByBottomSheetDialogFragment.OrderByFragmentListener; import net.osmand.plus.mapmarkers.OrderByBottomSheetDialogFragment.OrderByFragmentListener;
import net.osmand.plus.mapmarkers.SaveAsTrackBottomSheetDialogFragment.MarkerSaveAsTrackFragmentListener; import net.osmand.plus.mapmarkers.SaveAsTrackBottomSheetDialogFragment.MarkerSaveAsTrackFragmentListener;
@ -110,6 +111,10 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm
if (saveAsTrackFragment != null) { if (saveAsTrackFragment != null) {
((SaveAsTrackBottomSheetDialogFragment) saveAsTrackFragment).setListener(createSaveAsTrackFragmentListener()); ((SaveAsTrackBottomSheetDialogFragment) saveAsTrackFragment).setListener(createSaveAsTrackFragmentListener());
} }
Fragment coordinateInputDialog = fragmentManager.findFragmentByTag(CoordinateInputDialogFragment.TAG);
if (coordinateInputDialog != null) {
((CoordinateInputDialogFragment) coordinateInputDialog).setListener(createOnMapMarkersSavedListener());
}
View mainView = inflater.inflate(R.layout.fragment_map_markers_dialog, container); View mainView = inflater.inflate(R.layout.fragment_map_markers_dialog, container);
@ -203,10 +208,25 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm
return mainView; return mainView;
} }
private void updateAdapters() {
activeFragment.updateAdapter();
groupsFragment.updateAdapter();
historyFragment.updateAdapter();
}
private OsmandApplication getMyApplication() { private OsmandApplication getMyApplication() {
return (OsmandApplication) getActivity().getApplication(); return (OsmandApplication) getActivity().getApplication();
} }
private OnMapMarkersSavedListener createOnMapMarkersSavedListener() {
return new OnMapMarkersSavedListener() {
@Override
public void onMapMarkersSaved() {
updateAdapters();
}
};
}
private MarkerOptionsFragmentListener createOptionsFragmentListener() { private MarkerOptionsFragmentListener createOptionsFragmentListener() {
return new MarkerOptionsFragmentListener() { return new MarkerOptionsFragmentListener() {
@ -235,7 +255,10 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm
@Override @Override
public void coordinateInputOnClick() { public void coordinateInputOnClick() {
if (mapActivity != null) { if (mapActivity != null) {
CoordinateInputDialogFragment.showInstance(mapActivity); CoordinateInputDialogFragment fragment = new CoordinateInputDialogFragment();
fragment.setRetainInstance(true);
fragment.setListener(createOnMapMarkersSavedListener());
fragment.show(mapActivity.getSupportFragmentManager(), CoordinateInputDialogFragment.TAG);
} }
} }
@ -305,9 +328,7 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm
public void onMapMarkersModeChanged(boolean showDirectionEnabled) { public void onMapMarkersModeChanged(boolean showDirectionEnabled) {
mapActivity.getMapLayers().getMapWidgetRegistry().updateMapMarkersMode(mapActivity); mapActivity.getMapLayers().getMapWidgetRegistry().updateMapMarkersMode(mapActivity);
activeFragment.setShowDirectionEnabled(showDirectionEnabled); activeFragment.setShowDirectionEnabled(showDirectionEnabled);
activeFragment.updateAdapter(); updateAdapters();
groupsFragment.updateAdapter();
historyFragment.updateAdapter();
} }
}; };
} }

View file

@ -22,7 +22,7 @@ import android.widget.LinearLayout;
import net.osmand.AndroidUtils; import net.osmand.AndroidUtils;
import net.osmand.plus.MapMarkersHelper.MapMarker; import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.OsmandTextFieldBoxes; import net.osmand.plus.widgets.OsmandTextFieldBoxes;
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.base.BottomSheetDialogFragment; import net.osmand.plus.base.BottomSheetDialogFragment;

View file

@ -17,7 +17,7 @@ import android.widget.LinearLayout;
import net.osmand.AndroidUtils; import net.osmand.AndroidUtils;
import net.osmand.IndexConstants; import net.osmand.IndexConstants;
import net.osmand.plus.OsmandTextFieldBoxes; import net.osmand.plus.widgets.OsmandTextFieldBoxes;
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.base.BottomSheetDialogFragment; import net.osmand.plus.base.BottomSheetDialogFragment;

View file

@ -0,0 +1,117 @@
package net.osmand.plus.mapmarkers.adapters;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import net.osmand.data.LatLon;
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 java.util.List;
public class CoordinateInputAdapter extends RecyclerView.Adapter<MapMarkerItemViewHolder> {
private MapActivity mapActivity;
private boolean nightTheme;
private IconsCache iconsCache;
private List<MapMarker> mapMarkers;
private LatLon location;
private Float heading;
private boolean useCenter;
private int screenOrientation;
private boolean portrait;
public CoordinateInputAdapter (MapActivity mapActivity, List<MapMarker> mapMarkers) {
this.mapActivity = mapActivity;
nightTheme = !mapActivity.getMyApplication().getSettings().isLightContent();
iconsCache = mapActivity.getMyApplication().getIconsCache();
portrait = AndroidUiHelper.isOrientationPortrait(mapActivity);
this.mapMarkers = mapMarkers;
}
public void setLocation(LatLon location) {
this.location = location;
}
public void setHeading(Float heading) {
this.heading = heading;
}
public void setUseCenter(boolean useCenter) {
this.useCenter = useCenter;
}
public void setScreenOrientation(int screenOrientation) {
this.screenOrientation = screenOrientation;
}
@Override
public MapMarkerItemViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.map_marker_item_new, parent, false);
return new MapMarkerItemViewHolder(view);
}
@Override
public void onBindViewHolder(final MapMarkerItemViewHolder holder, int position) {
final MapMarker mapMarker = getItem(position);
holder.iconDirection.setVisibility(View.VISIBLE);
holder.icon.setImageDrawable(iconsCache.getIcon(R.drawable.ic_action_flag_dark, MapMarker.getColorId(mapMarker.colorIndex)));
holder.mainLayout.setBackgroundColor(ContextCompat.getColor(mapActivity, nightTheme ? R.color.bg_color_dark : R.color.bg_color_light));
holder.title.setTextColor(ContextCompat.getColor(mapActivity, nightTheme ? R.color.color_white : R.color.color_black));
holder.divider.setBackgroundColor(ContextCompat.getColor(mapActivity, nightTheme ? R.color.actionbar_dark_color : R.color.dashboard_divider_light));
holder.optionsBtn.setBackgroundDrawable(mapActivity.getResources().getDrawable(nightTheme ? R.drawable.marker_circle_background_dark_with_inset : R.drawable.marker_circle_background_light_with_inset));
holder.optionsBtn.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_remove_dark));
holder.iconReorder.setVisibility(View.GONE);
holder.numberText.setVisibility(View.VISIBLE);
holder.numberText.setText(Integer.toString(position + 1));
holder.description.setVisibility(View.GONE);
holder.optionsBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
int position = holder.getAdapterPosition();
if (position != RecyclerView.NO_POSITION) {
MapMarker mapMarker = getItem(position);
mapMarkers.remove(mapMarker);
notifyDataSetChanged();
}
}
});
boolean singleItem = getItemCount() == 1;
boolean fistItem = position == 0;
boolean lastItem = position == getItemCount() - 1;
if (portrait) {
holder.topDivider.setVisibility(fistItem ? View.VISIBLE : View.GONE);
holder.bottomShadow.setVisibility(lastItem ? View.VISIBLE : View.GONE);
}
holder.divider.setVisibility((!singleItem && !lastItem) ? View.VISIBLE : View.GONE);
holder.title.setText(mapMarker.getName(mapActivity));
DashLocationFragment.updateLocationView(useCenter, location,
heading, holder.iconDirection, R.drawable.ic_direction_arrow,
holder.distance, new LatLon(mapMarker.getLatitude(), mapMarker.getLongitude()),
screenOrientation, mapActivity.getMyApplication(), mapActivity, true);
}
@Override
public int getItemCount() {
return mapMarkers.size();
}
public boolean isEmpty() {
return getItemCount() == 0;
}
public MapMarker getItem(int position) {
return mapMarkers.get(position);
}
}

View file

@ -14,6 +14,7 @@ public class MapMarkerItemViewHolder extends RecyclerView.ViewHolder {
final View mainLayout; final View mainLayout;
final View topDivider; final View topDivider;
final ImageView iconDirection; final ImageView iconDirection;
final TextView numberText;
final ImageView iconReorder; final ImageView iconReorder;
final ImageView icon; final ImageView icon;
final TextView title; final TextView title;
@ -35,6 +36,7 @@ public class MapMarkerItemViewHolder extends RecyclerView.ViewHolder {
mainLayout = view.findViewById(R.id.main_layout); mainLayout = view.findViewById(R.id.main_layout);
topDivider = view.findViewById(R.id.top_divider); topDivider = view.findViewById(R.id.top_divider);
iconDirection = (ImageView) view.findViewById(R.id.map_marker_direction_icon); iconDirection = (ImageView) view.findViewById(R.id.map_marker_direction_icon);
numberText = (TextView) view.findViewById(R.id.map_marker_number_text_view);
iconReorder = (ImageView) view.findViewById(R.id.map_marker_reorder_icon); iconReorder = (ImageView) view.findViewById(R.id.map_marker_reorder_icon);
icon = (ImageView) view.findViewById(R.id.map_marker_icon); icon = (ImageView) view.findViewById(R.id.map_marker_icon);
title = (TextView) view.findViewById(R.id.map_marker_title); title = (TextView) view.findViewById(R.id.map_marker_title);

View file

@ -1,21 +1,21 @@
package net.osmand.plus; package net.osmand.plus.widgets;
import android.content.Context; import android.content.Context;
import android.os.Parcel;
import android.os.Parcelable;
import android.support.annotation.Nullable;
import android.support.v4.view.ViewCompat; import android.support.v4.view.ViewCompat;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.view.View; import android.view.View;
import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodManager;
import studio.carbonylgroup.textfieldboxes.ExtendedEditText;
import studio.carbonylgroup.textfieldboxes.TextFieldBoxes; import studio.carbonylgroup.textfieldboxes.TextFieldBoxes;
public class OsmandTextFieldBoxes extends TextFieldBoxes { public class OsmandTextFieldBoxes extends TextFieldBoxes {
private boolean useOsmandKeyboard; private boolean useOsmandKeyboard;
public void setUseOsmandKeyboard(boolean useOsmandKeyboard) {
this.useOsmandKeyboard = useOsmandKeyboard;
}
public OsmandTextFieldBoxes(Context context) { public OsmandTextFieldBoxes(Context context) {
super(context); super(context);
} }
@ -28,6 +28,10 @@ public class OsmandTextFieldBoxes extends TextFieldBoxes {
super(context, attrs, defStyleAttr); super(context, attrs, defStyleAttr);
} }
public void setUseOsmandKeyboard(boolean useOsmandKeyboard) {
this.useOsmandKeyboard = useOsmandKeyboard;
}
@Override @Override
protected void onFinishInflate() { protected void onFinishInflate() {
super.onFinishInflate(); super.onFinishInflate();
@ -35,18 +39,12 @@ 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);
}
} }
}); });
this.iconImageButton.setOnClickListener(new OnClickListener() { this.iconImageButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) { public void onClick(View v) {
select(); select();
} }
@ -63,6 +61,7 @@ public class OsmandTextFieldBoxes extends TextFieldBoxes {
if (!useOsmandKeyboard) { if (!useOsmandKeyboard) {
OsmandTextFieldBoxes.this.inputMethodManager.showSoftInput(OsmandTextFieldBoxes.this.editText, InputMethodManager.SHOW_IMPLICIT); OsmandTextFieldBoxes.this.inputMethodManager.showSoftInput(OsmandTextFieldBoxes.this.editText, InputMethodManager.SHOW_IMPLICIT);
} }
performClick();
} }
@Override @Override
@ -71,7 +70,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);
@ -85,4 +84,8 @@ public class OsmandTextFieldBoxes extends TextFieldBoxes {
this.activated = false; this.activated = false;
} }
public ExtendedEditText getEditText() {
return editText;
}
} }