use of net.osmand.plus.OsmandPlugin in project Osmand by osmandapp.
the class ItemViewHolder method getRightButtonAction.
public OnClickListener getRightButtonAction(final IndexItem item, final RightButtonAction clickAction) {
if (clickAction != RightButtonAction.DOWNLOAD) {
return new View.OnClickListener() {
@Override
public void onClick(View v) {
switch(clickAction) {
case ASK_FOR_FULL_VERSION_PURCHASE:
context.getMyApplication().logEvent(context, "in_app_purchase_show_from_wiki_context_menu");
context.purchaseFullVersion();
break;
case ASK_FOR_DEPTH_CONTOURS_PURCHASE:
context.purchaseDepthContours();
break;
case ASK_FOR_SEAMARKS_PLUGIN:
context.startActivity(new Intent(context, context.getMyApplication().getAppCustomization().getPluginsActivity()));
Toast.makeText(context.getApplicationContext(), context.getString(R.string.activate_seamarks_plugin), Toast.LENGTH_SHORT).show();
break;
case ASK_FOR_SRTM_PLUGIN_PURCHASE:
OsmandPlugin plugin = OsmandPlugin.getPlugin(SRTMPlugin.class);
if (plugin == null || plugin.getInstallURL() == null) {
Toast.makeText(context.getApplicationContext(), context.getString(R.string.activate_srtm_plugin), Toast.LENGTH_LONG).show();
} else {
context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(plugin.getInstallURL())));
}
break;
case ASK_FOR_SRTM_PLUGIN_ENABLE:
context.startActivity(new Intent(context, context.getMyApplication().getAppCustomization().getPluginsActivity()));
Toast.makeText(context, context.getString(R.string.activate_srtm_plugin), Toast.LENGTH_SHORT).show();
break;
case DOWNLOAD:
break;
}
}
};
} else {
final boolean isDownloading = context.getDownloadThread().isDownloading(item);
return new View.OnClickListener() {
@Override
public void onClick(View v) {
if (isDownloading) {
if (silentCancelDownload) {
context.getDownloadThread().cancelDownload(item);
} else {
context.makeSureUserCancelDownload(item);
}
} else if (item.isDownloaded() && !item.isOutdated()) {
contextMenu(v, item, item.getRelatedGroup());
} else {
download(item, item.getRelatedGroup());
}
}
};
}
}
use of net.osmand.plus.OsmandPlugin in project Osmand by osmandapp.
the class DownloadActivity method initAppStatusVariables.
public void initAppStatusVariables() {
srtmDisabled = OsmandPlugin.getEnabledPlugin(SRTMPlugin.class) == null;
nauticalPluginDisabled = OsmandPlugin.getEnabledPlugin(NauticalMapsPlugin.class) == null;
freeVersion = Version.isFreeVersion(getMyApplication());
OsmandPlugin srtmPlugin = OsmandPlugin.getPlugin(SRTMPlugin.class);
srtmNeedsInstallation = srtmPlugin == null || srtmPlugin.needsInstallation();
}
use of net.osmand.plus.OsmandPlugin in project Osmand by osmandapp.
the class DashPluginsFragment method addPluginsToLimit.
private void addPluginsToLimit(Iterator<OsmandPlugin> it, int l) {
while (plugins.size() < l && it.hasNext()) {
OsmandPlugin plugin = it.next();
if (plugin instanceof OsmandDevelopmentPlugin) {
continue;
}
plugins.add(plugin);
}
}
use of net.osmand.plus.OsmandPlugin in project Osmand by osmandapp.
the class SettingsActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
((OsmandApplication) getApplication()).applyTheme(this);
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.settings_pref);
PreferenceScreen screen = getPreferenceScreen();
general = (Preference) screen.findPreference("general_settings");
general.setOnPreferenceClickListener(this);
routing = (Preference) screen.findPreference("routing_settings");
routing.setOnPreferenceClickListener(this);
getToolbar().setTitle(Version.getFullVersion(getMyApplication()));
Intent intent = getIntent();
if (intent != null && intent.getIntExtra(INTENT_KEY_SETTINGS_SCREEN, 0) != 0) {
int s = intent.getIntExtra(INTENT_KEY_SETTINGS_SCREEN, 0);
if (s == SCREEN_GENERAL_SETTINGS) {
startActivity(new Intent(this, SettingsGeneralActivity.class));
} else if (s == SCREEN_NAVIGATION_SETTINGS) {
startActivity(new Intent(this, SettingsNavigationActivity.class));
}
}
PreferenceCategory plugins = (PreferenceCategory) screen.findPreference("plugin_settings");
for (OsmandPlugin op : OsmandPlugin.getEnabledPlugins()) {
final Class<? extends Activity> sa = op.getSettingsActivity();
if (sa != null) {
Preference preference = new Preference(this);
preference.setTitle(op.getName());
preference.setKey(op.getId());
preference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
startActivity(new Intent(SettingsActivity.this, sa));
return false;
}
});
plugins.addPreference(preference);
}
}
}
use of net.osmand.plus.OsmandPlugin in project Osmand by osmandapp.
the class DashPluginsFragment method onOpenDash.
@Override
public void onOpenDash() {
View contentView = getView();
LayoutInflater inflater = getActivity().getLayoutInflater();
LinearLayout pluginsContainer = (LinearLayout) contentView.findViewById(R.id.items);
pluginsContainer.removeAllViews();
for (OsmandPlugin p : plugins) {
inflatePluginView(inflater, pluginsContainer, p);
}
}
Aggregations