Search in sources :

Example 1 with OsmandPlugin

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());
                }
            }
        };
    }
}
Also used : OnClickListener(android.view.View.OnClickListener) Intent(android.content.Intent) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) OsmandPlugin(net.osmand.plus.OsmandPlugin)

Example 2 with OsmandPlugin

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();
}
Also used : OsmandPlugin(net.osmand.plus.OsmandPlugin)

Example 3 with OsmandPlugin

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);
    }
}
Also used : OsmandDevelopmentPlugin(net.osmand.plus.development.OsmandDevelopmentPlugin) OsmandPlugin(net.osmand.plus.OsmandPlugin)

Example 4 with OsmandPlugin

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);
        }
    }
}
Also used : OnPreferenceClickListener(android.preference.Preference.OnPreferenceClickListener) OsmandApplication(net.osmand.plus.OsmandApplication) PreferenceScreen(android.preference.PreferenceScreen) PreferenceCategory(android.preference.PreferenceCategory) Preference(android.preference.Preference) Intent(android.content.Intent) OsmandPlugin(net.osmand.plus.OsmandPlugin)

Example 5 with OsmandPlugin

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);
    }
}
Also used : LayoutInflater(android.view.LayoutInflater) TextView(android.widget.TextView) View(android.view.View) LinearLayout(android.widget.LinearLayout) OsmandPlugin(net.osmand.plus.OsmandPlugin)

Aggregations

OsmandPlugin (net.osmand.plus.OsmandPlugin)7 Intent (android.content.Intent)4 View (android.view.View)3 TextView (android.widget.TextView)3 ImageView (android.widget.ImageView)2 OsmandApplication (net.osmand.plus.OsmandApplication)2 Preference (android.preference.Preference)1 OnPreferenceClickListener (android.preference.Preference.OnPreferenceClickListener)1 PreferenceCategory (android.preference.PreferenceCategory)1 PreferenceScreen (android.preference.PreferenceScreen)1 LayoutInflater (android.view.LayoutInflater)1 OnClickListener (android.view.View.OnClickListener)1 Button (android.widget.Button)1 CompoundButton (android.widget.CompoundButton)1 LinearLayout (android.widget.LinearLayout)1 OsmandDevelopmentPlugin (net.osmand.plus.development.OsmandDevelopmentPlugin)1