Search in sources :

Example 1 with BaseSettingsFragment

use of net.osmand.plus.settings.fragments.BaseSettingsFragment in project Osmand by osmandapp.

the class ElevationDateBottomSheet method createReliefFactorButtons.

private void createReliefFactorButtons(Context context) {
    for (int i = 0; i < parameters.size(); i++) {
        RoutingParameter parameter = parameters.get(i);
        final BottomSheetItemWithCompoundButton[] preferenceItem = new BottomSheetItemWithCompoundButton[1];
        preferenceItem[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder().setChecked(i == selectedEntryIndex).setButtonTintList(createColorStateList(context, nightMode)).setTitle(getRoutingParameterTitle(app, parameter)).setLayoutId(R.layout.bottom_sheet_item_with_radio_btn_left).setTag(i).setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                selectedEntryIndex = (int) preferenceItem[0].getTag();
                if (selectedEntryIndex >= 0) {
                    RoutingParameter parameter = parameters.get(selectedEntryIndex);
                    updateSelectedParameters(app, appMode, parameters, parameter.getId());
                }
                Fragment target = getTargetFragment();
                if (target instanceof BaseSettingsFragment) {
                    ((BaseSettingsFragment) target).updateSetting(useHeightPref.getId());
                }
                if (target instanceof RouteOptionsBottomSheet) {
                    ((RouteOptionsBottomSheet) target).updateMenuItems();
                }
                updateReliefButtons();
                app.runInUIThread(new Runnable() {

                    @Override
                    public void run() {
                        dismiss();
                    }
                }, 500);
            }
        }).create();
        items.add(preferenceItem[0]);
        reliefFactorButtons.add(preferenceItem[0]);
    }
}
Also used : RoutingParameter(net.osmand.router.GeneralRouter.RoutingParameter) RouteOptionsBottomSheet(net.osmand.plus.routepreparationmenu.RouteOptionsBottomSheet) BaseSettingsFragment(net.osmand.plus.settings.fragments.BaseSettingsFragment) View(android.view.View) BooleanPreferenceBottomSheet.updateCustomButtonView(net.osmand.plus.settings.bottomsheets.BooleanPreferenceBottomSheet.updateCustomButtonView) TextView(android.widget.TextView) BooleanPreferenceBottomSheet.getCustomButtonView(net.osmand.plus.settings.bottomsheets.BooleanPreferenceBottomSheet.getCustomButtonView) Fragment(androidx.fragment.app.Fragment) BaseSettingsFragment(net.osmand.plus.settings.fragments.BaseSettingsFragment) MenuBottomSheetDialogFragment(net.osmand.plus.base.MenuBottomSheetDialogFragment) BottomSheetItemWithCompoundButton(net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithCompoundButton)

Example 2 with BaseSettingsFragment

use of net.osmand.plus.settings.fragments.BaseSettingsFragment in project Osmand by osmandapp.

the class ElevationDateBottomSheet method createUseHeightButton.

private void createUseHeightButton(Context context) {
    boolean checked = useHeightPref.getModeValue(appMode);
    useHeightButton = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder().setCompoundButtonColor(appModeColor).setChecked(checked).setTitle(checked ? on : off).setTitleColorId(checked ? activeColor : disabledColor).setCustomView(getCustomButtonView(app, appMode, checked, nightMode)).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean newValue = !useHeightPref.getModeValue(appMode);
            Fragment target = getTargetFragment();
            if (target instanceof OnConfirmPreferenceChange) {
                OnConfirmPreferenceChange confirmInterface = (OnConfirmPreferenceChange) target;
                if (confirmInterface.onConfirmPreferenceChange(useHeightPref.getId(), newValue, ApplyQueryType.NONE)) {
                    updateUseHeightButton(useHeightButton, newValue);
                    if (target instanceof BaseSettingsFragment) {
                        ((BaseSettingsFragment) target).updateSetting(useHeightPref.getId());
                    }
                }
            } else {
                useHeightPref.setModeValue(appMode, newValue);
                updateUseHeightButton(useHeightButton, newValue);
            }
        }
    }).create();
    items.add(useHeightButton);
}
Also used : OnConfirmPreferenceChange(net.osmand.plus.settings.fragments.OnConfirmPreferenceChange) BaseSettingsFragment(net.osmand.plus.settings.fragments.BaseSettingsFragment) View(android.view.View) BooleanPreferenceBottomSheet.updateCustomButtonView(net.osmand.plus.settings.bottomsheets.BooleanPreferenceBottomSheet.updateCustomButtonView) TextView(android.widget.TextView) BooleanPreferenceBottomSheet.getCustomButtonView(net.osmand.plus.settings.bottomsheets.BooleanPreferenceBottomSheet.getCustomButtonView) Fragment(androidx.fragment.app.Fragment) BaseSettingsFragment(net.osmand.plus.settings.fragments.BaseSettingsFragment) MenuBottomSheetDialogFragment(net.osmand.plus.base.MenuBottomSheetDialogFragment) BottomSheetItemWithCompoundButton(net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithCompoundButton)

Example 3 with BaseSettingsFragment

use of net.osmand.plus.settings.fragments.BaseSettingsFragment in project Osmand by osmandapp.

the class SelectFolderBottomSheet method onRightBottomButtonClick.

@Override
protected void onRightBottomButtonClick() {
    Fragment fragment = getTargetFragment();
    if (fragment instanceof BaseSettingsFragment) {
        String newPath = editText.getText().toString().trim();
        if (!newPath.isEmpty()) {
            boolean pathChanged = !newPath.equals(currentPath);
            Bundle bundle = new Bundle();
            bundle.putBoolean(TAG, true);
            bundle.putString(NEW_PATH, newPath);
            bundle.putBoolean(PATH_CHANGED, pathChanged);
            ((BaseSettingsFragment) fragment).onPreferenceChange(getPreference(), bundle);
        }
    }
    dismiss();
}
Also used : Bundle(android.os.Bundle) BaseSettingsFragment(net.osmand.plus.settings.fragments.BaseSettingsFragment) BaseSettingsFragment(net.osmand.plus.settings.fragments.BaseSettingsFragment) Fragment(androidx.fragment.app.Fragment)

Example 4 with BaseSettingsFragment

use of net.osmand.plus.settings.fragments.BaseSettingsFragment in project Osmand by osmandapp.

the class MapActivity method onPreferenceStartFragment.

@Override
public boolean onPreferenceStartFragment(PreferenceFragmentCompat caller, Preference pref) {
    try {
        FragmentManager manager = getSupportFragmentManager();
        String fragmentName = pref.getFragment();
        Fragment fragment = manager.getFragmentFactory().instantiate(this.getClassLoader(), fragmentName);
        if (caller instanceof BaseSettingsFragment) {
            fragment.setArguments(((BaseSettingsFragment) caller).buildArguments());
        }
        String tag = fragment.getClass().getName();
        if (AndroidUtils.isFragmentCanBeAdded(manager, tag)) {
            manager.beginTransaction().replace(R.id.fragmentContainer, fragment, tag).addToBackStack(DRAWER_SETTINGS_ID).commitAllowingStateLoss();
            return true;
        }
    } catch (Exception e) {
        LOG.error(e);
    }
    return false;
}
Also used : FragmentManager(androidx.fragment.app.FragmentManager) BaseSettingsFragment(net.osmand.plus.settings.fragments.BaseSettingsFragment) FirstUsageWizardFragment(net.osmand.plus.firstusage.FirstUsageWizardFragment) Fragment(androidx.fragment.app.Fragment) LoginBottomSheetFragment(net.osmand.plus.measurementtool.LoginBottomSheetFragment) ImportGpxBottomSheetDialogFragment(net.osmand.plus.importfiles.ui.ImportGpxBottomSheetDialogFragment) DataStorageFragment(net.osmand.plus.settings.datastorage.DataStorageFragment) DownloadTilesFragment(net.osmand.plus.plugins.rastermaps.DownloadTilesFragment) SendAnalyticsBottomSheetDialogFragment(net.osmand.plus.dialogs.SendAnalyticsBottomSheetDialogFragment) SnapTrackWarningFragment(net.osmand.plus.measurementtool.SnapTrackWarningFragment) GpsFilterFragment(net.osmand.plus.track.fragments.GpsFilterFragment) PlanRouteFragment(net.osmand.plus.mapmarkers.PlanRouteFragment) DashBaseFragment(net.osmand.plus.dashboard.DashBaseFragment) GpxApproximationFragment(net.osmand.plus.measurementtool.GpxApproximationFragment) CrashBottomSheetDialogFragment(net.osmand.plus.dialogs.CrashBottomSheetDialogFragment) ConfigureProfileFragment(net.osmand.plus.settings.fragments.ConfigureProfileFragment) ChooseRouteFragment(net.osmand.plus.routepreparationmenu.ChooseRouteFragment) SharedStorageWarningFragment(net.osmand.plus.settings.datastorage.SharedStorageWarningFragment) TrackMenuFragment(net.osmand.plus.track.fragments.TrackMenuFragment) TrackAppearanceFragment(net.osmand.plus.track.fragments.TrackAppearanceFragment) ContextMenuCardDialogFragment(net.osmand.plus.mapcontextmenu.builders.cards.dialogs.ContextMenuCardDialogFragment) XMasDialogFragment(net.osmand.plus.dialogs.XMasDialogFragment) AdditionalActionsBottomSheetDialogFragment(net.osmand.plus.mapcontextmenu.AdditionalActionsBottomSheetDialogFragment) WhatsNewDialogFragment(net.osmand.plus.dialogs.WhatsNewDialogFragment) FirstUsageWelcomeFragment(net.osmand.plus.firstusage.FirstUsageWelcomeFragment) BaseOsmAndFragment(net.osmand.plus.base.BaseOsmAndFragment) ContextMenuFragment(net.osmand.plus.base.ContextMenuFragment) BaseSettingsFragment(net.osmand.plus.settings.fragments.BaseSettingsFragment) SecondSplashScreenFragment(net.osmand.SecondSplashScreenFragment) MeasurementToolFragment(net.osmand.plus.measurementtool.MeasurementToolFragment) QuickSearchDialogFragment(net.osmand.plus.search.QuickSearchDialogFragment)

Example 5 with BaseSettingsFragment

use of net.osmand.plus.settings.fragments.BaseSettingsFragment in project Osmand by osmandapp.

the class AllocatedRoutingMemoryBottomSheet method onRightBottomButtonClick.

@Override
protected void onRightBottomButtonClick() {
    if (isChanged()) {
        Fragment target = getTargetFragment();
        if (target instanceof BaseSettingsFragment) {
            BaseSettingsFragment fragment = (BaseSettingsFragment) target;
            fragment.onApplyPreferenceChange(preference.getId(), false, currentValue);
        }
    }
    dismiss();
}
Also used : BaseSettingsFragment(net.osmand.plus.settings.fragments.BaseSettingsFragment) Fragment(androidx.fragment.app.Fragment) BaseSettingsFragment(net.osmand.plus.settings.fragments.BaseSettingsFragment)

Aggregations

BaseSettingsFragment (net.osmand.plus.settings.fragments.BaseSettingsFragment)7 Fragment (androidx.fragment.app.Fragment)6 Bundle (android.os.Bundle)2 View (android.view.View)2 TextView (android.widget.TextView)2 BaseOsmAndFragment (net.osmand.plus.base.BaseOsmAndFragment)2 MenuBottomSheetDialogFragment (net.osmand.plus.base.MenuBottomSheetDialogFragment)2 BottomSheetItemWithCompoundButton (net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithCompoundButton)2 BooleanPreferenceBottomSheet.getCustomButtonView (net.osmand.plus.settings.bottomsheets.BooleanPreferenceBottomSheet.getCustomButtonView)2 BooleanPreferenceBottomSheet.updateCustomButtonView (net.osmand.plus.settings.bottomsheets.BooleanPreferenceBottomSheet.updateCustomButtonView)2 FragmentManager (androidx.fragment.app.FragmentManager)1 SecondSplashScreenFragment (net.osmand.SecondSplashScreenFragment)1 QuadPoint (net.osmand.data.QuadPoint)1 ContextMenuFragment (net.osmand.plus.base.ContextMenuFragment)1 DashBaseFragment (net.osmand.plus.dashboard.DashBaseFragment)1 CrashBottomSheetDialogFragment (net.osmand.plus.dialogs.CrashBottomSheetDialogFragment)1 SendAnalyticsBottomSheetDialogFragment (net.osmand.plus.dialogs.SendAnalyticsBottomSheetDialogFragment)1 WhatsNewDialogFragment (net.osmand.plus.dialogs.WhatsNewDialogFragment)1 XMasDialogFragment (net.osmand.plus.dialogs.XMasDialogFragment)1 FirstUsageWelcomeFragment (net.osmand.plus.firstusage.FirstUsageWelcomeFragment)1