Search in sources :

Example 1 with NavigationInfo

use of net.osmand.plus.plugins.accessibility.NavigationInfo in project Osmand by osmandapp.

the class SearchPOIActivity method onCreate.

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    setContentView(R.layout.searchpoi);
    getSupportActionBar().setTitle(R.string.searchpoi_activity);
    // getSupportActionBar().setIcon(R.drawable.tab_search_poi_icon);
    setSupportProgressBarIndeterminateVisibility(false);
    app = (OsmandApplication) getApplication();
    amenityAdapter = new AmenityAdapter(new ArrayList<Amenity>());
    setListAdapter(amenityAdapter);
    searchFilterLayout = findViewById(R.id.SearchFilterLayout);
    searchFilter = (EditText) findViewById(R.id.searchEditText);
    accessibilityAssistant = new AccessibilityAssistant(this);
    navigationInfo = new NavigationInfo(app);
    searchFilter.addTextChangedListener(new TextWatcher() {

        @Override
        public void afterTextChanged(Editable s) {
            tChange = s;
            // Issue #2667 (3)
            if (currentSearchTask == null) {
                changeFilter(tChange);
            }
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
        }
    });
    searchFilter.setOnFocusChangeListener(new View.OnFocusChangeListener() {

        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (hasFocus) {
                getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
            }
        }
    });
    searchFilter.setHint(R.string.filter_poi_hint);
    ((ImageView) findViewById(R.id.search_icon)).setImageDrawable(getMyApplication().getUIUtilities().getThemedIcon(R.drawable.ic_action_filter_dark));
    ((ImageView) findViewById(R.id.options)).setImageDrawable(getMyApplication().getUIUtilities().getThemedIcon(R.drawable.ic_overflow_menu_white));
    findViewById(R.id.options).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            showOptionsMenu(v);
        }
    });
    updateIntent(getIntent());
}
Also used : AccessibilityAssistant(net.osmand.plus.plugins.accessibility.AccessibilityAssistant) ArrayList(java.util.ArrayList) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) NavigationInfo(net.osmand.plus.plugins.accessibility.NavigationInfo) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) ImageView(android.widget.ImageView)

Example 2 with NavigationInfo

use of net.osmand.plus.plugins.accessibility.NavigationInfo in project Osmand by osmandapp.

the class QuickSearchDialogFragment method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    FragmentActivity activity = requireActivity();
    app = getMyApplication();
    nightMode = !app.getSettings().isLightContent();
    navigationInfo = new NavigationInfo(app);
    accessibilityAssistant = new AccessibilityAssistant(activity);
    boolean isLightTheme = app.getSettings().isLightContent();
    int themeId = isLightTheme ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme;
    setStyle(STYLE_NO_FRAME, themeId);
    activity.getOnBackPressedDispatcher().addCallback(this, new OnBackPressedCallback(true) {

        public void handleOnBackPressed() {
            MapActivity mapActivity = getMapActivity();
            if (mapActivity != null) {
                mapActivity.showQuickSearch(ShowQuickSearchMode.CURRENT, false);
            }
        }
    });
}
Also used : FragmentActivity(androidx.fragment.app.FragmentActivity) AccessibilityAssistant(net.osmand.plus.plugins.accessibility.AccessibilityAssistant) OnBackPressedCallback(androidx.activity.OnBackPressedCallback) NavigationInfo(net.osmand.plus.plugins.accessibility.NavigationInfo) FavouritePoint(net.osmand.data.FavouritePoint) SuppressLint(android.annotation.SuppressLint) MapActivity(net.osmand.plus.activities.MapActivity)

Example 3 with NavigationInfo

use of net.osmand.plus.plugins.accessibility.NavigationInfo 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);
        showFragment(tab);
    }
    setTopSpinner();
    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);
        }
    }
    LOG.info("Start on create " + (System.currentTimeMillis() - t));
}
Also used : AccessibilityAssistant(net.osmand.plus.plugins.accessibility.AccessibilityAssistant) OsmandApplication(net.osmand.plus.OsmandApplication) PagerSlidingTabStrip(net.osmand.plus.views.controls.PagerSlidingTabStrip) ArrayList(java.util.ArrayList) OnPageChangeListener(androidx.viewpager.widget.ViewPager.OnPageChangeListener) Intent(android.content.Intent) ViewPager(androidx.viewpager.widget.ViewPager) FavouritePoint(net.osmand.data.FavouritePoint) OsmandSettings(net.osmand.plus.settings.backend.OsmandSettings) LatLon(net.osmand.data.LatLon) NavigationInfo(net.osmand.plus.plugins.accessibility.NavigationInfo)

Aggregations

AccessibilityAssistant (net.osmand.plus.plugins.accessibility.AccessibilityAssistant)3 NavigationInfo (net.osmand.plus.plugins.accessibility.NavigationInfo)3 ArrayList (java.util.ArrayList)2 FavouritePoint (net.osmand.data.FavouritePoint)2 SuppressLint (android.annotation.SuppressLint)1 Intent (android.content.Intent)1 Editable (android.text.Editable)1 TextWatcher (android.text.TextWatcher)1 View (android.view.View)1 AdapterView (android.widget.AdapterView)1 ImageView (android.widget.ImageView)1 ListView (android.widget.ListView)1 TextView (android.widget.TextView)1 OnBackPressedCallback (androidx.activity.OnBackPressedCallback)1 FragmentActivity (androidx.fragment.app.FragmentActivity)1 ViewPager (androidx.viewpager.widget.ViewPager)1 OnPageChangeListener (androidx.viewpager.widget.ViewPager.OnPageChangeListener)1 LatLon (net.osmand.data.LatLon)1 OsmandApplication (net.osmand.plus.OsmandApplication)1 MapActivity (net.osmand.plus.activities.MapActivity)1