mirror of
https://codeberg.org/OpenTracksApp/OpenTracks.git
synced 2026-10-02 17:43:06 +02:00
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_width="match_parent"
|
||||
android:numColumns="4"
|
||||
android:paddingBottom="20dp"
|
||||
android:paddingTop="20dp"
|
||||
android:stretchMode="columnWidth"
|
||||
android:verticalSpacing="20dp" />
|
||||
android:padding="4dp"
|
||||
android:stretchMode="spacingWidth"
|
||||
android:verticalSpacing="4dp" />
|
||||
|
||||
@@ -41,20 +41,20 @@ limitations under the License.
|
||||
android:layout_width="match_parent"
|
||||
android:orientation="horizontal" >
|
||||
<AutoCompleteTextView
|
||||
android:gravity="bottom"
|
||||
android:hint="@string/track_edit_activity_type_hint"
|
||||
android:id="@+id/track_edit_activity_type"
|
||||
android:imeOptions="actionNext"
|
||||
android:layout_gravity="bottom"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_weight="1"
|
||||
android:layout_width="0dp"
|
||||
style="@style/EditCategory" />
|
||||
<ImageButton
|
||||
android:contentDescription="@string/activity_type_walking"
|
||||
<Spinner
|
||||
android:id="@+id/track_edit_activity_type_icon"
|
||||
android:layout_gravity="bottom"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:src="@drawable/track_walk" />
|
||||
android:layout_width="wrap_content" />
|
||||
</LinearLayout>
|
||||
<TextView
|
||||
android:text="@string/generic_description"
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* Copyright 2008 Google Inc.
|
||||
*
|
||||
*
|
||||
* 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
|
||||
* the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* 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.fragments.ChooseActivityTypeDialogFragment;
|
||||
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.TrackNameUtils;
|
||||
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.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.AutoCompleteTextView;
|
||||
import android.widget.Button;
|
||||
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
|
||||
* data such as track name, activity type, and track description.
|
||||
*
|
||||
*
|
||||
* @author Leif Hendrik Wilden
|
||||
*/
|
||||
public class TrackEditActivity extends AbstractMyTracksActivity
|
||||
@@ -56,7 +63,7 @@ public class TrackEditActivity extends AbstractMyTracksActivity
|
||||
|
||||
private EditText name;
|
||||
private AutoCompleteTextView activityType;
|
||||
private ImageButton activityTypeIcon;
|
||||
private Spinner activityTypeIcon;
|
||||
private EditText description;
|
||||
|
||||
@Override
|
||||
@@ -88,14 +95,14 @@ public class TrackEditActivity extends AbstractMyTracksActivity
|
||||
this, R.array.activity_types, android.R.layout.simple_dropdown_item_1line);
|
||||
activityType.setAdapter(adapter);
|
||||
activityType.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
setActivityTypeIcon(TrackIconUtils.getIconValue(
|
||||
TrackEditActivity.this, (String) activityType.getAdapter().getItem(position)));
|
||||
}
|
||||
});
|
||||
activityType.setOnFocusChangeListener(new View.OnFocusChangeListener() {
|
||||
@Override
|
||||
@Override
|
||||
public void onFocusChange(View v, boolean hasFocus) {
|
||||
if (!hasFocus) {
|
||||
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;
|
||||
if (bundle != null) {
|
||||
iconValue = bundle.getString(ICON_VALUE_KEY);
|
||||
@@ -120,14 +118,65 @@ public class TrackEditActivity extends AbstractMyTracksActivity
|
||||
if (iconValue == null) {
|
||||
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.setText(track.getDescription());
|
||||
|
||||
Button save = (Button) findViewById(R.id.track_edit_save);
|
||||
save.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
track.setName(name.getText().toString());
|
||||
String category = activityType.getText().toString();
|
||||
@@ -152,7 +201,7 @@ public class TrackEditActivity extends AbstractMyTracksActivity
|
||||
} else {
|
||||
setTitle(R.string.menu_edit);
|
||||
cancel.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
@@ -174,12 +223,17 @@ public class TrackEditActivity extends AbstractMyTracksActivity
|
||||
|
||||
/**
|
||||
* Sets the activity type icon.
|
||||
*
|
||||
*
|
||||
* @param value the icon value
|
||||
*/
|
||||
private void setActivityTypeIcon(String 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
|
||||
|
||||
@@ -743,6 +743,7 @@ public class TrackListActivity extends AbstractSendToGoogleActivity
|
||||
private void updateMenuItems(boolean isRecording) {
|
||||
if (startGpsMenuItem != null) {
|
||||
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);
|
||||
}
|
||||
if (importAllMenuItem != null) {
|
||||
|
||||
+18
-8
@@ -22,6 +22,8 @@ import com.google.android.maps.mytracks.R;
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.BitmapFactory.Options;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.view.View;
|
||||
@@ -34,14 +36,14 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
* A DialogFragment to choose an activity type.
|
||||
*
|
||||
*
|
||||
* @author apoorvn
|
||||
*/
|
||||
public class ChooseActivityTypeDialogFragment extends DialogFragment {
|
||||
|
||||
/**
|
||||
* Interface for caller of this dialog fragment.
|
||||
*
|
||||
*
|
||||
* @author apoorvn
|
||||
*/
|
||||
public interface ChooseActivityTypeCaller {
|
||||
@@ -69,8 +71,8 @@ public class ChooseActivityTypeDialogFragment extends DialogFragment {
|
||||
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
GridView gridView = (GridView) getActivity()
|
||||
.getLayoutInflater().inflate(R.layout.choose_activity_type, null);
|
||||
GridView gridView =
|
||||
(GridView) getActivity().getLayoutInflater().inflate(R.layout.choose_activity_type, null);
|
||||
|
||||
final List<String> iconValues = TrackIconUtils.getAllIconValues();
|
||||
List<Integer> imageIds = new ArrayList<Integer>();
|
||||
@@ -78,11 +80,19 @@ public class ChooseActivityTypeDialogFragment extends DialogFragment {
|
||||
imageIds.add(TrackIconUtils.getIconDrawable(iconValue));
|
||||
}
|
||||
|
||||
ChooseActivityTypeImageAdapter imageAdapter = new ChooseActivityTypeImageAdapter(
|
||||
getActivity(), imageIds);
|
||||
Options options = new BitmapFactory.Options();
|
||||
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.setOnItemClickListener(new OnItemClickListener() {
|
||||
@Override
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
|
||||
dismiss();
|
||||
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)
|
||||
.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.
|
||||
*
|
||||
*
|
||||
* @author apoorvn
|
||||
*/
|
||||
public class ChooseActivityTypeImageAdapter extends BaseAdapter {
|
||||
|
||||
private final Context context;
|
||||
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.imageIds = imageIds;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.padding = padding;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -63,6 +70,9 @@ public class ChooseActivityTypeImageAdapter extends BaseAdapter {
|
||||
imageView = (ImageView) convertView;
|
||||
}
|
||||
imageView.setImageResource(imageIds.get(position));
|
||||
imageView.setMinimumHeight(height);
|
||||
imageView.setMinimumWidth(width);
|
||||
imageView.setPadding(padding, padding, padding, padding);
|
||||
return imageView;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,4 +124,9 @@ public class Api11Adapter extends Api10Adapter {
|
||||
public void invalidMenu(Activity activity) {
|
||||
activity.invalidateOptionsMenu();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSpinnerBackgroundLight() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,6 +133,11 @@ public class Api8Adapter implements ApiAdapter {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSpinnerBackgroundLight() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleSearchKey(MenuItem menuItem) {
|
||||
// Return false and allow the framework to handle the search key.
|
||||
|
||||
@@ -163,6 +163,13 @@ public interface ApiAdapter {
|
||||
*/
|
||||
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.
|
||||
* <p>
|
||||
|
||||
@@ -19,6 +19,8 @@ package com.google.android.apps.mytracks.util;
|
||||
import com.google.android.maps.mytracks.R;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Color;
|
||||
import android.util.Pair;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -27,7 +29,7 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
* Utilities for track icon.
|
||||
*
|
||||
*
|
||||
* @author Jimmy Shih
|
||||
*/
|
||||
public class TrackIconUtils {
|
||||
@@ -43,48 +45,52 @@ public class TrackIconUtils {
|
||||
|
||||
private TrackIconUtils() {}
|
||||
|
||||
private static LinkedHashMap<String, Pair<Integer, Integer>>
|
||||
map = new LinkedHashMap<String, Pair<Integer, Integer>>();
|
||||
private static LinkedHashMap<String, Pair<Integer, Integer>> map =
|
||||
new LinkedHashMap<String, Pair<Integer, Integer>>();
|
||||
|
||||
static {
|
||||
map.put(AIRPLANE,
|
||||
new Pair<Integer, Integer>(R.string.activity_type_airplane, R.drawable.track_airplane));
|
||||
map.put(RUN, new Pair<Integer, Integer>(R.string.activity_type_running, R.drawable.track_run));
|
||||
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(BOAT, new Pair<Integer, Integer>(R.string.activity_type_boat, R.drawable.track_boat));
|
||||
map.put(
|
||||
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(SNOW_BOARDING, new Pair<Integer, Integer>(
|
||||
R.string.activity_type_snow_boarding, R.drawable.track_snow_boarding));
|
||||
map.put(
|
||||
WALK, new Pair<Integer, Integer>(R.string.activity_type_walking, R.drawable.track_walk));
|
||||
map.put(AIRPLANE,
|
||||
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,
|
||||
R.string.activity_type_commercial_airplane, R.string.activity_type_rc_airplane };
|
||||
private static int[] bike = new int[] { R.string.activity_type_biking,
|
||||
R.string.activity_type_cycling, R.string.activity_type_dirt_bike,
|
||||
R.string.activity_type_motor_bike, R.string.activity_type_mountain_biking,
|
||||
R.string.activity_type_road_biking, R.string.activity_type_track_cycling };
|
||||
private static int[] boat = new int[] { R.string.activity_type_boat, R.string.activity_type_ferry,
|
||||
R.string.activity_type_motor_boating, R.string.activity_type_rc_boat };
|
||||
private static int[] drive = new int[] { R.string.activity_type_atv,
|
||||
R.string.activity_type_driving, R.string.activity_type_driving_bus,
|
||||
R.string.activity_type_driving_car };
|
||||
private static int[] run = new int[] { R.string.activity_type_running,
|
||||
R.string.activity_type_street_running, 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,
|
||||
private static int[] airplane = new int[] {
|
||||
R.string.activity_type_airplane, R.string.activity_type_commercial_airplane,
|
||||
R.string.activity_type_rc_airplane};
|
||||
private static int[] bike = new int[] {R.string.activity_type_biking,
|
||||
R.string.activity_type_cycling,
|
||||
R.string.activity_type_dirt_bike,
|
||||
R.string.activity_type_motor_bike,
|
||||
R.string.activity_type_mountain_biking,
|
||||
R.string.activity_type_road_biking,
|
||||
R.string.activity_type_track_cycling};
|
||||
private static int[] boat = new int[] {R.string.activity_type_boat, R.string.activity_type_ferry,
|
||||
R.string.activity_type_motor_boating, R.string.activity_type_rc_boat};
|
||||
private static int[] drive = new int[] {
|
||||
R.string.activity_type_atv, R.string.activity_type_driving,
|
||||
R.string.activity_type_driving_bus, R.string.activity_type_driving_car};
|
||||
private static int[] run = new int[] {
|
||||
R.string.activity_type_running, R.string.activity_type_street_running,
|
||||
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_trail_hiking, R.string.activity_type_walking };
|
||||
R.string.activity_type_trail_hiking, R.string.activity_type_walking};
|
||||
|
||||
/**
|
||||
* Gets the icon drawable.
|
||||
*
|
||||
*
|
||||
* @param iconValue the icon value
|
||||
*/
|
||||
public static int getIconDrawable(String iconValue) {
|
||||
@@ -97,7 +103,7 @@ public class TrackIconUtils {
|
||||
|
||||
/**
|
||||
* Gets the icon activity type.
|
||||
*
|
||||
*
|
||||
* @param iconValue the icon value
|
||||
*/
|
||||
public static int getIconActivityType(String iconValue) {
|
||||
@@ -121,7 +127,7 @@ public class TrackIconUtils {
|
||||
|
||||
/**
|
||||
* Gets the icon value.
|
||||
*
|
||||
*
|
||||
* @param context the context
|
||||
* @param activityType the activity type
|
||||
*/
|
||||
@@ -153,9 +159,37 @@ public class TrackIconUtils {
|
||||
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.
|
||||
*
|
||||
*
|
||||
* @param context the context
|
||||
* @param activityType the activity type
|
||||
* @param list the list
|
||||
|
||||
Reference in New Issue
Block a user