X-Git-Url: https://gitweb.stoutner.com/?a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2Factivities%2FDomainsActivity.kt;h=4996568e1e79084b865a75b4098f670a89a2a53a;hb=a9cc33fde503c6c8b0a870e0a5d4287e38a4f696;hp=96de49fa03c178f7f5042855f2dfbe90e9a8ab76;hpb=5987e0cf5095be146f4fdece1d6d01b5a4cc128d;p=PrivacyBrowserAndroid.git diff --git a/app/src/main/java/com/stoutner/privacybrowser/activities/DomainsActivity.kt b/app/src/main/java/com/stoutner/privacybrowser/activities/DomainsActivity.kt index 96de49fa..4996568e 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/activities/DomainsActivity.kt +++ b/app/src/main/java/com/stoutner/privacybrowser/activities/DomainsActivity.kt @@ -23,7 +23,6 @@ import android.app.Activity import android.content.Context import android.database.Cursor import android.os.Bundle -import android.os.Handler import android.view.Menu import android.view.MenuItem import android.view.View @@ -570,27 +569,21 @@ class DomainsActivity : AppCompatActivity(), AddDomainListener, DismissSnackbarI } } else { // The snackbar was dismissed without the undo button being pushed. // Delete the selected domain. - domainsDatabaseHelper.deleteDomain(databaseIdToDelete) - - // Enable the delete menu item if the system was waiting for a snackbar to be dismissed. - if (dismissingSnackbar) { - // Create a runnable to enable the delete menu item. - val enableDeleteMenuItemRunnable = Runnable { - // Enable or show the delete menu item according to the display mode. - if (twoPanedMode) - deleteMenuItem.isEnabled = true - else - deleteMenuItem.isVisible = true - - // Reset the dismissing snackbar tracker. - dismissingSnackbar = false - } - - // Instantiate a handler running the main looper. - val handler = Handler(mainLooper) - - // Enable or show the delete menu icon after 100 milliseconds to make sure that the previous domain has been deleted from the database. - handler.postDelayed(enableDeleteMenuItemRunnable, 100) + val rowsDeleted = domainsDatabaseHelper.deleteDomain(databaseIdToDelete) + + // Enable the delete menu item. + // The rows deleted should always be greater than 0, but in all cases they should be greater than -1. + // This has the effect of tricking the compiler into waiting until after the delete finishes to reenable the delete menu item, + // because the compiler (probably) can't tell that the response will never be less than -1, so it doesn't compile out the delay. + if (rowsDeleted > -1) { + // Enable or show the delete menu item according to the display mode. + if (twoPanedMode) + deleteMenuItem.isEnabled = true + else + deleteMenuItem.isVisible = true + + // Reset the dismissing snackbar tracker. + dismissingSnackbar = false } // Close the activity if back was pressed. @@ -694,7 +687,6 @@ class DomainsActivity : AppCompatActivity(), AddDomainListener, DismissSnackbarI val javaScriptSpinner = view.findViewById(R.id.javascript_spinner) val cookiesSpinner = view.findViewById(R.id.cookies_spinner) val domStorageSpinner = view.findViewById(R.id.dom_storage_spinner) - val formDataSpinner = view.findViewById(R.id.form_data_spinner) // Form data can be removed once the minimum API >= 26. val userAgentSpinner = view.findViewById(R.id.user_agent_spinner) val customUserAgentEditText = view.findViewById(R.id.custom_user_agent_edittext) val easyListSpinner = view.findViewById(R.id.easylist_spinner) @@ -720,7 +712,6 @@ class DomainsActivity : AppCompatActivity(), AddDomainListener, DismissSnackbarI val javaScriptInt = javaScriptSpinner.selectedItemPosition val cookiesInt = cookiesSpinner.selectedItemPosition val domStorageInt = domStorageSpinner.selectedItemPosition - val formDataInt = formDataSpinner.selectedItemPosition // Form data can be removed once the minimum API >= 26. val userAgentSwitchPosition = userAgentSpinner.selectedItemPosition val easyListInt = easyListSpinner.selectedItemPosition val easyPrivacyInt = easyPrivacySpinner.selectedItemPosition @@ -762,7 +753,7 @@ class DomainsActivity : AppCompatActivity(), AddDomainListener, DismissSnackbarI fontSizeInt = customFontSizeEditText.text.toString().toInt() // Save the domain settings. - domainsDatabaseHelper.updateDomain(currentDomainDatabaseId, domainNameString, javaScriptInt, cookiesInt, domStorageInt, formDataInt, userAgentName, easyListInt, easyPrivacyInt, fanboysAnnoyanceInt, + domainsDatabaseHelper.updateDomain(currentDomainDatabaseId, domainNameString, javaScriptInt, cookiesInt, domStorageInt, userAgentName, easyListInt, easyPrivacyInt, fanboysAnnoyanceInt, fanboysSocialBlockingInt, ultraListInt, ultraPrivacyInt, blockAllThirdPartyRequestsInt, fontSizeInt, swipeToRefreshInt, webViewThemeInt, wideViewportInt, displayWebpageImagesInt, pinnedSslCertificate, pinnedIpAddress)