[android] fix: Always show zoom buttons.

This commit is contained in:
Alexander Marchuk 2015-08-21 17:47:00 +03:00 committed by Alex Zolotarev
parent 6cc2c17303
commit 58c00ae968
60 changed files with 75 additions and 128 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 192 B

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 140 B

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 912 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 827 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 124 B

After

Width:  |  Height:  |  Size: 974 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 102 B

After

Width:  |  Height:  |  Size: 916 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 192 B

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 146 B

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

View file

@ -1,16 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:ignore="UnusedAttribute">
<item android:drawable="@drawable/btn_second_white_pressed"
android:state_pressed="true"/>
<item android:drawable="@drawable/btn_second_white_hover"
android:state_hovered="true"/>
<item android:drawable="@drawable/btn_second_white_disable"
android:state_enabled="false"/>
<item android:drawable="@drawable/btn_second_white_normal"/>
</selector>

View file

@ -2,12 +2,8 @@
<selector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:ignore="UnusedAttribute">
<item android:drawable="@drawable/btn_first_white_pressed"
<item android:drawable="@drawable/ic_zoom_in_pressed"
android:state_pressed="true"/>
<item android:drawable="@drawable/btn_first_white_hover"
android:state_hovered="true"/>
<item android:drawable="@drawable/btn_first_white_normal"/>
<item android:drawable="@drawable/ic_zoom_in"/>
</selector>

View file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:ignore="UnusedAttribute">
<item android:drawable="@drawable/ic_zoom_out_pressed"
android:state_pressed="true"/>
<item android:drawable="@drawable/ic_zoom_out"/>
</selector>

View file

@ -1,43 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/margin_navigation_buttons"
android:paddingRight="0dp"
android:paddingTop="@dimen/margin_navigation_buttons"
android:paddingBottom="@dimen/margin_navigation_buttons">
<ImageButton
android:id="@+id/yop_it"
style="@style/MwmWidget.MapButton.Zoom"
android:layout_alignParentRight="true"
android:layout_marginRight="@dimen/margin_quarter"
android:src="@drawable/ic_btn_yota_ptb"
android:visibility="gone"
tools:visibility="visible"/>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="right"
android:paddingLeft="@dimen/margin_navigation_buttons"
android:paddingRight="0dp"
android:paddingTop="@dimen/margin_navigation_buttons"
android:paddingBottom="@dimen/margin_navigation_buttons">
<ImageButton android:id="@+id/yop_it"
style="@style/MwmWidget.MapButton"
android:layout_marginRight="@dimen/margin_quarter"
android:src="@drawable/ic_btn_yota_ptb"
android:visibility="gone"
tools:visibility="visible"/>
<android.support.v4.widget.Space
android:id="@+id/space_bottom"
android:layout_width="0dp"
android:layout_height="@dimen/margin_bottom_zoom_buttons"
android:layout_alignParentBottom="true"/>
android:layout_height="0dp"
android:layout_weight="1"/>
<ImageButton
android:id="@+id/map_button_minus"
style="@style/MwmWidget.MapButton.Zoom"
android:layout_marginRight="@dimen/margin_quarter"
android:layout_above="@id/space_bottom"
android:layout_alignParentRight="true"
android:src="@drawable/ic_zoom_out"/>
<ImageButton android:id="@+id/map_button_plus"
style="@style/MwmWidget.MapButton"
android:layout_marginRight="@dimen/margin_quarter"
android:src="@drawable/zoom_in"/>
<ImageButton
android:id="@+id/map_button_plus"
style="@style/MwmWidget.MapButton.Zoom"
android:layout_marginRight="@dimen/margin_quarter"
android:layout_above="@+id/map_button_minus"
android:layout_alignParentRight="true"
android:src="@drawable/ic_zoom_in"/>
</RelativeLayout>
<ImageButton android:id="@+id/map_button_minus"
style="@style/MwmWidget.MapButton"
android:layout_marginRight="@dimen/margin_quarter"
android:src="@drawable/zoom_out"/>
</LinearLayout>

View file

@ -1,7 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="margin_bottom_zoom_buttons">250dp</dimen>
<dimen name="margin_ruler_bottom">72dp</dimen>
<dimen name="margin_compass_left">32dp</dimen>
<dimen name="margin_compass_bottom">88dp</dimen>

View file

@ -56,7 +56,9 @@
<dimen name="height_item_oneline">56dp</dimen>
<dimen name="height_item_edit_bookmark">72dp</dimen>
<dimen name="margin_bottom_zoom_buttons">150dp</dimen>
<dimen name="zoom_buttons_top_required_space">266dp</dimen>
<dimen name="zoom_buttons_bottom_max_space">240dp</dimen>
<!-- map widgets -->
<dimen name="margin_compass_left">32dp</dimen>

View file

@ -92,18 +92,12 @@
<style name="MwmWidget"/>
<style name="MwmWidget.MapButton" parent="android:Widget.ImageButton">
<style name="MwmWidget.MapButton"
parent="android:Widget.ImageButton">
<item name="android:scaleType">center</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">wrap_content</item>
</style>
<style name="MwmWidget.MapButton.White">
<item name="android:background">@drawable/bg_btn_white</item>
</style>
<style name="MwmWidget.MapButton.Zoom">
<item name="android:background">@drawable/bg_btn_zoom</item>
<item name="android:background">@null</item>
</style>
<style name="MwmWidget.Button"/>

View file

