Compare commits

..

1 Commits

Author SHA1 Message Date
Dennis Guse 53f9432d45 WIP 2025-06-30 07:21:39 +02:00
174 changed files with 1386 additions and 1287 deletions
-35
View File
@@ -1,40 +1,5 @@
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<JavaCodeStyleSettings>
<option name="IMPORT_LAYOUT_TABLE">
<value>
<package name="" withSubpackages="true" static="false" module="true" />
<package name="android" withSubpackages="true" static="true" />
<package name="androidx" withSubpackages="true" static="true" />
<package name="com" withSubpackages="true" static="true" />
<package name="junit" withSubpackages="true" static="true" />
<package name="net" withSubpackages="true" static="true" />
<package name="org" withSubpackages="true" static="true" />
<package name="java" withSubpackages="true" static="true" />
<package name="javax" withSubpackages="true" static="true" />
<package name="" withSubpackages="true" static="true" />
<emptyLine />
<package name="android" withSubpackages="true" static="false" />
<emptyLine />
<package name="androidx" withSubpackages="true" static="false" />
<emptyLine />
<package name="com" withSubpackages="true" static="false" />
<emptyLine />
<package name="junit" withSubpackages="true" static="false" />
<emptyLine />
<package name="net" withSubpackages="true" static="false" />
<emptyLine />
<package name="org" withSubpackages="true" static="false" />
<emptyLine />
<package name="java" withSubpackages="true" static="false" />
<emptyLine />
<package name="javax" withSubpackages="true" static="false" />
<emptyLine />
<package name="" withSubpackages="true" static="false" />
<emptyLine />
</value>
</option>
</JavaCodeStyleSettings>
<JetCodeStyleSettings>
<option name="PACKAGES_TO_USE_STAR_IMPORTS">
<value>
+4 -12
View File
@@ -100,8 +100,8 @@ __Only required permissions:__
### Public API
OpenTracks includes an API for starting/stopping recording by another installed application (e.g., [Automate](https://llamalab.com/automate/), [Tasker](https://tasker.joaoapps.com), or [Easer](https://github.com/renyuneyun/Easer)).
The API is disabled by default to protect the user's privacy, but it can easily be enabled in the settings. Once enabled, the API can be invoked by sending an explicit Intent to start an activity.
OpenTracks includes an API for starting/stopping recording by another installed application (e.g., [Automate](https://llamalab.com/automate/), [Tasker](https://tasker.joaoapps.com), or [Easer](https://github.com/renyuneyun/Easer)).
The API can be invoked by sending an explicit Intent to start an activity.
`Package` (depends on the variant installed):
* F-Droid: `de.dennisguse.opentracks`
@@ -121,17 +121,9 @@ The API is disabled by default to protect the user's privacy, but it can easily
* **Stop a recording:** `de.dennisguse.opentracks.publicapi.StopRecording`
* **Create a marker:** `de.dennisguse.opentracks.publicapi.CreateMarker`
For testing the API using adb, the general command syntax is:
For testing via adb: `adb shell am start -e someParameter someValue -n "package/class"`
```shell
adb shell am start -e someParameter someValue -n "package/class"
```
Depending on the package and class, a complete command could look something like this:
```shell
adb shell am start -n "de.dennisguse.opentracks.playstore/de.dennisguse.opentracks.publicapi.StartRecording"
```
The Public API is disabled by default to protect the user's privacy, but it can easily be enabled in the settings.
## File formats compatibility with open-source software
| | [GPX 1.1](https://www.topografix.com/GPX/1/1/) | [KML 2.3](https://docs.opengeospatial.org/is/12-007r2/12-007r2.html) | [KMZ 2.3](https://docs.opengeospatial.org/is/12-007r2/12-007r2.html) |
+7 -7
View File
@@ -6,7 +6,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.11.0'
classpath 'com.android.tools.build:gradle:8.9.1'
}
}
@@ -46,8 +46,8 @@ android {
defaultConfig {
applicationId 'de.dennisguse.opentracks'
versionCode 6217
versionName "v4.20.0"
versionCode 6102
versionName "v4.19.0"
buildConfigField "String", "VERSION_NAME_FULL", "\"${getVersionName()}\""
@@ -142,15 +142,15 @@ android {
dependencies {
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.1.5'
implementation 'androidx.appcompat:appcompat:1.7.1'
implementation 'androidx.appcompat:appcompat:1.7.0'
implementation 'androidx.preference:preference:1.2.1'
implementation 'androidx.documentfile:documentfile:1.1.0'
implementation 'androidx.documentfile:documentfile:1.0.1'
implementation 'androidx.gridlayout:gridlayout:1.1.0'
implementation 'com.google.android.material:material:1.12.0'
implementation 'androidx.constraintlayout:constraintlayout:2.2.1'
implementation 'androidx.core:core:1.16.0'
implementation 'androidx.core:core-splashscreen:1.0.1'
implementation 'androidx.mediarouter:mediarouter:1.8.0'
implementation 'androidx.mediarouter:mediarouter:1.7.0'
implementation 'androidx.core:core-location-altitude:1.0.0-alpha03'
androidTestImplementation 'androidx.test:core:1.6.1'
@@ -158,7 +158,7 @@ dependencies {
androidTestImplementation 'androidx.test:rules:1.6.1'
androidTestImplementation 'androidx.test:runner:1.6.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1'
androidTestImplementation 'org.mockito:mockito-android:5.18.0'
androidTestImplementation 'org.mockito:mockito-android:5.17.0'
androidTestUtil 'androidx.test:orchestrator:1.5.1'
}
@@ -0,0 +1,116 @@
<?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:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="210mm"
height="297mm"
viewBox="0 0 210 297"
version="1.1"
id="svg8"
inkscape:version="1.0 (4035a4fb49, 2020-05-01)"
sodipodi:docname="ic_marker_orange_pushpin_with_shadow.svg">
<defs
id="defs2">
<linearGradient
inkscape:collect="always"
id="linearGradient871"
x1="91.712517"
y1="266.48581"
x2="95.902588"
y2="266.72339"
gradientUnits="userSpaceOnUse"
gradientTransform="rotate(22.027833,208.46275,168.26892)"
>
<stop
style="stop-color:#ffffff;stop-opacity:1"
offset="0"
id="stop867" />
<stop
style="stop-color:#898d8d;stop-opacity:1"
offset="1"
id="stop869" />
</linearGradient>
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="0.49497475"
inkscape:cx="298.98541"
inkscape:cy="561.0427"
inkscape:document-units="mm"
inkscape:current-layer="layer1"
inkscape:document-rotation="0"
showgrid="false"
inkscape:window-width="1920"
inkscape:window-height="1012"
inkscape:window-x="0"
inkscape:window-y="1080"
inkscape:window-maximized="1" />
<metadata
id="metadata5">
<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></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Ebene 1"
inkscape:groupmode="layer"
id="layer1">
<path
d="m 108.52826,213.29755 a 56.035402,7.0061195 5.281088 0 0 -22.425508,2.5321 56.035402,7.0061195 5.281088 0 0 -0.233576,0.17697 l -0.206706,-0.0237 c -0.04471,0.11554 -0.07454,0.2314 -0.09612,0.34752 a 56.035402,7.0061195 5.281088 0 0 0.337963,1.58159 c 0.980726,1.70884 3.760629,3.46326 6.583579,5.2188 l -22.744347,15.50009 a 67.064653,11.556784 4.2275244 0 0 -39.967588,5.26867 67.064653,11.556784 4.2275244 0 0 -0.729154,0.57564 67.064653,11.556784 4.2275244 0 0 -2.754353,1.36358 67.064653,11.556784 4.2275244 0 0 38.908736,16.04324 l -32.176847,27.0646 52.228334,-24.74551 a 67.064653,11.556784 4.2275244 0 0 71.411147,-3.8186 67.064653,11.556784 4.2275244 0 0 0.72812,-0.57507 67.064653,11.556784 4.2275244 0 0 2.75539,-1.36415 67.064653,11.556784 4.2275244 0 0 -12.38374,-10.59818 40.033569,5.0733922 5.2502179 0 0 0.0563,-0.0369 40.033569,5.0733922 5.2502179 0 0 0.37672,-0.34325 l 22.45186,-15.30075 c 8.23597,-0.65161 17.65581,-1.47811 22.94433,-3.00957 a 56.035402,7.0061195 5.281088 0 0 2.65514,-1.03772 56.035402,7.0061195 5.281088 0 0 -46.08401,-12.26953 56.035402,7.0061195 5.281088 0 0 -41.6357,-2.54991 z"
style="fill:#333333;fill-opacity:0.49421525;stroke:#000000;stroke-width:0.138931px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.265501"
id="path839" />
<path
style="fill:url(#linearGradient871);fill-opacity:1;stroke:#000000;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.265501"
d="M 70.603317,174.30832 33.024148,288.94657 94.566672,183.19473 Z"
id="path865"
sodipodi:nodetypes="cccc" />
<ellipse
cx="144.42586"
cy="113.06232"
rx="70.318817"
ry="39.974442"
id="ellipse26"
style="fill:#d45500;fill-opacity:1;fill-rule:evenodd;stroke-width:0.264583"
transform="rotate(22.027833)" />
<ellipse
style="fill:#ff6600;fill-opacity:1;fill-rule:evenodd;stroke-width:0.264583"
id="ellipse30"
ry="39.974442"
rx="70.318817"
cy="105.23625"
cx="145.017"
transform="rotate(22.027833)" />
<path
id="rect28"
style="fill:#d45500;fill-opacity:1;fill-rule:evenodd;stroke-width:0.264583"
d="m 85.662408,24.322061 c -0.890996,8.350369 2.928035,17.133472 6.825491,25.923906 l -23.333902,57.672763 -0.730686,1.80598 0.248621,0.10059 a 42.43035,17.360788 22.027833 0 0 33.303948,30.10067 42.43035,17.360788 22.027833 0 0 44.86507,1.52585 l 0.13892,0.0562 0.24519,-0.60599 a 42.43035,17.360788 22.027833 0 0 0.59472,-1.15581 42.43035,17.360788 22.027833 0 0 0.37668,-1.24514 l 22.45185,-55.492655 c 9.28986,-2.66566 20.09069,-6.13552 24.76397,-13.17485 z" />
<ellipse
style="fill:#ff6600;fill-opacity:1;fill-rule:evenodd;stroke-width:0.264583"
id="path24"
ry="23.966745"
rx="59.409279"
cy="-10.262156"
cx="148.14029"
transform="rotate(22.027833)" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 5.0 KiB

@@ -1,15 +0,0 @@
الإصدار 3.0.0: OpenTracks
الإصدار الأول من OpenTracks (أي، تفرع صلب من MyTracks)
التغييرات:
- تغيير العلامة التجارية من MyTracks إلى OpenTracks
- إضافة مستشعر معدل ضربات القلب بتقنية Bluetooth LE
- إزالة جميع الميزات التي تتطلب الوصول إلى الإنترنت
- إزالة تكامل خرائط جوجل
- تمت إزالة استخدام خدمات Google Play
- تمت إزالة مستشعرات ANT+
- تمت إزالة مستشعرات البلوتوث الكلاسيكية
- تمت إزالة بروتوبوف
- تمت إزالة تقدير السعرات الحرارية وتقدير النشاط
- تمت إزالة واجهة برمجة تطبيقات MyTracks Service API (أي لا يوجد تكامل مع تطبيقات أخرى)
@@ -1,17 +0,0 @@
v3.0.1: OpenTracks
التغييرات:
- علامات المشاركة
- إعادة هيكلة الإعدادات
- تمت إزالة زر الرجوع إلى شريط العمل
- تصدير: تمت إزالة خيار إعدادات حجم الصورة
- تصدير: KML كتنسيق قابل للتحديد الآن
إصلاحات الأخطاء:
- أصبح دليل التصدير الآن /OpenTracks/
- الوضع الأفقي لا يتعطل
- تم إصلاح تصدير KML/KMZ
المطور:
- الاختبار قابل للتنفيذ (لكن العديد منها يفشل)
- تمكين التكامل المستمر مع TravisCI (لا توجد اختبارات)
@@ -1,14 +0,0 @@
v3.1.0: OpenTracks
التغييرات:
- تمت إضافة إظهار المسار في تطبيقات الخرائط (تم اختباره مع OsmAnd وMaps.ME)
- تمت الإضافة أثناء التتبع، إظهار إحصائيات المسار دون فتح الجهاز
- تمت إزالة الوضع الأفقي لعرض تفاصيل المسار (كان به أخطاء)
- تمت إزالة سجل اقتراحات البحث
إصلاح الخلل:
- طلب إذن تخزين لاستيراد الكل/تصدير الكل
مطور:
- الترقية إلى Gradle 5.6
- عدم تصغير بنيات الإصدار
@@ -1,22 +0,0 @@
رفيق تتبع الرياضة الذي يحترم خصوصيتك.
الرياضة والأنشطة الخارجية تمنح السعادة والمهارة والثقة بالنفس.
قدّر صحتك من خلال تتبع تمارينك الرياضية.
يسجل أثناء الجري أو المشي، ويمنحك كمبيوتر للدراجات بشاشة أكبر لركوب الدراجات.
حدد المواقع المثيرة للاهتمام على طول طريقك بالصور.
احتفظ بالإحصائيات المسجلة بتفاصيل كبيرة لتحليلها.
شارك فقط البيانات التي تريد أن يحصل عليها الآخرون.
* إعلانات صوتية.
* يدعم مستشعرات Bluetooth LE: معدل ضربات القلب والسرعة والمسافة (ركوب الدراجات)، والإيقاع (ركوب الدراجات)، ومقياس الطاقة (ركوب الدراجات).
* كسب الارتفاع وفقدان الارتفاع: عبر مستشعر بارومتري.
* يظهر الارتفاع بالارتفاع EGM2008 (فوق متوسط مستوى سطح البحر)؛ يتم تصديره على هيئة WGS84.
* تصدير البيانات كمسارات إما على هيئة KMZ (بما في ذلك الصور) أو KML أو GPX.
* لا يوجد وصول إلى الإنترنت أو أذونات إضافية.
* سمة داكنة وفاتحة، مع احترام إعدادات النظام.
* لا إعلانات.
برنامج ليبر / برنامج مجاني / مفتوح المصدر
بمعنى أنه يمكنك استخدام ودراسة وتغيير ومشاركة شفرة المصدر.
مرخص من أباتشي 2.0
@@ -1 +1 @@
رفيق تعقّب رياضي يحترم خصوصيتك.
تعقب الرياضة التي تحترم تماما خصوصيتك.
+1 -1
View File
@@ -1 +1 @@
المسارات المفتوحة
OpenTracks
@@ -1,7 +0,0 @@
v4.19.0: OpenTracks
Změny:
- Export GPX nebyl kompatibilní (pořadí a obsah rozšíření TrackPointExtension)
Oprava chyb:
- Před verzí 4.18.0 nebylo možné odstranit značky bez obrázků
@@ -1,4 +0,0 @@
v4.19.1: OpenTracks
Oprava chyby:
- Exportovaným souborům GPX chyběla jedna schemaLocation
@@ -1,4 +0,0 @@
v4.19.2: OpenTracks
Oprava chyby:
- Opraven pád z důvodu problémových překladů
@@ -1,4 +0,0 @@
v4.19.3: OpenTracks
Oprava chyby:
- Opraven export CSV pro nadmořskou výšku (byla uříznuta v 1000 m)
@@ -1,5 +0,0 @@
v4.19.4: OpenTracks
Oprava chyb:
- Edge-to-edge (SDK35): použito na všechny verze Androidu (určitý pokrok, ale stále se na tom pracuje)
- KMZ s obrázky nebylo možné exportovat (záhlaví nebylo možné vypočítat; funkce odstraněna)
@@ -1,5 +0,0 @@
v4.19.5: OpenTracks
Oprava chyby:
- Ikona v launcheru byla někdy příliš malá
- Ikona trasy v podrobnostech používá lokalizovaný typ aktivity
@@ -1,4 +0,0 @@
v4.19.6: OpenTracks
Změny:
- Podpora edge-to-edge by nyní měla fungovat na všech verzích systému Android
@@ -1,22 +1,10 @@
OpenTracks – ein GPS-Tracker, der deine Daten für sich behält.
Erfasst deine Kilometer, ohne dass es jemand anderes tut.
Sport und Aktivitäten im Freien machen Spaß und bieten Training und mehr Selbstvertrauen.
Achte auf deine Gesundheit, indem du dein Training im Blick behältst.
Die App zeichnet während dem Laufen oder Spazieren mit und kann auch als Fahrradcomputer genutzt werden.
Interessante Orte können am Weg entlang markiert und mit Fotos versehen werden.
Messdaten können zur Analyse detailreich gespeichert werden.
Du entscheidest, welche Daten du mit anderen Menschen teilst.
* Gesprochene Ansagen
* Unterstützt Bluetooth LE Sensoren: Herzschlagfrequenz, sowie Geschwindigkeit, Distanz, Kadenz und Leistungsmessung beim Fahrradfahren.
* Höhenmessung mit einem eingebauten Barometer.
* Anzeige der Höhenmessung in EGM2008 (über dem durchschnittlichen Meeresspiegel); Export als WGS84.
* Export deiner Streckendaten als KMZ (inkl. Fotos), KML oder GPX.
* Kein Internet oder zusätzliche Berechtigungen nötig.
* Dunkler und heller Modus, sowie automatische Anpassung an das System.
* Keine Werbung.
Freie Software / Open Source
Das bedeutet, dass du den Quellcode nutzen, inspizieren, verändern und teilen darfst.
Lizensiert unter Apache 2.0
Funktionen & Features:
* zeichnet Sport und andere Outdooraktivitäten auf
* unterstützt das Markieren interessanter Orte, inkl. Foto-Funktion
* zeichnet deine Herzfrequenz auf (Bluetooth LE)
* nutze beim Radfahren deine Trittfrequenz- und Geschwindigkeitssensoren sowie Leistungsmesser (Bluetooth LE)
* exportiert deine Daten als KML oder GPX
* funktioniert ganz ohne Internet
@@ -1,4 +0,0 @@
v4.19.1: OpenTracks
Bugfix:
- Exported GPX files missed one schemaLocation
@@ -1,5 +0,0 @@
v4.19.2: OpenTracks
Bugfix:
- Fix crash due to faulty translations
@@ -1,5 +0,0 @@
v4.19.3: OpenTracks
Bugfix:
- Fix CSV export for altitude (was cut at 1000m)
@@ -1,5 +0,0 @@
v4.19.4: OpenTracks
Bugfix:
- Edge-to-edge (SDK35): applied to all version of Android (some progress, but still work in progress)
- KMZ with pictures could not be exported (heading not computable; feature removed)
@@ -1,5 +0,0 @@
v4.19.5: OpenTracks
Bugfix:
- Launcher icon was sometimes shown too small
- Track icon on detail page using localized activity type
@@ -1,4 +0,0 @@
v4.19.6: OpenTracks
Changes:
- Edge-2-edge should now be working on all Android versions
@@ -1,8 +0,0 @@
v4.20.0: OpenTracks
Changes:
- Allow to change timezone offset of tracks
- Simplified Marker UI
Bugfix:
- Edge-2-edge: react to virtual keyboard
@@ -1,4 +0,0 @@
v4.19.2 : OpenTracks
Correction de bugs :
- Correction d'un crash dû à des traductions défectueuses
@@ -1,7 +0,0 @@
v4.19.0: OpenTracks
Athruithe:
- níor chomhlíon easpórtáil GPX (Ordú agus inneachar TrackPointExtension)
Ceartúchán Bug:
- níorbh fhéidir marcóirí réamh-v4.18.0 gan pictiúir a scriosadh
@@ -1,4 +0,0 @@
v4.19.1: OpenTracks
Ceartú fabht:
- Chaill comhaid GPX onnmhairithe suíomh scéime amháin
@@ -1,4 +0,0 @@
v4.19.2: OpenTracks
Ceartú fabht:
- Deisíodh tuairteáil mar gheall ar aistriúcháin lochtacha
@@ -1,4 +0,0 @@
v4.19.3: OpenTracks
Ceartú fabht:
- Deisíodh easpórtáil CSV le haghaidh airde (gearradh ag 1000m é)
@@ -1,5 +0,0 @@
v4.19.4: OpenTracks
Ceartú fabht:
- Imeall go himeall (SDK35): curtha i bhfeidhm ar gach leagan de Android (roinnt dul chun cinn, ach obair ar siúl fós)
- Níorbh fhéidir KMZ le pictiúir a easpórtáil (níorbh fhéidir an ceannteideal a ríomh; baineadh an ghné)
@@ -1,5 +0,0 @@
v4.19.5: OpenTracks
Ceartú fabht:
- Taispeánadh deilbhín an lainseálaí róbheag uaireanta
- Deilbhín an rianaithe ar an leathanach sonraí ag baint úsáide as cineál gníomhaíochta logánaithe
@@ -1,4 +0,0 @@
v4.19.6: OpenTracks
Athruithe:
- Ba chóir go mbeadh Edge-2-edge ag obair anois ar gach leagan de Android
@@ -1,4 +0,0 @@
V4.17.8: Opentracks
மாற்றங்கள்:
- விளக்கப்படங்கள்: காட்டப்பட்ட தரவை உள்ளமைக்க முடியும்
@@ -1,11 +0,0 @@
v4.18.0: ஓபன்ட்ராக்ச்
மாற்றங்கள்:
- சி.பி.எச் முடக்கப்பட்ட எச்சரிக்கையை முடக்கலாம்
பிழைத்திருத்த:
- பாட்டம்அப்ப்பார் உள்ளடக்கத்தை ஒன்றுடன் ஒன்று
டெவலப்பர்:
- ஆண்ட்ராய்டு இருப்பிடத்திற்கு பதிலாக பதிவு நிலையைப் பயன்படுத்தவும்
- மறுசீரமைக்கப்பட்ட சென்சார் திரட்டிகள்
@@ -1,7 +0,0 @@
V4.19.0: Opentracks
மாற்றங்கள்:
- சிபிஎக்ச் ஏற்றுமதி இணக்கமாக இல்லை (டிராக் பாயிண்ட் எக்ச்டென்சன் ஆர்டர் மற்றும் உள்ளடக்கம்)
பிழைத்திருத்த:
- முன்-V4.18.0 படங்கள் இல்லாத குறிப்பான்களை நீக்க முடியவில்லை
@@ -1,4 +0,0 @@
V4.19.1: Opentracks
பிழைத்திருத்த:
- ஏற்றுமதி செய்யப்பட்ட சிபிஎக்ச் கோப்புகள் ஒரு திட்டத்தை தவறவிட்டன
@@ -1,4 +0,0 @@
V4.19.2: Opentracks
பிழைத்திருத்த:
- தவறான மொழிபெயர்ப்புகள் காரணமாக விபத்தை சரிசெய்யவும்
@@ -1,4 +0,0 @@
V4.19.3: Opentracks
பிழைத்திருத்த:
- உயரத்திற்கு காபிம ஏற்றுமதியை சரிசெய்யவும் (1000 மீ.
@@ -1,5 +0,0 @@
V4.19.4: Opentracks
பிழைத்திருத்த:
-எட்ச்-டு-எட்ச் (SDK35): ஆண்ட்ராய்டு இன் அனைத்து பதிப்பிற்கும் பயன்படுத்தப்பட்டது (சில முன்னேற்றம், ஆனால் இன்னும் முன்னேற்றத்தில் உள்ளது)
- படங்களுடன் KMZ ஏற்றுமதி செய்ய முடியவில்லை (தலைப்பு கணக்கிட முடியாதது; நற்பொருத்தம் அகற்றப்பட்டது)
@@ -1,7 +0,0 @@
v3.2.1: OpenTracks
Değişiklikler:
- Ayarlar artık tek bir sayfada
Gelişim:
- Androidx Compat'a taşınan ayarlar (parçaları kullanır)
@@ -1,10 +0,0 @@
v4.17.5: Opentracks
Değişiklikler:
- Tekrarlanabilir yapının: işe yarayıp yaramadığını görelim.
Bugfix:
- Tekrarlanabilir yapı PlayStore simgesini kullanır.
Geliştirici:
- RELEASE_BUILD.sh eklendi
@@ -1,11 +0,0 @@
v4.18.0: Opentracks
Değişiklikler:
- GPS devre dışı bırakılmış uyarısı devre dışı bırakılabilir
Bugfix:
- Üst üste binen BottomAppBar düzeltildi
Gelişim:
- Android konumu yerine kayıt konumunu kullanır
- Refactored sensör toplayıcıları
@@ -1,7 +0,0 @@
v4.19.0: Opentracks
Değişiklikler:
- GPX dışa aktarma uyumlu değildi (TrackPointExtension sıra ve içerik)
Bugfix:
- pre-v4.18.0 öncesi resimsiz işaretçilerin silinmemesi düzeltildi
@@ -1,4 +0,0 @@
v4.19.2: Opentracks
Bugfix:
- Hatalı çeviriler nedeniyle çökme sorunu düzeltildi
+1 -1
View File
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Vendored
+2 -1
View File
@@ -86,7 +86,8 @@ done
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
' "$PWD" ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
@@ -763,8 +763,8 @@ public class CustomContentProviderUtilsTest {
TrackPoint trackPoint = contentProviderUtils.createTrackPoint(cursorMock);
// then
assertEquals(latitude, trackPoint.getPosition().latitude(), 0.01);
assertEquals(longitude, trackPoint.getPosition().longitude(), 0.01);
assertEquals(longitude, trackPoint.getLongitude(), 0.01);
assertEquals(latitude, trackPoint.getLatitude(), 0.01);
assertEquals(time, trackPoint.getTime().toEpochMilli());
assertEquals(speed, trackPoint.getSpeed().toMPS(), 0.01);
assertEquals(HeartRate.of(75f), trackPoint.getHeartRate());
@@ -0,0 +1,44 @@
package de.dennisguse.opentracks.io.file.exporter;
import org.junit.Test;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
public class FITv2TrackExporterTest {
private final byte FIT_PROTOCOL_VERSION = 2 << 4 + 0;
private final short FIT_PROFILE_VERSION = 21 * 1000 + 158;
private long checksum;
private final byte FILE_HEADER_SIZE = 14;
@Test
public void run() {
ByteBuffer littleEndian = ByteBuffer
.allocate(FILE_HEADER_SIZE)
.order(ByteOrder.LITTLE_ENDIAN);
littleEndian.put(0, FILE_HEADER_SIZE);
littleEndian.put(1, FIT_PROTOCOL_VERSION);
// Profile version: 1513
littleEndian.putShort(2, FIT_PROFILE_VERSION);
// Data size: 32bit
littleEndian.putInt(4, 0); // We do not calculate the data size.
// .FIT
littleEndian.putChar(8, '.');
littleEndian.putChar(9, 'F');
littleEndian.putChar(10, 'I');
littleEndian.putChar(11, 'T');
// CRC (not implemented)
littleEndian.put(12, (byte) 0);
littleEndian.put(13, (byte) 0);
var a = littleEndian.array();
littleEndian.array();
}
}
@@ -18,7 +18,6 @@ import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.LargeTest;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.rule.GrantPermissionRule;
import androidx.test.rule.ServiceTestRule;
import org.junit.After;
@@ -46,7 +45,6 @@ import java.util.concurrent.TimeoutException;
import java.util.stream.Collectors;
import de.dennisguse.opentracks.R;
import de.dennisguse.opentracks.TestUtil;
import de.dennisguse.opentracks.TimezoneRule;
import de.dennisguse.opentracks.content.data.TestDataUtil;
import de.dennisguse.opentracks.data.ContentProviderUtils;
@@ -89,9 +87,6 @@ public class ExportImportTest {
@Rule
public final ServiceTestRule mServiceRule = ServiceTestRule.withTimeout(5, TimeUnit.SECONDS);
@Rule
public GrantPermissionRule mGrantPermissionRule = TestUtil.createGrantPermissionRule();
//For csv_export_only() as we the timezone is hardcoded in the expectation.
@Rule
public TimezoneRule timezoneRule = new TimezoneRule(TimeZone.getTimeZone("Europe/Berlin"));
@@ -149,7 +144,7 @@ public class ExportImportTest {
Distance sensorDistance = Distance.of(10); // recording distance interval
sendLocation(trackPointCreator, "2020-02-02T02:02:03Z", 3.1234567, 14.0014567, 10, 13, 15, 1020.25, 1f);
sendLocation(trackPointCreator, "2020-02-02T02:02:03Z", 3, 14, 10, 13, 15, 10, 1f);
contentProviderUtils.insertMarker(new Marker(trackId, service.getLastStoredTrackPointWithLocation(), "Marker 1", "Marker 1 desc", "Marker 1 category", null, null));
// A sensor-only TrackPoint
@@ -160,10 +155,11 @@ public class ExportImportTest {
mockSensorData(trackPointCreator, 15f, null, 67f, 3f, 50f, null);
trackPointCreator.setClock("2020-02-02T02:02:15Z");
mockSensorData(trackPointCreator, null, null, 68f, 3f, 50f, null);
trackPointCreator.setClock("2020-02-02T02:02:16Z");
mockSensorData(trackPointCreator, 5f, Distance.of(2), 69f, 3f, 50f, null); // Distance will be added to next TrackPoint
sendLocation(trackPointCreator, "2020-02-02T02:02:17Z", 3.1234567, 14.0014567, 10, 13, 15, 1020.25, 0f);
sendLocation(trackPointCreator, "2020-02-02T02:02:17Z", 3, 14.001, 10, 13, 15, 10, 0f);
contentProviderUtils.insertMarker(new Marker(trackId, service.getLastStoredTrackPointWithLocation(), "Marker 2", "Marker 2 desc", "Marker 2 category", null, null));
trackPointCreator.setClock("2020-02-02T02:02:18Z");
@@ -173,14 +169,14 @@ public class ExportImportTest {
trackPointCreator.setClock("2020-02-02T02:03:20Z");
service.resumeTrack(trackId);
sendLocation(trackPointCreator, "2020-02-02T02:03:21Z", 3.1234567, 14.0024567, 10, 13, 15, 999.123, 0f);
sendLocation(trackPointCreator, "2020-02-02T02:03:21Z", 3, 14.002, 10, 13, 15, 10, 0f);
sendLocation(trackPointCreator, "2020-02-02T02:03:22Z", 3.1234567, 16, 10, 13, 15, 999.123, 0f);
sendLocation(trackPointCreator, "2020-02-02T02:03:22Z", 3, 16, 10, 13, 15, 10, 0f);
trackPointCreator.setClock("2020-02-02T02:03:30Z");
service.getTrackRecordingManager().onIdle();
sendLocation(trackPointCreator, "2020-02-02T02:03:50Z", 3.1234567, 16.001, 10, 27, 15, 999.123, 0f);
sendLocation(trackPointCreator, "2020-02-02T02:03:50Z", 3, 16.001, 10, 27, 15, 10, 0f);
trackPointCreator.getSensorManager().sensorDataSet = new SensorDataSet(trackPointCreator);
trackPointCreator.setClock("2020-02-02T02:04:00Z");
@@ -213,16 +209,16 @@ public class ExportImportTest {
assertEquals(Duration.ofSeconds(26), trackStatistics.getMovingTime()); //TODO Likely too low
// Distance
assertEquals(222049.34375, trackStatistics.getTotalDistance().toM(), 0.01); //TODO Too low
assertEquals(222125.53125, trackStatistics.getTotalDistance().toM(), 0.01); //TODO Too low
// Speed
assertEquals(8540.359, trackStatistics.getMaxSpeed().toMPS(), 0.01);
assertEquals(3965.166, trackStatistics.getAverageSpeed().toMPS(), 0.01);
assertEquals(8540.359, trackStatistics.getAverageMovingSpeed().toMPS(), 0.01);
assertEquals(8543.29, trackStatistics.getMaxSpeed().toMPS(), 0.01);
assertEquals(3966.52, trackStatistics.getAverageSpeed().toMPS(), 0.01);
assertEquals(8543.28, trackStatistics.getAverageMovingSpeed().toMPS(), 0.01);
// Altitude
assertEquals(999.122, trackStatistics.getMinAltitude(), 0.01);
assertEquals(1020.25, trackStatistics.getMaxAltitude(), 0.01);
assertEquals(10, trackStatistics.getMinAltitude(), 0.01);
assertEquals(10, trackStatistics.getMaxAltitude(), 0.01);
assertEquals(2, trackStatistics.getTotalAltitudeGain(), 0.01);
assertEquals(2, trackStatistics.getTotalAltitudeLoss(), 0.01);
@@ -233,8 +229,8 @@ public class ExportImportTest {
new TrackPoint(TrackPoint.Type.TRACKPOINT,
new Position(
Instant.parse("2020-02-02T02:02:03Z"),
3.123456, 14.001456, Distance.of(10),
Altitude.WGS84.of(1020.25), null,
3d, 14d, Distance.of(10),
Altitude.WGS84.of(10), null,
null,
Speed.of(15)))
.setAltitudeLoss(1f)
@@ -255,8 +251,8 @@ public class ExportImportTest {
new TrackPoint(TrackPoint.Type.TRACKPOINT,
new Position(
Instant.parse("2020-02-02T02:02:17Z"),
3.123456, 14.001456, Distance.of(10),
Altitude.WGS84.of(1020.25), null,
3d, 14.001, Distance.of(10),
Altitude.WGS84.of(10), null,
null,
Speed.of(5)))
.setSensorDistance(Distance.of(2))
@@ -270,16 +266,16 @@ public class ExportImportTest {
new TrackPoint(TrackPoint.Type.TRACKPOINT,
new Position(
Instant.parse("2020-02-02T02:03:21Z"),
3.123456, 14.002456, Distance.of(10),
Altitude.WGS84.of(999.1229858398438), null,
3d, 14.002d, Distance.of(10),
Altitude.WGS84.of(10), null,
null,
Speed.of(15)))
.setAltitudeLoss(0f)
.setAltitudeGain(0f),
new TrackPoint(TrackPoint.Type.SEGMENT_START_AUTOMATIC,
new Position(Instant.parse("2020-02-02T02:03:22Z"),
3.123456, 16d, Distance.of(10),
Altitude.WGS84.of(999.1229858398438), null,
3d, 16d, Distance.of(10),
Altitude.WGS84.of(10), null,
null,
Speed.of(15)))
.setAltitudeLoss(0f)
@@ -290,8 +286,8 @@ public class ExportImportTest {
new TrackPoint(TrackPoint.Type.TRACKPOINT,
new Position(
Instant.parse("2020-02-02T02:03:50Z"),
3.123456, 16.001, Distance.of(10),
Altitude.WGS84.of(999.1229858398438), null,
3d, 16.001, Distance.of(10),
Altitude.WGS84.of(10), null,
null, Speed.of(15)))
.setAltitudeLoss(0f)
.setAltitudeGain(0f),
@@ -338,26 +334,7 @@ public class ExportImportTest {
// Time
assertEquals(track.getZoneOffset(), importedTrack.getZoneOffset());
assertEquals(Instant.parse("2020-02-02T02:02:02Z"), importedTrackStatistics.getStartTime());
assertEquals(Instant.parse("2020-02-02T02:04:00Z"), importedTrackStatistics.getStopTime());
assertEquals(Duration.ofSeconds(56), importedTrackStatistics.getTotalTime());
assertEquals(Duration.ofSeconds(26), importedTrackStatistics.getMovingTime());
// Distance
assertEquals(222049.421, importedTrackStatistics.getTotalDistance().toM(), 0.01);
// Speed
assertEquals(8540.362, importedTrackStatistics.getMaxSpeed().toMPS(), 0.01);
assertEquals(3965.168, importedTrackStatistics.getAverageSpeed().toMPS(), 0.01);
assertEquals(8540.362, importedTrackStatistics.getAverageMovingSpeed().toMPS(), 0.01);
// Altitude
assertEquals(999.122, importedTrackStatistics.getMinAltitude(), 0.01);
assertEquals(1020.25, importedTrackStatistics.getMaxAltitude(), 0.01);
assertEquals(2, importedTrackStatistics.getTotalAltitudeGain(), 0.01);
assertEquals(2, importedTrackStatistics.getTotalAltitudeLoss(), 0.01);
assertEquals(track.getTrackStatistics(), importedTrackStatistics);
// 4. markers
assertMarkers();
@@ -429,8 +406,8 @@ public class ExportImportTest {
new TrackPoint(TrackPoint.Type.SEGMENT_START_AUTOMATIC,
new Position(
Instant.parse("2020-02-02T02:02:03Z"),
3.123456, 14.001456d, Distance.of(10),
Altitude.WGS84.of(1020.2), null,
3d, 14d, Distance.of(10),
Altitude.WGS84.of(10), null,
null,
Speed.of(15)))
.setAltitudeLoss(1f)
@@ -438,8 +415,8 @@ public class ExportImportTest {
new TrackPoint(TrackPoint.Type.TRACKPOINT,
new Position(
Instant.parse("2020-02-02T02:02:17Z"),
3.123456, 14.001456, Distance.of(10),
Altitude.WGS84.of(1020.2), null,
3d, 14.001, Distance.of(10),
Altitude.WGS84.of(10), null,
null,
Speed.of(5)))
.setAltitudeLoss(1f)
@@ -451,8 +428,8 @@ public class ExportImportTest {
new TrackPoint(TrackPoint.Type.SEGMENT_START_AUTOMATIC,
new Position(
Instant.parse("2020-02-02T02:03:21Z"),
3.123456, 14.002456, Distance.of(10),
Altitude.WGS84.of(999.0999755859375), null,
3d, 14.002, Distance.of(10),
Altitude.WGS84.of(10), null,
null,
Speed.of(15)))
.setAltitudeLoss(0f)
@@ -460,8 +437,8 @@ public class ExportImportTest {
new TrackPoint(TrackPoint.Type.SEGMENT_START_AUTOMATIC,
new Position(
Instant.parse("2020-02-02T02:03:22Z"),
3.123456, 16d, Distance.of(10),
Altitude.WGS84.of(999.0999755859375), null,
3d, 16d, Distance.of(10),
Altitude.WGS84.of(10), null,
null,
Speed.of(15)))
.setAltitudeLoss(0f)
@@ -469,8 +446,8 @@ public class ExportImportTest {
new TrackPoint(TrackPoint.Type.TRACKPOINT,
new Position(
Instant.parse("2020-02-02T02:03:50Z"),
3.123456, 16.001, Distance.of(10),
Altitude.WGS84.of(999.0999755859375), null,
3d, 16.001, Distance.of(10),
Altitude.WGS84.of(10), null,
null,
Speed.of(10)))
.setAltitudeLoss(0f)
@@ -490,16 +467,16 @@ public class ExportImportTest {
assertEquals(Duration.ofSeconds(107), importedTrackStatistics.getMovingTime());
// Distance
assertEquals(222271.734, importedTrackStatistics.getTotalDistance().toM(), 0.01);
assertEquals(222347.85, importedTrackStatistics.getTotalDistance().toM(), 0.01);
// Speed
assertEquals(2077.305, importedTrackStatistics.getMaxSpeed().toMPS(), 0.01);
assertEquals(2077.305, importedTrackStatistics.getAverageSpeed().toMPS(), 0.01);
assertEquals(2077.305, importedTrackStatistics.getAverageMovingSpeed().toMPS(), 0.01);
assertEquals(2078.01, importedTrackStatistics.getMaxSpeed().toMPS(), 0.01);
assertEquals(2078.01, importedTrackStatistics.getAverageSpeed().toMPS(), 0.01);
assertEquals(2078.01, importedTrackStatistics.getAverageMovingSpeed().toMPS(), 0.01);
// Altitude
assertEquals(999.099, importedTrackStatistics.getMinAltitude(), 0.01);
assertEquals(1020.2, importedTrackStatistics.getMaxAltitude(), 0.01);
assertEquals(10, importedTrackStatistics.getMinAltitude(), 0.01);
assertEquals(10, importedTrackStatistics.getMaxAltitude(), 0.01);
assertEquals(2, importedTrackStatistics.getTotalAltitudeGain(), 0.01);
assertEquals(2, importedTrackStatistics.getTotalAltitudeLoss(), 0.01);
@@ -637,7 +614,7 @@ public class ExportImportTest {
}
}
private void sendLocation(TrackPointCreator trackPointCreator, String time, double latitude, double longitude, float accuracy, float verticalAccuracy, float speed, double altitude, Float altitudeGain) {
private void sendLocation(TrackPointCreator trackPointCreator, String time, double latitude, double longitude, float accuracy, float verticalAccuracy, float speed, float altitude, Float altitudeGain) {
Location location = new Location("mock");
location.setLatitude(latitude);
location.setLongitude(longitude);
@@ -20,8 +20,8 @@ public class TrackPointAssert {
Assert.assertEquals("has location,", expected.hasLocation(), actual.hasLocation());
if (expected.hasLocation()) {
Assert.assertEquals("latitude", expected.getPosition().latitude(), actual.getPosition().latitude(), 0.001);
Assert.assertEquals("longitude", expected.getPosition().longitude(), actual.getPosition().longitude(), 0.001);
Assert.assertEquals("latitude", expected.getLatitude(), actual.getLatitude(), 0.001);
Assert.assertEquals("longitude", expected.getLongitude(), actual.getLongitude(), 0.001);
}
Assert.assertEquals("has altitude", expected.hasAltitude(), actual.hasAltitude());
+5 -5
View File
@@ -1,13 +1,13 @@
#time,trackpoint_type,latitude,longitude,altitude,accuracy_horizontal,accuracy_vertical,speed,altitude_gain,altitude_loss,sensor_distance,heartrate,cadence,power
"2020-02-02T03:02:02+01:00","SEGMENT_START_MANUAL",,,,,,,,,,,,
"2020-02-02T03:02:03+01:00","TRACKPOINT",3.123456,14.001456,1020.2,10,,54,1,1,,,,
"2020-02-02T03:02:03+01:00","TRACKPOINT",3,14,10,10,,54,1,1,,,,
"2020-02-02T03:02:04+01:00","TRACKPOINT",,,,,,54,1,1,10,66,3,50
"2020-02-02T03:02:15+01:00","TRACKPOINT",,,,,,,,,,68,3,50
"2020-02-02T03:02:17+01:00","TRACKPOINT",3.123456,14.001456,1020.2,10,,18,0,0,2,69,3,50
"2020-02-02T03:02:17+01:00","TRACKPOINT",3,14.001,10,10,,18,0,0,2,69,3,50
"2020-02-02T03:02:18+01:00","SEGMENT_END_MANUAL",,,,,,,,,,,,
"2020-02-02T03:03:20+01:00","SEGMENT_START_MANUAL",,,,,,,,,,,,
"2020-02-02T03:03:21+01:00","TRACKPOINT",3.123456,14.002456,999.1,10,,54,0,0,,,,
"2020-02-02T03:03:22+01:00","SEGMENT_START_AUTOMATIC",3.123456,16,999.1,10,,54,0,0,,,,
"2020-02-02T03:03:21+01:00","TRACKPOINT",3,14.002,10,10,,54,0,0,,,,
"2020-02-02T03:03:22+01:00","SEGMENT_START_AUTOMATIC",3,16,10,10,,54,0,0,,,,
"2020-02-02T03:03:30+01:00","IDLE",,,,,,,0,0,,,,
"2020-02-02T03:03:50+01:00","TRACKPOINT",3.123456,16.001,999.1,10,,54,0,0,,,,
"2020-02-02T03:03:50+01:00","TRACKPOINT",3,16.001,10,10,,54,0,0,,,,
"2020-02-02T03:04:00+01:00","SEGMENT_END_MANUAL",,,,,,,,,,,,
1 #time trackpoint_type latitude longitude altitude accuracy_horizontal accuracy_vertical speed altitude_gain altitude_loss sensor_distance heartrate cadence power
2 2020-02-02T03:02:02+01:00 SEGMENT_START_MANUAL
3 2020-02-02T03:02:03+01:00 TRACKPOINT 3.123456 3 14.001456 14 1020.2 10 10 54 1 1
4 2020-02-02T03:02:04+01:00 TRACKPOINT 54 1 1 10 66 3 50
5 2020-02-02T03:02:15+01:00 TRACKPOINT 68 3 50
6 2020-02-02T03:02:17+01:00 TRACKPOINT 3.123456 3 14.001456 14.001 1020.2 10 10 18 0 0 2 69 3 50
7 2020-02-02T03:02:18+01:00 SEGMENT_END_MANUAL
8 2020-02-02T03:03:20+01:00 SEGMENT_START_MANUAL
9 2020-02-02T03:03:21+01:00 TRACKPOINT 3.123456 3 14.002456 14.002 999.1 10 10 54 0 0
10 2020-02-02T03:03:22+01:00 SEGMENT_START_AUTOMATIC 3.123456 3 16 999.1 10 10 54 0 0
11 2020-02-02T03:03:30+01:00 IDLE 0 0
12 2020-02-02T03:03:50+01:00 TRACKPOINT 3.123456 3 16.001 999.1 10 10 54 0 0
13 2020-02-02T03:04:00+01:00 SEGMENT_END_MANUAL
@@ -3,7 +3,6 @@ package de.dennisguse.opentracks;
import android.os.Bundle;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import de.dennisguse.opentracks.databinding.AboutBinding;
@@ -30,8 +29,7 @@ public class AboutActivity extends AbstractActivity {
ViewUtils.makeClickableLinks(findViewById(android.R.id.content));
}
@NonNull
protected View createRootView() {
protected View getRootView() {
viewBinding = AboutBinding.inflate(getLayoutInflater());
return viewBinding.getRoot();
}
@@ -19,13 +19,7 @@ package de.dennisguse.opentracks;
import android.os.Bundle;
import android.view.View;
import androidx.activity.EdgeToEdge;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.ViewGroupCompat;
import androidx.core.view.WindowInsetsCompat;
import de.dennisguse.opentracks.services.announcement.TTSManager;
import de.dennisguse.opentracks.settings.PreferencesUtils;
@@ -41,27 +35,12 @@ public abstract class AbstractActivity extends AppCompatActivity {
setTheme(R.style.OpenTracksThemeOled);
}
EdgeToEdge.enable(this);
super.onCreate(savedInstanceState);
// Set volume control stream for text to speech
setVolumeControlStream(TTSManager.AUDIO_STREAM);
View rootView = createRootView();
setContentView(rootView);
edge2edgeApplyInsets(rootView);
}
private void edge2edgeApplyInsets(View rootView) {
ViewCompat.setOnApplyWindowInsetsListener(rootView, (view, windowInsets) -> {
Insets insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars() | WindowInsetsCompat.Type.displayCutout() | WindowInsetsCompat.Type.ime());
view.setPadding(insets.left, insets.top, insets.right, insets.bottom);
return WindowInsetsCompat.CONSUMED;
});
// For Android 10 and below.
ViewGroupCompat.installCompatInsetsDispatch(rootView);
setContentView(getRootView());
}
@Override
@@ -70,6 +49,5 @@ public abstract class AbstractActivity extends AppCompatActivity {
return true;
}
@NonNull
protected abstract View createRootView();
protected abstract View getRootView();
}
@@ -3,7 +3,6 @@ package de.dennisguse.opentracks;
import android.os.Bundle;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import de.dennisguse.opentracks.databinding.HelpBinding;
@@ -20,9 +19,8 @@ public class HelpActivity extends AbstractActivity {
ViewUtils.makeClickableLinks(findViewById(android.R.id.content));
}
@NonNull
@Override
protected View createRootView() {
protected View getRootView() {
helpBinding = HelpBinding.inflate(getLayoutInflater());
return helpBinding.getRoot();
}
@@ -7,8 +7,6 @@ import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import androidx.annotation.NonNull;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
@@ -30,9 +28,8 @@ public class ShowErrorActivity extends AbstractActivity {
setSupportActionBar(viewBinding.bottomAppBarLayout.bottomAppBar);
}
@NonNull
@Override
protected View createRootView() {
protected View getRootView() {
viewBinding = ActivityShowErrorBinding.inflate(getLayoutInflater());
return viewBinding.getRoot();
}
@@ -23,14 +23,12 @@ import android.widget.ArrayAdapter;
import androidx.annotation.NonNull;
import java.time.ZoneOffset;
import de.dennisguse.opentracks.data.ContentProviderUtils;
import de.dennisguse.opentracks.data.models.ActivityType;
import de.dennisguse.opentracks.data.models.Track;
import de.dennisguse.opentracks.databinding.TrackEditBinding;
import de.dennisguse.opentracks.fragments.ChooseActivityTypeDialogFragment;
import de.dennisguse.opentracks.ui.ZoneOffsetAdapter;
import de.dennisguse.opentracks.util.TrackUtils;
/**
* An activity that let's the user see and edit the user editable track meta data such as track name, activity type, and track description.
@@ -70,18 +68,19 @@ public class TrackEditActivity extends AbstractActivity implements ChooseActivit
return;
}
viewBinding.trackEditName.setText(track.getName());
viewBinding.fields.trackEditName.setText(track.getName());
viewBinding.fields.trackEditActivityType.setText(track.getActivityTypeLocalized());
viewBinding.trackEditActivityTypeLocalized.setText(track.getActivityTypeLocalized());
ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_dropdown_item_1line, ActivityType.getLocalizedStrings(this));
viewBinding.trackEditActivityTypeLocalized.setAdapter(adapter);
viewBinding.trackEditActivityTypeLocalized.setOnItemClickListener((parent, view, position, id) -> {
String localizedActivityType = (String) viewBinding.trackEditActivityTypeLocalized.getAdapter().getItem(position);
viewBinding.fields.trackEditActivityType.setAdapter(adapter);
viewBinding.fields.trackEditActivityType.setOnItemClickListener((parent, view, position, id) -> {
String localizedActivityType = (String) viewBinding.fields.trackEditActivityType.getAdapter().getItem(position);
setActivityTypeIcon(ActivityType.findByLocalizedString(this, localizedActivityType));
});
viewBinding.trackEditActivityTypeLocalized.setOnFocusChangeListener((v, hasFocus) -> {
viewBinding.fields.trackEditActivityType.setOnFocusChangeListener((v, hasFocus) -> {
if (!hasFocus) {
String localizedActivityType = viewBinding.trackEditActivityTypeLocalized.getText().toString();
String localizedActivityType = viewBinding.fields.trackEditActivityType.getText().toString();
setActivityTypeIcon(ActivityType.findByLocalizedString(this, localizedActivityType));
}
});
@@ -93,23 +92,16 @@ public class TrackEditActivity extends AbstractActivity implements ChooseActivit
if (activityType == null) {
activityType = track.getActivityType();
}
setActivityTypeIcon(activityType);
viewBinding.trackEditActivityTypeIcon.setOnClickListener(v -> ChooseActivityTypeDialogFragment.showDialog(getSupportFragmentManager(), this, viewBinding.trackEditActivityTypeLocalized.getText().toString()));
viewBinding.fields.trackEditActivityTypeIcon.setOnClickListener(v -> ChooseActivityTypeDialogFragment.showDialog(getSupportFragmentManager(), this, viewBinding.fields.trackEditActivityType.getText().toString()));
viewBinding.trackEditDescription.setText(track.getDescription());
final ArrayAdapter<ZoneOffset> zoneOffsetAdapter = new ZoneOffsetAdapter(this, android.R.layout.simple_dropdown_item_1line);
viewBinding.trackEditTimeOffset.setText(track.getZoneOffset().toString());
viewBinding.trackEditTimeOffset.setAdapter(zoneOffsetAdapter);
viewBinding.trackEditTimeOffset.setOnItemClickListener((parent, view, position, id) -> track.setZoneOffset(zoneOffsetAdapter.getItem(position)));
viewBinding.fields.trackEditDescription.setText(track.getDescription());
viewBinding.trackEditSave.setOnClickListener(v -> {
track.setName(viewBinding.trackEditName.getText().toString());
track.setDescription(viewBinding.trackEditDescription.getText().toString());
track.setActivityTypeLocalizedAndUpdateActivityType(this, viewBinding.trackEditActivityTypeLocalized.getText().toString());
contentProviderUtils.updateTrack(track);
TrackUtils.updateTrack(TrackEditActivity.this, track, viewBinding.fields.trackEditName.getText().toString(),
viewBinding.fields.trackEditActivityType.getText().toString(), viewBinding.fields.trackEditDescription.getText().toString(),
contentProviderUtils);
finish();
});
@@ -123,21 +115,20 @@ public class TrackEditActivity extends AbstractActivity implements ChooseActivit
outState.putSerializable(ICON_VALUE_KEY, activityType);
}
@NonNull
@Override
protected View createRootView() {
protected View getRootView() {
viewBinding = TrackEditBinding.inflate(getLayoutInflater());
return viewBinding.getRoot();
}
private void setActivityTypeIcon(ActivityType activityType) {
this.activityType = activityType;
viewBinding.trackEditActivityTypeIcon.setImageResource(activityType.getIconDrawableId());
viewBinding.fields.trackEditActivityTypeIcon.setImageResource(activityType.getIconDrawableId());
}
@Override
public void onChooseActivityTypeDone(ActivityType activityType) {
setActivityTypeIcon(activityType);
viewBinding.trackEditActivityTypeLocalized.setText(getString(activityType.getLocalizedStringId()));
viewBinding.fields.trackEditActivityType.setText(getString(activityType.getLocalizedStringId()));
}
}
@@ -30,7 +30,6 @@ import android.view.MenuItem;
import android.view.View;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.content.res.AppCompatResources;
import androidx.core.content.ContextCompat;
@@ -243,9 +242,8 @@ public class TrackListActivity extends AbstractTrackDeleteActivity implements Co
adapter = null;
}
@NonNull
@Override
protected View createRootView() {
protected View getRootView() {
viewBinding = TrackListBinding.inflate(getLayoutInflater());
viewBinding.trackListSearchView.getEditText().setOnEditorActionListener((v, actionId, event) -> {
@@ -34,6 +34,7 @@ import com.google.android.material.tabs.TabLayoutMediator;
import de.dennisguse.opentracks.chart.ChartFragment;
import de.dennisguse.opentracks.chart.TrackDataHubInterface;
import de.dennisguse.opentracks.data.ContentProviderUtils;
import de.dennisguse.opentracks.data.TrackDataHub;
import de.dennisguse.opentracks.data.models.Track;
import de.dennisguse.opentracks.databinding.TrackRecordedBinding;
@@ -66,6 +67,8 @@ public class TrackRecordedActivity extends AbstractTrackDeleteActivity implement
private static final String CURRENT_TAB_TAG_KEY = "current_tab_tag_key";
// The following are setFrequency in onCreate.
private ContentProviderUtils contentProviderUtils;
private TrackDataHub trackDataHub;
private TrackRecordedBinding viewBinding;
@@ -82,6 +85,8 @@ public class TrackRecordedActivity extends AbstractTrackDeleteActivity implement
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
contentProviderUtils = new ContentProviderUtils(this);
handleIntent(getIntent());
trackDataHub = new TrackDataHub(this);
@@ -96,6 +101,7 @@ public class TrackRecordedActivity extends AbstractTrackDeleteActivity implement
trackRecordingServiceConnection = new TrackRecordingServiceConnection(bindCallback);
Track track = contentProviderUtils.getTrack(trackId);
viewBinding.bottomAppBarLayout.bottomAppBar.replaceMenu(R.menu.track_detail);
setSupportActionBar(viewBinding.bottomAppBarLayout.bottomAppBar);
@@ -136,9 +142,8 @@ public class TrackRecordedActivity extends AbstractTrackDeleteActivity implement
outState.putInt(CURRENT_TAB_TAG_KEY, viewBinding.trackDetailActivityViewPager.getCurrentItem());
}
@NonNull
@Override
protected View createRootView() {
protected View getRootView() {
viewBinding = TrackRecordedBinding.inflate(getLayoutInflater());
return viewBinding.getRoot();
}
@@ -49,6 +49,7 @@ import de.dennisguse.opentracks.ui.markers.MarkerListActivity;
import de.dennisguse.opentracks.ui.util.ActivityUtils;
import de.dennisguse.opentracks.util.IntentDashboardUtils;
import de.dennisguse.opentracks.util.IntentUtils;
import de.dennisguse.opentracks.util.TrackUtils;
/**
* An activity to show the track detail, record a new track or resumes an existing one.
@@ -249,9 +250,8 @@ public class TrackRecordingActivity extends AbstractActivity implements ChooseAc
trackRecordingServiceConnection = null;
}
@NonNull
@Override
protected View createRootView() {
protected View getRootView() {
viewBinding = TrackRecordingBinding.inflate(getLayoutInflater());
return viewBinding.getRoot();
}
@@ -326,9 +326,7 @@ public class TrackRecordingActivity extends AbstractActivity implements ChooseAc
public void onChooseActivityTypeDone(ActivityType activityType) {
Track track = contentProviderUtils.getTrack(trackId);
String activityTypeLocalized = getString(activityType.getLocalizedStringId());
track.setActivityTypeLocalizedAndUpdateActivityType(this, activityTypeLocalized);
contentProviderUtils.updateTrack(track);
TrackUtils.updateTrack(this, track, null, activityTypeLocalized, null, contentProviderUtils);
}
private class CustomFragmentPagerAdapter extends FragmentStateAdapter {
@@ -7,8 +7,6 @@ import android.util.Pair;
import android.view.View;
import android.widget.ArrayAdapter;
import androidx.annotation.NonNull;
import de.dennisguse.opentracks.data.ContentProviderUtils;
import de.dennisguse.opentracks.data.models.ActivityType;
import de.dennisguse.opentracks.data.models.DistanceFormatter;
@@ -22,6 +20,7 @@ import de.dennisguse.opentracks.ui.aggregatedStatistics.ConfirmDeleteDialogFragm
import de.dennisguse.opentracks.util.ExportUtils;
import de.dennisguse.opentracks.util.IntentUtils;
import de.dennisguse.opentracks.util.StringUtils;
import de.dennisguse.opentracks.util.TrackUtils;
public class TrackStoppedActivity extends AbstractTrackDeleteActivity implements ChooseActivityTypeDialogFragment.ChooseActivityTypeCaller {
@@ -33,6 +32,8 @@ public class TrackStoppedActivity extends AbstractTrackDeleteActivity implements
private Track.Id trackId;
private boolean isDiscarding = false;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -104,16 +105,13 @@ public class TrackStoppedActivity extends AbstractTrackDeleteActivity implements
}
private void storeTrackMetaData(ContentProviderUtils contentProviderUtils, Track track) {
track.setName(viewBinding.trackEditName.getText().toString());
track.setDescription(viewBinding.trackEditDescription.getText().toString());
track.setActivityTypeLocalizedAndUpdateActivityType(this, viewBinding.trackEditActivityType.getText().toString());
contentProviderUtils.updateTrack(track);
TrackUtils.updateTrack(TrackStoppedActivity.this, track, viewBinding.trackEditName.getText().toString(),
viewBinding.trackEditActivityType.getText().toString(), viewBinding.trackEditDescription.getText().toString(),
contentProviderUtils);
}
@NonNull
@Override
protected View createRootView() {
protected View getRootView() {
viewBinding = TrackStoppedBinding.inflate(getLayoutInflater());
return viewBinding.getRoot();
}
@@ -143,6 +141,7 @@ public class TrackStoppedActivity extends AbstractTrackDeleteActivity implements
@Override
protected void onDeleteConfirmed() {
isDiscarding = true;
viewBinding.loadingLayout.loadingText.setText(getString(R.string.track_discarding));
viewBinding.contentLinearLayout.setVisibility(View.GONE);
viewBinding.loadingLayout.loadingIndeterminate.setVisibility(View.VISIBLE);
@@ -784,8 +784,8 @@ public class ContentProviderUtils {
values.put(TrackPointsColumns.TYPE, trackPoint.getType().type_db);
if (trackPoint.hasLocation()) {
values.put(TrackPointsColumns.LATITUDE, (int) (trackPoint.getPosition().latitude() * 1E6));
values.put(TrackPointsColumns.LONGITUDE, (int) (trackPoint.getPosition().longitude() * 1E6));
values.put(TrackPointsColumns.LONGITUDE, (int) (trackPoint.getLongitude() * 1E6));
values.put(TrackPointsColumns.LATITUDE, (int) (trackPoint.getLatitude() * 1E6));
}
values.put(TrackPointsColumns.TIME, trackPoint.getTime().toEpochMilli());
if (trackPoint.hasAltitude()) {
@@ -129,12 +129,10 @@ public enum ActivityType {
.orElse(ActivityType.UNKNOWN);
}
@NonNull
public static ActivityType findByLocalizedString(Context context, String localizedActivityType) {
return findByLocalizedString(context.getResources(), localizedActivityType);
}
@NonNull
public static ActivityType findByLocalizedString(Resources resources, String localizedActivityType) {
return Arrays.stream(ActivityType.values())
.filter(it -> resources.getString(it.getLocalizedStringId()).equals(localizedActivityType))
@@ -132,6 +132,14 @@ public final class Marker {
return position;
}
public double getLatitude() {
return position.latitude();
}
public double getLongitude() {
return position.longitude();
}
public boolean hasAccuracy() {
return position.hasHorizontalAccuracy();
}
@@ -16,7 +16,6 @@
package de.dennisguse.opentracks.data.models;
import android.content.Context;
import android.os.Parcel;
import android.os.Parcelable;
@@ -49,7 +48,7 @@ public class Track {
private ActivityType activityType;
private ZoneOffset zoneOffset;
private final ZoneOffset zoneOffset;
private TrackStatistics trackStatistics = new TrackStatistics();
@@ -59,7 +58,7 @@ public class Track {
}
public Track(@NonNull ZoneOffset zoneOffset) {
setZoneOffset(zoneOffset);
this.zoneOffset = zoneOffset;
}
/**
@@ -114,19 +113,10 @@ public class Track {
this.activityType = activityType;
}
public void setActivityTypeLocalizedAndUpdateActivityType(Context context, String activityTypeLocalized) {
setActivityTypeLocalized(activityTypeLocalized);
setActivityType(ActivityType.findByLocalizedString(context, activityTypeLocalized));
}
public ZoneOffset getZoneOffset() {
return zoneOffset;
}
public void setZoneOffset(@NonNull ZoneOffset zoneOffset) {
this.zoneOffset = zoneOffset;
}
public OffsetDateTime getStartTime() {
return trackStatistics
.getStartTime().atOffset(zoneOffset);
@@ -147,6 +147,18 @@ public class TrackPoint {
return position.hasLocation();
}
//TODO Should be double
@Deprecated //Use getPosition()
public Double getLatitude() {
return position.latitude();
}
//TODO Should be double
@Deprecated //Use getPosition()
public Double getLongitude() {
return position.longitude();
}
@NonNull
public Position getPosition() {
return position;
@@ -16,6 +16,7 @@
package de.dennisguse.opentracks.fragments;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.util.Log;
@@ -32,6 +33,7 @@ import androidx.fragment.app.Fragment;
import de.dennisguse.opentracks.R;
import de.dennisguse.opentracks.TrackRecordedActivity;
import de.dennisguse.opentracks.data.ContentProviderUtils;
import de.dennisguse.opentracks.data.models.ActivityType;
import de.dennisguse.opentracks.data.models.DistanceFormatter;
import de.dennisguse.opentracks.data.models.SpeedFormatter;
import de.dennisguse.opentracks.data.models.Track;
@@ -183,7 +185,13 @@ public class StatisticsRecordedFragment extends Fragment {
}
// Set activity type
viewBinding.statsActivityTypeIcon.setImageDrawable(ContextCompat.getDrawable(getContext(), track.getActivityType().getIconDrawableId()));
{
Context context = getContext();
String localizedActivityType = track.getActivityTypeLocalized();
int iconDrawableId = ActivityType.findByLocalizedString(context, localizedActivityType)
.getIconDrawableId();
viewBinding.statsActivityTypeIcon.setImageDrawable(ContextCompat.getDrawable(getContext(), iconDrawableId));
}
// Set time and start datetime
{
@@ -47,9 +47,8 @@ public class IntroductionActivity extends AbstractActivity {
viewBinding.introductionViewPager.setUserInputEnabled(false);
}
@NonNull
@Override
protected View createRootView() {
protected View getRootView() {
viewBinding = IntroductionBinding.inflate(getLayoutInflater());
return viewBinding.getRoot();
}
@@ -60,6 +60,7 @@ public class CSVTrackExporter implements TrackExporter {
ALTITUDE_FORMAT.setGroupingUsed(false);
COORDINATE_FORMAT.setMaximumFractionDigits(6);
COORDINATE_FORMAT.setMaximumIntegerDigits(3);
COORDINATE_FORMAT.setGroupingUsed(false);
SPEED_FORMAT.setMaximumFractionDigits(2);
@@ -91,19 +92,19 @@ public class CSVTrackExporter implements TrackExporter {
List<Column> columns = List.of(
new Column("time", null),
new Column("trackpoint_type", t -> quote(t.getType().name())),
new Column("latitude", t -> t.hasLocation() ? COORDINATE_FORMAT.format(t.getPosition().latitude()) : ""),
new Column("longitude", t -> t.hasLocation() ? COORDINATE_FORMAT.format(t.getPosition().longitude()) : ""),
new Column("altitude", t -> t.hasAltitude() ? ALTITUDE_FORMAT.format(t.getAltitude().toM()) : ""),
new Column("latitude", t -> t.hasLocation() ? COORDINATE_FORMAT.format(t.getLatitude()) : ""),
new Column("longitude", t -> t.hasLocation() ? COORDINATE_FORMAT.format(t.getLongitude()) : ""),
new Column("altitude", t -> t.hasAltitude() ? COORDINATE_FORMAT.format(t.getAltitude().toM()) : ""),
new Column("accuracy_horizontal", t -> t.hasHorizontalAccuracy() ? DISTANCE_FORMAT.format(t.getHorizontalAccuracy().toM()) : ""),
new Column("accuracy_vertical", t -> t.hasVerticalAccuracy() ? DISTANCE_FORMAT.format(t.getVerticalAccuracy().toM()) : ""),
new Column("speed", t -> t.hasSpeed() ? SPEED_FORMAT.format(t.getSpeed().toKMH()) : ""),
new Column("altitude_gain", t -> t.hasAltitudeGain() ? ALTITUDE_FORMAT.format(t.getAltitudeGain()) : ""),
new Column("altitude_loss", t -> t.hasAltitudeLoss() ? ALTITUDE_FORMAT.format(t.getAltitudeLoss()) : ""),
new Column("altitude_gain", t -> t.hasAltitudeGain() ? DISTANCE_FORMAT.format(t.getAltitudeGain()) : ""),
new Column("altitude_loss", t -> t.hasAltitudeLoss() ? DISTANCE_FORMAT.format(t.getAltitudeLoss()) : ""),
new Column("sensor_distance", t -> t.hasSensorDistance() ? DISTANCE_FORMAT.format(t.getSensorDistance().toM()) : ""),
new Column("heartrate", t -> t.hasHeartRate() ? HEARTRATE_FORMAT.format(t.getHeartRate().getBPM()) : ""),
new Column("cadence", t -> t.hasCadence() ? CADENCE_FORMAT.format(t.getCadence().getRPM()) : ""),
new Column("power", t -> t.hasPower() ? POWER_FORMAT.format(t.getPower().getW()) : ""));
new Column("power", t -> t.hasPower() ? ALTITUDE_FORMAT.format(t.getPower().getW()) : ""));
try {
prepare(outputStream);
@@ -135,7 +136,7 @@ public class CSVTrackExporter implements TrackExporter {
while (trackPointIterator.hasNext()) {
if (Thread.interrupted()) throw new InterruptedException();
writeTrackPoint(columns, trackPointIterator.next());
writeTrackPoint(columns, trackPointIterator.next());
}
}
}
@@ -21,6 +21,7 @@ import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.view.View;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@@ -94,6 +95,8 @@ public class ExportActivity extends AppCompatActivity implements ExportService.E
private int trackExportSkippedCount;
private int trackExportTotalCount;
boolean doubleBackToCancel = false;
private ExportActivityBinding viewBinding;
private ArrayList<String> trackErrors = new ArrayList<>();
@@ -211,6 +214,19 @@ public class ExportActivity extends AppCompatActivity implements ExportService.E
exportTasks.clear();
}
@Override
public void onBackPressed() {
if (doubleBackToCancel || getTotalDone() == trackExportTotalCount) {
super.onBackPressed();
return;
}
this.doubleBackToCancel = true;
Toast.makeText(this, getString(R.string.generic_click_twice_cancel), Toast.LENGTH_SHORT).show();
new Handler().postDelayed(() -> doubleBackToCancel = false, 2000);
}
private void createExportTasks(boolean allInOneFile) {
List<Track> tracks = contentProviderUtils.getTracks();
exportTasks = new ArrayList<>();
@@ -7,7 +7,6 @@ import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.ResultReceiver;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.core.app.JobIntentService;
@@ -18,8 +17,6 @@ import de.dennisguse.opentracks.util.ExportUtils;
public class ExportService extends JobIntentService {
private static final String TAG = ExportService.class.getSimpleName();
private static final int JOB_ID = 1;
private static final String EXTRA_RECEIVER = "extra_receiver";
@@ -58,9 +55,6 @@ public class ExportService extends JobIntentService {
ExportUtils.exportTrack(this, directoryFile, exportTask);
resultReceiver.send(ExportServiceResultReceiver.RESULT_CODE_SUCCESS, bundle);
} catch (Exception e) {
Log.e(TAG, "Export failed: " + e);
e.printStackTrace(); //TODO Remove
bundle.putString(ExportServiceResultReceiver.EXTRA_EXPORT_ERROR_MESSAGE, e.getMessage());
resultReceiver.send(ExportServiceResultReceiver.RESULT_CODE_ERROR, bundle);
}
@@ -0,0 +1,74 @@
package de.dennisguse.opentracks.io.file.exporter;
import androidx.annotation.NonNull;
import androidx.annotation.VisibleForTesting;
import java.io.OutputStream;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.channels.Channels;
import java.nio.channels.WritableByteChannel;
import java.util.List;
import de.dennisguse.opentracks.data.models.Track;
/**
* FIT v2.0
* https://developer.garmin.com/fit/
* <p>
* Encoding is little endian.
*/
public class FITv2TrackExporter implements TrackExporter {
private final byte FIT_PROTOCOL_VERSION = 2 << 4 + 0;
private final short FIT_PROFILE_VERSION = 21 * 1000 + 158;
private long checksum;
private final byte FILE_HEADER_SIZE = 14;
@Override
public boolean writeTrack(List<Track> tracks, @NonNull OutputStream outputStream) {
WritableByteChannel channel = Channels.newChannel(outputStream);
writeFileHeader(channel);
// writeFileId(channel);
writeFooter(channel);
return false;
}
// https://developer.garmin.com/fit/protocol/
@VisibleForTesting
void writeFileHeader(@NonNull WritableByteChannel channel) {
ByteBuffer littleEndian = ByteBuffer
.allocate(FILE_HEADER_SIZE)
.order(ByteOrder.LITTLE_ENDIAN);
littleEndian.put(0, FILE_HEADER_SIZE);
littleEndian.put(1, FIT_PROTOCOL_VERSION);
// Profile version
littleEndian.putShort(2, FIT_PROFILE_VERSION);
// Data size: 32bit
littleEndian.putInt(4, 0); // We do not calculate the data size.
// .FIT
littleEndian.putChar(8, '.');
littleEndian.putChar(9, 'F');
littleEndian.putChar(10, 'I');
littleEndian.putChar(11, 'T');
// CRC (not implemented)
littleEndian.put(12, (byte) 0);
littleEndian.put(13, (byte) 0);
var a = littleEndian.array();
littleEndian.array();
}
private void writeFooter(@NonNull WritableByteChannel channel) {
}
}
@@ -36,7 +36,6 @@ import de.dennisguse.opentracks.data.ContentProviderUtils;
import de.dennisguse.opentracks.data.TrackPointIterator;
import de.dennisguse.opentracks.data.models.Distance;
import de.dennisguse.opentracks.data.models.Marker;
import de.dennisguse.opentracks.data.models.Position;
import de.dennisguse.opentracks.data.models.Track;
import de.dennisguse.opentracks.data.models.TrackPoint;
import de.dennisguse.opentracks.stats.TrackStatistics;
@@ -254,7 +253,7 @@ public class GPXTrackExporter implements TrackExporter {
}
private void writeMarker(ZoneOffset zoneOffset, Marker marker) {
printWriter.println("<wpt " + formatLocation(marker.getPosition()) + ">");
printWriter.println("<wpt " + formatLocation(marker.getLatitude(), marker.getLongitude()) + ">");
if (marker.hasAltitude()) {
printWriter.println("<ele>" + ALTITUDE_FORMAT.format(marker.getAltitude().toM()) + "</ele>");
}
@@ -312,7 +311,7 @@ public class GPXTrackExporter implements TrackExporter {
private Distance writeTrackPoint(ZoneOffset zoneOffset, TrackPoint trackPoint, List<TrackPoint> sensorPoints, Distance trackDistance) {
Distance cumulativeDistance;
printWriter.println("<trkpt " + formatLocation(trackPoint.getPosition()) + ">");
printWriter.println("<trkpt " + formatLocation(trackPoint.getLatitude(), trackPoint.getLongitude()) + ">");
if (trackPoint.hasAltitude()) {
printWriter.println("<ele>" + ALTITUDE_FORMAT.format(trackPoint.getAltitude().toM()) + "</ele>");
@@ -396,7 +395,7 @@ public class GPXTrackExporter implements TrackExporter {
.orElse(null);
}
private String formatLocation(Position position) {
return "lat=\"" + COORDINATE_FORMAT.format(position.latitude()) + "\" lon=\"" + COORDINATE_FORMAT.format(position.longitude()) + "\"";
private String formatLocation(double latitude, double longitude) {
return "lat=\"" + COORDINATE_FORMAT.format(latitude) + "\" lon=\"" + COORDINATE_FORMAT.format(longitude) + "\"";
}
}
@@ -33,6 +33,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Objects;
import java.util.Optional;
import de.dennisguse.opentracks.R;
import de.dennisguse.opentracks.data.ContentProviderUtils;
@@ -273,7 +274,8 @@ public class KMLTrackExporter implements TrackExporter {
private void writeMarker(Marker marker, ZoneOffset zoneOffset) {
boolean existsPhoto = MarkerUtils.buildInternalPhotoFile(context, marker.getTrackId(), marker.getPhotoUrl()) != null;
if (marker.hasPhoto() && exportPhotos && existsPhoto) {
writePhotoOverlay(marker, zoneOffset);
float heading = getHeading(marker.getTrackId(), marker.getPosition());
writePhotoOverlay(marker, heading, zoneOffset);
} else {
writePlacemark(marker.getName(), marker.getCategory(), marker.getDescription(), marker.getPosition(), marker.getTime(), zoneOffset);
}
@@ -427,14 +429,15 @@ public class KMLTrackExporter implements TrackExporter {
}
}
private void writePhotoOverlay(Marker marker, ZoneOffset zoneOffset) {
private void writePhotoOverlay(Marker marker, float heading, ZoneOffset zoneOffset) {
printWriter.println("<PhotoOverlay>");
printWriter.println("<name>" + StringUtils.formatCData(marker.getName()) + "</name>");
printWriter.println("<description>" + StringUtils.formatCData(marker.getDescription()) + "</description>");
printWriter.print("<Camera>");
printWriter.print("<longitude>" + marker.getPosition().longitude() + "</longitude>");
printWriter.print("<latitude>" + marker.getPosition().latitude() + "</latitude>");
printWriter.print("<longitude>" + marker.getLongitude() + "</longitude>");
printWriter.print("<latitude>" + marker.getLatitude() + "</latitude>");
printWriter.print("<altitude>20</altitude>");
printWriter.print("<heading>" + heading + "</heading>");
printWriter.print("<tilt>90</tilt>");
printWriter.println("</Camera>");
printWriter.println("<TimeStamp><when>" + getTime(zoneOffset, marker.getTime()) + "</when></TimeStamp>");
@@ -465,6 +468,26 @@ public class KMLTrackExporter implements TrackExporter {
return StringUtils.formatDateTimeIso8601(instant, zoneOffset);
}
/**
* TODO: check if this is a useful feature (likely not).
* Gets the heading to a location.
*/
private float getHeading(Track.Id trackId, Position position) {
TrackPoint.Id trackPointId = contentProviderUtils.getTrackPointId(trackId, position);
if (trackPointId == null) {
return position.bearing();
}
TrackPoint viewLocation = contentProviderUtils.getLastValidTrackPoint(trackId);
if (viewLocation != null) {
Optional<Float> bearing = viewLocation.bearingTo(position);
if (bearing.isPresent()) {
return bearing.get();
}
}
return position.bearing();
}
private static String getCoordinates(Position position, String separator) {
String result = position.longitude() + separator + position.latitude();
if (position.hasAltitude()) {
@@ -20,7 +20,9 @@ import android.content.ClipData;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.core.content.ContextCompat;
@@ -54,6 +56,8 @@ public class ImportActivity extends FragmentActivity {
private ImportActivityBinding viewBinding;
boolean doubleBackToCancel = false;
private ArrayList<Uri> documentUris = new ArrayList<>();
private boolean isDirectory;
@@ -118,6 +122,21 @@ public class ImportActivity extends FragmentActivity {
outState.putBoolean(BUNDLE_IS_DIRECTORY, isDirectory);
}
@Override
public void onBackPressed() {
if (doubleBackToCancel || (summary != null && getTotalDone() == summary.getTotalCount())) {
super.onBackPressed();
viewModel.cancel();
getViewModelStore().clear();
return;
}
this.doubleBackToCancel = true;
Toast.makeText(this, getString(R.string.generic_click_twice_cancel), Toast.LENGTH_SHORT).show();
new Handler().postDelayed(() -> doubleBackToCancel=false, 2000);
}
private void initViews() {
viewBinding.importProgressDone.setText("0");
viewBinding.importProgressTotal.setText("0");
@@ -178,10 +178,10 @@ public class TrackImporter {
if (current.hasLocation()) {
Instant time = current.getTime();
if (current.getPosition().latitude() == 100) {
if (current.getLatitude() == 100) {
//TODO Remove by 31st December 2021.
trackPoints.set(i, new TrackPoint(TrackPoint.Type.SEGMENT_END_MANUAL, time));
} else if (current.getPosition().latitude() == 200) {
} else if (current.getLatitude() == 200) {
//TODO Remove by 31st December 2021.
trackPoints.set(i, new TrackPoint(TrackPoint.Type.SEGMENT_START_MANUAL, time));
//TODO Delete location
@@ -10,6 +10,7 @@ import de.dennisguse.opentracks.data.models.Track;
import de.dennisguse.opentracks.services.TrackRecordingService;
import de.dennisguse.opentracks.settings.PreferencesUtils;
import de.dennisguse.opentracks.util.IntentDashboardUtils;
import de.dennisguse.opentracks.util.TrackUtils;
public class StartRecording extends AbstractAPIActivity {
@@ -41,12 +42,12 @@ public class StartRecording extends AbstractAPIActivity {
ContentProviderUtils contentProviderUtils = new ContentProviderUtils(this);
Track track = contentProviderUtils.getTrack(trackId);
track.setName(bundle.getString(EXTRA_TRACK_NAME, ""));
track.setDescription(bundle.getString(EXTRA_TRACK_DESCRIPTION, ""));
track.setActivityType(ActivityType.findBy(bundle.getString(EXTRA_TRACK_ACTIVITY_TYPE_ID, null)));
track.setActivityTypeLocalized(bundle.getString(EXTRA_TRACK_ACTIVITY_TYPE_LOCALIZED, ""));
contentProviderUtils.updateTrack(track);
TrackUtils.updateTrack(this, track,
bundle.getString(EXTRA_TRACK_NAME, null),
bundle.getString(EXTRA_TRACK_ACTIVITY_TYPE_LOCALIZED, null),
ActivityType.findBy(bundle.getString(EXTRA_TRACK_ACTIVITY_TYPE_ID, null)),
bundle.getString(EXTRA_TRACK_DESCRIPTION, null),
contentProviderUtils);
}
private void startDashboardAPI(@NonNull Track.Id trackId, @NonNull Bundle bundle) {
@@ -72,9 +72,8 @@ public class SettingsActivity extends AbstractActivity implements ChooseActivity
}
}
@NonNull
@Override
protected View createRootView() {
protected View getRootView() {
viewBinding = SettingsBinding.inflate(getLayoutInflater());
return viewBinding.getRoot();
}
@@ -116,9 +116,8 @@ public class SettingsCustomLayoutEditActivity extends AbstractActivity implement
recordingLayoutFieldsVisible = null;
}
@NonNull
@Override
protected View createRootView() {
protected View getRootView() {
viewBinding = ActivitySettingsCustomLayoutBinding.inflate(getLayoutInflater());
return viewBinding.getRoot();
}
@@ -108,9 +108,8 @@ public class SettingsCustomLayoutListActivity extends AbstractActivity implement
adapter.reloadLayouts();
}
@NonNull
@Override
protected View createRootView() {
protected View getRootView() {
PreferencesUtils.getCustomLayout();
viewBinding = ActivitySettingsCustomLayoutListBinding.inflate(getLayoutInflater());
return viewBinding.getRoot();
@@ -35,6 +35,7 @@ import de.dennisguse.opentracks.settings.UnitSystem;
import de.dennisguse.opentracks.ui.util.ActivityUtils;
import de.dennisguse.opentracks.ui.util.ListItemUtils;
import de.dennisguse.opentracks.util.IntentUtils;
import de.dennisguse.opentracks.util.StringUtils;
public class TrackListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> implements ActionMode.Callback {
@@ -163,6 +164,7 @@ public class TrackListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener {
private final TrackListItemBinding viewBinding;
private final View view;
private Track.Id trackId;
@@ -170,9 +172,10 @@ public class TrackListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
super(itemView);
viewBinding = TrackListItemBinding.bind(itemView);
view = itemView;
viewBinding.getRoot().setOnClickListener(this);
viewBinding.getRoot().setOnLongClickListener(this);
view.setOnClickListener(this);
view.setOnLongClickListener(this);
}
@@ -226,12 +229,18 @@ public class TrackListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
viewBinding.trackListItemTime.setText(null);
}
//TODO Check if this is needed or a leftover from the MarkerList migration
String category = activityType == null ? activityTypeLocalized : null;
String categoryDescription = StringUtils.getCategoryDescription(category, description);
viewBinding.trackListItemCategoryDescription.setText(categoryDescription);
viewBinding.trackListItemCategoryDescription.setVisibility("".equals(categoryDescription) ? View.GONE : View.VISIBLE);
setSelected(selection.get((int) getId()));
}
public void setSelected(boolean isSelected) {
selection.put((int) getId(), isSelected);
viewBinding.getRoot().setActivated(isSelected);
view.setActivated(isSelected);
}
public long getId() {
@@ -242,7 +251,7 @@ public class TrackListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
@Override
public void onClick(View v) {
if (selectionMode) {
setSelected(!viewBinding.getRoot().isActivated());
setSelected(!view.isActivated());
actionMode.invalidate();
return;
}
@@ -258,14 +267,14 @@ public class TrackListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
.putExtra(TrackRecordedActivity.EXTRA_TRACK_ID, trackId);
ActivityOptions activityOptions = ActivityOptions.makeSceneTransitionAnimation(
context,
new Pair<>(viewBinding.getRoot().findViewById(R.id.track_list_item_icon), TrackRecordedActivity.VIEW_TRACK_ICON));
new Pair<>(view.findViewById(R.id.track_list_item_icon), TrackRecordedActivity.VIEW_TRACK_ICON));
context.startActivity(newIntent, activityOptions.toBundle());
}
}
@Override
public boolean onLongClick(View v) {
setSelected(!viewBinding.getRoot().isActivated());
setSelected(!view.isActivated());
if (!selectionMode) {
actionMode = context.startSupportActionMode(TrackListAdapter.this);
} else {
@@ -1,19 +0,0 @@
package de.dennisguse.opentracks.ui;
import android.content.Context;
import android.widget.ArrayAdapter;
import androidx.annotation.NonNull;
import java.time.ZoneOffset;
import java.util.stream.IntStream;
public class ZoneOffsetAdapter extends ArrayAdapter<ZoneOffset> {
public ZoneOffsetAdapter(@NonNull Context context, int resource) {
super(context, resource, IntStream.range(-12, +12)
.boxed()
.map(ZoneOffset::ofHours)
.toList());
}
}
@@ -83,9 +83,8 @@ public class AggregatedStatisticsActivity extends AbstractActivity implements Fi
outState.putBoolean(STATE_ARE_FILTERS_APPLIED, areFiltersApplied);
}
@NonNull
@Override
protected View createRootView() {
protected View getRootView() {
viewBinding = AggregatedStatsBinding.inflate(getLayoutInflater());
return viewBinding.getRoot();
}
@@ -24,15 +24,17 @@ import android.view.View;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.viewpager2.adapter.FragmentStateAdapter;
import androidx.viewpager2.widget.ViewPager2;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentStatePagerAdapter;
import androidx.viewpager.widget.ViewPager;
import java.util.ArrayList;
import java.util.List;
import de.dennisguse.opentracks.AbstractActivity;
import de.dennisguse.opentracks.R;
import de.dennisguse.opentracks.data.ContentProviderUtils;
import de.dennisguse.opentracks.data.models.Marker;
import de.dennisguse.opentracks.data.tables.MarkerColumns;
import de.dennisguse.opentracks.databinding.MarkerDetailActivityBinding;
import de.dennisguse.opentracks.ui.markers.DeleteMarkerDialogFragment.DeleteMarkerCaller;
@@ -51,7 +53,7 @@ public class MarkerDetailActivity extends AbstractActivity implements DeleteMark
private MarkerDetailActivityBinding viewBinding;
private Cursor cursor;
private List<Marker.Id> markerIds;
@Override
protected void onCreate(Bundle bundle) {
@@ -67,29 +69,40 @@ public class MarkerDetailActivity extends AbstractActivity implements DeleteMark
ContentProviderUtils contentProviderUtils = new ContentProviderUtils(this);
Marker marker = contentProviderUtils.getMarker(markerId);
//TODO only load used data: ID + name
cursor = contentProviderUtils.getMarkerCursor(marker.getTrackId(), null, -1);
if (cursor == null) {
finish();
}
markerIds = new ArrayList<>();
int markerIndex = -1;
if (cursor != null && cursor.moveToFirst()) {
while (markerIndex == -1 && cursor.moveToNext()) {
Marker.Id currentId = new Marker.Id(cursor.getLong(cursor.getColumnIndexOrThrow(MarkerColumns._ID)));
if (markerId.equals(currentId)) {
markerIndex = cursor.getPosition();
//TODO Load only markerIds, not the whole marker
try (Cursor cursor = contentProviderUtils.getMarkerCursor(marker.getTrackId(), null, -1)) {
if (cursor != null && cursor.moveToFirst()) {
for (int i = 0; i < cursor.getCount(); i++) {
Marker currentMarker = contentProviderUtils.createMarker(cursor);
markerIds.add(currentMarker.getId());
if (markerId.equals(currentMarker.getId())) {
markerIndex = markerIds.size() - 1;
}
cursor.moveToNext();
}
}
}
final MarkerDetailPagerAdapter markerAdapter = new MarkerDetailPagerAdapter(this);
final MarkerDetailPagerAdapter markerAdapter = new MarkerDetailPagerAdapter(getSupportFragmentManager());
viewBinding.makerDetailActivityViewPager.setAdapter(markerAdapter);
viewBinding.makerDetailActivityViewPager.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() {
viewBinding.makerDetailActivityViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageSelected(int position) {
viewBinding.markerDetailToolbar.setTitle(markerAdapter.getPageTitle(position));
// viewBinding.bottomAppBarLayout.bottomAppBarTitle.setText(markerAdapter.getPageTitle(position)); TOOD
}
@Override
public void onPageScrollStateChanged(int state) {
}
});
viewBinding.makerDetailActivityViewPager.setCurrentItem(markerIndex == -1 ? 0 : markerIndex);
@@ -97,49 +110,43 @@ public class MarkerDetailActivity extends AbstractActivity implements DeleteMark
setSupportActionBar(viewBinding.bottomAppBarLayout.bottomAppBar);
}
@NonNull
@Override
protected View createRootView() {
protected View getRootView() {
viewBinding = MarkerDetailActivityBinding.inflate(getLayoutInflater());
return viewBinding.getRoot();
}
@Override
protected void onDestroy() {
super.onDestroy();
viewBinding = null;
if (cursor != null) cursor.close();
cursor = null;
}
@Override
public void onMarkerDeleted() {
runOnUiThread(this::finish);
}
private class MarkerDetailPagerAdapter extends FragmentStateAdapter {
/**
* Marker detail pager adapter.
*
* @author Jimmy Shih
*/
private class MarkerDetailPagerAdapter extends FragmentStatePagerAdapter {
MarkerDetailPagerAdapter(@NonNull FragmentActivity fa) {
super(fa);
MarkerDetailPagerAdapter(FragmentManager fragmentManager) {
super(fragmentManager, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT);
}
@Override
@NonNull
public Fragment createFragment(int position) {
cursor.moveToPosition(position);
return MarkerDetailFragment.newInstance(new Marker.Id(cursor.getLong(cursor.getColumnIndexOrThrow(MarkerColumns._ID))));
}
@Override
public int getItemCount() {
return cursor.getCount();
public Fragment getItem(int position) {
return MarkerDetailFragment.newInstance(markerIds.get(position));
}
@Nullable
@Override
public CharSequence getPageTitle(int position) {
cursor.moveToPosition(position);
return getString(R.string.marker_detail_title, position + 1, getItemCount(), cursor.getString(cursor.getColumnIndexOrThrow(MarkerColumns.NAME)));
return getString(R.string.marker_title, position + 1, getCount());
}
@Override
public int getCount() {
return markerIds.size();
}
}
}
@@ -18,6 +18,7 @@ package de.dennisguse.opentracks.ui.markers;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
@@ -25,18 +26,22 @@ import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.AnimationUtils;
import androidx.annotation.NonNull;
import androidx.core.view.MenuProvider;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.lifecycle.Lifecycle;
import java.time.Duration;
import de.dennisguse.opentracks.R;
import de.dennisguse.opentracks.data.ContentProviderUtils;
import de.dennisguse.opentracks.data.models.Marker;
import de.dennisguse.opentracks.databinding.MarkerDetailFragmentBinding;
import de.dennisguse.opentracks.share.ShareUtils;
import de.dennisguse.opentracks.ui.util.ListItemUtils;
import de.dennisguse.opentracks.util.IntentUtils;
import de.dennisguse.opentracks.util.StringUtils;
@@ -50,15 +55,43 @@ public class MarkerDetailFragment extends Fragment {
private static final String TAG = MarkerDetailFragment.class.getSimpleName();
private static final String KEY_MARKER_ID = "markerId";
private static final Duration HIDE_TEXT_DELAY = Duration.ofSeconds(4);
private MenuItem shareMarkerImageMenuItem;
private ContentProviderUtils contentProviderUtils;
private Handler handler;
private Marker.Id markerId;
private Marker marker;
private MarkerDetailFragmentBinding viewBinding;
private final Runnable hideText = new Runnable() {
@Override
public void run() {
Animation animation = AnimationUtils.loadAnimation(getActivity(), R.anim.fadeout);
animation.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation anim) {
}
@Override
public void onAnimationRepeat(Animation anim) {
}
@Override
public void onAnimationEnd(Animation anim) {
viewBinding.markerDetailMarkerTextGradient.setVisibility(View.GONE);
viewBinding.markerDetailMarkerInfo.setVisibility(View.GONE);
}
});
viewBinding.markerDetailMarkerTextGradient.startAnimation(animation);
viewBinding.markerDetailMarkerInfo.startAnimation(animation);
}
};
public static MarkerDetailFragment newInstance(Marker.Id markerId) {
Bundle bundle = new Bundle();
bundle.putParcelable(KEY_MARKER_ID, markerId);
@@ -78,70 +111,43 @@ public class MarkerDetailFragment extends Fragment {
getParentFragmentManager().popBackStack();
return;
}
contentProviderUtils = new ContentProviderUtils(getContext());
contentProviderUtils = new ContentProviderUtils(getActivity());
handler = new Handler();
setHasOptionsMenu(true);
}
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
viewBinding = MarkerDetailFragmentBinding.inflate(inflater, container, false);
requireActivity().addMenuProvider(new MenuProvider() {
@Override
public void onCreateMenu(@NonNull Menu menu, @NonNull MenuInflater menuInflater) {
menuInflater.inflate(R.menu.marker_detail, menu);
shareMarkerImageMenuItem = menu.findItem(R.id.marker_detail_share);
updateMarker();
updateMenuItems();
viewBinding.markerDetailMarkerPhoto.setOnClickListener(v -> {
handler.removeCallbacks(hideText);
int visibility = viewBinding.markerDetailMarkerInfo.getVisibility() == View.GONE ? View.VISIBLE : View.GONE;
viewBinding.markerDetailMarkerTextGradient.setVisibility(visibility);
viewBinding.markerDetailMarkerInfo.setVisibility(visibility);
if (visibility == View.VISIBLE) {
handler.postDelayed(hideText, HIDE_TEXT_DELAY.toMillis());
}
@Override
public boolean onMenuItemSelected(@NonNull MenuItem item) {
FragmentActivity fragmentActivity = getActivity();
if (item.getItemId() == R.id.marker_detail_show_on_map) {
IntentUtils.showCoordinateOnMap(getContext(), marker);
return true;
}
if (item.getItemId() == R.id.marker_detail_edit) {
Intent intent = IntentUtils.newIntent(fragmentActivity, MarkerEditActivity.class)
.putExtra(MarkerEditActivity.EXTRA_MARKER_ID, markerId);
startActivity(intent);
return true;
}
if (item.getItemId() == R.id.marker_detail_share) {
if (marker.hasPhoto()) {
Intent intent = ShareUtils.newShareFileIntent(getContext(), marker.getId());
intent = Intent.createChooser(intent, null);
startActivity(intent);
}
return true;
}
if (item.getItemId() == R.id.marker_detail_delete) {
DeleteMarkerDialogFragment.showDialog(getChildFragmentManager(), markerId);
return true;
}
return false;
}
}, getViewLifecycleOwner(), Lifecycle.State.RESUMED);
});
return viewBinding.getRoot();
}
@Override
public void onResume() {
super.onResume();
// Need to update the marker in case returning after an edit
updateMarker();
updateMarker(true);
updateUi();
updateMenuItems();
}
@Override
public void onPause() {
super.onPause();
handler.removeCallbacks(hideText);
}
@Override
public void onDestroyView() {
super.onDestroyView();
@@ -160,35 +166,97 @@ public class MarkerDetailFragment extends Fragment {
super.setMenuVisibility(menuVisible);
// View pager caches the neighboring fragments in the resumed state.
// If becoming visible from the resumed state, update the UI to display the text above the image.
if (isResumed() && menuVisible) {
updateUi();
if (isResumed()) {
if (menuVisible) {
updateUi();
} else {
handler.removeCallbacks(hideText);
}
}
}
@Override
public void onCreateOptionsMenu(@NonNull Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.marker_detail, menu);
shareMarkerImageMenuItem = menu.findItem(R.id.marker_detail_share);
updateMarker(false);
updateMenuItems();
}
private void updateMenuItems() {
if (shareMarkerImageMenuItem != null) { // MenuProvider might not yet been initialized.
// shareMarkerImageMenuItem.setEnabled(marker.hasPhoto());
}
if (shareMarkerImageMenuItem != null)
shareMarkerImageMenuItem.setVisible(marker.hasPhoto());
}
private void updateMarker() {
marker = contentProviderUtils.getMarker(markerId);
if (marker == null) {
Log.d(TAG, "marker is null");
getParentFragmentManager().popBackStack();
@Override
public boolean onOptionsItemSelected(MenuItem item) {
FragmentActivity fragmentActivity = getActivity();
if (item.getItemId() == R.id.marker_detail_show_on_map) {
IntentUtils.showCoordinateOnMap(getContext(), marker);
return true;
}
if (item.getItemId() == R.id.marker_detail_edit) {
Intent intent = IntentUtils.newIntent(fragmentActivity, MarkerEditActivity.class)
.putExtra(MarkerEditActivity.EXTRA_MARKER_ID, markerId);
startActivity(intent);
return true;
}
if (item.getItemId() == R.id.marker_detail_share) {
if (marker.hasPhoto()) {
Intent intent = ShareUtils.newShareFileIntent(getContext(), marker.getId());
intent = Intent.createChooser(intent, null);
startActivity(intent);
}
return true;
}
if (item.getItemId() == R.id.marker_detail_delete) {
DeleteMarkerDialogFragment.showDialog(getChildFragmentManager(), markerId);
return true;
}
return super.onOptionsItemSelected(item);
}
private void updateMarker(boolean refresh) {
if (refresh || marker == null) {
marker = contentProviderUtils.getMarker(markerId);
if (marker == null) {
Log.d(TAG, "marker is null");
getParentFragmentManager().popBackStack();
}
}
}
private void updateUi() {
if (marker.hasPhoto()) {
boolean hasPhoto = marker.hasPhoto();
if (hasPhoto) {
handler.removeCallbacks(hideText);
viewBinding.markerDetailMarkerPhoto.setImageURI(marker.getPhotoUrl());
handler.postDelayed(hideText, HIDE_TEXT_DELAY.toMillis());
} else {
viewBinding.markerDetailMarkerPhoto.setImageDrawable(MarkerUtils.getDefaultPhoto(getContext()));
viewBinding.markerDetailMarkerPhoto.setImageResource(MarkerUtils.ICON_ID);
}
viewBinding.markerDetailMarkerCategory.setText(StringUtils.getCategory(marker.getCategory()));
viewBinding.markerDetailMarkerDescription.setText(marker.getDescription());
ListItemUtils.setTextView(getActivity(), viewBinding.markerDetailMarkerName, marker.getName(), hasPhoto);
viewBinding.markerDetailMarkerLocation.setText(StringUtils.formatCoordinate(getContext(), marker.getPosition()));
ListItemUtils.setTextView(getActivity(), viewBinding.markerDetailMarkerCategory, StringUtils.getCategory(marker.getCategory()), hasPhoto);
ListItemUtils.setTextView(getActivity(), viewBinding.markerDetailMarkerDescription, marker.getDescription(), hasPhoto);
setLocation(hasPhoto);
}
private void setLocation(boolean addShadow) {
String value = "[" + getString(R.string.stats_latitude) + " "
+ StringUtils.formatCoordinate(getContext(), marker.getLatitude()) + ", "
+ getString(R.string.stats_longitude) + " "
+ StringUtils.formatCoordinate(getContext(), marker.getLongitude()) + "]";
ListItemUtils.setTextView(getActivity(), viewBinding.markerDetailMarkerLocation, value, addShadow);
}
}
@@ -85,9 +85,8 @@ public class MarkerEditActivity extends AbstractActivity {
// UI elements
private MarkerEditBinding viewBinding;
@NonNull
@Override
protected View createRootView() {
protected View getRootView() {
viewBinding = MarkerEditBinding.inflate(getLayoutInflater());
return viewBinding.getRoot();
}
@@ -145,9 +145,8 @@ public class MarkerListActivity extends AbstractActivity implements DeleteMarker
contentProviderUtils = null;
}
@NonNull
@Override
protected View createRootView() {
protected View getRootView() {
viewBinding = MarkerListBinding.inflate(getLayoutInflater());
viewBinding.markerListSearchView.getEditText().setOnEditorActionListener((v, actionId, event) -> {
@@ -164,6 +164,7 @@ public class MarkerListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener {
private final MarkerListItemBinding viewBinding;
private final View view;
private Marker marker;
@@ -171,20 +172,23 @@ public class MarkerListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
super(view);
viewBinding = MarkerListItemBinding.bind(view);
this.view = view;
viewBinding.getRoot().setOnClickListener(this);
viewBinding.getRoot().setOnLongClickListener(this);
view.setOnClickListener(this);
view.setOnLongClickListener(this);
}
public void bind(Marker marker) {
this.marker = marker;
viewBinding.markerListItemPhoto.setVisibility(marker.hasPhoto() ? View.VISIBLE : View.GONE);
viewBinding.markerListItemTextGradient.setVisibility(marker.hasPhoto() ? View.VISIBLE : View.GONE);
if (marker.hasPhoto()) {
int height = ThemeUtils.getPhotoHeight(context);
ViewGroup.LayoutParams params = viewBinding.markerListItemPhoto.getLayoutParams();
params.height = height;
viewBinding.markerListItemPhoto.setLayoutParams(params);
viewBinding.markerListItemTextGradient.setLayoutParams(params);
asyncLoadPhoto(viewBinding.markerListItemPhoto, marker.getPhotoUrl(), marker.getId());
}
@@ -204,7 +208,7 @@ public class MarkerListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
public void setSelected(boolean isSelected) {
selection.put((int) getId(), isSelected);
viewBinding.getRoot().setActivated(isSelected);
view.setActivated(isSelected);
}
public long getId() {
@@ -26,13 +26,15 @@ public class MarkerUtils {
private static final String TAG = FileUtils.class.getSimpleName();
static final int ICON_ID = R.drawable.ic_marker_orange_pushpin_with_shadow;
private static final String JPEG_EXTENSION = "jpeg";
private MarkerUtils() {
}
public static Drawable getDefaultPhoto(@NonNull Context context) {
return ContextCompat.getDrawable(context, R.drawable.ic_marker_show_24dp);
return ContextCompat.getDrawable(context, ICON_ID);
}
/**
@@ -17,8 +17,11 @@
package de.dennisguse.opentracks.ui.util;
import android.content.Context;
import android.view.View;
import android.widget.TextView;
import androidx.core.content.ContextCompat;
import java.time.Duration;
import java.time.Instant;
import java.time.OffsetDateTime;
@@ -86,6 +89,29 @@ public class ListItemUtils {
return timeDistanceText;
}
/**
* Sets a text view.
*
* @param context the context
* @param textView the text view
* @param value the value for the text view
* @param addShadow true to add shadow
*/
public static void setTextView(Context context, TextView textView, String value, boolean addShadow) {
if (value == null || value.length() == 0) {
textView.setVisibility(View.GONE);
return;
}
textView.setVisibility(View.VISIBLE);
textView.setText(value);
if (addShadow) {
textView.setShadowLayer(5, 0, 2, ContextCompat.getColor(context, android.R.color.black));
} else {
textView.setShadowLayer(0, 0, 0, 0);
}
}
public static void setDateAndTime(Context context, TextView dateView, TextView timeView, Instant time, ZoneOffset timeZone) {
OffsetDateTime offsetDateTime = OffsetDateTime.ofInstant(time, timeZone);
String dateContent = StringUtils.formatDateTodayRelative(context, offsetDateTime);
@@ -50,14 +50,23 @@ public class IntentUtils {
return new Intent(context, cls).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
}
public static void showCoordinateOnMap(Context context, Marker marker) {
showCoordinateOnMap(context, marker.getLatitude(), marker.getLongitude(), marker.getName());
}
/**
* Send intent to show coordinates on a map (needs an another app).
*
* @param context the context
* @param latitude the latitude
* @param longitude the longitude
* @param label the label
*/
public static void showCoordinateOnMap(Context context, Marker marker) {
private static void showCoordinateOnMap(Context context, double latitude, double longitude, String label) {
//SEE https://developer.android.com/guide/components/intents-common.html#Maps
String uri = "geo:0,0?q=" + marker.getPosition().latitude() + "," + marker.getPosition().longitude();
if (marker.getName() != null && !marker.getName().isEmpty()) {
uri += "(" + marker.getName() + ")";
String uri = "geo:0,0?q=" + latitude + "," + longitude;
if (label != null && label.length() > 0) {
uri += "(" + label + ")";
}
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(uri));
@@ -45,7 +45,6 @@ import de.dennisguse.opentracks.data.models.Cadence;
import de.dennisguse.opentracks.data.models.Distance;
import de.dennisguse.opentracks.data.models.DistanceFormatter;
import de.dennisguse.opentracks.data.models.HeartRate;
import de.dennisguse.opentracks.data.models.Position;
import de.dennisguse.opentracks.data.models.Power;
import de.dennisguse.opentracks.settings.UnitSystem;
@@ -143,8 +142,25 @@ public class StringUtils {
return df.format(value);
}
public static String formatCoordinate(Context context, Position position) {
return context.getString(R.string.location_latitude_longitude, Location.convert(position.latitude(), Location.FORMAT_DEGREES), Location.convert(position.longitude(), Location.FORMAT_DEGREES));
/**
* Formats a coordinate
*
* @param context the context's object.
* @param coordinate the coordinate
*/
public static String formatCoordinate(Context context, double coordinate) {
return context.getString(R.string.location_coordinate, Location.convert(coordinate, Location.FORMAT_DEGREES));
}
/**
* Formats a complete coordinate (latitude, longitude)
*
* @param context the context's object.
* @param latitude the coordinate's latitude.
* @param longitude the coordinate's longitude.
*/
public static String formatCoordinate(Context context, double latitude, double longitude) {
return context.getString(R.string.location_latitude_longitude, Location.convert(latitude, Location.FORMAT_DEGREES), Location.convert(longitude, Location.FORMAT_DEGREES));
}
public static Pair<String, String> getHeartRateParts(Context context, HeartRate heartrate) {
@@ -0,0 +1,65 @@
/*
* Copyright 2013 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package de.dennisguse.opentracks.util;
import android.content.Context;
import de.dennisguse.opentracks.data.ContentProviderUtils;
import de.dennisguse.opentracks.data.models.ActivityType;
import de.dennisguse.opentracks.data.models.Track;
/**
* Utilities for updating track.
*
* @author Jimmy Shih
*/
//TOOD Refactor ActivityType handling in here!
@Deprecated //TODO Refactor: all this should happen somewhere else (ContentProviderUtils?)
public class TrackUtils {
private TrackUtils() {
}
public static void updateTrack(Context context, Track track, String name, String activityTypeLocalized, String description, ContentProviderUtils contentProviderUtils) {
updateTrack(context, track, name, activityTypeLocalized, ActivityType.findByLocalizedString(context, activityTypeLocalized), description, contentProviderUtils);
}
public static void updateTrack(Context context, Track track, String name, String activityTypeLocalized, ActivityType activityType, String description, ContentProviderUtils contentProviderUtils) {
boolean update = false;
if (name != null) {
track.setName(name);
update = true;
}
if (activityTypeLocalized != null) {
track.setActivityTypeLocalized(activityTypeLocalized);
update = true;
}
if (activityType != null) {
track.setActivityType(activityType);
} else if (activityTypeLocalized != null) {
track.setActivityType(ActivityType.findByLocalizedString(context, activityTypeLocalized)
);
}
if (description != null) {
track.setDescription(description);
update = true;
}
if (update) {
contentProviderUtils.updateTrack(track);
}
}
}
@@ -265,7 +265,7 @@ public abstract class GenericStatisticsViewHolder extends StatisticViewHolder<St
TrackPoint latestTrackPoint = data.latestTrackPoint();
String value;
if (latestTrackPoint != null && latestTrackPoint.hasLocation()) {
value = StringUtils.formatCoordinate(getContext(), latestTrackPoint.getPosition());
value = StringUtils.formatCoordinate(getContext(), latestTrackPoint.getLatitude(), latestTrackPoint.getLongitude());
} else {
value = getContext().getString(R.string.value_unknown);
}
+14
View File
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background" />
<foreground>
<inset
android:inset="20dp"
android:drawable="@drawable/ic_logo_color_24dp" />
</foreground>
<monochrome>
<inset
android:inset="20dp"
android:drawable="@drawable/ic_logo_24dp" />
</monochrome>
</adaptive-icon>
+2 -5
View File
@@ -1,6 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_logo_color_108dp" />
<monochrome android:drawable="@drawable/ic_logo_color_108dp" />
</adaptive-icon>
<inset xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/ic_logo_color_24dp" />
-16
View File
@@ -1,16 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:tint="?attr/colorControlNormal"
android:viewportWidth="108"
android:viewportHeight="108">
<group
android:scaleX="0.56"
android:scaleY="0.56"
android:translateX="22"
android:translateY="24">
<path
android:fillColor="#FFFFFF"
android:pathData="M82.489,12.834C83.196,10.418 82.043,9.556 79.926,10.917L10.087,55.828c-2.117,1.361 -1.795,2.628 0.714,2.815L39.806,60.807c2.51,0.188 5.291,2.267 6.18,4.621l10.282,27.208c0.89,2.354 2.195,2.304 2.902,-0.111z" />
</group>
</vector>
@@ -1,33 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<group
android:scaleX="0.56"
android:scaleY="0.56"
android:translateX="22"
android:translateY="24">
<path
android:pathData="M85.133,20.59C85.731,18.546 84.756,17.817 82.965,18.968L23.874,56.967c-1.791,1.152 -1.519,2.224 0.604,2.382L49.019,61.18c2.124,0.159 4.477,1.918 5.229,3.91l8.7,23.021c0.753,1.992 1.857,1.949 2.455,-0.094z"
android:strokeWidth="1"
android:strokeColor="#f69123">
<aapt:attr name="android:fillColor">
<gradient
android:endX="84.4913"
android:endY="19.211866"
android:startX="38.773293"
android:startY="80.33152"
android:type="linear">
<item
android:color="#FFFBB22F"
android:offset="0" />
<item
android:color="#FFF58820"
android:offset="1" />
</gradient>
</aapt:attr>
</path>
</group>
</vector>
@@ -0,0 +1,33 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="24dp"
android:height="24dp"
android:viewportWidth="100"
android:viewportHeight="100">
<group
android:name="rotationGroup"
android:pivotX="50"
android:pivotY="50"
android:scaleX="0.6"
android:scaleY="0.6"
>
<path android:pathData="M82.489,12.834C83.196,10.418 82.043,9.556 79.926,10.917L10.087,55.828c-2.117,1.361 -1.795,2.628 0.714,2.815L39.806,60.807c2.51,0.188 5.291,2.267 6.18,4.621l10.282,27.208c0.89,2.354 2.195,2.304 2.902,-0.111z">
<aapt:attr name="android:fillColor">
<gradient
android:endX="70.0"
android:endY="30.0"
android:startX="7.0"
android:startY="83.0"
android:type="linear">
<item
android:color="#FFFBB22F"
android:offset="0" />
<item
android:color="#FFFF6D00"
android:offset="1" />
</gradient>
</aapt:attr>
</path>
</group>
</vector>

Some files were not shown because too many files have changed in this diff Show More