Commit fd158993 by Lee Jaebin

#32576 作業指示ボタンの改善(ピン表示)

#32574 拡大状態でも作業指示・報告画面表示
parent d6f01a25
......@@ -7,6 +7,16 @@
android:background="@color/transparent">
<ImageButton
android:id="@+id/btn_pin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="2px"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:background="@drawable/ic_hidden_show_directions_button"
android:visibility="visible"/>
<ImageButton
android:id="@+id/btn_hide_task_direct"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
......
......@@ -775,11 +775,6 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
*/
protected void onActionProjectPdfWebView(Map<String, String> checkParam, ProjectTaskDto projectTaskDto) {}
/**
* Be override
*/
public Point convertToAuthoringPoint(float x, float y) { return new Point((int)x, (int)y); }
public void onClickShowHelpView(View v) {
int helpViewType = 0;
switch (mStatusCode) {
......
......@@ -20,6 +20,7 @@ import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Point;
import android.graphics.PointF;
import android.graphics.RectF;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
......@@ -156,6 +157,8 @@ import jp.agentec.abook.abv.ui.viewer.view.ABVMediaPlayer;
import jp.agentec.abook.abv.ui.viewer.view.Action3DImageView;
import jp.agentec.abook.abv.ui.viewer.view.ActionButton;
import jp.agentec.abook.abv.ui.viewer.view.ActionImageView;
import jp.agentec.abook.abv.ui.viewer.view.ActionProjectTaskCode;
import jp.agentec.abook.abv.ui.viewer.view.ActionProjectTaskPin;
import jp.agentec.abook.abv.ui.viewer.view.EnqueteLayout;
import jp.agentec.abook.abv.ui.viewer.view.EnqueteWebView;
import jp.agentec.abook.abv.ui.viewer.view.FullVideoView;
......@@ -271,6 +274,7 @@ public class ContentViewActivity extends ABVContentViewActivity {
private LinearLayout mScaleZoomLayout;
private boolean isOpenedProjectTask = false;
private TaskHotspotJSON mTaskHotspotJSON;
protected ImageButton btnChangePin;
protected ImageButton btnHideTaskDirectBtn;
protected ImageButton btnScaleZoomPlus;
protected ImageButton btnScaleZoom03;
......@@ -328,6 +332,8 @@ public class ContentViewActivity extends ABVContentViewActivity {
private ProgressBar m_progress;
public ValueCallback<Uri[]> mUploadMessage;
public boolean mShowPinFlg = true;
/**
* スクロールステータス
......@@ -4995,11 +5001,6 @@ public class ContentViewActivity extends ABVContentViewActivity {
projectTaskLayout.currentLayout = mShowPageLayout.get(currentPageNum);
}
@Override
public Point convertToAuthoringPoint(float x, float y) {
return projectTaskLayout.convertToAuthoringPoint(x, y);
}
// 作業のホットスポットJSONを取得
private void getTaskHotspotJSON() {
try {
......@@ -5032,7 +5033,16 @@ public class ContentViewActivity extends ABVContentViewActivity {
mScaleZoomLayout.setVisibility(View.VISIBLE);
mMainLayout.addView(mScaleZoomLayout, params);
btnChangePin = (ImageButton) mScaleZoomLayout.findViewById(id.btn_pin);
btnChangePin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mShowPinFlg = !mShowPinFlg;
changeTaskPinOrCode(mShowPinFlg);
}
});
btnChangePin.setVisibility(View.VISIBLE);
btnHideTaskDirectBtn = (ImageButton) mScaleZoomLayout.findViewById(R.id.btn_hide_task_direct);
btnHideTaskDirectBtn.setOnTouchListener(new View.OnTouchListener() {
@Override
......@@ -5127,7 +5137,7 @@ public class ContentViewActivity extends ABVContentViewActivity {
projectTaskLayout.setIconStatus(taskKey, true);
projectTaskLayout.currentTaskDto.taskKey = taskKey;
projectTaskLayout.currentTaskDto.taskCode = taskCode;
projectTaskLayout.addProjectTaskIcon(this, projectTaskLayout.currentLayout, projectTaskLayout.currentTaskDto);
projectTaskLayout.addProjectTaskIcon(this, projectTaskLayout.currentLayout, projectTaskLayout.currentTaskDto, mShowPinFlg);
//hideProjectTaskLayout();
break;
case ABookKeys.CMD_DELETE_TASK_DIRECTIONS:
......@@ -5184,6 +5194,25 @@ public class ContentViewActivity extends ABVContentViewActivity {
isOpenedProjectTask = isHide;
}
/**
* 作業のアイコンをピン・作業コードに切替
* @param isShowPin
*/
public void changeTaskPinOrCode(boolean isShowPin) {
for (int i = 0; i < mShowPageLayout.size(); i++) {
int key = mShowPageLayout.keyAt(i);
ZoomRelativeLayout zoomRelativeLayout = mShowPageLayout.get(key);
for (int j = 0; j < zoomRelativeLayout.getChildCount(); j++) {
View view = zoomRelativeLayout.getChildAt(j);
if (view instanceof ActionProjectTaskCode || view instanceof ActionProjectTaskPin) {
zoomRelativeLayout.removeView(view);
}
}
List<ProjectTaskDto> tasks = mTaskHotspotJSON.getPageTasks(i);
projectTaskLayout.addAllProjectTaskIcon(this, zoomRelativeLayout, tasks);
}
}
@Override
public void showTaskList() {
projectTaskLayout.showTaskList(mCurrentPageNumber, isNormalSize());
......@@ -5236,7 +5265,7 @@ public class ContentViewActivity extends ABVContentViewActivity {
DisplayMetrics displayMetrics = getResources().getDisplayMetrics();
int centerX = displayMetrics.widthPixels / 2;
int centerY = displayMetrics.widthPixels / 2;
int centerY = displayMetrics.heightPixels / 2;
ViewMargin margin = zoomLayout.getContentPageMargin();
Matrix matrix = new Matrix();
......
......@@ -10,7 +10,10 @@ import android.view.animation.Animation;
import android.view.animation.LinearInterpolator;
import android.widget.TextView;
import jp.agentec.abook.abv.bl.dto.ProjectTaskDto;
import jp.agentec.abook.abv.cl.util.PreferenceUtil;
import jp.agentec.abook.abv.launcher.android.R;
import jp.agentec.abook.abv.ui.common.appinfo.AppDefType;
/**
* Created by seo-y on 2018/11/15.
......@@ -20,20 +23,22 @@ public class ActionProjectTaskCode extends TextView {
public String taskKey;
private boolean isAnimated = false;
private Animation animation;
private Context mContext;
public ProjectTaskDto mProjectTaskDto;
public ActionProjectTaskCode(final Context context, final String text, boolean isFinished) {
public ActionProjectTaskCode(final Context context, final ProjectTaskDto dto) {
super(context);
mContext = context;
mProjectTaskDto = dto;
setSingleLine(true);
setEllipsize(TextUtils.TruncateAt.END);
setText(text);
setText(dto.taskCode);
setTextColor(Color.WHITE);
setTypeface(null, Typeface.BOLD);
setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);
setBackgroundResource(R.drawable.shape_hotspot);
setPadding(15,5,15,5);
if (isFinished) {
setBackgroundResource(R.drawable.shape_hotspot);
if (dto.isFinished) {
setBackgroundColor(ProjectTaskLayout.COLOR_BLUE);
} else {
setBackgroundColor(ProjectTaskLayout.COLOR_ORANGE);
......
package jp.agentec.abook.abv.ui.viewer.view;
import android.content.Context;
import android.graphics.Color;
import android.graphics.Typeface;
import android.text.TextUtils;
import android.util.TypedValue;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.LinearInterpolator;
import android.widget.ImageView;
import jp.agentec.abook.abv.bl.dto.ProjectTaskDto;
import jp.agentec.abook.abv.launcher.android.R;
/**
* Created by leej on 2019/02/25.
*/
public class ActionProjectTaskPin extends ImageView {
public String taskKey;
private boolean isAnimated = false;
private Context mContext;
private Animation animation;
public ProjectTaskDto mProjectTaskDto;
public ActionProjectTaskPin(final Context context, final ProjectTaskDto dto) {
super(context);
mContext = context;
mProjectTaskDto = dto;
if (mProjectTaskDto.isFinished) {
setImageResource(R.drawable.s_pin2);
} else {
setImageResource(R.drawable.s_pin1);
}
setBackgroundColor(Color.TRANSPARENT);
setAdjustViewBounds(true);
setScaleType(ScaleType.FIT_START);
}
public void stopAnimation() {
if (this.isAnimated) {
this.clearAnimation();
this.isAnimated = false;
}
}
public void startBlinkAnimation() {
if (animation == null) {
animation = new AlphaAnimation(1, 0);
animation.setDuration(1000);
animation.setInterpolator(new LinearInterpolator());
animation.setRepeatCount(Animation.INFINITE);
animation.setRepeatMode(Animation.REVERSE);
}
this.startAnimation(animation);
this.isAnimated = true;
}
}
......@@ -4,6 +4,7 @@ import android.content.ClipData;
import android.content.Context;
import android.graphics.Color;
import android.graphics.Point;
import android.graphics.PointF;
import android.net.Uri;
import android.util.DisplayMetrics;
import android.view.MotionEvent;
......@@ -28,8 +29,11 @@ import jp.agentec.abook.abv.bl.data.dao.AbstractDao;
import jp.agentec.abook.abv.bl.data.dao.TaskDao;
import jp.agentec.abook.abv.bl.dto.ProjectTaskDto;
import jp.agentec.abook.abv.bl.dto.TaskDto;
import jp.agentec.abook.abv.cl.util.PreferenceUtil;
import jp.agentec.abook.abv.launcher.android.R;
import jp.agentec.abook.abv.ui.common.activity.ABVActivity;
import jp.agentec.abook.abv.ui.common.activity.ABVContentViewActivity;
import jp.agentec.abook.abv.ui.common.appinfo.AppDefType;
import jp.agentec.abook.abv.ui.viewer.activity.ContentViewActivity;
import jp.agentec.adf.util.StringUtil;
......@@ -49,6 +53,13 @@ public class ProjectTaskLayout extends RelativeLayout {
private static final int ICON_WIDTH = 32;
private static final int ICON_HEIGHT = 32;
// 仮)ピンのイメージアイコンのサイズ
private static final int PIN_ICON_WIDTH = 20;
private static final int PIN_ICON_HEIGHT = 40;
// 仮)終了のピンのイメージアイコンのサイズ
private static final int PIN_FINISHED_ICON_WIDTH = 20;
private static final int PIN_FINISHED_ICON_HEIGHT = 40;
private static final int CODE_WIDTH = 46;
private static final int CODE_HEIGHT = 26;
......@@ -156,58 +167,76 @@ public class ProjectTaskLayout extends RelativeLayout {
});
}
public void addProjectTaskIcon(final Context context, final ZoomRelativeLayout rootLayout, final ProjectTaskDto dto) {
public void addProjectTaskIcon(final Context context, final ZoomRelativeLayout rootLayout, final ProjectTaskDto dto, boolean isShowPin) {
RelativeLayout.LayoutParams params;
final float density = context.getResources().getDisplayMetrics().density;
View taskView;
int width;
int height;
if(dto.taskCode == null || dto.taskCode.isEmpty()) {
Logger.d(TAG, String.format("[ActionProjectTaskIcon] : taskCode=%s, dto.pdfX:%f, dto.pdfY=%f", dto.taskCode, dto.pdfX, dto.pdfY));
final ActionProjectTaskIcon taskIcon = new ActionProjectTaskIcon(context);
taskIcon.startBlinkAnimation();
taskIcon.taskKey = dto.taskKey;
Point pointView = rootLayout.convertToViewPoint(dto.pdfX, dto.pdfY);
PointF pointView = rootLayout.convertToViewPoint(dto.pdfX, dto.pdfY);
int width = (int) (ICON_WIDTH * density);
int height = (int) (ICON_HEIGHT * density);
int marginLeft = (int)(pointView.x - (width / 2));
int marginTop = (int)(pointView.y - (height / 2));
width = (int) (ICON_WIDTH * density);
height = (int) (ICON_HEIGHT * density);
params = new RelativeLayout.LayoutParams(width, height);
params.setMargins(marginLeft, marginTop, 0, 0);
taskIcon.setTranslationX(pointView.x - (width / 2));
taskIcon.setTranslationY(pointView.y - (height / 2));
rootLayout.addView(taskIcon, params);
taskView = taskIcon;
} else {
final ActionProjectTaskCode taskCode = new ActionProjectTaskCode(context, dto.taskCode, dto.isFinished);
//taskCode.startBlinkAnimation();
taskCode.taskKey = dto.taskKey;
final Point pointView = rootLayout.convertToViewPoint(dto.pdfX, dto.pdfY);
final int width = (int) (CODE_WIDTH * density);
final int height = (int) (CODE_HEIGHT * density);
params = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, height);
taskCode.setLayoutParams(params);
taskCode.setVisibility(View.INVISIBLE);
rootLayout.addView(taskCode, params);
final PointF pointView = rootLayout.convertToViewPoint(dto.pdfX, dto.pdfY);
if (isShowPin) {
final ActionProjectTaskPin taskPin = new ActionProjectTaskPin(context, dto);
taskPin.taskKey = dto.taskKey;
if (dto.isFinished) {
width = (int) (PIN_FINISHED_ICON_WIDTH * density);
height = (int) (PIN_FINISHED_ICON_HEIGHT * density);
} else {
width = (int) (PIN_ICON_WIDTH * density);
height = (int) (PIN_ICON_HEIGHT * density);
}
taskView = taskCode;
params = new RelativeLayout.LayoutParams(width, height);
taskPin.setVisibility(View.INVISIBLE);
rootLayout.addView(taskPin, params);
taskCode.post(new Runnable() {
@Override
public void run() {
Logger.d(TAG, String.format("[ActionProjectTaskCode] : taskCode=%s, CODE_WIDTH=%d, fX=%d, fY=%d", dto.taskCode, CODE_WIDTH, pointView.x, pointView.y));
int realWidth = taskCode.getWidth(); //height is ready, sometimes realWidth = 0
ViewGroup.MarginLayoutParams margin = (ViewGroup.MarginLayoutParams)taskCode.getLayoutParams();
margin.leftMargin = (int)(pointView.x - ((realWidth > 0 ? realWidth : width) / 2));
margin.topMargin = (int)(pointView.y - (height / 2));
taskCode.setLayoutParams(new RelativeLayout.LayoutParams(margin));
taskCode.setVisibility(View.VISIBLE);
}
});
taskPin.setTranslationX(pointView.x - (width / 2));
taskPin.setTranslationY(pointView.y - height);
taskPin.setVisibility(View.VISIBLE);
taskView = taskPin;
} else {
final ActionProjectTaskCode taskCode = new ActionProjectTaskCode(context, dto);
//taskCode.startBlinkAnimation();
taskCode.taskKey = dto.taskKey;
final int postWidth = (int) (CODE_WIDTH * density);
final int postHeight = (int) (CODE_HEIGHT * density);
params = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, postHeight);
taskCode.setLayoutParams(params);
taskCode.setVisibility(View.INVISIBLE);
rootLayout.addView(taskCode, params);
taskView = taskCode;
taskCode.post(new Runnable() {
@Override
public void run() {
Logger.d(TAG, String.format("[ActionProjectTaskCode] : taskCode=%s, CODE_WIDTH=%d, fX=%d, fY=%d", dto.taskCode, CODE_WIDTH, (int) pointView.x, (int) pointView.y));
int realWidth = taskCode.getWidth(); //height is ready, sometimes realWidth = 0
taskCode.setTranslationX(pointView.x - ((realWidth > 0 ? realWidth : postWidth) / 2));
taskCode.setTranslationY(pointView.y - (postHeight / 2));
taskCode.setVisibility(View.VISIBLE);
}
});
}
}
if (rootLayout.isEnableProjectTaskNewOrMove()) {
......@@ -240,7 +269,7 @@ public class ProjectTaskLayout extends RelativeLayout {
public void addAllProjectTaskIcon(Context context, final ZoomRelativeLayout rootLayout, final List<ProjectTaskDto> dto) {
for (ProjectTaskDto task : dto) {
task.isFinished = isTaskFinished(task.taskKey);
addProjectTaskIcon(context, rootLayout, task);
addProjectTaskIcon(context, rootLayout, task, ((ContentViewActivity)context).mShowPinFlg);
}
}
......@@ -278,7 +307,7 @@ public class ProjectTaskLayout extends RelativeLayout {
public void showTaskForm(final Context context, ZoomRelativeLayout layout, int mXWalkOpenType, ProjectTaskDto projectTaskDto, boolean isNormalSize, float clickX) {
if (projectTaskDto.taskKey.equals(TEMP_TASK_KEY)) {
addProjectTaskIcon(context, layout, projectTaskDto);
addProjectTaskIcon(context, layout, projectTaskDto, ((ContentViewActivity)context).mShowPinFlg);
setTaskFormPosition(clickX, isNormalSize);
}
......@@ -401,7 +430,7 @@ public class ProjectTaskLayout extends RelativeLayout {
if (currentTaskDto != null && !StringUtil.isNullOrEmpty(currentTaskDto.taskKey)) {
if (currentTaskDto.taskKey.equals(TEMP_TASK_KEY)) {
addProjectTaskIcon(context, currentLayout, currentTaskDto);
addProjectTaskIcon(context, currentLayout, currentTaskDto, ((ContentViewActivity)context).mShowPinFlg);
} else {
if (context.getOpenedProjestTask()) {
setTaskCodeBlinkAnimation(currentTaskDto.taskKey, true);
......@@ -423,6 +452,16 @@ public class ProjectTaskLayout extends RelativeLayout {
}
break;
}
} else if (v instanceof ActionProjectTaskPin) {
ActionProjectTaskPin code = (ActionProjectTaskPin) v;
if (code.taskKey.equals(taskKey)) {
if (isBlink) {
code.startBlinkAnimation();
} else {
code.stopAnimation();
}
break;
}
}
}
}
......@@ -453,6 +492,20 @@ public class ProjectTaskLayout extends RelativeLayout {
}
break;
}
} else if (v instanceof ActionProjectTaskPin) {
ActionProjectTaskPin icon = (ActionProjectTaskPin) v;
if (icon.taskKey.equals(TEMP_TASK_KEY) || icon.taskKey.equals(taskKey)) {
icon.stopAnimation();
if (isTaskFinished(taskKey)) {
icon.setBackgroundColor(ProjectTaskLayout.COLOR_BLUE);
} else {
icon.setBackgroundColor(ProjectTaskLayout.COLOR_ORANGE);
}
if (isDelete || icon.taskKey.equals(TEMP_TASK_KEY)) {
currentLayout.removeView(v);
}
break;
}
}
}
}
......@@ -466,11 +519,17 @@ public class ProjectTaskLayout extends RelativeLayout {
} else {
view.setVisibility(View.VISIBLE);
}
} else if (view instanceof ActionProjectTaskPin) {
if (isHide) {
view.setVisibility(View.INVISIBLE);
} else {
view.setVisibility(View.VISIBLE);
}
}
}
}
public Point convertToAuthoringPoint(float x, float y) {
public PointF convertToAuthoringPoint(float x, float y) {
return currentLayout.convertToAuthoringPoint(x, y);
}
......
......@@ -139,15 +139,17 @@ public class ZoomRelativeLayout extends RelativeLayout {
mY = margin.top + getDefaultPDFHeight();
}
ViewGroup.MarginLayoutParams marginDrop = (ViewGroup.MarginLayoutParams)view.getLayoutParams();
marginDrop.leftMargin = (int) (mX - width / 2);
marginDrop.topMargin = (int) (mY - height / 2);
view.setLayoutParams(marginDrop);
Point pdfPoint = convertToAuthoringPoint(mX, mY);
// ViewGroup.MarginLayoutParams marginDrop = (ViewGroup.MarginLayoutParams)view.getLayoutParams();
// marginDrop.leftMargin = (int) (mX - width / 2);
// marginDrop.topMargin = (int) (mY - height / 2);
// view.setLayoutParams(marginDrop);
view.setTranslationX(mX - width / 2);
view.setTranslationY(mY - height / 2);
// ピンの場合、Yをピンの先に合わせるため、mY + height / 2で座標をセットする
PointF pdfPoint = tapConvertToAuthoringPoint(mX, ((ContentViewActivity) mContext).mShowPinFlg ? mY + height / 2 : mY);
((ContentViewActivity) mContext).updateProjectTaskPosition(pdfPoint.x, pdfPoint.y);
if (view instanceof ActionProjectTaskCode) {
if (view instanceof ActionProjectTaskCode || view instanceof ActionProjectTaskPin) {
((ContentViewActivity) mContext).updateProjectTaskPosition();
}
......@@ -185,7 +187,7 @@ public class ZoomRelativeLayout extends RelativeLayout {
@Override
protected void dispatchDraw(Canvas canvas) {
canvas.save(Canvas.MATRIX_SAVE_FLAG);
canvas.concat(imgMatrix);
// canvas.concat(imgMatrix);
super.dispatchDraw(canvas);
canvas.restore();
}
......@@ -272,7 +274,7 @@ public class ZoomRelativeLayout extends RelativeLayout {
mLastTouchX = x;
mLastTouchY = y;
changeTaskChildView();
break;
}
......@@ -317,7 +319,7 @@ public class ZoomRelativeLayout extends RelativeLayout {
private PageView getPageView() {
ViewGroup parenGroup = (ViewGroup) getParent();
if (mPageView == null) {
if (mPageView == null && parenGroup != null) {
for (int i = 0; i < parenGroup.getChildCount(); i++) {
View view = parenGroup.getChildAt(i);
if (!view.equals(this) && view instanceof PageView) {
......@@ -328,7 +330,41 @@ public class ZoomRelativeLayout extends RelativeLayout {
}
}
return mPageView;
}
private void changeTaskChildView() {
if (getChildCount() > 0) {
for (int i = 0; i < getChildCount(); i++) {
View view = getChildAt(i);
if (view instanceof ActionProjectTaskCode) {
setTaskTranslation((ActionProjectTaskCode) view);
} else if (view instanceof ActionProjectTaskPin) {
setTaskTranslation((ActionProjectTaskPin) view);
}
}
}
}
/**
* ActionProjectTaskCodeのx,y座標をセット
* @param view
*/
private void setTaskTranslation(ActionProjectTaskCode view) {
ProjectTaskDto dto = view.mProjectTaskDto;
PointF point = convertToAuthoringPoint(dto.pdfX, dto.pdfY);
view.setTranslationX(point.x - (view.getWidth() / 2));
view.setTranslationY(point.y - (view.getHeight() / 2));
}
/**
* ActionProjectTaskPinのx,y座標をセット
* @param view
*/
private void setTaskTranslation(ActionProjectTaskPin view) {
ProjectTaskDto dto = view.mProjectTaskDto;
PointF point = convertToAuthoringPoint(dto.pdfX, dto.pdfY);
view.setTranslationX(point.x - (view.getWidth() / 2));
view.setTranslationY(point.y - view.getHeight());
}
@Override
......@@ -456,6 +492,7 @@ public class ZoomRelativeLayout extends RelativeLayout {
mScaleFactor = matrixScale;
invalidate();
}
changeTaskChildView();
Logger.v(TAG, "SimpleOnScaleGestureListener:[onScale]:scaleFactor=%s", mScaleFactor);
return super.onScale(detector);
......@@ -580,6 +617,7 @@ public class ZoomRelativeLayout extends RelativeLayout {
matrixValue[Matrix.MTRANS_Y] = matrixY;
imgMatrix.setValues(matrixValue);
invalidate();
changeTaskChildView();
Logger.v(TAG, "[fixPosition]invalidate");
}
Logger.v(TAG, "[fixPosition][after]x=%s, y=%s", matrixValue[Matrix.MTRANS_X], matrixValue[Matrix.MTRANS_Y]);
......@@ -599,9 +637,9 @@ public class ZoomRelativeLayout extends RelativeLayout {
for (int i = 0; i < listMemo.size(); i++) {
// アイコン追加
ContentMemoDto dto = listMemo.get(i);
Point point = convertToAuthoringPoint(dto.axisX, dto.axisY);
dto.viewX = point.x;
dto.viewY = point.y;
PointF point = convertToAuthoringPoint(dto.axisX, dto.axisY);
dto.viewX = (int) point.x;
dto.viewY = (int) point.y;
MemoManager.addMemoIcon(this, dto);
}
}
......@@ -624,12 +662,12 @@ public class ZoomRelativeLayout extends RelativeLayout {
// }
/**
* オブジェクトの位置調整
* タップのx,y座標をPDFに合わせて変換
* @param x
* @param y
* @return
*/
public Point convertToAuthoringPoint(float x, float y) {
public PointF tapConvertToAuthoringPoint(float x, float y) {
float[] pdfMatrix = getMatrixValue(getPageView().imgMatrix);
float pdfScale = pdfMatrix[0];
......@@ -641,24 +679,44 @@ public class ZoomRelativeLayout extends RelativeLayout {
float pdfX = (x * scaleX) - (matrixX * scaleX);
float pdfY = (y * scaleY) - (matrixY * scaleY);
Point point = new Point((int)pdfX, (int)pdfY);
return point;
return new PointF((int)pdfX, (int)pdfY);
}
public Point convertToViewPoint(float x, float y) {
Logger.d(TAG, "convertToViewPoint:x=%s, y=%s", x, y);
// オーサリング基準座標から変換PDF基準座標に変換
float scale = Math.min(getDefaultPDFWidth() / (float)mAuthoringPageSize.width, getDefaultPDFHeight() / (float)mAuthoringPageSize.height);
float pdfX = x * scale;
float pdfY = y * scale;
Logger.d(TAG, "convertToViewPoint:scale=%s scaledWidth=%s, scaledHeight=%s pdfX=%s, pdfY=%s", scale, getDefaultPDFWidth(), getDefaultPDFHeight(), pdfX, pdfY);
/**
* オブジェクトの位置調整
* @param x
* @param y
* @return
*/
public PointF convertToAuthoringPoint(float x, float y) {
float[] testMatrix = getMatrixValue(getPageView().imgMatrix);
float matrixX = testMatrix[Matrix.MTRANS_X];
float matrixY = testMatrix[Matrix.MTRANS_Y];
float scale = Math.min(getScaledPDFWidth(mScaleFactor) / (float)mAuthoringPageSize.width, getScaledPDFHeight(mScaleFactor) / (float)mAuthoringPageSize.height);
float pdfX = (x * scale) + matrixX;
float pdfY = (y * scale) + matrixY;
// PDF座標からタッチ座標に変換
float viewX = pdfX + margin.left;
float viewY = pdfY + margin.top;
Logger.d(TAG, "convertToViewPoint:marginX=%s, marginY=%s, mPdfScale=%s viewX=%s, viewY=%s", margin.left, margin.top, mPdfScale, viewX, viewY);
Point point = new Point((int)viewX, (int)viewY);
return point;
return new PointF((int)pdfX, (int)pdfY);
}
public PointF convertToViewPoint(float x, float y) {
if (getPageView() != null) {
return convertToAuthoringPoint(x, y);
} else {
Logger.d(TAG, "convertToViewPoint:x=%s, y=%s", x, y);
// オーサリング基準座標から変換PDF基準座標に変換
float scale = Math.min(getDefaultPDFWidth() / (float)mAuthoringPageSize.width, getDefaultPDFHeight() / (float)mAuthoringPageSize.height);
float pdfX = x * scale;
float pdfY = y * scale;
Logger.d(TAG, "convertToViewPoint:scale=%s scaledWidth=%s, scaledHeight=%s pdfX=%s, pdfY=%s", scale, getDefaultPDFWidth(), getDefaultPDFHeight(), pdfX, pdfY);
// PDF座標からタッチ座標に変換
float viewX = pdfX + margin.left;
float viewY = pdfY + margin.top;
Logger.d(TAG, "convertToViewPoint:marginX=%s, marginY=%s, mPdfScale=%s viewX=%s, viewY=%s", margin.left, margin.top, mPdfScale, viewX, viewY);
return new PointF(viewX, viewY);
}
}
public boolean isLeftSideOfPdf(int x) {
......@@ -666,7 +724,7 @@ public class ZoomRelativeLayout extends RelativeLayout {
}
private void showMemoMenu(final float x, final float y) {
final Point convertedPoint = convertToAuthoringPoint(x, y);
final PointF convertedPoint = convertToAuthoringPoint(x, y);
if (contentMemoDao.getCopiedMemo() != null) {
// メモのコピーまたは切り取り中
final ABVPopupListWindow memoPopupWindow = createSimplePopupWindow();
......@@ -681,8 +739,8 @@ public class ZoomRelativeLayout extends RelativeLayout {
if (position == 0) {
// 新規
ContentMemoDto dto = new ContentMemoDto();
dto.axisX = convertedPoint.x;
dto.axisY = convertedPoint.y;
dto.axisX = (int) convertedPoint.x;
dto.axisY = (int) convertedPoint.y;
dto.viewX = (int)x;
dto.viewY = (int)y;
dto.contentId = mContentDto.contentId;
......@@ -701,8 +759,8 @@ public class ZoomRelativeLayout extends RelativeLayout {
}
dto.contentId = mContentDto.contentId;
dto.pageNum = mPageNumber;
dto.axisX = convertedPoint.x;
dto.axisY = convertedPoint.y;
dto.axisX = (int) convertedPoint.x;
dto.axisY = (int) convertedPoint.y;
dto.viewX = (int)x;
dto.viewY = (int)y;
dto.copyFlg = false;
......@@ -740,8 +798,8 @@ public class ZoomRelativeLayout extends RelativeLayout {
} else {
ContentMemoDto dto = new ContentMemoDto();
dto.axisX = convertedPoint.x;
dto.axisY = convertedPoint.y;
dto.axisX = (int) convertedPoint.x;
dto.axisY = (int) convertedPoint.y;
dto.viewX = (int)x;
dto.viewY = (int)y;
dto.pageNum = mPageNumber;
......@@ -835,7 +893,6 @@ public class ZoomRelativeLayout extends RelativeLayout {
} else {
((GuideViewActivity) mContext).singleTapMotion();
}
return false;
}
......@@ -880,16 +937,12 @@ public class ZoomRelativeLayout extends RelativeLayout {
float pdfY = pdfMatrix[Matrix.MTRANS_Y]/2;
// If left-out or right-out of PDF
// if ((x-(margin.left+pdfX)) < 0 || (((margin.left+pdfX)+scaledWidth)-x)<0) {
// return true;
// }
Logger.i("heigth");
// if (getHeight()) {
//
// // If top-out or bottom-out of PDF
// if ((y-(margin.top+pdfY)) < 0 || (((margin.top+pdfY)+scaledHeight)-y)<0) {
// return true;
// }
// }
Point pointPdf = convertToAuthoringPoint(x, y);
PointF pointPdf = tapConvertToAuthoringPoint(x, y);
ProjectTaskDto dto = new ProjectTaskDto();
dto.projectId = ((ContentViewActivity) mContext).getProjectId();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment