Commit 8d3866b7 by Kim Jinsung

Merge branch 'features/1.0.500_#33721' into 'feature/1.1.0'

Features/1.0.500 #33721

See merge request !17
parents f819c828 3ea100c1
......@@ -37,6 +37,7 @@ public class PhotoEditActivity extends Dialog {
private final String TAG = "PhotoEditActivity";
private final String editToolPath = "file:///android_asset/Drawing/index.html"; //EditToolのパス。
private final String editToolName = "Drawing"; //EditToolの名
private final float screenToDialogRatio = 0.8f; // 編集画面のタイアローグに表示するイメージの比率
private WebView editPageWebView; //ダイアローグの上に編集画面をロード
private Bitmap bitmapOfPhoto; //写真のBitmap情報
private int photoWidth;
......@@ -44,7 +45,6 @@ public class PhotoEditActivity extends Dialog {
private String photoFilePath; //ロードして修正するファイルのパス
private JsInf jsInf = new JsInf(); //Javascript Interface
private Context context;
private int screenRequestedOrientation;
/**
* 生成される時、イメージパスを取得。
......@@ -80,25 +80,29 @@ public class PhotoEditActivity extends Dialog {
Window window = ((Activity) context).getWindow();
window.getDecorView().getWindowVisibleDisplayFrame(displayRectangle);
//画面の方向によってダイアローグのサイズを決定
int screenOrientation = context.getResources().getConfiguration().orientation; //画面の方向
switch (screenOrientation){
case Surface.ROTATION_0: case Surface.ROTATION_180: //横
float photoRatio = (float) photoWidth / (float) photoHeight; //画面の横と縦の割合
float displayHeight = displayRectangle.height() * 0.9f; //画面の縦幅の90パーセント
float displayWidth = displayRectangle.width() * 0.9f; //画面の横幅の90パーセント
int dialogWidth = (int) (displayHeight * photoRatio); //ダイアローグの横幅を計算
if(dialogWidth < displayWidth){ //計算した横幅が画面より小さい場合はそのまま設定
getWindow().setLayout(dialogWidth, ViewGroup.LayoutParams.WRAP_CONTENT);
}
else{ //計算した横幅が画面より大き場合は画面の横幅に設定
if(getWindow() != null) {
//画面の方向によってダイアローグのサイズを決定
int screenOrientation = context.getResources().getConfiguration().orientation; //画面の方向
switch (screenOrientation) {
case Surface.ROTATION_0:
case Surface.ROTATION_180: //横
float photoRatio = (float) photoWidth / (float) photoHeight; //画面の横と縦の割合
float displayHeight = (float) displayRectangle.height() * screenToDialogRatio; //画面の縦幅の90パーセント
float displayWidth = (float) displayRectangle.width() * screenToDialogRatio; //画面の横幅の90パーセント
int dialogWidth = (int) (displayHeight * photoRatio); //ダイアローグの横幅を計算
if (dialogWidth < displayWidth) { //計算した横幅が画面より小さい場合はそのまま設定
getWindow().setLayout(dialogWidth, ViewGroup.LayoutParams.WRAP_CONTENT);//ViewGroup.LayoutParams.WRAP_CONTENT);
} else { //計算した横幅が画面より大き場合は画面の横幅に設定
getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
}
break;
case Surface.ROTATION_90:
case Surface.ROTATION_270: //縦
//画面方向が縦の場合、画面の横幅に設定
getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
}
break;
case Surface.ROTATION_90: case Surface.ROTATION_270: //縦
//画面方向が縦の場合、画面の横幅に設定
getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
break;
break;
}
}
//クローズボタン
......@@ -134,7 +138,7 @@ public class PhotoEditActivity extends Dialog {
if (url.contains(editToolName)) {
//最初ページロードの場合
//ページロードの終了後のCanvas設定
float photoRatio = (float) (bitmapOfPhoto.getHeight()) / (float) bitmapOfPhoto.getWidth(); //写真の割合を計算
float photoRatio = (float) photoHeight / (float) photoWidth; //写真の割合を計算
view.loadUrl(String.format("javascript:resizeCanvasToRatio(%f);", photoRatio)); //写真の割合によってCanvasのサイズを決める。
view.loadUrl(String.format("javascript:setBackground('%s');", photoFilePath)); //Canvasの背景をイメージにする
}
......@@ -239,6 +243,7 @@ public class PhotoEditActivity extends Dialog {
ABookAlertDialog aBookAlertDialog = AlertDialogUtil.createAlertDialog(context, title, message);
aBookAlertDialog.setIcon(R.drawable.icon);
aBookAlertDialog.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
//OKボタンを押すと編集画面を閉じる
superDismiss();
......@@ -307,7 +312,7 @@ public class PhotoEditActivity extends Dialog {
* @param newHeight 新しい縦幅
* @return 変更したイメージを返す。
*/
public static Bitmap scaleBitmap(Bitmap bitmap, int newWidth, int newHeight) {
private static Bitmap scaleBitmap(Bitmap bitmap, int newWidth, int newHeight) {
Bitmap scaledBitmap = Bitmap.createBitmap(newWidth, newHeight, Bitmap.Config.ARGB_8888);
float scaleX = newWidth / (float) bitmap.getWidth();
......@@ -324,9 +329,4 @@ public class PhotoEditActivity extends Dialog {
return scaledBitmap;
}
@Override
public void onWindowAttributesChanged(WindowManager.LayoutParams params) {
return;
}
}
\ No newline at end of file
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