apply plugin: 'com.android.application'
+apply plugin: 'kotlin-android'
android {
compileSdkVersion 33
versionName "1.3.1"
multiDexEnabled true
}
-
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
-
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
dependencies {
api fileTree(dir: 'libs', include: ['*.jar'])
+ implementation "androidx.core:core-ktx:1.10.0"
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.preference:preference:1.2.0'
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
-
<application android:icon="@drawable/icon" android:label="@string/app_name" android:theme="@style/Theme.AppCompat">
-
<activity android:name=".Main"
android:exported="true"
android:screenOrientation="landscape">
+++ /dev/null
-package jp.sourceforge.gokigen.memoma;
-
-import android.os.Build;
-import android.Manifest;
-import android.app.Dialog;
-import android.content.Intent;
-import android.content.pm.PackageManager;
-import android.os.Bundle;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.view.Window;
-
-import jp.sourceforge.gokigen.memoma.io.MeMoMaDataInOutManager;
-
-import static android.os.Build.VERSION_CODES.KITKAT;
-
-import androidx.appcompat.app.AppCompatActivity;
-import androidx.core.app.ActivityCompat;
-import androidx.core.content.ContextCompat;
-
-/**
- * メイン画面の処理
- *
- * @author MRSa
- *
- */
-public class Main extends AppCompatActivity
-{
- public static final String APP_IDENTIFIER = "Gokigen";
- public static final String APP_BASEDIR = "/MeMoMa";
- public static final String APP_NAMESPACE = "gokigen";
-
- private MeMoMaListener listener = null; // イベント処理クラス
-
-
- /** Called when the activity is first created. */
- @Override
- public void onCreate(Bundle savedInstanceState)
- {
- final int REQUEST_NEED_PERMISSIONS = 1010;
-
- super.onCreate(savedInstanceState);
-
- // データ保存・展開クラス を生成する
- // リスナクラスを生成する
- listener = new MeMoMaListener(this, new MeMoMaDataInOutManager(this));
-
- // タイトルにプログレスバーを出せるようにする
- requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
-
- // タイトルバーにアクションバーを出す
-// requestWindowFeature(Window.FEATURE_ACTION_BAR);
- requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
-
- // レイアウトを設定する **/
- setContentView(R.layout.main);
-
- // 外部メモリアクセス権のオプトイン
- if (((ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED))||
- (ContextCompat.checkSelfPermission(this, Manifest.permission.MANAGE_DOCUMENTS) != PackageManager.PERMISSION_GRANTED))
- {
- if (Build.VERSION.SDK_INT >= KITKAT)
- {
- ActivityCompat.requestPermissions(this,
- new String[]{
- Manifest.permission.WRITE_EXTERNAL_STORAGE,
- Manifest.permission.MANAGE_DOCUMENTS,
- },
- REQUEST_NEED_PERMISSIONS);
- }
- else
- {
- ActivityCompat.requestPermissions(this,
- new String[]{
- Manifest.permission.WRITE_EXTERNAL_STORAGE,
- },
- REQUEST_NEED_PERMISSIONS);
- }
- }
-
- try
- {
- // リスナクラスの準備
- listener.prepareListener();
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
-
- /**
- * メニューの生成
- */
- @Override
- public boolean onCreateOptionsMenu(Menu menu)
- {
- try
- {
- menu = listener.onCreateOptionsMenu(menu);
- return (super.onCreateOptionsMenu(menu));
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- return (false);
- }
-
- /**
- * メニューアイテムの選択
- */
- @Override
- public boolean onOptionsItemSelected(MenuItem item)
- {
- try
- {
- return (listener.onOptionsItemSelected(item));
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- return (false);
- }
-
- /**
- * メニュー表示前の処理
- */
- @Override
- public boolean onPrepareOptionsMenu(Menu menu)
- {
- try
- {
- listener.onPrepareOptionsMenu(menu);
- return (super.onPrepareOptionsMenu(menu));
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- return (false);
- }
-
- /**
- * 画面が裏に回ったときの処理
- */
- @Override
- public void onPause()
- {
- super.onPause();
- try
- {
- // 動作を止めるようイベント処理クラスに指示する
- listener.shutdown();
- }
- catch (Exception ex)
- {
- ex.printStackTrace();
- }
- }
-
- /**
- * 画面が表に出てきたときの処理
- */
- @Override
- public void onResume()
- {
- super.onResume();
- try
- {
- // 動作準備するようイベント処理クラスに指示する
- listener.prepareToStart();
- }
- catch (Exception ex)
- {
- ex.printStackTrace();
- }
- }
-
- /**
- * 終了時の処理
- *
- */
- @Override
- protected void onDestroy()
- {
- try
- {
- listener.finishListener();
- super.onDestroy();
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
-
- /**
- *
- */
- @Override
- protected void onStart()
- {
- super.onStart();
- }
-
- /**
- *
- */
- @Override
- protected void onStop()
- {
- super.onStop();
- }
-
- /**
- *
- */
- @Override
- protected void onSaveInstanceState(Bundle outState)
- {
- try
- {
- super.onSaveInstanceState(outState);
- if (listener != null)
- {
- // ここでActivityの情報を覚える
- listener.onSaveInstanceState(outState);
- }
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
-
- /**
- *
- */
- @Override
- protected void onRestoreInstanceState(Bundle savedInstanceState)
- {
- super.onRestoreInstanceState(savedInstanceState);
- try
- {
- if (listener != null)
- {
- // ここでActivityの情報を展開する
- listener.onRestoreInstanceState(savedInstanceState);
- }
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
-
- /**
- * ダイアログ表示の準備
- *
- */
- @Override
- protected Dialog onCreateDialog(int id)
- {
- try
- {
- return (listener.onCreateDialog(id));
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- return (null);
- }
-
- /**
- * ダイアログ表示の準備
- *
- */
- @Override
- protected void onPrepareDialog(int id, Dialog dialog)
- {
- try
- {
- listener.onPrepareDialog(id, dialog);
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
-
- /**
- * 子画面から応答をもらったときの処理
- */
- @Override
- protected void onActivityResult(int requestCode, int resultCode, Intent data)
- {
- super.onActivityResult(requestCode, resultCode, data);
- try
- {
- // 子画面からもらった情報の応答処理をイベント処理クラスに依頼する
- listener.onActivityResult(requestCode, resultCode, data);
- }
- catch (Exception ex)
- {
- ex.printStackTrace();
- }
- }
-}
--- /dev/null
+package jp.sourceforge.gokigen.memoma
+
+import android.app.Dialog
+import android.content.Intent
+import android.os.Bundle
+import android.util.Log
+import android.view.Menu
+import android.view.MenuItem
+import android.view.Window
+import androidx.appcompat.app.AppCompatActivity
+import jp.sourceforge.gokigen.memoma.io.MeMoMaDataInOutManager
+
+/**
+ * メイン画面の処理
+ */
+class Main : AppCompatActivity()
+{
+ private lateinit var listener: MeMoMaListener // イベント処理クラス
+
+ public override fun onCreate(savedInstanceState: Bundle?)
+ {
+ super.onCreate(savedInstanceState)
+
+ // リスナクラスを生成する
+ listener = MeMoMaListener(this, MeMoMaDataInOutManager(this))
+
+ // タイトルにプログレスバーを出せるようにする
+ supportRequestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS)
+
+ // タイトルバーにアクションバーを出す
+ supportRequestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY)
+
+ // レイアウトを設定する **/
+ setContentView(R.layout.main)
+
+ try
+ {
+ // リスナクラスの準備
+ listener.prepareListener()
+ }
+ catch (e: Exception)
+ {
+ e.printStackTrace()
+ }
+ Log.v(TAG, " START MEMOMA...");
+ }
+
+ /**
+ * メニューの生成
+ */
+ override fun onCreateOptionsMenu(menu: Menu): Boolean
+ {
+ try
+ {
+ val menu0 = listener.onCreateOptionsMenu(menu)
+ return (super.onCreateOptionsMenu(menu0))
+ }
+ catch (e: Exception)
+ {
+ e.printStackTrace()
+ }
+ return false
+ }
+
+ /**
+ * メニューアイテムの選択
+ */
+ override fun onOptionsItemSelected(item: MenuItem): Boolean
+ {
+ try
+ {
+ return listener.onOptionsItemSelected(item)
+ }
+ catch (e: Exception)
+ {
+ e.printStackTrace()
+ }
+ return false
+ }
+
+ /**
+ * メニュー表示前の処理
+ */
+ override fun onPrepareOptionsMenu(menu: Menu): Boolean
+ {
+ try
+ {
+ listener.onPrepareOptionsMenu(menu)
+ return (super.onPrepareOptionsMenu(menu))
+ }
+ catch (e: Exception)
+ {
+ e.printStackTrace()
+ }
+ return false
+ }
+
+ /**
+ * 画面が裏に回ったときの処理
+ */
+ public override fun onPause()
+ {
+ super.onPause()
+ try
+ {
+ // 動作を止めるようイベント処理クラスに指示する
+ listener.shutdown()
+ }
+ catch (ex: Exception)
+ {
+ ex.printStackTrace()
+ }
+ }
+
+ /**
+ * 画面が表に出てきたときの処理
+ */
+ public override fun onResume()
+ {
+ super.onResume()
+ try
+ {
+ // 動作準備するようイベント処理クラスに指示する
+ listener.prepareToStart()
+ }
+ catch (ex: Exception)
+ {
+ ex.printStackTrace()
+ }
+ }
+
+ /**
+ * 終了時の処理
+ */
+ override fun onDestroy()
+ {
+ try
+ {
+ listener.finishListener()
+ super.onDestroy()
+ }
+ catch (e: Exception)
+ {
+ e.printStackTrace()
+ }
+ }
+
+ /**
+ *
+ */
+ override fun onSaveInstanceState(outState: Bundle)
+ {
+ try
+ {
+ super.onSaveInstanceState(outState)
+ if (::listener.isInitialized)
+ {
+ // ここでActivityの情報を覚える
+ listener.onSaveInstanceState(outState)
+ }
+ }
+ catch (e: Exception)
+ {
+ e.printStackTrace()
+ }
+ }
+
+ /**
+ *
+ */
+ override fun onRestoreInstanceState(savedInstanceState: Bundle)
+ {
+ super.onRestoreInstanceState(savedInstanceState)
+ try
+ {
+ if (::listener.isInitialized)
+ {
+ // ここでActivityの情報を展開する
+ listener.onRestoreInstanceState(savedInstanceState)
+ }
+ }
+ catch (e: Exception)
+ {
+ e.printStackTrace()
+ }
+ }
+
+ /**
+ * ダイアログ表示の準備
+ *
+ */
+ override fun onCreateDialog(id: Int): Dialog
+ {
+ return listener.onCreateDialog(id)
+ }
+
+ /**
+ * ダイアログ表示の準備
+ *
+ */
+ override fun onPrepareDialog(id: Int, dialog: Dialog)
+ {
+ try
+ {
+ listener.onPrepareDialog(id, dialog)
+ }
+ catch (e: Exception)
+ {
+ e.printStackTrace()
+ }
+ }
+
+ /**
+ * 子画面から応答をもらったときの処理
+ */
+ override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?)
+ {
+ super.onActivityResult(requestCode, resultCode, data)
+ try
+ {
+ // 子画面からもらった情報の応答処理をイベント処理クラスに依頼する
+ listener.onActivityResult(requestCode, resultCode, data)
+ }
+ catch (ex: Exception)
+ {
+ ex.printStackTrace()
+ }
+ }
+
+ companion object {
+ const val APP_NAMESPACE = "gokigen"
+ private val TAG = Main::class.java.simpleName
+ }
+}
*/
public class MeMoMaListener implements OnClickListener, OnTouchListener, OnKeyListener, IObjectSelectionReceiver, ConfirmationDialog.IResultReceiver, ObjectDataInputDialog.IResultReceiver, ItemSelectionDialog.ISelectionItemReceiver, TextEditDialog.ITextEditResultReceiver, ObjectAligner.IAlignCallback, SelectLineShapeDialog.IResultReceiver
{
+ private final String TAG = toString();
+
private static final int MENU_ID_PREFERENCES = (Menu.FIRST + 1); // 設定画面の表示
private static final int MENU_ID_ABOUT_GOKIGEN = (Menu.FIRST + 2); // アプリケーションの情報表示
private static final int MENU_ID_NEW = (Menu.FIRST + 3); // 新規作成
private static final int MENU_ID_SHARE = (Menu.FIRST + 10); // 画像の共有
private static final int MENU_ID_UNDO = (Menu.FIRST + 11); // 処理の UNDO
- private AppCompatActivity parent; // 親分
- private TextEditDialog editTextDialog; // テキスト編集用ダイアログ
- private MeMoMaCanvasDrawer objectDrawer; // 画像の表示
- private MeMoMaObjectHolder objectHolder; // オブジェクトの保持クラス
- //private SelectFeatureListener featureListener = null; // 機能選択用のリスナ
-
- private MeMoMaDataInOutManager dataInOutManager;
-
- private OperationModeHolder drawModeHolder;
- private LineStyleHolder lineStyleHolder;
+ private final AppCompatActivity parent; // 親分
+ private final TextEditDialog editTextDialog; // テキスト編集用ダイアログ
+ private final MeMoMaCanvasDrawer objectDrawer; // 画像の表示
+ private final MeMoMaObjectHolder objectHolder; // オブジェクトの保持クラス
+ private final MeMoMaDataInOutManager dataInOutManager;
+ private final OperationModeHolder drawModeHolder;
+ private final LineStyleHolder lineStyleHolder;
- private ConfirmationDialog confirmationDialog;
- private ObjectDataInputDialog objectDataInputDialog;
- private SelectLineShapeDialog lineSelectionDialog;
- private ItemSelectionDialog itemSelectionDialog;
+ private final ConfirmationDialog confirmationDialog;
+ private final ObjectDataInputDialog objectDataInputDialog;
+ private final SelectLineShapeDialog lineSelectionDialog;
+ private final ItemSelectionDialog itemSelectionDialog;
private Integer selectedObjectKey = 0;
private Integer objectKeyToDelete = 0;
// 「実行中」の表示を消す
parent.setProgressBarIndeterminateVisibility(false);
- //// 起動時にデータを読み出す
+ // 起動時にデータを読み出す
prepareMeMoMaInfo();
}
{
try
{
- if (Build.VERSION.SDK_INT >= 19) {
- final int takeFlags = data.getFlags() & (Intent.FLAG_GRANT_READ_URI_PERMISSION);
- parent.getContentResolver().takePersistableUriPermission(backgroundUri, takeFlags);
+ if (Build.VERSION.SDK_INT >= 19)
+ {
+ parent.getContentResolver().takePersistableUriPermission(backgroundUri, Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
}
SharedPreferences.Editor editor = preferences.edit();
editor.putString("backgroundUri", backgroundUri.toString());
}
catch (Exception ex)
{
- Log.v(Main.APP_IDENTIFIER, "Ex:" + ex.toString() + " " + ex.getMessage());
+ Log.v(TAG, "Ex:" + ex.getMessage());
+ ex.printStackTrace();
}
return;
}
String backgroundString = preferences.getString("backgroundUri", "");
updateBackgroundImage(backgroundString);
- Log.v(Main.APP_IDENTIFIER, "RETURENED PREFERENCES " + backgroundString);
+ Log.v(TAG, "RETURENED PREFERENCES " + backgroundString);
}
else if (requestCode == MENU_ID_EXTEND)
int action = event.getAction();
if ((action == KeyEvent.ACTION_DOWN)&&(keyCode == KeyEvent.KEYCODE_DPAD_CENTER))
{
- Log.v(Main.APP_IDENTIFIER, "KEY ENTER");
+ Log.v(TAG, "KEY ENTER");
}
- Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::onKey() ");
+ Log.v(TAG, "MeMoMaListener::onKey() ");
return (false);
}
*/
private void prepareObjectInputDialog(Dialog dialog)
{
- Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::prepareObjectInputDialog(), key: " + selectedObjectKey);
+ Log.v(TAG, "MeMoMaListener::prepareObjectInputDialog(), key: " + selectedObjectKey);
// ダイアログの準備を行う
objectDataInputDialog.prepareObjectInputDialog(dialog, selectedObjectKey);
*/
private void prepareLineSelectionDialog(Dialog dialog)
{
- Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::prepareLineSelectionDialog(), key: " + selectedObjectKey);
+ Log.v(TAG, "MeMoMaListener::prepareLineSelectionDialog(), key: " + selectedObjectKey);
// ダイアログの準備を行う
lineSelectionDialog.prepareSelectLineShapeDialog(dialog, selectedObjectKey);
catch (Exception ex)
{
//
- Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::setButtonBorder(): " + ex.toString());
+ Log.v(TAG, "MeMoMaListener::setButtonBorder(): " + ex.toString());
}
}
*/
public void objectSelectedContext(Integer key)
{
- Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::objectSelectedContext(), key:" + key);
+ Log.v(TAG, "MeMoMaListener::objectSelectedContext(), key:" + key);
selectedContextKey = key;
// オブジェクトのアイテム選択ダイアログを表示する...
{
// 選択されたオブジェクトを記憶する
selectedObjectKey = key;
- Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::objectSelected() key : " + key);
+ Log.v(TAG, "MeMoMaListener::objectSelected() key : " + key);
// オブジェクトの詳細設定ダイアログを表示する...
parent.showDialog(R.id.objectinput_dialog);
public void acceptConfirmation()
{
//
- Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::acceptConfirmation()");
+ Log.v(TAG, "MeMoMaListener::acceptConfirmation()");
// オブジェクトデータをクリアする。
objectHolder.removeAllPositions(); // オブジェクトの保持クラス
*/
public void rejectConfirmation()
{
- Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::rejectConfirmation()");
+ Log.v(TAG, "MeMoMaListener::rejectConfirmation()");
}
/**
public void itemSelected(int index, String itemValue)
{
//
- Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::itemSelected() : " + itemValue + " [" + index + "]");
+ Log.v(TAG, "MeMoMaListener::itemSelected() : " + itemValue + " [" + index + "]");
if (index == ObjectOperationCommandHolder.OBJECTOPERATION_DELETE)
{
public void onSaveInstanceState(Bundle outState)
{
/* ここで状態を保存 */
- Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::onSaveInstanceState() : " + outState.toString() );
+ Log.v(TAG, "MeMoMaListener::onSaveInstanceState() : " + outState.toString() );
}
public void onRestoreInstanceState(Bundle savedInstanceState)
{
/* ここで状態を復元 */
- Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::onRestoreInstanceState() : " + savedInstanceState.toString());
+ Log.v(TAG, "MeMoMaListener::onRestoreInstanceState() : " + savedInstanceState.toString());
}
public void finishTextEditDialog(String message)
int buttonId = LineStyleHolder.getLineShapeImageId(style, shape);
final ImageButton lineStyleObj =parent.findViewById(R.id.LineStyleButton);
lineStyleObj.setImageResource(buttonId);
- // Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::finishSelectLineShape() buttonId:" + buttonId);
}
/**
import android.view.View;
import android.widget.ListView;
-import jp.sourceforge.gokigen.memoma.io.ExternalStorageFileUtility;
import jp.sourceforge.gokigen.memoma.holders.MeMoMaDataFileHolder;
import jp.sourceforge.gokigen.memoma.R;
* コンストラクタ
*
*/
- public FileSelectionDialog(Context arg, String titleMessage, ExternalStorageFileUtility utility, String extension, IResultReceiver receiver)
+ public FileSelectionDialog(Context arg, String titleMessage, String extension, IResultReceiver receiver)
{
context = arg;
resultReceiver = receiver;
title = titleMessage;
fileExtension = extension;
- dataFileHolder = new MeMoMaDataFileHolder(context, android.R.layout.simple_list_item_1, utility, extension);
+ dataFileHolder = new MeMoMaDataFileHolder(context, android.R.layout.simple_list_item_1, extension);
}
/**
* ファイル一覧データをつくる!
*
*/
- public void prepare(String currentFileName, String extendDirectory)
+ public void prepare()
{
- dataFileHolder.updateFileList(currentFileName, extendDirectory);
+ dataFileHolder.updateFileList("");
}
/**
import android.view.View;
import android.widget.TextView;
-import jp.sourceforge.gokigen.memoma.Main;
import jp.sourceforge.gokigen.memoma.R;
/**
*/
public class TextEditDialog
{
+ private final String TAG = toString();
private final Context context;
private ITextEditResultReceiver resultReceiver = null;
private final int icon;
catch (Exception ex)
{
// ログだけ吐いて、何もしない
- Log.v(Main.APP_IDENTIFIER, "TextEditDialog::prepare() " + ex.toString());
+ Log.v(TAG, "TextEditDialog::prepare() " + ex.toString());
}
}
package jp.sourceforge.gokigen.memoma.dialogs;
-import android.app.Activity;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.widget.TextView;
+import androidx.appcompat.app.AppCompatActivity;
+
/**
* テキストデータの反映
- *
- * @author MRSa
- *
*/
public class TextEditReceiver implements TextEditDialog.ITextEditResultReceiver
{
- private Activity parent;
- private String textId;
- private int textResId;
+ private final AppCompatActivity parent;
+ private final String textId;
+ private final int textResId;
/**
* コンストラクタ
- *
*/
- public TextEditReceiver(Activity argument, String prefId, int resId)
+ public TextEditReceiver(AppCompatActivity argument, String prefId, int resId)
{
textId = prefId;
parent = argument;
/**
* データの更新
- *
*/
public void finishTextEditDialog(String message)
{
import android.view.SurfaceHolder;
import android.view.SurfaceView;
-import jp.sourceforge.gokigen.memoma.Main;
-
/**
* 描画するくらす
*
*/
public class GokigenSurfaceView extends SurfaceView implements SurfaceHolder.Callback
{
+ private final String TAG = toString();
ICanvasDrawer canvasDrawer = null;
/**
if (canvas == null)
{
// 描画領域が取れないから抜けてしまう
- Log.v(Main.APP_IDENTIFIER, "GokigenSurfaceView::doDraw() canvas is null." );
+ Log.v(TAG, "GokigenSurfaceView::doDraw() canvas is null." );
return;
}
canvas.save();
}
catch (Exception ex)
{
- Log.v(Main.APP_IDENTIFIER, "ex.(doDraw())>" + ex.toString() + " " + ex.getMessage());
+ Log.v(TAG, "ex.(doDraw())>" + ex.toString() + " " + ex.getMessage());
}
}
package jp.sourceforge.gokigen.memoma.drawers;
import java.util.Enumeration;
-import android.app.Activity;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.widget.SeekBar;
import android.widget.TextView;
+import androidx.appcompat.app.AppCompatActivity;
+
import jp.sourceforge.gokigen.memoma.holders.ObjectConnector;
import jp.sourceforge.gokigen.memoma.holders.PositionObject;
import jp.sourceforge.gokigen.memoma.operations.IObjectSelectionReceiver;
import jp.sourceforge.gokigen.memoma.io.ImageLoader;
-import jp.sourceforge.gokigen.memoma.Main;
import jp.sourceforge.gokigen.memoma.R;
import jp.sourceforge.gokigen.memoma.holders.LineStyleHolder;
import jp.sourceforge.gokigen.memoma.holders.MeMoMaConnectLineHolder;
*/
public class MeMoMaCanvasDrawer implements ICanvasDrawer, GestureDetector.OnGestureListener, ScaleGestureDetector.OnScaleGestureListener, SeekBar.OnSeekBarChangeListener
{
+ private final String TAG = toString();
+
public static final float OBJECTLABEL_MARGIN = 8.0f;
public static final float OBJECTLABEL_MARGIN_WIDTH = 24.0f;
private final GestureDetector gestureDetector;
private final ScaleGestureDetector scaleGestureDetector;
- private final Activity parent;
+ private final AppCompatActivity parent;
/**
* コンストラクタ
*
*/
- public MeMoMaCanvasDrawer(Activity argument, MeMoMaObjectHolder object, LineStyleHolder styleHolder, IObjectSelectionReceiver receiver)
+ public MeMoMaCanvasDrawer(AppCompatActivity argument, MeMoMaObjectHolder object, LineStyleHolder styleHolder, IObjectSelectionReceiver receiver)
{
objectHolder = object;
lineHolder = objectHolder.getConnectLineHolder();
try
{
// とりあえず設定する情報をログに残してみる
- Log.v(Main.APP_IDENTIFIER, "MeMoMaCanvasDrawer::updateBackgroundBitmap() : w:" + width + " , h:"+ height + " " + uri);
+ Log.v(TAG, "MeMoMaCanvasDrawer::updateBackgroundBitmap() : w:" + width + " , h:"+ height + " " + uri);
// 背景画像を取得して設定する。
backgroundBitmap = ImageLoader.getBitmapFromUri(parent, ImageLoader.parseUri(uri), width, height);
}
catch (Exception ex)
{
- Log.v(Main.APP_IDENTIFIER, "MeMoMaCanvasDrawer::updateBackgroundBitmap() : " + uri + " , "+ ex.toString());
+ Log.v(TAG, "MeMoMaCanvasDrawer::updateBackgroundBitmap() : " + uri + " , "+ ex.toString());
ex.printStackTrace();
backgroundBitmap = null;
backgroundBitmapUri = "";
*/
public void prepareToStart(int width, int height)
{
- Log.v(Main.APP_IDENTIFIER, "MeMoMaCanvasDrawer::prepareToStart() " + "x:" + width + " , " + "y:" + height);
+ Log.v(TAG, "MeMoMaCanvasDrawer::prepareToStart() " + "x:" + width + " , " + "y:" + height);
// 背景画像を更新する
//updateBackgroundBitmap(backgroundBitmapUri, width, height);
screenWidth = width;
screenHeight = height;
- Log.v(Main.APP_IDENTIFIER, "changedScreenProperty() " + "x:" + width + " , " + "y:" + height);
+ Log.v(TAG, "changedScreenProperty() " + "x:" + width + " , " + "y:" + height);
}
catch (Exception ex)
{
// 例外発生...でもそのときには何もしない
- Log.v(Main.APP_IDENTIFIER, "drawOnCanvas() ex: " + ex.getMessage());
+ Log.v(TAG, "drawOnCanvas() ex: " + ex.getMessage());
}
}
catch (Exception ex)
{
// 例外発生...でもそのときには何もしない
- Log.v(Main.APP_IDENTIFIER, "drawOnBitmapCanvas() ex: " + ex.toString() + " " + ex.getMessage());
+ Log.v(TAG, "drawOnBitmapCanvas() ex: " + ex.toString() + " " + ex.getMessage());
}
}
else
{
// ここは呼ばれないはず。。。消したはずのものが残っている
- Log.v(Main.APP_IDENTIFIER, "DETECTED DELETED LINE");
+ Log.v(TAG, "DETECTED DELETED LINE");
}
}
}
catch (Exception ex)
{
// なにもしない
- Log.v(Main.APP_IDENTIFIER, "EXCEPTION :" + ex.toString());
+ Log.v(TAG, "EXCEPTION :" + ex.toString());
}
}
if ((tempPosX == Float.MIN_VALUE)||(tempPosY == Float.MIN_VALUE)||(downPosX == Float.MIN_VALUE)||(downPosY == Float.MIN_VALUE))
{
// タッチが2つ揃っていないので、何もしない。
- Log.v(Main.APP_IDENTIFIER, "onTouchUp : (" + downPosX + "," + downPosY + ") [" + drawScale + "] (" + tempPosX + "," + tempPosY + ") [" + drawTransX + "," + drawTransY + "]");
+ Log.v(TAG, "onTouchUp : (" + downPosX + "," + downPosY + ") [" + drawScale + "] (" + tempPosX + "," + tempPosY + ") [" + drawTransX + "," + drawTransY + "]");
return (false);
}
if (((diffX > 2.0f)||(diffY > 2.0f))||(longPress))
{
// タッチが離された場所にはオブジェクトがなかった場合...オブジェクトをその位置に移動させる
- Log.v(Main.APP_IDENTIFIER, "MOVE OBJECT : (" + diffX + "," + diffY + ")");
+ Log.v(TAG, "MOVE OBJECT : (" + diffX + "," + diffY + ")");
moveObjectPosition(x, y);
return (true);
}
// タッチが押された位置と離された位置が同じ位置だった場合......アイテムが選択された、と認識する。
- Log.v(Main.APP_IDENTIFIER, " ITEM SELECTED :" + x + "," + y);
+ Log.v(TAG, " ITEM SELECTED :" + x + "," + y);
if (selectionReceiver != null)
{
// アイテムが選択されたよ!と教える
isDraw = gestureDetector.onTouchEvent(event);
if (isDraw)
{
- Log.v(Main.APP_IDENTIFIER, "MeMoMaCanvasDrawer::onTouchEvent() : isDraw == true");
+ Log.v(TAG, "MeMoMaCanvasDrawer::onTouchEvent() : isDraw == true");
return (true);
}
RectF posRect = pos.getRect();
if (posRect.contains(x, y))
{
- Log.v(Main.APP_IDENTIFIER, "SELECTED :" + posRect.centerX() + "," + posRect.centerY() + " KEY :" + key);
+ Log.v(TAG, "SELECTED :" + posRect.centerX() + "," + posRect.centerY() + " KEY :" + key);
return (pos);
}
//Log.v(Main.APP_IDENTIFIER, "NOT MATCH :" + pos.rect.centerX() + "," + pos.rect.centerY());
*/
private void disconnectObjects(float startX, float startY, float endX, float endY)
{
- Log.v(Main.APP_IDENTIFIER, "MeMoMaCanvasDrawer::disconnectObjects() [" + startX + "," + startY +"]-[" + endX + "," + endY + "]");
+ Log.v(TAG, "MeMoMaCanvasDrawer::disconnectObjects() [" + startX + "," + startY +"]-[" + endX + "," + endY + "]");
try
{
Enumeration<Integer> keys = lineHolder.getLineKeys();
drawScale = preferences.getFloat("drawScale", 1.0f);
drawTransX = preferences.getFloat("drawTransX", 0.0f);
drawTransY = preferences.getFloat("drawTransY", 0.0f);
- Log.v(Main.APP_IDENTIFIER, "restoreTranslateAndZoomScale() : x" + drawScale + " X:" + drawTransX + " Y: " + drawTransY);
+ Log.v(TAG, "restoreTranslateAndZoomScale() : x" + drawScale + " X:" + drawTransX + " Y: " + drawTransY);
}
/**
*/
public void onLongPress(MotionEvent event)
{
- Log.v(Main.APP_IDENTIFIER, "MeMoMaCanvasDrawer::onLongPress() " + event.getX() + "," + event.getY());
+ Log.v(TAG, "MeMoMaCanvasDrawer::onLongPress() " + event.getX() + "," + event.getY());
// タッチ位置をオブジェクト画像の座標に変換する
float x = (event.getX() - drawTransX) / drawScale;
import android.widget.Toast;
import jp.sourceforge.gokigen.memoma.holders.PositionObject;
-import jp.sourceforge.gokigen.memoma.io.ExternalStorageFileUtility;
import jp.sourceforge.gokigen.memoma.dialogs.FileSelectionDialog;
import jp.sourceforge.gokigen.memoma.Main;
import jp.sourceforge.gokigen.memoma.io.MeMoMaFileExportCsvProcess;
*/
public class ExtensionActivityListener implements OnClickListener, MeMoMaFileLoadingProcess.IResultReceiver, MeMoMaFileExportCsvProcess.IResultReceiver, FileSelectionDialog.IResultReceiver, MeMoMaFileImportCsvProcess.IResultReceiver
{
+ private final String TAG = toString();
private final int MENU_ID_EXPORT= (Menu.FIRST + 1);
private final int MENU_ID_SHARE = (Menu.FIRST + 2);
private final int MENU_ID_IMPORT = (Menu.FIRST + 3);
private static final String EXTENSION_DIRECTORY = "/exported";
- private ExternalStorageFileUtility fileUtility;
+ //private ExternalStorageFileUtility fileUtility;
private MeMoMaObjectHolder objectHolder;
private FileSelectionDialog fileSelectionDialog = null;
ExtensionActivityListener(Activity argument)
{
parent = argument;
- fileUtility = new ExternalStorageFileUtility(Main.APP_BASEDIR);
+ //fileUtility = new ExternalStorageFileUtility(Main.APP_BASEDIR);
objectHolder = new MeMoMaObjectHolder(parent);
}
/**
}
catch (Exception ex)
{
- Log.v(Main.APP_IDENTIFIER, "Exception :" + ex.toString());
+ Log.v(TAG, "Exception :" + ex.toString());
}
}
*/
public void prepareToStart()
{
- Log.v(Main.APP_IDENTIFIER, "ExtensionActivityListener::prepareToStart() : " + objectHolder.getDataTitle());
+ Log.v(TAG, "ExtensionActivityListener::prepareToStart() : " + objectHolder.getDataTitle());
// アクションバーを表示する
ActionBar bar = parent.getActionBar();
// ファイルをロードする!
// (AsyncTaskを使ってデータを読み込む)
- MeMoMaFileLoadingProcess asyncTask = new MeMoMaFileLoadingProcess(parent, fileUtility, this);
+ MeMoMaFileLoadingProcess asyncTask = new MeMoMaFileLoadingProcess(parent, this);
asyncTask.execute(objectHolder);
}
*/
private void showDetailData(String first, String second, String third)
{
- Log.v(Main.APP_IDENTIFIER, "SELECTED: " + first + " " + second + " " + third);
+ Log.v(TAG, "SELECTED: " + first + " " + second + " " + third);
}
/**
public void onActivityResult(int requestCode, int resultCode, Intent data)
{
// なにもしない...
- Log.v(Main.APP_IDENTIFIER, "rc: " + requestCode + " rs: " + resultCode + " it: " + data.getDataString());
+ Log.v(TAG, "rc: " + requestCode + " rs: " + resultCode + " it: " + data.getDataString());
}
/**
if (id == R.id.SetFilterButton)
{
// フィルタ設定ボタンが押された!
- Log.v(Main.APP_IDENTIFIER, "Selected Filter");
+ Log.v(TAG, "Selected Filter");
}
}
isShareExportedData = isShare;
// AsyncTaskを使ってデータをエクスポートする
- MeMoMaFileExportCsvProcess asyncTask = new MeMoMaFileExportCsvProcess(parent, fileUtility, this);
+ MeMoMaFileExportCsvProcess asyncTask = new MeMoMaFileExportCsvProcess(parent, this);
asyncTask.execute(objectHolder);
}
{
if (id == R.id.listdialog)
{
- fileSelectionDialog = new FileSelectionDialog(parent, parent.getString(R.string.dialogtitle_selectcsv), fileUtility, ".csv", this);
+ fileSelectionDialog = new FileSelectionDialog(parent, parent.getString(R.string.dialogtitle_selectcsv), ".csv", this);
return (fileSelectionDialog.getDialog());
}
{
try
{
- Log.v(Main.APP_IDENTIFIER, " " + dialog.toString());
- fileSelectionDialog.prepare("", EXTENSION_DIRECTORY);
+ Log.v(TAG, " " + dialog.toString());
+ fileSelectionDialog.prepare();
}
catch (Exception e)
{
} catch (Exception ex)
{
// 例外発生...ログを吐く
- Log.v(Main.APP_IDENTIFIER, "ExtensionActivityListener::onLoadingProcess() : " + ex.toString());
+ Log.v(TAG, "ExtensionActivityListener::onLoadingProcess() : " + ex.toString());
}
}
*/
public void onLoadedResult(String detail)
{
- Log.v(Main.APP_IDENTIFIER, "ExtensionActivityListener::onLoadedResult() '" + objectHolder.getDataTitle() +"' : " + detail);
+ Log.v(TAG, "ExtensionActivityListener::onLoadedResult() '" + objectHolder.getDataTitle() +"' : " + detail);
// 読み込んだファイル名をタイトルに設定する
parent.setTitle(objectHolder.getDataTitle());
*/
public void onExportedResult(String exportedFileName, String detail)
{
- Log.v(Main.APP_IDENTIFIER, "ExtensionActivityListener::onExportedResult() '" + objectHolder.getDataTitle() +"' : " + detail);
+ Log.v(TAG, "ExtensionActivityListener::onExportedResult() '" + objectHolder.getDataTitle() +"' : " + detail);
// エクスポートしたことを伝達する
String outputMessage = parent.getString(R.string.export_csv) + " " + objectHolder.getDataTitle() + " " + detail;
}
catch (Exception ex)
{
- Log.v(Main.APP_IDENTIFIER, "shareContent (fileName : " + fileName + ")");
+ Log.v(TAG, "shareContent (fileName : " + fileName + ")");
ex.printStackTrace();
}
}
public void selectedFileName(String fileName)
{
// CSVファイルからオブジェクトをロードするクラスを呼び出す。
- Log.v(Main.APP_IDENTIFIER, "ExtensionActivityListener::selectedFileName() : " + fileName);
- MeMoMaFileImportCsvProcess asyncTask = new MeMoMaFileImportCsvProcess(parent, fileUtility, this, fileName);
+ Log.v(TAG, "ExtensionActivityListener::selectedFileName() : " + fileName);
+ MeMoMaFileImportCsvProcess asyncTask = new MeMoMaFileImportCsvProcess(parent, this, fileName);
asyncTask.execute(objectHolder);
}
*/
public void onImportedResult(String detail)
{
- Log.v(Main.APP_IDENTIFIER, "ExtensionActivityListener::onImportedResult() '" + objectHolder.getDataTitle() +"' : " + detail);
+ Log.v(TAG, "ExtensionActivityListener::onImportedResult() '" + objectHolder.getDataTitle() +"' : " + detail);
// インポートしたことを伝達する
String outputMessage = parent.getString(R.string.import_csv) + " " + objectHolder.getDataTitle() + " " + detail;
*/
public class MeMoMaConnectLineHolder
{
+ private final String TAG = toString();
+
private final IOperationHistoryHolder historyHolder;
public static final int ID_NOTSPECIFY = -1;
private Hashtable<Integer, ObjectConnector> connectLines;
{
historyHolder.addHistory(key, IOperationHistoryHolder.ChangeKind.DELETE_CONNECT_LINE, removeTarget);
}
- Log.v(Main.APP_IDENTIFIER, "DISCONNECT LINES : " + key);
+ Log.v(TAG, "DISCONNECT LINES : " + key);
return (true);
}
{
return;
}
- Log.v(Main.APP_IDENTIFIER, "LINE " + conn.getKey() + " [" + conn.getFromObjectKey() + " -> " + conn.getToObjectKey() + "] ");
+ Log.v(TAG, "LINE " + conn.getKey() + " [" + conn.getFromObjectKey() + " -> " + conn.getToObjectKey() + "] ");
}
/**
import java.io.FilenameFilter;
import android.content.Context;
+import android.util.Log;
import android.widget.ArrayAdapter;
-import jp.sourceforge.gokigen.memoma.io.ExternalStorageFileUtility;
-
/**
* めもまのデータファイル名を保持するクラス (ArrayAdapterを拡張)
*
*/
public class MeMoMaDataFileHolder extends ArrayAdapter<String> implements FilenameFilter
{
- private ExternalStorageFileUtility fileUtility;
- private String fileExtension;
+ private final String TAG = toString();
+ private final Context context;
+ private final String fileExtension;
/**
* コンストラクタ
*
*/
- public MeMoMaDataFileHolder(Context context, int textViewRscId, ExternalStorageFileUtility utility, String extension)
+ public MeMoMaDataFileHolder(Context context, int textViewRscId, String extension)
{
super(context, textViewRscId);
- fileUtility = utility;
- fileExtension = extension;
+ this.context = context;
+ fileExtension = extension;
}
/**
* ファイル一覧を生成する。
*
*/
- public int updateFileList(String currentFileName, String extendDirectory)
+ public int updateFileList(String currentFileName)
{
+ int matchedIndex = 0;
int outputIndex = -1;
-
clear();
- String directory = fileUtility.getGokigenDirectory();
- if (extendDirectory != null)
- {
- // ディレクトリが指定されていた時には、そのディレクトリを追加する
- directory = directory + extendDirectory;
- }
- String[] dirFileList = (new File(directory)).list(this);
- try {
- for (int index = 0; index < dirFileList.length; index++) {
- String fileName = dirFileList[index].substring(0, dirFileList[index].indexOf(fileExtension));
- if (fileName.contentEquals(currentFileName)) // ファイル先頭にない場合は追加する。
+ String[] dirFileList = context.fileList();
+ try
+ {
+ for (String fileName : dirFileList)
+ {
+ int position = fileName.indexOf(fileExtension);
+ if (position >= 0)
{
- // 選択したインデックスを設定する。
- outputIndex = index;
+ String fileBaseName = fileName.substring(0, position);
+ if (fileBaseName.contentEquals(currentFileName))
+ {
+ // 選択したインデックスを設定する。
+ outputIndex = matchedIndex;
+ }
+ add(fileBaseName);
+ matchedIndex++;
}
- add(fileName);
- //Log.v(Main.APP_IDENTIFIER, fileName + ", File : " + dirFileList[index]);
}
}
catch (Exception e)
{
- e.printStackTrace();
+ e.printStackTrace();
+ }
+
+ if (getCount() == 0)
+ {
+ add("No Title");
+ outputIndex = 0;
}
System.gc();
- //Log.v(Main.APP_IDENTIFIER, "::::::: " + " (" + currentFileName + ") : " + outputIndex);
+ Log.v(TAG, "::::::: " + " (" + currentFileName + ") : " + outputIndex + " <" + getCount() + ">");
return (outputIndex);
}
/**
* 受け付けるファイル名のフィルタを応答する。
* (指定された拡張子を持つなファイルだけ抽出する。)
- *
*/
public boolean accept(File dir, String filename)
{
*/
public class MeMoMaObjectHolder
{
+ private final String TAG = toString();
public static final int ID_NOTSPECIFY = -1;
public static final int DRAWSTYLE_RECTANGLE = 0;
{
historyHolder.addHistory(key, IOperationHistoryHolder.ChangeKind.DELETE_OBJECT, removeTarget);
}
- Log.v(Main.APP_IDENTIFIER, "REMOVE : " + key);
+ Log.v(TAG, "REMOVE : " + key);
return (true);
}
return;
}
RectF posRect = position.getRect();
- Log.v(Main.APP_IDENTIFIER, "[" + posRect.left + "," + posRect.top + "][" + posRect.right + "," + posRect.bottom + "] " + "label : " + position.getLabel() + " detail : " + position.getDetail());
+ Log.v(TAG, "[" + posRect.left + "," + posRect.top + "][" + posRect.right + "," + posRect.bottom + "] " + "label : " + position.getLabel() + " detail : " + position.getDetail());
}
+++ /dev/null
-package jp.sourceforge.gokigen.memoma.io;
-
-import android.os.Environment;
-import android.util.Log;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-
-import jp.sourceforge.gokigen.memoma.Main;
-
-/**
- * 外部ストレージにデータを記録するために使うユーティリティ
- *
- * @author MRSa
- */
-public class ExternalStorageFileUtility
-{
- private final String TAG = toString();
- private final int COPY_BUFFER_SIZE = 32768;
- private final int BUFFER_MARGIN = 4;
-
- private String baseDirectory = "/";
-
- /**
- * コンストラクタ
- *
- */
- public ExternalStorageFileUtility(String offsetDir)
- {
- // ベースディレクトリの作成 (あれば何もしない)
- if (!prepareBaseDirectory(offsetDir))
- {
- Log.v(TAG, " prepareBaseDirectory : error");
- }
- }
-
- /**
- * ベースディレクトリの決定を行う
- *
- */
- private boolean prepareBaseDirectory(String offsetDir)
- {
- String gokigenDirectory = Environment.getExternalStorageDirectory().getPath() + "/Gokigen";
- Log.v(TAG, "DIR : " + gokigenDirectory);
- try
- {
- File baseDir = new File(gokigenDirectory);
- if (!baseDir.exists())
- {
- if (!baseDir.mkdirs())
- {
- // ベースディレクトリ作成失敗...終了する
- baseDirectory = Environment.getExternalStorageDirectory().getPath();
- return (false);
- }
- }
- gokigenDirectory = gokigenDirectory + offsetDir;
- baseDir = new File(gokigenDirectory);
- if (!baseDir.exists())
- {
- if (!baseDir.mkdirs())
- {
- // ベースディレクトリ作成失敗...終了する
- baseDirectory = Environment.getExternalStorageDirectory().getPath() + "/Gokigen";
- return (false);
- }
- }
- baseDirectory = gokigenDirectory;
- return (true);
- }
- catch (Exception ex)
- {
- Log.v(Main.APP_IDENTIFIER, "prepareBaseDirectory() : " + ex.getMessage());
- }
- baseDirectory = Environment.getExternalStorageDirectory().getPath();
- return (false);
- }
-
- /**
- * ベースディレクトリを取得する
- * @return 書き込みを行うアプリ用ベースディレクトリ
- */
- public String getGokigenDirectory()
- {
- return (baseDirectory);
- }
-
- /**
- * ディレクトリを作成する
- *
- * @param dirName
- * @return
- */
- public boolean makeDirectory(String dirName)
- {
- String makeDir = baseDirectory + "/" + dirName;
- try
- {
- File dir = new File(makeDir);
- if (dir.exists() == false)
- {
- return (dir.mkdirs());
- }
- return (true);
- }
- catch (Exception ex)
- {
- Log.v(Main.APP_IDENTIFIER, "makeDirectory() : " + ex.getMessage());
- }
- return (false);
- }
-
- /**
- * 記録ファイルをオープンする
- * @param fileName ファイル名
- * @param isAppend 追記モードでオープンするか?
- * @return ファイルストリーム
- */
- public FileOutputStream openFileStream(String fileName, boolean isAppend)
- {
- try
- {
- String targetName = baseDirectory + "/" + fileName;
- FileOutputStream fileStream = new FileOutputStream(targetName, isAppend);
- return (fileStream);
- }
- catch (Exception e)
- {
- Log.v(Main.APP_IDENTIFIER, "openFileStream() : " + e.getMessage());
- }
- return (null);
- }
-
- /**
- * 日単位でディレクトリを作成し、そこに書き込むためのファイル名を決定する
- * @return ファイル名称
- */
- private String decideFileNameWithSpecifiedDate(String fileName, String year, String month, String date)
- {
- String directory = year;
-
- // 年のディレクトリを掘る
- makeDirectory(year);
-
- directory = directory + "/" + year + month;
-
- // 年月のディレクトリを掘る
- makeDirectory(directory);
-
- directory = directory + "/" + year + month + date;
-
- // 年月日のディレクトリを掘る
- makeDirectory(directory);
-
- return (directory + "/" + year + month + date + "-" + fileName);
- }
-
- /**
- * 日単位でディレクトリを作成し、そこに書き込むためのファイル名を決定する
- * @return ファイル名称
- */
- public String decideFileNameWithDate(String fileName)
- {
- Calendar calendar = Calendar.getInstance();
-
- SimpleDateFormat yearFormat = new SimpleDateFormat("yyyy");
- SimpleDateFormat monthFormat = new SimpleDateFormat("MM");
- SimpleDateFormat dateFormat = new SimpleDateFormat("dd");
-
- String year = yearFormat.format(calendar.getTime());
- String month = monthFormat.format(calendar.getTime());
- String date = dateFormat.format(calendar.getTime());
-
- return (decideFileNameWithSpecifiedDate(fileName, year, month, date));
- }
-
- /**
- * 日単位でディレクトリを作成し、そこに書き込むためのファイル名を決定する
- * @return ファイル名称
- */
- public String decideFileNameWithSpecifiedDate(String fileName, int year, int month, int day)
- {
- String yearStr = year + "";
- String monthStr = "";
- if (month < 10)
- {
- monthStr = "0" + month;
- }
- else
- {
- monthStr = month + "";
- }
- String dayStr = "";
- if (day < 10)
- {
- dayStr = "0" + day;
- }
- else
- {
- dayStr = day + "";
- }
- return (decideFileNameWithSpecifiedDate(fileName, yearStr, monthStr, dayStr));
- }
-
- /**
- * 日付ディレクトリ名を取得する
- * @param year
- * @param month
- * @param date
- * @return
- */
- public String decideDateDirectory(int year, int month, int date)
- {
- String addMonth = "";
- String addDate = "";
- String directory = baseDirectory + "/" + year + "/";
- if (month < 10)
- {
- addMonth = "0";
- }
- if (date < 10)
- {
- addDate = "0";
- }
- directory = directory + year + addMonth + month + "/" + year + addMonth + month + addDate + date + "/";
- return (directory);
- }
-
- /**
- * ファイルのコピー (kaniFilerから持ってきた...)
- *
- * @param destFileName コピー先ファイル (full path)
- * @param srcFileName コピー元ファイル (full path)
- */
- public boolean copyFile(String destFileName, String srcFileName)
- {
- File srcFile = null;
- File dstFile = null;
-
- boolean ret = false;
- InputStream is = null;
- OutputStream os = null;
-
- if (destFileName == srcFileName)
- {
- // ファイル名が同じだった場合にはコピーを実行しない
- return (false);
- }
-
- try
- {
- srcFile = new File(srcFileName);
- if (srcFile.exists() != true)
- {
- // ファイルが存在しなかった、、、終了する
- return (false);
- }
- is = new FileInputStream(srcFile);
-
- long dataFileSize = srcFile.length();
- byte[] buffer = new byte[COPY_BUFFER_SIZE + BUFFER_MARGIN];
-
- dstFile = new File(destFileName);
- if (dstFile.exists() == true)
- {
- // ファイルが存在した、、、削除して作り直す
- dstFile.delete();
- }
-
- os = new FileOutputStream(dstFile);
- if ((is != null)&&(os != null))
- {
- while (dataFileSize > 0)
- {
- int size = is.read(buffer, 0, COPY_BUFFER_SIZE);
- if (size <= 0)
- {
- break;
- }
- os.write(buffer, 0, size);
- }
- }
- os.flush();
- os.close();
- is.close();
-
- dstFile = null;
- srcFile = null;
- buffer = null;
- is = null;
- os = null;
- ret = true;
- System.gc();
- }
- catch (Exception e)
- {
- // 例外発生!!!
- try
- {
- if (is != null)
- {
- is.close();
- }
- }
- catch (Exception e2)
- {
- //
- }
-
- try
- {
- if (os != null)
- {
- os.close();
- }
- }
- catch (Exception e2)
- {
- //
- }
- is = null;
- os = null;
- srcFile = null;
- dstFile = null;
- System.gc();
-
- return (false);
- }
- return (ret);
- }
-}
import java.io.File;
import java.io.InputStream;
-import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Build;
-import android.os.Handler;
-import android.os.Message;
import android.util.Log;
-import android.widget.ImageView;
import jp.sourceforge.gokigen.memoma.Main;
-import jp.sourceforge.gokigen.memoma.R;
-/**
+/*
* 画像イメージを読み込む
- *
- * @author MRSa
- *
*/
public class ImageLoader
{
- ProgressDialog loadingDialog;
- Context parent;
-
- // 画像を表示する
- String imageFile = null;
- Bitmap imageBitmap = null;
- int imageWidth = 1;
- int imageHeight = 1;
- ImageView imageView = null;
-
- public ImageLoader(Context context)
- {
- loadingDialog = new ProgressDialog(context);
- parent = context;
- }
-
- /**
- * イメージファイルの一覧を取得する
- * (一度も動かしたことのないコードなので注意!)
- * @param activity
- * @return イメージファイル名の一覧
- */
+ private static final String TAG = "MeMoMa::ImageLoader";
/*
- public static String[] getImageFileList(Activity activity)
- {
- try
- {
- HashSet<String> list = new HashSet<String>();
-
- Cursor c = activity.managedQuery(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, null, null, null, null);
- while(c.moveToNext())
- {
- String imagefile = c.getString(c.getColumnIndexOrThrow(MediaStore.Images.ImageColumns.DATA));
- File file = new File(imagefile);
- list.add(file.getParent());
- }
- return (String[]) list.toArray(new String[list.size()]);
- }
- catch (Exception ex)
- {
- //
- }
- return (null);
- }
- */
-
- /**
* URIから変換
- *
*/
public static Uri parseUri(String imageFile)
{
}
/**
- * 画面にイメージを表示する
- *
- */
- public static void setImage(Context context, ImageView view, String imageFile)
- {
- // 画像を表示する
- Bitmap bitmap;
- int width = view.getWidth();
- int height = view.getHeight();
- if (imageFile.startsWith("content://"))
- {
- // URIから画像を設定する...OutOfMemory対策付き
- bitmap = getBitmapFromUri(context, Uri.parse(imageFile), width, height);
- }
- else
- {
- // OutOfMemory対策付き...ビットマップのサイズを圧縮して表示
- bitmap = getBitmap(imageFile, view.getWidth(), view.getHeight());
- }
- view.setScaleType(ImageView.ScaleType.FIT_XY);
- view.setImageBitmap(bitmap);
- }
-
- /**
- * 画面にイメージを表示する (ロード中ダイアログ表示つき)
- *
- */
- public void setImage(ImageView view, String targetFile)
- {
-
- // プログレスダイアログ(「ロード中...」)を表示する。
- loadingDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
- loadingDialog.setMessage(parent.getString(R.string.dataLoading));
- loadingDialog.setIndeterminate(true);
- loadingDialog.setCancelable(false);
- loadingDialog.show();
-
- imageFile = targetFile;
- imageView = view;
- imageBitmap = null;
- imageWidth = view.getWidth();
- imageHeight = view.getHeight();
-
- // ダイアログ表示中の処理
- Thread thread = new Thread(new Runnable()
- {
- public void run()
- {
- try
- {
- if (imageFile.startsWith("content://"))
- {
- // URIから画像を設定する...OutOfMemory対策付き
- imageBitmap = getBitmapFromUri(parent, Uri.parse(imageFile), imageWidth, imageHeight);
- }
- else
- {
- // OutOfMemory対策付き...ビットマップのサイズを圧縮して表示
- imageBitmap = getBitmap(imageFile, imageWidth, imageHeight);
- }
- handler.sendEmptyMessage(0);
- }
- catch (Exception ex)
- {
- handler.sendEmptyMessage(0);
- ex.printStackTrace();
- }
- }
-
- /**
- * 画面の更新
- */
- private final Handler handler = new Handler()
- {
- @Override
- public void handleMessage(Message msg)
- {
- if ((imageBitmap != null)&&(imageView != null))
- {
- imageView.setScaleType(ImageView.ScaleType.FIT_XY);
- imageView.setImageBitmap(imageBitmap);
- }
- imageFile = null;
- imageView = null;
- imageBitmap = null;
- imageWidth = 1;
- imageHeight = 1;
-
- loadingDialog.dismiss();
- }
- };
- });
- try
- {
- thread.start();
- }
- catch (Exception ex)
- {
- ex.printStackTrace();
- }
- }
-
- /**
* URI経由でビットマップデータを取得する
*
*/
input.close();
}
}
- catch (Exception ex)
+ catch (Throwable ex)
{
- Log.v(Main.APP_IDENTIFIER, "Ex(1): " + ex.toString() + " URI : " + uri);
+ Log.v(TAG, "Ex(1): " + ex.getMessage() + " URI : " + uri);
ex.printStackTrace();
if (input != null)
{
}
catch (Exception ex)
{
- Log.v(Main.APP_IDENTIFIER, "Ex(2): " + ex.toString());
+ Log.v(TAG, "Ex(2): " + ex.toString());
if (input != null)
{
try
ex.printStackTrace();
}
return (retBitmap);
- }
-
- /**
- * ビットマップデータを取得する
- *
- * @return ビットマップデータ
- */
- public static Bitmap getBitmap(String pictureString, int width, int height)
- {
-
- // ファイルの表示方法を若干変更する ⇒ Uri.Parse() から BitmapFactoryを利用する方法へ。
- BitmapFactory.Options opt = new BitmapFactory.Options();
-
- // OutOfMemoryエラー対策...一度読み込んで画像サイズを取得
- opt.inJustDecodeBounds = true;
- opt.inDither = true;
- BitmapFactory.decodeFile(pictureString, opt);
-
- // 表示サイズに合わせて縮小...表示サイズが取得できなかった場合には、QVGAサイズと仮定する
- if (width < 10)
- {
- width = 320;
- }
- if (height < 10)
- {
- height = 240;
- }
-
- // 画像の縮小サイズを決定する (縦幅、横幅の小さいほうにあわせる)
- int widthBounds = opt.outWidth / width;
- int heightBounds = opt.outHeight / height;
- opt.inSampleSize=Math.min(widthBounds, heightBounds);
- opt.inJustDecodeBounds = false;
-
- // 画像ファイルを応答する
- return (BitmapFactory.decodeFile(pictureString, opt));
- }
+ }
}
import java.util.Calendar;
import java.util.Locale;
-import android.content.ContentResolver;
-import android.content.ContentValues;
import android.net.Uri;
-import android.provider.MediaStore;
-import android.app.Activity;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.util.Log;
import android.widget.Toast;
import androidx.appcompat.app.ActionBar;
+import androidx.appcompat.app.AppCompatActivity;
import jp.sourceforge.gokigen.memoma.drawers.GokigenSurfaceView;
-import jp.sourceforge.gokigen.memoma.Main;
import jp.sourceforge.gokigen.memoma.R;
import jp.sourceforge.gokigen.memoma.drawers.MeMoMaCanvasDrawer;
import jp.sourceforge.gokigen.memoma.holders.MeMoMaDataFileHolder;
public class MeMoMaDataInOutManager implements MeMoMaFileSavingProcess.ISavingStatusHolder, MeMoMaFileSavingProcess.IResultReceiver, MeMoMaFileLoadingProcess.IResultReceiver, ActionBar.OnNavigationListener, ObjectLayoutCaptureExporter.ICaptureLayoutExporter
{
- private Activity parent;
+ private final String TAG = toString();
+ private final AppCompatActivity parent;
private MeMoMaObjectHolder objectHolder = null;
- private ExternalStorageFileUtility fileUtility;
+
private MeMoMaDataFileHolder dataFileHolder = null;
private boolean isSaving = false;
* コンストラクタ
*
*/
- public MeMoMaDataInOutManager(Activity activity)
+ public MeMoMaDataInOutManager(AppCompatActivity activity)
{
parent = activity;
- fileUtility = new ExternalStorageFileUtility(Main.APP_BASEDIR);
}
/**
public void prepare(MeMoMaObjectHolder objectHolder, ActionBar bar, String fileName)
{
this.objectHolder = objectHolder;
- //this.lineHolder = lineHolder;
-
+
// データファイルフォルダを更新する
- dataFileHolder = new MeMoMaDataFileHolder(parent, android.R.layout.simple_spinner_dropdown_item, fileUtility, ".xml");
- int index = dataFileHolder.updateFileList(fileName, null);
+ dataFileHolder = new MeMoMaDataFileHolder(parent, android.R.layout.simple_spinner_dropdown_item, ".xml");
+ int index = dataFileHolder.updateFileList(fileName);
try
{
if (dataFileHolder != null)
{
// データファイル一覧を更新する
- int index = dataFileHolder.updateFileList(titleName, null);
+ int index = dataFileHolder.updateFileList(titleName);
// タイトルをオブジェクトフォルダに記憶させる
objectHolder.setDataTitle(titleName);
/**
* データの保存を行う (同名のファイルが存在していた場合、 *.BAKにリネーム(上書き)してから保存する)
- *
- *
- * @param forceOverwrite trueの時は、ファイル名が確定していたときは(確認せずに)上書き保存を自動で行う。
- *
*/
public void saveFile(String dataTitle, boolean forceOverwrite)
{
if (objectHolder == null)
{
- Log.e(Main.APP_IDENTIFIER, "ERR>MeMoMaDataInOutManager::saveFile() : " + dataTitle);
+ Log.e(TAG, "ERR>MeMoMaDataInOutManager::saveFile() : " + dataTitle);
return;
}
// タイトルをオブジェクトフォルダに記憶させる
objectHolder.setDataTitle(dataTitle);
- Log.v(Main.APP_IDENTIFIER, "MeMoMaDataInOutManager::saveFile() : " + dataTitle);
+ Log.v(TAG, "MeMoMaDataInOutManager::saveFile() : " + dataTitle);
// 同期型でファイルを保存する。。。
String message = saveFileSynchronous();
/**
* データファイルのフルパスを応答する
- *
- *
- *
*/
public String getDataFileFullPath(String dataTitle, String extension)
{
- return (fileUtility.getGokigenDirectory() + "/" + dataTitle + extension);
+ return (parent.getFilesDir() + "/" + dataTitle + extension);
}
-
+
/** 保存中状態を設定する **/
public void setSavingStatus(boolean isSaving)
{
Toast.makeText(parent, outputMessage, Toast.LENGTH_SHORT).show();
// ファイルリスト更新 ... (ここでやっちゃあ、AsyncTaskにしている意味ないなあ...)
- dataFileHolder.updateFileList(objectHolder.getDataTitle(), null);
+ dataFileHolder.updateFileList(objectHolder.getDataTitle());
}
/**
/**
* ファイルからデータを読み込む。
- *
- *
*/
public void loadFile(String dataTitle)
{
/**
* ファイルからのデータ読み込み処理
- *
- *
*/
private void loadFileWithName(String dataTitle)
{
- if (objectHolder == null)
+ if (objectHolder == null)
{
- Log.e(Main.APP_IDENTIFIER, "ERR>MeMoMaDataInOutManager::loadFile() : " + dataTitle);
+ Log.e(TAG, "ERR>MeMoMaDataInOutManager::loadFile() : " + dataTitle);
return;
}
// タイトルをオブジェクトフォルダに記憶させる
objectHolder.setDataTitle(dataTitle);
- Log.v(Main.APP_IDENTIFIER, "MeMoMaDataInOutManager::loadFile() : " + dataTitle);
+ Log.v(TAG, "MeMoMaDataInOutManager::loadFile() : " + dataTitle);
// AsyncTaskを使ってデータを読み込む
- MeMoMaFileLoadingProcess asyncTask = new MeMoMaFileLoadingProcess(parent, fileUtility, this);
+ MeMoMaFileLoadingProcess asyncTask = new MeMoMaFileLoadingProcess(parent, this);
asyncTask.execute(objectHolder);
}
/**
* アクションバーを更新する...
- *
- *
*/
private void prepareActionBar(ActionBar bar)
{
/**
* ファイルを保存する...同期型で。
- *
- *
*/
private String saveFileSynchronous()
{
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent);
String backgroundUri = preferences.getString("backgroundUri","");
String userCheckboxString = preferences.getString("userCheckboxString","");
- MeMoMaFileSavingEngine saveEngine = new MeMoMaFileSavingEngine(fileUtility, backgroundUri, userCheckboxString);
+ MeMoMaFileSavingEngine saveEngine = new MeMoMaFileSavingEngine(parent, backgroundUri, userCheckboxString);
return (saveEngine.saveObjects(objectHolder));
}
-
-
+
/**
*
*
public boolean onNavigationItemSelected(int itemPosition, long itemId)
{
String data = dataFileHolder.getItem(itemPosition);
- Log.v(Main.APP_IDENTIFIER, "onNavigationItemSelected(" + itemPosition + "," + itemId + ") : " + data);
+ Log.v(TAG, "onNavigationItemSelected(" + itemPosition + "," + itemId + ") : " + data);
// 同期型で現在のファイルを保存する。。。
String message = saveFileSynchronous();
editor.apply();
// 選択したアイテムをロードする!
- loadFileWithName(data);
+ loadFileWithName(data);
- return (true);
+ return (true);
}
/**
* スクリーンキャプチャを実施する
- *
*/
public void doScreenCapture(String title, MeMoMaObjectHolder holder, MeMoMaCanvasDrawer drawer, boolean isShare)
{
isShareExportedData = isShare;
// AsyncTaskを使ってデータをエクスポートする
- ObjectLayoutCaptureExporter asyncTask = new ObjectLayoutCaptureExporter(parent, fileUtility, holder, drawer, this);
+ ObjectLayoutCaptureExporter asyncTask = new ObjectLayoutCaptureExporter(parent, holder, drawer, this);
asyncTask.execute(title);
}
/**
* ファイルのエクスポート結果を受け取る
- *
*/
- public void onCaptureLayoutExportedResult(String exportedFileName, String detail, int id)
+ public void onCaptureLayoutExportedResult(Uri exportedUri, String detail, int id)
{
- Log.v(Main.APP_IDENTIFIER, "MeMoMaDataInOutManager::onCaptureExportedResult() '" + objectHolder.getDataTitle() +"' : " + detail);
+ Log.v(TAG, "MeMoMaDataInOutManager::onCaptureExportedResult() '" + objectHolder.getDataTitle() +"' : " + detail + " " + exportedUri.toString());
// エクスポートしたことを伝達する
String outputMessage = parent.getString(R.string.capture_data) + " " + objectHolder.getDataTitle() + " " + detail;
Toast.makeText(parent, outputMessage, Toast.LENGTH_SHORT).show();
- if (isShareExportedData)
- {
- // ギャラリーに受信したファイルを登録し、エクスポートしたファイルを共有する
- try {
- long now = System.currentTimeMillis();
- ContentValues values = new ContentValues();
- ContentResolver resolver = parent.getContentResolver();
- values.put(MediaStore.Images.Media.MIME_TYPE, "image/png");
- values.put(MediaStore.Images.Media.DATA, exportedFileName);
- values.put(MediaStore.Images.Media.DATE_ADDED, now);
- values.put(MediaStore.Images.Media.DATE_TAKEN, now);
- values.put(MediaStore.Images.Media.DATE_MODIFIED, now);
- Uri insertedImage = resolver.insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
- if (insertedImage != null)
- {
- shareContent(insertedImage, id);
- }
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
-
- }
- isShareExportedData = false;
+ try
+ {
+ if (isShareExportedData)
+ {
+ // ギャラリーに受信したファイルを登録し、エクスポートしたファイルを共有する
+ shareContent(exportedUri, id);
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ isShareExportedData = false;
}
/**
* エクスポートしたファイルを共有する
- *
*/
private void shareContent(Uri imageName, int id)
{
*/
public class MeMoMaFileExportCsvProcess extends AsyncTask<MeMoMaObjectHolder, Integer, String>
{
+ private final String TAG = toString();
+ private final Context context;
private IResultReceiver receiver;
- private ExternalStorageFileUtility fileUtility;
private String exportedFileName = null;
private ProgressDialog savingDialog;
/**
* コンストラクタ
*/
- public MeMoMaFileExportCsvProcess(Context context, ExternalStorageFileUtility utility, IResultReceiver resultReceiver)
+ public MeMoMaFileExportCsvProcess(Context context, IResultReceiver resultReceiver)
{
+ this.context = context;
receiver = resultReceiver;
- fileUtility = utility;
// プログレスダイアログ(「保存中...」)を表示する。
savingDialog = new ProgressDialog(context);
savingDialog.show();
// ファイルをバックアップするディレクトリを作成する
- File dir = new File(fileUtility.getGokigenDirectory() + "/exported");
+ File dir = new File(context.getFilesDir() + "/exported");
if (!dir.mkdir())
{
Log.v(toString(), "mkDir() fail. : " + dir.getAbsolutePath());
catch (Exception e)
{
resultMessage = " ERR>" + e.toString();
- Log.v(Main.APP_IDENTIFIER, resultMessage);
+ Log.v(TAG, resultMessage);
e.printStackTrace();
}
return (resultMessage);
protected String doInBackground(MeMoMaObjectHolder... datas)
{
// ファイル名の設定 ... (拡張子なし)
- String fileName = fileUtility.getGokigenDirectory() + "/exported/" + datas[0].getDataTitle();
+ String fileName = context.getFilesDir() + "/exported/" + datas[0].getDataTitle();
// データを保管する
String result = exportToCsvFile(fileName, datas[0]);
}
catch (Exception ex)
{
- Log.v(Main.APP_IDENTIFIER, "MeMoMaFileExportCsvProcess::onPostExecute() : " + ex.toString());
+ Log.v(TAG, "MeMoMaFileExportCsvProcess::onPostExecute() : " + ex.toString());
}
// プログレスダイアログを消す
savingDialog.dismiss();
*
*/
public class MeMoMaFileImportCsvProcess extends AsyncTask<MeMoMaObjectHolder, Integer, String> implements MeMoMaFileSavingProcess.ISavingStatusHolder, MeMoMaFileSavingProcess.IResultReceiver
-{
- private Context parent = null;
+{
+ private final String TAG = toString();
+ private final Context context;
private IResultReceiver receiver = null;
- private ExternalStorageFileUtility fileUtility = null;
+
private String targetFileName = null;
private String fileSavedResult = "";
private ProgressDialog importingDialog = null;
/**
* コンストラクタ
*/
- public MeMoMaFileImportCsvProcess(Context context, ExternalStorageFileUtility utility, IResultReceiver resultReceiver, String fileName)
+ public MeMoMaFileImportCsvProcess(Context context, IResultReceiver resultReceiver, String fileName)
{
- parent = context;
+ this.context = context;
receiver = resultReceiver;
- fileUtility = utility;
targetFileName = fileName;
// プログレスダイアログ(「データインポート中...」)を表示する。
importingDialog.show();
// 設定読み出し用...あらかじめ、UIスレッドで読みだしておく。
- SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent);
+ SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
backgroundUri = preferences.getString("backgroundUri","");
userCheckboxString = preferences.getString("userCheckboxString","");
}
catch (Exception ex)
{
//
- Log.v(Main.APP_IDENTIFIER, "CSV:readRecord() ex : " + ex.toString());
+ Log.v(TAG, "CSV:readRecord() ex : " + ex.toString());
oneRecord = null;
}
return (oneRecord);
detailIndex = dataLine.indexOf("\",\"");
if (detailIndex < 0)
{
- Log.v(Main.APP_IDENTIFIER, "parseRecord() : label wrong : " + dataLine);
+ Log.v(TAG, "parseRecord() : label wrong : " + dataLine);
return;
}
label = dataLine.substring(1, detailIndex);
}
else // if ((userCheckIndexTrue <= detailIndex)&&(userCheckIndexFalse <= detailIndex))
{
- Log.v(Main.APP_IDENTIFIER, "parseRecord() : detail wrong : " + dataLine);
+ Log.v(TAG, "parseRecord() : detail wrong : " + dataLine);
return;
}
String[] datas = (dataLine.substring(nextIndex)).split(",");
if (datas.length < 6)
{
- Log.v(Main.APP_IDENTIFIER, "parseRecord() : data size wrong : " + datas.length);
+ Log.v(TAG, "parseRecord() : data size wrong : " + datas.length);
return;
}
int drawStyle = Integer.parseInt(datas[0]);
PositionObject pos = objectHolder.createPosition(left, top, drawStyle);
if (pos == null)
{
- Log.v(Main.APP_IDENTIFIER, "parseRecord() : object create failure.");
+ Log.v(TAG, "parseRecord() : object create failure.");
return;
}
pos.setRectRight(left + width);
pos.setDetail(detail);
pos.setPaintStyle(paintStyle);
pos.setUserChecked(userChecked);
- Log.v(Main.APP_IDENTIFIER, "OBJECT CREATED: " + label + "(" + left + "," + top + ") [" +drawStyle + "]");
+ Log.v(TAG, "OBJECT CREATED: " + label + "(" + left + "," + top + ") [" +drawStyle + "]");
}
catch (Exception ex)
{
- Log.v(Main.APP_IDENTIFIER, "parseRecord() " + ex.toString());
+ Log.v(TAG, "parseRecord() " + ex.toString());
}
}
String resultMessage = "";
try
{
- Log.v(Main.APP_IDENTIFIER, "CSV(import)>> " + fileName);
+ Log.v(TAG, "CSV(import)>> " + fileName);
BufferedReader buf = new BufferedReader(new FileReader(fileName));
String dataLine = readRecord(buf);
while (dataLine != null)
catch (Exception e)
{
resultMessage = " ERR(import)>" + e.toString();
- Log.v(Main.APP_IDENTIFIER, resultMessage);
+ Log.v(TAG, resultMessage);
e.printStackTrace();
}
return (resultMessage);
protected String doInBackground(MeMoMaObjectHolder... datas)
{
// ファイル名の設定 ... (拡張子なし)
- String fileName = fileUtility.getGokigenDirectory() + "/exported/" + targetFileName;
+ String fileName = context.getFilesDir() + "/exported/" + targetFileName;
// データを読み込む
String result = importFromCsvFile(fileName, datas[0]);
// データを保存する
- MeMoMaFileSavingEngine savingEngine = new MeMoMaFileSavingEngine(fileUtility, backgroundUri, userCheckboxString);
+ MeMoMaFileSavingEngine savingEngine = new MeMoMaFileSavingEngine(context, backgroundUri, userCheckboxString);
String message = savingEngine.saveObjects(datas[0]);
System.gc();
}
catch (Exception ex)
{
- Log.v(Main.APP_IDENTIFIER, "MeMoMaFileImportCsvProcess::onPostExecute() : " + ex.toString());
+ Log.v(TAG, "MeMoMaFileImportCsvProcess::onPostExecute() : " + ex.toString());
}
// プログレスダイアログを消す
importingDialog.dismiss();
*/
public class MeMoMaFileLoadingProcess extends AsyncTask<MeMoMaObjectHolder, Integer, String>
{
- private Context parent;
+ private final String TAG = toString();
+ private final Context parent;
private IResultReceiver receiver;
- private ExternalStorageFileUtility fileUtility;
private PositionObject position = null;
private ObjectConnector line = null;
/**
* コンストラクタ
*/
- public MeMoMaFileLoadingProcess(Context context, ExternalStorageFileUtility utility, IResultReceiver resultReceiver)
+ public MeMoMaFileLoadingProcess(Context context, IResultReceiver resultReceiver)
{
parent = context;
receiver = resultReceiver;
- fileUtility = utility;
}
/**
}
catch (Exception e)
{
- Log.v(Main.APP_IDENTIFIER, "ERR>parseStartTag() name:" + name + " " + e.toString());
+ Log.v(TAG, "ERR>parseStartTag() name:" + name + " " + e.toString());
}
}
RectF posRect = position.getRect();
if ((posRect.left > posRect.right)||(posRect.top > posRect.bottom))
{
- Log.v(Main.APP_IDENTIFIER, "RECT IS ILLEGAL. : [" + posRect.left + "," + posRect.top + "-[" + posRect.right + "," + posRect.bottom + "]");
+ Log.v(TAG, "RECT IS ILLEGAL. : [" + posRect.left + "," + posRect.top + "-[" + posRect.right + "," + posRect.bottom + "]");
position.setRectRight(posRect.left + MeMoMaObjectHolder.OBJECTSIZE_DEFAULT_X);
position.setRectBottom(posRect.top + MeMoMaObjectHolder.OBJECTSIZE_DEFAULT_Y);
}
}
catch (Exception e)
{
- Log.v(Main.APP_IDENTIFIER, "ERR>parseEndTag() name:" + name + " " + e.toString());
+ Log.v(TAG, "ERR>parseEndTag() name:" + name + " " + e.toString());
}
}
}
catch (Exception e)
{
- resultMessage = " ERR>" + e.toString();
- Log.v(Main.APP_IDENTIFIER, resultMessage);
+ resultMessage = " ERR>" + e.getMessage();
+ Log.v(TAG, resultMessage);
e.printStackTrace();
}
return (resultMessage);
protected String doInBackground(MeMoMaObjectHolder... datas)
{
// ファイル名の設定 ... (拡張子あり...保存時とは違う)
- String fileName = fileUtility.getGokigenDirectory() + "/" + datas[0].getDataTitle() + ".xml";
+ String fileName = parent.getFilesDir() + "/" + datas[0].getDataTitle() + ".xml";
// データを読みだす。
String result = restoreToXmlFile(fileName, datas[0]);
}
catch (Exception ex)
{
- Log.v(Main.APP_IDENTIFIER, "MeMoMaFileSavingProcess::onPostExecute() : " + ex.toString());
+ Log.v(TAG, "MeMoMaFileSavingProcess::onPostExecute() : " + ex.getMessage());
}
}
import org.xmlpull.v1.XmlSerializer;
+import android.content.Context;
import android.graphics.RectF;
import android.util.Log;
import android.util.Xml;
*
*/
public class MeMoMaFileSavingEngine
-{
- private ExternalStorageFileUtility fileUtility = null;
+{
+ private final String TAG = toString();
+ private final Context context;
private String backgroundUri = null;
private String userCheckboxString = null;
/**
* コンストラクタ
*/
- MeMoMaFileSavingEngine(ExternalStorageFileUtility utility, String bgUri, String checkBoxLabel)
+ MeMoMaFileSavingEngine(Context context, String bgUri, String checkBoxLabel)
{
- // ファイルユーティリティを記憶する
- fileUtility = utility;
-
+ this.context = context;
+
// ファイルをバックアップするディレクトリを作成する
- File dir = new File(fileUtility.getGokigenDirectory() + "/backup");
+ File dir = new File(context.getFilesDir() + "/backup");
dir.mkdir();
// 設定データ読み出し用...。
if (!result)
{
// バックアップファイルのコピー失敗をログに記述する
- Log.v(Main.APP_IDENTIFIER, "rename failure : " + dirName + backupFileName + ".xml");
+ Log.v(TAG, "rename failure : " + dirName + backupFileName + ".xml");
}
}
}
catch (Exception e)
{
- resultMessage = " ERR>" + e.toString();
- Log.v(Main.APP_IDENTIFIER, resultMessage);
+ resultMessage = " " + e.getMessage();
+ Log.v(TAG, e.getMessage());
e.printStackTrace();
}
return (resultMessage);
/**
* オブジェクトを保存する
- *
- *
*/
public String saveObjects(MeMoMaObjectHolder objectHolder)
{
// データタイトルがない場合...保存処理は行わない。
if (objectHolder.getDataTitle().length() <= 0)
{
- Log.v(Main.APP_IDENTIFIER, "MeMoMaFileSavingEngine::saveObjects() : specified file name is illegal, save aborted. : " + objectHolder.getDataTitle() );
+ Log.v(TAG, "MeMoMaFileSavingEngine::saveObjects() : specified file name is illegal, save aborted. : " + objectHolder.getDataTitle() );
return ("");
}
- // バックアップを保存する
- backupFiles(fileUtility.getGokigenDirectory() + "/" , objectHolder.getDataTitle());
+ if (objectHolder.isEmpty())
+ {
+ // データがない場合は保存しない
+ return("Data is empty, not saved.");
+ }
+
+ //// バックアップを保存する
+ //backupFiles(context.getFilesDir() + "/" , objectHolder.getDataTitle());
// ファイル名の設定 ... (拡張子なし)
- String fileName = fileUtility.getGokigenDirectory() + "/" + objectHolder.getDataTitle();
+ String fileName = context.getFilesDir() + "/" + objectHolder.getDataTitle();
// データを保管する
return (storeToXmlFile(fileName, objectHolder));
*
*/
public class MeMoMaFileSavingProcess extends AsyncTask<MeMoMaObjectHolder, Integer, String>
-{
+{
+ private final String TAG = toString();
+
+ private final Context context;
private IResultReceiver receiver = null;
- private ExternalStorageFileUtility fileUtility = null;
+ //private ExternalStorageFileUtility fileUtility = null;
private ISavingStatusHolder statusHolder = null;
private String backgroundUri = null;
/**
* コンストラクタ
*/
- public MeMoMaFileSavingProcess(Context context, ISavingStatusHolder holder, ExternalStorageFileUtility utility, IResultReceiver resultReceiver)
+ public MeMoMaFileSavingProcess(Context context, ISavingStatusHolder holder, IResultReceiver resultReceiver)
{
+ this.context = context;
receiver = resultReceiver;
- fileUtility = utility;
statusHolder = holder;
// プログレスダイアログ(「保存中...」)を表示する。
statusHolder.setSavingStatus(true);
// データの保管メイン
- MeMoMaFileSavingEngine savingEngine = new MeMoMaFileSavingEngine(fileUtility, backgroundUri, userCheckboxString);
+ MeMoMaFileSavingEngine savingEngine = new MeMoMaFileSavingEngine(context, backgroundUri, userCheckboxString);
String result = savingEngine.saveObjects(datas[0]);
System.gc();
}
catch (Exception ex)
{
- Log.v(Main.APP_IDENTIFIER, "MeMoMaFileSavingProcess::onPostExecute() : " + ex.toString());
+ Log.v(TAG, "MeMoMaFileSavingProcess::onPostExecute() : " + ex.toString());
}
// プログレスダイアログを消す
savingDialog.dismiss();
package jp.sourceforge.gokigen.memoma.io;
+import static jp.sourceforge.gokigen.memoma.Main.APP_NAMESPACE;
+
import java.io.File;
-import java.io.FileOutputStream;
import java.io.OutputStream;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Enumeration;
import java.util.Locale;
-import android.app.Activity;
import android.app.ProgressDialog;
+import android.content.ContentResolver;
+import android.content.ContentValues;
+import android.content.Context;
+import android.database.Cursor;
+import android.database.DatabaseUtils;
import android.graphics.Bitmap;
-import android.graphics.Bitmap.CompressFormat;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.RectF;
+import android.net.Uri;
import android.os.AsyncTask;
+import android.os.Build;
+import android.os.Environment;
+import android.provider.MediaStore;
import android.util.Log;
import android.view.Display;
-import jp.sourceforge.gokigen.memoma.Main;
+import androidx.appcompat.app.AppCompatActivity;
+
import jp.sourceforge.gokigen.memoma.R;
import jp.sourceforge.gokigen.memoma.drawers.MeMoMaCanvasDrawer;
import jp.sourceforge.gokigen.memoma.holders.MeMoMaObjectHolder;
* データをファイルに保存するとき用 アクセスラッパ (非同期処理を実行)
* Viewの情報を画像形式(png形式)で保存する。
* どのViewを保存するのかは、ICaptureExporter.getCaptureTargetView()クラスを使って教えてもらう。
- *
* AsyncTask
* String : 実行時に渡すクラス(Param) : ファイル名をもらう
* Integer : 途中経過を伝えるクラス(Progress) : 今回は使っていない
* String : 処理結果を伝えるクラス(Result) : 結果を応答する。
- *
- * @author MRSa
- *
*/
public class ObjectLayoutCaptureExporter extends AsyncTask<String, Integer, String>
{
+ private final String TAG = toString();
+ private static final boolean dumpLog = false;
+
private static final int OUTPUT_EXPORT_SHARE_ID = 1000;
private static final int OUTPUT_MARGIN = 8;
private static final int OUTPUT_MARGIN_TOP = 50;
private static final int MINIMUM_WIDTH = 800;
private static final int MINIMUM_HEIGHT = 600;
- private ICaptureLayoutExporter receiver;
- private ExternalStorageFileUtility fileUtility;
- private String exportedFileName = null;
- private MeMoMaObjectHolder objectHolder;
- private MeMoMaCanvasDrawer canvasDrawer;
- private ProgressDialog savingDialog;
+ private final ICaptureLayoutExporter receiver;
+
+ private final MeMoMaObjectHolder objectHolder;
+ private final MeMoMaCanvasDrawer canvasDrawer;
+ private final ProgressDialog savingDialog;
private float offsetX = 0.0f;
private float offsetY = 0.0f;
private int displayWidth;
private int displayHeight;
+ private final Context context;
+
+ private Uri exportedUri = null;
+
/**
* コンストラクタ
*/
- ObjectLayoutCaptureExporter(Activity context, ExternalStorageFileUtility utility, MeMoMaObjectHolder holder, MeMoMaCanvasDrawer drawer, ICaptureLayoutExporter resultReceiver)
+ ObjectLayoutCaptureExporter(AppCompatActivity context, MeMoMaObjectHolder holder, MeMoMaCanvasDrawer drawer, ICaptureLayoutExporter resultReceiver)
{
- receiver = resultReceiver;
- fileUtility = utility;
- objectHolder = holder;
+ this.context = context;
+ receiver = resultReceiver;
+ objectHolder = holder;
canvasDrawer = drawer;
// 現在の画面サイズを取得
savingDialog.show();
// ファイルをバックアップするディレクトリを作成する
- File dir = new File(fileUtility.getGokigenDirectory() + "/exported");
+ File dir = new File(context.getFilesDir() + "/exported");
if (!dir.mkdir())
{
- Log.v(Main.APP_IDENTIFIER, "mkdir is failed.");
+ Log.v(TAG, "mkdir is failed.");
}
}
/**
* 非同期処理実施前の前処理
- *
*/
@Override
protected void onPreExecute()
{
// なにもしない。
}
-
+
/**
* ビットマップデータを(PNG形式で)保管する。
- *
- *
*/
- private String exportToFile(String fileName, Bitmap targetBitmap)
+ private String exportToFile(String baseName, Bitmap targetImage)
{
- String resultMessage = "";
+ String resultMessage = "";
try
{
- if (targetBitmap == null)
- {
- // ビットマップが取れないため、ここで折り返す。
- return ("SCREEN DATA GET FAILURE...");
- }
-
- // エクスポートするファイル名を決定する
- Calendar calendar = Calendar.getInstance();
- SimpleDateFormat outFormat = new SimpleDateFormat("yyyyMMddHHmmss", Locale.US);
- exportedFileName = fileName + "_" + outFormat.format(calendar.getTime()) + ".png";
+ String outputDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).getPath() + "/" + APP_NAMESPACE + "/";
+ ContentResolver resolver = context.getContentResolver();
+ String fileName = baseName + ".png";
+
+ Uri extStorageUri;
+ ContentValues values = new ContentValues();
+ values.put(MediaStore.Images.Media.TITLE, fileName);
+ values.put(MediaStore.Images.Media.DISPLAY_NAME, fileName);
+ values.put(MediaStore.Images.Media.MIME_TYPE, "image/png");
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q)
+ {
+ values.put(MediaStore.Images.Media.RELATIVE_PATH, "Pictures/" + APP_NAMESPACE);
+ values.put(MediaStore.Images.Media.IS_PENDING, true);
+ extStorageUri = MediaStore.Images.Media.getContentUri(MediaStore.VOLUME_EXTERNAL_PRIMARY);
+ }
+ else
+ {
+ File path = new File(outputDir);
+ values.put(MediaStore.Images.Media.DATA, path.getAbsolutePath() + File.separator + fileName);
+ extStorageUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
+ }
+ Log.v(TAG, "---------- " + baseName + ".png " + values);
+ Uri imageUri = resolver.insert(extStorageUri, values);
+ if (imageUri != null)
+ {
+ ////////////////////////////////////////////////////////////////
+ if (dumpLog)
+ {
+ try
+ {
+ Cursor cursor = resolver.query(imageUri, null, null, null, null);
+ DatabaseUtils.dumpCursor(cursor);
+ cursor.close();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ resultMessage = e.getMessage();
+ }
+ }
+ ////////////////////////////////////////////////////////////////
- // PNG形式でファイル出力を行う。
- OutputStream out = new FileOutputStream(exportedFileName);
- targetBitmap.compress(CompressFormat.PNG, 100, out);
- out.flush();
- out.close();
+ OutputStream outputStream = resolver.openOutputStream(imageUri, "wa");
+ if (outputStream != null)
+ {
+ targetImage.compress(Bitmap.CompressFormat.PNG, 100, outputStream);
+ outputStream.flush();
+ outputStream.close();
+ }
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q)
+ {
+ values.put(MediaStore.Images.Media.IS_PENDING, false);
+ resolver.update(imageUri, values, null, null);
+ }
+ }
+ else
+ {
+ Log.v(TAG, " cannot get imageUri...");
+ }
+ exportedUri = imageUri;
}
- catch (Exception e)
+ catch (Throwable t)
{
- resultMessage = " ERR(png)>" + e.toString();
- Log.v(Main.APP_IDENTIFIER, resultMessage);
- e.printStackTrace();
- }
+ t.printStackTrace();
+ resultMessage = t.getMessage();
+ exportedUri = null;
+ }
return (resultMessage);
}
-
+
/**
* キャンバスの大きさがどれくらい必要か、チェックする。
- *
- *
*/
private Rect checkCanvasSize()
{
canvasSize.sort();
// 現在の画面サイズを取得
- //Display display = parent.getWindowManager().getDefaultDisplay();
- //int width = display.getWidth();
- //int height = display.getHeight();
if (displayWidth < MINIMUM_WIDTH)
{
displayWidth = MINIMUM_WIDTH;
{
canvasSize.bottom = canvasSize.top + displayHeight;
}
-
-
+
// 画像位置(キャンバス位置)の調整。。。
offsetX = 0.0f - canvasSize.left - (OUTPUT_MARGIN);
offsetY = 0.0f - canvasSize.top - (OUTPUT_MARGIN);
// 出力する画像データのサイズを表示する
- Log.v(Main.APP_IDENTIFIER, "ObjectLayoutCaptureExporter::checkCanvasSize() w:" + canvasSize.width() + " , h:" + canvasSize.height() + " offset :(" + offsetX + "," + offsetY + ")");
+ Log.v(TAG, "ObjectLayoutCaptureExporter::checkCanvasSize() w:" + canvasSize.width() + " , h:" + canvasSize.height() + " offset :(" + offsetX + "," + offsetY + ")");
return (canvasSize);
}
/**
* 非同期処理
* (バックグラウンドで実行する(このメソッドは、UIスレッドと別のところで実行する))
- *
*/
@Override
protected String doInBackground(String... datas)
// オブジェクトをビットマップの中に書き込む
canvasDrawer.drawOnBitmapCanvas(targetCanvas, offsetX, offsetY);
- // ファイル名の設定 ... (拡張子なし)
- String fileName = fileUtility.getGokigenDirectory() + "/exported/" + datas[0];
+ String fileName = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.US).format(Calendar.getInstance().getTime()) + "_" + datas[0];
// データを保管する
result = exportToFile(fileName, targetBitmap);
{
if (receiver != null)
{
- receiver.onCaptureLayoutExportedResult(exportedFileName, result, OUTPUT_EXPORT_SHARE_ID);
+ receiver.onCaptureLayoutExportedResult(exportedUri, result, OUTPUT_EXPORT_SHARE_ID);
}
}
catch (Exception ex)
{
- Log.v(Main.APP_IDENTIFIER, "ViewCaptureExporter::onPostExecute() : " + ex.toString());
+ Log.v(TAG, "ViewCaptureExporter::onPostExecute() : " + ex.getMessage());
+ ex.printStackTrace();
}
// プログレスダイアログを消す
if (savingDialog != null)
/**
* 結果報告用のインタフェース
- *
- * @author MRSa
- *
*/
public interface ICaptureLayoutExporter
{
// 保存結果の報告
- void onCaptureLayoutExportedResult(String exportedFileName, String detail, int id);
+ void onCaptureLayoutExportedResult(Uri exportedUri, String detail, int id);
}
}
}
catch (Exception ee)
{
- //
- Log.v(IDENTIFIER, "attach failure : " + contentUri + " " + ee.toString() + " " + ee.getMessage());
+ Log.v(IDENTIFIER, "attach failure : " + contentUri + " " + ee.getMessage());
+ ee.printStackTrace();
}
parent.startActivityForResult(intent, id);
}
catch (android.content.ActivityNotFoundException ex)
{
Toast.makeText(parent, "" + ex.getMessage(), Toast.LENGTH_SHORT).show();
- Log.v(IDENTIFIER, "android.content.ActivityNotFoundException : " + ex.toString() + " " + ex.getMessage());
+ Log.v(IDENTIFIER, "android.content.ActivityNotFoundException : " + ex.getMessage());
+ ex.printStackTrace();
}
- catch (Exception e)
+ catch (Throwable e)
{
- Log.v(IDENTIFIER, "xxx : " + e.toString() + " " + e.getMessage());
+ Log.v(IDENTIFIER, "xxx : " + e.getMessage());
e.printStackTrace();
}
}
+++ /dev/null
-package jp.sourceforge.gokigen.memoma.io;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.OutputStream;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import android.app.ProgressDialog;
-import android.content.Context;
-import android.graphics.Bitmap;
-import android.graphics.Bitmap.CompressFormat;
-import android.os.AsyncTask;
-import android.util.Log;
-import android.view.View;
-
-import jp.sourceforge.gokigen.memoma.Main;
-import jp.sourceforge.gokigen.memoma.R;
-
-/**
- * データをファイルに保存するとき用 アクセスラッパ (非同期処理を実行)
- * Viewの情報を画像形式(png形式)で保存する。
- * どのViewを保存するのかは、ICaptureExporter.getCaptureTargetView()クラスを使って教えてもらう。
- *
- * AsyncTask
- * String : 実行時に渡すクラス(Param) : ファイル名をもらう
- * Integer : 途中経過を伝えるクラス(Progress) : 今回は使っていない
- * String : 処理結果を伝えるクラス(Result) : 結果を応答する。
- *
- * @author MRSa
- *
- */
-public class ViewCaptureExporter extends AsyncTask<String, Integer, String>
-{
- private ICaptureExporter receiver = null;
- private ExternalStorageFileUtility fileUtility = null;
- private String exportedFileName = null;
-
- private ProgressDialog savingDialog = null;
-
- private Bitmap targetBitmap = null;
-
- /**
- * コンストラクタ
- */
- public ViewCaptureExporter(Context context, ExternalStorageFileUtility utility, ICaptureExporter resultReceiver)
- {
- receiver = resultReceiver;
- fileUtility = utility;
-
- // プログレスダイアログ(「保存中...」)を表示する。
- savingDialog = new ProgressDialog(context);
- savingDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
- savingDialog.setMessage(context.getString(R.string.dataSaving));
- savingDialog.setIndeterminate(true);
- savingDialog.setCancelable(false);
- savingDialog.show();
-
- /** ファイルをバックアップするディレクトリを作成する **/
- File dir = new File(fileUtility.getGokigenDirectory() + "/exported");
- dir.mkdir();
- }
-
- /**
- * 非同期処理実施前の前処理
- *
- */
- @Override
- protected void onPreExecute()
- {
- try
- {
- targetBitmap = null;
- if (receiver != null)
- {
- // 画面のキャプチャを実施する
- View targetView = receiver.getCaptureTargetView();
- targetView.setDrawingCacheEnabled(false);
- targetView.setDrawingCacheEnabled(true);
- targetBitmap = Bitmap.createBitmap(targetView.getDrawingCache());
- targetView.setDrawingCacheEnabled(false);
- }
- }
- catch (Exception ex)
- {
- Log.v(Main.APP_IDENTIFIER, "ViewCaptureExporter::onPreExecute() : " + ex.toString());
- }
- }
-
- /**
- * ビットマップデータを(PNG形式で)保管する。
- *
- *
- */
- private String exportToFile(String fileName)
- {
- String resultMessage = "";
- try
- {
- if (targetBitmap == null)
- {
- // ビットマップが取れないため、ここで折り返す。
- return ("SCREEN DATA GET FAILURE...");
- }
-
- // エクスポートするファイル名を決定する
- Calendar calendar = Calendar.getInstance();
- SimpleDateFormat outFormat = new SimpleDateFormat("yyyyMMddHHmmss");
- exportedFileName = fileName + "_" + outFormat.format(calendar.getTime()) + ".png";
-
- // PNG形式でファイル出力を行う。
- OutputStream out = new FileOutputStream(exportedFileName);
- targetBitmap.compress(CompressFormat.PNG, 100, out);
- out.flush();
- out.close();
- }
- catch (Exception e)
- {
- resultMessage = " ERR(png)>" + e.toString();
- Log.v(Main.APP_IDENTIFIER, resultMessage);
- e.printStackTrace();
- }
- return (resultMessage);
- }
-
- /**
- * 非同期処理
- * (バックグラウンドで実行する(このメソッドは、UIスレッドと別のところで実行する))
- *
- */
- @Override
- protected String doInBackground(String... datas)
- {
- // ファイル名の設定 ... (拡張子なし)
- String fileName = fileUtility.getGokigenDirectory() + "/exported/" + datas[0];
-
- // データを保管する
- String result = exportToFile(fileName);
-
- System.gc();
-
- return (result);
- }
-
- /**
- * 非同期処理の進捗状況の更新
- *
- */
- @Override
- protected void onProgressUpdate(Integer... values)
- {
- // 今回は何もしない
- }
-
- /**
- * 非同期処理の後処理
- * (結果を応答する)
- */
- @Override
- protected void onPostExecute(String result)
- {
- try
- {
- if (receiver != null)
- {
- receiver.onCaptureExportedResult(exportedFileName, result);
- }
- }
- catch (Exception ex)
- {
- Log.v(Main.APP_IDENTIFIER, "ViewCaptureExporter::onPostExecute() : " + ex.toString());
- }
- // プログレスダイアログを消す
- if (savingDialog != null)
- {
- savingDialog.dismiss();
- }
- return;
- }
-
- /**
- * 結果報告用のインタフェース
- *
- * @author MRSa
- *
- */
- public interface ICaptureExporter
- {
- /** データをキャプチャする Viewを取得する **/
- public abstract View getCaptureTargetView();
-
- /** 保存結果の報告 **/
- public abstract void onCaptureExportedResult(String exportedFileName, String detail);
- }
-}
/**
* オブジェクトの位置を整列するクラス (非同期処理を実行)
- *
* AsyncTask
* MeMoMaObjectHolder : 実行時に渡すクラス(Param)
* Integer : 途中経過を伝えるクラス(Progress)
* String : 処理結果を伝えるクラス(Result)
- *
- * @author MRSa
- *
*/
public class ObjectAligner extends AsyncTask<MeMoMaObjectHolder, Integer, String>
{
- private ProgressDialog executingDialog;
- private IAlignCallback receiver;
+ private final String TAG = toString();
+ private final ProgressDialog executingDialog;
+ private final IAlignCallback receiver;
/**
* コンストラクタ
*/
receiver = client;
// プログレスダイアログ(「保存中...」)を表示する。
- executingDialog = new ProgressDialog(context);
+ executingDialog = new ProgressDialog(context);
executingDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
executingDialog.setMessage(context.getString(R.string.dataAligning));
executingDialog.setIndeterminate(true);
}
catch (Exception ex)
{
- Log.v(Main.APP_IDENTIFIER, "ObjectAligner::onPostExecute() : " + ex.toString());
+ Log.v(TAG, "ObjectAligner::onPostExecute() : " + ex.toString());
}
// プログレスダイアログを消す
*/
public class ObjectDataInputDialog implements SeekBar.OnSeekBarChangeListener, CompoundButton.OnCheckedChangeListener, ImageButton.OnClickListener
{
+ private final String TAG = toString();
private final float FONTSIZE_SMALL = 5.0f;
private final float FONTSIZE_MIDDLE = 8.0f;
private final float FONTSIZE_LARGE = 12.0f;
catch (Exception ex)
{
//
- Log.v(Main.APP_IDENTIFIER, "setButtonBorder(): " + ex.toString());
+ Log.v(TAG, "setButtonBorder(): " + ex.toString());
}
}
*/
public class SelectLineShapeDialog implements ImageButton.OnClickListener
{
+ private final String TAG = toString();
private int lineThickness = LineStyleHolder.LINETHICKNESS_THIN;
private int lineStyle = LineStyleHolder.LINESTYLE_STRAIGHT_NO_ARROW;
private int lineShape = LineStyleHolder.LINESHAPE_NORMAL;
lineStyleHolder.setLineStyle(toSetLineStyle);
lineStyleHolder.setLineThickness(toSetLineThickness);
- Log.v(Main.APP_IDENTIFIER, ":::CHANGE LINE ::: shape:" + toSetLineShape + " style:" + toSetLineStyle + " thickness:" + toSetLineThickness);
+ Log.v(TAG, ":::CHANGE LINE ::: shape:" + toSetLineShape + " style:" + toSetLineStyle + " thickness:" + toSetLineThickness);
}
/**
catch (Exception ex)
{
//
- Log.v(Main.APP_IDENTIFIER, "setButtonBorder(): " + ex.toString());
+ Log.v(TAG, "setButtonBorder(): " + ex.toString());
}
}
--- /dev/null
+<vector android:height="24dp" android:tint="#323232"
+ android:viewportHeight="24" android:viewportWidth="24"
+ android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
+ <path android:fillColor="@android:color/white" android:pathData="M17,3L5,3c-1.11,0 -2,0.9 -2,2v14c0,1.1 0.89,2 2,2h14c1.1,0 2,-0.9 2,-2L21,7l-4,-4zM12,19c-1.66,0 -3,-1.34 -3,-3s1.34,-3 3,-3 3,1.34 3,3 -1.34,3 -3,3zM15,9L5,9L5,5h10v4z"/>
+</vector>
--- /dev/null
+<vector android:height="24dp" android:tint="#000000"
+ android:viewportHeight="24" android:viewportWidth="24"
+ android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
+ <path android:fillColor="@android:color/white" android:pathData="M17,3L5,3c-1.11,0 -2,0.9 -2,2v14c0,1.1 0.89,2 2,2h14c1.1,0 2,-0.9 2,-2L21,7l-4,-4zM12,19c-1.66,0 -3,-1.34 -3,-3s1.34,-3 3,-3 3,1.34 3,3 -1.34,3 -3,3zM15,9L5,9L5,5h10v4z"/>
+</vector>
--- /dev/null
+<vector android:height="24dp" android:tint="#DDDDDD"
+ android:viewportHeight="24" android:viewportWidth="24"
+ android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
+ <path android:fillColor="@android:color/white" android:pathData="M17,3L5,3c-1.11,0 -2,0.9 -2,2v14c0,1.1 0.89,2 2,2h14c1.1,0 2,-0.9 2,-2L21,7l-4,-4zM12,19c-1.66,0 -3,-1.34 -3,-3s1.34,-3 3,-3 3,1.34 3,3 -1.34,3 -3,3zM15,9L5,9L5,5h10v4z"/>
+</vector>
<string name="labelLineShapeSelection">形状</string>
<string name="Title_SelectLineShape">接続線の設定</string>
<string name="undo_operation">1つ戻す</string>
+ <string name="permission_not_granted">許可が得られませんでしたので終了します。</string>
+ <string name="permission_capture_error">許可を得るタイミングでエラーが発生しました。</string>
</resources>
<string name="labelLineShapeSelection">Line Shape</string>
<string name="Title_SelectLineShape">Select a line style</string>
<string name="undo_operation">Undo</string>
+ <string name="permission_not_granted">Permissions not granted by the user.</string>
+ <string name="permission_capture_error">Error Occurs at the request permission sequence.</string>
</resources>
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
+ ext.kotlin_version = '1.8.20'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.0.0'
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}