mirror of
https://codeberg.org/comaps/comaps
synced 2026-01-11 06:44:18 +00:00
Compare commits
2 Commits
jb_dlt_lis
...
jb_spd_st
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0062eb4414 | ||
|
|
c1137bd38a |
@@ -304,8 +304,8 @@ android {
|
||||
"ru",
|
||||
"sl",
|
||||
"sk",
|
||||
"sr-rCyrl",
|
||||
"sr-rLatn",
|
||||
"sr",
|
||||
"b+sr+Latn",
|
||||
"sv",
|
||||
"sw",
|
||||
"ta",
|
||||
|
||||
@@ -1196,7 +1196,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
||||
if (mOnmapDownloader != null)
|
||||
mOnmapDownloader.onResume();
|
||||
|
||||
mNavigationController.refresh();
|
||||
mNavigationController.refresh(getApplicationContext(), Framework.nativeGetRouteFollowingInfo());
|
||||
refreshLightStatusBar();
|
||||
|
||||
MwmApplication.from(this).getSensorHelper().addListener(this);
|
||||
|
||||
@@ -197,8 +197,10 @@ public class BookmarkCategoriesFragment extends BaseMwmRecyclerFragment<Bookmark
|
||||
() -> onShareActionSelected(mSelectedCategory, KmlFileType.Text)));
|
||||
items.add(new MenuBottomSheetItem(R.string.export_file_gpx, R.drawable.ic_file_gpx,
|
||||
() -> onShareActionSelected(mSelectedCategory, KmlFileType.Gpx)));
|
||||
items.add(new MenuBottomSheetItem(R.string.delete, R.drawable.ic_delete,
|
||||
() -> onDeleteActionSelected(mSelectedCategory)));
|
||||
// Disallow deleting the last category
|
||||
if (getAdapter().getBookmarkCategories().size() > 1)
|
||||
items.add(new MenuBottomSheetItem(R.string.delete, R.drawable.ic_delete,
|
||||
() -> onDeleteActionSelected(mSelectedCategory)));
|
||||
}
|
||||
return items;
|
||||
}
|
||||
@@ -295,24 +297,8 @@ public class BookmarkCategoriesFragment extends BaseMwmRecyclerFragment<Bookmark
|
||||
|
||||
private void onDeleteActionSelected(@NonNull BookmarkCategory category)
|
||||
{
|
||||
// Disallow deleting the last category
|
||||
if ((getAdapter().getBookmarkCategories().size() > 1))
|
||||
{
|
||||
BookmarkManager.INSTANCE.deleteCategory(category.getId());
|
||||
getAdapter().notifyDataSetChanged();
|
||||
}
|
||||
else
|
||||
{
|
||||
new MaterialAlertDialogBuilder(requireActivity())
|
||||
.setMessage(R.string.unable_to_delete_list)
|
||||
.setPositiveButton(android.R.string.yes, ((dialog, which) -> {
|
||||
onAddButtonClick();
|
||||
BookmarkManager.INSTANCE.deleteCategory(category.getId());
|
||||
getAdapter().notifyDataSetChanged();
|
||||
}))
|
||||
.setNegativeButton(android.R.string.no,(dialog, which) -> dialog.dismiss())
|
||||
.show();
|
||||
}
|
||||
BookmarkManager.INSTANCE.deleteCategory(category.getId());
|
||||
getAdapter().notifyDataSetChanged();
|
||||
}
|
||||
|
||||
private void onSettingsActionSelected(@NonNull BookmarkCategory category)
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
package app.organicmaps.routing;
|
||||
|
||||
import static androidx.core.content.ContextCompat.getString;
|
||||
import static app.organicmaps.sdk.util.Utils.dimen;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.location.Location;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
@@ -13,6 +16,7 @@ import androidx.core.graphics.Insets;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.core.view.WindowInsetsCompat;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.preference.PreferenceManager;
|
||||
import app.organicmaps.MwmApplication;
|
||||
import app.organicmaps.R;
|
||||
import app.organicmaps.maplayer.MapButtonsViewModel;
|
||||
@@ -58,6 +62,8 @@ public class NavigationController implements TrafficManager.TrafficCallback, Nav
|
||||
|
||||
private final NavMenu mNavMenu;
|
||||
View.OnClickListener mOnSettingsClickListener;
|
||||
private final SharedPreferences sharedPreferences;
|
||||
private boolean speedLimitEnabled;
|
||||
|
||||
private void addWindowsInsets(@NonNull View topFrame)
|
||||
{
|
||||
@@ -72,6 +78,8 @@ public class NavigationController implements TrafficManager.TrafficCallback, Nav
|
||||
public NavigationController(AppCompatActivity activity, View.OnClickListener onSettingsClickListener,
|
||||
NavMenu.OnMenuSizeChangedListener onMenuSizeChangedListener)
|
||||
{
|
||||
sharedPreferences = PreferenceManager.getDefaultSharedPreferences(activity);
|
||||
speedLimitEnabled = sharedPreferences.getBoolean(getString(activity, R.string.pref_speedlimit),true);
|
||||
mMapButtonsViewModel = new ViewModelProvider(activity).get(MapButtonsViewModel.class);
|
||||
|
||||
mFrame = activity.findViewById(R.id.navigation_frame);
|
||||
@@ -97,6 +105,16 @@ public class NavigationController implements TrafficManager.TrafficCallback, Nav
|
||||
|
||||
mSpeedLimit = topFrame.findViewById(R.id.nav_speed_limit);
|
||||
mCurrentSpeed = topFrame.findViewById(R.id.nav_current_speed);
|
||||
if (speedLimitEnabled)
|
||||
{
|
||||
UiUtils.show(mSpeedLimit);
|
||||
UiUtils.show(mCurrentSpeed);
|
||||
}
|
||||
else
|
||||
{
|
||||
UiUtils.hide(mSpeedLimit);
|
||||
UiUtils.hide(mCurrentSpeed);
|
||||
}
|
||||
|
||||
View mTopbar = topFrame.findViewById(R.id.statutbar);
|
||||
ViewCompat.setOnApplyWindowInsetsListener(mTopbar,(v, windowInsets) -> {
|
||||
@@ -136,7 +154,8 @@ public class NavigationController implements TrafficManager.TrafficCallback, Nav
|
||||
|
||||
mLanesView.setLanes(info.lanes);
|
||||
|
||||
updateSpeedWidgets(info);
|
||||
if (speedLimitEnabled)
|
||||
updateSpeedWidgets(info);
|
||||
}
|
||||
|
||||
private void updatePedestrian(@NonNull RoutingInfo info)
|
||||
@@ -144,7 +163,8 @@ public class NavigationController implements TrafficManager.TrafficCallback, Nav
|
||||
mNextTurnDistance.setText(Utils.formatDistance(mFrame.getContext(), info.distToTurn));
|
||||
|
||||
info.pedestrianTurnDirection.setTurnDrawable(mNextTurnImage);
|
||||
updateSpeedWidgets(info);
|
||||
if (speedLimitEnabled)
|
||||
updateSpeedWidgets(info);
|
||||
}
|
||||
|
||||
public void updateNorth()
|
||||
@@ -205,9 +225,21 @@ public class NavigationController implements TrafficManager.TrafficCallback, Nav
|
||||
mNavMenu.collapseNavBottomSheet();
|
||||
}
|
||||
|
||||
public void refresh()
|
||||
public void refresh(Context context, RoutingInfo info)
|
||||
{
|
||||
mNavMenu.refreshTts();
|
||||
mNavMenu.refreshTts();
|
||||
speedLimitEnabled = sharedPreferences.getBoolean(getString(context, R.string.pref_speedlimit),true);
|
||||
if (speedLimitEnabled)
|
||||
{
|
||||
UiUtils.show(mSpeedLimit);
|
||||
UiUtils.show(mCurrentSpeed);
|
||||
updateSpeedWidgets(info);
|
||||
}
|
||||
else
|
||||
{
|
||||
UiUtils.hide(mSpeedLimit);
|
||||
UiUtils.hide(mCurrentSpeed);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
10
android/app/src/main/res/drawable/ic_speed.xml
Normal file
10
android/app/src/main/res/drawable/ic_speed.xml
Normal file
@@ -0,0 +1,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="960"
|
||||
android:viewportHeight="960"
|
||||
android:tint="?iconTint">
|
||||
<path
|
||||
android:pathData="M418,620q24,24 62,23.5t56,-27.5l224,-336 -336,224q-27,18 -28.5,55t22.5,61ZM480,160q59,0 113.5,16.5T696,226l-76,48q-33,-17 -68.5,-25.5T480,240q-133,0 -226.5,93.5T160,560q0,42 11.5,83t32.5,77h552q23,-38 33.5,-79t10.5,-85q0,-36 -8.5,-70T766,420l48,-76q30,47 47.5,100T880,554q1,57 -13,109t-41,99q-11,18 -30,28t-40,10L204,800q-21,0 -40,-10t-30,-28q-26,-45 -40,-95.5T80,560q0,-83 31.5,-155.5t86,-127Q252,223 325,191.5T480,160ZM487,473Z"
|
||||
android:fillColor="#FFFFFF"/>
|
||||
</vector>
|
||||
@@ -926,4 +926,6 @@
|
||||
<string name="download_resources_custom_url_title">Serveur de cartes personnalisé</string>
|
||||
<string name="download_resources_custom_url_error_scheme">Veuillez saisir une URL complète commençant par http:// ou https://</string>
|
||||
<string name="download_resources_custom_url_message">Serveur pour télécharger les cartes. Laissez vide pour utiliser le serveur par défaut CoMaps.</string>
|
||||
<string name="pref_speedlimit_title">Compteur de vitesse</string>
|
||||
<string name="pref_speedlimit_summary">Affichage de la vitesse durant la navigation</string>
|
||||
</resources>
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
<string name="pref_power" translatable="false">pref_power</string>
|
||||
<string name="pref_custom_map_download_url" translatable="false">CustomMapDownloadUrl</string>
|
||||
<string name="pref_advanced" translatable="false">pref_advanced</string>
|
||||
<string name="pref_speedlimit" translatable="false">pref_speedlimit</string>
|
||||
|
||||
<string name="notification_ticker_ltr" translatable="false">%1$s: %2$s</string>
|
||||
<string name="notification_ticker_rtl" translatable="false">%2$s :%1$s</string>
|
||||
|
||||
@@ -975,5 +975,6 @@
|
||||
<string name="download_resources_custom_url_message">Override the default map download server used for map downloads. Leave empty to use CoMaps default server.</string>
|
||||
<string name="download_resources_custom_url_summary_none">Not set</string>
|
||||
<string name="download_resources_custom_url_error_scheme">Please enter a URL starting with http:// or https://</string>
|
||||
<string name="unable_to_delete_list">The app cannot work without at least one list. Do you want to remove it and create a new one?</string>
|
||||
<string name="pref_speedlimit_title">Speed limit</string>
|
||||
<string name="pref_speedlimit_summary">Show speed limit during navigation</string>
|
||||
</resources>
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
<locale android:name="ru" />
|
||||
<locale android:name="sl" />
|
||||
<locale android:name="sk" />
|
||||
<locale android:name="sr-Cyrl" />
|
||||
<locale android:name="sr" />
|
||||
<locale android:name="sr-Latn" />
|
||||
<locale android:name="sv" />
|
||||
<locale android:name="sw" />
|
||||
|
||||
@@ -143,6 +143,14 @@
|
||||
<extra android:name="from" android:value="settings" />
|
||||
</intent>
|
||||
</PreferenceScreen>
|
||||
<SwitchPreferenceCompat
|
||||
android:key="@string/pref_speedlimit"
|
||||
android:title="@string/pref_speedlimit_title"
|
||||
android:summary="@string/pref_speedlimit_summary"
|
||||
android:defaultValue="true"
|
||||
android:widgetLayout="@layout/preference_switch"
|
||||
app:singleLineTitle="true"
|
||||
app:icon="@drawable/ic_speed"/>
|
||||
</androidx.preference.PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
|
||||
Reference in New Issue
Block a user