Search in sources :

Example 1 with SRTMPlugin

use of net.osmand.plus.plugins.srtm.SRTMPlugin in project Osmand by osmandapp.

the class DashboardOnMap method onDownloadHasFinished.

public void onDownloadHasFinished() {
    if (visibleType == DashboardType.CONTOUR_LINES || visibleType == DashboardType.TERRAIN) {
        refreshContent(true);
        if (visibleType == DashboardType.TERRAIN) {
            SRTMPlugin plugin = OsmandPlugin.getActivePlugin(SRTMPlugin.class);
            if (plugin != null && plugin.isTerrainLayerEnabled()) {
                plugin.registerLayers(mapActivity, mapActivity);
            }
        }
        mapActivity.refreshMapComplete();
    } else if (visibleType == DashboardType.WIKIPEDIA) {
        refreshContent(true);
    }
}
Also used : SRTMPlugin(net.osmand.plus.plugins.srtm.SRTMPlugin)

Example 2 with SRTMPlugin

use of net.osmand.plus.plugins.srtm.SRTMPlugin in project Osmand by osmandapp.

the class DownloadActivity method initAppStatusVariables.

public void initAppStatusVariables() {
    OsmandApplication app = getMyApplication();
    srtmDisabled = !OsmandPlugin.isActive(SRTMPlugin.class) && !InAppPurchaseHelper.isContourLinesPurchased(app);
    nauticalPluginDisabled = !OsmandPlugin.isActive(NauticalMapsPlugin.class);
    freeVersion = Version.isFreeVersion(app);
    SRTMPlugin srtmPlugin = OsmandPlugin.getPlugin(SRTMPlugin.class);
    srtmNeedsInstallation = srtmPlugin == null || srtmPlugin.needsInstallation();
}
Also used : SRTMPlugin(net.osmand.plus.plugins.srtm.SRTMPlugin) OsmandApplication(net.osmand.plus.OsmandApplication)

Example 3 with SRTMPlugin

use of net.osmand.plus.plugins.srtm.SRTMPlugin in project Osmand by osmandapp.

the class OsmandPlugin method initPlugins.

public static void initPlugins(@NonNull OsmandApplication app) {
    Set<String> enabledPlugins = app.getSettings().getEnabledPlugins();
    allPlugins.clear();
    allPlugins.add(new WikipediaPlugin(app));
    allPlugins.add(new OsmandRasterMapsPlugin(app));
    allPlugins.add(new OsmandMonitoringPlugin(app));
    checkMarketPlugin(app, new SRTMPlugin(app));
    checkMarketPlugin(app, new NauticalMapsPlugin(app));
    checkMarketPlugin(app, new SkiMapsPlugin(app));
    allPlugins.add(new AudioVideoNotesPlugin(app));
    checkMarketPlugin(app, new ParkingPositionPlugin(app));
    allPlugins.add(new OsmEditingPlugin(app));
    allPlugins.add(new OpenPlaceReviewsPlugin(app));
    allPlugins.add(new MapillaryPlugin(app));
    allPlugins.add(new AccessibilityPlugin(app));
    allPlugins.add(new OsmandDevelopmentPlugin(app));
    loadCustomPlugins(app);
    registerAppInitializingDependedProperties(app);
    enablePluginsByDefault(app, enabledPlugins);
    activatePlugins(app, enabledPlugins);
}
Also used : SRTMPlugin(net.osmand.plus.plugins.srtm.SRTMPlugin) AudioVideoNotesPlugin(net.osmand.plus.plugins.audionotes.AudioVideoNotesPlugin) OpenPlaceReviewsPlugin(net.osmand.plus.plugins.openplacereviews.OpenPlaceReviewsPlugin) OsmandMonitoringPlugin(net.osmand.plus.plugins.monitoring.OsmandMonitoringPlugin) OsmEditingPlugin(net.osmand.plus.plugins.osmedit.OsmEditingPlugin) MapillaryPlugin(net.osmand.plus.plugins.mapillary.MapillaryPlugin) SkiMapsPlugin(net.osmand.plus.plugins.skimaps.SkiMapsPlugin) ParkingPositionPlugin(net.osmand.plus.plugins.parking.ParkingPositionPlugin) OsmandDevelopmentPlugin(net.osmand.plus.plugins.development.OsmandDevelopmentPlugin) NauticalMapsPlugin(net.osmand.plus.plugins.openseamaps.NauticalMapsPlugin) WikipediaPlugin(net.osmand.plus.wikipedia.WikipediaPlugin) AccessibilityPlugin(net.osmand.plus.plugins.accessibility.AccessibilityPlugin) OsmandRasterMapsPlugin(net.osmand.plus.plugins.rastermaps.OsmandRasterMapsPlugin)

Example 4 with SRTMPlugin

use of net.osmand.plus.plugins.srtm.SRTMPlugin in project Osmand by osmandapp.

the class PluginInfoFragment method onCreateView.

@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    app = requireMyApplication();
    plugin = getPluginFromArgs();
    if (plugin == null) {
        return null;
    }
    Context context = requireContext();
    nightMode = !app.getSettings().isLightContent();
    LayoutInflater themedInflater = UiUtilities.getInflater(context, nightMode);
    mainView = themedInflater.inflate(R.layout.plugin, container, false);
    AndroidUtils.addStatusBarPadding21v(context, mainView);
    TextView toolbarTitle = mainView.findViewById(R.id.toolbar_title);
    toolbarTitle.setText(plugin.getName());
    ImageView closeButton = mainView.findViewById(R.id.close_button);
    closeButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Activity activity = getMyActivity();
            if (activity != null) {
                activity.onBackPressed();
            }
        }
    });
    UiUtilities.rotateImageByLayoutDirection(closeButton);
    Drawable pluginImage = plugin.getAssetResourceImage();
    if (pluginImage != null) {
        ImageView img = mainView.findViewById(R.id.plugin_image);
        img.setImageDrawable(pluginImage);
    } else {
        mainView.findViewById(R.id.plugin_image_placeholder).setVisibility(View.VISIBLE);
    }
    TextView descriptionView = mainView.findViewById(R.id.plugin_description);
    descriptionView.setText(plugin.getDescription());
    int linkTextColorId = nightMode ? R.color.ctx_menu_bottom_view_url_color_dark : R.color.ctx_menu_bottom_view_url_color_light;
    int linkTextColor = ContextCompat.getColor(context, linkTextColorId);
    descriptionView.setLinkTextColor(linkTextColor);
    descriptionView.setMovementMethod(LinkMovementMethod.getInstance());
    AndroidUtils.removeLinkUnderline(descriptionView);
    Button settingsButton = mainView.findViewById(R.id.plugin_settings);
    settingsButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            FragmentActivity activity = getActivity();
            if (activity != null) {
                SettingsScreenType settingsScreenType = plugin.getSettingsScreenType();
                if (settingsScreenType != null) {
                    Bundle args = new Bundle();
                    args.putBoolean(PLUGIN_INFO, true);
                    BaseSettingsFragment.showInstance(activity, settingsScreenType, null, args, null);
                }
            }
        }
    });
    CompoundButton enableDisableButton = mainView.findViewById(R.id.plugin_enable_disable);
    enableDisableButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (plugin.isEnabled() != isChecked) {
                if (OsmandPlugin.enablePlugin(getActivity(), app, plugin, isChecked)) {
                    updateState();
                    Fragment target = getTargetFragment();
                    if (target instanceof PluginStateListener) {
                        ((PluginStateListener) target).onPluginStateChanged(plugin);
                    }
                }
            }
        }
    });
    Button getButton = mainView.findViewById(R.id.plugin_get);
    getButton.setText(plugin.isPaid() ? R.string.get_plugin : R.string.shared_string_install);
    getButton.setOnClickListener(v -> {
        FragmentActivity activity = getActivity();
        if (activity != null) {
            OsmAndFeature feature = null;
            if (plugin instanceof SRTMPlugin) {
                feature = OsmAndFeature.TERRAIN;
            } else if (plugin instanceof WikipediaPlugin) {
                feature = OsmAndFeature.WIKIPEDIA;
            } else {
                Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(plugin.getInstallURL()));
                AndroidUtils.startActivityIfSafe(activity, intent);
            }
            if (feature != null) {
                ChoosePlanFragment.showInstance(activity, feature);
            }
        }
    });
    updateState();
    return mainView;
}
Also used : Context(android.content.Context) SRTMPlugin(net.osmand.plus.plugins.srtm.SRTMPlugin) Bundle(android.os.Bundle) Drawable(android.graphics.drawable.Drawable) SettingsScreenType(net.osmand.plus.settings.fragments.BaseSettingsFragment.SettingsScreenType) FragmentActivity(androidx.fragment.app.FragmentActivity) Activity(android.app.Activity) Intent(android.content.Intent) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) ChoosePlanFragment(net.osmand.plus.chooseplan.ChoosePlanFragment) Fragment(androidx.fragment.app.Fragment) BaseOsmAndFragment(net.osmand.plus.base.BaseOsmAndFragment) BaseSettingsFragment(net.osmand.plus.settings.fragments.BaseSettingsFragment) FragmentActivity(androidx.fragment.app.FragmentActivity) OsmAndFeature(net.osmand.plus.chooseplan.OsmAndFeature) Button(android.widget.Button) CompoundButton(android.widget.CompoundButton) PluginStateListener(net.osmand.plus.plugins.PluginInstalledBottomSheetDialog.PluginStateListener) LayoutInflater(android.view.LayoutInflater) TextView(android.widget.TextView) WikipediaPlugin(net.osmand.plus.wikipedia.WikipediaPlugin) ImageView(android.widget.ImageView) CompoundButton(android.widget.CompoundButton)

Aggregations

SRTMPlugin (net.osmand.plus.plugins.srtm.SRTMPlugin)4 WikipediaPlugin (net.osmand.plus.wikipedia.WikipediaPlugin)2 Activity (android.app.Activity)1 Context (android.content.Context)1 Intent (android.content.Intent)1 Drawable (android.graphics.drawable.Drawable)1 Bundle (android.os.Bundle)1 LayoutInflater (android.view.LayoutInflater)1 View (android.view.View)1 Button (android.widget.Button)1 CompoundButton (android.widget.CompoundButton)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 Fragment (androidx.fragment.app.Fragment)1 FragmentActivity (androidx.fragment.app.FragmentActivity)1 OsmandApplication (net.osmand.plus.OsmandApplication)1 BaseOsmAndFragment (net.osmand.plus.base.BaseOsmAndFragment)1 ChoosePlanFragment (net.osmand.plus.chooseplan.ChoosePlanFragment)1 OsmAndFeature (net.osmand.plus.chooseplan.OsmAndFeature)1 PluginStateListener (net.osmand.plus.plugins.PluginInstalledBottomSheetDialog.PluginStateListener)1