Fix aidl widget icon crash

This commit is contained in:
Vitaliy 2020-01-20 15:49:32 +02:00
parent 3b428ec681
commit c52c9d2515
3 changed files with 8 additions and 6 deletions

View file

@ -171,7 +171,8 @@ public class ConnectedApp implements Comparable<ConnectedApp> {
if (layer != null) {
TextInfoWidget control = createWidgetControl(mapActivity, widget.getId());
widgetControls.put(widget.getId(), control);
int menuIconId = AndroidUtils.getDrawableId(mapActivity.getMyApplication(), widget.getMenuIconName());
int iconId = AndroidUtils.getDrawableId(mapActivity.getMyApplication(), widget.getMenuIconName());
int menuIconId = iconId != 0 ? iconId : ContextMenuItem.INVALID_ID;
MapWidgetRegistry.MapWidgetRegInfo widgetInfo = layer.registerSideWidget(control, menuIconId,
widget.getMenuTitle(), "aidl_widget_" + widget.getId(), false, widget.getOrder());
if (!mapActivity.getMapLayers().getMapWidgetRegistry().isVisible(widgetInfo.key)) {

View file

@ -40,6 +40,7 @@ import net.osmand.plus.AppInitializer.AppInitializeListener;
import net.osmand.plus.AppInitializer.InitEvents;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.ContextMenuAdapter;
import net.osmand.plus.ContextMenuItem;
import net.osmand.plus.FavouritesDbHelper;
import net.osmand.plus.GPXDatabase.GpxDataItem;
import net.osmand.plus.GpxSelectionHelper;
@ -318,7 +319,8 @@ public class OsmandAidlApi {
ApplicationMode.regWidgetVisibility(widget.getId(), (ApplicationMode[]) null);
TextInfoWidget control = connectedApp.createWidgetControl(mapActivity, widgetId);
connectedApp.getWidgetControls().put(widgetId, control);
int menuIconId = AndroidUtils.getDrawableId(app, widget.getMenuIconName());
int iconId = AndroidUtils.getDrawableId(app, widget.getMenuIconName());
int menuIconId = iconId != 0 ? iconId : ContextMenuItem.INVALID_ID;
MapWidgetRegInfo widgetInfo = layer.registerSideWidget(control,
menuIconId, widget.getMenuTitle(), "aidl_widget_" + widgetId,
false, widget.getOrder());

View file

@ -112,9 +112,8 @@ public class SettingsOsmEditingActivity extends SettingsBaseActivity {
@Override
protected void onPostExecute(OsmBugsUtil.OsmBugResult osmBugResult) {
if (osmBugResult.warning != null) {
Toast.makeText(context, osmBugResult.warning, Toast.LENGTH_LONG).show();
}
String text = osmBugResult.warning != null ? osmBugResult.warning : context.getString(R.string.osm_authorization_success);
Toast.makeText(context, text, Toast.LENGTH_LONG).show();
}
}
}
}