Search in sources :

Example 66 with OsmandSettings

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

the class AppModeDialog method prepareAppModeDrawerView.

// special method for drawer menu
// needed because if there's more than 4 items  - the don't fit in drawer
public static View prepareAppModeDrawerView(Activity a, final Set<ApplicationMode> selected, boolean useMapTheme, final View.OnClickListener onClickListener) {
    OsmandSettings settings = ((OsmandApplication) a.getApplication()).getSettings();
    final List<ApplicationMode> values = new ArrayList<ApplicationMode>(ApplicationMode.values(settings));
    selected.add(settings.getApplicationMode());
    return prepareAppModeView(a, values, selected, null, true, true, useMapTheme, onClickListener);
}
Also used : OsmandApplication(net.osmand.plus.OsmandApplication) ArrayList(java.util.ArrayList) ApplicationMode(net.osmand.plus.ApplicationMode) OsmandSettings(net.osmand.plus.OsmandSettings)

Example 67 with OsmandSettings

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

the class DashRateUsFragment method initView.

@Override
public View initView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = getActivity().getLayoutInflater().inflate(R.layout.dash_rate_us_fragment, container, false);
    TextView header = (TextView) view.findViewById(R.id.header);
    TextView subheader = (TextView) view.findViewById(R.id.subheader);
    Button positiveButton = (Button) view.findViewById(R.id.positive_button);
    Button negativeButton = (Button) view.findViewById(R.id.negative_button);
    positiveButton.setOnClickListener(new PositiveButtonListener(header, subheader, positiveButton, negativeButton));
    negativeButton.setOnClickListener(new NegativeButtonListener(header, subheader, positiveButton, negativeButton));
    OsmandSettings settings = getMyApplication().getSettings();
    mRateUsDismissListener = new RateUsDismissListener(dashboard, settings);
    return view;
}
Also used : Button(android.widget.Button) TextView(android.widget.TextView) TextView(android.widget.TextView) View(android.view.View) OsmandSettings(net.osmand.plus.OsmandSettings)

Example 68 with OsmandSettings

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

the class DashboardOnMap method addOrUpdateDashboardFragments.

private void addOrUpdateDashboardFragments() {
    OsmandSettings settings = getMyApplication().getSettings();
    TransactionBuilder builder = new TransactionBuilder(mapActivity.getSupportFragmentManager(), settings, mapActivity);
    builder.addFragmentsData(fragmentsData).addFragmentsData(OsmandPlugin.getPluginsCardsList()).getFragmentTransaction().commit();
}
Also used : TransactionBuilder(net.osmand.plus.dashboard.tools.TransactionBuilder) OsmandSettings(net.osmand.plus.OsmandSettings)

Example 69 with OsmandSettings

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

the class DashboardSettingsDialogFragment method onCreateDialog.

