Merge branch 'master' of https://github.com/osmandapp/Osmand
This commit is contained in:
commit
6875334be7
22 changed files with 205 additions and 158 deletions
|
@ -1,5 +1,14 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
|
<string name="rendering_attr_winter_road_name">Автозимник</string>
|
||||||
|
<string name="rendering_attr_ice_road_name">Ледовый автозимник</string>
|
||||||
|
<string name="routeInfo_winter_ice_road_name">Зимники</string>
|
||||||
|
<string name="rendering_attr_tracktype_grade1_name">Твёрдое</string>
|
||||||
|
<string name="rendering_attr_tracktype_grade2_name">Почти твёрдое</string>
|
||||||
|
<string name="rendering_attr_tracktype_grade3_name">Смешанное</string>
|
||||||
|
<string name="rendering_attr_tracktype_grade4_name">Почти мягкое</string>
|
||||||
|
<string name="rendering_attr_tracktype_grade5_name">Мягкое</string>
|
||||||
|
<string name="routeInfo_tracktype_name">Состояние дороги</string>
|
||||||
<string name="intermediate_waypoint">Промежуточная точка</string>
|
<string name="intermediate_waypoint">Промежуточная точка</string>
|
||||||
<string name="intermediate_destinations">Промежуточные точки</string>
|
<string name="intermediate_destinations">Промежуточные точки</string>
|
||||||
<string name="arrive_at_time">Прибытие в %1$s</string>
|
<string name="arrive_at_time">Прибытие в %1$s</string>
|
||||||
|
|
|
@ -11,6 +11,15 @@
|
||||||
Thx - Hardy
|
Thx - Hardy
|
||||||
|
|
||||||
-->
|
-->
|
||||||
|
<string name="rendering_attr_winter_road_name">Winter road</string>
|
||||||
|
<string name="rendering_attr_ice_road_name">Ice road</string>
|
||||||
|
<string name="routeInfo_winter_ice_road_name">Winter and ice roads</string>
|
||||||
|
<string name="rendering_attr_tracktype_grade1_name">Solid (paved)</string>
|
||||||
|
<string name="rendering_attr_tracktype_grade2_name">Solid (unpaved)</string>
|
||||||
|
<string name="rendering_attr_tracktype_grade3_name">Mostly solid</string>
|
||||||
|
<string name="rendering_attr_tracktype_grade4_name">Mostly soft</string>
|
||||||
|
<string name="rendering_attr_tracktype_grade5_name">Soft</string>
|
||||||
|
<string name="routeInfo_tracktype_name">Surface firmness</string>
|
||||||
<string name="shared_string_file_is_saved">%s is saved</string>
|
<string name="shared_string_file_is_saved">%s is saved</string>
|
||||||
<string name="shared_string_open_track">Open track</string>
|
<string name="shared_string_open_track">Open track</string>
|
||||||
<string name="shared_string_track_is_saved">Track %s is saved</string>
|
<string name="shared_string_track_is_saved">Track %s is saved</string>
|
||||||
|
|
|
@ -3,6 +3,7 @@ package net.osmand.aidl;
|
||||||
import net.osmand.aidl.search.SearchResult;
|
import net.osmand.aidl.search.SearchResult;
|
||||||
import net.osmand.aidl.gpx.AGpxBitmap;
|
import net.osmand.aidl.gpx.AGpxBitmap;
|
||||||
import net.osmand.aidl.navigation.ADirectionInfo;
|
import net.osmand.aidl.navigation.ADirectionInfo;
|
||||||
|
import net.osmand.aidl.navigation.OnVoiceNavigationParams;
|
||||||
|
|
||||||
interface IOsmAndAidlCallback {
|
interface IOsmAndAidlCallback {
|
||||||
|
|
||||||
|
@ -49,5 +50,5 @@ interface IOsmAndAidlCallback {
|
||||||
/**
|
/**
|
||||||
* Callback for {@link IOsmAndAidlInterface} registerForVoiceRouterMessages() method.
|
* Callback for {@link IOsmAndAidlInterface} registerForVoiceRouterMessages() method.
|
||||||
*/
|
*/
|
||||||
void onVoiceRouterNotify();
|
void onVoiceRouterNotify(in OnVoiceNavigationParams params);
|
||||||
}
|
}
|
|
@ -47,6 +47,7 @@ import net.osmand.aidl.mapmarker.AMapMarker;
|
||||||
import net.osmand.aidl.mapwidget.AMapWidget;
|
import net.osmand.aidl.mapwidget.AMapWidget;
|
||||||
import net.osmand.aidl.navdrawer.NavDrawerFooterParams;
|
import net.osmand.aidl.navdrawer.NavDrawerFooterParams;
|
||||||
import net.osmand.aidl.navigation.ADirectionInfo;
|
import net.osmand.aidl.navigation.ADirectionInfo;
|
||||||
|
import net.osmand.aidl.navigation.OnVoiceNavigationParams;
|
||||||
import net.osmand.aidl.plugins.PluginParams;
|
import net.osmand.aidl.plugins.PluginParams;
|
||||||
import net.osmand.aidl.search.SearchResult;
|
import net.osmand.aidl.search.SearchResult;
|
||||||
import net.osmand.aidl.tiles.ASqliteDbFile;
|
import net.osmand.aidl.tiles.ASqliteDbFile;
|
||||||
|
@ -1923,12 +1924,12 @@ public class OsmandAidlApi {
|
||||||
public void registerForVoiceRouterMessages(long id) {
|
public void registerForVoiceRouterMessages(long id) {
|
||||||
VoiceRouter.VoiceMessageListener listener = new VoiceRouter.VoiceMessageListener() {
|
VoiceRouter.VoiceMessageListener listener = new VoiceRouter.VoiceMessageListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onVoiceMessage() {
|
public void onVoiceMessage(List<String> cmds, List<String> played) {
|
||||||
if (aidlCallbackListener != null) {
|
if (aidlCallbackListener != null) {
|
||||||
for (OsmandAidlService.AidlCallbackParams cb : aidlCallbackListener.getAidlCallbacks().values()) {
|
for (OsmandAidlService.AidlCallbackParams cb : aidlCallbackListener.getAidlCallbacks().values()) {
|
||||||
if (!aidlCallbackListener.getAidlCallbacks().isEmpty() && (cb.getKey() & KEY_ON_VOICE_MESSAGE) > 0) {
|
if (!aidlCallbackListener.getAidlCallbacks().isEmpty() && (cb.getKey() & KEY_ON_VOICE_MESSAGE) > 0) {
|
||||||
try {
|
try {
|
||||||
cb.getCallback().onVoiceRouterNotify();
|
cb.getCallback().onVoiceRouterNotify(new OnVoiceNavigationParams(cmds, played));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOG.error(e.getMessage(), e);
|
LOG.error(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
package net.osmand.aidl.navigation;
|
||||||
|
|
||||||
|
parcelable OnVoiceNavigationParams;
|
|
@ -0,0 +1,55 @@
|
||||||
|
package net.osmand.aidl.navigation;
|
||||||
|
|
||||||
|
import android.os.Parcel;
|
||||||
|
import android.os.Parcelable;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class OnVoiceNavigationParams implements Parcelable {
|
||||||
|
|
||||||
|
private List<String> cmds;
|
||||||
|
private List<String> played;
|
||||||
|
|
||||||
|
public OnVoiceNavigationParams() {
|
||||||
|
cmds = new ArrayList<>();
|
||||||
|
played = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public OnVoiceNavigationParams(List<String> cmds, List<String> played) {
|
||||||
|
this.cmds = cmds;
|
||||||
|
this.played = played;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OnVoiceNavigationParams(Parcel in) {
|
||||||
|
readFromParcel(in);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final Creator<OnVoiceNavigationParams> CREATOR = new Creator<OnVoiceNavigationParams>() {
|
||||||
|
@Override
|
||||||
|
public OnVoiceNavigationParams createFromParcel(Parcel in) {
|
||||||
|
return new OnVoiceNavigationParams(in);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public OnVoiceNavigationParams[] newArray(int size) {
|
||||||
|
return new OnVoiceNavigationParams[size];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeToParcel(Parcel out, int flags) {
|
||||||
|
out.writeList(cmds);
|
||||||
|
out.writeList(played);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void readFromParcel(Parcel in) {
|
||||||
|
in.readList(cmds, getClass().getClassLoader());
|
||||||
|
in.readList(played, getClass().getClassLoader());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int describeContents() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
|
@ -40,6 +40,8 @@ public class OsmAndFormatter {
|
||||||
private static final SimpleDateFormat SIMPLE_TIME_OF_DAY_FORMAT = new SimpleDateFormat("HH:mm", Locale.getDefault());
|
private static final SimpleDateFormat SIMPLE_TIME_OF_DAY_FORMAT = new SimpleDateFormat("HH:mm", Locale.getDefault());
|
||||||
private static final String[] localDaysStr = getLettersStringArray(DateFormatSymbols.getInstance().getShortWeekdays(), 3);
|
private static final String[] localDaysStr = getLettersStringArray(DateFormatSymbols.getInstance().getShortWeekdays(), 3);
|
||||||
|
|
||||||
|
public static final float MILS_IN_DEGREE = 17.777778f;
|
||||||
|
|
||||||
public static final int FORMAT_DEGREES_SHORT = 6;
|
public static final int FORMAT_DEGREES_SHORT = 6;
|
||||||
public static final int FORMAT_DEGREES = LocationConvert.FORMAT_DEGREES;
|
public static final int FORMAT_DEGREES = LocationConvert.FORMAT_DEGREES;
|
||||||
public static final int FORMAT_MINUTES = LocationConvert.FORMAT_MINUTES;
|
public static final int FORMAT_MINUTES = LocationConvert.FORMAT_MINUTES;
|
||||||
|
@ -195,12 +197,23 @@ public class OsmAndFormatter {
|
||||||
while(bearing > 360.0) {
|
while(bearing > 360.0) {
|
||||||
bearing -= 360;
|
bearing -= 360;
|
||||||
}
|
}
|
||||||
int azimuth = (int) bearing;
|
|
||||||
|
|
||||||
if (app.getSettings().ANGULAR_UNITS.get() == AngularConstants.MILLIRADS) {
|
if (app.getSettings().ANGULAR_UNITS.get() == AngularConstants.MILLIRADS) {
|
||||||
return (int) (azimuth * 17.4533) + " " + AngularConstants.MILLIRADS.getUnitSymbol();
|
if (bearing < 0) {
|
||||||
|
return Math.round((360 + bearing) * MILS_IN_DEGREE) + " " + AngularConstants.MILLIRADS.getUnitSymbol();
|
||||||
} else {
|
} else {
|
||||||
return azimuth + AngularConstants.DEGREES.getUnitSymbol();
|
return Math.round(bearing * MILS_IN_DEGREE) + " " + AngularConstants.MILLIRADS.getUnitSymbol();
|
||||||
|
}
|
||||||
|
} else if (app.getSettings().ANGULAR_UNITS.get() == AngularConstants.DEGREES360) {
|
||||||
|
if (bearing < -0.5) {
|
||||||
|
return (360 + Math.round(bearing)) + AngularConstants.DEGREES360.getUnitSymbol();
|
||||||
|
} else if (bearing >= -0.5 && bearing < 0) {
|
||||||
|
return 0 + AngularConstants.DEGREES360.getUnitSymbol();
|
||||||
|
} else {
|
||||||
|
return Math.round(bearing) + AngularConstants.DEGREES360.getUnitSymbol();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return Math.round(bearing) + AngularConstants.DEGREES.getUnitSymbol();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2967,6 +2967,7 @@ public class OsmandSettings {
|
||||||
|
|
||||||
public enum AngularConstants {
|
public enum AngularConstants {
|
||||||
DEGREES(R.string.shared_string_degrees, "°"),
|
DEGREES(R.string.shared_string_degrees, "°"),
|
||||||
|
DEGREES360(R.string.shared_string_degrees, "°"),
|
||||||
MILLIRADS(R.string.shared_string_milliradians, "mil");
|
MILLIRADS(R.string.shared_string_milliradians, "mil");
|
||||||
|
|
||||||
private final int key;
|
private final int key;
|
||||||
|
|
|
@ -213,8 +213,14 @@ public class SettingsGeneralActivity extends SettingsBaseActivity implements OnR
|
||||||
AngularConstants[] ac = AngularConstants.values();
|
AngularConstants[] ac = AngularConstants.values();
|
||||||
entries = new String[ac.length];
|
entries = new String[ac.length];
|
||||||
for (int i = 0; i < entries.length; i++) {
|
for (int i = 0; i < entries.length; i++) {
|
||||||
|
if (ac[i] == AngularConstants.DEGREES) {
|
||||||
|
entries[i] = AngularConstants.DEGREES.toHumanString(getMyApplication()) + " 180";
|
||||||
|
} else if (ac [i] == AngularConstants.DEGREES360) {
|
||||||
|
entries[i] = AngularConstants.DEGREES.toHumanString(getMyApplication()) + " 360";
|
||||||
|
} else {
|
||||||
entries[i] = ac[i].toHumanString(getMyApplication());
|
entries[i] = ac[i].toHumanString(getMyApplication());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
registerListPreference(settings.ANGULAR_UNITS, screen, entries, ac);
|
registerListPreference(settings.ANGULAR_UNITS, screen, entries, ac);
|
||||||
|
|
||||||
// See language list and statistics at: https://hosted.weblate.org/projects/osmand/main/
|
// See language list and statistics at: https://hosted.weblate.org/projects/osmand/main/
|
||||||
|
|
|
@ -17,6 +17,8 @@ import net.osmand.plus.OsmandSettings;
|
||||||
import net.osmand.plus.OsmandSettings.CommonPreference;
|
import net.osmand.plus.OsmandSettings.CommonPreference;
|
||||||
import net.osmand.plus.routing.VoiceRouter.VoiceMessageListener;
|
import net.osmand.plus.routing.VoiceRouter.VoiceMessageListener;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class LockHelper implements SensorEventListener {
|
public class LockHelper implements SensorEventListener {
|
||||||
|
|
||||||
private static final int SENSOR_SENSITIVITY = 4;
|
private static final int SENSOR_SENSITIVITY = 4;
|
||||||
|
@ -57,7 +59,7 @@ public class LockHelper implements SensorEventListener {
|
||||||
};
|
};
|
||||||
voiceMessageListener = new VoiceMessageListener() {
|
voiceMessageListener = new VoiceMessageListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onVoiceMessage() {
|
public void onVoiceMessage(List<String> listCommands, List<String> played) {
|
||||||
unlockEvent();
|
unlockEvent();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -7,6 +7,7 @@ import android.graphics.PointF;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
|
import android.support.annotation.ColorRes;
|
||||||
import android.support.annotation.DrawableRes;
|
import android.support.annotation.DrawableRes;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
|
@ -26,6 +27,7 @@ import android.widget.FrameLayout;
|
||||||
import android.widget.HorizontalScrollView;
|
import android.widget.HorizontalScrollView;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.ProgressBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import net.osmand.AndroidUtils;
|
import net.osmand.AndroidUtils;
|
||||||
|
@ -917,6 +919,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
|
||||||
final RoutingHelper helper = app.getRoutingHelper();
|
final RoutingHelper helper = app.getRoutingHelper();
|
||||||
View startButton = mainView.findViewById(R.id.start_button);
|
View startButton = mainView.findViewById(R.id.start_button);
|
||||||
TextViewExProgress startButtonText = (TextViewExProgress) mainView.findViewById(R.id.start_button_descr);
|
TextViewExProgress startButtonText = (TextViewExProgress) mainView.findViewById(R.id.start_button_descr);
|
||||||
|
ProgressBar progressBar = (ProgressBar) mainView.findViewById(R.id.progress_bar_button);
|
||||||
boolean publicTransportMode = helper.getAppMode() == ApplicationMode.PUBLIC_TRANSPORT;
|
boolean publicTransportMode = helper.getAppMode() == ApplicationMode.PUBLIC_TRANSPORT;
|
||||||
boolean routeCalculated = isRouteCalculated();
|
boolean routeCalculated = isRouteCalculated();
|
||||||
int iconId = publicTransportMode ? R.drawable.ic_map : R.drawable.ic_action_start_navigation;
|
int iconId = publicTransportMode ? R.drawable.ic_map : R.drawable.ic_action_start_navigation;
|
||||||
|
@ -942,8 +945,8 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
|
||||||
color2 = R.color.description_font_and_bottom_sheet_icons;
|
color2 = R.color.description_font_and_bottom_sheet_icons;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
startButtonText.color1 = ContextCompat.getColor(mapActivity, color1);
|
setupRouteCalculationButtonProgressBar(progressBar, startButtonText, color1, color2);
|
||||||
startButtonText.color2 = ContextCompat.getColor(mapActivity, color2);
|
|
||||||
startButtonText.setCompoundDrawablesWithIntrinsicBounds(app.getUIUtilities().getIcon(iconId, color2), null, null, null);
|
startButtonText.setCompoundDrawablesWithIntrinsicBounds(app.getUIUtilities().getIcon(iconId, color2), null, null, null);
|
||||||
if (publicTransportMode) {
|
if (publicTransportMode) {
|
||||||
startButtonText.setText(R.string.shared_string_show_on_map);
|
startButtonText.setText(R.string.shared_string_show_on_map);
|
||||||
|
@ -976,6 +979,16 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setupRouteCalculationButtonProgressBar(@NonNull ProgressBar pb, @NonNull TextViewExProgress textProgress, @ColorRes int progressTextColor, @ColorRes int bgTextColor) {
|
||||||
|
MapActivity mapActivity = getMapActivity();
|
||||||
|
if (mapActivity != null) {
|
||||||
|
int progressColor = ContextCompat.getColor(mapActivity, nightMode ? R.color.active_color_primary_dark : R.color.active_color_primary_light);
|
||||||
|
pb.setProgressDrawable(AndroidUtils.createProgressDrawable(ContextCompat.getColor(mapActivity, R.color.color_transparent), ContextCompat.getColor(mapActivity, progressTextColor)));
|
||||||
|
textProgress.paint.setColor(progressColor);
|
||||||
|
textProgress.setTextColor(ContextCompat.getColor(mapActivity, bgTextColor));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void createRoutingParametersButtons(MapActivity mapActivity, final RouteMenuAppModes mode, LinearLayout optionsContainer) {
|
private void createRoutingParametersButtons(MapActivity mapActivity, final RouteMenuAppModes mode, LinearLayout optionsContainer) {
|
||||||
if (mapActivity == null || optionsContainer == null) {
|
if (mapActivity == null || optionsContainer == null) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -379,7 +379,7 @@ public class MapRouteInfoMenuFragment extends ContextMenuFragment {
|
||||||
progressBarButton.setProgress(progress);
|
progressBarButton.setProgress(progress);
|
||||||
}
|
}
|
||||||
TextViewExProgress textViewExProgress = (TextViewExProgress) view.findViewById(R.id.start_button_descr);
|
TextViewExProgress textViewExProgress = (TextViewExProgress) view.findViewById(R.id.start_button_descr);
|
||||||
textViewExProgress.percent = progress / 100f;
|
textViewExProgress.percent = publicTransportMode ? 0 : progress / 100f;
|
||||||
textViewExProgress.invalidate();
|
textViewExProgress.invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -395,12 +395,12 @@ public class MapRouteInfoMenuFragment extends ContextMenuFragment {
|
||||||
if (progressBar != null) {
|
if (progressBar != null) {
|
||||||
progressBar.setVisibility(View.GONE);
|
progressBar.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
View progressBarButton = view.findViewById(R.id.progress_bar_button);
|
ProgressBar progressBarButton = (ProgressBar) view.findViewById(R.id.progress_bar_button);
|
||||||
if (progressBarButton != null) {
|
if (progressBarButton != null) {
|
||||||
progressBarButton.setVisibility(View.GONE);
|
progressBarButton.setProgress(100);
|
||||||
}
|
}
|
||||||
TextViewExProgress textViewExProgress = (TextViewExProgress) view.findViewById(R.id.start_button_descr);
|
TextViewExProgress textViewExProgress = (TextViewExProgress) view.findViewById(R.id.start_button_descr);
|
||||||
textViewExProgress.percent = 1;
|
textViewExProgress.percent = isPublicTransportMode() ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void show(MapActivity mapActivity) {
|
public void show(MapActivity mapActivity) {
|
||||||
|
@ -469,7 +469,6 @@ public class MapRouteInfoMenuFragment extends ContextMenuFragment {
|
||||||
((TextView) mainView.findViewById(R.id.toTitle)).setTextColor(descriptionColor);
|
((TextView) mainView.findViewById(R.id.toTitle)).setTextColor(descriptionColor);
|
||||||
|
|
||||||
ctx.setupRouteCalculationProgressBar((ProgressBar) mainView.findViewById(R.id.progress_bar));
|
ctx.setupRouteCalculationProgressBar((ProgressBar) mainView.findViewById(R.id.progress_bar));
|
||||||
setupRouteCalculationButtonProgressBar((ProgressBar) view.findViewById(R.id.progress_bar_button));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean showInstance(final MapActivity mapActivity, int initialMenuState) {
|
public static boolean showInstance(final MapActivity mapActivity, int initialMenuState) {
|
||||||
|
@ -506,14 +505,4 @@ public class MapRouteInfoMenuFragment extends ContextMenuFragment {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setupRouteCalculationButtonProgressBar(@NonNull ProgressBar pb) {
|
|
||||||
MapActivity mapActivity = getMapActivity();
|
|
||||||
if (mapActivity != null) {
|
|
||||||
int bgColor = ContextCompat.getColor(mapActivity, isNightMode() ? R.color.activity_background_dark : R.color.activity_background_light);
|
|
||||||
int progressColor = ContextCompat.getColor(mapActivity, isNightMode() ? R.color.active_color_primary_dark : R.color.active_color_primary_light);
|
|
||||||
pb.setProgressDrawable(AndroidUtils.createProgressDrawable(bgColor, progressColor));
|
|
||||||
pb.getIndeterminateDrawable().setColorFilter(progressColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -4,6 +4,7 @@ import android.content.Context;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.CountDownTimer;
|
import android.os.CountDownTimer;
|
||||||
|
import android.support.annotation.ColorRes;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.support.v4.app.FragmentActivity;
|
import android.support.v4.app.FragmentActivity;
|
||||||
|
@ -425,9 +426,13 @@ public class WaypointsFragment extends BaseOsmAndFragment implements ObservableS
|
||||||
AndroidUtils.setBackground(mapActivity, view.findViewById(R.id.controls_divider), nightMode, R.color.divider_color_light, R.color.divider_color_dark);
|
AndroidUtils.setBackground(mapActivity, view.findViewById(R.id.controls_divider), nightMode, R.color.divider_color_light, R.color.divider_color_dark);
|
||||||
|
|
||||||
((TextView) view.findViewById(R.id.cancel_button_descr)).setTextColor(colorActive);
|
((TextView) view.findViewById(R.id.cancel_button_descr)).setTextColor(colorActive);
|
||||||
((TextView) view.findViewById(R.id.start_button_descr)).setText(getText(R.string.shared_string_apply));
|
|
||||||
|
|
||||||
setupRouteCalculationButtonProgressBar((ProgressBar) view.findViewById(R.id.progress_bar_button));
|
TextViewExProgress startButtonText = (TextViewExProgress) view.findViewById(R.id.start_button_descr);
|
||||||
|
ProgressBar progressBar = (ProgressBar) view.findViewById(R.id.progress_bar_button);
|
||||||
|
startButtonText.setText(getText(R.string.shared_string_apply));
|
||||||
|
|
||||||
|
int progressTextColor = nightMode ? R.color.active_buttons_and_links_text_disabled_dark : R.color.active_buttons_and_links_text_light;
|
||||||
|
setupRouteCalculationButtonProgressBar(progressBar, startButtonText, progressTextColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reloadListAdapter(ArrayAdapter<Object> listAdapter) {
|
public void reloadListAdapter(ArrayAdapter<Object> listAdapter) {
|
||||||
|
@ -551,19 +556,17 @@ public class WaypointsFragment extends BaseOsmAndFragment implements ObservableS
|
||||||
}
|
}
|
||||||
TextViewExProgress textViewExProgress = (TextViewExProgress) view.findViewById(R.id.start_button_descr);
|
TextViewExProgress textViewExProgress = (TextViewExProgress) view.findViewById(R.id.start_button_descr);
|
||||||
textViewExProgress.percent = progress / 100f;
|
textViewExProgress.percent = progress / 100f;
|
||||||
int color = nightMode ? R.color.active_buttons_and_links_text_disabled_dark : R.color.active_buttons_and_links_text_light;
|
|
||||||
textViewExProgress.color1 = ContextCompat.getColor(mapActivity, color);
|
|
||||||
textViewExProgress.color2 = ContextCompat.getColor(mapActivity, R.color.active_buttons_and_links_text_disabled_dark);
|
|
||||||
textViewExProgress.invalidate();
|
textViewExProgress.invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setupRouteCalculationButtonProgressBar(@NonNull ProgressBar pb) {
|
private void setupRouteCalculationButtonProgressBar(@NonNull ProgressBar pb, @NonNull TextViewExProgress textProgress, @ColorRes int progressTextColor) {
|
||||||
OsmandApplication app = getMyApplication();
|
OsmandApplication app = getMyApplication();
|
||||||
if (app != null) {
|
if (app != null) {
|
||||||
int bgColor = ContextCompat.getColor(app, nightMode ? R.color.activity_background_dark : R.color.activity_background_light);
|
int bgColor = ContextCompat.getColor(app, nightMode ? R.color.activity_background_dark : R.color.activity_background_light);
|
||||||
int progressColor = ContextCompat.getColor(app, nightMode ? R.color.active_color_primary_dark : R.color.active_color_primary_light);
|
int progressColor = ContextCompat.getColor(app, nightMode ? R.color.active_color_primary_dark : R.color.active_color_primary_light);
|
||||||
|
pb.setProgressDrawable(AndroidUtils.createProgressDrawable(bgColor, ContextCompat.getColor(app, progressTextColor)));
|
||||||
pb.setProgressDrawable(AndroidUtils.createProgressDrawable(bgColor, progressColor));
|
textProgress.paint.setColor(progressColor);
|
||||||
|
textProgress.setTextColor(ContextCompat.getColor(app, R.color.active_buttons_and_links_text_disabled_dark));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,6 @@ import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
|
|
||||||
import net.osmand.Location;
|
import net.osmand.Location;
|
||||||
import net.osmand.binary.RouteDataObject;
|
import net.osmand.binary.RouteDataObject;
|
||||||
|
@ -80,7 +79,7 @@ public class VoiceRouter {
|
||||||
private static RouteDirectionInfo nextRouteDirection;
|
private static RouteDirectionInfo nextRouteDirection;
|
||||||
|
|
||||||
public interface VoiceMessageListener {
|
public interface VoiceMessageListener {
|
||||||
void onVoiceMessage();
|
void onVoiceMessage(List<String> listCommands, List<String> played);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<WeakReference<VoiceMessageListener>> voiceMessageListeners = new ArrayList<>();
|
private List<WeakReference<VoiceMessageListener>> voiceMessageListeners = new ArrayList<>();
|
||||||
|
@ -241,8 +240,8 @@ public class VoiceRouter {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void announceBackOnRoute() {
|
public void announceBackOnRoute() {
|
||||||
CommandBuilder p = getNewCommandPlayerToPlay();
|
|
||||||
if (announceBackOnRoute) {
|
if (announceBackOnRoute) {
|
||||||
|
CommandBuilder p = getNewCommandPlayerToPlay();
|
||||||
if (p != null) {
|
if (p != null) {
|
||||||
p.backOnRoute();
|
p.backOnRoute();
|
||||||
}
|
}
|
||||||
|
@ -909,9 +908,12 @@ public class VoiceRouter {
|
||||||
|
|
||||||
private void play(CommandBuilder p) {
|
private void play(CommandBuilder p) {
|
||||||
if (p != null) {
|
if (p != null) {
|
||||||
p.play();
|
List<String> played = p.play();
|
||||||
|
notifyOnVoiceMessage(p.getListCommands(), played);
|
||||||
|
} else {
|
||||||
|
notifyOnVoiceMessage(Collections.EMPTY_LIST, Collections.EMPTY_LIST);
|
||||||
}
|
}
|
||||||
notifyOnVoiceMessage();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void makeSound() {
|
private void makeSound() {
|
||||||
|
@ -941,12 +943,12 @@ public class VoiceRouter {
|
||||||
voiceMessageListeners = updateVoiceMessageListeners(new ArrayList<>(voiceMessageListeners), voiceMessageListener, false);
|
voiceMessageListeners = updateVoiceMessageListeners(new ArrayList<>(voiceMessageListeners), voiceMessageListener, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void notifyOnVoiceMessage() {
|
private void notifyOnVoiceMessage(List<String> listCommands, List<String> played) {
|
||||||
List<WeakReference<VoiceMessageListener>> voiceMessageListeners = new ArrayList<>(this.voiceMessageListeners);
|
List<WeakReference<VoiceMessageListener>> voiceMessageListeners = this.voiceMessageListeners;
|
||||||
for (WeakReference<VoiceMessageListener> weakReference : voiceMessageListeners) {
|
for (WeakReference<VoiceMessageListener> weakReference : voiceMessageListeners) {
|
||||||
VoiceMessageListener lnt = weakReference.get();
|
VoiceMessageListener lnt = weakReference.get();
|
||||||
if (lnt != null) {
|
if (lnt != null) {
|
||||||
lnt.onVoiceMessage();
|
lnt.onVoiceMessage(listCommands, played);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,15 +5,12 @@ import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.osmand.PlatformUtil;
|
import net.osmand.PlatformUtil;
|
||||||
import net.osmand.plus.R;
|
|
||||||
import net.osmand.plus.routing.data.StreetName;
|
import net.osmand.plus.routing.data.StreetName;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
|
||||||
import alice.tuprolog.Struct;
|
import alice.tuprolog.Struct;
|
||||||
import alice.tuprolog.Term;
|
import alice.tuprolog.Term;
|
||||||
import android.support.v4.app.NotificationCompat;
|
|
||||||
import android.support.v4.app.NotificationManagerCompat;
|
|
||||||
|
|
||||||
public class CommandBuilder {
|
public class CommandBuilder {
|
||||||
|
|
||||||
|
@ -57,6 +54,7 @@ public class CommandBuilder {
|
||||||
protected final CommandPlayer commandPlayer;
|
protected final CommandPlayer commandPlayer;
|
||||||
protected boolean alreadyExecuted = false;
|
protected boolean alreadyExecuted = false;
|
||||||
private List<Struct> listStruct = new ArrayList<Struct>();
|
private List<Struct> listStruct = new ArrayList<Struct>();
|
||||||
|
private List<String> listCommands = new ArrayList<String>();
|
||||||
|
|
||||||
public CommandBuilder(CommandPlayer commandPlayer){
|
public CommandBuilder(CommandPlayer commandPlayer){
|
||||||
this.commandPlayer = commandPlayer;
|
this.commandPlayer = commandPlayer;
|
||||||
|
@ -71,9 +69,21 @@ public class CommandBuilder {
|
||||||
private CommandBuilder addCommand(String name, Object... args){
|
private CommandBuilder addCommand(String name, Object... args){
|
||||||
Struct struct = prepareStruct(name, args);
|
Struct struct = prepareStruct(name, args);
|
||||||
listStruct.add(struct);
|
listStruct.add(struct);
|
||||||
|
listCommands.add(name);
|
||||||
|
for(Object o : args) {
|
||||||
|
if(o == null) {
|
||||||
|
listCommands.add(o.toString());
|
||||||
|
} else {
|
||||||
|
listCommands.add("");
|
||||||
|
}
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<String> getListCommands() {
|
||||||
|
return listCommands;
|
||||||
|
}
|
||||||
|
|
||||||
private Struct prepareStruct(String name, Object... args) {
|
private Struct prepareStruct(String name, Object... args) {
|
||||||
checkState();
|
checkState();
|
||||||
Term[] list = new Term[args.length];
|
Term[] list = new Term[args.length];
|
||||||
|
@ -254,8 +264,8 @@ public class CommandBuilder {
|
||||||
return alt(prepareStruct(C_ROUTE_RECALC, dist, time), prepareStruct(C_ROUTE_RECALC, dist));
|
return alt(prepareStruct(C_ROUTE_RECALC, dist, time), prepareStruct(C_ROUTE_RECALC, dist));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void play(){
|
public List<String> play(){
|
||||||
this.commandPlayer.playCommands(this);
|
return this.commandPlayer.playCommands(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ public interface CommandPlayer {
|
||||||
|
|
||||||
public CommandBuilder newCommandBuilder();
|
public CommandBuilder newCommandBuilder();
|
||||||
|
|
||||||
public void playCommands(CommandBuilder builder);
|
public List<String> playCommands(CommandBuilder builder);
|
||||||
|
|
||||||
public void clear();
|
public void clear();
|
||||||
|
|
||||||
|
|
|
@ -12,15 +12,8 @@ import org.mozilla.javascript.NativeJSON;
|
||||||
import org.mozilla.javascript.Scriptable;
|
import org.mozilla.javascript.Scriptable;
|
||||||
import org.mozilla.javascript.ScriptableObject;
|
import org.mozilla.javascript.ScriptableObject;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.FileReader;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class JSCommandBuilder extends CommandBuilder {
|
public class JSCommandBuilder extends CommandBuilder {
|
||||||
|
|
||||||
|
@ -216,8 +209,8 @@ public class JSCommandBuilder extends CommandBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void play(){
|
public List<String> play(){
|
||||||
this.commandPlayer.playCommands(this);
|
return this.commandPlayer.playCommands(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -15,6 +15,7 @@ import java.io.FileReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class JSMediaCommandPlayerImpl extends MediaCommandPlayerImpl {
|
public class JSMediaCommandPlayerImpl extends MediaCommandPlayerImpl {
|
||||||
|
@ -44,11 +45,12 @@ public class JSMediaCommandPlayerImpl extends MediaCommandPlayerImpl {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void playCommands(CommandBuilder builder) {
|
public synchronized List<String> playCommands(CommandBuilder builder) {
|
||||||
if(vrt.isMute()) {
|
if(vrt.isMute()) {
|
||||||
return;
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
filesToPlay.addAll(splitAnnouncements(builder.execute()));
|
List<String> lst = splitAnnouncements(builder.execute());
|
||||||
|
filesToPlay.addAll(lst);
|
||||||
|
|
||||||
// If we have not already started to play audio, start.
|
// If we have not already started to play audio, start.
|
||||||
if (mediaPlayer == null) {
|
if (mediaPlayer == null) {
|
||||||
|
@ -63,6 +65,7 @@ public class JSMediaCommandPlayerImpl extends MediaCommandPlayerImpl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
playQueue();
|
playQueue();
|
||||||
|
return lst;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<String> splitAnnouncements(List<String> execute) {
|
private List<String> splitAnnouncements(List<String> execute) {
|
||||||
|
|
|
@ -67,7 +67,7 @@ public class MediaCommandPlayerImpl extends AbstractPrologCommandPlayer implemen
|
||||||
|
|
||||||
// Called from the calculating route thread.
|
// Called from the calculating route thread.
|
||||||
@Override
|
@Override
|
||||||
public synchronized void playCommands(CommandBuilder builder) {
|
public synchronized List<String> playCommands(CommandBuilder builder) {
|
||||||
if(vrt.isMute()) {
|
if(vrt.isMute()) {
|
||||||
StringBuilder bld = new StringBuilder();
|
StringBuilder bld = new StringBuilder();
|
||||||
for (String s : builder.execute()) {
|
for (String s : builder.execute()) {
|
||||||
|
@ -76,9 +76,11 @@ public class MediaCommandPlayerImpl extends AbstractPrologCommandPlayer implemen
|
||||||
if (ctx != null) {
|
if (ctx != null) {
|
||||||
// sendAlertToAndroidWear(ctx, bld.toString());
|
// sendAlertToAndroidWear(ctx, bld.toString());
|
||||||
}
|
}
|
||||||
return;
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
filesToPlay.addAll(builder.execute());
|
List<String> lst = builder.execute();
|
||||||
|
|
||||||
|
filesToPlay.addAll(lst);
|
||||||
|
|
||||||
// If we have not already started to play audio, start.
|
// If we have not already started to play audio, start.
|
||||||
if (mediaPlayer == null) {
|
if (mediaPlayer == null) {
|
||||||
|
@ -93,6 +95,7 @@ public class MediaCommandPlayerImpl extends AbstractPrologCommandPlayer implemen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
playQueue();
|
playQueue();
|
||||||
|
return lst;
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized void playQueue() {
|
synchronized void playQueue() {
|
||||||
|
|
|
@ -104,7 +104,7 @@ public class TTSCommandPlayerImpl extends AbstractPrologCommandPlayer {
|
||||||
|
|
||||||
// Called from the calculating route thread.
|
// Called from the calculating route thread.
|
||||||
@Override
|
@Override
|
||||||
public synchronized void playCommands(CommandBuilder builder) {
|
public synchronized List<String> playCommands(CommandBuilder builder) {
|
||||||
final List<String> execute = builder.execute(); //list of strings, the speech text, play it
|
final List<String> execute = builder.execute(); //list of strings, the speech text, play it
|
||||||
StringBuilder bld = new StringBuilder();
|
StringBuilder bld = new StringBuilder();
|
||||||
for (String s : execute) {
|
for (String s : execute) {
|
||||||
|
@ -132,6 +132,7 @@ public class TTSCommandPlayerImpl extends AbstractPrologCommandPlayer {
|
||||||
} else if (ctx != null && vrt.isMute()) {
|
} else if (ctx != null && vrt.isMute()) {
|
||||||
// sendAlertToAndroidWear(ctx, bld.toString());
|
// sendAlertToAndroidWear(ctx, bld.toString());
|
||||||
}
|
}
|
||||||
|
return execute;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,55 +0,0 @@
|
||||||
package net.osmand.plus.widgets;
|
|
||||||
|
|
||||||
import android.annotation.TargetApi;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.graphics.Canvas;
|
|
||||||
import android.graphics.Rect;
|
|
||||||
import android.support.annotation.Nullable;
|
|
||||||
import android.util.AttributeSet;
|
|
||||||
import android.widget.ImageView;
|
|
||||||
|
|
||||||
public class ImageViewExProgress extends ImageView {
|
|
||||||
|
|
||||||
public float percent;
|
|
||||||
public int color1;
|
|
||||||
public int color2;
|
|
||||||
|
|
||||||
public ImageViewExProgress(Context context) {
|
|
||||||
super(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ImageViewExProgress(Context context, @Nullable AttributeSet attrs) {
|
|
||||||
super(context, attrs);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ImageViewExProgress(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
|
|
||||||
super(context, attrs, defStyleAttr);
|
|
||||||
}
|
|
||||||
|
|
||||||
@TargetApi(21)
|
|
||||||
public ImageViewExProgress(Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
|
||||||
super(context, attrs, defStyleAttr, defStyleRes);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void draw(Canvas canvas) {
|
|
||||||
canvas.save();
|
|
||||||
setColorFilter(color1);
|
|
||||||
int width = getWidth();
|
|
||||||
int widthP = (int) (width * percent);
|
|
||||||
int height = getHeight();
|
|
||||||
canvas.clipRect(new Rect(0, 0, widthP, height));
|
|
||||||
super.draw(canvas);
|
|
||||||
canvas.restore();
|
|
||||||
|
|
||||||
canvas.save();
|
|
||||||
setColorFilter(color2);
|
|
||||||
int width2 = getWidth();
|
|
||||||
int widthP2 = (int) (width2 * percent);
|
|
||||||
int height2 = getHeight();
|
|
||||||
canvas.clipRect(new Rect(widthP2, 0, width2, height2));
|
|
||||||
super.draw(canvas);
|
|
||||||
canvas.restore();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -2,67 +2,52 @@ package net.osmand.plus.widgets;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
|
import android.graphics.Paint;
|
||||||
import android.graphics.PorterDuff;
|
import android.graphics.PorterDuff;
|
||||||
import android.graphics.Rect;
|
import android.graphics.PorterDuffXfermode;
|
||||||
import android.graphics.drawable.Drawable;
|
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
|
|
||||||
public class TextViewExProgress extends TextViewEx {
|
public class TextViewExProgress extends TextViewEx {
|
||||||
|
|
||||||
|
public Paint paint;
|
||||||
public float percent;
|
public float percent;
|
||||||
public int color1;
|
|
||||||
public int color2;
|
|
||||||
|
|
||||||
public TextViewExProgress(Context context) {
|
public TextViewExProgress(Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
|
initPaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
public TextViewExProgress(Context context, AttributeSet attrs) {
|
public TextViewExProgress(Context context, AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
|
initPaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
public TextViewExProgress(Context context, AttributeSet attrs, int defStyleAttr) {
|
public TextViewExProgress(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||||
super(context, attrs, defStyleAttr);
|
super(context, attrs, defStyleAttr);
|
||||||
|
initPaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
public TextViewExProgress(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
public TextViewExProgress(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||||
super(context, attrs, defStyleAttr, defStyleRes);
|
super(context, attrs, defStyleAttr, defStyleRes);
|
||||||
|
initPaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Canvas canvas) {
|
public void onDraw(Canvas canvas) {
|
||||||
canvas.save();
|
super.onDraw(canvas);
|
||||||
setTextColor(color1);
|
drawProgress(canvas);
|
||||||
Drawable[] icons = getCompoundDrawables();
|
|
||||||
for (int i = 0; i < icons.length; i++) {
|
|
||||||
Drawable drawable = icons[i];
|
|
||||||
if (drawable != null) {
|
|
||||||
drawable.setColorFilter(color1, PorterDuff.Mode.SRC_ATOP);
|
|
||||||
icons[i] = drawable;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
setCompoundDrawables(icons[0], icons[1], icons[2], icons[3]);
|
|
||||||
int width = getWidth();
|
|
||||||
int widthP = (int) (width * percent);
|
|
||||||
int height = getHeight();
|
|
||||||
canvas.clipRect(new Rect(0, 0, widthP, height));
|
|
||||||
super.draw(canvas);
|
|
||||||
canvas.restore();
|
|
||||||
|
|
||||||
canvas.save();
|
private void drawProgress(Canvas canvas) {
|
||||||
setTextColor(color2);
|
int w = getWidth();
|
||||||
for (int i = 0; i < icons.length; i++) {
|
int h = getHeight();
|
||||||
Drawable drawable = icons[i];
|
float rectW = w * (percent);
|
||||||
if (drawable != null) {
|
canvas.drawRect(0, 0, rectW, h, paint);
|
||||||
drawable.setColorFilter(color2, PorterDuff.Mode.SRC_ATOP);
|
}
|
||||||
icons[i] = drawable;
|
|
||||||
}
|
private void initPaint() {
|
||||||
}
|
paint = new Paint();
|
||||||
setCompoundDrawables(icons[0], icons[1], icons[2], icons[3]);
|
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.XOR));
|
||||||
int width2 = getWidth();
|
setLayerType(LAYER_TYPE_SOFTWARE, null);
|
||||||
int widthP2 = (int) (width2 * percent);
|
|
||||||
int height2 = getHeight();
|
|
||||||
canvas.clipRect(new Rect(widthP2, 0, width2, height2));
|
|
||||||
super.draw(canvas);
|
|
||||||
canvas.restore();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue