forked from upstream-mirrors/OpenTracks
Made generic activity type selectable.
Decreased icon size.
This commit is contained in:
@@ -45,6 +45,7 @@ public class TrackIconUtils {
|
|||||||
private static final String RUN = "RUN";
|
private static final String RUN = "RUN";
|
||||||
private static final String SKI = "SKI";
|
private static final String SKI = "SKI";
|
||||||
private static final String SNOW_BOARDING = "SNOW_BOARDING";
|
private static final String SNOW_BOARDING = "SNOW_BOARDING";
|
||||||
|
private static final String UNKNOWN = "UNKNOWN";
|
||||||
private static final String WALK = "WALK";
|
private static final String WALK = "WALK";
|
||||||
|
|
||||||
private static final int[] AIRPLANE_LIST = new int[]{R.string.activity_type_airplane, R.string.activity_type_commercial_airplane, R.string.activity_type_rc_airplane};
|
private static final int[] AIRPLANE_LIST = new int[]{R.string.activity_type_airplane, R.string.activity_type_commercial_airplane, R.string.activity_type_rc_airplane};
|
||||||
@@ -59,6 +60,7 @@ public class TrackIconUtils {
|
|||||||
private static final LinkedHashMap<String, Pair<Integer, Integer>> MAP = new LinkedHashMap<>();
|
private static final LinkedHashMap<String, Pair<Integer, Integer>> MAP = new LinkedHashMap<>();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
//Reflects order in ChooseActivityTypeDialogFragment
|
||||||
MAP.put(RUN, new Pair<>(R.string.activity_type_running, R.drawable.ic_activity_run_24dp));
|
MAP.put(RUN, new Pair<>(R.string.activity_type_running, R.drawable.ic_activity_run_24dp));
|
||||||
MAP.put(WALK, new Pair<>(R.string.activity_type_walking, R.drawable.ic_activity_walk_24dp));
|
MAP.put(WALK, new Pair<>(R.string.activity_type_walking, R.drawable.ic_activity_walk_24dp));
|
||||||
MAP.put(BIKE, new Pair<>(R.string.activity_type_biking, R.drawable.ic_activity_bike_24dp));
|
MAP.put(BIKE, new Pair<>(R.string.activity_type_biking, R.drawable.ic_activity_bike_24dp));
|
||||||
@@ -92,10 +94,10 @@ public class TrackIconUtils {
|
|||||||
*/
|
*/
|
||||||
public static int getIconActivityType(String iconValue) {
|
public static int getIconActivityType(String iconValue) {
|
||||||
if (iconValue == null || iconValue.equals("")) {
|
if (iconValue == null || iconValue.equals("")) {
|
||||||
return R.string.activity_type_walking;
|
return R.string.activity_type_unknown;
|
||||||
}
|
}
|
||||||
Pair<Integer, Integer> pair = MAP.get(iconValue);
|
Pair<Integer, Integer> pair = MAP.get(iconValue);
|
||||||
return pair == null ? R.string.activity_type_walking : pair.first;
|
return pair == null ? R.string.activity_type_unknown : pair.first;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -113,7 +115,7 @@ public class TrackIconUtils {
|
|||||||
*/
|
*/
|
||||||
public static String getIconValue(Context context, String activityType) {
|
public static String getIconValue(Context context, String activityType) {
|
||||||
if (activityType == null || activityType.equals("")) {
|
if (activityType == null || activityType.equals("")) {
|
||||||
return "";
|
return UNKNOWN;
|
||||||
}
|
}
|
||||||
if (inList(context, activityType, AIRPLANE_LIST)) {
|
if (inList(context, activityType, AIRPLANE_LIST)) {
|
||||||
return AIRPLANE;
|
return AIRPLANE;
|
||||||
@@ -139,7 +141,7 @@ public class TrackIconUtils {
|
|||||||
if (inList(context, activityType, WALK_LIST)) {
|
if (inList(context, activityType, WALK_LIST)) {
|
||||||
return WALK;
|
return WALK;
|
||||||
}
|
}
|
||||||
return "";
|
return UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setIconSpinner(Spinner spinner, String iconValue) {
|
public static void setIconSpinner(Spinner spinner, String iconValue) {
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ limitations under the License.
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:columnWidth="64dp"
|
android:columnWidth="56dp"
|
||||||
android:numColumns="4"
|
android:numColumns="4"
|
||||||
android:paddingStart="12dp"
|
android:paddingStart="12dp"
|
||||||
android:paddingTop="12dp"
|
android:paddingTop="12dp"
|
||||||
|
|||||||
Reference in New Issue
Block a user