mirror of
https://codeberg.org/comaps/comaps
synced 2026-01-05 20:23:48 +00:00
Compare commits
4 Commits
matheusgom
...
matheusgom
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
505a5c20de | ||
|
|
f5af8c8cd5 | ||
|
|
10398acedb | ||
|
|
38fc18b6e6 |
@@ -114,6 +114,7 @@ public final class CarAppSession extends Session implements DefaultLifecycleObse
|
||||
public void onCreate(@NonNull LifecycleOwner owner)
|
||||
{
|
||||
Logger.d(TAG);
|
||||
Framework.nativeSetCarScreenMode(true);
|
||||
mSensorsManager = new CarSensorsManager(getCarContext());
|
||||
mDisplayManager = MwmApplication.from(getCarContext()).getDisplayManager();
|
||||
mDisplayManager.addListener(DisplayType.Car, this);
|
||||
@@ -159,6 +160,7 @@ public final class CarAppSession extends Session implements DefaultLifecycleObse
|
||||
public void onDestroy(@NonNull LifecycleOwner owner)
|
||||
{
|
||||
mDisplayManager.removeListener(DisplayType.Car);
|
||||
Framework.nativeSetCarScreenMode(false);
|
||||
}
|
||||
|
||||
private void init()
|
||||
|
||||
@@ -1490,6 +1490,12 @@ JNIEXPORT void JNICALL Java_app_organicmaps_sdk_Framework_nativeSet3dMode(JNIEnv
|
||||
g_framework->Set3dMode(allow3d, allow3dBuildings);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_app_organicmaps_sdk_Framework_nativeSetCarScreenMode(JNIEnv * env, jclass, jboolean enabled)
|
||||
{
|
||||
if (g_framework)
|
||||
frm()->SetCarScreenMode(static_cast<bool>(enabled));
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_app_organicmaps_sdk_Framework_nativeGet3dMode(JNIEnv * env, jclass, jobject result)
|
||||
{
|
||||
bool enabled;
|
||||
|
||||
@@ -280,6 +280,8 @@ public class Framework
|
||||
|
||||
public static native void nativeSet3dMode(boolean allow3d, boolean allow3dBuildings);
|
||||
|
||||
public static native void nativeSetCarScreenMode(boolean enabled);
|
||||
|
||||
public static native boolean nativeGetAutoZoomEnabled();
|
||||
|
||||
public static native void nativeSetAutoZoomEnabled(boolean enabled);
|
||||
|
||||
@@ -59,6 +59,7 @@ NS_SWIFT_NAME(FrameworkHelper)
|
||||
+ (void)updatePlacePageData;
|
||||
+ (void)updateAfterDeleteBookmark;
|
||||
+ (int)currentZoomLevel;
|
||||
+ (void)setCarScreenMode:(BOOL)enabled;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@@ -241,4 +241,8 @@
|
||||
return [[ElevationProfileData alloc] initWithElevationInfo:GetFramework().GetTrackRecordingElevationInfo()];
|
||||
}
|
||||
|
||||
+ (void)setCarScreenMode:(BOOL)enabled {
|
||||
GetFramework().SetCarScreenMode(enabled);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -62,6 +62,8 @@ final class CarPlayService: NSObject {
|
||||
toWindow: window,
|
||||
isCarplayActivated: true
|
||||
)
|
||||
|
||||
FrameworkHelper.setCarScreenMode(true)
|
||||
}
|
||||
|
||||
private var savedInterfaceController: CPInterfaceController?
|
||||
@@ -126,6 +128,7 @@ final class CarPlayService: NSObject {
|
||||
isCarplayActivated: false
|
||||
)
|
||||
}
|
||||
FrameworkHelper.setCarScreenMode(false)
|
||||
}
|
||||
|
||||
@objc func destroy() {
|
||||
|
||||
@@ -43,8 +43,8 @@ final class InfoItemView: UIView {
|
||||
addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(onInfoLabelTap)))
|
||||
addGestureRecognizer(UILongPressGestureRecognizer(target: self, action: #selector(onInfoLabelLongPress(_:))))
|
||||
|
||||
infoLabel.lineBreakMode = .byWordWrapping
|
||||
infoLabel.numberOfLines = 0
|
||||
infoLabel.lineBreakMode = .byTruncatingTail
|
||||
infoLabel.numberOfLines = 1
|
||||
infoLabel.allowsDefaultTighteningForTruncation = true
|
||||
infoLabel.isUserInteractionEnabled = false
|
||||
|
||||
@@ -66,17 +66,17 @@ final class InfoItemView: UIView {
|
||||
accessoryButton.translatesAutoresizingMaskIntoConstraints = false
|
||||
|
||||
NSLayoutConstraint.activate([
|
||||
heightAnchor.constraint(greaterThanOrEqualToConstant: Constants.viewHeight),
|
||||
heightAnchor.constraint(equalToConstant: Constants.viewHeight),
|
||||
|
||||
iconButton.leadingAnchor.constraint(equalTo: leadingAnchor),
|
||||
iconButton.centerYAnchor.constraint(equalTo: centerYAnchor),
|
||||
iconButton.widthAnchor.constraint(equalToConstant: Constants.iconButtonSize),
|
||||
iconButton.topAnchor.constraint(greaterThanOrEqualTo: topAnchor),
|
||||
iconButton.bottomAnchor.constraint(lessThanOrEqualTo: bottomAnchor),
|
||||
iconButton.topAnchor.constraint(equalTo: topAnchor),
|
||||
iconButton.bottomAnchor.constraint(equalTo: bottomAnchor),
|
||||
|
||||
infoLabel.leadingAnchor.constraint(equalTo: iconButton.trailingAnchor),
|
||||
infoLabel.topAnchor.constraint(equalTo: topAnchor, constant: Constants.infoLabelTopBottomSpacing),
|
||||
infoLabel.bottomAnchor.constraint(equalTo: bottomAnchor, constant: -Constants.infoLabelTopBottomSpacing),
|
||||
infoLabel.topAnchor.constraint(equalTo: topAnchor),
|
||||
infoLabel.bottomAnchor.constraint(equalTo: bottomAnchor),
|
||||
infoLabel.trailingAnchor.constraint(equalTo: accessoryButton.leadingAnchor),
|
||||
|
||||
accessoryButton.trailingAnchor.constraint(equalTo: trailingAnchor),
|
||||
|
||||
@@ -175,6 +175,16 @@ void Framework::OnLocationUpdate(GpsInfo const & info)
|
||||
#endif
|
||||
|
||||
m_routingManager.OnLocationUpdate(rInfo);
|
||||
|
||||
bool const isRoutingActive = m_routingManager.IsRoutingActive();
|
||||
|
||||
if (m_wasRoutingActive != isRoutingActive)
|
||||
{
|
||||
m_wasRoutingActive = isRoutingActive;
|
||||
|
||||
/// State changed (Started OR Stopped) -> Refresh 3D Buildings
|
||||
Refresh3dMode();
|
||||
}
|
||||
}
|
||||
|
||||
void Framework::OnCompassUpdate(CompassInfo const & info)
|
||||
@@ -2424,6 +2434,10 @@ void Framework::Allow3dMode(bool allow3d, bool allow3dBuildings)
|
||||
if (!m_powerManager.IsFacilityEnabled(power_management::Facility::Buildings3d))
|
||||
allow3dBuildings = false;
|
||||
|
||||
/// If we are in CarPlay/AA mode and Navigation is active, force 3D buildings off.
|
||||
if (m_isCarScreenMode && m_routingManager.IsRoutingActive())
|
||||
allow3dBuildings = false;
|
||||
|
||||
m_drapeEngine->Allow3dMode(allow3d, allow3dBuildings);
|
||||
}
|
||||
|
||||
@@ -3224,6 +3238,7 @@ void Framework::OnRouteFollow(routing::RouterType type)
|
||||
// GetRoutingSettings(type).m_matchRoute to the FollowRoute() instead of |isPedestrianRoute|.
|
||||
// |isArrowGlued| parameter fully corresponds to |m_matchRoute| in RoutingSettings.
|
||||
m_drapeEngine->FollowRoute(scale, scale3d, enableAutoZoom, !isPedestrianRoute /* isArrowGlued */);
|
||||
Refresh3dMode();
|
||||
}
|
||||
|
||||
// RoutingManager::Delegate
|
||||
@@ -3292,3 +3307,25 @@ void Framework::OnPowerSchemeChanged(power_management::Scheme const actualScheme
|
||||
if (actualScheme == power_management::Scheme::EconomyMaximum && GetTrafficManager().IsEnabled())
|
||||
GetTrafficManager().SetEnabled(false);
|
||||
}
|
||||
|
||||
void Framework::SetCarScreenMode(bool enabled)
|
||||
{
|
||||
if (m_isCarScreenMode == enabled)
|
||||
return;
|
||||
|
||||
m_isCarScreenMode = enabled;
|
||||
|
||||
bool allow3d, allow3dBuildings;
|
||||
Load3dMode(allow3d, allow3dBuildings);
|
||||
Allow3dMode(allow3d, allow3dBuildings);
|
||||
}
|
||||
|
||||
void Framework::Refresh3dMode()
|
||||
{
|
||||
bool allow3d = true;
|
||||
bool allow3dBuildings = true;
|
||||
|
||||
/// Load User Preferences and apply logic
|
||||
Load3dMode(allow3d, allow3dBuildings);
|
||||
Allow3dMode(allow3d, allow3dBuildings);
|
||||
}
|
||||
|
||||
@@ -769,4 +769,13 @@ public:
|
||||
// PowerManager::Subscriber override.
|
||||
void OnPowerFacilityChanged(power_management::Facility const facility, bool enabled) override;
|
||||
void OnPowerSchemeChanged(power_management::Scheme const actualScheme) override;
|
||||
|
||||
public:
|
||||
/// Call this from iOS/Android when CarPlay/AA session starts/ends
|
||||
void SetCarScreenMode(bool enabled);
|
||||
bool m_isCarScreenMode = false;
|
||||
|
||||
private:
|
||||
void Refresh3dMode();
|
||||
bool m_wasRoutingActive = false;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user