mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2025-02-09 08:26:48 +01:00
Allows to edit the GPX track entry in Sports Activity item
This commit is contained in:
parent
840c512a32
commit
fffe7e37c4
67
app/src/main/assets/gps_edit.svg
Normal file
67
app/src/main/assets/gps_edit.svg
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<svg
|
||||||
|
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||||
|
xmlns:cc="http://creativecommons.org/ns#"
|
||||||
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||||
|
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||||
|
height="24"
|
||||||
|
viewBox="0 0 23.999999 24"
|
||||||
|
width="24"
|
||||||
|
fill="#000000"
|
||||||
|
version="1.1"
|
||||||
|
id="svg1360"
|
||||||
|
sodipodi:docname="gps_edit.svg"
|
||||||
|
inkscape:version="1.0.2 (e86c870879, 2021-01-15)">
|
||||||
|
<metadata
|
||||||
|
id="metadata1366">
|
||||||
|
<rdf:RDF>
|
||||||
|
<cc:Work
|
||||||
|
rdf:about="">
|
||||||
|
<dc:format>image/svg+xml</dc:format>
|
||||||
|
<dc:type
|
||||||
|
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||||
|
<dc:title />
|
||||||
|
</cc:Work>
|
||||||
|
</rdf:RDF>
|
||||||
|
</metadata>
|
||||||
|
<defs
|
||||||
|
id="defs1364" />
|
||||||
|
<sodipodi:namedview
|
||||||
|
pagecolor="#ffffff"
|
||||||
|
bordercolor="#666666"
|
||||||
|
borderopacity="1"
|
||||||
|
objecttolerance="10"
|
||||||
|
gridtolerance="10"
|
||||||
|
guidetolerance="10"
|
||||||
|
inkscape:pageopacity="0"
|
||||||
|
inkscape:pageshadow="2"
|
||||||
|
inkscape:window-width="1920"
|
||||||
|
inkscape:window-height="1042"
|
||||||
|
id="namedview1362"
|
||||||
|
showgrid="false"
|
||||||
|
inkscape:zoom="22.627417"
|
||||||
|
inkscape:cx="16.91793"
|
||||||
|
inkscape:cy="12.554585"
|
||||||
|
inkscape:window-x="0"
|
||||||
|
inkscape:window-y="38"
|
||||||
|
inkscape:window-maximized="1"
|
||||||
|
inkscape:current-layer="svg1360"
|
||||||
|
inkscape:document-rotation="0" />
|
||||||
|
<path
|
||||||
|
d="M 0,0 H 24 V 23.999999 H 0 Z"
|
||||||
|
fill="none"
|
||||||
|
id="path1356" />
|
||||||
|
<path
|
||||||
|
id="path1358"
|
||||||
|
d="M 11 1 L 11 3.0605469 C 6.83 3.5205469 3.5205469 6.8300004 3.0605469 11 L 1 11 L 1 13 L 3.0605469 13 C 3.1662398 13.958129 3.428073 14.867751 3.8105469 15.710938 L 5.3476562 14.171875 C 5.1249836 13.487952 5 12.758847 5 12 C 5 8.1300004 8.13 5 12 5 C 12.757962 5 13.486688 5.1235288 14.169922 5.3457031 L 15.707031 3.8085938 C 14.864949 3.4271153 13.956627 3.166074 13 3.0605469 L 13 1 L 11 1 z M 20.1875 8.2851562 L 18.650391 9.8203125 C 18.874661 10.50644 19 11.238321 19 12 C 19 15.869999 15.87 19 12 19 C 11.235489 19 10.500828 18.87431 9.8125 18.648438 L 8.2753906 20.183594 C 9.1223377 20.569471 10.036747 20.833195 11 20.939453 L 11 23 L 13 23 L 13 20.939453 C 17.17 20.479453 20.479453 17.17 20.939453 13 L 23 13 L 23 11 L 20.939453 11 C 20.833594 10.040369 20.57097 9.1294462 20.1875 8.2851562 z " />
|
||||||
|
<path
|
||||||
|
d="M 4.6773789,-4.5166116 H 28.677379 V 19.483388 H 4.6773789 Z"
|
||||||
|
fill="none"
|
||||||
|
id="path1344" />
|
||||||
|
<path
|
||||||
|
d="m 14.05875,9.0199994 0.92,0.92 -9.0600003,9.0599996 h -0.92 v -0.92 L 14.05875,9.0199993 m 3.6,-6.0199997 c -0.25,0 -0.51,0.1 -0.7,0.29 l -1.83,1.83 3.75,3.7499997 1.83,-1.8299997 c 0.39,-0.39 0.39,-1.02 0,-1.41 l -2.34,-2.34 c -0.2,-0.2 -0.45,-0.29 -0.71,-0.29 z m -3.6,3.19 L 2.9987497,17.249999 v 3.75 h 3.75 L 17.80875,9.9399994 Z"
|
||||||
|
id="path948" />
|
||||||
|
</svg>
|
After Width: | Height: | Size: 2.9 KiB |
@ -38,6 +38,7 @@ import android.view.View;
|
|||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.animation.Animation;
|
import android.view.animation.Animation;
|
||||||
import android.view.animation.AnimationUtils;
|
import android.view.animation.AnimationUtils;
|
||||||
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
@ -56,9 +57,13 @@ import org.slf4j.Logger;
|
|||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.FileFilter;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Comparator;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -80,7 +85,6 @@ import nodomain.freeyourgadget.gadgetbridge.util.DateTimeUtils;
|
|||||||
import nodomain.freeyourgadget.gadgetbridge.util.FileUtils;
|
import nodomain.freeyourgadget.gadgetbridge.util.FileUtils;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.util.SwipeEvents;
|
import nodomain.freeyourgadget.gadgetbridge.util.SwipeEvents;
|
||||||
//import nodomain.freeyourgadget.gadgetbridge.util.OnSwipeTouchListener;
|
|
||||||
|
|
||||||
public class ActivitySummaryDetail extends AbstractGBActivity {
|
public class ActivitySummaryDetail extends AbstractGBActivity {
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(ActivitySummaryDetail.class);
|
private static final Logger LOG = LoggerFactory.getLogger(ActivitySummaryDetail.class);
|
||||||
@ -89,6 +93,10 @@ public class ActivitySummaryDetail extends AbstractGBActivity {
|
|||||||
private boolean show_raw_data = false;
|
private boolean show_raw_data = false;
|
||||||
private int alternateColor;
|
private int alternateColor;
|
||||||
private Menu mOptionsMenu;
|
private Menu mOptionsMenu;
|
||||||
|
List<String> filesGpxList = new ArrayList<>();
|
||||||
|
int selectedGpxIndex;
|
||||||
|
String selectedGpxFile;
|
||||||
|
File export_path = null;
|
||||||
|
|
||||||
public static int getAlternateColor(Context context) {
|
public static int getAlternateColor(Context context) {
|
||||||
TypedValue typedValue = new TypedValue();
|
TypedValue typedValue = new TypedValue();
|
||||||
@ -218,7 +226,6 @@ public class ActivitySummaryDetail extends AbstractGBActivity {
|
|||||||
} else {
|
} else {
|
||||||
hideCanvas();
|
hideCanvas();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -274,6 +281,58 @@ public class ActivitySummaryDetail extends AbstractGBActivity {
|
|||||||
.show();
|
.show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
ImageView activity_summary_detail_edit_gps = findViewById(R.id.activity_summary_detail_edit_gps);
|
||||||
|
activity_summary_detail_edit_gps.setOnClickListener(new View.OnClickListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
export_path = get_path();
|
||||||
|
filesGpxList = get_gpx_file_list();
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(ActivitySummaryDetail.this);
|
||||||
|
builder.setTitle(R.string.activity_summary_detail_select_gpx_track);
|
||||||
|
ArrayAdapter<String> directory_listing = new ArrayAdapter<String>(ActivitySummaryDetail.this, android.R.layout.simple_list_item_1, filesGpxList);
|
||||||
|
builder.setSingleChoiceItems(directory_listing, 0, new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
selectedGpxIndex = which;
|
||||||
|
selectedGpxFile = export_path + "/" + filesGpxList.get(selectedGpxIndex);
|
||||||
|
String message = String.format("%s %s?", getString(R.string.set), filesGpxList.get(selectedGpxIndex));
|
||||||
|
if (selectedGpxIndex == 0) {
|
||||||
|
selectedGpxFile = null;
|
||||||
|
message = String.format("%s?", getString(R.string.activity_summary_detail_clear_gpx_track));
|
||||||
|
}
|
||||||
|
|
||||||
|
new AlertDialog.Builder(ActivitySummaryDetail.this)
|
||||||
|
.setCancelable(true)
|
||||||
|
.setIcon(R.drawable.ic_warning)
|
||||||
|
.setTitle(R.string.activity_summary_detail_editing_gpx_track)
|
||||||
|
.setMessage(message)
|
||||||
|
.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
currentItem.setGpxTrack(selectedGpxFile);
|
||||||
|
currentItem.update();
|
||||||
|
if (get_gpx_file() != null) {
|
||||||
|
showCanvas();
|
||||||
|
activitySummariesGpsFragment.set_data(get_gpx_file());
|
||||||
|
} else {
|
||||||
|
hideCanvas();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.setNegativeButton(R.string.Cancel, new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.show();
|
||||||
|
dialog.dismiss();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
AlertDialog dialog = builder.create();
|
||||||
|
dialog.show();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void makeSummaryHeader(BaseActivitySummary item) {
|
private void makeSummaryHeader(BaseActivitySummary item) {
|
||||||
@ -310,6 +369,49 @@ public class ActivitySummaryDetail extends AbstractGBActivity {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private File get_path() {
|
||||||
|
File path = null;
|
||||||
|
try {
|
||||||
|
path = FileUtils.getExternalFilesDir();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<String> get_gpx_file_list() {
|
||||||
|
List<String> list = new ArrayList<>();
|
||||||
|
|
||||||
|
File[] fileListing = export_path.listFiles(new FileFilter() {
|
||||||
|
@Override
|
||||||
|
public boolean accept(File file) {
|
||||||
|
return file.getPath().toLowerCase().endsWith(".gpx");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (fileListing != null && fileListing.length > 1) {
|
||||||
|
Arrays.sort(fileListing, new Comparator<File>() {
|
||||||
|
@Override
|
||||||
|
public int compare(File fileA, File fileB) {
|
||||||
|
if (fileA.lastModified() < fileB.lastModified()) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (fileA.lastModified() > fileB.lastModified()) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
list.add(getString(R.string.activity_summary_detail_clear_gpx_track));
|
||||||
|
|
||||||
|
for (File file : fileListing) {
|
||||||
|
list.add(file.getName());
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
private void makeSummaryContent(BaseActivitySummary item) {
|
private void makeSummaryContent(BaseActivitySummary item) {
|
||||||
//make view of data from summaryData of item
|
//make view of data from summaryData of item
|
||||||
String units = GBApplication.getPrefs().getString(SettingsActivity.PREF_MEASUREMENT_SYSTEM, GBApplication.getContext().getString(R.string.p_unit_metric));
|
String units = GBApplication.getPrefs().getString(SettingsActivity.PREF_MEASUREMENT_SYSTEM, GBApplication.getContext().getString(R.string.p_unit_metric));
|
||||||
|
10
app/src/main/res/drawable/ic_edit.xml
Normal file
10
app/src/main/res/drawable/ic_edit.xml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:tint="#7E7E7E"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M14.06,9.02l0.92,0.92L5.92,19L5,19v-0.92l9.06,-9.06M17.66,3c-0.25,0 -0.51,0.1 -0.7,0.29l-1.83,1.83 3.75,3.75 1.83,-1.83c0.39,-0.39 0.39,-1.02 0,-1.41l-2.34,-2.34c-0.2,-0.2 -0.45,-0.29 -0.71,-0.29zM14.06,6.19L3,17.25L3,21h3.75L17.81,9.94l-3.75,-3.75z"/>
|
||||||
|
</vector>
|
13
app/src/main/res/drawable/ic_gps_edit.xml
Normal file
13
app/src/main/res/drawable/ic_gps_edit.xml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:tint="#7E7E7E"
|
||||||
|
android:viewportWidth="23.999998"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path
|
||||||
|
android:pathData="M11,1L11,3.0605C6.83,3.5205 3.5205,6.83 3.0605,11L1,11L1,13L3.0605,13C3.1662,13.9581 3.4281,14.8678 3.8105,15.7109L5.3477,14.1719C5.125,13.488 5,12.7588 5,12C5,8.13 8.13,5 12,5C12.758,5 13.4867,5.1235 14.1699,5.3457L15.707,3.8086C14.8649,3.4271 13.9566,3.1661 13,3.0605L13,1L11,1zM20.1875,8.2852L18.6504,9.8203C18.8747,10.5064 19,11.2383 19,12C19,15.87 15.87,19 12,19C11.2355,19 10.5008,18.8743 9.8125,18.6484L8.2754,20.1836C9.1223,20.5695 10.0367,20.8332 11,20.9395L11,23L13,23L13,20.9395C17.17,20.4795 20.4795,17.17 20.9395,13L23,13L23,11L20.9395,11C20.8336,10.0404 20.571,9.1294 20.1875,8.2852z"
|
||||||
|
android:fillColor="#000000"/>
|
||||||
|
<path
|
||||||
|
android:pathData="m14.0588,9.02 l0.92,0.92 -9.06,9.06h-0.92v-0.92L14.0588,9.02m3.6,-6.02c-0.25,0 -0.51,0.1 -0.7,0.29l-1.83,1.83 3.75,3.75 1.83,-1.83c0.39,-0.39 0.39,-1.02 0,-1.41l-2.34,-2.34c-0.2,-0.2 -0.45,-0.29 -0.71,-0.29zM14.0588,6.19L2.9987,17.25v3.75h3.75L17.8088,9.94Z"
|
||||||
|
android:fillColor="#000000"/>
|
||||||
|
</vector>
|
@ -62,10 +62,20 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_gravity="end"
|
android:layout_gravity="end"
|
||||||
android:layout_weight="0.1"
|
android:layout_weight="0"
|
||||||
android:contentDescription="@string/icon_placeholder"
|
android:contentDescription="@string/icon_placeholder"
|
||||||
android:scaleType="fitEnd"
|
android:scaleType="fitEnd"
|
||||||
app:srcCompat="@drawable/ic_create" />
|
app:srcCompat="@drawable/ic_edit" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/activity_summary_detail_edit_gps"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_gravity="end"
|
||||||
|
android:layout_weight="0"
|
||||||
|
android:contentDescription="@string/icon_placeholder"
|
||||||
|
android:scaleType="fitEnd"
|
||||||
|
app:srcCompat="@drawable/ic_gps_edit" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
@ -715,6 +715,7 @@
|
|||||||
<string name="Cancel">Cancel</string>
|
<string name="Cancel">Cancel</string>
|
||||||
<string name="Delete">Delete</string>
|
<string name="Delete">Delete</string>
|
||||||
<string name="ok">OK</string>
|
<string name="ok">OK</string>
|
||||||
|
<string name="set">Set</string>
|
||||||
<string name="activity_data_management_directory_content_title">Export/Import directory content</string>
|
<string name="activity_data_management_directory_content_title">Export/Import directory content</string>
|
||||||
<string name="activity_DB_ShowContentButton">Show Export/Import directory content</string>
|
<string name="activity_DB_ShowContentButton">Show Export/Import directory content</string>
|
||||||
<string name="activity_db_management_clean_export_directory_label">Delete files in Export/Import directory</string>
|
<string name="activity_db_management_clean_export_directory_label">Delete files in Export/Import directory</string>
|
||||||
@ -788,6 +789,9 @@
|
|||||||
<string name="activity_summaries">Sport Activities</string>
|
<string name="activity_summaries">Sport Activities</string>
|
||||||
<string name="activity_summary_detail">Sport Activity Detail</string>
|
<string name="activity_summary_detail">Sport Activity Detail</string>
|
||||||
<string name="activity_summary_edit_name_title">Edit label</string>
|
<string name="activity_summary_edit_name_title">Edit label</string>
|
||||||
|
<string name="activity_summary_detail_select_gpx_track">Select GPX track</string>
|
||||||
|
<string name="activity_summary_detail_clear_gpx_track">Clear GPX track</string>
|
||||||
|
<string name="activity_summary_detail_editing_gpx_track">Editing linked GPX track</string>
|
||||||
<string name="activity_summary_today">Today</string>
|
<string name="activity_summary_today">Today</string>
|
||||||
<string name="activity_summary_yesterday">Yesterday</string>
|
<string name="activity_summary_yesterday">Yesterday</string>
|
||||||
<string name="activity_type_biking">Biking</string>
|
<string name="activity_type_biking">Biking</string>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user