forked from upstream-mirrors/OpenTracks
Merge heads
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 3.6 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 3.2 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 4.0 KiB |
@@ -18,7 +18,6 @@ limitations under the License.
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:numColumns="4"
|
android:numColumns="4"
|
||||||
android:paddingBottom="20dp"
|
android:padding="4dp"
|
||||||
android:paddingTop="20dp"
|
android:stretchMode="spacingWidth"
|
||||||
android:stretchMode="columnWidth"
|
android:verticalSpacing="4dp" />
|
||||||
android:verticalSpacing="20dp" />
|
|
||||||
|
|||||||
@@ -41,20 +41,20 @@ limitations under the License.
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:orientation="horizontal" >
|
android:orientation="horizontal" >
|
||||||
<AutoCompleteTextView
|
<AutoCompleteTextView
|
||||||
|
android:gravity="bottom"
|
||||||
android:hint="@string/track_edit_activity_type_hint"
|
android:hint="@string/track_edit_activity_type_hint"
|
||||||
android:id="@+id/track_edit_activity_type"
|
android:id="@+id/track_edit_activity_type"
|
||||||
android:imeOptions="actionNext"
|
android:imeOptions="actionNext"
|
||||||
android:layout_gravity="bottom"
|
android:layout_gravity="bottom"
|
||||||
|
android:layout_height="fill_parent"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
style="@style/EditCategory" />
|
style="@style/EditCategory" />
|
||||||
<ImageButton
|
<Spinner
|
||||||
android:contentDescription="@string/activity_type_walking"
|
|
||||||
android:id="@+id/track_edit_activity_type_icon"
|
android:id="@+id/track_edit_activity_type_icon"
|
||||||
android:layout_gravity="bottom"
|
android:layout_gravity="bottom"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content" />
|
||||||
android:src="@drawable/track_walk" />
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
<TextView
|
<TextView
|
||||||
android:text="@string/generic_description"
|
android:text="@string/generic_description"
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2008 Google Inc.
|
* Copyright 2008 Google Inc.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||||
* use this file except in compliance with the License. You may obtain a copy of
|
* use this file except in compliance with the License. You may obtain a copy of
|
||||||
* the License at
|
* the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
@@ -20,24 +20,31 @@ import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
|
|||||||
import com.google.android.apps.mytracks.content.Track;
|
import com.google.android.apps.mytracks.content.Track;
|
||||||
import com.google.android.apps.mytracks.fragments.ChooseActivityTypeDialogFragment;
|
import com.google.android.apps.mytracks.fragments.ChooseActivityTypeDialogFragment;
|
||||||
import com.google.android.apps.mytracks.fragments.ChooseActivityTypeDialogFragment.ChooseActivityTypeCaller;
|
import com.google.android.apps.mytracks.fragments.ChooseActivityTypeDialogFragment.ChooseActivityTypeCaller;
|
||||||
|
import com.google.android.apps.mytracks.util.ApiAdapterFactory;
|
||||||
import com.google.android.apps.mytracks.util.TrackIconUtils;
|
import com.google.android.apps.mytracks.util.TrackIconUtils;
|
||||||
import com.google.android.apps.mytracks.util.TrackNameUtils;
|
import com.google.android.apps.mytracks.util.TrackNameUtils;
|
||||||
import com.google.android.maps.mytracks.R;
|
import com.google.android.maps.mytracks.R;
|
||||||
|
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.BitmapFactory;
|
||||||
|
import android.graphics.BitmapFactory.Options;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.view.KeyEvent;
|
||||||
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.AutoCompleteTextView;
|
import android.widget.AutoCompleteTextView;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.ImageButton;
|
import android.widget.ImageView;
|
||||||
|
import android.widget.Spinner;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An activity that let's the user see and edit the user editable track meta
|
* An activity that let's the user see and edit the user editable track meta
|
||||||
* data such as track name, activity type, and track description.
|
* data such as track name, activity type, and track description.
|
||||||
*
|
*
|
||||||
* @author Leif Hendrik Wilden
|
* @author Leif Hendrik Wilden
|
||||||
*/
|
*/
|
||||||
public class TrackEditActivity extends AbstractMyTracksActivity
|
public class TrackEditActivity extends AbstractMyTracksActivity
|
||||||
@@ -56,7 +63,7 @@ public class TrackEditActivity extends AbstractMyTracksActivity
|
|||||||
|
|
||||||
private EditText name;
|
private EditText name;
|
||||||
private AutoCompleteTextView activityType;
|
private AutoCompleteTextView activityType;
|
||||||
private ImageButton activityTypeIcon;
|
private Spinner activityTypeIcon;
|
||||||
private EditText description;
|
private EditText description;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -88,14 +95,14 @@ public class TrackEditActivity extends AbstractMyTracksActivity
|
|||||||
this, R.array.activity_types, android.R.layout.simple_dropdown_item_1line);
|
this, R.array.activity_types, android.R.layout.simple_dropdown_item_1line);
|
||||||
activityType.setAdapter(adapter);
|
activityType.setAdapter(adapter);
|
||||||
activityType.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
activityType.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||||
setActivityTypeIcon(TrackIconUtils.getIconValue(
|
setActivityTypeIcon(TrackIconUtils.getIconValue(
|
||||||
TrackEditActivity.this, (String) activityType.getAdapter().getItem(position)));
|
TrackEditActivity.this, (String) activityType.getAdapter().getItem(position)));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
activityType.setOnFocusChangeListener(new View.OnFocusChangeListener() {
|
activityType.setOnFocusChangeListener(new View.OnFocusChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onFocusChange(View v, boolean hasFocus) {
|
public void onFocusChange(View v, boolean hasFocus) {
|
||||||
if (!hasFocus) {
|
if (!hasFocus) {
|
||||||
setActivityTypeIcon(TrackIconUtils.getIconValue(
|
setActivityTypeIcon(TrackIconUtils.getIconValue(
|
||||||
@@ -104,15 +111,6 @@ public class TrackEditActivity extends AbstractMyTracksActivity
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
activityTypeIcon = (ImageButton) findViewById(R.id.track_edit_activity_type_icon);
|
|
||||||
activityTypeIcon.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
new ChooseActivityTypeDialogFragment().show(getSupportFragmentManager(),
|
|
||||||
ChooseActivityTypeDialogFragment.CHOOSE_ACTIVITY_TYPE_DIALOG_TAG);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
iconValue = null;
|
iconValue = null;
|
||||||
if (bundle != null) {
|
if (bundle != null) {
|
||||||
iconValue = bundle.getString(ICON_VALUE_KEY);
|
iconValue = bundle.getString(ICON_VALUE_KEY);
|
||||||
@@ -120,14 +118,65 @@ public class TrackEditActivity extends AbstractMyTracksActivity
|
|||||||
if (iconValue == null) {
|
if (iconValue == null) {
|
||||||
iconValue = track.getIcon();
|
iconValue = track.getIcon();
|
||||||
}
|
}
|
||||||
setActivityTypeIcon(iconValue);
|
|
||||||
|
// Add a border around the icon
|
||||||
|
Options options = new BitmapFactory.Options();
|
||||||
|
options.inJustDecodeBounds = true;
|
||||||
|
BitmapFactory.decodeResource(getResources(), R.drawable.track_airplane, options);
|
||||||
|
final int padding = 4;
|
||||||
|
final int width = options.outWidth + 2 * padding;
|
||||||
|
final int height = options.outHeight + 2 * padding;
|
||||||
|
|
||||||
|
activityTypeIcon = (Spinner) findViewById(R.id.track_edit_activity_type_icon);
|
||||||
|
ArrayAdapter<StringBuilder> activityTypeIconAdapter = new ArrayAdapter<StringBuilder>(
|
||||||
|
this, android.R.layout.simple_spinner_item,
|
||||||
|
new StringBuilder[] {new StringBuilder(iconValue)}) {
|
||||||
|
@Override
|
||||||
|
public View getView(int position, View convertView, android.view.ViewGroup parent) {
|
||||||
|
ImageView imageView =
|
||||||
|
convertView != null ? (ImageView) convertView : new ImageView(getContext());
|
||||||
|
Bitmap source = BitmapFactory.decodeResource(
|
||||||
|
getResources(), TrackIconUtils.getIconDrawable(getItem(position).toString()));
|
||||||
|
if (ApiAdapterFactory.getApiAdapter().isSpinnerBackgroundLight()) {
|
||||||
|
source = TrackIconUtils.invertBitmap(source);
|
||||||
|
}
|
||||||
|
imageView.setImageBitmap(source);
|
||||||
|
imageView.setMinimumHeight(height);
|
||||||
|
imageView.setMinimumWidth(width);
|
||||||
|
imageView.setPadding(padding, padding, padding, padding);
|
||||||
|
return imageView;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
activityTypeIcon.setAdapter(activityTypeIconAdapter);
|
||||||
|
activityTypeIcon.setOnTouchListener(new View.OnTouchListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onTouch(View v, MotionEvent event) {
|
||||||
|
if (event.getAction() == MotionEvent.ACTION_UP) {
|
||||||
|
new ChooseActivityTypeDialogFragment().show(getSupportFragmentManager(),
|
||||||
|
ChooseActivityTypeDialogFragment.CHOOSE_ACTIVITY_TYPE_DIALOG_TAG);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
activityTypeIcon.setOnKeyListener(new View.OnKeyListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onKey(View v, int keyCode, KeyEvent event) {
|
||||||
|
if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER) {
|
||||||
|
new ChooseActivityTypeDialogFragment().show(getSupportFragmentManager(),
|
||||||
|
ChooseActivityTypeDialogFragment.CHOOSE_ACTIVITY_TYPE_DIALOG_TAG);
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
description = (EditText) findViewById(R.id.track_edit_description);
|
description = (EditText) findViewById(R.id.track_edit_description);
|
||||||
description.setText(track.getDescription());
|
description.setText(track.getDescription());
|
||||||
|
|
||||||
Button save = (Button) findViewById(R.id.track_edit_save);
|
Button save = (Button) findViewById(R.id.track_edit_save);
|
||||||
save.setOnClickListener(new View.OnClickListener() {
|
save.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
track.setName(name.getText().toString());
|
track.setName(name.getText().toString());
|
||||||
String category = activityType.getText().toString();
|
String category = activityType.getText().toString();
|
||||||
@@ -152,7 +201,7 @@ public class TrackEditActivity extends AbstractMyTracksActivity
|
|||||||
} else {
|
} else {
|
||||||
setTitle(R.string.menu_edit);
|
setTitle(R.string.menu_edit);
|
||||||
cancel.setOnClickListener(new View.OnClickListener() {
|
cancel.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
@@ -174,12 +223,17 @@ public class TrackEditActivity extends AbstractMyTracksActivity
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the activity type icon.
|
* Sets the activity type icon.
|
||||||
*
|
*
|
||||||
* @param value the icon value
|
* @param value the icon value
|
||||||
*/
|
*/
|
||||||
private void setActivityTypeIcon(String value) {
|
private void setActivityTypeIcon(String value) {
|
||||||
iconValue = value;
|
iconValue = value;
|
||||||
activityTypeIcon.setImageResource(TrackIconUtils.getIconDrawable(value));
|
ArrayAdapter<StringBuilder> adapter =
|
||||||
|
(ArrayAdapter<StringBuilder>) activityTypeIcon.getAdapter();
|
||||||
|
StringBuilder stringBuilder = adapter.getItem(0);
|
||||||
|
stringBuilder.delete(0, stringBuilder.length());
|
||||||
|
stringBuilder.append(value);
|
||||||
|
adapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -743,6 +743,7 @@ public class TrackListActivity extends AbstractSendToGoogleActivity
|
|||||||
private void updateMenuItems(boolean isRecording) {
|
private void updateMenuItems(boolean isRecording) {
|
||||||
if (startGpsMenuItem != null) {
|
if (startGpsMenuItem != null) {
|
||||||
startGpsMenuItem.setTitle(startGps ? R.string.menu_stop_gps : R.string.menu_start_gps);
|
startGpsMenuItem.setTitle(startGps ? R.string.menu_stop_gps : R.string.menu_start_gps);
|
||||||
|
startGpsMenuItem.setIcon(startGps ? R.drawable.menu_stop_gps : R.drawable.menu_start_gps);
|
||||||
startGpsMenuItem.setVisible(!isRecording);
|
startGpsMenuItem.setVisible(!isRecording);
|
||||||
}
|
}
|
||||||
if (importAllMenuItem != null) {
|
if (importAllMenuItem != null) {
|
||||||
|
|||||||
+18
-8
@@ -22,6 +22,8 @@ import com.google.android.maps.mytracks.R;
|
|||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
|
import android.graphics.BitmapFactory;
|
||||||
|
import android.graphics.BitmapFactory.Options;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.DialogFragment;
|
import android.support.v4.app.DialogFragment;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@@ -34,14 +36,14 @@ import java.util.List;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A DialogFragment to choose an activity type.
|
* A DialogFragment to choose an activity type.
|
||||||
*
|
*
|
||||||
* @author apoorvn
|
* @author apoorvn
|
||||||
*/
|
*/
|
||||||
public class ChooseActivityTypeDialogFragment extends DialogFragment {
|
public class ChooseActivityTypeDialogFragment extends DialogFragment {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface for caller of this dialog fragment.
|
* Interface for caller of this dialog fragment.
|
||||||
*
|
*
|
||||||
* @author apoorvn
|
* @author apoorvn
|
||||||
*/
|
*/
|
||||||
public interface ChooseActivityTypeCaller {
|
public interface ChooseActivityTypeCaller {
|
||||||
@@ -69,8 +71,8 @@ public class ChooseActivityTypeDialogFragment extends DialogFragment {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||||
GridView gridView = (GridView) getActivity()
|
GridView gridView =
|
||||||
.getLayoutInflater().inflate(R.layout.choose_activity_type, null);
|
(GridView) getActivity().getLayoutInflater().inflate(R.layout.choose_activity_type, null);
|
||||||
|
|
||||||
final List<String> iconValues = TrackIconUtils.getAllIconValues();
|
final List<String> iconValues = TrackIconUtils.getAllIconValues();
|
||||||
List<Integer> imageIds = new ArrayList<Integer>();
|
List<Integer> imageIds = new ArrayList<Integer>();
|
||||||
@@ -78,11 +80,19 @@ public class ChooseActivityTypeDialogFragment extends DialogFragment {
|
|||||||
imageIds.add(TrackIconUtils.getIconDrawable(iconValue));
|
imageIds.add(TrackIconUtils.getIconDrawable(iconValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
ChooseActivityTypeImageAdapter imageAdapter = new ChooseActivityTypeImageAdapter(
|
Options options = new BitmapFactory.Options();
|
||||||
getActivity(), imageIds);
|
options.inJustDecodeBounds = true;
|
||||||
|
BitmapFactory.decodeResource(getResources(), R.drawable.track_airplane, options);
|
||||||
|
int padding = 32;
|
||||||
|
int width = options.outWidth + 2 * padding;
|
||||||
|
int height = options.outHeight + 2 * padding;
|
||||||
|
gridView.setColumnWidth(width);
|
||||||
|
|
||||||
|
ChooseActivityTypeImageAdapter imageAdapter =
|
||||||
|
new ChooseActivityTypeImageAdapter(getActivity(), imageIds, width, height, padding);
|
||||||
gridView.setAdapter(imageAdapter);
|
gridView.setAdapter(imageAdapter);
|
||||||
gridView.setOnItemClickListener(new OnItemClickListener() {
|
gridView.setOnItemClickListener(new OnItemClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
|
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
|
||||||
dismiss();
|
dismiss();
|
||||||
caller.onChooseActivityTypeDone(iconValues.get(position));
|
caller.onChooseActivityTypeDone(iconValues.get(position));
|
||||||
@@ -92,4 +102,4 @@ public class ChooseActivityTypeDialogFragment extends DialogFragment {
|
|||||||
return new AlertDialog.Builder(getActivity()).setNegativeButton(R.string.generic_cancel, null)
|
return new AlertDialog.Builder(getActivity()).setNegativeButton(R.string.generic_cancel, null)
|
||||||
.setTitle(R.string.track_edit_activity_type_hint).setView(gridView).create();
|
.setTitle(R.string.track_edit_activity_type_hint).setView(gridView).create();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-2
@@ -26,17 +26,24 @@ import java.util.List;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Image adapter for choosing an activity type.
|
* Image adapter for choosing an activity type.
|
||||||
*
|
*
|
||||||
* @author apoorvn
|
* @author apoorvn
|
||||||
*/
|
*/
|
||||||
public class ChooseActivityTypeImageAdapter extends BaseAdapter {
|
public class ChooseActivityTypeImageAdapter extends BaseAdapter {
|
||||||
|
|
||||||
private final Context context;
|
private final Context context;
|
||||||
private final List<Integer> imageIds;
|
private final List<Integer> imageIds;
|
||||||
|
private final int width;
|
||||||
|
private final int height;
|
||||||
|
private final int padding;
|
||||||
|
|
||||||
public ChooseActivityTypeImageAdapter(Context context, List<Integer> imageIds) {
|
public ChooseActivityTypeImageAdapter(
|
||||||
|
Context context, List<Integer> imageIds, int width, int height, int padding) {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.imageIds = imageIds;
|
this.imageIds = imageIds;
|
||||||
|
this.width = width;
|
||||||
|
this.height = height;
|
||||||
|
this.padding = padding;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -63,6 +70,9 @@ public class ChooseActivityTypeImageAdapter extends BaseAdapter {
|
|||||||
imageView = (ImageView) convertView;
|
imageView = (ImageView) convertView;
|
||||||
}
|
}
|
||||||
imageView.setImageResource(imageIds.get(position));
|
imageView.setImageResource(imageIds.get(position));
|
||||||
|
imageView.setMinimumHeight(height);
|
||||||
|
imageView.setMinimumWidth(width);
|
||||||
|
imageView.setPadding(padding, padding, padding, padding);
|
||||||
return imageView;
|
return imageView;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -124,4 +124,9 @@ public class Api11Adapter extends Api10Adapter {
|
|||||||
public void invalidMenu(Activity activity) {
|
public void invalidMenu(Activity activity) {
|
||||||
activity.invalidateOptionsMenu();
|
activity.invalidateOptionsMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isSpinnerBackgroundLight() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -133,6 +133,11 @@ public class Api8Adapter implements ApiAdapter {
|
|||||||
// Do nothing
|
// Do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isSpinnerBackgroundLight() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handleSearchKey(MenuItem menuItem) {
|
public boolean handleSearchKey(MenuItem menuItem) {
|
||||||
// Return false and allow the framework to handle the search key.
|
// Return false and allow the framework to handle the search key.
|
||||||
|
|||||||
@@ -163,6 +163,13 @@ public interface ApiAdapter {
|
|||||||
*/
|
*/
|
||||||
public void invalidMenu(Activity activity);
|
public void invalidMenu(Activity activity);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* True if the spinner background is light color.
|
||||||
|
* <p>
|
||||||
|
* Due to changes in API level 11.
|
||||||
|
*/
|
||||||
|
public boolean isSpinnerBackgroundLight();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles the search key press. Returns true if handled.
|
* Handles the search key press. Returns true if handled.
|
||||||
* <p>
|
* <p>
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ package com.google.android.apps.mytracks.util;
|
|||||||
import com.google.android.maps.mytracks.R;
|
import com.google.android.maps.mytracks.R;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.Color;
|
||||||
import android.util.Pair;
|
import android.util.Pair;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -27,7 +29,7 @@ import java.util.List;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Utilities for track icon.
|
* Utilities for track icon.
|
||||||
*
|
*
|
||||||
* @author Jimmy Shih
|
* @author Jimmy Shih
|
||||||
*/
|
*/
|
||||||
public class TrackIconUtils {
|
public class TrackIconUtils {
|
||||||
@@ -43,48 +45,52 @@ public class TrackIconUtils {
|
|||||||
|
|
||||||
private TrackIconUtils() {}
|
private TrackIconUtils() {}
|
||||||
|
|
||||||
private static LinkedHashMap<String, Pair<Integer, Integer>>
|
private static LinkedHashMap<String, Pair<Integer, Integer>> map =
|
||||||
map = new LinkedHashMap<String, Pair<Integer, Integer>>();
|
new LinkedHashMap<String, Pair<Integer, Integer>>();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
map.put(AIRPLANE,
|
map.put(RUN, new Pair<Integer, Integer>(R.string.activity_type_running, R.drawable.track_run));
|
||||||
new Pair<Integer, Integer>(R.string.activity_type_airplane, R.drawable.track_airplane));
|
map.put(
|
||||||
|
WALK, new Pair<Integer, Integer>(R.string.activity_type_walking, R.drawable.track_walk));
|
||||||
map.put(BIKE, new Pair<Integer, Integer>(R.string.activity_type_biking, R.drawable.track_bike));
|
map.put(BIKE, new Pair<Integer, Integer>(R.string.activity_type_biking, R.drawable.track_bike));
|
||||||
map.put(BOAT, new Pair<Integer, Integer>(R.string.activity_type_boat, R.drawable.track_boat));
|
|
||||||
map.put(
|
map.put(
|
||||||
DRIVE, new Pair<Integer, Integer>(R.string.activity_type_driving, R.drawable.track_drive));
|
DRIVE, new Pair<Integer, Integer>(R.string.activity_type_driving, R.drawable.track_drive));
|
||||||
map.put(RUN, new Pair<Integer, Integer>(R.string.activity_type_running, R.drawable.track_run));
|
|
||||||
map.put(SKI, new Pair<Integer, Integer>(R.string.activity_type_skiing, R.drawable.track_ski));
|
map.put(SKI, new Pair<Integer, Integer>(R.string.activity_type_skiing, R.drawable.track_ski));
|
||||||
map.put(SNOW_BOARDING, new Pair<Integer, Integer>(
|
map.put(SNOW_BOARDING, new Pair<Integer, Integer>(
|
||||||
R.string.activity_type_snow_boarding, R.drawable.track_snow_boarding));
|
R.string.activity_type_snow_boarding, R.drawable.track_snow_boarding));
|
||||||
map.put(
|
map.put(AIRPLANE,
|
||||||
WALK, new Pair<Integer, Integer>(R.string.activity_type_walking, R.drawable.track_walk));
|
new Pair<Integer, Integer>(R.string.activity_type_airplane, R.drawable.track_airplane));
|
||||||
|
map.put(BOAT, new Pair<Integer, Integer>(R.string.activity_type_boat, R.drawable.track_boat));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int[] airplane = new int[] { R.string.activity_type_airplane,
|
private static int[] airplane = new int[] {
|
||||||
R.string.activity_type_commercial_airplane, R.string.activity_type_rc_airplane };
|
R.string.activity_type_airplane, R.string.activity_type_commercial_airplane,
|
||||||
private static int[] bike = new int[] { R.string.activity_type_biking,
|
R.string.activity_type_rc_airplane};
|
||||||
R.string.activity_type_cycling, R.string.activity_type_dirt_bike,
|
private static int[] bike = new int[] {R.string.activity_type_biking,
|
||||||
R.string.activity_type_motor_bike, R.string.activity_type_mountain_biking,
|
R.string.activity_type_cycling,
|
||||||
R.string.activity_type_road_biking, R.string.activity_type_track_cycling };
|
R.string.activity_type_dirt_bike,
|
||||||
private static int[] boat = new int[] { R.string.activity_type_boat, R.string.activity_type_ferry,
|
R.string.activity_type_motor_bike,
|
||||||
R.string.activity_type_motor_boating, R.string.activity_type_rc_boat };
|
R.string.activity_type_mountain_biking,
|
||||||
private static int[] drive = new int[] { R.string.activity_type_atv,
|
R.string.activity_type_road_biking,
|
||||||
R.string.activity_type_driving, R.string.activity_type_driving_bus,
|
R.string.activity_type_track_cycling};
|
||||||
R.string.activity_type_driving_car };
|
private static int[] boat = new int[] {R.string.activity_type_boat, R.string.activity_type_ferry,
|
||||||
private static int[] run = new int[] { R.string.activity_type_running,
|
R.string.activity_type_motor_boating, R.string.activity_type_rc_boat};
|
||||||
R.string.activity_type_street_running, R.string.activity_type_track_running,
|
private static int[] drive = new int[] {
|
||||||
R.string.activity_type_trail_running };
|
R.string.activity_type_atv, R.string.activity_type_driving,
|
||||||
private static int[] ski = new int[] {
|
R.string.activity_type_driving_bus, R.string.activity_type_driving_car};
|
||||||
R.string.activity_type_cross_country_skiing, R.string.activity_type_skiing };
|
private static int[] run = new int[] {
|
||||||
private static int[] snowBoarding = new int[] { R.string.activity_type_snow_boarding };
|
R.string.activity_type_running, R.string.activity_type_street_running,
|
||||||
private static int[] walk = new int[] { R.string.activity_type_hiking,
|
R.string.activity_type_track_running, R.string.activity_type_trail_running};
|
||||||
|
private static int[] ski =
|
||||||
|
new int[] {R.string.activity_type_cross_country_skiing, R.string.activity_type_skiing};
|
||||||
|
private static int[] snowBoarding = new int[] {R.string.activity_type_snow_boarding};
|
||||||
|
private static int[] walk = new int[] {R.string.activity_type_hiking,
|
||||||
R.string.activity_type_off_trail_hiking, R.string.activity_type_speed_walking,
|
R.string.activity_type_off_trail_hiking, R.string.activity_type_speed_walking,
|
||||||
R.string.activity_type_trail_hiking, R.string.activity_type_walking };
|
R.string.activity_type_trail_hiking, R.string.activity_type_walking};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the icon drawable.
|
* Gets the icon drawable.
|
||||||
*
|
*
|
||||||
* @param iconValue the icon value
|
* @param iconValue the icon value
|
||||||
*/
|
*/
|
||||||
public static int getIconDrawable(String iconValue) {
|
public static int getIconDrawable(String iconValue) {
|
||||||
@@ -97,7 +103,7 @@ public class TrackIconUtils {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the icon activity type.
|
* Gets the icon activity type.
|
||||||
*
|
*
|
||||||
* @param iconValue the icon value
|
* @param iconValue the icon value
|
||||||
*/
|
*/
|
||||||
public static int getIconActivityType(String iconValue) {
|
public static int getIconActivityType(String iconValue) {
|
||||||
@@ -121,7 +127,7 @@ public class TrackIconUtils {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the icon value.
|
* Gets the icon value.
|
||||||
*
|
*
|
||||||
* @param context the context
|
* @param context the context
|
||||||
* @param activityType the activity type
|
* @param activityType the activity type
|
||||||
*/
|
*/
|
||||||
@@ -153,9 +159,37 @@ public class TrackIconUtils {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Inverts the colors in a bitmap.
|
||||||
|
*
|
||||||
|
* @param source the source
|
||||||
|
*/
|
||||||
|
public static Bitmap invertBitmap(Bitmap source) {
|
||||||
|
Bitmap output = Bitmap.createBitmap(source.getWidth(), source.getHeight(), source.getConfig());
|
||||||
|
int height = source.getHeight();
|
||||||
|
int width = source.getWidth();
|
||||||
|
int pixelColor;
|
||||||
|
int alpha;
|
||||||
|
int red;
|
||||||
|
int green;
|
||||||
|
int blue;
|
||||||
|
|
||||||
|
for (int y = 0; y < height; y++) {
|
||||||
|
for (int x = 0; x < width; x++) {
|
||||||
|
pixelColor = source.getPixel(x, y);
|
||||||
|
alpha = Color.alpha(pixelColor);
|
||||||
|
red = 255 - Color.red(pixelColor);
|
||||||
|
green = 255 - Color.green(pixelColor);
|
||||||
|
blue = 255 - Color.blue(pixelColor);
|
||||||
|
output.setPixel(x, y, Color.argb(alpha, red, green, blue));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if the activity type is in the list.
|
* Returns true if the activity type is in the list.
|
||||||
*
|
*
|
||||||
* @param context the context
|
* @param context the context
|
||||||
* @param activityType the activity type
|
* @param activityType the activity type
|
||||||
* @param list the list
|
* @param list the list
|
||||||
|
|||||||
Reference in New Issue
Block a user