@ -6,7 +6,6 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.Configuration;
import android.graphics.Point;
import android.location.Location;
import android.os.Build;
@ -23,8 +22,8 @@ import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.Toast;
import com.mapswithme.country.ActiveCountryTree;
import com.mapswithme.country.DownloadActivity;
@ -105,6 +104,8 @@ public class MwmActivity extends BaseMwmFragmentActivity
private final StoragePathManager mPathManager = new StoragePathManager();
private AlertDialog mStorageDisconnectedDialog;
private View mFrame;
// map
private MapFragment mMapFragment;
// Place page
@ -504,6 +505,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
public void onStartRouteFollow()
{
mMainMenu.setNavigationMode(true);
adjustZoomButtons(true);
}
@Override
@ -513,6 +515,8 @@ public class MwmActivity extends BaseMwmFragmentActivity
private void initMap()
{
mFrame = findViewById(R.id.map_fragment_container);
mFadeView = (FadeView) findViewById(R.id.fade_view);
mFadeView.setListener(new FadeView.Listener()
{
@ -531,7 +535,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
.replace(R.id.map_fragment_container, mMapFragment, MapFragment.FRAGMENT_TAG)
.commit();
}
findViewById(R.id.map_fragment_container).setOnTouchListener(this);
mFrame.setOnTouchListener(this);
}
@SuppressWarnings("deprecation")
@ -947,13 +951,12 @@ public class MwmActivity extends BaseMwmFragmentActivity
listenLocationStateModeUpdates();
invalidateLocationState();
startWatchingExternalStorage();
adjustZoomButtons(Framework.nativeIsRoutingActive());
mSearchController.refreshToolbar();
mPlacePage.onResume();
LikesManager.INSTANCE.showDialogs(this);
refreshZoomButtonsAfterLayout();
mMainMenu.onResume();
}
@ -966,32 +969,32 @@ public class MwmActivity extends BaseMwmFragmentActivity
popFragment();
}
private void refreshZoomButtonsAfterLayout()
private void adjustZoomButtons(boolean routingActive)
{
mFadeView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener()
boolean show = (routingActive || MwmApplication.get().nativeGetBoolean(SettingsActivity.ZOOM_BUTTON_ENABLED, true));
UiUtils.showIf(show, mBtnZoomIn, mBtnZoomOut);
if (!show)
return;
mFrame.post(new Runnable()
{
@SuppressWarnings("deprecation")
@Override
public void onGlobalLayout()
public void run()
{
refreshZoomButtonsVisibility();
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN)
mFadeView.getViewTreeObserver().removeGlobalOnLayoutListener(this);
else
mFadeView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
int height = mFrame.getMeasuredHeight();
int top = UiUtils.dimen(R.dimen.zoom_buttons_top_required_space);
int bottom = UiUtils.dimen(R.dimen.zoom_buttons_bottom_max_space);
int space = (top + bottom < height ? bottom : height - top);
LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) mBtnZoomOut.getLayoutParams();
lp.bottomMargin = space;
mBtnZoomOut.setLayoutParams(lp);
}
});
}
private void refreshZoomButtonsVisibility()
{
final boolean showZoomSetting = MwmApplication.get().nativeGetBoolean(SettingsActivity.ZOOM_BUTTON_ENABLED, true) || Framework.nativeIsRoutingActive();
UiUtils.showIf(showZoomSetting &&
!UiUtils.areViewsIntersecting(mSearchController.getToolbar(), mBtnZoomIn) &&
!UiUtils.areViewsIntersecting(mLayoutRouting, mBtnZoomIn),
mBtnZoomIn, mBtnZoomOut);
}
@Override
protected void onPause()
{
@ -1264,43 +1267,19 @@ public class MwmActivity extends BaseMwmFragmentActivity
@Override
public void onPreviewVisibilityChanged(boolean isVisible)
{
if (isVisible)
{
if (previewIntersectsZoomButtons())
UiUtils.hide(mBtnZoomIn, mBtnZoomOut);
}
else
if (!isVisible)
{
Framework.deactivatePopup();
mPlacePage.setMapObject(null);
refreshZoomButtonsVisibility();
mMainMenu.show(true);
}
}
private static boolean previewIntersectsZoomButtons()
{
return (!UiUtils.isBigTablet() && !UiUtils.isSmallTablet());
}
@Override
public void onPlacePageVisibilityChanged(boolean isVisible)
{
if (isVisible)
{
AlohaHelper.logClick(AlohaHelper.PP_OPEN);
if (placePageIntersectsZoomButtons())
UiUtils.hide(mBtnZoomIn, mBtnZoomOut);
else
refreshZoomButtonsVisibility();
}
else
AlohaHelper.logClick(AlohaHelper.PP_CLOSE);
}
private boolean placePageIntersectsZoomButtons()
{
return !(UiUtils.isBigTablet() || (UiUtils.isSmallTablet() && getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE));
AlohaHelper.logClick(isVisible ? AlohaHelper.PP_OPEN
: AlohaHelper.PP_CLOSE);
}
@Override
@ -1338,8 +1317,8 @@ public class MwmActivity extends BaseMwmFragmentActivity
private void closeRouting()
{
mLayoutRouting.setState(RoutingLayout.State.HIDDEN, true);
refreshZoomButtonsVisibility();
mMainMenu.setNavigationMode(false);
adjustZoomButtons(false);
}
@Override
@ -1390,16 +1369,13 @@ public class MwmActivity extends BaseMwmFragmentActivity
public void onDownload()
{
mLayoutRouting.setState(RoutingLayout.State.HIDDEN, false);
refreshZoomButtonsVisibility();
ActiveCountryTree.downloadMapsForIndex(missingCountries, StorageOptions.MAP_OPTION_MAP_AND_CAR_ROUTING);
showDownloader(true);
}
@Override
public void onCancel()
{
refreshZoomButtonsVisibility();
}
{}
@Override
public void onOk()
@ -1407,15 +1383,12 @@ public class MwmActivity extends BaseMwmFragmentActivity
if (RoutingResultCodesProcessor.isDownloadable(resultCode))
{
mLayoutRouting.setState(RoutingLayout.State.HIDDEN, false);
refreshZoomButtonsVisibility();
showDownloader(false);
}
}
});
fragment.show(getSupportFragmentManager(), RoutingErrorDialogFragment.class.getName());
}
refreshZoomButtonsVisibility();
}
});
}