Revert adding a setting to always show the next turn, set up the routing session to know when the device is in landscape position, and if it is, don't show the next turn (unless the old logic applies), but show it by default.

Signed-off-by: Jeremiah Miller <jmil@tuta.io>
This commit is contained in:
Jeremiah Miller 2024-01-18 12:32:34 -07:00
parent fd79f66a3c
commit 6bc1c28a7f
20 changed files with 30 additions and 97 deletions

View file

@ -1144,6 +1144,12 @@ Java_app_organicmaps_Framework_nativeChangeWritableDir(JNIEnv * env, jclass, jst
g_framework->AddLocalMaps();
}
JNIEXPORT void JNICALL
Java_app_organicmaps_Framework_nativeSetIsLandscape(JNIEnv * env, jclass, jboolean isLandscape)
{
return frm()->GetRoutingManager().SetIsLandscape(static_cast<bool>(isLandscape));
}
JNIEXPORT jboolean JNICALL
Java_app_organicmaps_Framework_nativeIsRoutingActive(JNIEnv * env, jclass)
{
@ -1644,14 +1650,6 @@ Java_app_organicmaps_Framework_nativeSetAutoZoomEnabled(JNIEnv * env, jclass, jb
frm()->AllowAutoZoom(autoZoomEnabled);
}
JNIEXPORT void JNICALL
Java_app_organicmaps_Framework_nativeSetAlwaysShowNextTurnEnabled(JNIEnv * env, jclass, jboolean enabled)
{
bool const alwaysShowNextTurnEnabled = static_cast<bool>(enabled);
frm()->SaveAlwaysShowNextTurn(alwaysShowNextTurnEnabled);
frm()->AllowAlwaysShowNextTurn(alwaysShowNextTurnEnabled);
}
JNIEXPORT void JNICALL
Java_app_organicmaps_Framework_nativeSetTransitSchemeEnabled(JNIEnv * env, jclass, jboolean enabled)
{
@ -1702,12 +1700,6 @@ Java_app_organicmaps_Framework_nativeGetAutoZoomEnabled(JNIEnv *, jclass)
return frm()->LoadAutoZoom();
}
JNIEXPORT jboolean JNICALL
Java_app_organicmaps_Framework_nativeGetAlwaysShowNextTurnEnabled(JNIEnv *, jclass)
{
return frm()->LoadAlwaysShowNextTurn();
}
// static void nativeZoomToPoint(double lat, double lon, int zoom, boolean animate);
JNIEXPORT void JNICALL
Java_app_organicmaps_Framework_nativeZoomToPoint(JNIEnv * env, jclass, jdouble lat, jdouble lon, jint zoom, jboolean animate)

View file

@ -255,6 +255,8 @@ public class Framework
public static native void nativeChangeWritableDir(String newPath);
// Routing.
public static native void nativeSetIsLandscape(boolean isLandscape);
public static native boolean nativeIsRoutingActive();
public static native boolean nativeIsRouteBuilt();
@ -357,10 +359,6 @@ public class Framework
public static native void nativeSetAutoZoomEnabled(boolean enabled);
public static native boolean nativeGetAlwaysShowNextTurnEnabled();
public static native void nativeSetAlwaysShowNextTurnEnabled(boolean enabled);
public static native void nativeSetTransitSchemeEnabled(boolean enabled);
public static native void nativeSaveSettingSchemeEnabled(boolean enabled);

View file

@ -448,7 +448,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
final boolean newUiModeIsCarConnected = newUiMode == Configuration.UI_MODE_TYPE_CAR;
final boolean newUiModeIsCarDisconnected = mLastUiMode == Configuration.UI_MODE_TYPE_CAR && newUiMode == Configuration.UI_MODE_TYPE_NORMAL;
mLastUiMode = newUiMode;
Framework.nativeSetIsLandscape(newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE);
if (newUiModeIsCarConnected || newUiModeIsCarDisconnected)
return;
recreate();
@ -568,6 +568,8 @@ public class MwmActivity extends BaseMwmFragmentActivity
initMainMenu();
initOnmapDownloader();
initPositionChooser();
Framework.nativeSetIsLandscape(getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE);
}
private void initPositionChooser()

View file

@ -268,7 +268,6 @@ public class SettingsPrefsFragment extends BaseXmlSettingsFragment
init3dModePrefsCallbacks();
initPerspectivePrefsCallbacks();
initAutoZoomPrefsCallbacks();
initAlwaysShowNextTurnPrefsCallbacks();
initLoggingEnabledPrefsCallbacks();
initEmulationBadStorage();
initUseMobileDataPrefsCallbacks();
@ -519,23 +518,6 @@ public class SettingsPrefsFragment extends BaseXmlSettingsFragment
});
}
private void initAlwaysShowNextTurnPrefsCallbacks()
{
final TwoStatePreference pref = getPreference(getString(R.string.pref_always_show_next_turn));
boolean alwaysShowNextTurnEnabled = Framework.nativeGetAlwaysShowNextTurnEnabled();
pref.setChecked(alwaysShowNextTurnEnabled);
pref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener()
{
@Override
public boolean onPreferenceChange(Preference preference, Object newValue)
{
Framework.nativeSetAlwaysShowNextTurnEnabled((Boolean)newValue);
return true;
}
});
}
private void initPlayServicesPrefsCallbacks()
{
final Preference pref = findPreference(getString(R.string.pref_play_services));

View file

@ -30,7 +30,6 @@
<string name="pref_3d_buildings" translatable="false">3DBuildings</string>
<string name="pref_osm_profile" translatable="false">Osm profile</string>
<string name="pref_auto_zoom" translatable="false">AutoZoom</string>
<string name="pref_always_show_next_turn" translatable="false">AlwaysShowNextTurn</string>
<string name="pref_large_fonts_size" translatable="false">LargeFontSize</string>
<string name="pref_use_mobile_data" translatable="false">UseMobileData</string>
<string name="pref_settings_general" translatable="false">GeneralSettings</string>

View file

@ -239,7 +239,6 @@
<!-- Settings «Route» category: «Tts unavailable» subtitle -->
<string name="pref_tts_unavailable">Not Available</string>
<string name="pref_map_auto_zoom">Auto zoom</string>
<string name="pref_map_always_show_next_turn">Always show next turn</string>
<string name="duration_disabled">Off</string>
<string name="duration_1_hour">1 hour</string>
<string name="duration_2_hours">2 hours</string>

View file

@ -120,17 +120,12 @@
android:title="@string/pref_map_auto_zoom"
app:singleLineTitle="false"
android:order="3"/>
<SwitchPreferenceCompat
android:key="@string/pref_always_show_next_turn"
android:title="@string/pref_map_always_show_next_turn"
app:singleLineTitle="false"
android:order="4"/>
<androidx.preference.PreferenceScreen
android:key="@string/pref_tts_screen"
android:title="@string/pref_tts_enable_title"
app:singleLineTitle="false"
android:persistent="false"
android:order="5">
android:order="4">
<SwitchPreferenceCompat
android:key="@string/pref_tts_enabled"
android:title="@string/pref_tts_enable_title"

View file

@ -5739,10 +5739,6 @@
zh-Hans = 自动缩放
zh-Hant = 自動縮放
[pref_map_always_show_next_turn]
tags = android,ios
en = Always show next turn
[duration_disabled]
tags = android,ios
en = Off

View file

@ -354,6 +354,8 @@ void setShowLocationAlert(BOOL needShow) {
- (void)orientationChanged
{
GetFramework().GetRoutingManager().SetIsLandscape((CLDeviceOrientation)UIDevice.currentDevice.orientation == landscapeLeft
|| (CLDeviceOrientation)UIDevice.currentDevice.orientation == landscapeRight);
self.locationManager.headingOrientation = (CLDeviceOrientation)UIDevice.currentDevice.orientation;
}

View file

@ -252,8 +252,6 @@
"pref_map_auto_zoom" = "Auto zoom";
"pref_map_always_show_next_turn" = "Always show next turn";
"duration_disabled" = "Off";
"duration_1_hour" = "1 hour";

View file

@ -252,8 +252,6 @@
"pref_map_auto_zoom" = "Auto zoom";
"pref_map_always_show_next_turn" = "Always show next turn";
"duration_disabled" = "Off";
"duration_1_hour" = "1 hour";

View file

@ -59,6 +59,8 @@ class AvailableArea: UIView {
let orientation = UIDevice.current.orientation
guard !orientation.isFlat && orientation != .portraitUpsideDown else { return }
self.orientation = orientation
GetFramework().GetRoutingManager().SetIsLandscape(orientation == landscapeLeft
|| orientation == landscapeRight);
}
}

View file

@ -29,7 +29,10 @@ class DirectionView: SolidTouchView {
override func layoutSubviews() {
var textAlignment = NSTextAlignment.center
if UIDevice.current.orientation == .landscapeLeft || UIDevice.current.orientation == .landscapeRight {
GetFramework().GetRoutingManager().SetIsLandscape(true);
textAlignment = alternative(iPhone: .left, iPad: .center)
} else {
GetFramework().GetRoutingManager().SetIsLandscape(false);
}
titleLabel.textAlignment = textAlignment
typeLabel.textAlignment = textAlignment

View file

@ -27,7 +27,6 @@ using namespace power_management;
@property(weak, nonatomic) IBOutlet SettingsTableViewLinkCell *nightModeCell;
@property(weak, nonatomic) IBOutlet SettingsTableViewSwitchCell *perspectiveViewCell;
@property(weak, nonatomic) IBOutlet SettingsTableViewSwitchCell *autoZoomCell;
@property(weak, nonatomic) IBOutlet SettingsTableViewSwitchCell *alwaysShowNextTurnCell;
@property(weak, nonatomic) IBOutlet SettingsTableViewLinkCell *voiceInstructionsCell;
@property(weak, nonatomic) IBOutlet SettingsTableViewLinkCell *drivingOptionsCell;
@ -204,7 +203,6 @@ using namespace power_management;
[self.perspectiveViewCell configWithDelegate:self title:L(@"pref_map_3d_title") isOn:on];
[self.autoZoomCell configWithDelegate:self title:L(@"pref_map_auto_zoom") isOn:GetFramework().LoadAutoZoom()];
[self.alwaysShowNextTurnCell configWithDelegate:self title:L(@"pref_map_always_show_next_turn") isOn:GetFramework().LoadAlwaysShowNextTurn()];
NSString *ttsEnabledString = [MWMTextToSpeech isTTSEnabled] ? L(@"on") : L(@"off");
[self.voiceInstructionsCell configWithTitle:L(@"pref_tts_enable_title") info:ttsEnabledString];
@ -243,10 +241,6 @@ using namespace power_management;
auto &f = GetFramework();
f.AllowAutoZoom(value);
f.SaveAutoZoom(value);
} else if (cell == self.alwaysShowNextTurnCell) {
auto &f = GetFramework();
f.AllowAlwaysShowNextTurn(value);
f.SaveAlwaysShowNextTurn(value);
}
}

View file

@ -594,9 +594,6 @@
<connections>
<outlet property="autoDownloadCell" destination="eE4-OC-9uX" id="c2A-dX-VMy"/>
<outlet property="autoZoomCell" destination="veW-Fm-2Hl" id="zbI-m2-mDP"/>
<!--TODO add alwaysShowNextTurnCell. I don't have xcode, so I don't know how without messing things up
<outlet property="alwaysShowNextTurnCell" destination="veW-Fm-2Hl" id="zbI-m2-mDP"/>
-->
<outlet property="compassCalibrationCell" destination="P5e-67-f4k" id="KcB-EC-S2y"/>
<outlet property="drivingOptionsCell" destination="KrE-Sc-fI1" id="XOl-eI-xJX"/>
<outlet property="fontScaleCell" destination="pri-6G-9Zb" id="rHJ-ZT-lwM"/>

View file

@ -98,7 +98,6 @@ char const kMapStyleKey[] = "MapStyleKeyV1";
char const kAllow3dKey[] = "Allow3d";
char const kAllow3dBuildingsKey[] = "Buildings3d";
char const kAllowAutoZoom[] = "AutoZoom";
char const kAllowAlwaysShowNextTurn[] = "AlwaysShowNextTurn";
char const kTrafficEnabledKey[] = "TrafficEnabled";
char const kTransitSchemeEnabledKey[] = "TransitSchemeEnabled";
char const kIsolinesEnabledKey[] = "IsolinesEnabled";
@ -2468,24 +2467,6 @@ void Framework::SaveAutoZoom(bool allowAutoZoom)
settings::Set(kAllowAutoZoom, allowAutoZoom);
}
bool Framework::LoadAlwaysShowNextTurn()
{
bool allowAlwaysShowNextTurn;
if (!settings::Get(kAllowAlwaysShowNextTurn, allowAlwaysShowNextTurn))
allowAlwaysShowNextTurn = true;
return allowAlwaysShowNextTurn;
}
void Framework::AllowAlwaysShowNextTurn(bool allowAlwaysShowNextTurn)
{
m_routingManager.SetAlwaysShowNextTurn(allowAlwaysShowNextTurn);
}
void Framework::SaveAlwaysShowNextTurn(bool allowAlwaysShowNextTurn)
{
settings::Set(kAllowAlwaysShowNextTurn, allowAlwaysShowNextTurn);
}
bool Framework::LoadTransitSchemeEnabled()
{
bool enabled;

View file

@ -681,10 +681,6 @@ public:
void AllowAutoZoom(bool allowAutoZoom);
void SaveAutoZoom(bool allowAutoZoom);
bool LoadAlwaysShowNextTurn();
void AllowAlwaysShowNextTurn(bool allowAlwaysShowNextTurn);
void SaveAlwaysShowNextTurn(bool allowAlwaysShowNextTurn);
TrafficManager & GetTrafficManager();
TransitReadManager & GetTransitManager();

View file

@ -260,9 +260,9 @@ public:
m_routingSession.SetTurnNotificationsUnits(units);
}
void SetAlwaysShowNextTurn(bool alwaysShowNextTurn)
void SetIsLandscape(bool isLandscape)
{
m_routingSession.SetAlwaysShowNextTurn(alwaysShowNextTurn);
m_routingSession.SetIsLandscape(isLandscape);
}
void SetDrapeEngine(ref_ptr<df::DrapeEngine> engine, bool is3dAllowed);

View file

@ -426,24 +426,22 @@ void RoutingSession::GetRouteFollowingInfo(FollowingInfo & info) const
info.m_completionPercent = GetCompletionPercent();
// Lane information and next street name.
if (m_alwaysShowNextTurn
|| distanceToTurnMeters < kShowLanesMinDistInMeters
info.m_lanes.clear();
info.m_displayedStreetName = info.m_targetName;
if (distanceToTurnMeters < kShowLanesMinDistInMeters
|| m_route->GetCurrentTimeToNearestTurnSec() < 60.0)
{
info.m_displayedStreetName = info.m_targetName;
// There are two nested loops below. Outer one is for lanes and inner one (ctor of
// SingleLaneInfo) is
// for each lane's directions. The size of turn.m_lanes is relatively small. Less than 10 in
// most cases.
info.m_lanes.clear();
info.m_lanes.reserve(turn.m_lanes.size());
for (size_t j = 0; j < turn.m_lanes.size(); ++j)
info.m_lanes.emplace_back(turn.m_lanes[j]);
}
else
else if(m_isLandscape)
{
info.m_displayedStreetName = "";
info.m_lanes.clear();
}
// Pedestrian info.
@ -735,10 +733,10 @@ void RoutingSession::SetTurnNotificationsUnits(measurement_utils::Units const un
m_turnNotificationsMgr.SetLengthUnits(units);
}
void RoutingSession::SetAlwaysShowNextTurn(bool alwaysShowNextTurn)
void RoutingSession::SetIsLandscape(bool isLandscape)
{
CHECK_THREAD_CHECKER(m_threadChecker, ());
m_alwaysShowNextTurn = alwaysShowNextTurn;
m_isLandscape = isLandscape;
}

View file

@ -138,12 +138,13 @@ public:
void GenerateNotifications(std::vector<std::string> & notifications);
void EnableTurnNotifications(bool enable);
void SetTurnNotificationsUnits(measurement_utils::Units const units);
void SetAlwaysShowNextTurn(bool alwaysShowNextTurn);
void SetTurnNotificationsLocale(std::string const & locale);
bool AreTurnNotificationsEnabled() const;
std::string GetTurnNotificationsLocale() const;
void SetLocaleWithJsonForTesting(std::string const & json, std::string const & locale);
void SetIsLandscape(bool isLandscape);
void EmitCloseRoutingEvent() const;
void RouteCall(RouteCallback const & callback) const;
@ -209,7 +210,7 @@ private:
m2::PointD m_userCurrentPosition;
bool m_userCurrentPositionValid = false;
bool m_alwaysShowNextTurn = false;
bool m_isLandscape = false;
// Sound turn notification parameters.
turns::sound::NotificationManager m_turnNotificationsMgr;