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.util.TypedValue;
|
||||
import android.view.GestureDetector;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.VelocityTracker;
|
||||
|
@ -735,10 +736,10 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
|
|||
if (leftTitleButtonController.visible) {
|
||||
leftTitleButtonView.setVisibility(View.VISIBLE);
|
||||
Drawable leftIcon = leftTitleButtonController.getLeftIcon();
|
||||
if (leftIcon != null) {
|
||||
leftTitleButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, null, null);
|
||||
Drawable rightIcon = leftTitleButtonController.getRightIcon();
|
||||
leftTitleButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, rightIcon, null);
|
||||
leftTitleButton.setCompoundDrawablePadding(dpToPx(8f));
|
||||
}
|
||||
((LinearLayout) leftTitleButtonView).setGravity(rightIcon != null ? Gravity.END : Gravity.START);
|
||||
|
||||
if (leftTitleButtonController.needRightText) {
|
||||
titleButtonRightText.setText(leftTitleButtonController.rightTextCaption);
|
||||
|
@ -762,8 +763,10 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
|
|||
rightTitleButtonView.setVisibility(rightTitleButtonController.visible ? View.VISIBLE : View.INVISIBLE);
|
||||
|
||||
Drawable leftIcon = rightTitleButtonController.getLeftIcon();
|
||||
rightTitleButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, null, null);
|
||||
Drawable rightIcon = rightTitleButtonController.getRightIcon();
|
||||
rightTitleButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, rightIcon, null);
|
||||
rightTitleButton.setCompoundDrawablePadding(dpToPx(8f));
|
||||
((LinearLayout) rightTitleButtonView).setGravity(rightIcon != null ? Gravity.END : Gravity.START);
|
||||
} else {
|
||||
rightTitleButtonView.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
|
@ -776,8 +779,10 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
|
|||
bottomTitleButtonView.setVisibility(bottomTitleButtonController.visible ? View.VISIBLE : View.GONE);
|
||||
|
||||
Drawable leftIcon = bottomTitleButtonController.getLeftIcon();
|
||||
bottomTitleButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, null, null);
|
||||
Drawable rightIcon = bottomTitleButtonController.getRightIcon();
|
||||
bottomTitleButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, rightIcon, null);
|
||||
bottomTitleButton.setCompoundDrawablePadding(dpToPx(8f));
|
||||
((LinearLayout) bottomTitleButtonView).setGravity(rightIcon != null ? Gravity.END : Gravity.START);
|
||||
} else {
|
||||
bottomTitleButtonView.setVisibility(View.GONE);
|
||||
}
|
||||
|
@ -798,10 +803,10 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
|
|||
leftDownloadButtonView.setVisibility(leftDownloadButtonController.visible ? View.VISIBLE : View.INVISIBLE);
|
||||
|
||||
Drawable leftIcon = leftDownloadButtonController.getLeftIcon();
|
||||
if (leftIcon != null) {
|
||||
leftDownloadButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, null, null);
|
||||
Drawable rightIcon = leftDownloadButtonController.getRightIcon();
|
||||
leftDownloadButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, rightIcon, null);
|
||||
leftDownloadButton.setCompoundDrawablePadding(dpToPx(8f));
|
||||
}
|
||||
((LinearLayout) leftDownloadButtonView).setGravity(rightIcon != null ? Gravity.END : Gravity.START);
|
||||
} else {
|
||||
leftDownloadButtonView.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
|
@ -814,8 +819,10 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
|
|||
rightDownloadButtonView.setVisibility(rightDownloadButtonController.visible ? View.VISIBLE : View.INVISIBLE);
|
||||
|
||||
Drawable leftIcon = rightDownloadButtonController.getLeftIcon();
|
||||
rightDownloadButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, null, null);
|
||||
Drawable rightIcon = rightDownloadButtonController.getRightIcon();
|
||||
rightDownloadButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, rightIcon, null);
|
||||
rightDownloadButton.setCompoundDrawablePadding(dpToPx(8f));
|
||||
((LinearLayout) rightDownloadButtonView).setGravity(rightIcon != null ? Gravity.END : Gravity.START);
|
||||
} else {
|
||||
rightDownloadButtonView.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
|
|
|
@ -531,11 +531,13 @@ public abstract class MenuController extends BaseMenuController {
|
|||
public abstract class TitleButtonController {
|
||||
public String caption = "";
|
||||
public int leftIconId = 0;
|
||||
public int rightIconId = 0;
|
||||
public boolean needRightText = false;
|
||||
public String rightTextCaption = "";
|
||||
public boolean visible = true;
|
||||
public boolean needColorizeIcon = true;
|
||||
public Drawable leftIcon;
|
||||
public Drawable rightIcon;
|
||||
|
||||
public Drawable getLeftIcon() {
|
||||
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();
|
||||
}
|
||||
|
||||
|
|
|
@ -58,6 +58,7 @@ public class TransportRouteController extends MenuController {
|
|||
}
|
||||
};
|
||||
leftTitleButtonController.caption = mapActivity.getString(R.string.shared_string_previous);
|
||||
leftTitleButtonController.leftIconId = R.drawable.ic_arrow_back;
|
||||
|
||||
rightTitleButtonController = new TitleButtonController() {
|
||||
@Override
|
||||
|
@ -69,6 +70,7 @@ public class TransportRouteController extends MenuController {
|
|||
}
|
||||
};
|
||||
rightTitleButtonController.caption = mapActivity.getString(R.string.shared_string_next);
|
||||
rightTitleButtonController.rightIconId = R.drawable.ic_arrow_forward;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue