Cancel and Save buttons appear above keyboard
This commit is contained in:
parent
39a02f2eb2
commit
bc0ef56fba
3 changed files with 44 additions and 11 deletions
|
@ -1060,7 +1060,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
|||
private BaseSettingsFragment getVisibleBaseSettingsFragment(int... ids) {
|
||||
for (int id : ids) {
|
||||
Fragment fragment = getSupportFragmentManager().findFragmentById(id);
|
||||
if (fragment != null && !fragment.isRemoving() && fragment.isVisible() && fragment instanceof BaseSettingsFragment
|
||||
if (fragment != null && !fragment.isRemoving() && fragment instanceof BaseSettingsFragment
|
||||
&& ((BaseSettingsFragment) fragment).getStatusBarColorId() != -1) {
|
||||
return (BaseSettingsFragment) fragment;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package net.osmand.plus.settings;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
@ -34,6 +35,7 @@ import android.support.v7.widget.RecyclerView;
|
|||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
|
@ -142,7 +144,6 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
|
|||
updateTheme();
|
||||
View view = super.onCreateView(inflater, container, savedInstanceState);
|
||||
if (view != null) {
|
||||
AndroidUtils.addStatusBarPadding21v(getContext(), view);
|
||||
if (getPreferenceScreen() != null) {
|
||||
PreferenceManager prefManager = getPreferenceManager();
|
||||
PreferenceScreen preferenceScreen = prefManager.inflateFromResource(prefManager.getContext(), currentScreenType.preferencesResId, null);
|
||||
|
@ -228,6 +229,27 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
|
|||
activity.getWindow().setStatusBarColor(ContextCompat.getColor(activity, colorId));
|
||||
}
|
||||
}
|
||||
if (activity instanceof MapActivity) {
|
||||
View view = getView();
|
||||
if (view != null) {
|
||||
ViewTreeObserver vto = view.getViewTreeObserver();
|
||||
vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
|
||||
@Override
|
||||
public void onGlobalLayout() {
|
||||
|
||||
View view = getView();
|
||||
if (view != null) {
|
||||
ViewTreeObserver obs = view.getViewTreeObserver();
|
||||
obs.removeOnGlobalLayoutListener(this);
|
||||
view.requestLayout();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
((MapActivity) activity).exitFromFullScreen();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -236,17 +258,19 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
|
|||
public void onPause() {
|
||||
super.onPause();
|
||||
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (!wasDrawerDisabled && mapActivity != null) {
|
||||
mapActivity.enableDrawer();
|
||||
Activity activity = getActivity();
|
||||
if (activity != null) {
|
||||
if (!wasDrawerDisabled && activity instanceof MapActivity) {
|
||||
((MapActivity) activity).enableDrawer();
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
Activity activity = getActivity();
|
||||
if (activity != null) {
|
||||
if (!(activity instanceof MapActivity) && statusBarColor != -1) {
|
||||
activity.getWindow().setStatusBarColor(statusBarColor);
|
||||
}
|
||||
if (!isFullScreenAllowed() && activity instanceof MapActivity) {
|
||||
((MapActivity) activity).enterToFullScreen();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -343,6 +367,10 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
|
|||
}
|
||||
}
|
||||
|
||||
protected boolean isFullScreenAllowed() {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected abstract void setupPreferences();
|
||||
|
||||
protected void onBindPreferenceViewHolder(Preference preference, PreferenceViewHolder holder) {
|
||||
|
|
|
@ -149,8 +149,8 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment {
|
|||
|
||||
AndroidUtils.setBackground(getContext(), buttonsContainer, isNightMode(), R.color.list_background_color_light, R.color.list_background_color_dark);
|
||||
|
||||
UiUtilities.setupDialogButton(false, cancelButton, DialogButtonType.SECONDARY, R.string.shared_string_cancel);
|
||||
UiUtilities.setupDialogButton(false, saveButton, DialogButtonType.PRIMARY, R.string.shared_string_save);
|
||||
UiUtilities.setupDialogButton(isNightMode(), cancelButton, DialogButtonType.SECONDARY, R.string.shared_string_cancel);
|
||||
UiUtilities.setupDialogButton(isNightMode(), saveButton, DialogButtonType.PRIMARY, R.string.shared_string_save);
|
||||
|
||||
cancelButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
@ -177,6 +177,11 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment {
|
|||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isFullScreenAllowed() {
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isChanged() {
|
||||
return !profile.equals(changedProfile);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue