Bugfix (Two AIDL items in the drawer) #6466

This commit is contained in:
madwasp79 2019-01-28 10:59:39 +02:00
parent 917cd7740d
commit a1116dfe33
2 changed files with 21 additions and 13 deletions

View file

@ -1707,6 +1707,7 @@ public class OsmandAidlApi {
String appPackage = entry.getKey();
for (NavDrawerItem item : entry.getValue()) {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(item.uri));
boolean isCopy = false;
if (intent.resolveActivity(pm) == null) {
intent = pm.getLaunchIntentForPackage(appPackage);
}
@ -1715,18 +1716,25 @@ public class OsmandAidlApi {
intent.addFlags(item.flags);
}
final Intent finalIntent = intent;
adapter.addItem(new ContextMenuItem.ItemBuilder()
.setId(item.getId())
.setTitle(item.name)
.setIcon(getIconId(item.iconName))
.setListener(new ContextMenuAdapter.ItemClickListener() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int position, boolean isChecked, int[] viewCoordinates) {
activity.startActivity(finalIntent);
return true;
}
})
.createItem());
for (String s : adapter.getItemNames()) {
if (item.name.equals(s)) {
isCopy = true;
}
}
if (!isCopy) {
adapter.addItem(new ContextMenuItem.ItemBuilder()
.setId(item.getId())
.setTitle(item.name)
.setIcon(getIconId(item.iconName))
.setListener(new ContextMenuAdapter.ItemClickListener() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int position, boolean isChecked, int[] viewCoordinates) {
activity.startActivity(finalIntent);
return true;
}
})
.createItem());
}
}
}
}

View file

@ -647,7 +647,7 @@ public class OsmandApplication extends MultiDexApplication {
defaultHandler.uncaughtException(thread, ex);
} catch (Exception e) {
// swallow all exceptions
android.util.Log.e(PlatformUtil.TAG, "Exception while handle other exception", e); //$NON-NLS-1$
LOG.error("Exception while handle other exception" + e.getMessage(), e); //$NON-NLS-1$
}
}