Add CorrdinateInputFormats
This commit is contained in:
parent
9cc0c2a844
commit
06f3ae09c6
2 changed files with 108 additions and 0 deletions
|
@ -9,6 +9,11 @@
|
|||
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
|
||||
-->
|
||||
<string name="dd_mm_ss_format">DD°MM′SS″</string>
|
||||
<string name="dd_dddddd_format">DD.DDDDDD°</string>
|
||||
<string name="dd_ddddd_format">DD.DDDDD°</string>
|
||||
<string name="dd_mm_mmmm_format">DD°MM.MMMM′</string>
|
||||
<string name="dd_mm_mmm_format">DD°MM.MMM′</string>
|
||||
<string name="east_abbreviation">E</string>
|
||||
<string name="west_abbreviation">W</string>
|
||||
<string name="south_abbreviation">S</string>
|
||||
|
|
|
@ -0,0 +1,103 @@
|
|||
package net.osmand.plus.mapmarkers;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.annotation.IntDef;
|
||||
|
||||
import net.osmand.plus.R;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
public class CoordinateInputFormats {
|
||||
|
||||
public static final int DD_MM_MMM = 0;
|
||||
public static final int DD_MM_MMMM = 1;
|
||||
public static final int DD_DDDDD = 2;
|
||||
public static final int DD_DDDDDD = 3;
|
||||
public static final int DD_MM_SS = 4;
|
||||
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
@IntDef({DD_MM_MMM, DD_MM_MMMM, DD_DDDDD, DD_DDDDDD, DD_MM_SS})
|
||||
@interface CoordinateInputFormatDef {
|
||||
}
|
||||
|
||||
public static String formatToHumanString(Context ctx, @CoordinateInputFormatDef int format) {
|
||||
switch (format) {
|
||||
case DD_MM_MMM:
|
||||
return ctx.getString(R.string.dd_mm_mmm_format);
|
||||
case DD_MM_MMMM:
|
||||
return ctx.getString(R.string.dd_mm_mmmm_format);
|
||||
case DD_DDDDD:
|
||||
return ctx.getString(R.string.dd_ddddd_format);
|
||||
case DD_DDDDDD:
|
||||
return ctx.getString(R.string.dd_dddddd_format);
|
||||
case DD_MM_SS:
|
||||
return ctx.getString(R.string.dd_mm_ss_format);
|
||||
default:
|
||||
return "Unknown format";
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean containsThirdPart(@CoordinateInputFormatDef int format) {
|
||||
return format == DD_MM_MMM || format == DD_MM_MMMM || format == DD_MM_SS;
|
||||
}
|
||||
|
||||
public static int getSecondPartSymbolsCount(@CoordinateInputFormatDef int format) {
|
||||
switch (format) {
|
||||
case DD_MM_MMM:
|
||||
case DD_MM_MMMM:
|
||||
case DD_MM_SS:
|
||||
return 2;
|
||||
case DD_DDDDD:
|
||||
return 5;
|
||||
case DD_DDDDDD:
|
||||
return 6;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static int getThirdPartSymbolsCount(@CoordinateInputFormatDef int format) {
|
||||
switch (format) {
|
||||
case DD_MM_MMM:
|
||||
return 3;
|
||||
case DD_MM_MMMM:
|
||||
return 4;
|
||||
case DD_MM_SS:
|
||||
return 2;
|
||||
case DD_DDDDD:
|
||||
case DD_DDDDDD:
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static String getFirstSeparator(@CoordinateInputFormatDef int format) {
|
||||
switch (format) {
|
||||
case DD_MM_MMM:
|
||||
case DD_MM_MMMM:
|
||||
case DD_MM_SS:
|
||||
return "°";
|
||||
case DD_DDDDD:
|
||||
case DD_DDDDDD:
|
||||
return ".";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public static String getSecondSeparator(@CoordinateInputFormatDef int format) {
|
||||
switch (format) {
|
||||
case DD_MM_MMM:
|
||||
case DD_MM_MMMM:
|
||||
return ".";
|
||||
case DD_DDDDD:
|
||||
case DD_DDDDDD:
|
||||
return "°";
|
||||
case DD_MM_SS:
|
||||
return "′";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue