diff --git a/app/src/main/java/com/etesync/syncadapter/App.kt b/app/src/main/java/com/etesync/syncadapter/App.kt index 94074115..162282a8 100644 --- a/app/src/main/java/com/etesync/syncadapter/App.kt +++ b/app/src/main/java/com/etesync/syncadapter/App.kt @@ -369,7 +369,7 @@ class App : Application() { val OVERRIDE_PROXY_HOST = "overrideProxyHost" val OVERRIDE_PROXY_PORT = "overrideProxyPort" val FORCE_LANGUAGE = "forceLanguage" - val CHANGE_NOTIFICATION = "changeNotification" + val CHANGE_NOTIFICATION = "show_change_notification" val OVERRIDE_PROXY_HOST_DEFAULT = "localhost" val OVERRIDE_PROXY_PORT_DEFAULT = 8118 diff --git a/app/src/main/java/com/etesync/syncadapter/model/Settings.java b/app/src/main/java/com/etesync/syncadapter/model/Settings.java index 327b2605..6c23032b 100644 --- a/app/src/main/java/com/etesync/syncadapter/model/Settings.java +++ b/app/src/main/java/com/etesync/syncadapter/model/Settings.java @@ -14,11 +14,6 @@ import android.database.sqlite.SQLiteDatabase; import android.support.annotation.Nullable; public class Settings { - public enum ChangeNotification { - ALL_CHANGES, - NONE - } - final SQLiteDatabase db; public Settings(SQLiteDatabase db) { @@ -82,11 +77,6 @@ public class Settings { } } - public ChangeNotification getChangeNotification(String name) { - int changeNotificationIndex = getInt(name, 0); - return ChangeNotification.values()[changeNotificationIndex]; - } - public void putString(String name, @Nullable String value) { ContentValues values = new ContentValues(2); values.put(ServiceDB.Settings.NAME, name); diff --git a/app/src/main/java/com/etesync/syncadapter/syncadapter/SyncManager.kt b/app/src/main/java/com/etesync/syncadapter/syncadapter/SyncManager.kt index b17068b3..29cc2639 100644 --- a/app/src/main/java/com/etesync/syncadapter/syncadapter/SyncManager.kt +++ b/app/src/main/java/com/etesync/syncadapter/syncadapter/SyncManager.kt @@ -31,6 +31,7 @@ import com.etesync.syncadapter.ui.ViewCollectionActivity import io.requery.Persistable import io.requery.sql.EntityDataStore import okhttp3.OkHttpClient +import org.jetbrains.anko.defaultSharedPreferences import java.io.FileNotFoundException import java.io.IOException import java.util.* @@ -227,9 +228,8 @@ constructor(protected val context: Context, protected val account: Account, prot } private fun notifyUserOnSync() { - val changeNotification = Settings(ServiceDB.OpenHelper(context).readableDatabase) - .getChangeNotification(App.CHANGE_NOTIFICATION) - if (remoteEntries!!.isEmpty() || changeNotification == Settings.ChangeNotification.NONE) { + val changeNotification = context.defaultSharedPreferences.getBoolean(App.CHANGE_NOTIFICATION, true) + if (remoteEntries!!.isEmpty() || !changeNotification) { return } val notificationHelper = NotificationHelper(context, diff --git a/app/src/main/java/com/etesync/syncadapter/ui/AppSettingsActivity.kt b/app/src/main/java/com/etesync/syncadapter/ui/AppSettingsActivity.kt index c58830b4..51ee9a11 100644 --- a/app/src/main/java/com/etesync/syncadapter/ui/AppSettingsActivity.kt +++ b/app/src/main/java/com/etesync/syncadapter/ui/AppSettingsActivity.kt @@ -19,6 +19,7 @@ import com.etesync.syncadapter.model.ServiceDB import com.etesync.syncadapter.model.Settings import com.etesync.syncadapter.utils.HintManager import com.etesync.syncadapter.utils.LanguageUtils +import org.jetbrains.anko.defaultSharedPreferences import java.net.URI import java.net.URISyntaxException @@ -116,6 +117,9 @@ class AppSettingsActivity : BaseActivity() { prefLogToExternalStorage = findPreference("log_to_external_storage") as SwitchPreferenceCompat prefLogToExternalStorage.isChecked = settings.getBoolean(App.LOG_TO_EXTERNAL_STORAGE, false) + val prefChangeNotification = findPreference("show_change_notification") as SwitchPreferenceCompat + prefChangeNotification.isChecked = context!!.defaultSharedPreferences.getBoolean(App.CHANGE_NOTIFICATION, true) + initSelectLanguageList() } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index e680cd7c..b1154807 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -99,10 +99,6 @@ Force Language Auto Show change notifications - - For all changes - None - Synchronize now diff --git a/app/src/main/res/xml/settings_app.xml b/app/src/main/res/xml/settings_app.xml index 1ac45c38..178cf21c 100644 --- a/app/src/main/res/xml/settings_app.xml +++ b/app/src/main/res/xml/settings_app.xml @@ -11,11 +11,8 @@ -