Commit 9f2c6766 authored by Daniel Wolf's avatar Daniel Wolf
Browse files

Current state

parent 8f5c4b36
...@@ -65,6 +65,6 @@ class SettingsActivity : BaseActivity() { ...@@ -65,6 +65,6 @@ class SettingsActivity : BaseActivity() {
} }
enum class Category { enum class Category {
GENERAL, NOTIFICATION, PIN, CACHE, LOGGING, IP, NETWORK, QUERIES GENERAL, NOTIFICATION, PIN, CACHE, LOGGING, IP, NETWORK, QUERIES, SETTINGS_EXPORT
} }
} }
\ No newline at end of file
package com.frostnerd.smokescreen.dialog
import android.content.Context
import android.content.DialogInterface
import androidx.appcompat.app.AlertDialog
import com.frostnerd.smokescreen.R
import com.frostnerd.smokescreen.getPreferences
/*
* Copyright (C) 2019 Daniel Wolf (Ch4t4r)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* You can contact the developer at daniel.wolf@frostnerd.com.
*/
class SettingsExportDialog(context: Context):AlertDialog(context, context.getPreferences().theme.dialogStyle) {
init {
val view = layoutInflater.inflate(R.layout.dialog_settingsexport, null, false)
setView(view)
setTitle(R.string.title_export_settings)
setButton(DialogInterface.BUTTON_NEGATIVE, context.getString(android.R.string.cancel)) { dialog, _ ->
dialog.dismiss()
}
}
}
\ No newline at end of file
...@@ -73,6 +73,7 @@ class SettingsFragment : PreferenceFragmentCompat() { ...@@ -73,6 +73,7 @@ class SettingsFragment : PreferenceFragmentCompat() {
SettingsActivity.Category.IP -> R.xml.preferences_ip SettingsActivity.Category.IP -> R.xml.preferences_ip
SettingsActivity.Category.NETWORK -> R.xml.preferences_network SettingsActivity.Category.NETWORK -> R.xml.preferences_network
SettingsActivity.Category.QUERIES -> R.xml.preferences_queries SettingsActivity.Category.QUERIES -> R.xml.preferences_queries
SettingsActivity.Category.SETTINGS_EXPORT -> R.xml.preferences_export
} }
setPreferencesFromResource(resource, rootKey) setPreferencesFromResource(resource, rootKey)
log("Preferences added.") log("Preferences added.")
...@@ -130,6 +131,7 @@ class SettingsFragment : PreferenceFragmentCompat() { ...@@ -130,6 +131,7 @@ class SettingsFragment : PreferenceFragmentCompat() {
SettingsActivity.Category.IP -> processIPCategory() SettingsActivity.Category.IP -> processIPCategory()
SettingsActivity.Category.NETWORK -> processNetworkCategory() SettingsActivity.Category.NETWORK -> processNetworkCategory()
SettingsActivity.Category.QUERIES -> processQueryCategory() SettingsActivity.Category.QUERIES -> processQueryCategory()
SettingsActivity.Category.SETTINGS_EXPORT -> processSettingsExportCategory()
} }
} }
...@@ -446,6 +448,13 @@ class SettingsFragment : PreferenceFragmentCompat() { ...@@ -446,6 +448,13 @@ class SettingsFragment : PreferenceFragmentCompat() {
} }
} }
fun processSettingsExportCategory() {
findPreference("export_settings").setOnPreferenceClickListener {
true
}
}
private fun showLogDeletionDialog() { private fun showLogDeletionDialog() {
AlertDialog.Builder(requireContext(), requireContext().getPreferences().theme.dialogStyle) AlertDialog.Builder(requireContext(), requireContext().getPreferences().theme.dialogStyle)
.setTitle(R.string.title_delete_all_logs) .setTitle(R.string.title_delete_all_logs)
......
...@@ -59,5 +59,8 @@ class SettingsOverviewFragment: Fragment() { ...@@ -59,5 +59,8 @@ class SettingsOverviewFragment: Fragment() {
queryLogging.setOnClickListener { queryLogging.setOnClickListener {
SettingsActivity.showCategory(context!!, SettingsActivity.Category.QUERIES) SettingsActivity.showCategory(context!!, SettingsActivity.Category.QUERIES)
} }
settingsExport.setOnClickListener {
SettingsActivity.showCategory(context!!, SettingsActivity.Category.SETTINGS_EXPORT)
}
} }
} }
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
</LinearLayout>
\ No newline at end of file
...@@ -181,6 +181,28 @@ ...@@ -181,6 +181,28 @@
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:layout_height="32dp"/> android:layout_height="32dp"/>
</RelativeLayout> </RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:paddingTop="12dp"
android:paddingBottom="12dp"
android:id="@+id/settingsExport"
android:textStyle="bold"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:textSize="18sp"
android:textStyle="bold"
android:text="@string/preference_category_importexport"
android:layout_centerVertical="true"
android:layout_height="wrap_content"/>
<ImageView
android:layout_width="32dp"
android:src="@drawable/ic_chevron_right"
android:tint="?android:attr/textColor"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:layout_height="32dp"/>
</RelativeLayout>
</LinearLayout> </LinearLayout>
......
...@@ -149,6 +149,10 @@ ...@@ -149,6 +149,10 @@
<string name="title_delete_queries">Clear queries</string> <string name="title_delete_queries">Clear queries</string>
<string name="summary_delete_queries">Click here to delete all logged queries.</string> <string name="summary_delete_queries">Click here to delete all logged queries.</string>
<string name="preference_category_importexport">Export/Import</string>
<string name="title_export_settings">Export settings</string>
<string name="summary_export_settings">Export some settings of your choice</string>
<string-array name="languages"> <string-array name="languages">
<item>System language</item> <item>System language</item>
<item>English</item> <item>English</item>
......
<?xml version="1.0" encoding="utf-8" ?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory title="@string/preference_category_importexport">
<Preference
android:key="export_settings"
android:summary="@string/summary_export_settings"
android:title="@string/title_export_settings" />
</PreferenceCategory>
</PreferenceScreen>
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment