allow exporting the app settings

This commit is contained in:
tibbi 2019-02-13 22:52:10 +01:00
parent ee73674468
commit 47eb989d3b
2 changed files with 117 additions and 5 deletions

View File

@ -16,10 +16,7 @@ import com.simplemobiletools.commons.dialogs.CustomIntervalPickerDialog
import com.simplemobiletools.commons.dialogs.RadioGroupDialog
import com.simplemobiletools.commons.dialogs.SelectAlarmSoundDialog
import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.ALARM_SOUND_TYPE_NOTIFICATION
import com.simplemobiletools.commons.helpers.IS_CUSTOMIZING_COLORS
import com.simplemobiletools.commons.helpers.PERMISSION_READ_CALENDAR
import com.simplemobiletools.commons.helpers.PERMISSION_WRITE_CALENDAR
import com.simplemobiletools.commons.helpers.*
import com.simplemobiletools.commons.models.AlarmSound
import com.simplemobiletools.commons.models.RadioItem
import kotlinx.android.synthetic.main.activity_settings.*
@ -77,6 +74,8 @@ class SettingsActivity : SimpleActivity() {
updateTextColors(settings_holder)
checkPrimaryColor()
setupSectionColors()
setupExportSettings()
setupImportSettings()
}
override fun onPause() {
@ -115,7 +114,8 @@ class SettingsActivity : SimpleActivity() {
private fun setupSectionColors() {
val adjustedPrimaryColor = getAdjustedPrimaryColor()
arrayListOf(reminders_label, caldav_label, weekly_view_label, monthly_view_label, simple_event_list_label, widgets_label, events_label, new_events_label).forEach {
arrayListOf(reminders_label, caldav_label, weekly_view_label, monthly_view_label, simple_event_list_label, widgets_label, events_label,
new_events_label, migrating_label).forEach {
it.setTextColor(adjustedPrimaryColor)
}
}
@ -644,4 +644,54 @@ class SettingsActivity : SimpleActivity() {
}.start()
}
}
private fun setupExportSettings() {
settings_export_holder.setOnClickListener {
val configItems = LinkedHashMap<String, Any>().apply {
put(IS_USING_SHARED_THEME, config.isUsingSharedTheme)
put(TEXT_COLOR, config.textColor)
put(BACKGROUND_COLOR, config.backgroundColor)
put(PRIMARY_COLOR, config.primaryColor)
put(APP_ICON_COLOR, config.appIconColor)
put(USE_ENGLISH, config.useEnglish)
put(WAS_USE_ENGLISH_TOGGLED, config.wasUseEnglishToggled)
put(WIDGET_BG_COLOR, config.widgetBgColor)
put(WIDGET_TEXT_COLOR, config.widgetTextColor)
put(WEEK_NUMBERS, config.showWeekNumbers)
put(START_WEEKLY_AT, config.startWeeklyAt)
put(END_WEEKLY_AT, config.endWeeklyAt)
put(END_WEEKLY_AT, config.endWeeklyAt)
put(VIBRATE, config.vibrateOnReminder)
put(LAST_EVENT_REMINDER_MINUTES, config.lastEventReminderMinutes1)
put(LAST_EVENT_REMINDER_MINUTES_2, config.lastEventReminderMinutes2)
put(LAST_EVENT_REMINDER_MINUTES_3, config.lastEventReminderMinutes3)
put(DISPLAY_PAST_EVENTS, config.displayPastEvents)
put(FONT_SIZE, config.fontSize)
put(LIST_WIDGET_VIEW_TO_OPEN, config.listWidgetViewToOpen)
put(REMINDER_AUDIO_STREAM, config.reminderAudioStream)
put(REPLACE_DESCRIPTION, config.replaceDescription)
put(SHOW_GRID, config.showGrid)
put(LOOP_REMINDERS, config.loopReminders)
put(REPLACE_DESCRIPTION, config.replaceDescription)
put(DIM_PAST_EVENTS, config.dimPastEvents)
put(USE_PREVIOUS_EVENT_REMINDERS, config.usePreviousEventReminders)
put(DEFAULT_REMINDER_1, config.defaultReminder1)
put(DEFAULT_REMINDER_2, config.defaultReminder2)
put(DEFAULT_REMINDER_3, config.defaultReminder3)
put(PULL_TO_REFRESH, config.pullToRefresh)
put(DEFAULT_START_TIME, config.defaultStartTime)
put(DEFAULT_DURATION, config.defaultDuration)
put(USE_SAME_SNOOZE, config.useSameSnooze)
put(SNOOZE_TIME, config.snoozeTime)
put(USE_24_HOUR_FORMAT, config.use24HourFormat)
put(SUNDAY_FIRST, config.isSundayFirst)
}
exportSettings(configItems, "calendar-settings.txt")
}
}
private fun setupImportSettings() {
}
}

View File

@ -980,5 +980,67 @@
android:text="@string/delete_all_events"/>
</RelativeLayout>
<View
android:id="@+id/migrating_divider"
android:layout_width="match_parent"
android:layout_height="1px"
android:background="@color/divider_grey"
android:importantForAccessibility="no"/>
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/migrating_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/bigger_margin"
android:layout_marginLeft="@dimen/bigger_margin"
android:layout_marginTop="@dimen/activity_margin"
android:text="@string/migrating"
android:textAllCaps="true"
android:textSize="@dimen/smaller_text_size"/>
<RelativeLayout
android:id="@+id/settings_export_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/medium_margin"
android:background="?attr/selectableItemBackground"
android:paddingLeft="@dimen/normal_margin"
android:paddingTop="@dimen/activity_margin"
android:paddingRight="@dimen/normal_margin"
android:paddingBottom="@dimen/activity_margin">
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/settings_export"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:paddingStart="@dimen/medium_margin"
android:paddingLeft="@dimen/medium_margin"
android:text="@string/export_settings"/>
</RelativeLayout>
<RelativeLayout
android:id="@+id/settings_import_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/medium_margin"
android:background="?attr/selectableItemBackground"
android:paddingLeft="@dimen/normal_margin"
android:paddingTop="@dimen/activity_margin"
android:paddingRight="@dimen/normal_margin"
android:paddingBottom="@dimen/activity_margin">
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/settings_import"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:paddingStart="@dimen/medium_margin"
android:paddingLeft="@dimen/medium_margin"
android:text="@string/import_settings"/>
</RelativeLayout>
</LinearLayout>
</ScrollView>