From d5b1536b19a72706056506530c02b661e97b19bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20L=C3=A4nge?= Date: Thu, 18 Jan 2024 14:46:24 +0100 Subject: [PATCH] Reformat code automatic code reformat using Android Studio --- app/src/main/AndroidManifest.xml | 32 ++-- .../activities/BaseActivity.java | 20 +-- .../activities/DiaryEntryActivity.java | 3 +- .../activities/ExportPDFActivity.java | 8 +- .../activities/UserDetailsActivity.java | 1 - .../backup/BackupCreator.kt | 3 +- .../database/PainDiaryDatabaseService.kt | 9 +- .../database/dao/DiaryEntryDao.kt | 5 +- .../database/dao/DrugDao.kt | 2 +- .../database/dao/PainDescriptionDao.kt | 3 +- .../database/dao/UserDao.kt | 3 +- .../database/entities/enums/PainQuality.java | 2 - .../database/entities/enums/Time.java | 1 - .../database/entities/impl/DiaryEntry.java | 10 +- .../database/entities/impl/User.java | 2 +- .../database/model/DiaryEntry.kt | 6 +- .../database/model/Drug.kt | 2 +- .../database/model/PainDescription.kt | 1 - .../database/model/User.kt | 2 +- .../database/utils/Converters.kt | 3 +- .../database/utils/Utils.java | 18 +- .../helpers/AutocompleteAdapter.java | 12 +- .../helpers/EventDecorator.java | 2 +- .../helpers/ExpandableListAdapter.java | 164 +++++++++--------- .../helpers/HelpDataDump.java | 2 +- .../helpers/Helper.java | 40 ++--- .../helpers/NotificationHelper.java | 4 +- .../helpers/NotificationJobService.kt | 8 +- .../helpers/PdfCreator.java | 53 +++--- .../helpers/TimePreference.java | 4 +- .../tutorial/PrefManager.java | 2 +- .../tutorial/TutorialActivity.java | 11 +- .../viewmodel/DatabaseViewModel.kt | 2 +- 33 files changed, 215 insertions(+), 225 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 33545a4..94f07ae 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -8,15 +8,15 @@ android:normalScreens="true" android:resizeable="true" android:smallScreens="true" - android:xlargeScreens="true"/> + android:xlargeScreens="true" /> + android:exported="true" + android:theme="@style/SplashTheme"> - - + - + android:theme="@style/AppTheme.NoActionBar"> - + @@ -117,10 +115,11 @@ - - + @@ -135,8 +134,9 @@ - - + + + \ No newline at end of file diff --git a/app/src/main/java/org/secuso/privacyfriendlypaindiary/activities/BaseActivity.java b/app/src/main/java/org/secuso/privacyfriendlypaindiary/activities/BaseActivity.java index e52f6e7..157e851 100644 --- a/app/src/main/java/org/secuso/privacyfriendlypaindiary/activities/BaseActivity.java +++ b/app/src/main/java/org/secuso/privacyfriendlypaindiary/activities/BaseActivity.java @@ -23,6 +23,8 @@ License, or (at your option) any later version. import android.os.Handler; import android.preference.PreferenceActivity; import android.preference.PreferenceManager; +import android.view.MenuItem; +import android.view.View; import androidx.appcompat.app.ActionBarDrawerToggle; import androidx.appcompat.app.AppCompatActivity; @@ -31,10 +33,6 @@ License, or (at your option) any later version. import androidx.core.view.GravityCompat; import androidx.drawerlayout.widget.DrawerLayout; -import android.view.MenuItem; -import android.view.View; - - import com.google.android.material.navigation.NavigationView; import org.secuso.privacyfriendlypaindiary.R; @@ -94,7 +92,7 @@ public boolean onNavigationItemSelected(MenuItem item) { protected boolean goToNavigationItem(final int itemId) { - if(itemId == getNavigationDrawerID()) { + if (itemId == getNavigationDrawerID()) { // just close drawer because we are already in this activity mDrawerLayout.closeDrawer(GravityCompat.START); return true; @@ -122,7 +120,7 @@ public void run() { // set active navigation item private void selectNavigationItem(int itemId) { - for(int i = 0 ; i < mNavigationView.getMenu().size(); i++) { + for (int i = 0; i < mNavigationView.getMenu().size(); i++) { boolean b = itemId == mNavigationView.getMenu().getItem(i).getItemId(); mNavigationView.getMenu().getItem(i).setChecked(b); } @@ -131,6 +129,7 @@ private void selectNavigationItem(int itemId) { /** * Enables back navigation for activities that are launched from the NavBar. See * {@code AndroidManifest.xml} to find out the parent activity names for each activity. + * * @param intent */ private void createBackStack(Intent intent) { @@ -147,13 +146,14 @@ private void createBackStack(Intent intent) { /** * This method manages the behaviour of the navigation drawer * Add your menu items (ids) to res/menu/activity_main_drawer.xml + * * @param itemId Item that has been clicked by the user */ private void callDrawerItem(final int itemId) { Intent intent; - switch(itemId) { + switch (itemId) { case R.id.nav_main: intent = new Intent(this, MainActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); @@ -183,8 +183,8 @@ private void callDrawerItem(final int itemId) { break; case R.id.nav_settings: intent = new Intent(this, SettingsActivity.class); - intent.putExtra( PreferenceActivity.EXTRA_SHOW_FRAGMENT, SettingsActivity.GeneralPreferenceFragment.class.getName() ); - intent.putExtra( PreferenceActivity.EXTRA_NO_HEADERS, true ); + intent.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT, SettingsActivity.GeneralPreferenceFragment.class.getName()); + intent.putExtra(PreferenceActivity.EXTRA_NO_HEADERS, true); createBackStack(intent); break; default: @@ -196,7 +196,7 @@ protected void onPostCreate(Bundle savedInstanceState) { super.onPostCreate(savedInstanceState); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); - if(getSupportActionBar() == null) { + if (getSupportActionBar() == null) { setSupportActionBar(toolbar); } diff --git a/app/src/main/java/org/secuso/privacyfriendlypaindiary/activities/DiaryEntryActivity.java b/app/src/main/java/org/secuso/privacyfriendlypaindiary/activities/DiaryEntryActivity.java index a6b3a76..35bc446 100644 --- a/app/src/main/java/org/secuso/privacyfriendlypaindiary/activities/DiaryEntryActivity.java +++ b/app/src/main/java/org/secuso/privacyfriendlypaindiary/activities/DiaryEntryActivity.java @@ -60,7 +60,6 @@ License, or (at your option) any later version. import com.bumptech.glide.request.transition.Transition; import org.secuso.privacyfriendlypaindiary.R; -import org.secuso.privacyfriendlypaindiary.database.DBServiceInterface; import org.secuso.privacyfriendlypaindiary.database.entities.enums.BodyRegion; import org.secuso.privacyfriendlypaindiary.database.entities.enums.Condition; import org.secuso.privacyfriendlypaindiary.database.entities.enums.PainQuality; @@ -149,7 +148,7 @@ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_diaryentry); - if(savedInstanceState != null) { + if (savedInstanceState != null) { currentPage = savedInstanceState.getInt("current"); } diff --git a/app/src/main/java/org/secuso/privacyfriendlypaindiary/activities/ExportPDFActivity.java b/app/src/main/java/org/secuso/privacyfriendlypaindiary/activities/ExportPDFActivity.java index e4f613f..ece3d60 100644 --- a/app/src/main/java/org/secuso/privacyfriendlypaindiary/activities/ExportPDFActivity.java +++ b/app/src/main/java/org/secuso/privacyfriendlypaindiary/activities/ExportPDFActivity.java @@ -18,7 +18,6 @@ License, or (at your option) any later version. import android.Manifest; import android.app.DatePickerDialog; -import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; import android.graphics.pdf.PdfDocument; @@ -26,6 +25,9 @@ License, or (at your option) any later version. import android.os.Build; import android.os.Bundle; import android.os.Environment; +import android.view.View; +import android.widget.DatePicker; +import android.widget.Toast; import androidx.appcompat.app.AppCompatActivity; import androidx.core.app.ActivityCompat; @@ -36,10 +38,6 @@ License, or (at your option) any later version. import androidx.lifecycle.Observer; import androidx.lifecycle.ViewModelProvider; -import android.view.View; -import android.widget.DatePicker; -import android.widget.Toast; - import com.google.android.material.textfield.TextInputLayout; import org.secuso.privacyfriendlypaindiary.R; diff --git a/app/src/main/java/org/secuso/privacyfriendlypaindiary/activities/UserDetailsActivity.java b/app/src/main/java/org/secuso/privacyfriendlypaindiary/activities/UserDetailsActivity.java index 99ce084..bc7a531 100644 --- a/app/src/main/java/org/secuso/privacyfriendlypaindiary/activities/UserDetailsActivity.java +++ b/app/src/main/java/org/secuso/privacyfriendlypaindiary/activities/UserDetailsActivity.java @@ -38,7 +38,6 @@ License, or (at your option) any later version. import com.google.android.material.textfield.TextInputLayout; import org.secuso.privacyfriendlypaindiary.R; -import org.secuso.privacyfriendlypaindiary.database.DBServiceInterface; import org.secuso.privacyfriendlypaindiary.database.entities.enums.Gender; import org.secuso.privacyfriendlypaindiary.database.entities.impl.AbstractPersistentObject; import org.secuso.privacyfriendlypaindiary.database.entities.impl.User; diff --git a/app/src/main/java/org/secuso/privacyfriendlypaindiary/backup/BackupCreator.kt b/app/src/main/java/org/secuso/privacyfriendlypaindiary/backup/BackupCreator.kt index 0c11b77..f3af9f3 100644 --- a/app/src/main/java/org/secuso/privacyfriendlypaindiary/backup/BackupCreator.kt +++ b/app/src/main/java/org/secuso/privacyfriendlypaindiary/backup/BackupCreator.kt @@ -2,7 +2,6 @@ package org.secuso.privacyfriendlypaindiary.backup import android.content.Context import android.content.SharedPreferences -import android.database.sqlite.SQLiteDatabase import android.preference.PreferenceManager import android.util.JsonWriter import android.util.Log @@ -36,7 +35,7 @@ class BackupCreator : IBackupCreator { PreferenceManager.getDefaultSharedPreferences(context.applicationContext) writePreferences(writer, pref) writer.name("preferences2") - val prefTutorialActivity : SharedPreferences = + val prefTutorialActivity: SharedPreferences = context.getSharedPreferences(PrefManager.PREF_NAME, PrefManager.PRIVATE_MODE) writePreferences(writer, prefTutorialActivity) Log.d("PFA BackupCreator", "Writing files") diff --git a/app/src/main/java/org/secuso/privacyfriendlypaindiary/database/PainDiaryDatabaseService.kt b/app/src/main/java/org/secuso/privacyfriendlypaindiary/database/PainDiaryDatabaseService.kt index feba305..0af6d4d 100644 --- a/app/src/main/java/org/secuso/privacyfriendlypaindiary/database/PainDiaryDatabaseService.kt +++ b/app/src/main/java/org/secuso/privacyfriendlypaindiary/database/PainDiaryDatabaseService.kt @@ -6,8 +6,13 @@ import org.secuso.privacyfriendlypaindiary.database.entities.interfaces.DiaryEnt import org.secuso.privacyfriendlypaindiary.database.entities.interfaces.DrugIntakeInterface import org.secuso.privacyfriendlypaindiary.database.entities.interfaces.DrugInterface import org.secuso.privacyfriendlypaindiary.database.entities.interfaces.UserInterface -import org.secuso.privacyfriendlypaindiary.database.model.* -import java.util.* +import org.secuso.privacyfriendlypaindiary.database.model.DiaryEntry +import org.secuso.privacyfriendlypaindiary.database.model.Drug +import org.secuso.privacyfriendlypaindiary.database.model.DrugIntake +import org.secuso.privacyfriendlypaindiary.database.model.PainDescription +import org.secuso.privacyfriendlypaindiary.database.model.User +import java.util.Calendar +import java.util.Date class PainDiaryDatabaseService private constructor(context: Context) : DBServiceInterface { private var database: PainDiaryDatabase diff --git a/app/src/main/java/org/secuso/privacyfriendlypaindiary/database/dao/DiaryEntryDao.kt b/app/src/main/java/org/secuso/privacyfriendlypaindiary/database/dao/DiaryEntryDao.kt index 1a01e1a..097e6d8 100644 --- a/app/src/main/java/org/secuso/privacyfriendlypaindiary/database/dao/DiaryEntryDao.kt +++ b/app/src/main/java/org/secuso/privacyfriendlypaindiary/database/dao/DiaryEntryDao.kt @@ -2,13 +2,12 @@ package org.secuso.privacyfriendlypaindiary.database.dao import androidx.room.* import org.secuso.privacyfriendlypaindiary.database.model.DiaryEntry -import org.secuso.privacyfriendlypaindiary.database.model.Drug import java.util.* @Dao interface DiaryEntryDao { @Insert - fun insert(diaryEntry: DiaryEntry) : Long + fun insert(diaryEntry: DiaryEntry): Long @Update fun update(diaryEntry: DiaryEntry) @@ -29,7 +28,7 @@ interface DiaryEntryDao { fun deleteDiaryEntryByID(id: Long) @Query("SELECT MAX(_id) FROM diaryentries") - fun getIDOfLatestDiaryEntry() : Long + fun getIDOfLatestDiaryEntry(): Long @Query("SELECT date FROM diaryentries WHERE date >= :startDate AND date <= :endDate ORDER BY DATE(date) asc") fun getDatesByDateRange(startDate: Date, endDate: Date): Array diff --git a/app/src/main/java/org/secuso/privacyfriendlypaindiary/database/dao/DrugDao.kt b/app/src/main/java/org/secuso/privacyfriendlypaindiary/database/dao/DrugDao.kt index 39f2850..bcdeeff 100644 --- a/app/src/main/java/org/secuso/privacyfriendlypaindiary/database/dao/DrugDao.kt +++ b/app/src/main/java/org/secuso/privacyfriendlypaindiary/database/dao/DrugDao.kt @@ -6,7 +6,7 @@ import org.secuso.privacyfriendlypaindiary.database.model.Drug @Dao interface DrugDao { @Insert - fun insert(drug: Drug) : Long + fun insert(drug: Drug): Long @Update fun update(drug: Drug) diff --git a/app/src/main/java/org/secuso/privacyfriendlypaindiary/database/dao/PainDescriptionDao.kt b/app/src/main/java/org/secuso/privacyfriendlypaindiary/database/dao/PainDescriptionDao.kt index 3b06fea..ad7ba7d 100644 --- a/app/src/main/java/org/secuso/privacyfriendlypaindiary/database/dao/PainDescriptionDao.kt +++ b/app/src/main/java/org/secuso/privacyfriendlypaindiary/database/dao/PainDescriptionDao.kt @@ -1,13 +1,12 @@ package org.secuso.privacyfriendlypaindiary.database.dao import androidx.room.* -import org.secuso.privacyfriendlypaindiary.database.model.DiaryEntry import org.secuso.privacyfriendlypaindiary.database.model.PainDescription @Dao interface PainDescriptionDao { @Insert - fun insert(painDescription: PainDescription) : Long + fun insert(painDescription: PainDescription): Long @Update fun update(painDescription: PainDescription) diff --git a/app/src/main/java/org/secuso/privacyfriendlypaindiary/database/dao/UserDao.kt b/app/src/main/java/org/secuso/privacyfriendlypaindiary/database/dao/UserDao.kt index 993ea7b..0c29307 100644 --- a/app/src/main/java/org/secuso/privacyfriendlypaindiary/database/dao/UserDao.kt +++ b/app/src/main/java/org/secuso/privacyfriendlypaindiary/database/dao/UserDao.kt @@ -1,13 +1,12 @@ package org.secuso.privacyfriendlypaindiary.database.dao -import androidx.lifecycle.LiveData import androidx.room.* import org.secuso.privacyfriendlypaindiary.database.model.User @Dao interface UserDao { @Insert - fun insert(user: User) : Long + fun insert(user: User): Long @Update fun update(user: User) diff --git a/app/src/main/java/org/secuso/privacyfriendlypaindiary/database/entities/enums/PainQuality.java b/app/src/main/java/org/secuso/privacyfriendlypaindiary/database/entities/enums/PainQuality.java index 97ebf80..521ddde 100644 --- a/app/src/main/java/org/secuso/privacyfriendlypaindiary/database/entities/enums/PainQuality.java +++ b/app/src/main/java/org/secuso/privacyfriendlypaindiary/database/entities/enums/PainQuality.java @@ -18,9 +18,7 @@ License, or (at your option) any later version. import org.secuso.privacyfriendlypaindiary.R; -import java.util.EnumSet; import java.util.HashMap; -import java.util.Locale; import java.util.Map; /** diff --git a/app/src/main/java/org/secuso/privacyfriendlypaindiary/database/entities/enums/Time.java b/app/src/main/java/org/secuso/privacyfriendlypaindiary/database/entities/enums/Time.java index 727bb67..72d910a 100644 --- a/app/src/main/java/org/secuso/privacyfriendlypaindiary/database/entities/enums/Time.java +++ b/app/src/main/java/org/secuso/privacyfriendlypaindiary/database/entities/enums/Time.java @@ -18,7 +18,6 @@ License, or (at your option) any later version. import org.secuso.privacyfriendlypaindiary.R; -import java.util.EnumSet; import java.util.HashMap; import java.util.Map; diff --git a/app/src/main/java/org/secuso/privacyfriendlypaindiary/database/entities/impl/DiaryEntry.java b/app/src/main/java/org/secuso/privacyfriendlypaindiary/database/entities/impl/DiaryEntry.java index ceba9b1..bce4e54 100644 --- a/app/src/main/java/org/secuso/privacyfriendlypaindiary/database/entities/impl/DiaryEntry.java +++ b/app/src/main/java/org/secuso/privacyfriendlypaindiary/database/entities/impl/DiaryEntry.java @@ -16,8 +16,8 @@ License, or (at your option) any later version. */ package org.secuso.privacyfriendlypaindiary.database.entities.impl; -import org.secuso.privacyfriendlypaindiary.database.entities.interfaces.DiaryEntryInterface; import org.secuso.privacyfriendlypaindiary.database.entities.enums.Condition; +import org.secuso.privacyfriendlypaindiary.database.entities.interfaces.DiaryEntryInterface; import org.secuso.privacyfriendlypaindiary.database.entities.interfaces.DrugIntakeInterface; import org.secuso.privacyfriendlypaindiary.database.entities.interfaces.PainDescriptionInterface; @@ -72,8 +72,8 @@ public DiaryEntry(Date date, Condition condition, PainDescriptionInterface painD this.condition = condition; this.painDescription = painDescription; this.notes = notes; - if(intakes != null) { - for(DrugIntakeInterface intake : intakes) { + if (intakes != null) { + for (DrugIntakeInterface intake : intakes) { addDrugIntake(intake); } } @@ -138,8 +138,8 @@ public void removeDrugIntake(DrugIntakeInterface intake) { @Override public DrugIntakeInterface getDrugIntakeByID(long id) { - for(DrugIntakeInterface intake : intakes) { - if(intake.getObjectID() == id) { + for (DrugIntakeInterface intake : intakes) { + if (intake.getObjectID() == id) { return intake; } } diff --git a/app/src/main/java/org/secuso/privacyfriendlypaindiary/database/entities/impl/User.java b/app/src/main/java/org/secuso/privacyfriendlypaindiary/database/entities/impl/User.java index ff0ae1e..7562b0a 100644 --- a/app/src/main/java/org/secuso/privacyfriendlypaindiary/database/entities/impl/User.java +++ b/app/src/main/java/org/secuso/privacyfriendlypaindiary/database/entities/impl/User.java @@ -16,8 +16,8 @@ License, or (at your option) any later version. */ package org.secuso.privacyfriendlypaindiary.database.entities.impl; -import org.secuso.privacyfriendlypaindiary.database.entities.interfaces.UserInterface; import org.secuso.privacyfriendlypaindiary.database.entities.enums.Gender; +import org.secuso.privacyfriendlypaindiary.database.entities.interfaces.UserInterface; import java.util.Date; diff --git a/app/src/main/java/org/secuso/privacyfriendlypaindiary/database/model/DiaryEntry.kt b/app/src/main/java/org/secuso/privacyfriendlypaindiary/database/model/DiaryEntry.kt index 579a4bc..314c6d5 100644 --- a/app/src/main/java/org/secuso/privacyfriendlypaindiary/database/model/DiaryEntry.kt +++ b/app/src/main/java/org/secuso/privacyfriendlypaindiary/database/model/DiaryEntry.kt @@ -4,7 +4,7 @@ import androidx.room.Entity import androidx.room.Ignore import androidx.room.PrimaryKey import org.secuso.privacyfriendlypaindiary.database.entities.interfaces.DiaryEntryInterface -import java.util.* +import java.util.Date @Entity(tableName = "diaryentries") data class DiaryEntry( @@ -29,9 +29,9 @@ data class DiaryEntry( _id = 0 ) - companion object{ + companion object { @JvmStatic - fun fromDiaryEntryInterface(diaryEntryInterface: DiaryEntryInterface) :DiaryEntry { + fun fromDiaryEntryInterface(diaryEntryInterface: DiaryEntryInterface): DiaryEntry { return DiaryEntry( diaryEntryInterface.objectID, diaryEntryInterface.date, diff --git a/app/src/main/java/org/secuso/privacyfriendlypaindiary/database/model/Drug.kt b/app/src/main/java/org/secuso/privacyfriendlypaindiary/database/model/Drug.kt index 0753dfb..55bd0e4 100644 --- a/app/src/main/java/org/secuso/privacyfriendlypaindiary/database/model/Drug.kt +++ b/app/src/main/java/org/secuso/privacyfriendlypaindiary/database/model/Drug.kt @@ -26,7 +26,7 @@ data class Drug( } } - fun toDrugInterface() : DrugInterface { + fun toDrugInterface(): DrugInterface { val drugInterface = org.secuso.privacyfriendlypaindiary.database.entities.impl.Drug( name, dose diff --git a/app/src/main/java/org/secuso/privacyfriendlypaindiary/database/model/PainDescription.kt b/app/src/main/java/org/secuso/privacyfriendlypaindiary/database/model/PainDescription.kt index 36e99e6..2c5fba7 100644 --- a/app/src/main/java/org/secuso/privacyfriendlypaindiary/database/model/PainDescription.kt +++ b/app/src/main/java/org/secuso/privacyfriendlypaindiary/database/model/PainDescription.kt @@ -3,7 +3,6 @@ package org.secuso.privacyfriendlypaindiary.database.model import androidx.room.Entity import androidx.room.Ignore import androidx.room.PrimaryKey -import org.secuso.privacyfriendlypaindiary.database.entities.enums.BodyRegion import org.secuso.privacyfriendlypaindiary.database.entities.interfaces.PainDescriptionInterface import org.secuso.privacyfriendlypaindiary.database.utils.Utils diff --git a/app/src/main/java/org/secuso/privacyfriendlypaindiary/database/model/User.kt b/app/src/main/java/org/secuso/privacyfriendlypaindiary/database/model/User.kt index f5fc67b..ce526a1 100644 --- a/app/src/main/java/org/secuso/privacyfriendlypaindiary/database/model/User.kt +++ b/app/src/main/java/org/secuso/privacyfriendlypaindiary/database/model/User.kt @@ -5,7 +5,7 @@ import androidx.room.Ignore import androidx.room.PrimaryKey import org.secuso.privacyfriendlypaindiary.database.entities.enums.Gender import org.secuso.privacyfriendlypaindiary.database.entities.interfaces.UserInterface -import java.util.* +import java.util.Date @Entity(tableName = "users") data class User( diff --git a/app/src/main/java/org/secuso/privacyfriendlypaindiary/database/utils/Converters.kt b/app/src/main/java/org/secuso/privacyfriendlypaindiary/database/utils/Converters.kt index 6cca418..65baacf 100644 --- a/app/src/main/java/org/secuso/privacyfriendlypaindiary/database/utils/Converters.kt +++ b/app/src/main/java/org/secuso/privacyfriendlypaindiary/database/utils/Converters.kt @@ -4,7 +4,8 @@ import android.util.Log import androidx.room.TypeConverter import java.text.ParseException import java.text.SimpleDateFormat -import java.util.* +import java.util.Date +import java.util.Locale object Converters { private const val DB_DATE_PATTERN = "yyyy-MM-dd" diff --git a/app/src/main/java/org/secuso/privacyfriendlypaindiary/database/utils/Utils.java b/app/src/main/java/org/secuso/privacyfriendlypaindiary/database/utils/Utils.java index 61d45f7..827e2cd 100644 --- a/app/src/main/java/org/secuso/privacyfriendlypaindiary/database/utils/Utils.java +++ b/app/src/main/java/org/secuso/privacyfriendlypaindiary/database/utils/Utils.java @@ -13,10 +13,10 @@ public class Utils { public static String convertBodyRegionEnumSetToString(EnumSet bodyRegions) { String bodyRegionsAsString = ""; - for(BodyRegion region : bodyRegions) { + for (BodyRegion region : bodyRegions) { bodyRegionsAsString += region.getValue() + ","; } - if(!bodyRegionsAsString.isEmpty()) { + if (!bodyRegionsAsString.isEmpty()) { bodyRegionsAsString = bodyRegionsAsString.substring(0, bodyRegionsAsString.length() - 1); } else { bodyRegionsAsString = null; @@ -26,7 +26,7 @@ public static String convertBodyRegionEnumSetToString(EnumSet bodyRe public static EnumSet convertStringToBodyRegionEnumSet(String bodyRegionsAsString) { EnumSet bodyRegions = EnumSet.noneOf(BodyRegion.class); - if(bodyRegionsAsString != null && !bodyRegionsAsString.isEmpty()) { + if (bodyRegionsAsString != null && !bodyRegionsAsString.isEmpty()) { String[] regions = bodyRegionsAsString.split(","); for (String bodyRegion : regions) { try { @@ -42,10 +42,10 @@ public static EnumSet convertStringToBodyRegionEnumSet(String bodyRe public static String convertPainQualityEnumSetToString(EnumSet painQualities) { String painQualitiesAsString = ""; - for(PainQuality quality : painQualities) { + for (PainQuality quality : painQualities) { painQualitiesAsString += quality.toString() + ","; } - if(!painQualitiesAsString.isEmpty()) { + if (!painQualitiesAsString.isEmpty()) { painQualitiesAsString = painQualitiesAsString.substring(0, painQualitiesAsString.length() - 1); } else { painQualitiesAsString = null; @@ -55,7 +55,7 @@ public static String convertPainQualityEnumSetToString(EnumSet pain public static EnumSet convertStringToPainQualityEnumSet(String painQualitiesAsString) { EnumSet painQualities = EnumSet.noneOf(PainQuality.class); - if(painQualitiesAsString != null && !painQualitiesAsString.isEmpty()) { + if (painQualitiesAsString != null && !painQualitiesAsString.isEmpty()) { String[] qualities = painQualitiesAsString.split(","); for (String quality : qualities) { PainQuality q = PainQuality.fromString(quality); @@ -67,10 +67,10 @@ public static EnumSet convertStringToPainQualityEnumSet(String pain public static String convertTimeEnumSetToString(EnumSet