Merge pull request #4706 from osmandapp/change_statusbar
Add small fixes; do not hide status bar with map controls
This commit is contained in:
commit
107ba0257f
7 changed files with 43 additions and 29 deletions
|
@ -249,38 +249,50 @@ public class AndroidUtils {
|
|||
return new PointF(centroidX, centroidY);
|
||||
}
|
||||
|
||||
public static void showSystemUI(Activity activity) {
|
||||
if (Build.VERSION.SDK_INT >= 19 && !isSystemUiVisible(activity)) {
|
||||
switchSystemUiVisibility(activity);
|
||||
public static void showNavBar(Activity activity) {
|
||||
if (Build.VERSION.SDK_INT >= 19 && !isNavBarVisible(activity)) {
|
||||
switchNavBarVisibility(activity);
|
||||
}
|
||||
}
|
||||
|
||||
public static void hideSystemUI(Activity activity) {
|
||||
if (Build.VERSION.SDK_INT >= 19 && isSystemUiVisible(activity)) {
|
||||
switchSystemUiVisibility(activity);
|
||||
public static void hideNavBar(Activity activity) {
|
||||
if (Build.VERSION.SDK_INT >= 19 && isNavBarVisible(activity)) {
|
||||
switchNavBarVisibility(activity);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isSystemUiVisible(Activity activity) {
|
||||
public static boolean isNavBarVisible(Activity activity) {
|
||||
if (Build.VERSION.SDK_INT >= 19) {
|
||||
int uiOptions = activity.getWindow().getDecorView().getSystemUiVisibility();
|
||||
return !((uiOptions | View.SYSTEM_UI_FLAG_FULLSCREEN) == uiOptions);
|
||||
return !((uiOptions | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == uiOptions);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void switchSystemUiVisibility(Activity activity) {
|
||||
public static void switchNavBarVisibility(Activity activity) {
|
||||
if (Build.VERSION.SDK_INT < 19) {
|
||||
return;
|
||||
}
|
||||
View decorView = activity.getWindow().getDecorView();
|
||||
int uiOptions = decorView.getSystemUiVisibility();
|
||||
uiOptions ^= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
|
||||
uiOptions ^= View.SYSTEM_UI_FLAG_FULLSCREEN;
|
||||
uiOptions ^= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
|
||||
decorView.setSystemUiVisibility(uiOptions);
|
||||
}
|
||||
|
||||
public static void enterToFullScreen(Activity activity) {
|
||||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
activity.getWindow().getDecorView()
|
||||
.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
|
||||
}
|
||||
}
|
||||
|
||||
public static void exitFromFullScreen(Activity activity) {
|
||||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
public static <K, V extends Comparable<? super V>> Map<K, V> sortByValue(Map<K, V> map) {
|
||||
List<Map.Entry<K, V>> list = new LinkedList<>(map.entrySet());
|
||||
Collections.sort(list, new Comparator<Map.Entry<K, V>>() {
|
||||
|
|
|
@ -2,6 +2,7 @@ package net.osmand;
|
|||
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.res.Configuration;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.Fragment;
|
||||
|
@ -116,7 +117,7 @@ public class SecondSplashScreenFragment extends Fragment {
|
|||
textLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
|
||||
textLayoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
|
||||
int defaultLogoMarginTop = (int) getResources().getDimension(R.dimen.splash_screen_logo_top);
|
||||
int logoMarginTop = defaultLogoMarginTop - getStatusBarHeight();
|
||||
int logoMarginTop = defaultLogoMarginTop - (Build.VERSION.SDK_INT >= 21 ? 0 : getStatusBarHeight());
|
||||
int logoPaddingLeft = 0;
|
||||
int logoPaddingRight = 0;
|
||||
int defaultTextMarginBottom = (int) getResources().getDimension(R.dimen.splash_screen_text_bottom);
|
||||
|
|
|
@ -328,15 +328,11 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
|||
}
|
||||
|
||||
public void exitFromFullScreen() {
|
||||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
|
||||
}
|
||||
AndroidUtils.exitFromFullScreen(this);
|
||||
}
|
||||
|
||||
public void enterToFullScreen() {
|
||||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
|
||||
}
|
||||
AndroidUtils.enterToFullScreen(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -835,8 +831,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
|||
}
|
||||
boolean night = app.getDaynightHelper().isNightModeForMapControls();
|
||||
boolean mapTopBar = findViewById(R.id.map_top_bar).getVisibility() == View.VISIBLE;
|
||||
boolean markerTopBar = mapLayers.getMapMarkersLayer() != null
|
||||
&& mapLayers.getMapMarkersLayer().getWidgetsFactory().isTopBarVisible();
|
||||
boolean markerTopBar = findViewById(R.id.map_markers_top_bar).getVisibility() == View.VISIBLE;
|
||||
if (mapTopBar) {
|
||||
colorId = night ? R.color.status_bar_route_dark : R.color.status_bar_route_light;
|
||||
} else if (markerTopBar) {
|
||||
|
|
|
@ -37,6 +37,7 @@ import net.osmand.plus.OsmandSettings;
|
|||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.Version;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.base.BaseOsmAndFragment;
|
||||
import net.osmand.plus.download.DownloadActivity;
|
||||
import net.osmand.plus.download.DownloadActivityType;
|
||||
import net.osmand.plus.download.DownloadIndexesThread;
|
||||
|
@ -64,7 +65,7 @@ import java.util.Map;
|
|||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
public class FirstUsageWizardFragment extends Fragment implements OsmAndLocationListener,
|
||||
public class FirstUsageWizardFragment extends BaseOsmAndFragment implements OsmAndLocationListener,
|
||||
AppInitializeListener, DownloadEvents {
|
||||
public static final String TAG = "FirstUsageWizardFrag";
|
||||
public static final int FIRST_USAGE_LOCATION_PERMISSION = 300;
|
||||
|
@ -449,6 +450,11 @@ public class FirstUsageWizardFragment extends Fragment implements OsmAndLocation
|
|||
((MapActivity)getActivity()).enableDrawer();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isFullScreenAllowed() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateLocation(final Location loc) {
|
||||
final OsmandApplication app = getMyApplication();
|
||||
|
@ -908,10 +914,6 @@ public class FirstUsageWizardFragment extends Fragment implements OsmAndLocation
|
|||
}
|
||||
}
|
||||
|
||||
private OsmandApplication getMyApplication() {
|
||||
return (OsmandApplication) getActivity().getApplication();
|
||||
}
|
||||
|
||||
private static void logError(String msg, Throwable e) {
|
||||
Log.e(TAG, "Error: " + msg, e);
|
||||
}
|
||||
|
|
|
@ -383,7 +383,7 @@ public class PlanRouteFragment extends BaseOsmAndFragment implements OsmAndLocat
|
|||
@Override
|
||||
public int getStatusBarColorId() {
|
||||
if (fullScreen || !portrait) {
|
||||
return nightMode ? R.color.status_bar_dark : R.color.status_bar_route_light;
|
||||
return nightMode ? R.color.actionbar_dark_color : R.color.status_bar_route_light;
|
||||
}
|
||||
return R.color.status_bar_transparent_gradient;
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ import android.support.v4.app.Fragment;
|
|||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.app.FragmentPagerAdapter;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v4.content.FileProvider;
|
||||
import android.support.v4.view.ViewPager;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
|
@ -419,6 +420,9 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
|||
);
|
||||
|
||||
toolbar = (Toolbar) view.findViewById(R.id.toolbar);
|
||||
if (!app.getSettings().isLightContent()) {
|
||||
toolbar.setBackgroundColor(ContextCompat.getColor(mapActivity, R.color.actionbar_dark_color));
|
||||
}
|
||||
toolbar.setNavigationIcon(app.getIconsCache().getThemedIcon(R.drawable.ic_arrow_back));
|
||||
toolbar.setNavigationContentDescription(R.string.access_shared_string_navigate_up);
|
||||
toolbar.setNavigationOnClickListener(
|
||||
|
|
|
@ -658,7 +658,7 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
|
||||
public void showMapControls() {
|
||||
mapActivity.findViewById(R.id.MapHudButtonsOverlay).setVisibility(View.VISIBLE);
|
||||
AndroidUtils.showSystemUI(mapActivity);
|
||||
AndroidUtils.showNavBar(mapActivity);
|
||||
}
|
||||
|
||||
public void hideMapControls() {
|
||||
|
@ -674,7 +674,7 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
return mapActivity.findViewById(R.id.MapHudButtonsOverlay).getVisibility() == View.VISIBLE;
|
||||
}
|
||||
|
||||
public void switchMapControlsVisibility(boolean switchSystemUiVisibility) {
|
||||
public void switchMapControlsVisibility(boolean switchNavBarVisibility) {
|
||||
if (app.getRoutingHelper().isFollowingMode() || app.getRoutingHelper().isPauseNavigation()
|
||||
|| mapActivity.getMeasurementToolFragment() != null
|
||||
|| mapActivity.getPlanRouteFragment() != null
|
||||
|
@ -683,8 +683,8 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
}
|
||||
if (isMapControlsVisible()) {
|
||||
hideMapControls();
|
||||
if (switchSystemUiVisibility) {
|
||||
AndroidUtils.hideSystemUI(mapActivity);
|
||||
if (switchNavBarVisibility) {
|
||||
AndroidUtils.hideNavBar(mapActivity);
|
||||
}
|
||||
} else {
|
||||
showMapControls();
|
||||
|
|
Loading…
Reference in a new issue