Update animation

This commit is contained in:
Victor Shcherb 2015-03-25 23:52:51 +01:00
parent 07086316f7
commit 0e6face6ff
8 changed files with 106 additions and 101 deletions

View file

@ -29,12 +29,4 @@
<include layout="@layout/check_item_rel" />
<ImageView
android:id="@+id/sort"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:layout_marginRight="8dp" />
</LinearLayout>

View file

@ -47,10 +47,7 @@ public abstract class ActionBarPreferenceActivity extends PreferenceActivity {
shadowView = null;
}
tb.setClickable(true);
Drawable back = getResources().getDrawable(R.drawable.abc_ic_ab_back_mtrl_am_alpha);
back.mutate();
back.setColorFilter(0xffffffff, PorterDuff.Mode.MULTIPLY);
tb.setNavigationIcon(back);
tb.setNavigationIcon(((OsmandApplication)getApplication()).getIconsCache().getActionBarIcon(R.drawable.abc_ic_ab_back_mtrl_am_alpha));
tb.setBackgroundColor(getResources().getColor(getResIdFromAttribute(this, R.attr.pstsTabBackground)));
tb.setTitleTextColor(getResources().getColor(getResIdFromAttribute(this, R.attr.pstsTextColor)));
tb.setNavigationOnClickListener(new View.OnClickListener() {

View file

@ -5,6 +5,7 @@ import android.graphics.drawable.Drawable;
import android.support.v7.app.ActionBarActivity;
import android.view.View;
import android.view.ViewGroup;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
/**
@ -17,7 +18,7 @@ public class OsmandActionBarActivity extends ActionBarActivity {
//should be called after set content view
protected void setupHomeButton(){
Drawable back = getResources().getDrawable(R.drawable.abc_ic_ab_back_mtrl_am_alpha);
Drawable back = ((OsmandApplication)getApplication()).getIconsCache().getActionBarIcon(R.drawable.abc_ic_ab_back_mtrl_am_alpha);
back.setColorFilter(getResources().getColor(R.color.color_white), PorterDuff.Mode.MULTIPLY);
getSupportActionBar().setHomeButtonEnabled(true);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);

View file

@ -145,8 +145,7 @@ public class SettingsActivity extends SettingsBaseActivity {
ll.setOrientation(LinearLayout.VERTICAL);
Toolbar tb = new Toolbar(this);
tb.setClickable(true);
Drawable back = getResources().getDrawable(R.drawable.abc_ic_ab_back_mtrl_am_alpha);
back.setColorFilter(app.getResources().getColor(R.color.color_white), PorterDuff.Mode.MULTIPLY);
Drawable back = ((OsmandApplication)getApplication()).getIconsCache().getActionBarIcon(R.drawable.abc_ic_ab_back_mtrl_am_alpha);
tb.setNavigationIcon(back);
tb.setTitle(R.string.about_settings);
tb.setBackgroundColor(getResources().getColor( getResIdFromAttribute(this, R.attr.pstsTabBackground)));

View file

@ -35,10 +35,13 @@ import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.widget.Toolbar;
import android.util.DisplayMetrics;
import android.view.Gravity;
import android.view.View;
@ -64,8 +67,6 @@ import com.github.ksoichiro.android.observablescrollview.ScrollState;
import com.software.shell.fab.ActionButton;
/**
* Created by Denis
* on 03.03.15.
*/
public class DashboardOnMap implements ObservableScrollViewCallbacks {
@ -101,6 +102,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
private WaypointDialogHelper waypointDialogHelper;
private final int[] running = new int[] { -1 };
private List<LocationPointWrapper> deletedPoints = new ArrayList<LocationPointWrapper>();
private Drawable gradientToolbar;
public enum DashboardType {
WAYPOINTS,
@ -136,12 +138,13 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
updateTopButton(sy);
}
});
gradientToolbar = mapActivity.getResources().getDrawable(R.drawable.gradient_toolbar).mutate();
if (ScreenOrientationHelper.isOrientationPortrait(mapActivity)) {
((ObservableListView) listView).setScrollViewCallbacks(this);
mFlexibleSpaceImageHeight = mapActivity.getResources().getDimensionPixelSize(
R.dimen.dashboard_map_top_padding);
// Set padding view for ListView. This is the flexible space.
paddingView = new View(mapActivity);
paddingView = new View(mapActivity);
AbsListView.LayoutParams lp = new AbsListView.LayoutParams(AbsListView.LayoutParams.MATCH_PARENT,
mFlexibleSpaceImageHeight);
paddingView.setLayoutParams(lp);
@ -206,6 +209,8 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
ImageView lst = (ImageView) dashboardView.findViewById(R.id.toolbar_list);
lst.setVisibility(View.GONE);
ImageView back = (ImageView) dashboardView.findViewById(R.id.toolbar_back);
back.setImageDrawable(
((OsmandApplication)getMyApplication()).getIconsCache().getActionBarIcon(R.drawable.abc_ic_ab_back_mtrl_am_alpha));
back.setOnClickListener(new View.OnClickListener() {
@Override
@ -233,7 +238,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
@Override
public void onClick(View v) {
setDashboardVisibility(true, flatNow ? DashboardType.WAYPOINTS : DashboardType.WAYPOINTS_FLAT,
previousVisibleType);
previousVisibleType, false);
}
});
}
@ -268,7 +273,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
public void onClick(View v) {
Class<? extends Activity> sta = mapActivity.getMyApplication().getAppCustomization()
.getSettingsActivity();
visible = false;
hideDashboard(false);
mapActivity.startActivity(new Intent(mapActivity, sta));
}
});
@ -282,9 +287,9 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
@Override
public void onClick(View v) {
if (visibleType == DashboardType.DASHBOARD) {
setDashboardVisibility(true, DashboardType.LIST_MENU, null);
setDashboardVisibility(true, DashboardType.LIST_MENU, null, true);
} else {
setDashboardVisibility(true, DashboardType.DASHBOARD, null);
setDashboardVisibility(true, DashboardType.DASHBOARD, null, true);
}
}
});
@ -358,11 +363,17 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
public void hideDashboard() {
setDashboardVisibility(false, visibleType);
}
public void setDashboardVisibility(boolean visible, DashboardType type) {
setDashboardVisibility(visible, type, this.visible ? visibleType : null);
public void hideDashboard(boolean animation) {
setDashboardVisibility(false, visibleType, animation);
}
public void setDashboardVisibility(boolean visible, DashboardType type, DashboardType prevItem) {
public void setDashboardVisibility(boolean visible, DashboardType type) {
setDashboardVisibility(visible, type, this.visible ? visibleType : null, true);
}
public void setDashboardVisibility(boolean visible, DashboardType type, boolean animation) {
setDashboardVisibility(visible, type, this.visible ? visibleType : null, animation);
}
public void setDashboardVisibility(boolean visible, DashboardType type, DashboardType prevItem, boolean animation) {
if(visible == this.visible && type == visibleType) {
return;
}
@ -400,12 +411,11 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
updateToolbarActions();
//fabButton.showFloatingActionButton();
open(dashboardView.findViewById(R.id.animateContent));
open(dashboardView.findViewById(R.id.animateContent), animation);
updateLocation(true, true, false);
} else {
mapActivity.getMapViewTrackingUtilities().setDashboard(null);
hide(dashboardView.findViewById(R.id.animateContent));
hide(dashboardView.findViewById(R.id.animateContent), animation);
mapActivity.findViewById(R.id.MapHudButtonsOverlay).setVisibility(View.VISIBLE);
actionButton.hide();
for (WeakReference<DashBaseFragment> df : fragList) {
@ -518,7 +528,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
@Override
public void onClick(View v) {
hideDashboard();
hideDashboard(false);
final Intent intent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization()
.getDownloadIndexActivity());
intent.putExtra(DownloadActivity.FILTER_KEY, f.toString());
@ -555,36 +565,46 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
// To animate view slide out from right to left
private void open(View view){
TranslateAnimation animate = new TranslateAnimation(-mapActivity.findViewById(R.id.MapHudButtonsOverlay).getWidth(),0,0,0);
animate.setDuration(500);
animate.setFillAfter(true);
view.startAnimation(animate);
view.setVisibility(View.VISIBLE);
private void open(View view, boolean animation) {
if (animation) {
TranslateAnimation animate = new TranslateAnimation(-mapActivity.findViewById(R.id.MapHudButtonsOverlay)
.getWidth(), 0, 0, 0);
animate.setDuration(500);
animate.setFillAfter(true);
view.startAnimation(animate);
view.setVisibility(View.VISIBLE);
} else {
view.setVisibility(View.VISIBLE);
}
}
private void hide(View view) {
TranslateAnimation animate = new TranslateAnimation(0, -mapActivity.findViewById(R.id.MapHudButtonsOverlay).getWidth(), 0, 0);
animate.setDuration(500);
animate.setFillAfter(true);
animate.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
dashboardView.setVisibility(View.GONE);
}
});
view.startAnimation(animate);
private void hide(View view, boolean animation) {
if(!animation) {
dashboardView.setVisibility(View.GONE);
} else {
TranslateAnimation animate = new TranslateAnimation(0, -mapActivity.findViewById(R.id.MapHudButtonsOverlay)
.getWidth(), 0, 0);
animate.setDuration(500);
animate.setFillAfter(true);
animate.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
dashboardView.setVisibility(View.GONE);
}
});
view.startAnimation(animate);
}
view.setVisibility(View.GONE);
}
@ -728,27 +748,44 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
@Override
public void onScrollChanged(int scrollY, boolean firstScroll, boolean dragging) {
// Translate list background
if(listBackgroundView != null) {
if (listBackgroundView != null) {
setTranslationY(listBackgroundView, Math.max(0, -scrollY + mFlexibleSpaceImageHeight));
}
updateTopButton(scrollY);
}
private void updateTopButton(int scrollY) {
float t = mFlexibleSpaceImageHeight == 0 ? 1 : 1 - Math.max(0, -scrollY + mFlexibleSpaceImageHeight)
/ ((float) mFlexibleSpaceImageHeight);
if(t > 0.75) {
t = 1;
}
int clr = (((int) (t * 255)) << 24) | 0xff8f00;
paddingView.setBackgroundColor(clr);
if (listBackgroundView != null) {
dashboardView.findViewById(R.id.map_part_dashboard).setBackgroundColor(clr);
}
if (t != 1) {
((Toolbar) dashboardView.findViewById(R.id.toolbar)).setBackgroundDrawable(gradientToolbar);
} else {
((Toolbar) dashboardView.findViewById(R.id.toolbar)).setBackgroundColor(clr);
}
if (actionButton != null) {
double scale = mapActivity.getResources().getDisplayMetrics().density;
int originalPosition = (int) (160 * scale);
int minTop = (int) (65 * scale);
FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) actionButton.getLayoutParams();
if(minTop > originalPosition - scrollY) {
if (minTop > originalPosition - scrollY) {
actionButton.hide();
} else {
actionButton.show();
lp.topMargin = originalPosition - scrollY;
((FrameLayout) actionButton.getParent()).updateViewLayout(actionButton, lp);
}
}
}

View file

@ -11,7 +11,6 @@ import net.osmand.plus.IconsCache;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.activities.IntermediatePointsDialog;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.helpers.WaypointHelper.LocationPointWrapper;
import net.osmand.plus.poi.PoiLegacyFilter;
@ -23,15 +22,12 @@ import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.DialogInterface.OnDismissListener;
import android.os.AsyncTask;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.FragmentActivity;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.CompoundButton;
import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;
@ -96,12 +92,6 @@ public class WaypointDialogHelper {
// 0);
}
private FrameLayout.LayoutParams getDialogLayoutParams() {
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT);
params.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL;
return params;
}
public ArrayAdapter<Object> getWaypointsDrawerAdapter(
final boolean edit, final List<LocationPointWrapper> deletedPoints,
@ -145,7 +135,7 @@ public class WaypointDialogHelper {
if (v == null || v.findViewById(R.id.info_close) == null) {
v = ctx.getLayoutInflater().inflate(R.layout.waypoint_reached, null);
}
updatePointInfoView(app, ctx, v, point, false);
updatePointInfoView(app, ctx, v, point, true);
View remove = v.findViewById(R.id.info_close);
if (!edit) {
remove.setVisibility(View.GONE);
@ -189,23 +179,7 @@ public class WaypointDialogHelper {
protected View createItemForCategory(final FragmentActivity ctx, final int type, final int[] running,
final int position, final ArrayAdapter<Object> thisAdapter) {
View v;
IconsCache iconsCache = app.getIconsCache();
v = ctx.getLayoutInflater().inflate(R.layout.waypoint_header, null);
ImageView sort = (ImageView) v.findViewById(R.id.sort);
//sort button in Destination header
if (type == 0 && sort != null && app.getTargetPointsHelper().getIntermediatePoints().size() > 0) {
sort.setVisibility(View.VISIBLE);
sort.setImageDrawable(iconsCache.getContentIcon(R.drawable.ic_sort_waypoint_dark));
sort.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
IntermediatePointsDialog.openIntermediatePointsDialog(ctx, app, true);
}
});
} else {
sort.setVisibility(View.GONE);
}
final CompoundButton btn = (CompoundButton) v.findViewById(R.id.check_item);
btn.setVisibility(waypointHelper.isTypeConfigurable(type) ? View.VISIBLE : View.GONE);
btn.setOnCheckedChangeListener(null);
@ -303,8 +277,8 @@ public class WaypointDialogHelper {
if (listAdapter.getItem(item) instanceof LocationPointWrapper) {
LocationPointWrapper ps = (LocationPointWrapper) listAdapter.getItem(item);
showOnMap(app, ctx, ps.getPoint(), false);
} else if (new Integer(WaypointHelper.TARGETS).equals(listAdapter.getItem(item))) {
IntermediatePointsDialog.openIntermediatePointsDialog(ctx, app, true);
// } else if (new Integer(WaypointHelper.TARGETS).equals(listAdapter.getItem(item))) {
// IntermediatePointsDialog.openIntermediatePointsDialog(ctx, app, true);
} else if (listAdapter.getItem(item) instanceof RadiusItem) {
selectDifferentRadius(((RadiusItem) listAdapter.getItem(item)).type, running, item, listAdapter,
ctx);
@ -393,9 +367,7 @@ public class WaypointDialogHelper {
if (!rc && i != WaypointHelper.WAYPOINTS && i != WaypointHelper.TARGETS) {
// skip
} else if (waypointHelper.isTypeVisible(i)) {
if (i != WaypointHelper.TARGETS) {
points.add(new Integer(i));
}
points.add(new Integer(i));
if ((i == WaypointHelper.POI || i == WaypointHelper.FAVORITES || i == WaypointHelper.WAYPOINTS)
&& rc) {
if (waypointHelper.isTypeEnabled(i)) {
@ -439,11 +411,14 @@ public class WaypointDialogHelper {
} else {
thread.startMoving(flat, flon, fZoom, true);
}
// ctx.getMapLayers().getContextMenuLayer().setSelectedObject(locationPoint);
// ctx.getMapLayers()
// .getContextMenuLayer()
// .setLocation(new LatLon(locationPoint.getLatitude(), locationPoint.getLongitude()),
// PointDescription.getSimpleName(locationPoint, ctx));
if(ctx.getDashboard().isVisible()) {
ctx.getDashboard().hideDashboard();
ctx.getMapLayers().getContextMenuLayer().setSelectedObject(locationPoint);
ctx.getMapLayers()
.getContextMenuLayer()
.setLocation(new LatLon(locationPoint.getLatitude(), locationPoint.getLongitude()),
PointDescription.getSimpleName(locationPoint, ctx));
}
}
}

View file

@ -259,8 +259,8 @@ public class EditingPOIDialogProvider implements DialogProvider {
final AutoCompleteTextView value = new AutoCompleteTextView(activity);
final Button delete = new Button(activity);
tag.setDropDownWidth(ViewGroup.LayoutParams.WRAP_CONTENT);
value.setDropDownWidth(ViewGroup.LayoutParams.WRAP_CONTENT);
tag.setDropDownWidth(ViewGroup.LayoutParams.MATCH_PARENT);
value.setDropDownWidth(ViewGroup.LayoutParams.MATCH_PARENT);
tag.setLayoutParams(tlp);
if(tg != null) {
tag.setText(tg);

View file

@ -517,11 +517,14 @@ public class RouteInfoWidgetsFactory {
private OsmandApplication app;
private int dist;
private LanesDrawable lanesDrawable;
private View centerInfo;
private View progress;
public LanesControl(final MapActivity map, final OsmandMapTileView view) {
lanesView = (ImageView) map.findViewById(R.id.map_lanes);
lanesText = (TextView) map.findViewById(R.id.map_lanes_dist_text);
centerInfo = (View) map.findViewById(R.id.map_center_info);
progress = (View) map.findViewById(R.id.map_horizontal_progress);
lanesDrawable = new LanesDrawable(map, map.getMapView().getScaleCoefficient());
lanesView.setImageDrawable(lanesDrawable);
trackingUtilities = map.getMapViewTrackingUtilities();
@ -603,6 +606,7 @@ public class RouteInfoWidgetsFactory {
}
updateVisibility(lanesText, visible);
updateVisibility(lanesView, visible);
updateVisibility(centerInfo, visible || progress.getVisibility() == View.VISIBLE);
return true;
}
}