• R/O
  • HTTP
  • SSH
  • HTTPS

A01d: Commit

OPC(Olympus Air)用望遠鏡アプリ。


Commit MetaInfo

Révision30de96170296e0fe5c96dbedf6c1242903cc4e00 (tree)
l'heure2018-10-13 11:00:01
AuteurMRSa <mrsa@myad...>
CommiterMRSa

Message de Log

ログデータを共有できるようにした。

Change Summary

Modification

--- /dev/null
+++ b/app/src/main/java/net/osdn/gokigen/a01d/logcat/LogCatExporter.java
@@ -0,0 +1,63 @@
1+package net.osdn.gokigen.a01d.logcat;
2+
3+import android.app.Activity;
4+import android.content.Intent;
5+import android.support.annotation.NonNull;
6+import android.util.Log;
7+import android.view.View;
8+import android.widget.AdapterView;
9+import android.widget.ArrayAdapter;
10+
11+import net.osdn.gokigen.a01d.ConfirmationDialog;
12+import net.osdn.gokigen.a01d.R;
13+
14+class LogCatExporter implements AdapterView.OnItemLongClickListener
15+{
16+ private final String TAG = toString();
17+ private final Activity activity;
18+
19+ LogCatExporter(@NonNull Activity context)
20+ {
21+ this.activity = context;
22+
23+ }
24+
25+ @Override
26+ public boolean onItemLongClick(final AdapterView<?> adapterView, View view, int i, long l)
27+ {
28+ Log.v(TAG, "onItemLongClick()" );
29+
30+ ConfirmationDialog confirm = ConfirmationDialog.newInstance(activity);
31+
32+ confirm.show(R.string.dialog_confirm_title_output_log, R.string.dialog_confirm_message_output_log, new ConfirmationDialog.Callback() {
33+ @Override
34+ public void confirm()
35+ {
36+ Log.v(TAG, "confirm()" );
37+ try {
38+ StringBuilder buf = new StringBuilder();
39+ ArrayAdapter<String> adapter = (ArrayAdapter<String>) adapterView.getAdapter();
40+ for (int index = 0; index < adapter.getCount(); index++)
41+ {
42+ buf.append(adapter.getItem(index));
43+ buf.append("\r\n");
44+ }
45+
46+ Intent intent = new Intent();
47+ intent.setAction(Intent.ACTION_SEND);
48+ intent.setType("text/plain");
49+ intent.putExtra(Intent.EXTRA_TITLE, "debug log for " + activity.getString(R.string.app_name));
50+ intent.putExtra(Intent.EXTRA_TEXT, new String(buf));
51+ activity.startActivity(intent);
52+
53+ // Toast.makeText(activity, adapter.getItem(adapter.getCount() - 1), Toast.LENGTH_SHORT).show();
54+ }
55+ catch (Exception e)
56+ {
57+ e.printStackTrace();
58+ }
59+ }
60+ });
61+ return (true);
62+ }
63+}
--- a/app/src/main/java/net/osdn/gokigen/a01d/logcat/LogCatFragment.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/logcat/LogCatFragment.java
@@ -1,5 +1,6 @@
11 package net.osdn.gokigen.a01d.logcat;
22
3+import android.app.Activity;
34 import android.os.Bundle;
45 import android.support.annotation.Nullable;
56 import android.support.v4.app.FragmentActivity;
@@ -15,6 +16,7 @@ import android.widget.ArrayAdapter;
1516 import android.widget.ListView;
1617 import android.widget.Toast;
1718
19+
1820 import net.osdn.gokigen.a01d.R;
1921
2022 import java.util.ArrayList;
@@ -172,6 +174,16 @@ public class LogCatFragment extends ListFragment
172174 super.onActivityCreated(savedInstanceState);
173175 Log.v(TAG, "LogCatFragment::onActivityCreated()");
174176 setHasOptionsMenu(true);
177+
178+ Activity activity = getActivity();
179+ if (activity != null)
180+ {
181+ ListView view = getListView();
182+ if (view != null)
183+ {
184+ getListView().setOnItemLongClickListener(new LogCatExporter(activity));
185+ }
186+ }
175187 }
176188
177189 @Override
@@ -179,6 +191,7 @@ public class LogCatFragment extends ListFragment
179191 {
180192 adapter = new ArrayAdapter<>(inflater.getContext(), android.R.layout.simple_list_item_1, dataItems);
181193 setListAdapter(adapter);
194+
182195 return (super.onCreateView(inflater, container, savedInstanceState));
183196 }
184197 }
--- a/app/src/main/java/net/osdn/gokigen/a01d/logcat/LogCatUpdater.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/logcat/LogCatUpdater.java
@@ -1,6 +1,5 @@
11 package net.osdn.gokigen.a01d.logcat;
22
3-
43 import java.io.BufferedReader;
54 import java.io.InputStreamReader;
65 import java.util.ArrayList;
--- a/app/src/main/res/values-ja/strings.xml
+++ b/app/src/main/res/values-ja/strings.xml
@@ -124,4 +124,6 @@
124124 <string name="pref_gr2_display_mode">ディスプレイモード</string>
125125 <string name="pref_gr2_lcd_sleep">接続中はカメラ画面OFF</string>
126126
127+ <string name="dialog_confirm_title_output_log">ログの共有</string>
128+ <string name="dialog_confirm_message_output_log">デバッグログを共有します。</string>
127129 </resources>
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -129,4 +129,6 @@
129129 <string name="pref_gr2_display_mode">Display Mode</string>
130130 <string name="pref_gr2_lcd_sleep">Screen off during connected</string>
131131
132+ <string name="dialog_confirm_title_output_log">Share debug log</string>
133+ <string name="dialog_confirm_message_output_log">Share the debug log, OK?</string>
132134 </resources>
--- a/build.gradle
+++ b/build.gradle
@@ -6,7 +6,7 @@ buildscript {
66 google()
77 }
88 dependencies {
9- classpath 'com.android.tools.build:gradle:3.2.0'
9+ classpath 'com.android.tools.build:gradle:3.2.1'
1010
1111 // NOTE: Do not place your application dependencies here; they belong
1212 // in the individual module build.gradle files
Afficher sur ancien navigateur de dépôt.