Commit b112ebc7 by Lee Jaebin

MRレビュー後、修正

parent 0c3fb0ba
......@@ -7,7 +7,7 @@
android:background="@color/transparent">
<ImageButton
android:id="@+id/btn_pin"
android:id="@+id/btn_pin_toggle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="2px"
......
......@@ -264,7 +264,8 @@ public class ContentViewActivity extends ABVContentViewActivity {
private LinearLayout mScaleZoomLayout;
private boolean isOpenedProjectTask = false;
private TaskHotspotJSON mTaskHotspotJSON;
protected ImageButton btnChangeIcon;
// ピンと作業コードの切替ボタン
protected ImageButton btnPinToggleIcon;
protected ImageButton btnHideTaskDirectBtn;
protected ImageButton btnScaleZoomPlus;
protected ImageButton btnScaleZoom03;
......@@ -5034,8 +5035,9 @@ public class ContentViewActivity extends ABVContentViewActivity {
mScaleZoomLayout.setVisibility(View.VISIBLE);
mMainLayout.addView(mScaleZoomLayout, params);
btnChangeIcon = (ImageButton) mScaleZoomLayout.findViewById(id.btn_pin);
btnChangeIcon.setOnClickListener(new View.OnClickListener() {
// ピンと作業コードの切替ボタン
btnPinToggleIcon = (ImageButton) mScaleZoomLayout.findViewById(id.btn_pin_toggle);
btnPinToggleIcon.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mShowPinFlg = !mShowPinFlg;
......@@ -5043,7 +5045,7 @@ public class ContentViewActivity extends ABVContentViewActivity {
}
});
btnChangeIcon.setVisibility(View.VISIBLE);
btnPinToggleIcon.setVisibility(View.VISIBLE);
btnHideTaskDirectBtn = (ImageButton) mScaleZoomLayout.findViewById(R.id.btn_hide_task_direct);
btnHideTaskDirectBtn.setOnTouchListener(new View.OnTouchListener() {
@Override
......@@ -5096,12 +5098,11 @@ public class ContentViewActivity extends ABVContentViewActivity {
mMainLayout.addView(projectTaskLayout);
List<ProjectTaskDto> tasks = mTaskHotspotJSON.getPageTasks(pageNumber);
projectTaskLayout.addAllProjectTaskIcon(this, rootLayout, tasks);
projectTaskLayout.addAllProjectTaskIcon(rootLayout, tasks);
//画面回転の時
if (configChangedFlg && !isNormalSize()) {
projectTaskLayout.currentLayout = rootLayout;
//setProjectCurrentLayout(mCurrentPageNumber);
RelativeLayout.LayoutParams params;
DisplayMetrics displayMetrics = getResources().getDisplayMetrics();
int halfWidth = (int) (displayMetrics.density * ProjectTaskLayout.HALF_WIDTH);
......@@ -5120,7 +5121,7 @@ public class ContentViewActivity extends ABVContentViewActivity {
public void showProjectTaskLayout(ZoomRelativeLayout layout, ProjectTaskDto projectTaskDto, float clickX) {
//setCurrentProjectTask(layout, currentTaskDto);
projectTaskLayout.showTaskForm(this, layout, mXWalkOpenType, projectTaskDto, isNormalSize(), clickX);
projectTaskLayout.showTaskForm(layout, mXWalkOpenType, projectTaskDto, isNormalSize(), clickX);
isOpenedProjectTask = true;
}
......@@ -5141,7 +5142,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, mShowPinFlg);
projectTaskLayout.addProjectTaskIcon(projectTaskLayout.currentLayout, projectTaskLayout.currentTaskDto);
//hideProjectTaskLayout();
break;
case ABookKeys.CMD_DELETE_TASK_DIRECTIONS:
......@@ -5207,24 +5208,21 @@ public class ContentViewActivity extends ABVContentViewActivity {
for (int i = 0; i < mShowPageLayout.size(); i++) {
int key = mShowPageLayout.keyAt(i);
ZoomRelativeLayout zoomRelativeLayout = mShowPageLayout.get(key);
List<View> deleteViewList = new ArrayList<View>();
for (int j = 0; j < zoomRelativeLayout.getChildCount(); j++) {
for (int j = zoomRelativeLayout.getChildCount() - 1; j >= 0; j--) {
View view = zoomRelativeLayout.getChildAt(j);
if (view instanceof ActionProjectTaskCode) {
((ActionProjectTaskCode)view).stopAnimation();
// 削除対象のビューをリストViewに追加する
deleteViewList.add(view);
((ActionProjectTaskCode) view).stopAnimation();
} else if (view instanceof ActionProjectTaskPin) {
((ActionProjectTaskPin)view).stopAnimation();
// 削除対象のビューをリストViewに追加する
deleteViewList.add(view);
((ActionProjectTaskPin) view).stopAnimation();
}
}
for (View view : deleteViewList) {
if (view instanceof ActionProjectTaskCode || view instanceof ActionProjectTaskPin) {
// ピン、作業コードのビューを削除
zoomRelativeLayout.removeView(view);
}
}
List<ProjectTaskDto> tasks = mTaskHotspotJSON.getPageTasks(i);
projectTaskLayout.addAllProjectTaskIcon(this, zoomRelativeLayout, tasks);
projectTaskLayout.addAllProjectTaskIcon(zoomRelativeLayout, tasks);
}
}
......
......@@ -26,7 +26,7 @@ public class ActionProjectTaskCode extends TextView {
private Context mContext;
public ProjectTaskDto mProjectTaskDto;
public ActionProjectTaskCode(final Context context, final ProjectTaskDto dto) {
public ActionProjectTaskCode(Context context, ProjectTaskDto dto) {
super(context);
mContext = context;
mProjectTaskDto = dto;
......
......@@ -164,17 +164,16 @@ public class ProjectTaskLayout extends RelativeLayout {
});
}
public void addProjectTaskIcon(final Context context, final ZoomRelativeLayout rootLayout, final ProjectTaskDto dto, boolean isShowPin) {
mContext = (ContentViewActivity)context;
public void addProjectTaskIcon(final ZoomRelativeLayout rootLayout, final ProjectTaskDto dto) {
RelativeLayout.LayoutParams params;
final float density = context.getResources().getDisplayMetrics().density;
final float density = mContext.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);
final ActionProjectTaskIcon taskIcon = new ActionProjectTaskIcon(mContext);
taskIcon.startBlinkAnimation();
taskIcon.taskKey = dto.taskKey;
......@@ -191,9 +190,9 @@ public class ProjectTaskLayout extends RelativeLayout {
taskView = taskIcon;
} else {
final PointF pointView = rootLayout.convertToViewPoint(dto.pdfX, dto.pdfY);
if (isShowPin) {
if (mContext.mShowPinFlg) {
// ピンで表示
final ActionProjectTaskPin taskPin = new ActionProjectTaskPin(context, dto);
final ActionProjectTaskPin taskPin = new ActionProjectTaskPin(mContext, dto);
taskPin.taskKey = dto.taskKey;
if (dto.isFinished) {
width = (int) (PIN_FINISHED_ICON_WIDTH * density);
......@@ -218,7 +217,7 @@ public class ProjectTaskLayout extends RelativeLayout {
taskView = taskPin;
} else {
// 作業コードで表示
final ActionProjectTaskCode taskCode = new ActionProjectTaskCode(context, dto);
final ActionProjectTaskCode taskCode = new ActionProjectTaskCode(mContext, dto);
//taskCode.startBlinkAnimation();
taskCode.taskKey = dto.taskKey;
......@@ -259,7 +258,7 @@ public class ProjectTaskLayout extends RelativeLayout {
ClipData data = ClipData.newPlainText("", "");
View.DragShadowBuilder shadowBuilder = new View.DragShadowBuilder(view);
view.startDrag(data, shadowBuilder, view, 0);
((ContentViewActivity) context).setCurrentProjectTask(dto);
mContext.setCurrentProjectTask(dto);
}
//rootLayout.invalidate();
return true;
......@@ -271,17 +270,17 @@ public class ProjectTaskLayout extends RelativeLayout {
@Override
public void onClick(View view) {
Logger.d(TAG, "[taskView.setOnClickListener]:taskCode=" + dto.taskCode);
if (!((ContentViewActivity)context).getOpenedProjestTask()) {
((ContentViewActivity)context).showProjectTaskLayout(rootLayout, dto, view.getX());
if (!mContext.getOpenedProjestTask()) {
mContext.showProjectTaskLayout(rootLayout, dto, view.getX());
}
}
});
}
public void addAllProjectTaskIcon(Context context, final ZoomRelativeLayout rootLayout, final List<ProjectTaskDto> dto) {
public void addAllProjectTaskIcon(final ZoomRelativeLayout rootLayout, final List<ProjectTaskDto> dto) {
for (ProjectTaskDto task : dto) {
task.isFinished = isTaskFinished(task.taskKey);
addProjectTaskIcon(context, rootLayout, task, ((ContentViewActivity)context).mShowPinFlg);
addProjectTaskIcon(rootLayout, task);
}
}
......@@ -317,9 +316,9 @@ public class ProjectTaskLayout extends RelativeLayout {
});
}
public void showTaskForm(final Context context, ZoomRelativeLayout layout, int mXWalkOpenType, ProjectTaskDto projectTaskDto, boolean isNormalSize, float clickX) {
public void showTaskForm(ZoomRelativeLayout layout, int mXWalkOpenType, ProjectTaskDto projectTaskDto, boolean isNormalSize, float clickX) {
if (projectTaskDto.taskKey.equals(TEMP_TASK_KEY)) {
addProjectTaskIcon(context, layout, projectTaskDto, ((ContentViewActivity)context).mShowPinFlg);
addProjectTaskIcon(layout, projectTaskDto);
setTaskFormPosition(clickX, isNormalSize);
}
......@@ -442,7 +441,7 @@ public class ProjectTaskLayout extends RelativeLayout {
if (currentTaskDto != null && !StringUtil.isNullOrEmpty(currentTaskDto.taskKey)) {
if (currentTaskDto.taskKey.equals(TEMP_TASK_KEY)) {
addProjectTaskIcon(mContext, currentLayout, currentTaskDto, ((ContentViewActivity) mContext).mShowPinFlg);
addProjectTaskIcon(currentLayout, currentTaskDto);
} else {
if (mContext.getOpenedProjestTask()) {
setTaskCodeBlinkAnimation(currentTaskDto.taskKey, true);
......@@ -541,18 +540,6 @@ public class ProjectTaskLayout extends RelativeLayout {
}
}
public PointF convertToAuthoringPoint(float x, float y) {
return currentLayout.convertToAuthoringPoint(x, y);
}
public static int getIconWidth() {
return ICON_WIDTH;
}
public static int getIconHeight() {
return ICON_HEIGHT;
}
public static String getTempTaskKey() {
return TEMP_TASK_KEY;
}
......
......@@ -92,8 +92,6 @@ public class ZoomRelativeLayout extends RelativeLayout {
class MyDragListener implements OnDragListener {
@Override
public boolean onDrag(View v, DragEvent event) {
View view = (View) event.getLocalState();
switch (event.getAction()) {
case DragEvent.ACTION_DRAG_STARTED:
//理由不明、イベントが二回くる、二回目でgetX()だけがマイナス
......@@ -107,10 +105,11 @@ public class ZoomRelativeLayout extends RelativeLayout {
case DragEvent.ACTION_DRAG_EXITED:
break;
case DragEvent.ACTION_DROP:
View view = (View) event.getLocalState();
float mX = event.getX();
float mY = event.getY();
if (Math.abs(mX - fX) < view.getWidth() / 2 && Math.abs(mY - fY) < view.getHeight() / 2) {
// 作業コード、ピンの動きが上下左右10pxの差分がなければ、クリックイベントとして見做す。
if (Math.abs(mX - fX) < 10 && Math.abs(mY - fY) < 10) {
view.performClick();
return true;
}
......@@ -143,7 +142,7 @@ public class ZoomRelativeLayout extends RelativeLayout {
// 作業のy座標をセット(作業アイコンがピンで且つ、PDF範囲を超えたフラグ(isOutTranslation)がtrueの場合、(mY - アイコンの縦サイズ)で縦をセットする)
view.setTranslationY(mY - (isOutTranslation && view instanceof ActionProjectTaskPin ? view.getHeight() : view.getHeight() / 2));
// タップした座標をPDF用の座標に変換する
PointF pdfPoint = tapConvertToAuthoringPoint(mX, view instanceof ActionProjectTaskPin && !isOutTranslation ? mY + view.getHeight() / 2 : mY);
PointF pdfPoint = convertToTapPoint(mX, view instanceof ActionProjectTaskPin && !isOutTranslation ? mY + view.getHeight() / 2 : mY);
// 座標を更新する
((ContentViewActivity) mContext).updateProjectTaskPosition(pdfPoint.x, pdfPoint.y);
......@@ -356,7 +355,7 @@ public class ZoomRelativeLayout extends RelativeLayout {
*/
private void setTaskTranslationCode(ActionProjectTaskCode view) {
ProjectTaskDto dto = view.mProjectTaskDto;
PointF point = convertToAuthoringPoint(dto.pdfX, dto.pdfY);
PointF point = convertToScalePoint(dto.pdfX, dto.pdfY);
view.setTranslationX(point.x - (view.getWidth() / 2));
view.setTranslationY(point.y - (view.getHeight() / 2));
}
......@@ -367,7 +366,7 @@ public class ZoomRelativeLayout extends RelativeLayout {
*/
private void setTaskTranslationPin(ActionProjectTaskPin view) {
ProjectTaskDto dto = view.mProjectTaskDto;
PointF point = convertToAuthoringPoint(dto.pdfX, dto.pdfY);
PointF point = convertToScalePoint(dto.pdfX, dto.pdfY);
view.setTranslationX(point.x - (view.getWidth() / 2));
view.setTranslationY(point.y - view.getHeight());
}
......@@ -645,12 +644,12 @@ public class ZoomRelativeLayout extends RelativeLayout {
}
/**
* タップのx,y座標をPDFに合わせて変換
* ドロップ&ドラッグ・ダブルタップ時のx,y座標をPDFに合わせて変換
* @param x
* @param y
* @return
*/
public PointF tapConvertToAuthoringPoint(float x, float y) {
public PointF convertToTapPoint(float x, float y) {
float[] pdfMatrix = getMatrixValue(getPageView().imgMatrix);
float scaleX = (float)mAuthoringPageSize.width / getScaledPDFWidth(pdfMatrix[Matrix.MSCALE_X]);
......@@ -662,12 +661,12 @@ public class ZoomRelativeLayout extends RelativeLayout {
}
/**
* オブジェクトの位置調整
* 作業の位置調整
* @param x
* @param y
* @return
*/
public PointF convertToAuthoringPoint(float x, float y) {
public PointF convertToScalePoint(float x, float y) {
float[] pdfMatrix = getMatrixValue(getPageView().imgMatrix);
float scaleX = getScaledPDFWidth(pdfMatrix[Matrix.MSCALE_X]) / (float)mAuthoringPageSize.width;
......@@ -686,13 +685,14 @@ public class ZoomRelativeLayout extends RelativeLayout {
*/
public PointF convertToViewPoint(float x, float y) {
Logger.d(TAG, "convertToViewPoint:x=%s, y=%s", x, y);
// 初期表示時、getPageView()がnullの場合があるので、初期情報を元にx, y座標を変換する
if (getPageView() != null) {
return convertToAuthoringPoint(x, y);
} else {
return convertToScalePoint(x, y);
}
// 初期表示の場合は、PDFPageビューが存在しないので、初期表示のみ以下の処理で行われる
// オーサリング基準座標から変換PDF基準座標に変換
float scaleX = getDefaultPDFWidth() / (float)mAuthoringPageSize.width;
float scaleY = getDefaultPDFHeight() / (float)mAuthoringPageSize.height;
float scaleX = getDefaultPDFWidth() / (float) mAuthoringPageSize.width;
float scaleY = getDefaultPDFHeight() / (float) mAuthoringPageSize.height;
// PDF座標からタッチ座標に変換
float viewX = (x * scaleX) + margin.left;
......@@ -700,7 +700,6 @@ public class ZoomRelativeLayout extends RelativeLayout {
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 Point convertToMemoViewPoint(float x, float y) {
Logger.d(TAG, "convertToViewPoint:x=%s, y=%s", x, y);
......@@ -731,7 +730,7 @@ public class ZoomRelativeLayout extends RelativeLayout {
// 変換PDF基準座標からオーサリング基準座標に変換
float scale = Math.min((float)mAuthoringPageSize.width / getDefaultPDFWidth(), (float)mAuthoringPageSize.height / getDefaultPDFHeight());
Point point = new Point((int)(pdfX * scale), (int)(pdfY * scale));
Logger.d(TAG, "convertToAuthoringPoint:scale=%s scaledWidth=%s, scaledHeight=%s authX=%s, auyhY=%s", scale, getDefaultPDFWidth(), getDefaultPDFHeight(), (pdfX * scale), (pdfY * scale));
Logger.d(TAG, "convertToScalePoint:scale=%s scaledWidth=%s, scaledHeight=%s authX=%s, auyhY=%s", scale, getDefaultPDFWidth(), getDefaultPDFHeight(), (pdfX * scale), (pdfY * scale));
return point;
}
......@@ -775,8 +774,8 @@ public class ZoomRelativeLayout extends RelativeLayout {
}
dto.contentId = mContentDto.contentId;
dto.pageNum = mPageNumber;
dto.axisX = (int) convertedPoint.x;
dto.axisY = (int) convertedPoint.y;
dto.axisX = convertedPoint.x;
dto.axisY = convertedPoint.y;
dto.viewX = (int)x;
dto.viewY = (int)y;
dto.copyFlg = false;
......@@ -814,8 +813,8 @@ public class ZoomRelativeLayout extends RelativeLayout {
} else {
ContentMemoDto dto = new ContentMemoDto();
dto.axisX = (int) convertedPoint.x;
dto.axisY = (int) convertedPoint.y;
dto.axisX = convertedPoint.x;
dto.axisY = convertedPoint.y;
dto.viewX = (int)x;
dto.viewY = (int)y;
dto.pageNum = mPageNumber;
......@@ -953,7 +952,7 @@ public class ZoomRelativeLayout extends RelativeLayout {
}
// タップしたx, yをPDF用の座標に変換
PointF pointPdf = tapConvertToAuthoringPoint(x, y);
PointF pointPdf = convertToTapPoint(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