Add the ability to disable and enable third-party apps from UI

This commit is contained in:
Alex Sytnyk 2018-10-03 11:50:46 +03:00
parent e4c842bd2a
commit 85e201ab02
2 changed files with 19 additions and 2 deletions

View file

@ -1611,6 +1611,11 @@ public class OsmandAidlApi {
return res;
}
public void switchEnabled(@NonNull ConnectedApp app) {
app.enabled = !app.enabled;
saveConnectedApps();
}
boolean isAppEnabled(@NonNull String pack) {
ConnectedApp app = connectedApps.get(pack);
if (app == null) {

View file

@ -49,6 +49,8 @@ public class PluginsActivity extends OsmandListActivity {
Intent intent = new Intent(this, PluginActivity.class);
intent.putExtra(PluginActivity.EXTRA_PLUGIN_ID, ((OsmandPlugin) tag).getId());
startActivity(intent);
} else if (tag instanceof ConnectedApp) {
switchEnabled((ConnectedApp) tag);
}
}
@ -69,6 +71,11 @@ public class PluginsActivity extends OsmandListActivity {
}
}
private void switchEnabled(@NonNull ConnectedApp app) {
getMyApplication().getAidlApi().switchEnabled(app);
getListAdapter().notifyDataSetChanged();
}
protected class PluginsListAdapter extends ArrayAdapter<Object> {
PluginsListAdapter() {
@ -104,10 +111,15 @@ public class PluginsActivity extends OsmandListActivity {
name = app.getName();
pluginDescription.setText(R.string.third_party_application);
pluginLogo.setImageDrawable(app.getIcon());
pluginLogo.setOnClickListener(null);
pluginLogo.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
switchEnabled(app);
}
});
pluginOptions.setVisibility(View.GONE);
pluginOptions.setOnClickListener(null);
view.setTag(null);
view.setTag(app);
} else if (item instanceof OsmandPlugin) {
final OsmandPlugin plugin = (OsmandPlugin) item;
active = plugin.isActive();