Repository from CVS
https://osdn.net/cvs/view/gokigen/MeMoMa/
Révision | c69701fee2c97c6389e56d80b39b8d7d6bc0a34f (tree) |
---|---|
l'heure | 2018-07-13 00:40:06 |
Auteur | MRSa <mrsa@myad...> |
Commiter | MRSa |
CSV一覧表示にアクションバーが出なかった不具合を修正、画像出力時のタイトルをライトグレー化する。
@@ -18,6 +18,7 @@ | ||
18 | 18 | </activity> |
19 | 19 | <activity android:name=".extension.ExtensionActivity" |
20 | 20 | android:label="@string/extent_name" |
21 | + android:theme="@android:style/Theme.Holo.Light.DarkActionBar" | |
21 | 22 | android:screenOrientation="landscape"> |
22 | 23 | <intent-filter> |
23 | 24 | <action android:name="jp.sfjp.gokigen.memoma.extension.activity" /> |
@@ -3,6 +3,8 @@ package jp.sourceforge.gokigen.memoma; | ||
3 | 3 | import java.util.List; |
4 | 4 | |
5 | 5 | import android.content.Context; |
6 | +import android.graphics.Color; | |
7 | +import android.support.annotation.NonNull; | |
6 | 8 | import android.view.LayoutInflater; |
7 | 9 | import android.view.View; |
8 | 10 | import android.view.ViewGroup; |
@@ -12,9 +14,9 @@ import android.widget.TextView; | ||
12 | 14 | |
13 | 15 | public class SymbolListArrayAdapter extends ArrayAdapter<SymbolListArrayItem> |
14 | 16 | { |
15 | - private LayoutInflater inflater = null; | |
16 | - private int textViewResourceId = 0; | |
17 | - private List<SymbolListArrayItem> listItems = null; | |
17 | + private final LayoutInflater inflater; | |
18 | + private final int textViewResourceId; | |
19 | + private final List<SymbolListArrayItem> listItems; | |
18 | 20 | |
19 | 21 | /** |
20 | 22 | * コンストラクタ |
@@ -35,9 +37,9 @@ public class SymbolListArrayAdapter extends ArrayAdapter<SymbolListArrayItem> | ||
35 | 37 | * |
36 | 38 | */ |
37 | 39 | @Override |
38 | - public View getView(int position, View convertView, ViewGroup parent) | |
40 | + public @NonNull View getView(int position, View convertView, @NonNull ViewGroup parent) | |
39 | 41 | { |
40 | - View view = null; | |
42 | + View view; | |
41 | 43 | if(convertView != null) |
42 | 44 | { |
43 | 45 | view = convertView; |
@@ -49,26 +51,28 @@ public class SymbolListArrayAdapter extends ArrayAdapter<SymbolListArrayItem> | ||
49 | 51 | |
50 | 52 | SymbolListArrayItem item = listItems.get(position); |
51 | 53 | |
52 | - ImageView imageView = (ImageView) view.findViewWithTag("icon"); | |
54 | + ImageView imageView = view.findViewWithTag("icon"); | |
53 | 55 | imageView.setImageResource(item.getIconResource()); |
54 | 56 | |
55 | 57 | int subIcon = item.getSubIconResource(); |
56 | 58 | //if (subIcon != 0) |
57 | 59 | { |
58 | - ImageView subImage = (ImageView) view.findViewWithTag("subIcon"); | |
60 | + ImageView subImage = view.findViewWithTag("subIcon"); | |
59 | 61 | subImage.setImageResource(subIcon); |
60 | 62 | } |
61 | 63 | |
62 | - TextView titleView = (TextView)view.findViewWithTag("title"); | |
64 | + TextView titleView = view.findViewWithTag("title"); | |
65 | + titleView.setTextColor(Color.LTGRAY); | |
63 | 66 | titleView.setText(item.getTextResource1st()); |
64 | 67 | |
65 | - TextView detailView = (TextView)view.findViewWithTag("detail"); | |
68 | + TextView detailView = view.findViewWithTag("detail"); | |
69 | + detailView.setTextColor(Color.LTGRAY); | |
66 | 70 | detailView.setText(item.getTextResource2nd()); |
67 | 71 | |
68 | - /** | |
69 | - TextView optionView = (TextView)view.findViewWithTag("option"); | |
72 | + /* | |
73 | + TextView optionView = view.findViewWithTag("option"); | |
70 | 74 | optionView.setText(item.getTextResource3rd()); |
71 | - **/ | |
75 | + */ | |
72 | 76 | return (view); |
73 | 77 | } |
74 | 78 | } |
@@ -307,6 +307,12 @@ public class MeMoMaCanvasDrawer implements ICanvasDrawer, GestureDetector.OnGes | ||
307 | 307 | // タイトルとめもまのアイコンを表示する : 文字の色は黒でいいのかな... |
308 | 308 | Bitmap bitmap = BitmapFactory.decodeResource(parent.getResources(), R.drawable.icon1); |
309 | 309 | canvas.drawBitmap(bitmap, 2.0f, 2.0f, paint); |
310 | + | |
311 | + // 文字をライトグレー、ちょっと影付きにする | |
312 | + paint.setColor(Color.LTGRAY); | |
313 | + paint.setStyle(Paint.Style.FILL_AND_STROKE); | |
314 | + paint.setShadowLayer(0.5f, 0.5f, 0.5f, Color.DKGRAY); | |
315 | + | |
310 | 316 | canvas.drawText(objectHolder.getDataTitle(), (bitmap.getWidth() + 10.0f), 32.0f, paint); |
311 | 317 | |
312 | 318 | } |
@@ -1,5 +1,6 @@ | ||
1 | 1 | package jp.sourceforge.gokigen.memoma.extension; |
2 | 2 | |
3 | +import android.app.ActionBar; | |
3 | 4 | import android.app.Activity; |
4 | 5 | import android.app.Dialog; |
5 | 6 | import android.content.Intent; |
@@ -31,16 +32,16 @@ public class ExtensionActivity extends Activity | ||
31 | 32 | { |
32 | 33 | super.onCreate(savedInstanceState); |
33 | 34 | |
34 | - /** リスナクラスを生成する **/ | |
35 | - listener = new ExtensionActivityListener((Activity) this); | |
35 | + // リスナクラスを生成する | |
36 | + listener = new ExtensionActivityListener(this); | |
36 | 37 | |
37 | - /** レイアウトを設定する **/ | |
38 | - setContentView(R.layout.extensionview); | |
38 | + // レイアウトを設定する | |
39 | + setContentView(R.layout.extensionview); | |
39 | 40 | |
40 | - /** リスナクラスの準備 **/ | |
41 | - listener.prepareExtraDatas(getIntent()); | |
42 | - listener.prepareListener(); | |
43 | - } | |
41 | + // リスナクラスの準備 | |
42 | + listener.prepareExtraDatas(getIntent()); | |
43 | + listener.prepareListener(); | |
44 | + } | |
44 | 45 | |
45 | 46 | /** |
46 | 47 | * メニューの生成 |
@@ -48,7 +49,7 @@ public class ExtensionActivity extends Activity | ||
48 | 49 | @Override |
49 | 50 | public boolean onCreateOptionsMenu(Menu menu) |
50 | 51 | { |
51 | - menu = listener.onCreateOptionsMenu(menu); | |
52 | + menu = listener.onCreateOptionsMenu(menu); | |
52 | 53 | return (super.onCreateOptionsMenu(menu)); |
53 | 54 | } |
54 | 55 |
@@ -5,14 +5,15 @@ import java.util.ArrayList; | ||
5 | 5 | import java.util.Calendar; |
6 | 6 | import java.util.Enumeration; |
7 | 7 | import java.util.List; |
8 | +import java.util.Locale; | |
8 | 9 | |
10 | +import android.app.ActionBar; | |
9 | 11 | import android.app.Activity; |
10 | 12 | import android.app.Dialog; |
11 | 13 | import android.content.Intent; |
12 | 14 | import android.util.Log; |
13 | 15 | import android.view.Menu; |
14 | 16 | import android.view.MenuItem; |
15 | -import android.view.MotionEvent; | |
16 | 17 | import android.view.View; |
17 | 18 | import android.view.View.OnClickListener; |
18 | 19 | import android.widget.AdapterView; |
@@ -42,27 +43,27 @@ import jp.sourceforge.gokigen.memoma.SymbolListArrayItem; | ||
42 | 43 | */ |
43 | 44 | public class ExtensionActivityListener implements OnClickListener, MeMoMaFileLoadingProcess.IResultReceiver, MeMoMaFileExportCsvProcess.IResultReceiver, FileSelectionDialog.IResultReceiver, MeMoMaFileImportCsvProcess.IResultReceiver |
44 | 45 | { |
45 | - public final int MENU_ID_EXPORT= (Menu.FIRST + 1); | |
46 | - public final int MENU_ID_SHARE = (Menu.FIRST + 2); | |
47 | - public final int MENU_ID_IMPORT = (Menu.FIRST + 3); | |
46 | + private final int MENU_ID_EXPORT= (Menu.FIRST + 1); | |
47 | + private final int MENU_ID_SHARE = (Menu.FIRST + 2); | |
48 | + private final int MENU_ID_IMPORT = (Menu.FIRST + 3); | |
48 | 49 | |
49 | - private final String EXTENSION_DIRECTORY = "/exported"; | |
50 | + private static final String EXTENSION_DIRECTORY = "/exported"; | |
50 | 51 | |
51 | - private ExternalStorageFileUtility fileUtility = null; | |
52 | - private MeMoMaObjectHolder objectHolder = null; | |
52 | + private ExternalStorageFileUtility fileUtility; | |
53 | + private MeMoMaObjectHolder objectHolder; | |
53 | 54 | private FileSelectionDialog fileSelectionDialog = null; |
54 | 55 | |
55 | 56 | private boolean isShareExportedData = false; |
56 | 57 | |
57 | 58 | private List<SymbolListArrayItem> listItems = null; |
58 | 59 | |
59 | - private Activity parent = null; // 親分 | |
60 | + private final Activity parent; // 親分 | |
60 | 61 | |
61 | 62 | /** |
62 | 63 | * コンストラクタ |
63 | - * @param argument | |
64 | + * @param argument parent activity | |
64 | 65 | */ |
65 | - public ExtensionActivityListener(Activity argument) | |
66 | + ExtensionActivityListener(Activity argument) | |
66 | 67 | { |
67 | 68 | parent = argument; |
68 | 69 | fileUtility = new ExternalStorageFileUtility(Main.APP_BASEDIR); |
@@ -71,7 +72,7 @@ public class ExtensionActivityListener implements OnClickListener, MeMoMaFileLo | ||
71 | 72 | /** |
72 | 73 | * 起動時にデータを準備する |
73 | 74 | * |
74 | - * @param myIntent | |
75 | + * @param myIntent intent information | |
75 | 76 | */ |
76 | 77 | public void prepareExtraDatas(Intent myIntent) |
77 | 78 | { |
@@ -97,7 +98,7 @@ public class ExtensionActivityListener implements OnClickListener, MeMoMaFileLo | ||
97 | 98 | public void prepareListener() |
98 | 99 | { |
99 | 100 | // フィルタ設定ボタン |
100 | - final ImageButton filterButton = (ImageButton) parent.findViewById(R.id.SetFilterButton); | |
101 | + final ImageButton filterButton = parent.findViewById(R.id.SetFilterButton); | |
101 | 102 | filterButton.setOnClickListener(this); |
102 | 103 | |
103 | 104 | } |
@@ -117,7 +118,15 @@ public class ExtensionActivityListener implements OnClickListener, MeMoMaFileLo | ||
117 | 118 | { |
118 | 119 | Log.v(Main.APP_IDENTIFIER, "ExtensionActivityListener::prepareToStart() : " + objectHolder.getDataTitle()); |
119 | 120 | |
120 | - // ファイルをロードする! | |
121 | + // アクションバーを表示する | |
122 | + ActionBar bar = parent.getActionBar(); | |
123 | + if (bar != null) | |
124 | + { | |
125 | + bar.show(); | |
126 | + bar.setTitle(objectHolder.getDataTitle()); | |
127 | + } | |
128 | + | |
129 | + // ファイルをロードする! | |
121 | 130 | // (AsyncTaskを使ってデータを読み込む) |
122 | 131 | MeMoMaFileLoadingProcess asyncTask = new MeMoMaFileLoadingProcess(parent, fileUtility, this); |
123 | 132 | asyncTask.execute(objectHolder); |
@@ -142,13 +151,13 @@ public class ExtensionActivityListener implements OnClickListener, MeMoMaFileLo | ||
142 | 151 | |
143 | 152 | /** |
144 | 153 | * 他画面から戻ってきたとき... |
145 | - * @param requestCode | |
146 | - * @param resultCode | |
147 | - * @param data | |
154 | + * | |
155 | + * | |
148 | 156 | */ |
149 | 157 | public void onActivityResult(int requestCode, int resultCode, Intent data) |
150 | 158 | { |
151 | 159 | // なにもしない... |
160 | + Log.v(Main.APP_IDENTIFIER, "rc: " + requestCode + " rs: " + resultCode + " it: " + data.getDataString()); | |
152 | 161 | } |
153 | 162 | |
154 | 163 | /** |
@@ -160,25 +169,28 @@ public class ExtensionActivityListener implements OnClickListener, MeMoMaFileLo | ||
160 | 169 | if (id == R.id.SetFilterButton) |
161 | 170 | { |
162 | 171 | // フィルタ設定ボタンが押された! |
172 | + Log.v(Main.APP_IDENTIFIER, "Selected Filter"); | |
163 | 173 | } |
164 | 174 | } |
165 | 175 | |
166 | - /** | |
176 | +/* | |
177 | + ** | |
167 | 178 | * 触られたときの処理 |
168 | - * | |
169 | - */ | |
179 | + * | |
180 | + * | |
170 | 181 | public boolean onTouch(View v, MotionEvent event) |
171 | 182 | { |
183 | + Log.v(Main.APP_IDENTIFIER, " " + v.toString() + " " + event.toString()); | |
172 | 184 | // int id = v.getId(); |
173 | 185 | // int action = event.getAction(); |
174 | 186 | |
175 | 187 | return (false); |
176 | 188 | } |
189 | +*/ | |
177 | 190 | |
178 | 191 | /** |
179 | 192 | * メニューへのアイテム追加 |
180 | - * @param menu | |
181 | - * @return | |
193 | + * | |
182 | 194 | */ |
183 | 195 | public Menu onCreateOptionsMenu(Menu menu) |
184 | 196 | { |
@@ -199,26 +211,22 @@ public class ExtensionActivityListener implements OnClickListener, MeMoMaFileLo | ||
199 | 211 | |
200 | 212 | /** |
201 | 213 | * メニュー表示前の処理 |
202 | - * @param menu | |
203 | - * @return | |
214 | + * | |
204 | 215 | */ |
205 | 216 | public void onPrepareOptionsMenu(Menu menu) |
206 | 217 | { |
207 | 218 | menu.findItem(MENU_ID_SHARE).setVisible(true); |
208 | 219 | menu.findItem(MENU_ID_EXPORT).setVisible(true); |
209 | 220 | menu.findItem(MENU_ID_IMPORT).setVisible(true); |
210 | - | |
211 | - return; | |
212 | 221 | } |
213 | 222 | |
214 | 223 | /** |
215 | 224 | * メニューのアイテムが選択されたときの処理 |
216 | - * @param item | |
217 | - * @return | |
225 | + * | |
218 | 226 | */ |
219 | 227 | public boolean onOptionsItemSelected(MenuItem item) |
220 | 228 | { |
221 | - boolean result = false; | |
229 | + boolean result; | |
222 | 230 | switch (item.getItemId()) |
223 | 231 | { |
224 | 232 | case MENU_ID_EXPORT: |
@@ -245,6 +253,7 @@ public class ExtensionActivityListener implements OnClickListener, MeMoMaFileLo | ||
245 | 253 | return (result); |
246 | 254 | } |
247 | 255 | |
256 | + | |
248 | 257 | /** |
249 | 258 | * CSV形式でデータをインポートする |
250 | 259 | * |
@@ -280,13 +289,13 @@ public class ExtensionActivityListener implements OnClickListener, MeMoMaFileLo | ||
280 | 289 | return (fileSelectionDialog.getDialog()); |
281 | 290 | } |
282 | 291 | |
283 | -/** | |
292 | + /* | |
284 | 293 | if (id == R.id.info_about_gokigen) |
285 | 294 | { |
286 | 295 | CreditDialog dialog = new CreditDialog(parent); |
287 | 296 | return (dialog.getDialog()); |
288 | 297 | } |
289 | -**/ | |
298 | + */ | |
290 | 299 | return (null); |
291 | 300 | } |
292 | 301 |
@@ -296,7 +305,15 @@ public class ExtensionActivityListener implements OnClickListener, MeMoMaFileLo | ||
296 | 305 | */ |
297 | 306 | private void prepareFileSelectionDialog(Dialog dialog) |
298 | 307 | { |
299 | - fileSelectionDialog.prepare("", EXTENSION_DIRECTORY); | |
308 | + try | |
309 | + { | |
310 | + Log.v(Main.APP_IDENTIFIER, " " + dialog.toString()); | |
311 | + fileSelectionDialog.prepare("", EXTENSION_DIRECTORY); | |
312 | + } | |
313 | + catch (Exception e) | |
314 | + { | |
315 | + e.printStackTrace(); | |
316 | + } | |
300 | 317 | } |
301 | 318 | |
302 | 319 | /** |
@@ -309,7 +326,6 @@ public class ExtensionActivityListener implements OnClickListener, MeMoMaFileLo | ||
309 | 326 | { |
310 | 327 | // CSVインポートダイアログを準備する |
311 | 328 | prepareFileSelectionDialog(dialog); |
312 | - return; | |
313 | 329 | } |
314 | 330 | } |
315 | 331 |
@@ -323,7 +339,7 @@ public class ExtensionActivityListener implements OnClickListener, MeMoMaFileLo | ||
323 | 339 | { |
324 | 340 | // リストに表示するアイテムを生成する |
325 | 341 | listItems = null; |
326 | - listItems = new ArrayList<SymbolListArrayItem>(); | |
342 | + listItems = new ArrayList<>(); | |
327 | 343 | |
328 | 344 | // TODO: 何らかの法則に従って並べ替えをする。 |
329 | 345 |
@@ -337,7 +353,7 @@ public class ExtensionActivityListener implements OnClickListener, MeMoMaFileLo | ||
337 | 353 | int objectStyleIcon = MeMoMaObjectHolder .getObjectDrawStyleIcon(pos.drawStyle); |
338 | 354 | |
339 | 355 | // ユーザチェックの有無表示 |
340 | - int userCheckedIcon = (pos.userChecked == true) ? R.drawable.btn_checked : R.drawable.btn_notchecked; | |
356 | + int userCheckedIcon = (pos.userChecked) ? R.drawable.btn_checked : R.drawable.btn_notchecked; | |
341 | 357 | |
342 | 358 | // TODO: アイテム選択時の情報エリアは(ArrayItem側には)用意しているが未使用。 |
343 | 359 | SymbolListArrayItem listItem = new SymbolListArrayItem(userCheckedIcon, pos.label, pos.detail, "", objectStyleIcon); |
@@ -382,7 +398,7 @@ public class ExtensionActivityListener implements OnClickListener, MeMoMaFileLo | ||
382 | 398 | String outputMessage = parent.getString(R.string.export_csv) + " " + objectHolder.getDataTitle() + " " + detail; |
383 | 399 | Toast.makeText(parent, outputMessage, Toast.LENGTH_SHORT).show(); |
384 | 400 | |
385 | - if (isShareExportedData == true) | |
401 | + if (isShareExportedData) | |
386 | 402 | { |
387 | 403 | // エクスポートしたファイルを共有する |
388 | 404 | shareContent(exportedFileName); |
@@ -398,7 +414,7 @@ public class ExtensionActivityListener implements OnClickListener, MeMoMaFileLo | ||
398 | 414 | try |
399 | 415 | { |
400 | 416 | // リストアダプターを生成し、設定する |
401 | - ListView listView = (ListView) parent.findViewById(R.id.ExtensionView); | |
417 | + ListView listView = parent.findViewById(R.id.ExtensionView); | |
402 | 418 | ListAdapter adapter = new SymbolListArrayAdapter(parent, R.layout.listarrayitems, listItems); |
403 | 419 | listView.setAdapter(adapter); |
404 | 420 |
@@ -425,7 +441,7 @@ public class ExtensionActivityListener implements OnClickListener, MeMoMaFileLo | ||
425 | 441 | /** |
426 | 442 | * エクスポートしたファイルを共有する |
427 | 443 | * |
428 | - * @param fileName | |
444 | + * | |
429 | 445 | */ |
430 | 446 | private void shareContent(String fileName) |
431 | 447 | { |
@@ -434,7 +450,7 @@ public class ExtensionActivityListener implements OnClickListener, MeMoMaFileLo | ||
434 | 450 | { |
435 | 451 | // 現在の時刻を取得する |
436 | 452 | Calendar calendar = Calendar.getInstance(); |
437 | - SimpleDateFormat outFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm"); | |
453 | + SimpleDateFormat outFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.US); | |
438 | 454 | String date = outFormat.format(calendar.getTime()); |
439 | 455 | |
440 | 456 | // メールタイトル |
@@ -450,7 +466,7 @@ public class ExtensionActivityListener implements OnClickListener, MeMoMaFileLo | ||
450 | 466 | } |
451 | 467 | catch (Exception ex) |
452 | 468 | { |
453 | - | |
469 | + ex.printStackTrace(); | |
454 | 470 | } |
455 | 471 | } |
456 | 472 |
@@ -468,8 +484,7 @@ public class ExtensionActivityListener implements OnClickListener, MeMoMaFileLo | ||
468 | 484 | |
469 | 485 | /** |
470 | 486 | * インポート結果の受信 |
471 | - * | |
472 | - * @param detail | |
487 | + * | |
473 | 488 | */ |
474 | 489 | public void onImportedResult(String detail) |
475 | 490 | { |
@@ -6,6 +6,7 @@ import java.io.OutputStream; | ||
6 | 6 | import java.text.SimpleDateFormat; |
7 | 7 | import java.util.Calendar; |
8 | 8 | import java.util.Enumeration; |
9 | +import java.util.Locale; | |
9 | 10 | |
10 | 11 | import android.app.Activity; |
11 | 12 | import android.app.ProgressDialog; |
@@ -42,27 +43,32 @@ public class ObjectLayoutCaptureExporter extends AsyncTask<String, Integer, Stri | ||
42 | 43 | |
43 | 44 | private static final int MINIMUM_WIDTH = 800; |
44 | 45 | private static final int MINIMUM_HEIGHT = 600; |
45 | - | |
46 | - private Activity parent = null; | |
47 | - private ICaptureLayoutExporter receiver = null; | |
48 | - private ExternalStorageFileUtility fileUtility = null; | |
46 | + | |
47 | + private ICaptureLayoutExporter receiver; | |
48 | + private ExternalStorageFileUtility fileUtility; | |
49 | 49 | private String exportedFileName = null; |
50 | - private MeMoMaObjectHolder objectHolder = null; | |
51 | - private MeMoMaCanvasDrawer canvasDrawer = null; | |
52 | - private ProgressDialog savingDialog = null; | |
50 | + private MeMoMaObjectHolder objectHolder; | |
51 | + private MeMoMaCanvasDrawer canvasDrawer; | |
52 | + private ProgressDialog savingDialog; | |
53 | 53 | private float offsetX = 0.0f; |
54 | 54 | private float offsetY = 0.0f; |
55 | + private int displayWidth; | |
56 | + private int displayHeight; | |
55 | 57 | |
56 | 58 | /** |
57 | 59 | * コンストラクタ |
58 | 60 | */ |
59 | - public ObjectLayoutCaptureExporter(Activity context, ExternalStorageFileUtility utility, MeMoMaObjectHolder holder, MeMoMaCanvasDrawer drawer, ICaptureLayoutExporter resultReceiver) | |
61 | + ObjectLayoutCaptureExporter(Activity context, ExternalStorageFileUtility utility, MeMoMaObjectHolder holder, MeMoMaCanvasDrawer drawer, ICaptureLayoutExporter resultReceiver) | |
60 | 62 | { |
61 | 63 | receiver = resultReceiver; |
62 | 64 | fileUtility = utility; |
63 | 65 | objectHolder = holder; |
64 | 66 | canvasDrawer = drawer; |
65 | - parent = context; | |
67 | + | |
68 | + // 現在の画面サイズを取得 | |
69 | + Display display = context.getWindowManager().getDefaultDisplay(); | |
70 | + displayWidth = display.getWidth(); | |
71 | + displayHeight = display.getHeight(); | |
66 | 72 | |
67 | 73 | // プログレスダイアログ(「保存中...」)を表示する。 |
68 | 74 | savingDialog = new ProgressDialog(context); |
@@ -72,9 +78,12 @@ public class ObjectLayoutCaptureExporter extends AsyncTask<String, Integer, Stri | ||
72 | 78 | savingDialog.setCancelable(false); |
73 | 79 | savingDialog.show(); |
74 | 80 | |
75 | - /** ファイルをバックアップするディレクトリを作成する **/ | |
81 | + // ファイルをバックアップするディレクトリを作成する | |
76 | 82 | File dir = new File(fileUtility.getGokigenDirectory() + "/exported"); |
77 | - dir.mkdir(); | |
83 | + if (!dir.mkdir()) | |
84 | + { | |
85 | + Log.v(Main.APP_IDENTIFIER, "mkdir is failed."); | |
86 | + } | |
78 | 87 | } |
79 | 88 | |
80 | 89 | /** |
@@ -89,10 +98,8 @@ public class ObjectLayoutCaptureExporter extends AsyncTask<String, Integer, Stri | ||
89 | 98 | |
90 | 99 | /** |
91 | 100 | * ビットマップデータを(PNG形式で)保管する。 |
92 | - * | |
93 | - * @param fileName | |
94 | - * @param objectHolder | |
95 | - * @return | |
101 | + * | |
102 | + * | |
96 | 103 | */ |
97 | 104 | private String exportToFile(String fileName, Bitmap targetBitmap) |
98 | 105 | { |
@@ -107,7 +114,7 @@ public class ObjectLayoutCaptureExporter extends AsyncTask<String, Integer, Stri | ||
107 | 114 | |
108 | 115 | // エクスポートするファイル名を決定する |
109 | 116 | Calendar calendar = Calendar.getInstance(); |
110 | - SimpleDateFormat outFormat = new SimpleDateFormat("yyyyMMddHHmmss"); | |
117 | + SimpleDateFormat outFormat = new SimpleDateFormat("yyyyMMddHHmmss", Locale.US); | |
111 | 118 | exportedFileName = fileName + "_" + outFormat.format(calendar.getTime()) + ".png"; |
112 | 119 | |
113 | 120 | // PNG形式でファイル出力を行う。 |
@@ -128,7 +135,7 @@ public class ObjectLayoutCaptureExporter extends AsyncTask<String, Integer, Stri | ||
128 | 135 | /** |
129 | 136 | * キャンバスの大きさがどれくらい必要か、チェックする。 |
130 | 137 | * |
131 | - * @return | |
138 | + * | |
132 | 139 | */ |
133 | 140 | private Rect checkCanvasSize() |
134 | 141 | { |
@@ -166,26 +173,26 @@ public class ObjectLayoutCaptureExporter extends AsyncTask<String, Integer, Stri | ||
166 | 173 | canvasSize.sort(); |
167 | 174 | |
168 | 175 | // 現在の画面サイズを取得 |
169 | - Display display = parent.getWindowManager().getDefaultDisplay(); | |
170 | - int width = display.getWidth(); | |
171 | - int height = display.getHeight(); | |
172 | - if (width < MINIMUM_WIDTH) | |
176 | + //Display display = parent.getWindowManager().getDefaultDisplay(); | |
177 | + //int width = display.getWidth(); | |
178 | + //int height = display.getHeight(); | |
179 | + if (displayWidth < MINIMUM_WIDTH) | |
173 | 180 | { |
174 | - width = MINIMUM_WIDTH; | |
181 | + displayWidth = MINIMUM_WIDTH; | |
175 | 182 | } |
176 | - if (height < MINIMUM_HEIGHT) | |
183 | + if (displayHeight < MINIMUM_HEIGHT) | |
177 | 184 | { |
178 | - height = MINIMUM_HEIGHT; | |
185 | + displayHeight = MINIMUM_HEIGHT; | |
179 | 186 | } |
180 | 187 | |
181 | 188 | // 出力の最小サイズを(表示画面サイズに)設定 |
182 | - if (canvasSize.width() < width) | |
189 | + if (canvasSize.width() < displayWidth) | |
183 | 190 | { |
184 | - canvasSize.right = canvasSize.left + width; | |
191 | + canvasSize.right = canvasSize.left + displayWidth; | |
185 | 192 | } |
186 | - if (canvasSize.height() < height) | |
193 | + if (canvasSize.height() < displayHeight) | |
187 | 194 | { |
188 | - canvasSize.bottom = canvasSize.top + height; | |
195 | + canvasSize.bottom = canvasSize.top + displayHeight; | |
189 | 196 | } |
190 | 197 | |
191 | 198 |
@@ -206,21 +213,27 @@ public class ObjectLayoutCaptureExporter extends AsyncTask<String, Integer, Stri | ||
206 | 213 | @Override |
207 | 214 | protected String doInBackground(String... datas) |
208 | 215 | { |
209 | - Rect canvasSize = checkCanvasSize(); | |
210 | - Bitmap targetBitmap = Bitmap.createBitmap(canvasSize.width(), canvasSize.height(), Bitmap.Config.RGB_565); | |
211 | - Canvas targetCanvas = new Canvas(targetBitmap); | |
212 | - | |
213 | - // オブジェクトをビットマップの中に書き込む | |
214 | - canvasDrawer.drawOnBitmapCanvas(targetCanvas, offsetX, offsetY); | |
216 | + String result = ""; | |
217 | + try | |
218 | + { | |
219 | + Rect canvasSize = checkCanvasSize(); | |
220 | + Bitmap targetBitmap = Bitmap.createBitmap(canvasSize.width(), canvasSize.height(), Bitmap.Config.RGB_565); | |
221 | + Canvas targetCanvas = new Canvas(targetBitmap); | |
215 | 222 | |
216 | - // ファイル名の設定 ... (拡張子なし) | |
217 | - String fileName = fileUtility.getGokigenDirectory() + "/exported/" + datas[0]; | |
223 | + // オブジェクトをビットマップの中に書き込む | |
224 | + canvasDrawer.drawOnBitmapCanvas(targetCanvas, offsetX, offsetY); | |
218 | 225 | |
219 | - // データを保管する | |
220 | - String result = exportToFile(fileName, targetBitmap); | |
226 | + // ファイル名の設定 ... (拡張子なし) | |
227 | + String fileName = fileUtility.getGokigenDirectory() + "/exported/" + datas[0]; | |
221 | 228 | |
229 | + // データを保管する | |
230 | + result = exportToFile(fileName, targetBitmap); | |
231 | + } | |
232 | + catch (Throwable t) | |
233 | + { | |
234 | + t.printStackTrace(); | |
235 | + } | |
222 | 236 | System.gc(); |
223 | - | |
224 | 237 | return (result); |
225 | 238 | } |
226 | 239 |
@@ -257,7 +270,6 @@ public class ObjectLayoutCaptureExporter extends AsyncTask<String, Integer, Stri | ||
257 | 270 | { |
258 | 271 | savingDialog.dismiss(); |
259 | 272 | } |
260 | - return; | |
261 | 273 | } |
262 | 274 | |
263 | 275 | /** |
@@ -268,7 +280,7 @@ public class ObjectLayoutCaptureExporter extends AsyncTask<String, Integer, Stri | ||
268 | 280 | */ |
269 | 281 | public interface ICaptureLayoutExporter |
270 | 282 | { |
271 | - /** 保存結果の報告 **/ | |
272 | - public abstract void onCaptureLayoutExportedResult(String exportedFileName, String detail); | |
283 | + // 保存結果の報告 | |
284 | + void onCaptureLayoutExportedResult(String exportedFileName, String detail); | |
273 | 285 | } |
274 | 286 | } |