Added indeterminate progress bar for public transport routing
This commit is contained in:
parent
052d976b08
commit
83a2f7abef
7 changed files with 79 additions and 71 deletions
|
@ -412,9 +412,9 @@ dependencies {
|
||||||
// turn off for now
|
// turn off for now
|
||||||
//implementation 'com.atilika.kuromoji:kuromoji-ipadic:0.9.0'
|
//implementation 'com.atilika.kuromoji:kuromoji-ipadic:0.9.0'
|
||||||
implementation 'com.squareup.picasso:picasso:2.71828'
|
implementation 'com.squareup.picasso:picasso:2.71828'
|
||||||
|
implementation 'me.zhanghai.android.materialprogressbar:library:1.4.2'
|
||||||
// JS core
|
// JS core
|
||||||
implementation group: 'org.mozilla', name: 'rhino', version: '1.7.9'
|
implementation group: 'org.mozilla', name: 'rhino', version: '1.7.9'
|
||||||
|
|
||||||
// size restrictions
|
// size restrictions
|
||||||
// implementation 'com.ibm.icu:icu4j:50.1'
|
// implementation 'com.ibm.icu:icu4j:50.1'
|
||||||
// implementation 'net.sf.trove4j:trove4j:3.0.3'
|
// implementation 'net.sf.trove4j:trove4j:3.0.3'
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="bottom"
|
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||||
android:orientation="vertical">
|
android:layout_gravity="bottom"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/bottom_controls_container"
|
android:id="@+id/bottom_controls_container"
|
||||||
|
@ -184,18 +185,20 @@
|
||||||
android:layout_gravity="center"/>
|
android:layout_gravity="center"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<ProgressBar
|
<me.zhanghai.android.materialprogressbar.MaterialProgressBar
|
||||||
android:id="@+id/map_horizontal_progress"
|
android:id="@+id/map_horizontal_progress"
|
||||||
style="?android:attr/progressBarStyleHorizontal"
|
android:layout_width="match_parent"
|
||||||
android:layout_width="match_parent"
|
android:layout_height="4dp"
|
||||||
android:layout_gravity="bottom"
|
android:layout_gravity="bottom"
|
||||||
android:layout_height="4dp"
|
android:max="100"
|
||||||
android:max="100"
|
android:visibility="gone"
|
||||||
android:visibility="gone"
|
osmand:mpb_progressStyle="horizontal"
|
||||||
tools:progress="60"
|
osmand:mpb_useIntrinsicPadding="false"
|
||||||
tools:visibility="visible" />
|
osmand:mpb_setBothDrawables="true"
|
||||||
|
style="@style/Widget.MaterialProgressBar.ProgressBar.Horizontal"
|
||||||
|
tools:progress="60"
|
||||||
|
tools:visibility="visible" />
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="bottom"
|
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||||
android:orientation="vertical">
|
android:layout_gravity="bottom"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
<!--<net.osmand.plus.quickaction.QuickActionsWidget
|
<!--<net.osmand.plus.quickaction.QuickActionsWidget
|
||||||
android:id="@+id/quick_action_widget"
|
android:id="@+id/quick_action_widget"
|
||||||
|
@ -224,16 +225,20 @@
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<ProgressBar
|
<me.zhanghai.android.materialprogressbar.MaterialProgressBar
|
||||||
android:id="@+id/map_horizontal_progress"
|
android:id="@+id/map_horizontal_progress"
|
||||||
style="?android:attr/progressBarStyleHorizontal"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="4dp"
|
android:layout_height="4dp"
|
||||||
android:layout_gravity="bottom"
|
android:layout_gravity="bottom"
|
||||||
android:max="100"
|
android:max="100"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
|
osmand:mpb_progressStyle="horizontal"
|
||||||
|
osmand:mpb_useIntrinsicPadding="false"
|
||||||
|
osmand:mpb_setBothDrawables="true"
|
||||||
|
style="@style/Widget.MaterialProgressBar.ProgressBar.Horizontal"
|
||||||
tools:progress="60"
|
tools:progress="60"
|
||||||
tools:visibility="visible" />
|
tools:visibility="visible" />
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -501,16 +501,17 @@
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<ProgressBar
|
<me.zhanghai.android.materialprogressbar.MaterialProgressBar
|
||||||
android:id="@+id/progress_bar"
|
android:id="@+id/progress_bar"
|
||||||
style="?android:attr/progressBarStyleHorizontal"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="2dp"
|
android:layout_height="2dp"
|
||||||
android:layout_gravity="bottom"
|
android:layout_gravity="bottom"
|
||||||
android:max="100"
|
android:max="100"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
tools:progress="60"
|
osmand:mpb_progressStyle="horizontal"
|
||||||
tools:visibility="visible" />
|
osmand:mpb_useIntrinsicPadding="false"
|
||||||
|
osmand:mpb_setBothDrawables="true"
|
||||||
|
style="@style/Widget.MaterialProgressBar.ProgressBar.Horizontal" />
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
|
|
|
@ -540,6 +540,8 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
||||||
: ContextCompat.getColor(this, R.color.wikivoyage_active_light);
|
: ContextCompat.getColor(this, R.color.wikivoyage_active_light);
|
||||||
|
|
||||||
pb.setProgressDrawable(AndroidUtils.createProgressDrawable(bgColor, progressColor));
|
pb.setProgressDrawable(AndroidUtils.createProgressDrawable(bgColor, progressColor));
|
||||||
|
pb.setIndeterminate(getRoutingHelper().getAppMode() == ApplicationMode.PUBLIC_TRANSPORT);
|
||||||
|
pb.getIndeterminateDrawable().setColorFilter(progressColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ImportHelper getImportHelper() {
|
public ImportHelper getImportHelper() {
|
||||||
|
|
|
@ -383,7 +383,6 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
|
||||||
if (fragmentRef != null && fragment.isVisible()) {
|
if (fragmentRef != null && fragment.isVisible()) {
|
||||||
setRouteCalculationInProgress(true);
|
setRouteCalculationInProgress(true);
|
||||||
fragment.updateRouteCalculationProgress(0);
|
fragment.updateRouteCalculationProgress(0);
|
||||||
fragment.updateControlButtons();
|
|
||||||
fragment.updateInfo();
|
fragment.updateInfo();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -396,7 +395,6 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
|
||||||
fragment.updateInfo();
|
fragment.updateInfo();
|
||||||
}
|
}
|
||||||
fragment.updateRouteCalculationProgress(progress);
|
fragment.updateRouteCalculationProgress(progress);
|
||||||
fragment.updateControlButtons();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -407,7 +405,6 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
|
||||||
if (app != null && fragmentRef != null && fragment.isVisible()) {
|
if (app != null && fragmentRef != null && fragment.isVisible()) {
|
||||||
boolean routeCalculating = app.getRoutingHelper().isRouteBeingCalculated() || app.getTransportRoutingHelper().isRouteBeingCalculated();
|
boolean routeCalculating = app.getRoutingHelper().isRouteBeingCalculated() || app.getTransportRoutingHelper().isRouteBeingCalculated();
|
||||||
if (setRouteCalculationInProgress(routeCalculating)) {
|
if (setRouteCalculationInProgress(routeCalculating)) {
|
||||||
fragment.updateControlButtons();
|
|
||||||
fragment.updateInfo();
|
fragment.updateInfo();
|
||||||
if (!routeCalculationInProgress) {
|
if (!routeCalculationInProgress) {
|
||||||
fragment.hideRouteCalculationProgressBar();
|
fragment.hideRouteCalculationProgressBar();
|
||||||
|
@ -870,17 +867,33 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
|
||||||
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);
|
||||||
boolean publicTransportMode = helper.getAppMode() == ApplicationMode.PUBLIC_TRANSPORT;
|
boolean publicTransportMode = helper.getAppMode() == ApplicationMode.PUBLIC_TRANSPORT;
|
||||||
|
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;
|
||||||
int color;
|
int color1;
|
||||||
if (isRouteCalculated()) {
|
int color2;
|
||||||
AndroidUtils.setBackground(app, startButton, nightMode, R.color.active_buttons_and_links_light, R.color.active_buttons_and_links_dark);
|
if (publicTransportMode) {
|
||||||
color = nightMode ? R.color.main_font_dark : R.color.card_and_list_background_light;
|
if (routeCalculated) {
|
||||||
|
color1 = nightMode ? R.color.active_buttons_and_links_dark : R.color.active_buttons_and_links_light;
|
||||||
|
AndroidUtils.setBackground(app, startButton, nightMode, R.color.card_and_list_background_light, R.color.card_and_list_background_dark);
|
||||||
|
color2 = color1;
|
||||||
|
} else {
|
||||||
|
color1 = R.color.description_font_and_bottom_sheet_icons;
|
||||||
|
AndroidUtils.setBackground(app, startButton, nightMode, R.color.activity_background_light, R.color.activity_background_dark);
|
||||||
|
color2 = color1;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
AndroidUtils.setBackground(app, startButton, nightMode, R.color.activity_background_light, R.color.activity_background_dark);
|
color1 = nightMode ? R.color.main_font_dark : R.color.card_and_list_background_light;
|
||||||
color = R.color.description_font_and_bottom_sheet_icons;
|
if (routeCalculated) {
|
||||||
|
AndroidUtils.setBackground(app, startButton, nightMode, R.color.active_buttons_and_links_light, R.color.active_buttons_and_links_dark);
|
||||||
|
color2 = nightMode ? R.color.main_font_dark : R.color.card_and_list_background_light;
|
||||||
|
} else {
|
||||||
|
AndroidUtils.setBackground(app, startButton, nightMode, R.color.activity_background_light, R.color.activity_background_dark);
|
||||||
|
color2 = R.color.description_font_and_bottom_sheet_icons;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
startButtonText.color2 = ContextCompat.getColor(app, color);
|
startButtonText.color1 = ContextCompat.getColor(mapActivity, color1);
|
||||||
startButtonText.setCompoundDrawablesWithIntrinsicBounds(app.getUIUtilities().getIcon(iconId, color), null, null, null);
|
startButtonText.color2 = ContextCompat.getColor(mapActivity, color2);
|
||||||
|
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);
|
||||||
} else if (helper.isFollowingMode() || helper.isPauseNavigation()) {
|
} else if (helper.isFollowingMode() || helper.isPauseNavigation()) {
|
||||||
|
|
|
@ -152,7 +152,6 @@ public class MapRouteInfoMenuFragment extends ContextMenuFragment {
|
||||||
dismiss();
|
dismiss();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
updateControlButtons();
|
|
||||||
updateInfo();
|
updateInfo();
|
||||||
View mainView = getMainView();
|
View mainView = getMainView();
|
||||||
if (mainView != null) {
|
if (mainView != null) {
|
||||||
|
@ -355,6 +354,11 @@ public class MapRouteInfoMenuFragment extends ContextMenuFragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isPublicTransportMode() {
|
||||||
|
OsmandApplication app = getMyApplication();
|
||||||
|
return app != null && app.getRoutingHelper().getAppMode() == ApplicationMode.PUBLIC_TRANSPORT;
|
||||||
|
}
|
||||||
|
|
||||||
public void updateRouteCalculationProgress(int progress) {
|
public void updateRouteCalculationProgress(int progress) {
|
||||||
MapActivity mapActivity = getMapActivity();
|
MapActivity mapActivity = getMapActivity();
|
||||||
View mainView = getMainView();
|
View mainView = getMainView();
|
||||||
|
@ -362,9 +366,12 @@ public class MapRouteInfoMenuFragment extends ContextMenuFragment {
|
||||||
if (mapActivity == null || mainView == null || view == null) {
|
if (mapActivity == null || mainView == null || view == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
boolean publicTransportMode = isPublicTransportMode();
|
||||||
ProgressBar progressBar = (ProgressBar) mainView.findViewById(R.id.progress_bar);
|
ProgressBar progressBar = (ProgressBar) mainView.findViewById(R.id.progress_bar);
|
||||||
if (progressBar != null) {
|
if (progressBar != null) {
|
||||||
|
if (progress == 0) {
|
||||||
|
progressBar.setIndeterminate(publicTransportMode);
|
||||||
|
}
|
||||||
if (progressBar.getVisibility() != View.VISIBLE) {
|
if (progressBar.getVisibility() != View.VISIBLE) {
|
||||||
progressBar.setVisibility(View.VISIBLE);
|
progressBar.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
@ -372,8 +379,9 @@ public class MapRouteInfoMenuFragment extends ContextMenuFragment {
|
||||||
}
|
}
|
||||||
ProgressBar progressBarButton = (ProgressBar) view.findViewById(R.id.progress_bar_button);
|
ProgressBar progressBarButton = (ProgressBar) view.findViewById(R.id.progress_bar_button);
|
||||||
if (progressBarButton != null) {
|
if (progressBarButton != null) {
|
||||||
if (progressBarButton.getVisibility() != View.VISIBLE) {
|
int visibility = publicTransportMode ? View.GONE : View.VISIBLE;
|
||||||
progressBarButton.setVisibility(View.VISIBLE);
|
if (progressBarButton.getVisibility() != visibility) {
|
||||||
|
progressBarButton.setVisibility(visibility);
|
||||||
}
|
}
|
||||||
progressBarButton.setProgress(progress);
|
progressBarButton.setProgress(progress);
|
||||||
}
|
}
|
||||||
|
@ -398,31 +406,8 @@ public class MapRouteInfoMenuFragment extends ContextMenuFragment {
|
||||||
if (progressBarButton != null) {
|
if (progressBarButton != null) {
|
||||||
progressBarButton.setVisibility(View.GONE);
|
progressBarButton.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
int color = isNightMode() ? R.color.main_font_dark : R.color.card_and_list_background_light;
|
TextViewExProgress textViewExProgress = (TextViewExProgress) view.findViewById(R.id.start_button_descr);
|
||||||
((TextView) view.findViewById(R.id.start_button_descr)).setTextColor(ContextCompat.getColor(mapActivity, color));
|
textViewExProgress.percent = 1;
|
||||||
}
|
|
||||||
|
|
||||||
public void updateControlButtons() {
|
|
||||||
OsmandApplication app = getMyApplication();
|
|
||||||
MapActivity mapActivity = getMapActivity();
|
|
||||||
View view = getView();
|
|
||||||
if (app != null && mapActivity != null && view != null) {
|
|
||||||
TextViewExProgress textViewExProgress = (TextViewExProgress) view.findViewById(R.id.start_button_descr);
|
|
||||||
textViewExProgress.color1 = ContextCompat.getColor(mapActivity, isNightMode() ? R.color.main_font_dark : R.color.card_and_list_background_light);
|
|
||||||
textViewExProgress.color2 = ContextCompat.getColor(mapActivity, R.color.description_font_and_bottom_sheet_icons);
|
|
||||||
|
|
||||||
boolean publicTransportMode = app.getRoutingHelper().getAppMode() == ApplicationMode.PUBLIC_TRANSPORT;
|
|
||||||
if (menu != null && menu.isRouteCalculated()) {
|
|
||||||
if (publicTransportMode) {
|
|
||||||
AndroidUtils.setBackground(app, view.findViewById(R.id.start_button), isNightMode(), R.color.card_and_list_background_light, R.color.card_and_list_background_dark);
|
|
||||||
textViewExProgress.color1 = ContextCompat.getColor(mapActivity, isNightMode() ? R.color.active_buttons_and_links_dark : R.color.active_buttons_and_links_light);
|
|
||||||
} else {
|
|
||||||
AndroidUtils.setBackground(app, view.findViewById(R.id.start_button), isNightMode(), R.color.active_buttons_and_links_light, R.color.active_buttons_and_links_dark);
|
|
||||||
textViewExProgress.color1 = ContextCompat.getColor(mapActivity, isNightMode() ? R.color.main_font_dark : R.color.card_and_list_background_light);
|
|
||||||
}
|
|
||||||
textViewExProgress.percent = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void show(MapActivity mapActivity) {
|
public void show(MapActivity mapActivity) {
|
||||||
|
@ -495,8 +480,6 @@ public class MapRouteInfoMenuFragment extends ContextMenuFragment {
|
||||||
|
|
||||||
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));
|
setupRouteCalculationButtonProgressBar((ProgressBar) view.findViewById(R.id.progress_bar_button));
|
||||||
|
|
||||||
updateControlButtons();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean showInstance(final MapActivity mapActivity, int initialMenuState) {
|
public static boolean showInstance(final MapActivity mapActivity, int initialMenuState) {
|
||||||
|
@ -540,6 +523,7 @@ public class MapRouteInfoMenuFragment extends ContextMenuFragment {
|
||||||
int bgColor = ContextCompat.getColor(mapActivity, isNightMode() ? R.color.activity_background_dark : R.color.activity_background_light);
|
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_buttons_and_links_dark : R.color.active_buttons_and_links_light);
|
int progressColor = ContextCompat.getColor(mapActivity, isNightMode() ? R.color.active_buttons_and_links_dark : R.color.active_buttons_and_links_light);
|
||||||
pb.setProgressDrawable(AndroidUtils.createProgressDrawable(bgColor, progressColor));
|
pb.setProgressDrawable(AndroidUtils.createProgressDrawable(bgColor, progressColor));
|
||||||
|
pb.getIndeterminateDrawable().setColorFilter(progressColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue