Search in sources :

Example 6 with OsmandApplication

use of net.osmand.plus.OsmandApplication in project Osmand by osmandapp.

the class WhatsNewDialogFragment method onCreateDialog.

@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    final OsmandApplication osmandApplication = (OsmandApplication) getActivity().getApplication();
    final String appVersion = Version.getAppVersion(osmandApplication);
    builder.setTitle(getString(R.string.whats_new) + " " + appVersion).setMessage(getString(R.string.release_2_9)).setNegativeButton(R.string.shared_string_close, null);
    if (AppInitializer.LATEST_CHANGES_URL != null) {
        builder.setPositiveButton(R.string.read_more, new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                Intent i = new Intent(Intent.ACTION_VIEW);
                i.setData(Uri.parse(AppInitializer.LATEST_CHANGES_URL));
                startActivity(i);
                dismiss();
            }
        });
    }
    return builder.create();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) OsmandApplication(net.osmand.plus.OsmandApplication) DialogInterface(android.content.DialogInterface) Intent(android.content.Intent) NonNull(android.support.annotation.NonNull)

Example 7 with OsmandApplication

use of net.osmand.plus.OsmandApplication in project Osmand by osmandapp.

the class SettingsDevelopmentActivity method onCreate.

@SuppressLint("SimpleDateFormat")
@Override
public void onCreate(Bundle savedInstanceState) {
    ((OsmandApplication) getApplication()).applyTheme(this);
    super.onCreate(savedInstanceState);
    getToolbar().setTitle(R.string.debugging_and_development);
    PreferenceScreen cat = getPreferenceScreen();
    CheckBoxPreference dbg = createCheckBoxPreference(settings.DEBUG_RENDERING_INFO, R.string.trace_rendering, R.string.trace_rendering_descr);
    cat.addPreference(dbg);
    cat.addPreference(createCheckBoxPreference(settings.DISABLE_COMPLEX_ROUTING, R.string.disable_complex_routing, R.string.disable_complex_routing_descr));
    cat.addPreference(createCheckBoxPreference(settings.USE_FAST_RECALCULATION, R.string.use_fast_recalculation, R.string.use_fast_recalculation_desc));
    final CheckBoxPreference openGlRender = createCheckBoxPreference(settings.USE_OPENGL_RENDER, R.string.use_opengl_render, R.string.use_opengl_render_descr);
    cat.addPreference(openGlRender);
    cat.addPreference(createCheckBoxPreference(settings.USE_OSM_LIVE_FOR_ROUTING, R.string.use_osm_live_routing, R.string.use_osm_live_routing_description));
    cat.addPreference(createCheckBoxPreference(settings.ANIMATE_MY_LOCATION, R.string.animate_my_location, R.string.animate_my_location_desc));
    final Preference firstRunPreference = new Preference(this);
    firstRunPreference.setTitle(R.string.simulate_initial_startup);
    firstRunPreference.setSummary(R.string.simulate_initial_startup_descr);
    firstRunPreference.setSelectable(true);
    firstRunPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {

        @Override
        public boolean onPreferenceClick(Preference preference) {
            getMyApplication().getAppInitializer().resetFirstTimeRun();
            getMyApplication().getSettings().FIRST_MAP_IS_DOWNLOADED.set(false);
            getMyApplication().getSettings().MAPILLARY_FIRST_DIALOG_SHOWN.set(false);
            getMyApplication().getSettings().WEBGL_SUPPORTED.set(true);
            getMyApplication().getSettings().METRIC_SYSTEM_CHANGED_MANUALLY.set(false);
            getMyApplication().showToastMessage(R.string.shared_string_ok);
            return true;
        }
    });
    cat.addPreference(firstRunPreference);
    cat.addPreference(createCheckBoxPreference(settings.SHOULD_SHOW_FREE_VERSION_BANNER, R.string.show_free_version_banner, R.string.show_free_version_banner_description));
    cat.addPreference(createCheckBoxPreference(settings.NO_DISCOUNT_INFO, R.string.no_update_info, R.string.no_update_info_desc));
    cat.addPreference(createCheckBoxPreference(settings.SHOW_LEGACY_SEARCH, R.string.show_legacy_search, R.string.show_legacy_search_desc));
    // FIXME delete USE_MAP_MARKERS
    // cat.addPreference(createCheckBoxPreference(settings.USE_MAP_MARKERS,
    // R.string.map_markers,
    // R.string.show_map_markers_description));
    Preference pref = new Preference(this);
    final Preference simulate = pref;
    final OsmAndLocationSimulation sim = getMyApplication().getLocationProvider().getLocationSimulation();
    final Runnable updateTitle = new Runnable() {

        @Override
        public void run() {
            simulate.setSummary(sim.isRouteAnimating() ? R.string.simulate_your_location_stop_descr : R.string.simulate_your_location_descr);
        }
    };
    pref.setTitle(R.string.simulate_your_location);
    updateTitle.run();
    pref.setKey("simulate_your_location");
    pref.setOnPreferenceClickListener(new OnPreferenceClickListener() {

        @Override
        public boolean onPreferenceClick(Preference preference) {
            updateTitle.run();
            sim.startStopRouteAnimation(SettingsDevelopmentActivity.this, updateTitle);
            return true;
        }
    });
    cat.addPreference(pref);
    pref = new Preference(this);
    pref.setTitle(R.string.test_voice_prompts);
    pref.setSummary(R.string.play_commands_of_currently_selected_voice);
    pref.setKey("test_voice_commands");
    pref.setOnPreferenceClickListener(new OnPreferenceClickListener() {

        @Override
        public boolean onPreferenceClick(Preference preference) {
            startActivity(new Intent(SettingsDevelopmentActivity.this, TestVoiceActivity.class));
            return true;
        }
    });
    cat.addPreference(pref);
    pref = new Preference(this);
    pref.setTitle(R.string.app_modes_choose);
    pref.setSummary(R.string.app_modes_choose_descr);
    pref.setKey("available_application_modes");
    pref.setOnPreferenceClickListener(new OnPreferenceClickListener() {

        @Override
        public boolean onPreferenceClick(Preference preference) {
            availableProfileDialog();
            return true;
        }
    });
    cat.addPreference(pref);
    PreferenceCategory info = new PreferenceCategory(this);
    info.setTitle(R.string.info_button);
    cat.addPreference(info);
    pref = new Preference(this);
    pref.setTitle(R.string.global_app_allocated_memory);
    long javaAvailMem = (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / (1024 * 1024l);
    long javaTotal = Runtime.getRuntime().totalMemory() / (1024 * 1024l);
    long dalvikSize = android.os.Debug.getNativeHeapAllocatedSize() / (1024 * 1024l);
    pref.setSummary(getString(R.string.global_app_allocated_memory_descr, javaAvailMem, javaTotal, dalvikSize));
    pref.setSelectable(false);
    // setEnabled(false) creates bad readability on some devices
    // pref.setEnabled(false);
    info.addPreference(pref);
    // ActivityManager activityManager = (ActivityManager)getSystemService(Context.ACTIVITY_SERVICE);
    // ActivityManager.MemoryInfo memoryInfo = new ActivityManager.MemoryInfo();
    // activityManager.getMemoryInfo(memoryInfo);
    // long totalSize = memoryInfo.availMem / (1024*1024l);
    MemoryInfo mem = new Debug.MemoryInfo();
    Debug.getMemoryInfo(mem);
    pref = new Preference(this);
    pref.setTitle(R.string.native_app_allocated_memory);
    pref.setSummary(getString(R.string.native_app_allocated_memory_descr, mem.nativePrivateDirty / 1024, mem.dalvikPrivateDirty / 1024, mem.otherPrivateDirty / 1024, mem.nativePss / 1024, mem.dalvikPss / 1024, mem.otherPss / 1024));
    pref.setSelectable(false);
    // setEnabled(false) creates bad readability on some devices
    // pref.setEnabled(false);
    info.addPreference(pref);
    final Preference agpspref = new Preference(this);
    agpspref.setTitle(R.string.agps_info);
    if (settings.AGPS_DATA_LAST_TIME_DOWNLOADED.get() != 0L) {
        SimpleDateFormat prt = new SimpleDateFormat("yyyy-MM-dd  HH:mm");
        agpspref.setSummary(getString(R.string.agps_data_last_downloaded, prt.format(settings.AGPS_DATA_LAST_TIME_DOWNLOADED.get())));
    } else {
        agpspref.setSummary(getString(R.string.agps_data_last_downloaded, "--"));
    }
    agpspref.setSelectable(true);
    // setEnabled(false) creates bad readability on some devices
    // pref.setEnabled(false);
    agpspref.setOnPreferenceClickListener(new OnPreferenceClickListener() {

        @Override
        public boolean onPreferenceClick(Preference preference) {
            if (getMyApplication().getSettings().isInternetConnectionAvailable(true)) {
                getMyApplication().getLocationProvider().redownloadAGPS();
                SimpleDateFormat prt = new SimpleDateFormat("yyyy-MM-dd  HH:mm");
                agpspref.setSummary(getString(R.string.agps_data_last_downloaded, prt.format(settings.AGPS_DATA_LAST_TIME_DOWNLOADED.get())));
            }
            return true;
        }
    });
    info.addPreference(agpspref);
    SunriseSunset sunriseSunset = getMyApplication().getDaynightHelper().getSunriseSunset();
    pref = new Preference(this);
    pref.setTitle(R.string.day_night_info);
    if (sunriseSunset != null) {
        SimpleDateFormat prt = new SimpleDateFormat("yyyy-MM-dd  HH:mm");
        pref.setSummary(getString(R.string.day_night_info_description, prt.format(sunriseSunset.getSunrise()), prt.format(sunriseSunset.getSunset())));
    } else {
        pref.setSummary(getString(R.string.day_night_info_description, "null", "null"));
    }
    pref.setSelectable(false);
    // setEnabled(false) creates bad readability on some devices
    // pref.setEnabled(false);
    info.addPreference(pref);
}
Also used : OsmandApplication(net.osmand.plus.OsmandApplication) PreferenceScreen(android.preference.PreferenceScreen) CheckBoxPreference(android.preference.CheckBoxPreference) OsmAndLocationSimulation(net.osmand.plus.OsmAndLocationSimulation) Intent(android.content.Intent) OnPreferenceClickListener(android.preference.Preference.OnPreferenceClickListener) MemoryInfo(android.os.Debug.MemoryInfo) SunriseSunset(net.osmand.util.SunriseSunset) OnPreferenceClickListener(android.preference.Preference.OnPreferenceClickListener) CheckBoxPreference(android.preference.CheckBoxPreference) Preference(android.preference.Preference) PreferenceCategory(android.preference.PreferenceCategory) SimpleDateFormat(java.text.SimpleDateFormat) SuppressLint(android.annotation.SuppressLint)

Example 8 with OsmandApplication

use of net.osmand.plus.OsmandApplication in project Osmand by osmandapp.

the class DirectionsDialogs method addWaypointDialogAndLaunchMap.

public static void addWaypointDialogAndLaunchMap(final AppCompatActivity act, final double lat, final double lon, final PointDescription name) {
    final TargetPointsHelper targetPointsHelper = ((OsmandApplication) act.getApplication()).getTargetPointsHelper();
    if (targetPointsHelper.getPointToNavigate() != null) {
        Bundle args = new Bundle();
        args.putDouble(AddWaypointBottomSheetDialogFragment.LAT_KEY, lat);
        args.putDouble(AddWaypointBottomSheetDialogFragment.LON_KEY, lon);
        args.putString(AddWaypointBottomSheetDialogFragment.POINT_DESCRIPTION_KEY, PointDescription.serializeToString(name));
        AddWaypointBottomSheetDialogFragment fragment = new AddWaypointBottomSheetDialogFragment();
        fragment.setArguments(args);
        fragment.show(act.getSupportFragmentManager(), AddWaypointBottomSheetDialogFragment.TAG);
    } else {
        targetPointsHelper.navigateToPoint(new LatLon(lat, lon), true, -1, name);
        closeContextMenu(act);
        MapActivity.launchMapActivityMoveToTop(act);
    }
}
Also used : LatLon(net.osmand.data.LatLon) OsmandApplication(net.osmand.plus.OsmandApplication) Bundle(android.os.Bundle) TargetPointsHelper(net.osmand.plus.TargetPointsHelper)

Example 9 with OsmandApplication

use of net.osmand.plus.OsmandApplication in project Osmand by osmandapp.

the class FavoriteDialogs method prepareAddFavouriteDialog.

public static void prepareAddFavouriteDialog(Activity activity, Dialog dialog, Bundle args, double lat, double lon, PointDescription desc) {
    final Resources resources = activity.getResources();
    String name = desc == null ? "" : desc.getName();
    if (name.length() == 0) {
        name = resources.getString(R.string.add_favorite_dialog_default_favourite_name);
    }
    OsmandApplication app = (OsmandApplication) activity.getApplication();
    final FavouritePoint point = new FavouritePoint(lat, lon, name, app.getSettings().LAST_FAV_CATEGORY_ENTERED.get());
    args.putSerializable(KEY_FAVORITE, point);
    final EditText editText = (EditText) dialog.findViewById(R.id.Name);
    editText.setText(point.getName());
    editText.selectAll();
    editText.requestFocus();
    final AutoCompleteTextView cat = (AutoCompleteTextView) dialog.findViewById(R.id.Category);
    cat.setText(point.getCategory());
    AndroidUtils.softKeyboardDelayed(editText);
}
Also used : EditText(android.widget.EditText) OsmandApplication(net.osmand.plus.OsmandApplication) FavouritePoint(net.osmand.data.FavouritePoint) Resources(android.content.res.Resources) AutoCompleteTextView(android.widget.AutoCompleteTextView)

Example 10 with OsmandApplication

use of net.osmand.plus.OsmandApplication in project Osmand by osmandapp.

the class DownloadResourceGroup method addGroup.

public void addGroup(DownloadResourceGroup g) {
    if (type.isScreen()) {
        if (!g.type.isHeader()) {
            throw new UnsupportedOperationException("Trying to add " + g.getUniqueId() + " to " + getUniqueId());
        }
    }
    if (type.isHeader()) {
        if (!g.type.isScreen()) {
            throw new UnsupportedOperationException("Trying to add " + g.getUniqueId() + " to " + getUniqueId());
        }
    }
    groups.add(g);
    if (g.individualResources != null) {
        final net.osmand.Collator collator = OsmAndCollator.primaryCollator();
        final OsmandApplication app = getRoot().app;
        final OsmandRegions osmandRegions = app.getRegions();
        Collections.sort(g.individualResources, new Comparator<IndexItem>() {

            @Override
            public int compare(IndexItem lhs, IndexItem rhs) {
                int lli = lhs.getType().getOrderIndex();
                int rri = rhs.getType().getOrderIndex();
                if (lli < rri) {
                    return -1;
                } else if (lli > rri) {
                    return 1;
                }
                return collator.compare(lhs.getVisibleName(app.getApplicationContext(), osmandRegions), rhs.getVisibleName(app.getApplicationContext(), osmandRegions));
            }
        });
    }
}
Also used : OsmandRegions(net.osmand.map.OsmandRegions) OsmandApplication(net.osmand.plus.OsmandApplication)

Aggregations

OsmandApplication (net.osmand.plus.OsmandApplication)181 View (android.view.View)46 TextView (android.widget.TextView)39 ArrayList (java.util.ArrayList)33 AlertDialog (android.support.v7.app.AlertDialog)32 ImageView (android.widget.ImageView)31 DialogInterface (android.content.DialogInterface)27 OsmandSettings (net.osmand.plus.OsmandSettings)27 LatLon (net.osmand.data.LatLon)25 Intent (android.content.Intent)21 AdapterView (android.widget.AdapterView)19 File (java.io.File)17 OsmandMapTileView (net.osmand.plus.views.OsmandMapTileView)15 Location (net.osmand.Location)13 EditText (android.widget.EditText)12 ContextMenuAdapter (net.osmand.plus.ContextMenuAdapter)12 ArrayAdapter (android.widget.ArrayAdapter)11 ListView (android.widget.ListView)11 ContextMenuItem (net.osmand.plus.ContextMenuItem)11 SelectedGpxFile (net.osmand.plus.GpxSelectionHelper.SelectedGpxFile)11