Skip to content

Commit

Permalink
Log settings clean-up. Log to sdcard1 has been removed, as ambiguous!
Browse files Browse the repository at this point in the history
Files should log to internal storage, subfolder "CanZE".
Testing in progress ...
  • Loading branch information
fesch committed Aug 20, 2021
1 parent ccebb0e commit 36eb874
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 16 deletions.
4 changes: 3 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme"
tools:ignore="AllowBackup,GoogleAppIndexingWarning">
tools:ignore="AllowBackup,GoogleAppIndexingWarning"
android:requestLegacyExternalStorage="true"
>
<meta-data
android:name="firebase_crashlytics_collection_enabled"
android:value="false" />
Expand Down
20 changes: 15 additions & 5 deletions app/src/main/java/lu/fisch/canze/activities/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@

import com.google.firebase.crashlytics.FirebaseCrashlytics;

import java.io.File;
import java.util.Locale;

import lu.fisch.canze.BuildConfig;
Expand Down Expand Up @@ -171,7 +172,8 @@ public class MainActivity extends AppCompatActivity implements FieldListener /*,
public static boolean debugLogMode = false;
public static boolean fieldLogMode = false;

public static boolean dataExportMode = false;
// use "debugLogMode" instead
//public static boolean dataExportMode = false;
public static DataLogger dataLogger = null; // rather use singleton in onCreate

public static int car = CAR_NONE;
Expand Down Expand Up @@ -327,7 +329,7 @@ private void loadSettings() {
bluetoothBackgroundMode = settings.getBoolean(SettingsActivity.SETTING_DEVICE_USE_BACKGROUND_MODE, false);
milesMode = settings.getBoolean(SettingsActivity.SETTING_CAR_USE_MILES, false);
altFieldsMode = settings.getBoolean(SettingsActivity.SETTING_DEVICE_USE_ISOTP_FIELDS, false);
dataExportMode = settings.getBoolean(SettingsActivity.SETTING_LOGGING_USE_SD_CARD, false);
//dataExportMode = settings.getBoolean(SettingsActivity.SETTING_LOGGING_USE_SD_CARD, false);
debugLogMode = settings.getBoolean(SettingsActivity.SETTING_LOGGING_DEBUG_LOG, false);
fieldLogMode = settings.getBoolean(SettingsActivity.SETTING_LOGGING_FIELDS_LOG, false);
toastLevel = settings.getInt(SettingsActivity.SETTING_DISPLAY_TOAST_LEVEL, MainActivity.TOAST_ELM);
Expand Down Expand Up @@ -378,8 +380,8 @@ private void loadSettings() {
// registerApplicationFields(); // now done in Fields.load
}

// after loading PREFERENCES we may have new values for "dataExportMode"
dataExportMode = dataLogger.activate(dataExportMode);
// after loading PREFERENCES we may have new values for "debugLogMode"
debugLogMode = dataLogger.activate(debugLogMode);
} catch (Exception e) {
if (BuildConfig.BRANCH.equals("master")) {
logExceptionToCrashlytics(e);
Expand Down Expand Up @@ -1245,7 +1247,15 @@ public String getExternalFolder() {
// Two isues
// - through USB the folder is unfortunately read-only. This makes it almost impossible to use the _Research facility
// - it selects Internal storage instead of SD card. Why is somewhat unclear, but more or less OK for now
return getExternalFilesDir(null).getAbsolutePath() + "/";
//Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
//startActivityForResult(intent, 713);

File path = Environment.getExternalStoragePublicDirectory("CanZE");
//debug("Datalogger: "+Environment.DIRECTORY_DCIM);
path.mkdirs();
return path.getAbsolutePath();

//return getExternalFilesDir(null).getAbsolutePath() + "/";
}

public static void logExceptionToCrashlytics (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ public void onClick(DialogInterface dialog, int id) {
return true;
}
});

/*
findPreference(SETTING_LOGGING_USE_SD_CARD).setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(final Preference preference) {
Expand Down Expand Up @@ -574,7 +574,7 @@ public void onClick(DialogInterface dialog, int id) {
return true;
}
});
});*/

// On debug log check
findPreference(SETTING_LOGGING_DEBUG_LOG).setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
Expand Down
10 changes: 5 additions & 5 deletions app/src/main/res/layout/activity_settings_custom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
android:textStyle="bold" />

<ListView
android:layout_width="match_parent"
android:id="@+id/lstAll"
android:choiceMode="singleChoice"
android:listSelector="?attr/colorButtonNormal"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"/>
android:layout_weight="0.5"
android:choiceMode="singleChoice"
android:listSelector="?attr/colorButtonNormal" />

<TableLayout
android:layout_width="match_parent"
Expand Down Expand Up @@ -83,7 +83,7 @@
android:id="@+id/lstSelected"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_weight="0.5"
android:choiceMode="singleChoice"
android:listSelector="?attr/colorButtonNormal" />
</LinearLayout>
6 changes: 3 additions & 3 deletions app/src/main/res/xml/fragment_settings_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,17 @@
<SwitchPreference
app:iconSpaceReserved="false"
app:key="loggingDebugLog"
app:summary="@string/label_SdCardLogging"
app:summary="Logs go to the internal shared storage, folder CanZE"
app:title="@string/label_Debug" />
<SwitchPreference
app:iconSpaceReserved="false"
app:key="loggingFieldLog"
app:summary="@string/help_Fields"
app:title="@string/label_Fields" />
<SwitchPreference
<!--<SwitchPreference
app:iconSpaceReserved="false"
app:key="loggingUseSdCard"
app:title="@string/label_LogToSdcard1" />
app:title="@string/label_LogToSdcard1" />-->
</PreferenceCategory>

<PreferenceCategory
Expand Down
Empty file modified gradlew
100755 → 100644
Empty file.

0 comments on commit 36eb874

Please sign in to comment.