Skip to content

Commit

Permalink
Moved CSV import from settings to import/export settings.
Browse files Browse the repository at this point in the history
  • Loading branch information
mateusz-bak committed May 29, 2022
1 parent 4e9bc35 commit 04652d7
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package software.mdev.bookstracker.ui.bookslist.fragments
import android.content.SharedPreferences
import android.content.SharedPreferences.OnSharedPreferenceChangeListener
import android.os.Bundle
import android.widget.Toast
import androidx.appcompat.app.AlertDialog
import androidx.core.content.ContextCompat
import androidx.preference.Preference
Expand All @@ -26,6 +25,7 @@ class SettingsBackupFragment : PreferenceFragmentCompat(), OnSharedPreferenceCha
var preferenceExport = findPreference<Preference>(Constants.KEY_EXPORT)
var preferenceExportLocal = findPreference<Preference>(Constants.KEY_EXPORT_LOCAL)
var preferenceImport = findPreference<Preference>(Constants.KEY_IMPORT)
val preferenceCsvImport = findPreference<Preference>(Constants.KEY_CSV_IMPORT)

if (preferenceExport != null) {
preferenceExport.onPreferenceClickListener = Preference.OnPreferenceClickListener {
Expand All @@ -47,6 +47,13 @@ class SettingsBackupFragment : PreferenceFragmentCompat(), OnSharedPreferenceCha
true
}
}

if (preferenceCsvImport != null) {
preferenceCsvImport.onPreferenceClickListener = Preference.OnPreferenceClickListener {
Backup().runImporterCSV(activity as ListActivity)
true
}
}
}

override fun onResume() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import software.mdev.bookstracker.ui.bookslist.viewmodel.BooksViewModel
import android.content.Intent
import android.net.Uri
import android.os.Build
import software.mdev.bookstracker.other.Backup


class SettingsFragment : PreferenceFragmentCompat(), OnSharedPreferenceChangeListener {
Expand All @@ -35,7 +34,6 @@ class SettingsFragment : PreferenceFragmentCompat(), OnSharedPreferenceChangeLis
val preferenceChangelog = findPreference<Preference>(Constants.KEY_CHANGELOG)
val preferenceBackup = findPreference<Preference>(Constants.KEY_BACKUP)
val preferenceFeedback = findPreference<Preference>(Constants.KEY_FEEDBACK)
val preferenceCsvImport = findPreference<Preference>(Constants.KEY_CSV_IMPORT)

if (preferenceCheckForUpdates != null) {
val updater = Updater()
Expand Down Expand Up @@ -75,13 +73,6 @@ class SettingsFragment : PreferenceFragmentCompat(), OnSharedPreferenceChangeLis
true
}
}

if (preferenceCsvImport != null) {
preferenceCsvImport.onPreferenceClickListener = Preference.OnPreferenceClickListener {
Backup().runImporterCSV(activity as ListActivity)
true
}
}
}

override fun onResume() {
Expand Down
6 changes: 0 additions & 6 deletions app/src/main/res/xml/preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,6 @@
android:summary="@string/backup_summary"
android:title="@string/backup_title" />

<Preference
android:icon="@drawable/ic_iconscout_file_import_24"
android:key="KEY_CSV_IMPORT"
android:summary="@string/import_csv_summary"
android:title="@string/import_csv_title" />

<PreferenceCategory
android:key="customization"
android:title="@string/customization">
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/res/xml/preferences_backup.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@
android:summary="@string/import_summary"
android:title="@string/import_title" />

<Preference
android:icon="@drawable/ic_iconscout_file_import_24"
android:key="KEY_CSV_IMPORT"
android:summary="@string/import_csv_summary"
android:title="@string/import_csv_title" />

</PreferenceCategory>

</PreferenceScreen>

0 comments on commit 04652d7

Please sign in to comment.