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