@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    TypedValue typedValue = new TypedValue();
    Resources.Theme theme = getActivity().getTheme();
    theme.resolveAttribute(android.R.attr.textColorPrimary, typedValue, true);
    textColorPrimary = typedValue.data;
    theme.resolveAttribute(R.attr.dialog_inactive_text_color, typedValue, true);
    textColorSecondary = typedValue.data;
    final OsmandSettings settings = mapActivity.getMyApplication().getSettings();
    final View showDashboardOnStart = createCheckboxItem(settings.SHOW_DASHBOARD_ON_START, R.string.show_on_start, R.string.show_on_start_description);
    final View accessFromMap = createCheckboxItem(settings.SHOW_DASHBOARD_ON_MAP_SCREEN, R.string.access_from_map, R.string.access_from_map_description);
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    if (savedInstanceState != null && savedInstanceState.containsKey(CHECKED_ITEMS)) {
        mAdapter = new DashFragmentAdapter(getActivity(), mFragmentsData, savedInstanceState.getBooleanArray(CHECKED_ITEMS), savedInstanceState.getIntArray(NUMBER_OF_ROWS_ARRAY));
    } else {
        mAdapter = new DashFragmentAdapter(getActivity(), mFragmentsData, settings);
    }
    builder.setTitle(R.string.dahboard_options_dialog_title).setAdapter(mAdapter, null).setPositiveButton(R.string.shared_string_apply, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialogInterface, int type) {
            boolean[] shouldShow = mAdapter.getCheckedItems();
            int[] numberOfRows = mAdapter.getNumbersOfRows();
            for (int i = 0; i < shouldShow.length; i++) {
                final DashFragmentData fragmentData = mFragmentsData.get(i);
                settings.registerBooleanPreference(DashboardOnMap.SHOULD_SHOW + fragmentData.tag, true).makeGlobal().set(shouldShow[i]);
                if (fragmentData.rowNumberTag != null) {
                    settings.registerIntPreference(fragmentData.rowNumberTag, DEFAULT_NUMBER_OF_ROWS).makeGlobal().set(numberOfRows[i]);
                }
            }
            mapActivity.getDashboard().refreshDashboardFragments();
            settings.SHOW_DASHBOARD_ON_START.set(((CompoundButton) showDashboardOnStart.findViewById(R.id.toggle_item)).isChecked());
            settings.SHOW_DASHBOARD_ON_MAP_SCREEN.set(((CompoundButton) accessFromMap.findViewById(R.id.toggle_item)).isChecked());
            mapActivity.getMapLayers().getMapControlsLayer().initDasboardRelatedControls();
        }
    }).setNegativeButton(R.string.shared_string_cancel, null);
    final AlertDialog dialog = builder.create();
    ListView listView = dialog.getListView();
    listView.addHeaderView(showDashboardOnStart);
    listView.addHeaderView(accessFromMap);
    return dialog;
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface) View(android.view.View) TextView(android.widget.TextView) ListView(android.widget.ListView) OsmandSettings(net.osmand.plus.OsmandSettings) ListView(android.widget.ListView) Resources(android.content.res.Resources) TypedValue(android.util.TypedValue) NonNull(android.support.annotation.NonNull)

Example 70 with OsmandSettings

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

the class SearchActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    ((OsmandApplication) getApplication()).applyTheme(this);
    super.onCreate(savedInstanceState);
    getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
    long t = System.currentTimeMillis();
    setContentView(R.layout.tab_content);
    settings = ((OsmandApplication) getApplication()).getSettings();
    accessibilityAssistant = new AccessibilityAssistant(this);
    navigationInfo = new NavigationInfo((OsmandApplication) getApplication());
    showOnlyOneTab = getIntent() != null && getIntent().getBooleanExtra(SHOW_ONLY_ONE_TAB, false);
    getSupportActionBar().setTitle("");
    getSupportActionBar().setElevation(0);
    Integer tab = settings.SEARCH_TAB.get();
    if (!showOnlyOneTab) {
        ViewPager mViewPager = (ViewPager) findViewById(R.id.pager);
        PagerSlidingTabStrip mSlidingTabLayout = (PagerSlidingTabStrip) findViewById(R.id.sliding_tabs);
        List<TabItem> mTabs = new ArrayList<TabItem>();
        mTabs.add(getTabIndicator(R.string.poi, getFragment(POI_TAB_INDEX)));
        mTabs.add(getTabIndicator(R.string.address, getFragment(ADDRESS_TAB_INDEX)));
        mTabs.add(getTabIndicator(R.string.shared_string_location, getFragment(LOCATION_TAB_INDEX)));
        mTabs.add(getTabIndicator(R.string.favorite, getFragment(FAVORITES_TAB_INDEX)));
        mTabs.add(getTabIndicator(R.string.shared_string_history, getFragment(HISTORY_TAB_INDEX)));
        setViewPagerAdapter(mViewPager, mTabs);
        mSlidingTabLayout.setViewPager(mViewPager);
        mViewPager.setCurrentItem(Math.min(tab, HISTORY_TAB_INDEX));
        mSlidingTabLayout.setOnPageChangeListener(new OnPageChangeListener() {

            @Override
            public void onPageSelected(int arg0) {
                settings.SEARCH_TAB.set(arg0);
            }

            @Override
            public void onPageScrolled(int arg0, float arg1, int arg2) {
            }

            @Override
            public void onPageScrollStateChanged(int arg0) {
            }
        });
    } else {
        setContentView(R.layout.search_activity_single);
        Class<?> cl = getFragment(tab);
        try {
            getSupportFragmentManager().beginTransaction().replace(R.id.layout, (Fragment) cl.newInstance()).commit();
        } catch (InstantiationException e) {
            throw new IllegalStateException(e);
        } catch (IllegalAccessException e) {
            throw new IllegalStateException(e);
        }
    }
    setTopSpinner();
    Log.i("net.osmand", "Start on create " + (System.currentTimeMillis() - t));
    Intent intent = getIntent();
    OsmandSettings settings = ((OsmandApplication) getApplication()).getSettings();
    LatLon last = settings.getLastKnownMapLocation();
    if (intent != null) {
        double lat = intent.getDoubleExtra(SEARCH_LAT, 0);
        double lon = intent.getDoubleExtra(SEARCH_LON, 0);
        if (lat != 0 || lon != 0) {
            LatLon l = new LatLon(lat, lon);
            if (!Algorithms.objectEquals(reqSearchPoint, l)) {
                reqSearchPoint = l;
                if ((Math.abs(lat - last.getLatitude()) < 0.00001) && (Math.abs(lon - last.getLongitude()) < 0.00001)) {
                    updateSearchPoint(reqSearchPoint, getString(R.string.select_search_position) + " " + getString(R.string.search_position_map_view), false);
                } else {
                    updateSearchPoint(reqSearchPoint, getString(R.string.select_search_position) + " ", true);
                }
            }
        }
    }
    if (searchPoint == null) {
        if (!Algorithms.objectEquals(reqSearchPoint, last)) {
            reqSearchPoint = last;
            updateSearchPoint(last, getString(R.string.select_search_position) + " " + getString(R.string.search_position_map_view), false);
        }
    }
}
Also used : AccessibilityAssistant(net.osmand.access.AccessibilityAssistant) OsmandApplication(net.osmand.plus.OsmandApplication) PagerSlidingTabStrip(net.osmand.plus.views.controls.PagerSlidingTabStrip) ArrayList(java.util.ArrayList) OnPageChangeListener(android.support.v4.view.ViewPager.OnPageChangeListener) Intent(android.content.Intent) ViewPager(android.support.v4.view.ViewPager) NavigatePointFragment(net.osmand.plus.activities.NavigatePointFragment) Fragment(android.support.v4.app.Fragment) FavoritesListFragment(net.osmand.plus.activities.FavoritesListFragment) FavouritePoint(net.osmand.data.FavouritePoint) OsmandSettings(net.osmand.plus.OsmandSettings) LatLon(net.osmand.data.LatLon) NavigationInfo(net.osmand.access.NavigationInfo)

Aggregations

OsmandSettings (net.osmand.plus.OsmandSettings)91 View (android.view.View)27 OsmandApplication (net.osmand.plus.OsmandApplication)25 ArrayList (java.util.ArrayList)20 LatLon (net.osmand.data.LatLon)17 DialogInterface (android.content.DialogInterface)14 ArrayAdapter (android.widget.ArrayAdapter)14 TextView (android.widget.TextView)14 AlertDialog (android.support.v7.app.AlertDialog)11 ImageView (android.widget.ImageView)11 PointDescription (net.osmand.data.PointDescription)10 AdapterView (android.widget.AdapterView)9 ContextMenuAdapter (net.osmand.plus.ContextMenuAdapter)8 ContextMenuItem (net.osmand.plus.ContextMenuItem)8 ApplicationMode (net.osmand.plus.ApplicationMode)7 Paint (android.graphics.Paint)6 Pair (android.support.v4.util.Pair)6 ListView (android.widget.ListView)6 SpannableString (android.text.SpannableString)5 CompoundButton (android.widget.CompoundButton)5