Add previous and next icons
This commit is contained in:
parent
073463f64a
commit
39b5b3e0b2
3 changed files with 36 additions and 11 deletions
|
@ -14,6 +14,7 @@ import android.support.v4.content.ContextCompat;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.TypedValue;
|
import android.util.TypedValue;
|
||||||
import android.view.GestureDetector;
|
import android.view.GestureDetector;
|
||||||
|
import android.view.Gravity;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.VelocityTracker;
|
import android.view.VelocityTracker;
|
||||||
|
@ -735,10 +736,10 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
|
||||||
if (leftTitleButtonController.visible) {
|
if (leftTitleButtonController.visible) {
|
||||||
leftTitleButtonView.setVisibility(View.VISIBLE);
|
leftTitleButtonView.setVisibility(View.VISIBLE);
|
||||||
Drawable leftIcon = leftTitleButtonController.getLeftIcon();
|
Drawable leftIcon = leftTitleButtonController.getLeftIcon();
|
||||||
if (leftIcon != null) {
|
Drawable rightIcon = leftTitleButtonController.getRightIcon();
|
||||||
leftTitleButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, null, null);
|
leftTitleButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, rightIcon, null);
|
||||||
leftTitleButton.setCompoundDrawablePadding(dpToPx(8f));
|
leftTitleButton.setCompoundDrawablePadding(dpToPx(8f));
|
||||||
}
|
((LinearLayout) leftTitleButtonView).setGravity(rightIcon != null ? Gravity.END : Gravity.START);
|
||||||
|
|
||||||
if (leftTitleButtonController.needRightText) {
|
if (leftTitleButtonController.needRightText) {
|
||||||
titleButtonRightText.setText(leftTitleButtonController.rightTextCaption);
|
titleButtonRightText.setText(leftTitleButtonController.rightTextCaption);
|
||||||
|
@ -762,8 +763,10 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
|
||||||
rightTitleButtonView.setVisibility(rightTitleButtonController.visible ? View.VISIBLE : View.INVISIBLE);
|
rightTitleButtonView.setVisibility(rightTitleButtonController.visible ? View.VISIBLE : View.INVISIBLE);
|
||||||
|
|
||||||
Drawable leftIcon = rightTitleButtonController.getLeftIcon();
|
Drawable leftIcon = rightTitleButtonController.getLeftIcon();
|
||||||
rightTitleButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, null, null);
|
Drawable rightIcon = rightTitleButtonController.getRightIcon();
|
||||||
|
rightTitleButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, rightIcon, null);
|
||||||
rightTitleButton.setCompoundDrawablePadding(dpToPx(8f));
|
rightTitleButton.setCompoundDrawablePadding(dpToPx(8f));
|
||||||
|
((LinearLayout) rightTitleButtonView).setGravity(rightIcon != null ? Gravity.END : Gravity.START);
|
||||||
} else {
|
} else {
|
||||||
rightTitleButtonView.setVisibility(View.INVISIBLE);
|
rightTitleButtonView.setVisibility(View.INVISIBLE);
|
||||||
}
|
}
|
||||||
|
@ -776,8 +779,10 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
|
||||||
bottomTitleButtonView.setVisibility(bottomTitleButtonController.visible ? View.VISIBLE : View.GONE);
|
bottomTitleButtonView.setVisibility(bottomTitleButtonController.visible ? View.VISIBLE : View.GONE);
|
||||||
|
|
||||||
Drawable leftIcon = bottomTitleButtonController.getLeftIcon();
|
Drawable leftIcon = bottomTitleButtonController.getLeftIcon();
|
||||||
bottomTitleButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, null, null);
|
Drawable rightIcon = bottomTitleButtonController.getRightIcon();
|
||||||
|
bottomTitleButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, rightIcon, null);
|
||||||
bottomTitleButton.setCompoundDrawablePadding(dpToPx(8f));
|
bottomTitleButton.setCompoundDrawablePadding(dpToPx(8f));
|
||||||
|
((LinearLayout) bottomTitleButtonView).setGravity(rightIcon != null ? Gravity.END : Gravity.START);
|
||||||
} else {
|
} else {
|
||||||
bottomTitleButtonView.setVisibility(View.GONE);
|
bottomTitleButtonView.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
@ -798,10 +803,10 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
|
||||||
leftDownloadButtonView.setVisibility(leftDownloadButtonController.visible ? View.VISIBLE : View.INVISIBLE);
|
leftDownloadButtonView.setVisibility(leftDownloadButtonController.visible ? View.VISIBLE : View.INVISIBLE);
|
||||||
|
|
||||||
Drawable leftIcon = leftDownloadButtonController.getLeftIcon();
|
Drawable leftIcon = leftDownloadButtonController.getLeftIcon();
|
||||||
if (leftIcon != null) {
|
Drawable rightIcon = leftDownloadButtonController.getRightIcon();
|
||||||
leftDownloadButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, null, null);
|
leftDownloadButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, rightIcon, null);
|
||||||
leftDownloadButton.setCompoundDrawablePadding(dpToPx(8f));
|
leftDownloadButton.setCompoundDrawablePadding(dpToPx(8f));
|
||||||
}
|
((LinearLayout) leftDownloadButtonView).setGravity(rightIcon != null ? Gravity.END : Gravity.START);
|
||||||
} else {
|
} else {
|
||||||
leftDownloadButtonView.setVisibility(View.INVISIBLE);
|
leftDownloadButtonView.setVisibility(View.INVISIBLE);
|
||||||
}
|
}
|
||||||
|
@ -814,8 +819,10 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
|
||||||
rightDownloadButtonView.setVisibility(rightDownloadButtonController.visible ? View.VISIBLE : View.INVISIBLE);
|
rightDownloadButtonView.setVisibility(rightDownloadButtonController.visible ? View.VISIBLE : View.INVISIBLE);
|
||||||
|
|
||||||
Drawable leftIcon = rightDownloadButtonController.getLeftIcon();
|
Drawable leftIcon = rightDownloadButtonController.getLeftIcon();
|
||||||
rightDownloadButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, null, null);
|
Drawable rightIcon = rightDownloadButtonController.getRightIcon();
|
||||||
|
rightDownloadButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, rightIcon, null);
|
||||||
rightDownloadButton.setCompoundDrawablePadding(dpToPx(8f));
|
rightDownloadButton.setCompoundDrawablePadding(dpToPx(8f));
|
||||||
|
((LinearLayout) rightDownloadButtonView).setGravity(rightIcon != null ? Gravity.END : Gravity.START);
|
||||||
} else {
|
} else {
|
||||||
rightDownloadButtonView.setVisibility(View.INVISIBLE);
|
rightDownloadButtonView.setVisibility(View.INVISIBLE);
|
||||||
}
|
}
|
||||||
|
|
|
@ -531,11 +531,13 @@ public abstract class MenuController extends BaseMenuController {
|
||||||
public abstract class TitleButtonController {
|
public abstract class TitleButtonController {
|
||||||
public String caption = "";
|
public String caption = "";
|
||||||
public int leftIconId = 0;
|
public int leftIconId = 0;
|
||||||
|
public int rightIconId = 0;
|
||||||
public boolean needRightText = false;
|
public boolean needRightText = false;
|
||||||
public String rightTextCaption = "";
|
public String rightTextCaption = "";
|
||||||
public boolean visible = true;
|
public boolean visible = true;
|
||||||
public boolean needColorizeIcon = true;
|
public boolean needColorizeIcon = true;
|
||||||
public Drawable leftIcon;
|
public Drawable leftIcon;
|
||||||
|
public Drawable rightIcon;
|
||||||
|
|
||||||
public Drawable getLeftIcon() {
|
public Drawable getLeftIcon() {
|
||||||
if (leftIcon != null) {
|
if (leftIcon != null) {
|
||||||
|
@ -551,6 +553,20 @@ public abstract class MenuController extends BaseMenuController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Drawable getRightIcon() {
|
||||||
|
if (rightIcon != null) {
|
||||||
|
return rightIcon;
|
||||||
|
}
|
||||||
|
if (rightIconId != 0) {
|
||||||
|
if (needColorizeIcon) {
|
||||||
|
return getIcon(rightIconId, isLight() ? R.color.map_widget_blue : R.color.osmand_orange);
|
||||||
|
}
|
||||||
|
return ContextCompat.getDrawable(getMapActivity(), rightIconId);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public abstract void buttonPressed();
|
public abstract void buttonPressed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,6 +58,7 @@ public class TransportRouteController extends MenuController {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
leftTitleButtonController.caption = mapActivity.getString(R.string.shared_string_previous);
|
leftTitleButtonController.caption = mapActivity.getString(R.string.shared_string_previous);
|
||||||
|
leftTitleButtonController.leftIconId = R.drawable.ic_arrow_back;
|
||||||
|
|
||||||
rightTitleButtonController = new TitleButtonController() {
|
rightTitleButtonController = new TitleButtonController() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -69,6 +70,7 @@ public class TransportRouteController extends MenuController {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
rightTitleButtonController.caption = mapActivity.getString(R.string.shared_string_next);
|
rightTitleButtonController.caption = mapActivity.getString(R.string.shared_string_next);
|
||||||
|
rightTitleButtonController.rightIconId = R.drawable.ic_arrow_forward;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue