Fix empty space on bottom map screen

This commit is contained in:
Vitaliy 2020-01-02 11:58:05 +02:00
parent c6ba5159b7
commit 594ed86b60
3 changed files with 24 additions and 44 deletions

View file

@ -1,6 +1,7 @@
package net.osmand.plus.activities;
import android.Manifest;
import android.annotation.TargetApi;
import android.app.Activity;
import android.app.AlarmManager;
import android.app.Dialog;
@ -37,6 +38,7 @@ import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewStub;
import android.view.ViewTreeObserver;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ProgressBar;
@ -373,14 +375,32 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
mIsDestroyed = false;
}
public void exitFromFullScreen() {
public void exitFromFullScreen(View view) {
runLayoutListener(view);
AndroidUtils.exitFromFullScreen(this);
}
public void enterToFullScreen() {
runLayoutListener(getLayout());
AndroidUtils.enterToFullScreen(this);
}
private void runLayoutListener(final View view) {
if (view != null) {
ViewTreeObserver vto = view.getViewTreeObserver();
vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
@Override
public void onGlobalLayout() {
ViewTreeObserver obs = view.getViewTreeObserver();
obs.removeOnGlobalLayoutListener(this);
view.requestLayout();
}
});
}
}
@Override
protected void onSaveInstanceState(Bundle outState) {
if (removeFragment(PlanRouteFragment.TAG)) {

View file

@ -1,6 +1,5 @@
package net.osmand.plus.base;
import android.annotation.TargetApi;
import android.app.Activity;
import android.graphics.drawable.Drawable;
import android.os.Build;
@ -14,13 +13,12 @@ import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.content.ContextCompat;
import android.view.View;
import android.view.ViewTreeObserver;
import android.view.animation.Animation;
import android.widget.ImageView;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.OsmandActionBarActivity;
import net.osmand.plus.activities.OsmandInAppPurchaseActivity;
@ -47,25 +45,7 @@ public class BaseOsmAndFragment extends Fragment implements TransitionAnimator {
}
}
if (!isFullScreenAllowed() && 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();
((MapActivity) activity).exitFromFullScreen(getView());
}
}
}

View file

@ -1,7 +1,6 @@
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;
@ -36,7 +35,6 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CompoundButton;
import android.view.ViewTreeObserver;
import android.widget.ImageView;
import android.widget.TextView;
@ -231,25 +229,7 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
}
}
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();
((MapActivity) activity).exitFromFullScreen(getView());
}
}
}