[android-auto] Nit fixes

Signed-off-by: Andrew Shkrob <andrew.shkrob.social@yandex.by>
This commit is contained in:
Andrew Shkrob 2022-12-11 14:43:52 +01:00
parent e0cb3e4bdf
commit 90662aed81
6 changed files with 14 additions and 28 deletions

View file

@ -726,7 +726,7 @@
android:permission="android.permission.BIND_JOB_SERVICE"
android:exported="false"/>
<service
android:name=".car.NavigationCarAppService"
android:name="app.organicmaps.car.NavigationCarAppService"
android:exported="true">
<intent-filter>
<action android:name="androidx.car.app.CarAppService" />

View file

@ -28,7 +28,6 @@ public final class NavigationSession extends Session implements DefaultLifecycle
{
private static final String TAG = NavigationSession.class.getSimpleName();
private OMController mMapController;
boolean mInitFailed = false;

View file

@ -76,6 +76,7 @@ public class SurfaceRenderer implements DefaultLifecycleObserver, SurfaceCallbac
Log.d(TAG, "onCreate");
mCarContext.getCarService(AppManager.class).setSurfaceCallback(this);
// TODO: Properly process deep links from other apps on AA.
boolean launchByDeepLink = false;
mMap.onCreate(launchByDeepLink);
}
@ -145,16 +146,12 @@ public class SurfaceRenderer implements DefaultLifecycleObserver, SurfaceCallbac
{
// If a focal point value is negative, use the center point of the visible area.
if (x < 0)
{
x = visibleArea.centerX();
}
if (y < 0)
{
y = visibleArea.centerY();
}
}
boolean animated = Float.compare(scaleFactor, 2f) == 0;
final boolean animated = Float.compare(scaleFactor, 2f) == 0;
Map.onScale(scaleFactor, x, y, animated);
}

View file

@ -34,19 +34,17 @@ public final class UiHelpers
public static Row createSharedPrefsCheckbox(
@NonNull CarContext context, @StringRes int titleRes, PrefsGetter getter, PrefsSetter setter)
{
final boolean getterValue = getter.get();
if (mCheckboxIcon == null || mCheckboxSelectedIcon == null)
initCheckboxIcons(context);
Row.Builder builder = new Row.Builder();
builder.setTitle(context.getString(titleRes));
builder.setOnClickListener(() -> {
setter.set(!getter.get());
setter.set(!getterValue);
context.getCarService(ScreenManager.class).getTop().invalidate();
});
if (getter.get())
builder.setImage(mCheckboxSelectedIcon);
else
builder.setImage(mCheckboxIcon);
builder.setImage(getterValue ? mCheckboxSelectedIcon : mCheckboxIcon);
return builder.build();
}
@ -65,10 +63,7 @@ public final class UiHelpers
RoutingOptions.addOption(roadType);
context.getCarService(ScreenManager.class).getTop().invalidate();
});
if (RoutingOptions.hasOption(roadType))
builder.setImage(mCheckboxSelectedIcon);
else
builder.setImage(mCheckboxIcon);
builder.setImage(RoutingOptions.hasOption(roadType) ? mCheckboxSelectedIcon : mCheckboxIcon);
return builder.build();
}

View file

@ -35,7 +35,8 @@ public class BookmarksScreen extends MapScreen
public BookmarksScreen(@NonNull CarContext carContext, @NonNull OMController mapController)
{
super(carContext, mapController);
MAX_CATEGORIES_SIZE = getCarContext().getCarService(ConstraintManager.class).getContentLimit(ConstraintManager.CONTENT_LIMIT_TYPE_LIST);
final ConstraintManager constraintManager = getCarContext().getCarService(ConstraintManager.class);
MAX_CATEGORIES_SIZE = constraintManager.getContentLimit(ConstraintManager.CONTENT_LIMIT_TYPE_LIST);
}
private BookmarksScreen(@NonNull CarContext carContext, @NonNull OMController mapController, @NonNull BookmarkCategory bookmarkCategory)
@ -48,15 +49,11 @@ public class BookmarksScreen extends MapScreen
@Override
public Template onGetTemplate()
{
MapTemplate.Builder builder = new MapTemplate.Builder();
builder.setHeader(createHeader());
builder.setMapController(getMapController());
builder.setActionStrip(getActionStrip());
if (mBookmarkCategory == null)
builder.setItemList(createBookmarkCategoriesList());
else
builder.setItemList(createBookmarksList());
builder.setItemList(mBookmarkCategory == null ? createBookmarkCategoriesList() : createBookmarksList());
return builder.build();
}
@ -65,10 +62,7 @@ public class BookmarksScreen extends MapScreen
{
Header.Builder builder = new Header.Builder();
builder.setStartHeaderAction(Action.BACK);
if (mBookmarkCategory == null)
builder.setTitle(getCarContext().getString(R.string.bookmarks));
else
builder.setTitle(mBookmarkCategory.getName());
builder.setTitle(mBookmarkCategory == null ? getCarContext().getString(R.string.bookmarks) : mBookmarkCategory.getName());
return builder.build();
}

View file

@ -24,7 +24,8 @@ public class SearchScreen extends Screen implements SearchTemplate.SearchCallbac
public SearchScreen(@NonNull CarContext carContext)
{
super(carContext);
MAX_RESULTS_SIZE = getCarContext().getCarService(ConstraintManager.class).getContentLimit(ConstraintManager.CONTENT_LIMIT_TYPE_LIST);
final ConstraintManager constraintManager = getCarContext().getCarService(ConstraintManager.class);
MAX_RESULTS_SIZE = constraintManager.getContentLimit(ConstraintManager.CONTENT_LIMIT_TYPE_LIST);
}
@NonNull