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);
}
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;
}
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();
}
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;
}
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);
}
}
}
Aggregations