1 package jp.sourceforge.gokigen.memoma;
3 import android.app.Activity;
4 import android.app.AlertDialog;
5 import android.app.Dialog;
6 import android.content.DialogInterface;
7 import android.content.Intent;
8 import android.content.SharedPreferences;
9 import android.graphics.Color;
10 import android.graphics.PorterDuff.Mode;
11 import android.graphics.drawable.BitmapDrawable;
12 import android.net.Uri;
13 import android.os.Bundle;
14 import android.preference.PreferenceManager;
15 import android.support.v7.app.AppCompatActivity;
16 import android.util.Log;
17 import android.view.KeyEvent;
18 import android.view.Menu;
19 import android.view.MenuItem;
20 import android.view.MotionEvent;
21 import android.view.View;
22 import android.view.View.OnClickListener;
23 import android.view.View.OnKeyListener;
24 import android.view.View.OnTouchListener;
25 import android.widget.ImageButton;
26 import android.widget.SeekBar;
28 import jp.sourceforge.gokigen.memoma.dialogs.ConfirmationDialog;
29 import jp.sourceforge.gokigen.memoma.dialogs.CreditDialog;
30 import jp.sourceforge.gokigen.memoma.dialogs.TextEditDialog;
31 import jp.sourceforge.gokigen.memoma.drawers.MeMoMaCanvasDrawer;
32 import jp.sourceforge.gokigen.memoma.extension.ExtensionActivity;
33 import jp.sourceforge.gokigen.memoma.fileio.MeMoMaDataInOutManager;
34 import jp.sourceforge.gokigen.memoma.holders.LineStyleHolder;
35 import jp.sourceforge.gokigen.memoma.holders.MeMoMaConnectLineHolder;
36 import jp.sourceforge.gokigen.memoma.holders.MeMoMaObjectHolder;
37 import jp.sourceforge.gokigen.memoma.holders.OperationModeHolder;
44 public class MeMoMaListener implements OnClickListener, OnTouchListener, OnKeyListener, IObjectSelectionReceiver, ConfirmationDialog.IResultReceiver, ObjectDataInputDialog.IResultReceiver, ItemSelectionDialog.ISelectionItemReceiver, TextEditDialog.ITextEditResultReceiver, ObjectAligner.IAlignCallback, SelectLineShapeDialog.IResultReceiver
46 public static final int MENU_ID_PREFERENCES = (Menu.FIRST + 1); // 設定画面の表示
47 public static final int MENU_ID_ABOUT_GOKIGEN = (Menu.FIRST + 2); // アプリケーションの情報表示
48 public static final int MENU_ID_NEW = (Menu.FIRST + 3); // 新規作成
49 public static final int MENU_ID_EXTEND= (Menu.FIRST + 4); // 拡張機能
50 public static final int MENU_ID_ALIGN = (Menu.FIRST + 5); // オブジェクトの整列
51 public static final int MENU_ID_INSERT_PICTURE = (Menu.FIRST + 6); // 画像の指定
52 public static final int MENU_ID_OPERATION = (Menu.FIRST + 7); // 操作コマンド
53 public static final int MENU_ID_RENAME = (Menu.FIRST + 8); // リネーム
54 public static final int MENU_ID_CAPTURE = (Menu.FIRST + 9); // 画像のキャプチャ
55 public static final int MENU_ID_SHARE = (Menu.FIRST + 10); // 画像の共有
58 private AppCompatActivity parent = null; // 親分
59 private TextEditDialog editTextDialog = null; // テキスト編集用ダイアログ
60 private MeMoMaCanvasDrawer objectDrawer = null; // 画像の表示
61 private MeMoMaObjectHolder objectHolder = null; // オブジェクトの保持クラス
62 private MeMoMaConnectLineHolder lineHolder =null; // オブジェクト間の接続状態保持クラス
63 //private SelectFeatureListener featureListener = null; // 機能選択用のリスナ
65 private MeMoMaDataInOutManager dataInOutManager = null;
67 private OperationModeHolder drawModeHolder = null;
68 private LineStyleHolder lineStyleHolder = null;
70 private ConfirmationDialog confirmationDialog = null;
72 private ObjectDataInputDialog objectDataInputDialog = null;
74 private SelectLineShapeDialog lineSelectionDialog = null;
76 private ItemSelectionDialog itemSelectionDialog = null;
77 private ObjectOperationCommandHolder commandHolder = null;
79 private boolean isEditing = false;
80 private Integer selectedObjectKey = 0;
81 private Integer objectKeyToDelete = 0;
82 private Integer selectedContextKey = 0;
88 public MeMoMaListener(AppCompatActivity argument, MeMoMaDataInOutManager inoutManager)
91 dataInOutManager = inoutManager;
92 lineHolder = new MeMoMaConnectLineHolder();
93 objectHolder = new MeMoMaObjectHolder(argument, lineHolder);
94 editTextDialog = new TextEditDialog(parent, R.drawable.icon);
95 //lineHolder = new MeMoMaConnectLineHolder();
96 //featureListener = new SelectFeatureListener(parent);
97 drawModeHolder = new OperationModeHolder(parent);
99 lineStyleHolder = new LineStyleHolder(parent);
100 lineStyleHolder.prepare();
103 confirmationDialog = new ConfirmationDialog(argument);
104 confirmationDialog.prepare(this, android.R.drawable.ic_dialog_alert, parent.getString(R.string.createnew_title), parent.getString(R.string.createnew_message));
106 // オブジェクトのデータ入力ダイアログを生成
107 objectDataInputDialog = new ObjectDataInputDialog(argument, objectHolder);
108 objectDataInputDialog.setResultReceiver(this);
110 // 接続線の形状と太さを選択するダイアログを生成
111 lineSelectionDialog = new SelectLineShapeDialog(argument, lineStyleHolder);
112 lineSelectionDialog.setResultReceiver(this);
115 commandHolder = new ObjectOperationCommandHolder(argument);
116 itemSelectionDialog = new ItemSelectionDialog(argument);
117 itemSelectionDialog.prepare(this, commandHolder, parent.getString(R.string.object_operation));
120 objectDrawer = new MeMoMaCanvasDrawer(argument, objectHolder, lineStyleHolder, this);
122 SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent);
123 String colorString = preferences.getString("backgroundColor", "0xff004000");
124 objectDrawer.setBackgroundColor(colorString);
129 * がっつりこのクラスにイベントリスナを接続する
132 public void prepareListener()
134 SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent);
137 final ImageButton homeButton = (ImageButton) parent.findViewById(R.id.HomeButton);
138 homeButton.setOnClickListener(this);
141 final ImageButton expandButton = (ImageButton) parent.findViewById(R.id.ExpandButton);
142 expandButton.setOnClickListener(this);
145 final ImageButton createObjectButton = (ImageButton) parent.findViewById(R.id.CreateObjectButton);
146 createObjectButton.setOnClickListener(this);
148 final ImageButton deleteObjectButton = (ImageButton) parent.findViewById(R.id.DeleteObjectButton);
149 deleteObjectButton.setOnClickListener(this);
152 final ImageButton lineStyleButton = (ImageButton) parent.findViewById(R.id.LineStyleButton);
153 lineStyleButton.setOnClickListener(this);
156 final ImageButton saveButton = (ImageButton) parent.findViewById(R.id.SaveButton);
157 saveButton.setOnClickListener(this);
160 final GokigenSurfaceView surfaceView = (GokigenSurfaceView) parent.findViewById(R.id.GraphicView);
161 surfaceView.setOnTouchListener(this);
164 final SeekBar seekbar = (SeekBar) parent.findViewById(R.id.ZoomInOut);
165 seekbar.setOnSeekBarChangeListener(objectDrawer);
166 int progress = preferences.getInt("zoomProgress", 50);
167 seekbar.setProgress(progress);
170 parent.setProgressBarIndeterminateVisibility(false);
179 public void finishListener()
188 public void prepareToStart()
190 // 設定に記録されているデータを画面に反映させる
191 SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent);
194 //int objectStyle = Integer.parseInt(preferences.getString("drawStyle", "0"));
200 updateButtons(Integer.parseInt(preferences.getString("operationMode", "0")));
202 // 条件に合わせて、描画クラスを変更する
203 final GokigenSurfaceView surfaceView = (GokigenSurfaceView) parent.findViewById(R.id.GraphicView);
204 surfaceView.setCanvasDrawer(objectDrawer);
207 String backgroundString = preferences.getString("backgroundUri", "");
208 objectDrawer.setBackgroundUri(backgroundString);
214 public void shutdown()
225 public void onActivityResult(int requestCode, int resultCode, Intent data)
227 if ((requestCode == MENU_ID_INSERT_PICTURE)&&(resultCode == Activity.RESULT_OK))
231 // 取得したuri を preferenceに記録する
232 SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent);
233 Uri backgroundUri = data.getData();
234 SharedPreferences.Editor editor = preferences.edit();
235 editor.putString("backgroundUri", backgroundUri.toString());
239 updateBackgroundImage(backgroundUri.toString());
245 Log.v(Main.APP_IDENTIFIER, "Ex:" + ex.toString() + " " + ex.getMessage());
249 else if (requestCode == MENU_ID_PREFERENCES)
252 SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent);
253 String colorString = preferences.getString("backgroundColor", "0xff004000");
254 objectDrawer.setBackgroundColor(colorString);
257 String backgroundString = preferences.getString("backgroundUri", "");
258 updateBackgroundImage(backgroundString);
260 Log.v(Main.APP_IDENTIFIER, "RETURENED PREFERENCES " + backgroundString);
263 else if (requestCode == MENU_ID_EXTEND)
265 // その他...今開いているファイルを読みなおす
266 dataInOutManager.loadFile((String) parent.getTitle());
282 private void updateBackgroundImage(String uri)
285 GokigenSurfaceView graphView = (GokigenSurfaceView) parent.findViewById(R.id.GraphicView);
288 objectDrawer.updateBackgroundBitmap(uri, graphView.getWidth(), graphView.getHeight());
298 public void onClick(View v)
302 //Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::onClick() " + id);
303 if (id == R.id.MeMoMaInfo)
306 showInfoMessageEditDialog();
308 else if (id == R.id.LineStyleButton)
310 // ライン形状を変えるダイアログで変更するように変更する
311 selectLineShapeDialog();
313 else if (id == R.id.ExpandButton)
318 else if ((id == R.id.DeleteObjectButton)||(id == R.id.CreateObjectButton))
320 // 削除ボタン or 作成ボタンが押された時の処理
321 updateButtons(drawModeHolder.updateOperationMode(id));
323 else if (id == R.id.HomeButton)
326 // 表示倍率と並行移動についてリセットする
327 objectDrawer.resetScaleAndLocation((SeekBar) parent.findViewById(R.id.ZoomInOut));
332 else if (id == R.id.SaveButton)
343 public boolean onTouch(View v, MotionEvent event)
346 // int action = event.getAction();
348 //Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::onTouch() " + id);
350 if (id == R.id.GraphicView)
353 ((GokigenSurfaceView) v).onTouchEvent(event);
362 public boolean onKey(View v, int keyCode, KeyEvent event)
364 int action = event.getAction();
365 if ((action == KeyEvent.ACTION_DOWN)&&(keyCode == KeyEvent.KEYCODE_DPAD_CENTER))
370 Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::onKey() ");
379 public Menu onCreateOptionsMenu(Menu menu)
382 MenuItem menuItem = menu.add(Menu.NONE, MENU_ID_NEW, Menu.NONE, parent.getString(R.string.createnew));
383 menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); /* for Android 3.1 */
384 menuItem.setIcon(android.R.drawable.ic_menu_add); // 丸プラス
387 menuItem = menu.add(Menu.NONE, MENU_ID_SHARE, Menu.NONE, parent.getString(R.string.shareContent));
388 menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); /* for Android 3.1 */
389 menuItem.setIcon(android.R.drawable.ic_menu_share);
392 menuItem = menu.add(Menu.NONE, MENU_ID_CAPTURE, Menu.NONE, parent.getString(R.string.capture_data));
393 menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); /* for Android 3.1 */
394 menuItem.setIcon(android.R.drawable.ic_menu_crop); // オブジェクトのキャプチャ
397 menuItem = menu.add(Menu.NONE, MENU_ID_ALIGN, Menu.NONE, parent.getString(R.string.align_data));
398 menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); /* for Android 3.1 */
399 menuItem.setIcon(android.R.drawable.ic_menu_rotate); // オブジェクトの整列
402 menuItem = menu.add(Menu.NONE, MENU_ID_RENAME, Menu.NONE, parent.getString(R.string.rename_title));
403 menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); /* for Android 3.1 */
404 menuItem.setIcon(android.R.drawable.ic_menu_edit); // タイトルの変更
407 menuItem = menu.add(Menu.NONE, MENU_ID_INSERT_PICTURE, Menu.NONE, parent.getString(R.string.background_data));
408 menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); /* for Android 3.1 */
409 menuItem.setIcon(android.R.drawable.ic_menu_gallery); // 壁紙の選択
412 menuItem = menu.add(Menu.NONE, MENU_ID_EXTEND, Menu.NONE, parent.getString(R.string.extend_menu));
413 menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); /* for Android 3.1 */
414 menuItem.setIcon(android.R.drawable.ic_menu_share); // 拡張メニュー...
417 menuItem = menu.add(Menu.NONE, MENU_ID_PREFERENCES, Menu.NONE, parent.getString(R.string.preference_name));
418 menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); /* for Android 3.1 */
419 menuItem.setIcon(android.R.drawable.ic_menu_preferences);
422 menuItem = menu.add(Menu.NONE, MENU_ID_ABOUT_GOKIGEN, Menu.NONE, parent.getString(R.string.about_gokigen));
423 menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); /* for Android 3.1 */
424 menuItem.setIcon(android.R.drawable.ic_menu_info_details);
434 public void onPrepareOptionsMenu(Menu menu)
436 menu.findItem(MENU_ID_NEW).setVisible(true);
437 menu.findItem(MENU_ID_SHARE).setVisible(true);
438 menu.findItem(MENU_ID_CAPTURE).setVisible(true);
439 menu.findItem(MENU_ID_ALIGN).setVisible(true);
440 menu.findItem(MENU_ID_RENAME).setVisible(true);
441 menu.findItem(MENU_ID_INSERT_PICTURE).setVisible(true);
442 menu.findItem(MENU_ID_EXTEND).setVisible(true);
443 menu.findItem(MENU_ID_PREFERENCES).setVisible(true);
444 menu.findItem(MENU_ID_ABOUT_GOKIGEN).setVisible(true);
449 * メニューのアイテムが選択されたときの処理
453 public boolean onOptionsItemSelected(MenuItem item)
455 boolean result = false;
456 switch (item.getItemId())
458 case MENU_ID_PREFERENCES:
463 case MENU_ID_ABOUT_GOKIGEN:
486 // タイトル名の変更 (テキスト編集ダイアログを表示する)
487 showInfoMessageEditDialog();
491 case MENU_ID_INSERT_PICTURE:
497 case MENU_ID_CAPTURE:
498 // 画面キャプチャを指示された場合...
504 // 画面キャプチャ&共有を指示された場合...
509 case android.R.id.home:
510 /** アイコンが押された時の処理... **/
512 showInfoMessageEditDialog();
524 * 画像ファイルの挿入 (データファイルの更新)
527 private void insertPicture()
529 Intent intent = new Intent();
530 intent.setType("image/*");
531 intent.setAction(Intent.ACTION_GET_CONTENT);
532 parent.startActivityForResult(intent, MENU_ID_INSERT_PICTURE);
540 private void doCapture(boolean isShare)
542 // 画面のスクリーンショットをとる処理を実行する
543 dataInOutManager.doScreenCapture((String) parent.getTitle(), objectHolder, objectDrawer, isShare);
553 private void showAboutGokigen()
555 // アプリの情報(クレジット)を表示する!
556 parent.showDialog(R.id.info_about_gokigen);
563 private void callExtendMenu()
565 // 現在表示中のデータをファイルに保存する
566 dataInOutManager.saveFile((String) parent.getTitle(), true);
568 // 現在読み込んでいるファイルのファイル名を生成する
569 String fullPath = dataInOutManager.getDataFileFullPath((String) parent.getTitle(), ".xml");
572 // (渡すデータを作って Intentとする)
573 Intent intent = new Intent();
575 intent.setAction(ExtensionActivity.MEMOMA_EXTENSION_LAUNCH_ACTIVITY);
576 intent.putExtra(ExtensionActivity.MEMOMA_EXTENSION_DATA_FULLPATH, fullPath);
577 intent.putExtra(ExtensionActivity.MEMOMA_EXTENSION_DATA_TITLE, (String) parent.getTitle());
579 // データ表示用Activityを起動する
580 parent.startActivityForResult(intent, MENU_ID_EXTEND);
587 private void prepareMeMoMaInfo()
589 // 設定に記録されているデータを画面のタイトルに反映させる
590 SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent);
591 String memomaInfo = preferences.getString("MeMoMaInfo", parent.getString(R.string.app_name));
592 parent.setTitle(memomaInfo);
595 android.support.v7.app.ActionBar bar = parent.getSupportActionBar();
598 dataInOutManager.prepare(objectHolder, bar, memomaInfo);
601 //dataInOutManager.loadFile((String) parent.getTitle());
608 * @param forceOverwrite trueの時は、ファイル名が確定していたときは(確認せずに)上書き保存を自動で行う。
611 private void saveData(boolean forceOverwrite)
613 dataInOutManager.saveFile((String) parent.getTitle(), forceOverwrite);
620 private void alignData()
622 ObjectAligner aligner = new ObjectAligner(parent, this);
623 aligner.execute(objectHolder);
630 private void showInfoMessageEditDialog()
632 parent.showDialog(R.id.editTextArea);
636 * 新規作成が指示されたとき...全部クリアして作りなおして良いか確認する。
639 private void createNewScreen()
641 parent.showDialog(R.id.confirmation);
647 private void selectLineShapeDialog()
649 // 接続線の設定ダイアログを表示する...
650 parent.showDialog(R.id.selectline_dialog);
654 * メッセージ編集ダイアログの表示を準備する
657 private void prepareInfoMessageEditDialog(Dialog dialog)
659 String message = (String) parent.getTitle();
660 editTextDialog.prepare(dialog, this, parent.getString(R.string.dataTitle), message, true);
664 * メッセージ編集ダイアログの表示を準備する
667 private void prepareConfirmationDialog(Dialog dialog)
669 // Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::prepareConfirmationDialog() " );
673 * オブジェクト入力用ダイアログの表示を準備する
676 private void prepareObjectInputDialog(Dialog dialog)
678 Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::prepareObjectInputDialog(), key: " + selectedObjectKey);
681 objectDataInputDialog.prepareObjectInputDialog(dialog, selectedObjectKey);
686 * アイテム選択ダイアログの表示を準備する
690 private void prepareItemSelectionDialog(Dialog dialog)
693 // (動的変更時。。。今回は固定なので何もしない)
697 * 接続線選択用ダイアログの表示を準備する
700 private void prepareLineSelectionDialog(Dialog dialog)
702 Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::prepareLineSelectionDialog(), key: " + selectedObjectKey);
705 lineSelectionDialog.prepareSelectLineShapeDialog(dialog, selectedObjectKey);
711 private void showPreference()
716 Intent prefIntent = new Intent(parent,jp.sourceforge.gokigen.memoma.Preference.class);
717 parent.startActivityForResult(prefIntent, MENU_ID_PREFERENCES);
722 //updater.showMessage("ERROR", MainUpdater.SHOWMETHOD_DONTCARE);
730 private void setLineStyle()
732 int buttonId = LineStyleHolder.getLineShapeImageId(lineStyleHolder.getLineStyle(), lineStyleHolder.getLineShape());
733 final ImageButton lineStyleObj = (ImageButton) parent.findViewById(R.id.LineStyleButton);
734 lineStyleObj.setImageResource(buttonId);
741 public void objectCreated()
743 // ここで動作モードを移動モードに戻す。
744 drawModeHolder.changeOperationMode(OperationModeHolder.OPERATIONMODE_MOVE);
745 updateButtons(OperationModeHolder.OPERATIONMODE_MOVE);
755 public int touchedVacantArea()
757 SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent);
758 return (Integer.parseInt(preferences.getString("operationMode", "0")));
765 public int touchUppedVacantArea()
767 SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent);
768 return (Integer.parseInt(preferences.getString("operationMode", "0")));
772 * オブジェクトを本当に削除して良いか確認した後に、オブジェクトを削除する。
776 private void removeObject(Integer key)
778 // 本当に消して良いか、確認をするダイアログを表示して、OKが押されたら消す。
779 AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(parent);
780 alertDialogBuilder.setTitle(parent.getString(R.string.deleteconfirm_title));
781 alertDialogBuilder.setIcon(android.R.drawable.ic_dialog_alert);
782 alertDialogBuilder.setMessage(parent.getString(R.string.deleteconfirm_message));
784 // 削除するオブジェクトのキーを覚えこむ。
785 objectKeyToDelete = key;
788 alertDialogBuilder.setPositiveButton(parent.getString(R.string.confirmYes), new DialogInterface.OnClickListener()
790 public void onClick(DialogInterface dialog, int id)
792 // 削除モードの時... 確認後削除だけど、今は確認なしで削除を行う。
793 objectHolder.removePosition(objectKeyToDelete);
795 // 削除するオブジェクトに接続されている線もすべて削除する
796 objectHolder.getConnectLineHolder().removeAllConnection(objectKeyToDelete);
801 // ここで動作モードを削除モードから移動モードに戻す。
802 drawModeHolder.changeOperationMode(OperationModeHolder.OPERATIONMODE_MOVE);
803 updateButtons(OperationModeHolder.OPERATIONMODE_MOVE);
812 alertDialogBuilder.setNegativeButton(parent.getString(R.string.confirmNo), new DialogInterface.OnClickListener()
814 public void onClick(DialogInterface dialog, int id)
820 // ダイアログはキャンセル可能に設定する
821 alertDialogBuilder.setCancelable(true);
824 AlertDialog alertDialog = alertDialogBuilder.create();
835 private void duplicateObject(Integer key)
838 objectHolder.duplicatePosition(key);
849 private void expandObject(Integer key)
852 objectHolder.expandObjectSize(key);
862 private void shrinkObject(Integer key)
865 objectHolder.shrinkObjectSize(key);
871 private void setButtonBorder(ImageButton button, boolean isHighlight)
875 BitmapDrawable btnBackgroundShape = (BitmapDrawable)button.getBackground();
876 if (isHighlight == true)
878 // btnBackgroundShape.setColorFilter(Color.rgb(51, 181, 229), Mode.LIGHTEN);
879 btnBackgroundShape.setColorFilter(Color.BLUE, Mode.LIGHTEN);
883 btnBackgroundShape.setColorFilter(Color.BLACK, Mode.LIGHTEN);
889 Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::setButtonBorder(): " + ex.toString());
897 private void updateButtons(int mode)
899 final ImageButton createObjectButton = (ImageButton) parent.findViewById(R.id.CreateObjectButton);
900 final ImageButton deleteObjectButton = (ImageButton) parent.findViewById(R.id.DeleteObjectButton);
902 if (mode == OperationModeHolder.OPERATIONMODE_DELETE)
904 setButtonBorder(createObjectButton, false);
905 setButtonBorder(deleteObjectButton, true);
907 else if (mode == OperationModeHolder.OPERATIONMODE_CREATE)
909 setButtonBorder(createObjectButton, true);
910 setButtonBorder(deleteObjectButton, false);
912 else // if (mode == OperationModeHolder.OPERATIONMODE_MOVE)
914 setButtonBorder(createObjectButton, false);
915 setButtonBorder(deleteObjectButton, false);
921 * オブジェクトが選択された(長押しで!)
924 public void objectSelectedContext(Integer key)
926 Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::objectSelectedContext(), key:" + key);
927 selectedContextKey = key;
929 // オブジェクトのアイテム選択ダイアログを表示する...
930 parent.showDialog(MENU_ID_OPERATION);
939 public boolean objectSelected(Integer key)
941 SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent);
942 int operationMode = Integer.parseInt(preferences.getString("operationMode", "0"));
943 if (operationMode == OperationModeHolder.OPERATIONMODE_DELETE)
950 //if ((operationMode == OperationModeHolder.OPERATIONMODE_MOVE)||
951 // (operationMode == OperationModeHolder.OPERATIONMODE_CREATE))
954 selectedObjectKey = key;
955 Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::objectSelected() key : " + key);
957 // オブジェクトの詳細設定ダイアログを表示する...
958 parent.showDialog(R.id.objectinput_dialog);
967 public Dialog onCreateDialog(int id)
969 if (id == R.id.info_about_gokigen)
972 CreditDialog dialog = new CreditDialog(parent);
973 return (dialog.getDialog());
975 if (id == R.id.editTextArea)
978 return (editTextDialog.getDialog());
980 if (id == R.id.confirmation)
983 return (confirmationDialog.getDialog());
985 if (id == R.id.objectinput_dialog)
987 // オブジェクト入力のダイアログを表示する
988 return (objectDataInputDialog.getDialog());
990 if (id == MENU_ID_OPERATION)
993 return (itemSelectionDialog.getDialog());
995 if (id == R.id.selectline_dialog)
998 return (lineSelectionDialog.getDialog());
1007 public void onPrepareDialog(int id, Dialog dialog)
1009 if (id == R.id.editTextArea)
1012 prepareInfoMessageEditDialog(dialog);
1015 if (id == R.id.confirmation)
1018 prepareConfirmationDialog(dialog);
1021 if (id == R.id.objectinput_dialog)
1023 // オブジェクト入力のダイアログを表示する
1024 prepareObjectInputDialog(dialog);
1026 if (id == MENU_ID_OPERATION)
1028 // オブジェクト操作選択のダイアログを表示する
1029 prepareItemSelectionDialog(dialog);
1031 if (id == R.id.selectline_dialog)
1034 prepareLineSelectionDialog(dialog);
1042 public void acceptConfirmation()
1045 Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::acceptConfirmation()");
1048 objectHolder.removeAllPositions(); // オブジェクトの保持クラス
1049 objectHolder.getConnectLineHolder().removeAllLines(); // オブジェクト間の接続状態保持クラス
1051 // 画面の倍率と表示位置を初期状態に戻す
1052 if (objectDrawer != null)
1054 final SeekBar zoomBar = (SeekBar) parent.findViewById(R.id.ZoomInOut);
1055 objectDrawer.resetScaleAndLocation(zoomBar);
1059 // 題名を "無題"に変更し、関係情報をクリアする
1060 String newName = parent.getString(R.string.no_name);
1061 parent.setTitle(newName);
1062 SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent);
1063 SharedPreferences.Editor editor = preferences.edit();
1064 editor.putString("MeMoMaInfo", newName);
1069 redrawSurfaceview();
1072 showInfoMessageEditDialog();
1080 private void redrawSurfaceview()
1082 final GokigenSurfaceView surfaceview = (GokigenSurfaceView) parent.findViewById(R.id.GraphicView);
1083 surfaceview.doDraw();
1090 public void rejectConfirmation()
1092 Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::rejectConfirmation()");
1099 public void objectAligned()
1102 redrawSurfaceview();
1106 * オブジェクト編集ダイアログが閉じられた時の処理
1109 public void finishObjectInput()
1112 redrawSurfaceview();
1116 * オブジェクト編集ダイアログが閉じられた時の処理
1119 public void cancelObjectInput()
1130 public boolean isEditing()
1140 public void setIsEditing(boolean value)
1149 public void itemSelected(int index, String itemValue)
1152 Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::itemSelected() : " + itemValue + " [" + index + "]");
1154 if (index == ObjectOperationCommandHolder.OBJECTOPERATION_DELETE)
1157 removeObject(selectedContextKey);
1159 else if (index == ObjectOperationCommandHolder.OBJECTOPERATION_DUPLICATE)
1162 duplicateObject(selectedContextKey);
1164 else if (index == ObjectOperationCommandHolder.OBJECTOPERATION_SIZEBIGGER)
1167 expandObject(selectedContextKey);
1169 else if (index == ObjectOperationCommandHolder.OBJECTOPERATION_SIZESMALLER)
1172 shrinkObject(selectedContextKey);
1180 public void itemSelectedMulti(String[] items, boolean[] status)
1184 public void canceledSelection()
1189 public void onSaveInstanceState(Bundle outState)
1192 //Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::onSaveInstanceState()");
1195 public void onRestoreInstanceState(Bundle savedInstanceState)
1198 Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::onRestoreInstanceState()");
1201 public boolean finishTextEditDialog(String message)
1203 if ((message == null)||(message.length() == 0))
1205 // データが入力されていなかったので、何もしない。
1210 SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent);
1211 SharedPreferences.Editor editor = preferences.edit();
1212 editor.putString("MeMoMaInfo", message);
1216 parent.setTitle(message);
1222 dataInOutManager.updateFileList(message, parent.getSupportActionBar());
1226 public boolean cancelTextEditDialog()
1235 public void finishSelectLineShape(int style, int shape, int thickness)
1237 int buttonId = LineStyleHolder.getLineShapeImageId(style, shape);
1238 final ImageButton lineStyleObj = (ImageButton) parent.findViewById(R.id.LineStyleButton);
1239 lineStyleObj.setImageResource(buttonId);
1240 //Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::finishSelectLineShape() buttonId:" + buttonId);
1247 public void cancelSelectLineShape()