From 9a5056144442235423a156c5fd5c222c9188fb08 Mon Sep 17 00:00:00 2001 From: SNURO Date: Thu, 9 Nov 2023 02:38:08 +0900 Subject: [PATCH 1/2] FileLogger added to check distance on still state, Speedlist deleted due to error on long duration singlemode play, enlarged modal exit button on multimode room create --- .../app/src/main/java/Logging/FileLogger.java | 32 ++++++++++++++++++ .../ui/single_mode/SingleModeFragment.java | 33 +++++++++++-------- .../res/layout/create_room_modal_layout.xml | 1 + 3 files changed, 52 insertions(+), 14 deletions(-) create mode 100644 android/RunUsAndroid/app/src/main/java/Logging/FileLogger.java diff --git a/android/RunUsAndroid/app/src/main/java/Logging/FileLogger.java b/android/RunUsAndroid/app/src/main/java/Logging/FileLogger.java new file mode 100644 index 00000000..da675c67 --- /dev/null +++ b/android/RunUsAndroid/app/src/main/java/Logging/FileLogger.java @@ -0,0 +1,32 @@ +package Logging; + +import android.content.Context; +import android.util.Log; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; + +// save log to file in device +// you can find log file in directory returned by context.getFilesDir() +// you can navigate in folders of device in Android Studio -> View -> Tool Windows -> Device Explorer +// context.getFilesDir() returns path "/data/data/com.example.runusandroid/files/phenotype_storage_info" + +public class FileLogger { + + public static void logToFileAndLogcat(Context context, String tag, String message) { + // Log to Logcat + Log.d(tag, message); + + // Log to a file + try { + File logFile = new File(context.getFilesDir(), "distance_log.txt"); + FileOutputStream outputStream = new FileOutputStream(logFile, true); + String logMessage = message + "\n"; + outputStream.write(logMessage.getBytes()); + outputStream.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } +} diff --git a/android/RunUsAndroid/app/src/main/java/com/example/runusandroid/ui/single_mode/SingleModeFragment.java b/android/RunUsAndroid/app/src/main/java/com/example/runusandroid/ui/single_mode/SingleModeFragment.java index b0825be0..63b3812b 100644 --- a/android/RunUsAndroid/app/src/main/java/com/example/runusandroid/ui/single_mode/SingleModeFragment.java +++ b/android/RunUsAndroid/app/src/main/java/com/example/runusandroid/ui/single_mode/SingleModeFragment.java @@ -67,6 +67,7 @@ import retrofit2.Call; import retrofit2.Callback; import retrofit2.Response; +import Logging.FileLogger; public class SingleModeFragment extends Fragment { @@ -661,20 +662,24 @@ public void onReceive(Context context, Intent intent) { lastLocation.setLongitude(pathPoints.get(pathPoints.size() - 2).longitude); // unit : meter -> kilometer distance += location.distanceTo(lastLocation) / (double) 1000; - if ((int) distance != lastDistanceInt) { - LocalDateTime currentTime = LocalDateTime.now(); - Duration iterationDuration = Duration.between(iterationStartTime, currentTime); - long secondsDuration = iterationDuration.getSeconds(); - float newPace = (float) (1.0 / (secondsDuration / 3600.0)); - if (newPace > maxSpeed) - maxSpeed = newPace; - if (newPace < minSpeed) - minSpeed = newPace; - speedList.add(newPace); - iterationStartTime = currentTime; - - } - Log.d("test:distance", "Distance:" + distance); + Log.d("test:distance:5sec", "Last 5 second Distance :" + location.distanceTo(lastLocation) / (double) 1000); + // log distance into file + FileLogger.logToFileAndLogcat(mainActivity, "test:distance:5sec", ""+location.distanceTo(lastLocation) / (double) 1000); + // Below code seems to cause NullPointerException after 10 minutes or so (on Duration.between) +// if ((int) distance != lastDistanceInt) { +// LocalDateTime currentTime = LocalDateTime.now(); +// Duration iterationDuration = Duration.between(iterationStartTime, currentTime); +// long secondsDuration = iterationDuration.getSeconds(); +// float newPace = (float) (1.0 / (secondsDuration / 3600.0)); +// if (newPace > maxSpeed) +// maxSpeed = newPace; +// if (newPace < minSpeed) +// minSpeed = newPace; +// speedList.add(newPace); +// iterationStartTime = currentTime; +// +// } + Log.d("test:distance:total", "Distance:" + distance); } } currentDistanceText.setText(String.format(Locale.getDefault(), "%.2f " + "km", distance)); diff --git a/android/RunUsAndroid/app/src/main/res/layout/create_room_modal_layout.xml b/android/RunUsAndroid/app/src/main/res/layout/create_room_modal_layout.xml index e53fda91..5a012fa5 100644 --- a/android/RunUsAndroid/app/src/main/res/layout/create_room_modal_layout.xml +++ b/android/RunUsAndroid/app/src/main/res/layout/create_room_modal_layout.xml @@ -17,6 +17,7 @@ android:layout_alignParentEnd="true" android:layout_marginTop="10dp" android:layout_marginEnd="10dp" + android:padding="10dp" android:background="@android:color/transparent" android:src="@drawable/ic_close" /> From 2b1fda582550544bf5b9ff962e5745e1002a9ae5 Mon Sep 17 00:00:00 2001 From: SNURO Date: Thu, 9 Nov 2023 03:17:43 +0900 Subject: [PATCH 2/2] added dummy profile image in setting layout --- .../res/drawable/circle_profile_picture.xml | 6 +++++ .../main/res/layout/fragment_user_setting.xml | 22 +++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 android/RunUsAndroid/app/src/main/res/drawable/circle_profile_picture.xml diff --git a/android/RunUsAndroid/app/src/main/res/drawable/circle_profile_picture.xml b/android/RunUsAndroid/app/src/main/res/drawable/circle_profile_picture.xml new file mode 100644 index 00000000..dbfa80bb --- /dev/null +++ b/android/RunUsAndroid/app/src/main/res/drawable/circle_profile_picture.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/android/RunUsAndroid/app/src/main/res/layout/fragment_user_setting.xml b/android/RunUsAndroid/app/src/main/res/layout/fragment_user_setting.xml index 6f4b62b5..520b0d55 100644 --- a/android/RunUsAndroid/app/src/main/res/layout/fragment_user_setting.xml +++ b/android/RunUsAndroid/app/src/main/res/layout/fragment_user_setting.xml @@ -6,6 +6,28 @@ android:layout_height="match_parent" tools:context=".ui.user_setting.UserSettingFragment"> + + + +