Commit 62397df1 by Kim Jinsung

ベースシーンとシーン登録処理追加

parent cc209be0
...@@ -616,21 +616,19 @@ public class AcmsClient implements AcmsClientResponseListener { ...@@ -616,21 +616,19 @@ public class AcmsClient implements AcmsClientResponseListener {
/** /**
* パノラマで使用するシーンを登録 * パノラマで使用するシーンを登録
* @param sid * @param sid
* @param contentId
* @param FormFile シーンで使用する画像 * @param FormFile シーンで使用する画像
* @return * @return
* @throws IOException * @throws IOException
* @throws AcmsException * @throws AcmsException
*/ */
public SceneEntryJSON sceneEntry(String sid, Long contentId, File FormFile) throws IOException, AcmsException, NetworkDisconnectedException { public SceneEntryJSON sceneEntry(String sid, File FormFile) throws IOException, AcmsException, NetworkDisconnectedException {
if (networkAdapter != null && !networkAdapter.isNetworkConnected()) { // NWのチェック if (networkAdapter != null && !networkAdapter.isNetworkConnected()) { // NWのチェック
throw new NetworkDisconnectedException(); throw new NetworkDisconnectedException();
} }
String apiUrl = AcmsApis.getApiUrl(env.acmsAddress, urlPath, AcmsApis.ApiSceneEntry); String apiUrl = AcmsApis.getApiUrl(env.acmsAddress, urlPath, AcmsApis.ApiSceneEntry);
HttpMultipart part1 = new HttpMultipart(ABookKeys.SID, sid); HttpMultipart part1 = new HttpMultipart(ABookKeys.SID, sid);
HttpMultipart part2 = new HttpMultipart(ABookKeys.CONTENT_ID, StringUtil.toString(contentId)); HttpMultipart part2 = new HttpMultipart(ABookKeys.FORM_FILE, FormFile);
HttpMultipart part3 = new HttpMultipart(ABookKeys.FORM_FILE, FormFile); HttpResponse result = HttpRequestSender.post(apiUrl, new HttpMultipart[]{part1, part2});
HttpResponse result = HttpRequestSender.post(apiUrl, new HttpMultipart[]{part1, part2, part3});
SceneEntryJSON json = new SceneEntryJSON(result.httpResponseBody); SceneEntryJSON json = new SceneEntryJSON(result.httpResponseBody);
if (json.httpStatus != 200) { if (json.httpStatus != 200) {
if (json.errorMessage != null) { if (json.errorMessage != null) {
......
...@@ -129,6 +129,7 @@ public class ABookKeys { ...@@ -129,6 +129,7 @@ public class ABookKeys {
public static final String EDITABLE = "editable"; //commonAttachedDataUrl()で編集可否を判別するパラメタをWebからもらう。 public static final String EDITABLE = "editable"; //commonAttachedDataUrl()で編集可否を判別するパラメタをWebからもらう。
public static final String FILE_PATH = "filePath"; //再編集する場合、クリックしたイマージのパスのパラメタ public static final String FILE_PATH = "filePath"; //再編集する場合、クリックしたイマージのパスのパラメタ
public static final String BASE_CONTENT_REGISTER = "BaseContentRegister";
//THETA端末関連 //THETA端末関連
public static final String THETA_FILE_ID = "OBJECT_ID"; public static final String THETA_FILE_ID = "OBJECT_ID";
public static final String THETA_THUMBNAIL = "THUMBNAIL"; public static final String THETA_THUMBNAIL = "THUMBNAIL";
......
...@@ -1380,12 +1380,11 @@ public class OperationLogic extends AbstractLogic { ...@@ -1380,12 +1380,11 @@ public class OperationLogic extends AbstractLogic {
/** /**
* シーンの登録 * シーンの登録
* @param file * @param file
* @param contentId
* @throws IOException * @throws IOException
* @throws AcmsException * @throws AcmsException
*/ */
public Integer sendScene(File file, Long contentId) throws IOException, AcmsException, NetworkDisconnectedException { public Integer sendScene(File file) throws IOException, AcmsException, NetworkDisconnectedException {
SceneEntryJSON json = AcmsClient.getInstance(cache.getUrlPath(), networkAdapter).sceneEntry(cache.getMemberInfo().sid, contentId, file); SceneEntryJSON json = AcmsClient.getInstance(cache.getUrlPath(), networkAdapter).sceneEntry(cache.getMemberInfo().sid, file);
return json.resourceId; return json.resourceId;
} }
......
...@@ -44,6 +44,21 @@ public class AlertDialogUtil { ...@@ -44,6 +44,21 @@ public class AlertDialogUtil {
} }
/** /**
* 共通ダイアログ表示用(OKボタンコールバック、CANCELボタンコールバック)
* @param context コンテキスト
* @param title タイトル
* @param message メッセージ
* @param okOnClick OKボタンコールバック
* @param okOnClick CANCELボタンコールバック
*/
public static void showAlertDialog(Context context, int title, int message, DialogInterface.OnClickListener okOnClick, DialogInterface.OnClickListener canOnClick) {
ABookAlertDialog alertDialog = createAlertDialog(context, context.getResources().getString(title), context.getResources().getString(message));
alertDialog.setNegativeButton(R.string.cancel, canOnClick);
alertDialog.setPositiveButton(R.string.ok, okOnClick);
alertDialog.show();
}
/**
* 共通ダイアログ表示用(Cancel表示・非表示、OKボタンコールバック) * 共通ダイアログ表示用(Cancel表示・非表示、OKボタンコールバック)
* @param context コンテキスト * @param context コンテキスト
* @param title タイトル * @param title タイトル
......
...@@ -102,10 +102,12 @@ import jp.agentec.abook.abv.ui.common.view.ABVListDialog; ...@@ -102,10 +102,12 @@ import jp.agentec.abook.abv.ui.common.view.ABVListDialog;
import jp.agentec.abook.abv.ui.common.view.ABVPopupListWindow; import jp.agentec.abook.abv.ui.common.view.ABVPopupListWindow;
import jp.agentec.abook.abv.ui.home.adapter.HierarchyOperationGroupListAdapter; import jp.agentec.abook.abv.ui.home.adapter.HierarchyOperationGroupListAdapter;
import jp.agentec.abook.abv.ui.home.helper.ABookCheckWebViewHelper; import jp.agentec.abook.abv.ui.home.helper.ABookCheckWebViewHelper;
import jp.agentec.abook.abv.ui.home.helper.ABookPermissionHelper;
import jp.agentec.abook.abv.ui.home.helper.ActivityHandlingHelper; import jp.agentec.abook.abv.ui.home.helper.ActivityHandlingHelper;
import jp.agentec.abook.abv.ui.home.helper.HomeOperationListHelper; import jp.agentec.abook.abv.ui.home.helper.HomeOperationListHelper;
import jp.agentec.abook.abv.ui.home.helper.OperationGroupMasterListHelper; import jp.agentec.abook.abv.ui.home.helper.OperationGroupMasterListHelper;
import jp.agentec.abook.abv.ui.home.helper.OperationListHelper; import jp.agentec.abook.abv.ui.home.helper.OperationListHelper;
import jp.agentec.abook.abv.ui.viewer.activity.DeviceImageListActivity;
import jp.agentec.abook.abv.ui.viewer.activity.HTMLXWalkWebViewActivity; import jp.agentec.abook.abv.ui.viewer.activity.HTMLXWalkWebViewActivity;
import jp.agentec.adf.util.DateTimeFormat; import jp.agentec.adf.util.DateTimeFormat;
import jp.agentec.adf.util.DateTimeUtil; import jp.agentec.adf.util.DateTimeUtil;
...@@ -170,6 +172,10 @@ public class OperationListActivity extends ABVUIActivity { ...@@ -170,6 +172,10 @@ public class OperationListActivity extends ABVUIActivity {
// 作業種別のサービスオプション値を保持用フラグ // 作業種別のサービスオプション値を保持用フラグ
private boolean mOperationGroupMasterServiceOperationFlg; private boolean mOperationGroupMasterServiceOperationFlg;
//シーン画像選択画面からベース画像登録後に閉じたときに処理追加のため、
private static final int SUB_DIVICE_IMAGE_LIST_ACTIVITY = 1001;
private Long mSelectedOperationId;
// ビューの作成 // ビューの作成
private class ReloadHandler implements Runnable { private class ReloadHandler implements Runnable {
@Override @Override
...@@ -1152,139 +1158,197 @@ public class OperationListActivity extends ABVUIActivity { ...@@ -1152,139 +1158,197 @@ public class OperationListActivity extends ABVUIActivity {
*/ */
public void showPanoEntryDialog(final OperationDto operationDto) { public void showPanoEntryDialog(final OperationDto operationDto) {
Logger.d(TAG, "*****************showPanoEntryDialog"); Logger.d(TAG, "*****************showPanoEntryDialog");
if (contentRefresher != null && contentRefresher.isRefreshing()) { //パーミッションチェック
// 新着更新処理が行っていれば、止める ABookPermissionHelper helper = new ABookPermissionHelper(this, Constant.ABookPermissionType.ReadExternalStorage, null);
contentRefresher.stopRefresh(); if (helper.checkMultiPermissions(true)) {
} mSelectedOperationId = operationDto.operationId;
if (mPanoEntryDialog == null) { //シーン画像選択画面表示
mPanoEntryDialog = new Dialog(OperationListActivity.this); Intent intent = new Intent();
mPanoEntryDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); intent.putExtra(ABookKeys.BASE_CONTENT_REGISTER, true);
mPanoEntryDialog.setCanceledOnTouchOutside(false); intent.putExtra(ABookKeys.OPERATION_ID, mSelectedOperationId);
mPanoEntryDialog.setContentView(R.layout.operation_pano_entry_dialog); intent.putExtra(ABookKeys.OPERATION_NAME, operationDto.operationName);
}
mPanoCotnentImageView = (ImageView) mPanoEntryDialog.findViewById(R.id.pano_image_view);
mPanoContentNameTextView = (TextView) mPanoEntryDialog.findViewById(R.id.operation_name);
mPanoContentNameTextView.setText(operationDto.operationName);
mPanoCotnentImageView.setImageBitmap(null);
FileUtil.delete(ABVEnvironment.getInstance().getCacheTempAttachedImageDirPath());
// 閉じるボタン
mPanoEntryDialog.findViewById(R.id.closeBtn).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mPanoCotnentImageView.setImageBitmap(null);
mSelectPanoContentUri = null;
mPanoEntryDialog.dismiss();
FileUtil.delete(ABVEnvironment.getInstance().getCacheTempAttachedImageDirPath());
}
});
// 画像選択ボタン String className = DeviceImageListActivity.class.getName();
mPanoEntryDialog.findViewById(R.id.select_image).setOnClickListener(new View.OnClickListener() { if (isNormalSize() == false) {
@Override className += "Dialog";
public void onClick(View v) {
startCameraIntent(ABOOK_CHECK_OPERATION_PANO_CONTENT_IMAGE, "Camera", ABookKeys.IMAGE, false);
} }
});
// 登録ボタン intent.setClassName(getPackageName(), className);
mPanoEntryDialog.findViewById(R.id.btn_entry).setOnClickListener(new View.OnClickListener() { startActivityForResult(intent, SUB_DIVICE_IMAGE_LIST_ACTIVITY);
@Override
public void onClick(View v) {
if (!ABVEnvironment.getInstance().networkAdapter.isNetworkConnected()) {
ABVToastUtil.showMakeText(OperationListActivity.this, R.string.msg_network_offline, Toast.LENGTH_SHORT);
return;
}
if (mSelectPanoContentUri == null) {
ABVToastUtil.showMakeText(OperationListActivity.this, PatternStringUtil.patternToInt(getApplicationContext(),
R.string.msg_pano_image_no_selected,
getUserPref(AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0)), Toast.LENGTH_SHORT);
return;
}
// リソースパターンの適用
showProgressView(PatternStringUtil.patternToString(getApplicationContext(),
R.string.msg_common_processing,
getUserPref(AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0)));
CommonExecutor.execute(new Runnable() {
@Override
public void run() {
boolean isError = true;
String[] projection = {MediaStore.MediaColumns.DATA};
Cursor cursor = getContentResolver().query(mSelectPanoContentUri, projection, null, null, null);
String scenePath = null;
if (mSelectPanoContentUri.toString().contains("file")) { //アプリ内に臨時保存した画像ファイル
scenePath = mSelectPanoContentUri.getPath();
} else { } else {
if (cursor != null) { Logger.w(TAG, "ReadExternalStorage checkMultiPermissions false");
if (cursor.moveToFirst()) { }
scenePath = cursor.getString(0); // if (contentRefresher != null && contentRefresher.isRefreshing()) {
} // // 新着更新処理が行っていれば、止める
cursor.close(); // contentRefresher.stopRefresh();
// }
// if (mPanoEntryDialog == null) {
// mPanoEntryDialog = new Dialog(OperationListActivity.this);
// mPanoEntryDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
// mPanoEntryDialog.setCanceledOnTouchOutside(false);
// mPanoEntryDialog.setContentView(R.layout.operation_pano_entry_dialog);
// }
// mPanoCotnentImageView = (ImageView) mPanoEntryDialog.findViewById(R.id.pano_image_view);
// mPanoContentNameTextView = (TextView) mPanoEntryDialog.findViewById(R.id.operation_name);
//
// mPanoContentNameTextView.setText(operationDto.operationName);
// mPanoCotnentImageView.setImageBitmap(null);
// FileUtil.delete(ABVEnvironment.getInstance().getCacheTempAttachedImageDirPath());
//
// // 閉じるボタン
// mPanoEntryDialog.findViewById(R.id.closeBtn).setOnClickListener(new View.OnClickListener() {
//
// @Override
// public void onClick(View v) {
// mPanoCotnentImageView.setImageBitmap(null);
// mSelectPanoContentUri = null;
// mPanoEntryDialog.dismiss();
// FileUtil.delete(ABVEnvironment.getInstance().getCacheTempAttachedImageDirPath());
// }
// });
//
//
// // 画像選択ボタン
// mPanoEntryDialog.findViewById(R.id.select_image).setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// startCameraIntent(ABOOK_CHECK_OPERATION_PANO_CONTENT_IMAGE, "Camera", ABookKeys.IMAGE, false);
// }
// });
//
//
// // 登録ボタン
// mPanoEntryDialog.findViewById(R.id.btn_entry).setOnClickListener(new View.OnClickListener() {
//
// @Override
// public void onClick(View v) {
// if (!ABVEnvironment.getInstance().networkAdapter.isNetworkConnected()) {
// ABVToastUtil.showMakeText(OperationListActivity.this, R.string.msg_network_offline, Toast.LENGTH_SHORT);
// return;
// }
// if (mSelectPanoContentUri == null) {
// ABVToastUtil.showMakeText(OperationListActivity.this, PatternStringUtil.patternToInt(getApplicationContext(),
// R.string.msg_pano_image_no_selected,
// getUserPref(AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0)), Toast.LENGTH_SHORT);
// return;
// }
// // リソースパターンの適用
// showProgressView(PatternStringUtil.patternToString(getApplicationContext(),
// R.string.msg_common_processing,
// getUserPref(AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0)));
// CommonExecutor.execute(new Runnable() {
// @Override
// public void run() {
// boolean isError = true;
// String[] projection = {MediaStore.MediaColumns.DATA};
// Cursor cursor = getContentResolver().query(mSelectPanoContentUri, projection, null, null, null);
//
// String scenePath = null;
// if (mSelectPanoContentUri.toString().contains("file")) { //アプリ内に臨時保存した画像ファイル
// scenePath = mSelectPanoContentUri.getPath();
// } else {
// if (cursor != null) {
// if (cursor.moveToFirst()) {
// scenePath = cursor.getString(0);
// }
// cursor.close();
// }
//
// }
// if (scenePath != null) {
// File file = new File(scenePath);
// isError = true;
// try {
// mOperationLogic.sendPanoContent(operationDto.operationId, operationDto.operationName, file);
// isError = false;
// } catch (ABVException e) {
// //noinspection EnumSwitchStatementWhichMissesCases
// switch (e.getCode()) {
// case P_E_ACMS_P001:
// showSimpleAlertDialog(R.string.app_name,
// PatternStringUtil.patternToInt(getApplicationContext(),
// R.string.P001,
// getUserPref(AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0)));
// break;
// case P_E_ACMS_P002:
// showSimpleAlertDialog(R.string.app_name,
// PatternStringUtil.patternToInt(getApplicationContext(),
// R.string.P002,
// getUserPref(AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0)));
// break;
// case S_E_ACMS_0500:
// handleErrorMessageToast(ABVExceptionCode.S_E_ACMS_0500);
// break;
// default:
// Logger.e(TAG, "PanoContent send error", e);
// handleErrorMessageToast(ErrorCode.E107);
// break;
// }
// } catch (Exception e) {
// Logger.e(TAG, e);
// ErrorMessage.showErrorMessageToast(OperationListActivity.this, ErrorCode.E107);
// }
// }
// if (isError) {
// closeProgressPopup();
// } else {
// handler.post(new Runnable() {
// @Override
// public void run() {
// progressDialogHorizontal.setProgress(20);
// mOperationLogic.setContentCreatingFlg(operationDto.operationId);
// refreshOperationList();
// }
// });
//
// //10秒後に新着更新させる
// handler.postDelayed(new Runnable() {
// @Override
// public void run() {
// int progress = progressDialogHorizontal.getProgress();
// progressDialogHorizontal.setProgress(progress + 8);
// if (progress >= 100) {
// closeProgressPopup();
// mPanoEntryDialog.dismiss();
// mPanoCotnentImageView.setImageBitmap(null);
// dataRefresh(true);
// } else {
// handler.postDelayed(this, 1000);
// }
// }
// }, 1000);
// }
// }
// });
// }
// });
//
// if (mPanoEntryDialog != null) {
// mPanoEntryDialog.show();
// }
} }
}
if (scenePath != null) {
File file = new File(scenePath);
isError = true;
try {
mOperationLogic.sendPanoContent(operationDto.operationId, operationDto.operationName, file);
isError = false;
} catch (ABVException e) {
//noinspection EnumSwitchStatementWhichMissesCases
switch (e.getCode()) {
case P_E_ACMS_P001:
showSimpleAlertDialog(R.string.app_name,
PatternStringUtil.patternToInt(getApplicationContext(),
R.string.P001,
getUserPref(AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0)));
break;
case P_E_ACMS_P002:
showSimpleAlertDialog(R.string.app_name,
PatternStringUtil.patternToInt(getApplicationContext(),
R.string.P002,
getUserPref(AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0)));
break;
case S_E_ACMS_0500:
handleErrorMessageToast(ABVExceptionCode.S_E_ACMS_0500);
break;
default:
Logger.e(TAG, "PanoContent send error", e);
handleErrorMessageToast(ErrorCode.E107);
break;
}
} catch (Exception e) {
Logger.e(TAG, e);
ErrorMessage.showErrorMessageToast(OperationListActivity.this, ErrorCode.E107);
}
}
if (isError) {
closeProgressPopup();
} else {
handler.post(new Runnable() {
@Override @Override
public void run() { protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
progressDialogHorizontal.setProgress(20); activityResultFlg = true;
mOperationLogic.setContentCreatingFlg(operationDto.operationId); Uri result = (intent == null || resultCode != RESULT_OK) ? null : intent.getData();
//ベースファイル登録した後にシーン画像選択画面閉じた後に呼ばれる
if (requestCode == SUB_DIVICE_IMAGE_LIST_ACTIVITY) {
mOperationLogic.setContentCreatingFlg(mSelectedOperationId);
refreshOperationList(); refreshOperationList();
}
});
//10秒後に新着更新させる //10秒(コンテンツ作成し、公開までの時間)に新着更新させる。
showProgressView(getString(R.string.msg_common_processing));
handler.postDelayed(new Runnable() { handler.postDelayed(new Runnable() {
@Override @Override
public void run() { public void run() {
int progress = progressDialogHorizontal.getProgress(); int progress = progressDialogHorizontal.getProgress();
progressDialogHorizontal.setProgress(progress + 8); progressDialogHorizontal.setProgress(progress + 10);
if (progress >= 100) { if (progress >= 100) {
closeProgressPopup(); closeProgressPopup();
mPanoEntryDialog.dismiss(); //新着更新
mPanoCotnentImageView.setImageBitmap(null);
dataRefresh(true); dataRefresh(true);
} else { } else {
handler.postDelayed(this, 1000); handler.postDelayed(this, 1000);
...@@ -1292,45 +1356,31 @@ public class OperationListActivity extends ABVUIActivity { ...@@ -1292,45 +1356,31 @@ public class OperationListActivity extends ABVUIActivity {
} }
}, 1000); }, 1000);
} }
} // if (requestCode == ABOOK_CHECK_OPERATION_PANO_CONTENT_IMAGE) {
}); // if (result != null) {
} // mSelectPanoContentUri = result;
}); // try {
// String[] projection = {MediaStore.MediaColumns.DATA};
if (mPanoEntryDialog != null) { // Cursor cursor = getContentResolver().query(mSelectPanoContentUri, projection, null, null, null);
mPanoEntryDialog.show(); // String photoFilePath = ABookCheckWebViewHelper.getInstance().contentSchemeUriToFilePath(cursor);
} // int rotationAngle = ABookCheckWebViewHelper.getInstance().rotateBitmapOrientation(photoFilePath);
} // if (rotationAngle != 0) {
// mLocalFile = ABookCheckWebViewHelper.getInstance().rotateBitmapToImageFile(rotationAngle, photoFilePath, ABVEnvironment.getInstance().getCacheTempAttachedImageDirPath());
@Override // mSelectPanoContentUri = Uri.fromFile(mLocalFile);
protected void onActivityResult(int requestCode, int resultCode, Intent intent) { // }
activityResultFlg = true; // if (mSelectPanoContentUri != null) {
Uri result = (intent == null || resultCode != RESULT_OK) ? null : intent.getData(); // InputStream stream = getContentResolver().openInputStream(mSelectPanoContentUri);
if (requestCode == ABOOK_CHECK_OPERATION_PANO_CONTENT_IMAGE) { // Bitmap bitmap = BitmapFactory.decodeStream(stream);
if (result != null) { // mPanoCotnentImageView.setImageBitmap(bitmap);
mSelectPanoContentUri = result; // }
try { //
String[] projection = {MediaStore.MediaColumns.DATA}; // } catch (FileNotFoundException e) {
Cursor cursor = getContentResolver().query(mSelectPanoContentUri, projection, null, null, null); // Logger.e(TAG, "panoImageContent is not found", e);
String photoFilePath = ABookCheckWebViewHelper.getInstance().contentSchemeUriToFilePath(cursor); // } catch (IOException e) {
int rotationAngle = ABookCheckWebViewHelper.getInstance().rotateBitmapOrientation(photoFilePath); // Logger.e(TAG, "IOException = ", e);
if (rotationAngle != 0) { // }
mLocalFile = ABookCheckWebViewHelper.getInstance().rotateBitmapToImageFile(rotationAngle, photoFilePath, ABVEnvironment.getInstance().getCacheTempAttachedImageDirPath()); // }
mSelectPanoContentUri = Uri.fromFile(mLocalFile); // }
}
if (mSelectPanoContentUri != null) {
InputStream stream = getContentResolver().openInputStream(mSelectPanoContentUri);
Bitmap bitmap = BitmapFactory.decodeStream(stream);
mPanoCotnentImageView.setImageBitmap(bitmap);
}
} catch (FileNotFoundException e) {
Logger.e(TAG, "panoImageContent is not found", e);
} catch (IOException e) {
Logger.e(TAG, "IOException = ", e);
}
}
}
} }
/** /**
......
...@@ -22,7 +22,6 @@ import com.imagepicker.ImageInternalFetcher; ...@@ -22,7 +22,6 @@ import com.imagepicker.ImageInternalFetcher;
import com.theta.helper.ThetaHelper; import com.theta.helper.ThetaHelper;
import com.theta.network.ThetaDeviceInfo; import com.theta.network.ThetaDeviceInfo;
import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
...@@ -30,15 +29,10 @@ import java.util.List; ...@@ -30,15 +29,10 @@ import java.util.List;
import java.util.Set; import java.util.Set;
import jp.agentec.abook.abv.bl.common.Callback; import jp.agentec.abook.abv.bl.common.Callback;
import jp.agentec.abook.abv.bl.common.CommonExecutor;
import jp.agentec.abook.abv.bl.common.Constant; import jp.agentec.abook.abv.bl.common.Constant;
import jp.agentec.abook.abv.bl.common.constant.ABookKeys; import jp.agentec.abook.abv.bl.common.constant.ABookKeys;
import jp.agentec.abook.abv.bl.common.constant.ABookValues; import jp.agentec.abook.abv.bl.common.constant.ABookValues;
import jp.agentec.abook.abv.bl.common.exception.ABVExceptionCode;
import jp.agentec.abook.abv.bl.common.exception.AcmsException;
import jp.agentec.abook.abv.bl.common.log.Logger; import jp.agentec.abook.abv.bl.common.log.Logger;
import jp.agentec.abook.abv.bl.logic.AbstractLogic;
import jp.agentec.abook.abv.bl.logic.OperationLogic;
import jp.agentec.abook.abv.cl.environment.DeviceInfo; import jp.agentec.abook.abv.cl.environment.DeviceInfo;
import jp.agentec.abook.abv.launcher.android.R; import jp.agentec.abook.abv.launcher.android.R;
import jp.agentec.abook.abv.ui.common.activity.ABVUIActivity; import jp.agentec.abook.abv.ui.common.activity.ABVUIActivity;
...@@ -50,6 +44,7 @@ import jp.agentec.abook.abv.ui.viewer.activity.theta.ThetaCameraActivity; ...@@ -50,6 +44,7 @@ import jp.agentec.abook.abv.ui.viewer.activity.theta.ThetaCameraActivity;
import jp.agentec.abook.abv.ui.viewer.activity.theta.task.DeviceInfoTask; import jp.agentec.abook.abv.ui.viewer.activity.theta.task.DeviceInfoTask;
import jp.agentec.abook.abv.ui.viewer.adapter.ImageGalleryAdapter; import jp.agentec.abook.abv.ui.viewer.adapter.ImageGalleryAdapter;
import jp.agentec.abook.abv.ui.viewer.adapter.WifiThetaConnectAdapter; import jp.agentec.abook.abv.ui.viewer.adapter.WifiThetaConnectAdapter;
import jp.agentec.abook.abv.ui.viewer.helper.SceneSendHelper;
import jp.agentec.abook.abv.ui.viewer.view.CustomImage; import jp.agentec.abook.abv.ui.viewer.view.CustomImage;
public class DeviceImageListActivity extends ABVUIActivity { public class DeviceImageListActivity extends ABVUIActivity {
...@@ -78,7 +73,7 @@ public class DeviceImageListActivity extends ABVUIActivity { ...@@ -78,7 +73,7 @@ public class DeviceImageListActivity extends ABVUIActivity {
GridView mGalleryGridView; GridView mGalleryGridView;
ImageGalleryAdapter mGalleryAdapter; ImageGalleryAdapter mGalleryAdapter;
private Set<String> mSelectedImages; private ArrayList<String> mSelectedImages;
private List<CustomImage>mLocalImageList; private List<CustomImage>mLocalImageList;
private Set<String>mLocalImageUriList; private Set<String>mLocalImageUriList;
public ImageInternalFetcher mImageFetcher; public ImageInternalFetcher mImageFetcher;
...@@ -87,12 +82,16 @@ public class DeviceImageListActivity extends ABVUIActivity { ...@@ -87,12 +82,16 @@ public class DeviceImageListActivity extends ABVUIActivity {
private int mGridViewRowHeight; private int mGridViewRowHeight;
private boolean mIsOnResume; private boolean mIsOnResume;
private Long mContentId; private Long mContentId;
private Long mOperationId;
private String mOperationName;
private Dialog mThetaDeviceConnectDialog; private Dialog mThetaDeviceConnectDialog;
private ListView notSavedListView; private ListView notSavedListView;
private ListView savedListView; private ListView savedListView;
private boolean isBaseSceneUpload = false; private boolean mIsBaseSceneUpload = false;
private boolean mIsBaseSceneUploadSuccess = true;
private ThetaHelper mThetaHelper = new ThetaHelper(this); private ThetaHelper mThetaHelper = new ThetaHelper(this);
private SceneSendHelper mSceneSendHelper = new SceneSendHelper(this);
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
...@@ -101,20 +100,19 @@ public class DeviceImageListActivity extends ABVUIActivity { ...@@ -101,20 +100,19 @@ public class DeviceImageListActivity extends ABVUIActivity {
setContentView(R.layout.ac_device_image_list); setContentView(R.layout.ac_device_image_list);
Intent intent = getIntent(); Intent intent = getIntent();
mContentId = intent.getLongExtra(ABookKeys.CONTENT_ID, -1); mIsBaseSceneUpload = intent.getBooleanExtra(ABookKeys.BASE_CONTENT_REGISTER, false);
if (mContentId == -1) { mOperationId = intent.getLongExtra(ABookKeys.OPERATION_ID, -1);
isBaseSceneUpload = true; mOperationName = intent.getStringExtra(ABookKeys.OPERATION_NAME);
} mSelectedImages = new ArrayList<>();
mSelectedImages = new HashSet<>();
mLocalImageList = new ArrayList<>(); mLocalImageList = new ArrayList<>();
mLocalImageUriList = new HashSet<>(); mLocalImageUriList = new HashSet<>();
mIsOnResume = false;
mIsBaseSceneUploadSuccess = false;
mImageFetcher = new ImageInternalFetcher(this, THUMBNALE_SIZE); mImageFetcher = new ImageInternalFetcher(this, THUMBNALE_SIZE);
mImageFetcher.addImageCache(this, THUMB_IMAGE_CACHE_DIRECTORY_NAME); mImageFetcher.addImageCache(this, THUMB_IMAGE_CACHE_DIRECTORY_NAME);
mImageFetcher.clearCache(); mImageFetcher.clearCache();
mIsOnResume = false;
mGalleryGridView = findViewById(R.id.gallery_grid); mGalleryGridView = findViewById(R.id.gallery_grid);
Button closeBtn = findViewById(R.id.close); // 閉じるボタン Button closeBtn = findViewById(R.id.close); // 閉じるボタン
closeBtn.setOnClickListener(new View.OnClickListener() { closeBtn.setOnClickListener(new View.OnClickListener() {
...@@ -123,9 +121,10 @@ public class DeviceImageListActivity extends ABVUIActivity { ...@@ -123,9 +121,10 @@ public class DeviceImageListActivity extends ABVUIActivity {
Logger.v(TAG, "CloseBtn.onClick"); Logger.v(TAG, "CloseBtn.onClick");
//キャッシュをクリア //キャッシュをクリア
mImageFetcher.clearCache(); mImageFetcher.clearCache();
finish(); activityClose();
} }
}); });
mRegistBtn = findViewById(R.id.regist); mRegistBtn = findViewById(R.id.regist);
mRegistBtn.setOnClickListener(new View.OnClickListener() { mRegistBtn.setOnClickListener(new View.OnClickListener() {
@Override @Override
...@@ -142,7 +141,6 @@ public class DeviceImageListActivity extends ABVUIActivity { ...@@ -142,7 +141,6 @@ public class DeviceImageListActivity extends ABVUIActivity {
} }
}); });
} }
} }
}); });
mRegistBtn.setEnabled(false); mRegistBtn.setEnabled(false);
...@@ -289,7 +287,7 @@ public class DeviceImageListActivity extends ABVUIActivity { ...@@ -289,7 +287,7 @@ public class DeviceImageListActivity extends ABVUIActivity {
* 端末のギャラリーから画像情報を元にして、GridViewビューア描画 * 端末のギャラリーから画像情報を元にして、GridViewビューア描画
*/ */
private void displayGalleryGridView() { private void displayGalleryGridView() {
mGalleryAdapter = new ImageGalleryAdapter(this, mLocalImageList, mGridViewRowHeight); mGalleryAdapter = new ImageGalleryAdapter(this, mLocalImageList, mGridViewRowHeight, mIsBaseSceneUpload);
mGalleryGridView.setAdapter(mGalleryAdapter); mGalleryGridView.setAdapter(mGalleryAdapter);
mGalleryGridView.setOnItemClickListener(new AdapterView.OnItemClickListener() { mGalleryGridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
private boolean isClicked = false; private boolean isClicked = false;
...@@ -297,7 +295,16 @@ public class DeviceImageListActivity extends ABVUIActivity { ...@@ -297,7 +295,16 @@ public class DeviceImageListActivity extends ABVUIActivity {
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
CustomImage customImage = mGalleryAdapter.getItem(i); CustomImage customImage = mGalleryAdapter.getItem(i);
if (containsCustomImageUri(customImage.mUri)) { if (containsCustomImageUri(customImage.mUri)) {
boolean isFirst = firstCustomImageUri(customImage.mUri);
mSelectedImages.remove(customImage.mUri.toString()); mSelectedImages.remove(customImage.mUri.toString());
//ベースシーンが削除された場合、2番目に選択された画像がベースシーン選択状態にする
if (mIsBaseSceneUpload) {
if (isFirst) {
mGalleryAdapter.notifyDataSetChanged();
mRegistBtn.setEnabled(mSelectedImages.size() != 0);
return;
}
}
} else { } else {
//最大選択画像をチェック //最大選択画像をチェック
if (mSelectedImages.size() + 1 > IMAGE_SELECT_MAX_COUNT) { if (mSelectedImages.size() + 1 > IMAGE_SELECT_MAX_COUNT) {
...@@ -336,34 +343,30 @@ public class DeviceImageListActivity extends ABVUIActivity { ...@@ -336,34 +343,30 @@ public class DeviceImageListActivity extends ABVUIActivity {
} }
/** /**
* 選択画像配列から1番目かチェック
* @param imageUri 画像ファイル情報
* @return true:1番目、false:2番目以上
*/
public boolean firstCustomImageUri(Uri imageUri){
if (mIsBaseSceneUpload && mIsBaseSceneUploadSuccess) {
return false;
}
return mSelectedImages.indexOf(imageUri.toString()) == 0;
}
/**
* 選択されている画像をサーバ側に送信する。 * 選択されている画像をサーバ側に送信する。
*/ */
private void sendImageList(final Set<String> sendImages) { private void sendImageList(final List<String> sendImages) {
showProgressView(PatternStringUtil.patternToString(getApplicationContext(), showProgressView(PatternStringUtil.patternToString(getApplicationContext(),
R.string.msg_access_registing, R.string.msg_access_registing,
getUserPref(AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0))); getUserPref(AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0)));
CommonExecutor.execute(new Runnable() { mSceneSendHelper.setListener(new SceneSendHelper.DeviceImageListSendListener() {
@Override /**
public void run() { * シーン登録成功した後、ダイアログ表示
final Set<String> needSendImages = new HashSet<>(sendImages); */
for(String filePath : sendImages){
File file = new File(filePath);
try {
AbstractLogic.getLogic(OperationLogic.class).sendScene(file, mContentId);
needSendImages.remove(filePath);
//プログレスバー進捗
final int progress = (int) (((float)(sendImages.size() - needSendImages.size()) / sendImages.size()) * 100);
runOnUiThread(new Runnable() {
@Override @Override
public void run() { public void sceneSendfinish() {
progressDialogHorizontal.setProgress(progress);
}
});
//送信終了
if (needSendImages.size() == 0) {
//プログレスバーを100%を表示してから非表示するため、ディレーする。
handler.postDelayed(new Runnable() { handler.postDelayed(new Runnable() {
@Override @Override
public void run() { public void run() {
...@@ -373,63 +376,89 @@ public class DeviceImageListActivity extends ABVUIActivity { ...@@ -373,63 +376,89 @@ public class DeviceImageListActivity extends ABVUIActivity {
AlertDialogUtil.showAlertDialog(DeviceImageListActivity.this, R.string.app_name, R.string.msg_image_select_send_success, true, new DialogInterface.OnClickListener() { AlertDialogUtil.showAlertDialog(DeviceImageListActivity.this, R.string.app_name, R.string.msg_image_select_send_success, true, new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
finish(); activityClose();
} }
}); });
} }
}, SEND_FINISH_DIALOG_DELAY_MILLIS); }, SEND_FINISH_DIALOG_DELAY_MILLIS);
} }
} catch (AcmsException ex) { /**
Logger.e(TAG, ex); * インジケーターのプログレスバー更新
if (ex.getCode() == ABVExceptionCode.P_E_ACMS_P007) { * @param progress プログレスバー設定値
// シーン追加時、ロック状態である場合 */
@Override
public void changeProgress(final int progress) {
runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {
@Override @Override
public void run() { public void run() {
closeProgressPopup(); if (mIsBaseSceneUpload) {
showSimpleAlertDialog(R.string.app_name, R.string.error_msg_open_pano_edit); mIsBaseSceneUploadSuccess = true;
} }
}); progressDialogHorizontal.setProgress(progress);
} else {
handler.post(new Runnable() {
@Override
public void run() {
sendImageFailDialog(needSendImages);
} }
}); });
} }
break; /**
} catch (Exception e) { * サーバ通信失敗時に再度送信要求しない。
Logger.e(TAG, e); * @param errorMessage エラーメッセージ
handler.post(new Runnable() { */
@Override
public void sceneSendFail(final String errorMessage) {
// シーン追加時、ロック状態である場合
runOnUiThread(new Runnable() {
@Override @Override
public void run() { public void run() {
sendImageFailDialog(needSendImages); closeProgressPopup();
} showSimpleAlertDialog(errorMessage);
});
break;
}
}
} }
}); });
} }
/** /**
* サーバ側通信時、失敗の時の再登録ダイアログ表示 * サーバ通信失敗時に再度送信要求する
* @param needSendImages 登録必要な画像URI配列 * @param sendImages 再送信画像FilePath配列
*/ */
private void sendImageFailDialog(final Set<String> needSendImages) { @Override
public void sceneSendFailRetry(final List<String> sendImages) {
handler.post(new Runnable() {
@Override
public void run() {
closeProgressPopup(); closeProgressPopup();
AlertDialogUtil.showAlertDialog(this, R.string.app_name, R.string.msg_image_select_send_fail_retry, false, new DialogInterface.OnClickListener() { //ベースシーンアップロード時、ベースシーン登録完了の場合、Cancelでシーン画像選択画面非表示
if (mIsBaseSceneUpload && mIsBaseSceneUploadSuccess) {
AlertDialogUtil.showAlertDialog(DeviceImageListActivity.this, R.string.app_name, R.string.msg_image_select_send_fail_retry, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) { //OKボタン
if (checkNetworkConnected()) {
sendImageList(sendImages);
}
}
}, new DialogInterface.OnClickListener() { //Cancelボタン
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
activityClose();
}
});
} else {
AlertDialogUtil.showAlertDialog(DeviceImageListActivity.this, R.string.app_name, R.string.msg_image_select_send_fail_retry, false, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) { //OKボタン
//インターネット非接続チェック //インターネット非接続チェック
if (checkNetworkConnected()) { if (checkNetworkConnected()) {
sendImageList(needSendImages); sendImageList(sendImages);
} }
} }
}); });
} }
}
});
}
});
mSceneSendHelper.sendSceneImages(sendImages, mOperationId, mOperationName, mIsBaseSceneUpload);
}
/** /**
* THETAカメラ接続ダイアログを表示 * THETAカメラ接続ダイアログを表示
...@@ -541,6 +570,33 @@ public class DeviceImageListActivity extends ABVUIActivity { ...@@ -541,6 +570,33 @@ public class DeviceImageListActivity extends ABVUIActivity {
} }
} }
/**
* デバイスのWifi有効・無効チェックし
* 無効の場合、ダイアログ表示
* @return true:有効, false:無効
*/
private boolean deviceWifiEnable() {
if (DeviceInfo.isDeviceWifiEnabled(DeviceImageListActivity.this)) {
return true;
} else {
showSimpleAlertDialog(R.string.msg_error_device_wifi_off);
return false;
}
}
/**
* ActivityをFinishする
*/
private void activityClose() {
//ベースシーン登録成功後、新着更新させるため
if (mIsBaseSceneUpload) {
if (mIsBaseSceneUploadSuccess) {
Intent data = new Intent();
setResult(RESULT_OK);
}
}
finish();
}
/** /**
* THETAカメラ情報取得完了後、呼ばれる * THETAカメラ情報取得完了後、呼ばれる
...@@ -575,18 +631,4 @@ public class DeviceImageListActivity extends ABVUIActivity { ...@@ -575,18 +631,4 @@ public class DeviceImageListActivity extends ABVUIActivity {
} }
} }
} }
/**
* デバイスのWifi有効・無効チェックし
* 無効の場合、ダイアログ表示
* @return true:有効, false:無効
*/
private boolean deviceWifiEnable() {
if (DeviceInfo.isDeviceWifiEnabled(DeviceImageListActivity.this)) {
return true;
} else {
showSimpleAlertDialog(R.string.msg_error_device_wifi_off);
return false;
}
}
} }
...@@ -94,7 +94,7 @@ public class ParentWebViewActivity extends ABVContentViewActivity { ...@@ -94,7 +94,7 @@ public class ParentWebViewActivity extends ABVContentViewActivity {
if (helper.checkMultiPermissions(true)) { if (helper.checkMultiPermissions(true)) {
//シーン画像選択画面表示 //シーン画像選択画面表示
Intent intent = new Intent(); Intent intent = new Intent();
intent.putExtra(ABookKeys.CONTENT_ID, contentId); intent.putExtra(ABookKeys.BASE_CONTENT_REGISTER, false);
String className = DeviceImageListActivity.class.getName(); String className = DeviceImageListActivity.class.getName();
if (isNormalSize() == false) { if (isNormalSize() == false) {
className += "Dialog"; className += "Dialog";
......
...@@ -18,11 +18,12 @@ public class ImageGalleryAdapter extends BaseAdapter { ...@@ -18,11 +18,12 @@ public class ImageGalleryAdapter extends BaseAdapter {
LayoutInflater inflater; LayoutInflater inflater;
List<CustomImage> imageUriList; List<CustomImage> imageUriList;
int mRowHeight; int mRowHeight;
boolean isBaseSceneUpload;
public ImageGalleryAdapter(Context context, List<CustomImage> imageUriList, int rowHeight) { public ImageGalleryAdapter(Context context, List<CustomImage> imageUriList, int rowHeight, boolean isBaseSceneUpload) {
this.context = context; this.context = context;
this.imageUriList = imageUriList; this.imageUriList = imageUriList;
this.mRowHeight = rowHeight; this.mRowHeight = rowHeight;
this.isBaseSceneUpload = isBaseSceneUpload;
inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
} }
...@@ -59,10 +60,19 @@ public class ImageGalleryAdapter extends BaseAdapter { ...@@ -59,10 +60,19 @@ public class ImageGalleryAdapter extends BaseAdapter {
CustomImage customImage = getItem(position); CustomImage customImage = getItem(position);
boolean isSelected = ((DeviceImageListActivity)context).containsCustomImageUri(customImage.mUri); boolean isSelected = ((DeviceImageListActivity)context).containsCustomImageUri(customImage.mUri);
holder.mThumbnailSelected.setImageResource(R.drawable.check_mark);
holder.mThumbnailSelected.setVisibility(View.INVISIBLE);
//ベースシーンチェック画像設定
if (isBaseSceneUpload) {
boolean isFirstImage = ((DeviceImageListActivity)context).firstCustomImageUri(customImage.mUri);
if (isFirstImage) {
holder.mThumbnailSelected.setImageResource(R.drawable.icon_base_content_check);
}
}
if (isSelected) { if (isSelected) {
holder.mThumbnailSelected.setVisibility(View.VISIBLE); holder.mThumbnailSelected.setVisibility(View.VISIBLE);
} else {
holder.mThumbnailSelected.setVisibility(View.INVISIBLE);
} }
if (holder.customImage == null || !holder.customImage.mUri.equals(customImage.mUri)) { if (holder.customImage == null || !holder.customImage.mUri.equals(customImage.mUri)) {
......
package jp.agentec.abook.abv.ui.viewer.helper;
import android.content.Context;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import jp.agentec.abook.abv.bl.common.CommonExecutor;
import jp.agentec.abook.abv.bl.common.exception.ABVExceptionCode;
import jp.agentec.abook.abv.bl.common.exception.AcmsException;
import jp.agentec.abook.abv.bl.common.log.Logger;
import jp.agentec.abook.abv.bl.logic.AbstractLogic;
import jp.agentec.abook.abv.bl.logic.OperationLogic;
import jp.agentec.abook.abv.launcher.android.R;
/**
* シーン画像ファイルをサーバへ登録する処理クラス
*/
public class SceneSendHelper {
private static final String TAG = "DeviceImageListHelper";
private SceneSendHelper.DeviceImageListSendListener listener;
private Context mContext;
public SceneSendHelper(Context context) {
mContext = context;
}
public void setListener(SceneSendHelper.DeviceImageListSendListener listener) {
this.listener = listener;
}
public interface DeviceImageListSendListener {
void sceneSendfinish();
void changeProgress(final int progress);
void sceneSendFail(final String errorMessage);
void sceneSendFailRetry(List<String> retrySendImages);
}
/**
* シーン画像をサーバへ送信
* @param sendImages シーン画像ファイルPath配列
* @param operationId 作業ID
* @param OperationName 作業名
* @param isBaseSceneUpload ベースシーン登録フラグ(true:登録、false:登録しない)
*/
public void sendSceneImages(final List<String> sendImages, final Long operationId, final String OperationName, final boolean isBaseSceneUpload) {
CommonExecutor.execute(new Runnable() {
@Override
public void run() {
String firstFilePath = sendImages.get(0);
final List<String> needSendImages = new ArrayList<>(sendImages);
for(String filePath : sendImages){
File file = new File(filePath);
try {
if (isBaseSceneUpload && firstFilePath.equals(filePath)) {
AbstractLogic.getLogic(OperationLogic.class).sendPanoContent(operationId, OperationName, file);
} else {
AbstractLogic.getLogic(OperationLogic.class).sendScene(file);
}
needSendImages.remove(filePath);
//プログレスバー進捗
int progress = (int) (((float)(sendImages.size() - needSendImages.size()) / sendImages.size()) * 100);
listener.changeProgress(progress);
//送信終了
if (needSendImages.size() == 0) {
listener.sceneSendfinish();
}
} catch (AcmsException ex) {
Logger.e(TAG, ex);
if (ex.getCode() == ABVExceptionCode.P_E_ACMS_P007) {
listener.sceneSendFail(mContext.getString(R.string.error_msg_open_pano_edit));
} else {
listener.sceneSendFailRetry(needSendImages);
}
break;
} catch (Exception e) {
Logger.e(TAG, e);
listener.sceneSendFailRetry(needSendImages);
break;
}
}
}
});
}
}
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