mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-23 18:36:50 +01:00
Add button to share JSON details
This commit is contained in:
parent
22a6d9b7d9
commit
95b6485965
@ -68,6 +68,7 @@ import java.io.File;
|
|||||||
import java.io.FileFilter;
|
import java.io.FileFilter;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
@ -530,6 +531,9 @@ public class ActivitySummaryDetail extends AbstractGBActivity {
|
|||||||
} else if (itemId == R.id.activity_action_dev_share_raw_details) {
|
} else if (itemId == R.id.activity_action_dev_share_raw_details) {
|
||||||
shareRawDetails(ActivitySummaryDetail.this, currentItem);
|
shareRawDetails(ActivitySummaryDetail.this, currentItem);
|
||||||
return true;
|
return true;
|
||||||
|
} else if (itemId == R.id.activity_action_dev_share_json_details) {
|
||||||
|
shareJsonDetails(ActivitySummaryDetail.this, currentItem);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
@ -627,6 +631,21 @@ public class ActivitySummaryDetail extends AbstractGBActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void shareJsonDetails(final Context context, final BaseActivitySummary summary) {
|
||||||
|
if (summary.getSummaryData() == null) {
|
||||||
|
GB.toast(context, "No json details in this activity", Toast.LENGTH_LONG, GB.WARN);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final String jsonSummaryFilename = FileUtils.makeValidFileName(String.format("%s.json", DateTimeUtils.formatIso8601(summary.getStartTime())));
|
||||||
|
|
||||||
|
try {
|
||||||
|
AndroidUtils.shareBytesAsFile(context, jsonSummaryFilename, summary.getSummaryData().getBytes(StandardCharsets.UTF_8));
|
||||||
|
} catch (final Exception e) {
|
||||||
|
GB.toast(context, "Unable to share json details: " + e.getMessage(), Toast.LENGTH_LONG, GB.ERROR, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void updateMenuItems() {
|
private void updateMenuItems() {
|
||||||
boolean hasGpx = false;
|
boolean hasGpx = false;
|
||||||
boolean hasRawSummary = false;
|
boolean hasRawSummary = false;
|
||||||
|
@ -43,6 +43,11 @@
|
|||||||
android:id="@+id/activity_action_dev_share_raw_details"
|
android:id="@+id/activity_action_dev_share_raw_details"
|
||||||
android:title="@string/activity_detail_share_raw_details"
|
android:title="@string/activity_detail_share_raw_details"
|
||||||
app:showAsAction="never" />
|
app:showAsAction="never" />
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/activity_action_dev_share_json_details"
|
||||||
|
android:title="@string/activity_detail_share_json_details"
|
||||||
|
app:showAsAction="never" />
|
||||||
</menu>
|
</menu>
|
||||||
</item>
|
</item>
|
||||||
|
|
||||||
|
@ -2286,6 +2286,7 @@
|
|||||||
<string name="activity_detail_share_gps_label">Share GPS Track</string>
|
<string name="activity_detail_share_gps_label">Share GPS Track</string>
|
||||||
<string name="activity_detail_share_raw_summary">Share Raw Summary</string>
|
<string name="activity_detail_share_raw_summary">Share Raw Summary</string>
|
||||||
<string name="activity_detail_share_raw_details">Share Raw Details</string>
|
<string name="activity_detail_share_raw_details">Share Raw Details</string>
|
||||||
|
<string name="activity_detail_share_json_details">Share JSON Details</string>
|
||||||
<string name="gps_track">GPS track</string>
|
<string name="gps_track">GPS track</string>
|
||||||
<string name="dev_tools">Dev Tools</string>
|
<string name="dev_tools">Dev Tools</string>
|
||||||
<!-- Device Actions Preferences -->
|
<!-- Device Actions Preferences -->
|
||||||
|
Loading…
Reference in New Issue
Block a user