[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [orbot/master] Java 8 code cleanup, lambdas over anonymous inner classes. This gets rid of



commit af1ab221b3d2b7e52a2a359c5cda67d8028df0c2
Author: bim <dsnake@xxxxxxxxxxxxxx>
Date:   Fri Jul 24 11:51:51 2020 -0400

    Java 8 code cleanup, lambdas over anonymous inner classes. This gets rid of
    unused imports. Also removed methods in the main app that are not used by
    the program at all.
---
 .../integration/android/IntentIntegrator.java      |  40 ++++----
 .../org/torproject/android/OnBootReceiver.java     |   6 +-
 .../main/java/org/torproject/android/OrbotApp.java |  52 +---------
 .../org/torproject/android/OrbotMainActivity.java  |  98 ++++---------------
 .../org/torproject/android/settings/Languages.java |  18 ----
 .../android/settings/SettingsPreferences.java      |  18 ++--
 .../torproject/android/ui/AppManagerActivity.java  |  21 ++--
 .../ui/hiddenservices/ClientCookiesActivity.java   |  51 ++++------
 .../ui/hiddenservices/HiddenServicesActivity.java  |  55 +++++------
 .../ui/hiddenservices/adapters/BackupAdapter.java  |   7 +-
 .../adapters/ClientCookiesAdapter.java             |  30 +++---
 .../hiddenservices/adapters/OnionListAdapter.java  |  34 +++----
 .../ui/hiddenservices/dialogs/AddCookieDialog.java |  28 +++---
 .../dialogs/CookieActionsDialog.java               |  24 ++---
 .../hiddenservices/dialogs/CookieDeleteDialog.java |  33 +++----
 .../ui/hiddenservices/dialogs/HSActionsDialog.java |  75 ++++++---------
 .../ui/hiddenservices/dialogs/HSCookieDialog.java  |  56 +++++------
 .../ui/hiddenservices/dialogs/HSDataDialog.java    |  44 ++++-----
 .../ui/hiddenservices/dialogs/HSDeleteDialog.java  |  51 +++++-----
 .../dialogs/SelectCookieBackupDialog.java          |  35 ++-----
 .../dialogs/SelectHSBackupDialog.java              |  35 ++-----
 .../permissions/PermissionManager.java             |  37 +++----
 .../ui/hiddenservices/storage/ExternalStorage.java |   8 +-
 .../ui/onboarding/BridgeWizardActivity.java        |  49 +++-------
 .../ui/onboarding/CustomBridgesActivity.java       |  13 +--
 .../android/ui/onboarding/MoatActivity.java        | 106 ++++++++++-----------
 .../android/ui/onboarding/OnboardingActivity.java  |  15 +--
 .../android/service/ApplicationTest.java           |  13 ---
 .../torproject/android/service/OrbotService.java   |  30 ++----
 .../android/service/TorEventHandler.java           |   1 -
 .../android/service/util/ExternalIPFetcher.java    |   1 -
 .../android/service/util/TorServiceUtils.java      |   3 -
 .../torproject/android/service/vpn/VpnUtils.java   |   3 -
 33 files changed, 371 insertions(+), 719 deletions(-)

diff --git a/app/src/main/java/com/google/zxing/integration/android/IntentIntegrator.java b/app/src/main/java/com/google/zxing/integration/android/IntentIntegrator.java
index d5628e87..f3dbb9e4 100644
--- a/app/src/main/java/com/google/zxing/integration/android/IntentIntegrator.java
+++ b/app/src/main/java/com/google/zxing/integration/android/IntentIntegrator.java
@@ -27,7 +27,6 @@ import android.app.Activity;
 import android.app.AlertDialog;
 import android.app.Fragment;
 import android.content.ActivityNotFoundException;
-import android.content.DialogInterface;
 import android.content.Intent;
 import android.content.pm.PackageManager;
 import android.content.pm.ResolveInfo;
@@ -370,29 +369,26 @@ public class IntentIntegrator {
     AlertDialog.Builder downloadDialog = new AlertDialog.Builder(activity);
     downloadDialog.setTitle(title);
     downloadDialog.setMessage(message);
-    downloadDialog.setPositiveButton(buttonYes, new DialogInterface.OnClickListener() {
-      @Override
-      public void onClick(DialogInterface dialogInterface, int i) {
-        String packageName;
-        if (targetApplications.contains(BS_PACKAGE)) {
-          // Prefer to suggest download of BS if it's anywhere in the list
-          packageName = BS_PACKAGE;
+    downloadDialog.setPositiveButton(buttonYes, (dialogInterface, i) -> {
+      String packageName;
+      if (targetApplications.contains(BS_PACKAGE)) {
+        // Prefer to suggest download of BS if it's anywhere in the list
+        packageName = BS_PACKAGE;
+      } else {
+        // Otherwise, first option:
+        packageName = targetApplications.get(0);
+      }
+      Uri uri = Uri.parse("market://details?id=" + packageName);
+      Intent intent = new Intent(Intent.ACTION_VIEW, uri);
+      try {
+        if (fragment == null) {
+          activity.startActivity(intent);
         } else {
-          // Otherwise, first option:
-          packageName = targetApplications.get(0);
-        }
-        Uri uri = Uri.parse("market://details?id=" + packageName);
-        Intent intent = new Intent(Intent.ACTION_VIEW, uri);
-        try {
-          if (fragment == null) {
-            activity.startActivity(intent);
-          } else {
-            fragment.startActivity(intent);
-          }
-        } catch (ActivityNotFoundException anfe) {
-          // Hmm, market is not installed
-          Log.w(TAG, "Google Play is not installed; cannot install " + packageName);
+          fragment.startActivity(intent);
         }
+      } catch (ActivityNotFoundException anfe) {
+        // Hmm, market is not installed
+        Log.w(TAG, "Google Play is not installed; cannot install " + packageName);
       }
     });
     downloadDialog.setNegativeButton(buttonNo, null);
diff --git a/app/src/main/java/org/torproject/android/OnBootReceiver.java b/app/src/main/java/org/torproject/android/OnBootReceiver.java
index 0bfb20d7..b8d88e58 100644
--- a/app/src/main/java/org/torproject/android/OnBootReceiver.java
+++ b/app/src/main/java/org/torproject/android/OnBootReceiver.java
@@ -1,6 +1,5 @@
 package org.torproject.android;
 
-
 import android.content.BroadcastReceiver;
 import android.content.Context;
 import android.content.Intent;
@@ -26,7 +25,6 @@ public class OnBootReceiver extends BroadcastReceiver {
 
 	private void startService (String action, Context context)
 	{
-
 		Intent intent = new Intent(context, OrbotService.class);
 		intent.setAction(action);
 		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
@@ -38,7 +36,7 @@ public class OnBootReceiver extends BroadcastReceiver {
 		}
 
 	}
-	
-	
+
+
 }
 
diff --git a/app/src/main/java/org/torproject/android/OrbotApp.java b/app/src/main/java/org/torproject/android/OrbotApp.java
index e1f83233..7cb4317f 100644
--- a/app/src/main/java/org/torproject/android/OrbotApp.java
+++ b/app/src/main/java/org/torproject/android/OrbotApp.java
@@ -1,17 +1,9 @@
-
 package org.torproject.android;
 
-import android.annotation.SuppressLint;
-import android.app.Activity;
 import android.app.Application;
-import android.app.Notification;
-import android.app.NotificationManager;
-import android.app.PendingIntent;
 import android.content.Context;
-import android.content.Intent;
-import android.content.pm.PackageManager;
 import android.content.res.Configuration;
-import androidx.core.app.NotificationCompat;
+
 import org.torproject.android.service.OrbotConstants;
 import org.torproject.android.service.util.Prefs;
 import org.torproject.android.settings.Languages;
@@ -19,11 +11,8 @@ import org.torproject.android.settings.LocaleHelper;
 
 import java.util.Locale;
 
-
 public class OrbotApp extends Application implements OrbotConstants {
 
-    private Locale locale;
-
     @Override
     public void onCreate() {
         super.onCreate();
@@ -32,7 +21,6 @@ public class OrbotApp extends Application implements OrbotConstants {
         if (!Prefs.getDefaultLocale().equals(Locale.getDefault().getLanguage())) {
             Languages.setLanguage(this, Prefs.getDefaultLocale(), true);
         }
-
     }
 
     @Override
@@ -49,42 +37,4 @@ public class OrbotApp extends Application implements OrbotConstants {
             Languages.setLanguage(this, Prefs.getDefaultLocale(), true);
     }
 
-
-    public static Languages getLanguages(Activity activity) {
-        return Languages.get(activity);
-    }
-
-
-    @SuppressLint("NewApi")
-    protected void showToolbarNotification (String shortMsg, String notifyMsg, int notifyId, int icon)
-    {
-
-        NotificationCompat.Builder notifyBuilder;
-
-        //Reusable code.
-        PackageManager pm = getPackageManager();
-        Intent intent = pm.getLaunchIntentForPackage(getPackageName());
-        PendingIntent pendIntent = PendingIntent.getActivity(this, 0, intent, 0);
-
-        NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
-
-        notifyBuilder = new NotificationCompat.Builder(this)
-                .setContentTitle(getString(org.torproject.android.service.R.string.app_name));
-
-
-        notifyBuilder.setContentIntent(pendIntent);
-
-        notifyBuilder.setContentText(shortMsg);
-        notifyBuilder.setSmallIcon(icon);
-        notifyBuilder.setTicker(notifyMsg);
-
-        notifyBuilder.setOngoing(false);
-
-        notifyBuilder.setStyle(new NotificationCompat.BigTextStyle()
-                .bigText(notifyMsg).setBigContentTitle(getString(org.torproject.android.service.R.string.app_name)));
-
-        Notification notification = notifyBuilder.build();
-
-        notificationManager.notify(notifyId, notification);
-    }
 }
diff --git a/app/src/main/java/org/torproject/android/OrbotMainActivity.java b/app/src/main/java/org/torproject/android/OrbotMainActivity.java
index 328476a9..34e7c176 100644
--- a/app/src/main/java/org/torproject/android/OrbotMainActivity.java
+++ b/app/src/main/java/org/torproject/android/OrbotMainActivity.java
@@ -3,8 +3,6 @@
 
 package org.torproject.android;
 
-import android.app.ActivityManager;
-import android.app.ActivityManager.RunningServiceInfo;
 import android.app.AlertDialog;
 
 import android.content.BroadcastReceiver;
@@ -35,7 +33,6 @@ import android.widget.AdapterView;
 import android.widget.AdapterView.OnItemSelectedListener;
 import android.widget.ArrayAdapter;
 import android.widget.Button;
-import android.widget.CompoundButton;
 import android.widget.ImageView;
 import android.widget.LinearLayout;
 import android.widget.Spinner;
@@ -294,22 +291,14 @@ public class OrbotMainActivity extends AppCompatActivity implements OrbotConstan
         mTxtOrbotLog = findViewById(R.id.orbotLog);
 
         lblStatus = findViewById(R.id.lblStatus);
-        lblStatus.setOnClickListener(new View.OnClickListener() {
-            @Override
-            public void onClick(View v) {
-                mDrawer.openDrawer(LOG_DRAWER_GRAVITY);
-            }
-        });
+        lblStatus.setOnClickListener(v -> mDrawer.openDrawer(LOG_DRAWER_GRAVITY));
 
         lblPorts = findViewById(R.id.lblPorts);
 
         imgStatus = findViewById(R.id.imgStatus);
-        imgStatus.setOnLongClickListener(new View.OnLongClickListener() {
-            @Override
-            public boolean onLongClick(View v) {
-                toggleTor();
-                return true;
-            }
+        imgStatus.setOnLongClickListener(v -> {
+            toggleTor();
+            return true;
         });
 
         downloadText = findViewById(R.id.trafficDown);
@@ -320,12 +309,7 @@ public class OrbotMainActivity extends AppCompatActivity implements OrbotConstan
         uploadText.setText(zero);
 
         mBtnStart = findViewById(R.id.btnStart);
-        mBtnStart.setOnClickListener(new View.OnClickListener() {
-            @Override
-            public void onClick(View v) {
-                toggleTor();
-            }
-        });
+        mBtnStart.setOnClickListener(v -> toggleTor());
 
         mBtnVPN = findViewById(R.id.btnVPN);
 
@@ -337,24 +321,13 @@ public class OrbotMainActivity extends AppCompatActivity implements OrbotConstan
             sendIntentToService(ACTION_START_VPN);
         }
 
-        mBtnVPN.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
-            @Override
-            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
-                enableVPN(isChecked);
-            }
-        });
+        mBtnVPN.setOnCheckedChangeListener((buttonView, isChecked) -> enableVPN(isChecked));
 
 
         mBtnBridges = findViewById(R.id.btnBridges);
         mBtnBridges.setChecked(Prefs.bridgesEnabled());
-        mBtnBridges.setOnClickListener(new View.OnClickListener() {
-
-            @Override
-            public void onClick(View v) {
-                promptSetupBridges(); //if ARM processor, show all bridge options
-            }
-
-
+        mBtnBridges.setOnClickListener(v -> {
+            promptSetupBridges(); //if ARM processor, show all bridge options
         });
 
         spnCountries = findViewById(R.id.spinnerCountry);
@@ -700,16 +673,13 @@ public class OrbotMainActivity extends AppCompatActivity implements OrbotConstan
                 final Boolean authCookie = intent.getBooleanExtra("hs_auth_cookie", false);
                 final Uri mKeyUri = intent.getData();
 
-                DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
-
-                    public void onClick(DialogInterface dialog, int which) {
-                        if (which == DialogInterface.BUTTON_POSITIVE) {
-                            enableHiddenServicePort(
-                                    hiddenServiceName, hiddenServicePort,
-                                    hiddenServiceRemotePort, backupToPackage,
-                                    mKeyUri, authCookie
-                            );
-                        }
+                DialogInterface.OnClickListener dialogClickListener = (dialog, which) -> {
+                    if (which == DialogInterface.BUTTON_POSITIVE) {
+                        enableHiddenServicePort(
+                                hiddenServiceName, hiddenServicePort,
+                                hiddenServiceRemotePort, backupToPackage,
+                                mKeyUri, authCookie
+                        );
                     }
                 };
 
@@ -817,13 +787,10 @@ public class OrbotMainActivity extends AppCompatActivity implements OrbotConstan
                 finish();
 
                 final Handler handler = new Handler();
-                handler.postDelayed(new Runnable() {
-                    @Override
-                    public void run() {
-                        //Do something after 100ms
-                        startActivity(new Intent(OrbotMainActivity.this, OrbotMainActivity.class));
+                handler.postDelayed(() -> {
+                    //Do something after 100ms
+                    startActivity(new Intent(OrbotMainActivity.this, OrbotMainActivity.class));
 
-                    }
                 }, 1000);
 
 
@@ -1073,20 +1040,6 @@ public class OrbotMainActivity extends AppCompatActivity implements OrbotConstan
         sendIntentToService(TorServiceConstants.ACTION_STATUS);
     }
 
-    private boolean isTorServiceRunning() {
-        ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
-
-        if (manager != null) {
-            for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
-                if (OrbotService.class.getName().equals(service.service.getClassName())) {
-                    return true;
-                }
-            }
-        }
-
-        return false;
-    }
-
 
     // this is what takes messages or values from the callback threads or other non-mainUI threads
 //and passes them back into the main UI thread for display to the user
@@ -1228,12 +1181,7 @@ public class OrbotMainActivity extends AppCompatActivity implements OrbotConstan
                             iv.setLayoutParams(params);
                             iv.setImageDrawable(pMgr.getApplicationIcon(pkgId));
 
-                            iv.setOnClickListener(new View.OnClickListener() {
-                                @Override
-                                public void onClick(View v) {
-                                    openBrowser(URL_TOR_CHECK, false, pkgId);
-                                }
-                            });
+                            iv.setOnClickListener(v -> openBrowser(URL_TOR_CHECK, false, pkgId));
 
                             llBoxShortcuts.addView(iv);
                             appsAdded++;
@@ -1264,13 +1212,7 @@ public class OrbotMainActivity extends AppCompatActivity implements OrbotConstan
             iv.setLayoutParams(params);
             iv.setImageDrawable(getResources().getDrawable(R.drawable.ic_settings_white_24dp));
             llBoxShortcuts.addView(iv);
-            iv.setOnClickListener(new View.OnClickListener() {
-                @Override
-                public void onClick(View v) {
-                    startActivityForResult(new Intent(OrbotMainActivity.this, AppManagerActivity.class), REQUEST_VPN_APPS_SELECT);
-
-                }
-            });
+            iv.setOnClickListener(v -> startActivityForResult(new Intent(OrbotMainActivity.this, AppManagerActivity.class), REQUEST_VPN_APPS_SELECT));
         }
 
     }
diff --git a/app/src/main/java/org/torproject/android/settings/Languages.java b/app/src/main/java/org/torproject/android/settings/Languages.java
index da83cd97..b9a76b91 100644
--- a/app/src/main/java/org/torproject/android/settings/Languages.java
+++ b/app/src/main/java/org/torproject/android/settings/Languages.java
@@ -3,7 +3,6 @@ package org.torproject.android.settings;
 import android.annotation.SuppressLint;
 import android.app.Activity;
 import android.content.ContextWrapper;
-import android.content.Intent;
 import android.content.res.AssetManager;
 import android.content.res.Configuration;
 import android.content.res.Resources;
@@ -19,7 +18,6 @@ import java.util.Set;
 import java.util.TreeMap;
 
 public class Languages {
-    public static final String TAG = "Languages";
 
     public static Locale defaultLocale;
     public static final Locale TIBETAN = new Locale("bo");
@@ -175,22 +173,6 @@ public class Languages {
         }
     }
 
-    /**
-     * Force reload the {@link Activity to make language changes take effect.}
-     *
-     * @param activity the {@code Activity} to force reload
-     */
-    public static void forceChangeLanguage(Activity activity) {
-        Intent intent = activity.getIntent();
-        if (intent == null) // when launched as LAUNCHER
-            return;
-        intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
-        activity.finish();
-        activity.overridePendingTransition(0, 0);
-        activity.startActivity(intent);
-        activity.overridePendingTransition(0, 0);
-    }
-
     /**
      * Return an array of the names of all the supported languages, sorted to
      * match what is returned by {@link Languages#getSupportedLocales()}.
diff --git a/app/src/main/java/org/torproject/android/settings/SettingsPreferences.java b/app/src/main/java/org/torproject/android/settings/SettingsPreferences.java
index 2af632ee..4279fd65 100644
--- a/app/src/main/java/org/torproject/android/settings/SettingsPreferences.java
+++ b/app/src/main/java/org/torproject/android/settings/SettingsPreferences.java
@@ -9,7 +9,6 @@ import android.os.Bundle;
 import android.preference.EditTextPreference;
 import android.preference.ListPreference;
 import android.preference.Preference;
-import android.preference.Preference.OnPreferenceChangeListener;
 import android.preference.PreferenceActivity;
 import android.preference.PreferenceCategory;
 import android.preference.PreferenceScreen;
@@ -32,16 +31,13 @@ public class SettingsPreferences extends PreferenceActivity {
         Languages languages = Languages.get(this);
         prefLocale.setEntries(languages.getAllNames());
         prefLocale.setEntryValues(languages.getSupportedLocales());
-        prefLocale.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
-            @Override
-            public boolean onPreferenceChange(Preference preference, Object newValue) {
-                String language = (String) newValue;
-                Intent intentResult = new Intent();
-                intentResult.putExtra("locale", language);
-                setResult(RESULT_OK, intentResult);
-                finish();
-                return false;
-            }
+        prefLocale.setOnPreferenceChangeListener((preference, newValue) -> {
+            String language = (String) newValue;
+            Intent intentResult = new Intent();
+            intentResult.putExtra("locale", language);
+            setResult(RESULT_OK, intentResult);
+            finish();
+            return false;
         });
     }
 
diff --git a/app/src/main/java/org/torproject/android/ui/AppManagerActivity.java b/app/src/main/java/org/torproject/android/ui/AppManagerActivity.java
index 98e62a1f..63dab0ef 100644
--- a/app/src/main/java/org/torproject/android/ui/AppManagerActivity.java
+++ b/app/src/main/java/org/torproject/android/ui/AppManagerActivity.java
@@ -35,7 +35,6 @@ import org.torproject.android.service.vpn.TorifiedApp;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
-import java.util.Comparator;
 import java.util.Iterator;
 import java.util.List;
 import java.util.StringTokenizer;
@@ -125,17 +124,15 @@ public class AppManagerActivity extends AppCompatActivity implements OnClickList
         if (mApps == null)
             mApps = getApps(prefs);
 
-        Collections.sort(mApps,new Comparator<TorifiedApp>() {
-            public int compare(TorifiedApp o1, TorifiedApp o2) {
-                /* Some apps start with lowercase letters and without the sorting being case
-                   insensitive they'd appear at the end of the grid of apps, a position where users
-                   would likely not expect to find them.
-                 */
-                if (o1.isTorified() == o2.isTorified())
-                    return o1.getName().compareToIgnoreCase(o2.getName());
-                if (o1.isTorified()) return -1;
-                return 1;
-            }
+        Collections.sort(mApps, (o1, o2) -> {
+            /* Some apps start with lowercase letters and without the sorting being case
+               insensitive they'd appear at the end of the grid of apps, a position where users
+               would likely not expect to find them.
+             */
+            if (o1.isTorified() == o2.isTorified())
+                return o1.getName().compareToIgnoreCase(o2.getName());
+            if (o1.isTorified()) return -1;
+            return 1;
         });
 
         final LayoutInflater inflater = getLayoutInflater();
diff --git a/app/src/main/java/org/torproject/android/ui/hiddenservices/ClientCookiesActivity.java b/app/src/main/java/org/torproject/android/ui/hiddenservices/ClientCookiesActivity.java
index 511cda5a..0ed20f57 100644
--- a/app/src/main/java/org/torproject/android/ui/hiddenservices/ClientCookiesActivity.java
+++ b/app/src/main/java/org/torproject/android/ui/hiddenservices/ClientCookiesActivity.java
@@ -13,8 +13,6 @@ import androidx.appcompat.app.AppCompatActivity;
 import androidx.appcompat.widget.Toolbar;
 import android.view.Menu;
 import android.view.MenuItem;
-import android.view.View;
-import android.widget.AdapterView;
 import android.widget.ListView;
 import android.widget.Toast;
 import com.google.zxing.integration.android.IntentIntegrator;
@@ -47,12 +45,9 @@ public class ClientCookiesActivity extends AppCompatActivity {
 
         mResolver = getContentResolver();
 
-        findViewById(R.id.fab).setOnClickListener(new View.OnClickListener() {
-            @Override
-            public void onClick(View view) {
-                AddCookieDialog dialog = new AddCookieDialog();
-                dialog.show(getSupportFragmentManager(), "AddCookieDialog");
-            }
+        findViewById(R.id.fab).setOnClickListener(view -> {
+            AddCookieDialog dialog = new AddCookieDialog();
+            dialog.show(getSupportFragmentManager(), "AddCookieDialog");
         });
 
         mAdapter = new ClientCookiesAdapter(
@@ -67,33 +62,29 @@ public class ClientCookiesActivity extends AppCompatActivity {
         ListView cookies = findViewById(R.id.clien_cookies_list);
         cookies.setAdapter(mAdapter);
 
-        cookies.setOnItemClickListener(new AdapterView.OnItemClickListener() {
-
-            @Override
-            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
-                Cursor item = (Cursor) parent.getItemAtPosition(position);
+        cookies.setOnItemClickListener((parent, view, position, id) -> {
+            Cursor item = (Cursor) parent.getItemAtPosition(position);
 
-                Bundle arguments = new Bundle();
-                arguments.putInt(
-                        "_id", item.getInt(item.getColumnIndex(CookieContentProvider.ClientCookie._ID))
-                );
+            Bundle arguments = new Bundle();
+            arguments.putInt(
+                    "_id", item.getInt(item.getColumnIndex(CookieContentProvider.ClientCookie._ID))
+            );
 
-                arguments.putString(
-                        "domain", item.getString(item.getColumnIndex(CookieContentProvider.ClientCookie.DOMAIN))
-                );
+            arguments.putString(
+                    "domain", item.getString(item.getColumnIndex(CookieContentProvider.ClientCookie.DOMAIN))
+            );
 
-                arguments.putString(
-                        "auth_cookie_value", item.getString(item.getColumnIndex(CookieContentProvider.ClientCookie.AUTH_COOKIE_VALUE))
-                );
+            arguments.putString(
+                    "auth_cookie_value", item.getString(item.getColumnIndex(CookieContentProvider.ClientCookie.AUTH_COOKIE_VALUE))
+            );
 
-                arguments.putInt(
-                        "enabled", item.getInt(item.getColumnIndex(CookieContentProvider.ClientCookie.ENABLED))
-                );
+            arguments.putInt(
+                    "enabled", item.getInt(item.getColumnIndex(CookieContentProvider.ClientCookie.ENABLED))
+            );
 
-                CookieActionsDialog dialog = new CookieActionsDialog();
-                dialog.setArguments(arguments);
-                dialog.show(getSupportFragmentManager(), CookieActionsDialog.class.getSimpleName());
-            }
+            CookieActionsDialog dialog = new CookieActionsDialog();
+            dialog.setArguments(arguments);
+            dialog.show(getSupportFragmentManager(), CookieActionsDialog.class.getSimpleName());
         });
 
     }
diff --git a/app/src/main/java/org/torproject/android/ui/hiddenservices/HiddenServicesActivity.java b/app/src/main/java/org/torproject/android/ui/hiddenservices/HiddenServicesActivity.java
index 4bf06e5b..8ea67ec7 100644
--- a/app/src/main/java/org/torproject/android/ui/hiddenservices/HiddenServicesActivity.java
+++ b/app/src/main/java/org/torproject/android/ui/hiddenservices/HiddenServicesActivity.java
@@ -52,12 +52,9 @@ public class HiddenServicesActivity extends AppCompatActivity {
         mResolver = getContentResolver();
 
         fab = findViewById(R.id.fab);
-        fab.setOnClickListener(new View.OnClickListener() {
-            @Override
-            public void onClick(View view) {
-                HSDataDialog dialog = new HSDataDialog();
-                dialog.show(getSupportFragmentManager(), "HSDataDialog");
-            }
+        fab.setOnClickListener(view -> {
+            HSDataDialog dialog = new HSDataDialog();
+            dialog.show(getSupportFragmentManager(), "HSDataDialog");
         });
 
         mAdapter = new OnionListAdapter(
@@ -75,37 +72,33 @@ public class HiddenServicesActivity extends AppCompatActivity {
         ListView onion_list = findViewById(R.id.onion_list);
         onion_list.setAdapter(mAdapter);
 
-        onion_list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
+        onion_list.setOnItemClickListener((parent, view, position, id) -> {
+            Cursor item = (Cursor) parent.getItemAtPosition(position);
 
-            @Override
-            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
-                Cursor item = (Cursor) parent.getItemAtPosition(position);
-
-                Bundle arguments = new Bundle();
-                arguments.putInt(
-                        "_id", item.getInt(item.getColumnIndex(HSContentProvider.HiddenService._ID))
-                );
+            Bundle arguments = new Bundle();
+            arguments.putInt(
+                    "_id", item.getInt(item.getColumnIndex(HSContentProvider.HiddenService._ID))
+            );
 
-                arguments.putString(
-                        "port", item.getString(item.getColumnIndex(HSContentProvider.HiddenService.PORT))
-                );
+            arguments.putString(
+                    "port", item.getString(item.getColumnIndex(HSContentProvider.HiddenService.PORT))
+            );
 
-                arguments.putString(
-                        "onion", item.getString(item.getColumnIndex(HSContentProvider.HiddenService.DOMAIN))
-                );
+            arguments.putString(
+                    "onion", item.getString(item.getColumnIndex(HSContentProvider.HiddenService.DOMAIN))
+            );
 
-                arguments.putInt(
-                        "auth_cookie", item.getInt(item.getColumnIndex(HSContentProvider.HiddenService.AUTH_COOKIE))
-                );
+            arguments.putInt(
+                    "auth_cookie", item.getInt(item.getColumnIndex(HSContentProvider.HiddenService.AUTH_COOKIE))
+            );
 
-                arguments.putString(
-                        "auth_cookie_value", item.getString(item.getColumnIndex(HSContentProvider.HiddenService.AUTH_COOKIE_VALUE))
-                );
+            arguments.putString(
+                    "auth_cookie_value", item.getString(item.getColumnIndex(HSContentProvider.HiddenService.AUTH_COOKIE_VALUE))
+            );
 
-                HSActionsDialog dialog = new HSActionsDialog();
-                dialog.setArguments(arguments);
-                dialog.show(getSupportFragmentManager(), HSActionsDialog.class.getSimpleName());
-            }
+            HSActionsDialog dialog = new HSActionsDialog();
+            dialog.setArguments(arguments);
+            dialog.show(getSupportFragmentManager(), HSActionsDialog.class.getSimpleName());
         });
     }
 
diff --git a/app/src/main/java/org/torproject/android/ui/hiddenservices/adapters/BackupAdapter.java b/app/src/main/java/org/torproject/android/ui/hiddenservices/adapters/BackupAdapter.java
index 272dbf36..1533f5b1 100644
--- a/app/src/main/java/org/torproject/android/ui/hiddenservices/adapters/BackupAdapter.java
+++ b/app/src/main/java/org/torproject/android/ui/hiddenservices/adapters/BackupAdapter.java
@@ -14,11 +14,6 @@ import java.util.List;
 public class BackupAdapter extends ArrayAdapter<File> {
     private int mResource;
 
-    public BackupAdapter(Context context, int resource) {
-        super(context, resource);
-        mResource = resource;
-    }
-
     public BackupAdapter(Context context, int resource, List<File> zips) {
         super(context, resource, zips);
         mResource = resource;
@@ -38,7 +33,7 @@ public class BackupAdapter extends ArrayAdapter<File> {
         File p = getItem(position);
 
         if (p != null) {
-            TextView name = (TextView) v.findViewById(R.id.backup_name);
+            TextView name = v.findViewById(R.id.backup_name);
 
             if (name != null)
                 name.setText(p.getName());
diff --git a/app/src/main/java/org/torproject/android/ui/hiddenservices/adapters/ClientCookiesAdapter.java b/app/src/main/java/org/torproject/android/ui/hiddenservices/adapters/ClientCookiesAdapter.java
index e0db9528..f61958cd 100644
--- a/app/src/main/java/org/torproject/android/ui/hiddenservices/adapters/ClientCookiesAdapter.java
+++ b/app/src/main/java/org/torproject/android/ui/hiddenservices/adapters/ClientCookiesAdapter.java
@@ -8,7 +8,6 @@ import androidx.cursoradapter.widget.CursorAdapter;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
-import android.widget.CompoundButton;
 import android.widget.Switch;
 import android.widget.TextView;
 import android.widget.Toast;
@@ -31,28 +30,25 @@ public class ClientCookiesAdapter extends CursorAdapter {
         int id = cursor.getInt(cursor.getColumnIndex(CookieContentProvider.ClientCookie._ID));
         final String where = CookieContentProvider.ClientCookie._ID + "=" + id;
 
-        TextView domain = (TextView) view.findViewById(R.id.cookie_onion);
+        TextView domain = view.findViewById(R.id.cookie_onion);
         domain.setText(cursor.getString(cursor.getColumnIndex(CookieContentProvider.ClientCookie.DOMAIN)));
 
-        Switch enabled = (Switch) view.findViewById(R.id.cookie_switch);
+        Switch enabled = view.findViewById(R.id.cookie_switch);
         enabled.setChecked(
                 cursor.getInt(cursor.getColumnIndex(CookieContentProvider.ClientCookie.ENABLED)) == 1
         );
 
-        enabled.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
-            @Override
-            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
-                ContentResolver resolver = mContext.getContentResolver();
-                ContentValues fields = new ContentValues();
-                fields.put(CookieContentProvider.ClientCookie.ENABLED, isChecked);
-                resolver.update(
-                        CookieContentProvider.CONTENT_URI, fields, where, null
-                );
-
-                Toast.makeText(
-                        mContext, R.string.please_restart_Orbot_to_enable_the_changes, Toast.LENGTH_LONG
-                ).show();
-            }
+        enabled.setOnCheckedChangeListener((buttonView, isChecked) -> {
+            ContentResolver resolver = mContext.getContentResolver();
+            ContentValues fields = new ContentValues();
+            fields.put(CookieContentProvider.ClientCookie.ENABLED, isChecked);
+            resolver.update(
+                    CookieContentProvider.CONTENT_URI, fields, where, null
+            );
+
+            Toast.makeText(
+                    mContext, R.string.please_restart_Orbot_to_enable_the_changes, Toast.LENGTH_LONG
+            ).show();
         });
     }
 
diff --git a/app/src/main/java/org/torproject/android/ui/hiddenservices/adapters/OnionListAdapter.java b/app/src/main/java/org/torproject/android/ui/hiddenservices/adapters/OnionListAdapter.java
index 485afe09..895f2779 100644
--- a/app/src/main/java/org/torproject/android/ui/hiddenservices/adapters/OnionListAdapter.java
+++ b/app/src/main/java/org/torproject/android/ui/hiddenservices/adapters/OnionListAdapter.java
@@ -8,7 +8,6 @@ import androidx.cursoradapter.widget.CursorAdapter;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
-import android.widget.CompoundButton;
 import android.widget.Switch;
 import android.widget.TextView;
 import android.widget.Toast;
@@ -31,32 +30,29 @@ public class OnionListAdapter extends CursorAdapter {
         int id = cursor.getInt(cursor.getColumnIndex(HSContentProvider.HiddenService._ID));
         final String where = HSContentProvider.HiddenService._ID + "=" + id;
 
-        TextView port = (TextView) view.findViewById(R.id.hs_port);
+        TextView port = view.findViewById(R.id.hs_port);
         port.setText(cursor.getString(cursor.getColumnIndex(HSContentProvider.HiddenService.PORT)));
-        TextView name = (TextView) view.findViewById(R.id.hs_name);
+        TextView name = view.findViewById(R.id.hs_name);
         name.setText(cursor.getString(cursor.getColumnIndex(HSContentProvider.HiddenService.NAME)));
-        TextView domain = (TextView) view.findViewById(R.id.hs_onion);
+        TextView domain = view.findViewById(R.id.hs_onion);
         domain.setText(cursor.getString(cursor.getColumnIndex(HSContentProvider.HiddenService.DOMAIN)));
 
-        Switch enabled = (Switch) view.findViewById(R.id.hs_switch);
+        Switch enabled = view.findViewById(R.id.hs_switch);
         enabled.setChecked(
                 cursor.getInt(cursor.getColumnIndex(HSContentProvider.HiddenService.ENABLED)) == 1
         );
 
-        enabled.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
-            @Override
-            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
-                ContentResolver resolver = mContext.getContentResolver();
-                ContentValues fields = new ContentValues();
-                fields.put(HSContentProvider.HiddenService.ENABLED, isChecked);
-                resolver.update(
-                        HSContentProvider.CONTENT_URI, fields, where, null
-                );
-
-                Toast.makeText(
-                        mContext, R.string.please_restart_Orbot_to_enable_the_changes, Toast.LENGTH_LONG
-                ).show();
-            }
+        enabled.setOnCheckedChangeListener((buttonView, isChecked) -> {
+            ContentResolver resolver = mContext.getContentResolver();
+            ContentValues fields = new ContentValues();
+            fields.put(HSContentProvider.HiddenService.ENABLED, isChecked);
+            resolver.update(
+                    HSContentProvider.CONTENT_URI, fields, where, null
+            );
+
+            Toast.makeText(
+                    mContext, R.string.please_restart_Orbot_to_enable_the_changes, Toast.LENGTH_LONG
+            ).show();
         });
     }
 
diff --git a/app/src/main/java/org/torproject/android/ui/hiddenservices/dialogs/AddCookieDialog.java b/app/src/main/java/org/torproject/android/ui/hiddenservices/dialogs/AddCookieDialog.java
index c47d9ae8..6fa99d8d 100644
--- a/app/src/main/java/org/torproject/android/ui/hiddenservices/dialogs/AddCookieDialog.java
+++ b/app/src/main/java/org/torproject/android/ui/hiddenservices/dialogs/AddCookieDialog.java
@@ -29,27 +29,21 @@ public class AddCookieDialog extends DialogFragment {
                 .create();
 
         Button save = dialog_view.findViewById(R.id.cookie_dialog_save);
-        save.setOnClickListener(new View.OnClickListener() {
-            public void onClick(View v) {
-                String onion = ((EditText) dialog_view.findViewById(R.id.cookie_onion)).getText().toString();
-                String cookie = ((EditText) dialog_view.findViewById(R.id.cookie_value)).getText().toString();
-
-                if (checkInput(onion, cookie)) {
-                    saveData(onion, cookie);
-                    Toast.makeText(
-                            v.getContext(), R.string.please_restart_Orbot_to_enable_the_changes, Toast.LENGTH_LONG
-                    ).show();
-                    addCookieDialog.dismiss();
-                }
+        save.setOnClickListener(v -> {
+            String onion = ((EditText) dialog_view.findViewById(R.id.cookie_onion)).getText().toString();
+            String cookie = ((EditText) dialog_view.findViewById(R.id.cookie_value)).getText().toString();
+
+            if (checkInput(onion, cookie)) {
+                saveData(onion, cookie);
+                Toast.makeText(
+                        v.getContext(), R.string.please_restart_Orbot_to_enable_the_changes, Toast.LENGTH_LONG
+                ).show();
+                addCookieDialog.dismiss();
             }
         });
 
         Button cancel = dialog_view.findViewById(R.id.cookie_dialog_cancel);
-        cancel.setOnClickListener(new View.OnClickListener() {
-            public void onClick(View v) {
-                addCookieDialog.cancel();
-            }
-        });
+        cancel.setOnClickListener(v -> addCookieDialog.cancel());
 
         return addCookieDialog;
     }
diff --git a/app/src/main/java/org/torproject/android/ui/hiddenservices/dialogs/CookieActionsDialog.java b/app/src/main/java/org/torproject/android/ui/hiddenservices/dialogs/CookieActionsDialog.java
index c8f3db25..dcd00cc3 100644
--- a/app/src/main/java/org/torproject/android/ui/hiddenservices/dialogs/CookieActionsDialog.java
+++ b/app/src/main/java/org/torproject/android/ui/hiddenservices/dialogs/CookieActionsDialog.java
@@ -29,26 +29,16 @@ public class CookieActionsDialog extends DialogFragment {
                 .setTitle(R.string.client_cookies)
                 .create();
 
-        dialog_view.findViewById(R.id.btn_cookie_backup).setOnClickListener(new View.OnClickListener() {
-            public void onClick(View v) {
-                doBackup();
-            }
-        });
+        dialog_view.findViewById(R.id.btn_cookie_backup).setOnClickListener(v -> doBackup());
 
-        dialog_view.findViewById(R.id.btn_cookie_delete).setOnClickListener(new View.OnClickListener() {
-            public void onClick(View v) {
-                CookieDeleteDialog dialog = new CookieDeleteDialog();
-                dialog.setArguments(arguments);
-                dialog.show(getFragmentManager(), "CookieDeleteDialog");
-                actionDialog.dismiss();
-            }
+        dialog_view.findViewById(R.id.btn_cookie_delete).setOnClickListener(v -> {
+            CookieDeleteDialog dialog = new CookieDeleteDialog();
+            dialog.setArguments(arguments);
+            dialog.show(getFragmentManager(), "CookieDeleteDialog");
+            actionDialog.dismiss();
         });
 
-        dialog_view.findViewById(R.id.btn_cookie_cancel).setOnClickListener(new View.OnClickListener() {
-            public void onClick(View v) {
-                actionDialog.dismiss();
-            }
-        });
+        dialog_view.findViewById(R.id.btn_cookie_cancel).setOnClickListener(v -> actionDialog.dismiss());
 
         return actionDialog;
     }
diff --git a/app/src/main/java/org/torproject/android/ui/hiddenservices/dialogs/CookieDeleteDialog.java b/app/src/main/java/org/torproject/android/ui/hiddenservices/dialogs/CookieDeleteDialog.java
index ed847cdc..f8338803 100644
--- a/app/src/main/java/org/torproject/android/ui/hiddenservices/dialogs/CookieDeleteDialog.java
+++ b/app/src/main/java/org/torproject/android/ui/hiddenservices/dialogs/CookieDeleteDialog.java
@@ -19,24 +19,21 @@ public class CookieDeleteDialog extends DialogFragment {
         final Bundle arguments = getArguments();
         final Context context = getContext();
 
-        DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
-            @Override
-            public void onClick(DialogInterface dialog, int which) {
-                switch (which) {
-                    case DialogInterface.BUTTON_POSITIVE:
-                        // Delete from db
-                        context.getContentResolver().delete(
-                                CookieContentProvider.CONTENT_URI,
-                                CookieContentProvider.ClientCookie._ID + "=" + arguments.getInt("_id"),
-                                null
-                        );
-
-                        break;
-
-                    case DialogInterface.BUTTON_NEGATIVE:
-                        // Do nothing
-                        break;
-                }
+        DialogInterface.OnClickListener dialogClickListener = (dialog, which) -> {
+            switch (which) {
+                case DialogInterface.BUTTON_POSITIVE:
+                    // Delete from db
+                    context.getContentResolver().delete(
+                            CookieContentProvider.CONTENT_URI,
+                            CookieContentProvider.ClientCookie._ID + "=" + arguments.getInt("_id"),
+                            null
+                    );
+
+                    break;
+
+                case DialogInterface.BUTTON_NEGATIVE:
+                    // Do nothing
+                    break;
             }
         };
 
diff --git a/app/src/main/java/org/torproject/android/ui/hiddenservices/dialogs/HSActionsDialog.java b/app/src/main/java/org/torproject/android/ui/hiddenservices/dialogs/HSActionsDialog.java
index 8e7ff7e8..b250c3db 100644
--- a/app/src/main/java/org/torproject/android/ui/hiddenservices/dialogs/HSActionsDialog.java
+++ b/app/src/main/java/org/torproject/android/ui/hiddenservices/dialogs/HSActionsDialog.java
@@ -14,7 +14,6 @@ import androidx.fragment.app.DialogFragment;
 import androidx.appcompat.app.AlertDialog;
 
 import android.view.View;
-import android.widget.Button;
 import android.widget.Toast;
 
 import org.torproject.android.R;
@@ -36,62 +35,48 @@ public class HSActionsDialog extends DialogFragment {
                 .setTitle(R.string.hidden_services)
                 .create();
 
-        dialog_view.findViewById(R.id.btn_hs_backup).setOnClickListener(new View.OnClickListener() {
-            public void onClick(View v) {
-                doBackup();
-            }
-        });
+        dialog_view.findViewById(R.id.btn_hs_backup).setOnClickListener(v -> doBackup());
 
-        dialog_view.findViewById(R.id.btn_hs_clipboard).setOnClickListener(new View.OnClickListener() {
-            public void onClick(View v) {
-                Context mContext = v.getContext();
-                ClipboardManager clipboard = (ClipboardManager) mContext.getSystemService(Context.CLIPBOARD_SERVICE);
-                ClipData clip = ClipData.newPlainText("onion", arguments.getString("onion"));
-                clipboard.setPrimaryClip(clip);
-                Toast.makeText(mContext, R.string.done, Toast.LENGTH_LONG).show();
-                actionDialog.dismiss();
-            }
+        dialog_view.findViewById(R.id.btn_hs_clipboard).setOnClickListener(v -> {
+            Context mContext = v.getContext();
+            ClipboardManager clipboard = (ClipboardManager) mContext.getSystemService(Context.CLIPBOARD_SERVICE);
+            ClipData clip = ClipData.newPlainText("onion", arguments.getString("onion"));
+            clipboard.setPrimaryClip(clip);
+            Toast.makeText(mContext, R.string.done, Toast.LENGTH_LONG).show();
+            actionDialog.dismiss();
         });
 
-        dialog_view.findViewById(R.id.bt_hs_show_auth).setOnClickListener(new View.OnClickListener() {
-            public void onClick(View v) {
-                String auth_cookie_value = arguments.getString("auth_cookie_value");
-
-                if (arguments.getInt("auth_cookie") == 1) {
-                    if (auth_cookie_value == null || auth_cookie_value.length() < 1) {
-                        Toast.makeText(
-                                v.getContext(), R.string.please_restart_Orbot_to_enable_the_changes, Toast.LENGTH_LONG
-                        ).show();
-                    } else {
-                        HSCookieDialog dialog = new HSCookieDialog();
-                        dialog.setArguments(arguments);
-                        dialog.show(getFragmentManager(), "HSCookieDialog");
-                    }
-                } else {
+        dialog_view.findViewById(R.id.bt_hs_show_auth).setOnClickListener(v -> {
+            String auth_cookie_value = arguments.getString("auth_cookie_value");
+
+            if (arguments.getInt("auth_cookie") == 1) {
+                if (auth_cookie_value == null || auth_cookie_value.length() < 1) {
                     Toast.makeText(
-                            v.getContext(), R.string.auth_cookie_was_not_configured, Toast.LENGTH_LONG
+                            v.getContext(), R.string.please_restart_Orbot_to_enable_the_changes, Toast.LENGTH_LONG
                     ).show();
+                } else {
+                    HSCookieDialog dialog = new HSCookieDialog();
+                    dialog.setArguments(arguments);
+                    dialog.show(getFragmentManager(), "HSCookieDialog");
                 }
-
-                actionDialog.dismiss();
+            } else {
+                Toast.makeText(
+                        v.getContext(), R.string.auth_cookie_was_not_configured, Toast.LENGTH_LONG
+                ).show();
             }
-        });
 
-        dialog_view.findViewById(R.id.btn_hs_delete).setOnClickListener(new View.OnClickListener() {
-            public void onClick(View v) {
-                HSDeleteDialog dialog = new HSDeleteDialog();
-                dialog.setArguments(arguments);
-                dialog.show(getFragmentManager(), "HSDeleteDialog");
-                actionDialog.dismiss();
-            }
+            actionDialog.dismiss();
         });
 
-        dialog_view.findViewById(R.id.btn_hs_cancel).setOnClickListener(new View.OnClickListener() {
-            public void onClick(View v) {
-                actionDialog.dismiss();
-            }
+        dialog_view.findViewById(R.id.btn_hs_delete).setOnClickListener(v -> {
+            HSDeleteDialog dialog = new HSDeleteDialog();
+            dialog.setArguments(arguments);
+            dialog.show(getFragmentManager(), "HSDeleteDialog");
+            actionDialog.dismiss();
         });
 
+        dialog_view.findViewById(R.id.btn_hs_cancel).setOnClickListener(v -> actionDialog.dismiss());
+
         return actionDialog;
     }
 
diff --git a/app/src/main/java/org/torproject/android/ui/hiddenservices/dialogs/HSCookieDialog.java b/app/src/main/java/org/torproject/android/ui/hiddenservices/dialogs/HSCookieDialog.java
index 054516fb..ce71a96f 100644
--- a/app/src/main/java/org/torproject/android/ui/hiddenservices/dialogs/HSCookieDialog.java
+++ b/app/src/main/java/org/torproject/android/ui/hiddenservices/dialogs/HSCookieDialog.java
@@ -32,48 +32,40 @@ public class HSCookieDialog extends DialogFragment {
                 .setView(dialog_view)
                 .create();
 
-        TextView cookie = (TextView) dialog_view.findViewById(R.id.hs_cookie);
+        TextView cookie = dialog_view.findViewById(R.id.hs_cookie);
         cookie.setText(auth_cookie_value);
 
-        Button clipboard = (Button) dialog_view.findViewById(R.id.hs_cookie_to_clipboard);
-        clipboard.setOnClickListener(new View.OnClickListener() {
-            public void onClick(View v) {
-                Context mContext = v.getContext();
-                ClipboardManager clipboard = (ClipboardManager) mContext.getSystemService(Context.CLIPBOARD_SERVICE);
-                ClipData clip = ClipData.newPlainText("cookie", auth_cookie_value);
-                clipboard.setPrimaryClip(clip);
-                Toast.makeText(mContext, R.string.done, Toast.LENGTH_LONG).show();
-                cookieDialog.dismiss();
-            }
+        Button clipboard = dialog_view.findViewById(R.id.hs_cookie_to_clipboard);
+        clipboard.setOnClickListener(v -> {
+            Context mContext = v.getContext();
+            ClipboardManager clipboard1 = (ClipboardManager) mContext.getSystemService(Context.CLIPBOARD_SERVICE);
+            ClipData clip = ClipData.newPlainText("cookie", auth_cookie_value);
+            clipboard1.setPrimaryClip(clip);
+            Toast.makeText(mContext, R.string.done, Toast.LENGTH_LONG).show();
+            cookieDialog.dismiss();
         });
 
-        Button shareQR = (Button) dialog_view.findViewById(R.id.hs_cookie_to_qr);
-        shareQR.setOnClickListener(new View.OnClickListener() {
-            public void onClick(View v) {
-                try {
-                    JSONObject backup = new JSONObject();
-                    backup.put(CookieContentProvider.ClientCookie.DOMAIN, arguments.getString("onion"));
-                    backup.put(CookieContentProvider.ClientCookie.AUTH_COOKIE_VALUE, arguments.getString("auth_cookie_value"));
-
-                    IntentIntegrator integrator = new IntentIntegrator(getActivity());
-                    integrator.shareText(backup.toString());
+        Button shareQR = dialog_view.findViewById(R.id.hs_cookie_to_qr);
+        shareQR.setOnClickListener(v -> {
+            try {
+                JSONObject backup = new JSONObject();
+                backup.put(CookieContentProvider.ClientCookie.DOMAIN, arguments.getString("onion"));
+                backup.put(CookieContentProvider.ClientCookie.AUTH_COOKIE_VALUE, arguments.getString("auth_cookie_value"));
 
-                } catch (JSONException e) {
-                    // TODO Auto-generated catch block
-                    e.printStackTrace();
-                }
+                IntentIntegrator integrator = new IntentIntegrator(getActivity());
+                integrator.shareText(backup.toString());
 
-                cookieDialog.dismiss();
+            } catch (JSONException e) {
+                // TODO Auto-generated catch block
+                e.printStackTrace();
             }
-        });
 
-        Button cancel = (Button) dialog_view.findViewById(R.id.hs_cookie_cancel);
-        cancel.setOnClickListener(new View.OnClickListener() {
-            public void onClick(View v) {
-                cookieDialog.dismiss();
-            }
+            cookieDialog.dismiss();
         });
 
+        Button cancel = dialog_view.findViewById(R.id.hs_cookie_cancel);
+        cancel.setOnClickListener(v -> cookieDialog.dismiss());
+
         return cookieDialog;
     }
 }
diff --git a/app/src/main/java/org/torproject/android/ui/hiddenservices/dialogs/HSDataDialog.java b/app/src/main/java/org/torproject/android/ui/hiddenservices/dialogs/HSDataDialog.java
index ee3ac343..28c1d716 100644
--- a/app/src/main/java/org/torproject/android/ui/hiddenservices/dialogs/HSDataDialog.java
+++ b/app/src/main/java/org/torproject/android/ui/hiddenservices/dialogs/HSDataDialog.java
@@ -35,35 +35,29 @@ public class HSDataDialog extends DialogFragment {
 
         // Buttons action
         Button save = dialog_view.findViewById(R.id.HSDialogSave);
-        save.setOnClickListener(new View.OnClickListener() {
-            public void onClick(View v) {
-                String serverName = ((EditText) dialog_view.findViewById(R.id.hsName)).getText().toString();
-                int localPort, onionPort;
-                try {
-                    localPort = Integer.parseInt(((EditText) dialog_view.findViewById(R.id.hsLocalPort)).getText().toString());
-                    onionPort = Integer.parseInt(((EditText) dialog_view.findViewById(R.id.hsOnionPort)).getText().toString());
-                } catch (NumberFormatException nfe) {
-                    Toast.makeText(v.getContext(), R.string.fields_can_t_be_empty, Toast.LENGTH_LONG).show();
-                    return;
-                }
-                boolean authCookie = ((CheckBox) dialog_view.findViewById(R.id.hsAuth)).isChecked();
-
-                if (checkInput(serverName, localPort, onionPort)) {
-                    saveData(serverName, localPort, onionPort, authCookie);
-                    Toast.makeText(
-                            v.getContext(), R.string.please_restart_Orbot_to_enable_the_changes, Toast.LENGTH_LONG
-                    ).show();
-                    serviceDataDialog.dismiss();
-                }
+        save.setOnClickListener(v -> {
+            String serverName = ((EditText) dialog_view.findViewById(R.id.hsName)).getText().toString();
+            int localPort, onionPort;
+            try {
+                localPort = Integer.parseInt(((EditText) dialog_view.findViewById(R.id.hsLocalPort)).getText().toString());
+                onionPort = Integer.parseInt(((EditText) dialog_view.findViewById(R.id.hsOnionPort)).getText().toString());
+            } catch (NumberFormatException nfe) {
+                Toast.makeText(v.getContext(), R.string.fields_can_t_be_empty, Toast.LENGTH_LONG).show();
+                return;
+            }
+            boolean authCookie = ((CheckBox) dialog_view.findViewById(R.id.hsAuth)).isChecked();
+
+            if (checkInput(serverName, localPort, onionPort)) {
+                saveData(serverName, localPort, onionPort, authCookie);
+                Toast.makeText(
+                        v.getContext(), R.string.please_restart_Orbot_to_enable_the_changes, Toast.LENGTH_LONG
+                ).show();
+                serviceDataDialog.dismiss();
             }
         });
 
         Button cancel = dialog_view.findViewById(R.id.HSDialogCancel);
-        cancel.setOnClickListener(new View.OnClickListener() {
-            public void onClick(View v) {
-                serviceDataDialog.cancel();
-            }
-        });
+        cancel.setOnClickListener(v -> serviceDataDialog.cancel());
 
         return serviceDataDialog;
     }
diff --git a/app/src/main/java/org/torproject/android/ui/hiddenservices/dialogs/HSDeleteDialog.java b/app/src/main/java/org/torproject/android/ui/hiddenservices/dialogs/HSDeleteDialog.java
index 27a547f8..1712d937 100644
--- a/app/src/main/java/org/torproject/android/ui/hiddenservices/dialogs/HSDeleteDialog.java
+++ b/app/src/main/java/org/torproject/android/ui/hiddenservices/dialogs/HSDeleteDialog.java
@@ -22,36 +22,33 @@ public class HSDeleteDialog extends DialogFragment {
         final Bundle arguments = getArguments();
         final Context context = getContext();
 
-        DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
-            @Override
-            public void onClick(DialogInterface dialog, int which) {
-                switch (which) {
-                    case DialogInterface.BUTTON_POSITIVE:
-                        // Delete from db
-                        context.getContentResolver().delete(
-                                HSContentProvider.CONTENT_URI,
-                                HSContentProvider.HiddenService._ID + "=" + arguments.getInt("_id"),
-                                null
-                        );
-
-                        // Delete from internal storage
-                        String base = context.getFilesDir().getAbsolutePath() + "/" + TorServiceConstants.HIDDEN_SERVICES_DIR;
-                        File dir = new File(base, "hs" + arguments.getString("port"));
-
-                        if (dir.isDirectory()) {
-                            String[] children = dir.list();
-                            for (String aChildren : children) {
-                                new File(dir, aChildren).delete();
-                            }
-                            dir.delete();
+        DialogInterface.OnClickListener dialogClickListener = (dialog, which) -> {
+            switch (which) {
+                case DialogInterface.BUTTON_POSITIVE:
+                    // Delete from db
+                    context.getContentResolver().delete(
+                            HSContentProvider.CONTENT_URI,
+                            HSContentProvider.HiddenService._ID + "=" + arguments.getInt("_id"),
+                            null
+                    );
+
+                    // Delete from internal storage
+                    String base = context.getFilesDir().getAbsolutePath() + "/" + TorServiceConstants.HIDDEN_SERVICES_DIR;
+                    File dir = new File(base, "hs" + arguments.getString("port"));
+
+                    if (dir.isDirectory()) {
+                        String[] children = dir.list();
+                        for (String aChildren : children) {
+                            new File(dir, aChildren).delete();
                         }
+                        dir.delete();
+                    }
 
-                        break;
+                    break;
 
-                    case DialogInterface.BUTTON_NEGATIVE:
-                        // Do nothing
-                        break;
-                }
+                case DialogInterface.BUTTON_NEGATIVE:
+                    // Do nothing
+                    break;
             }
         };
 
diff --git a/app/src/main/java/org/torproject/android/ui/hiddenservices/dialogs/SelectCookieBackupDialog.java b/app/src/main/java/org/torproject/android/ui/hiddenservices/dialogs/SelectCookieBackupDialog.java
index a8e380d9..120b0693 100644
--- a/app/src/main/java/org/torproject/android/ui/hiddenservices/dialogs/SelectCookieBackupDialog.java
+++ b/app/src/main/java/org/torproject/android/ui/hiddenservices/dialogs/SelectCookieBackupDialog.java
@@ -1,13 +1,11 @@
 package org.torproject.android.ui.hiddenservices.dialogs;
 
 import android.app.Dialog;
-import android.content.DialogInterface;
 import android.os.Bundle;
 import androidx.annotation.NonNull;
 import androidx.fragment.app.DialogFragment;
 import androidx.appcompat.app.AlertDialog;
 import android.view.View;
-import android.widget.AdapterView;
 import android.widget.ListView;
 import org.torproject.android.R;
 import org.torproject.android.ui.hiddenservices.adapters.BackupAdapter;
@@ -15,7 +13,6 @@ import org.torproject.android.ui.hiddenservices.backup.BackupUtils;
 import org.torproject.android.ui.hiddenservices.storage.ExternalStorage;
 
 import java.io.File;
-import java.io.FilenameFilter;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
@@ -33,23 +30,14 @@ public class SelectCookieBackupDialog extends DialogFragment {
         File[] files = null;
 
         try {
-            files = backupDir.listFiles(new FilenameFilter() {
-                @Override
-                public boolean accept(File dir, String name) {
-                    return name.toLowerCase().endsWith(".json");
-                }
-            });
+            files = backupDir.listFiles((dir, name) -> name.toLowerCase().endsWith(".json"));
         } catch (NullPointerException e) {
             // Silent block
         }
 
         if (files == null || files.length < 1) {
             cookieBackupDialog.setMessage(R.string.create_a_backup_first);
-            cookieBackupDialog.setNegativeButton(R.string.btn_cancel, new DialogInterface.OnClickListener() {
-                public void onClick(DialogInterface dialog, int id) {
-                    dialog.dismiss();
-                }
-            });
+            cookieBackupDialog.setNegativeButton(R.string.btn_cancel, (dialog, id) -> dialog.dismiss());
 
             return cookieBackupDialog.create();
         }
@@ -57,25 +45,18 @@ public class SelectCookieBackupDialog extends DialogFragment {
         final View dialog_view = getActivity().getLayoutInflater().inflate(R.layout.layout_hs_backups_list, null);
 
         cookieBackupDialog.setView(dialog_view);
-        cookieBackupDialog.setPositiveButton(R.string.btn_okay, new DialogInterface.OnClickListener() {
-            public void onClick(DialogInterface dialog, int id) {
-                dialog.dismiss();
-            }
-        });
+        cookieBackupDialog.setPositiveButton(R.string.btn_okay, (dialog, id) -> dialog.dismiss());
 
-        ListView backups = (ListView) dialog_view.findViewById(R.id.listview_hs_backups);
+        ListView backups = dialog_view.findViewById(R.id.listview_hs_backups);
 
         List<File> json_backups = new ArrayList<>();
         Collections.addAll(json_backups, files);
 
         backups.setAdapter(new BackupAdapter(getContext(), R.layout.layout_hs_backups_list_item, json_backups));
-        backups.setOnItemClickListener(new AdapterView.OnItemClickListener() {
-            @Override
-            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
-                BackupUtils backupUtils = new BackupUtils(view.getContext().getApplicationContext());
-                File p = (File) parent.getItemAtPosition(position);
-                backupUtils.restoreCookieBackup(p);
-            }
+        backups.setOnItemClickListener((parent, view, position, id) -> {
+            BackupUtils backupUtils = new BackupUtils(view.getContext().getApplicationContext());
+            File p = (File) parent.getItemAtPosition(position);
+            backupUtils.restoreCookieBackup(p);
         });
 
         return cookieBackupDialog.create();
diff --git a/app/src/main/java/org/torproject/android/ui/hiddenservices/dialogs/SelectHSBackupDialog.java b/app/src/main/java/org/torproject/android/ui/hiddenservices/dialogs/SelectHSBackupDialog.java
index ae15ae49..6f02f872 100644
--- a/app/src/main/java/org/torproject/android/ui/hiddenservices/dialogs/SelectHSBackupDialog.java
+++ b/app/src/main/java/org/torproject/android/ui/hiddenservices/dialogs/SelectHSBackupDialog.java
@@ -1,13 +1,11 @@
 package org.torproject.android.ui.hiddenservices.dialogs;
 
 import android.app.Dialog;
-import android.content.DialogInterface;
 import android.os.Bundle;
 import androidx.annotation.NonNull;
 import androidx.fragment.app.DialogFragment;
 import androidx.appcompat.app.AlertDialog;
 import android.view.View;
-import android.widget.AdapterView;
 import android.widget.ListView;
 import org.torproject.android.R;
 import org.torproject.android.ui.hiddenservices.adapters.BackupAdapter;
@@ -15,7 +13,6 @@ import org.torproject.android.ui.hiddenservices.backup.BackupUtils;
 import org.torproject.android.ui.hiddenservices.storage.ExternalStorage;
 
 import java.io.File;
-import java.io.FilenameFilter;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
@@ -33,23 +30,14 @@ public class SelectHSBackupDialog extends DialogFragment {
         File[] files = null;
 
         try {
-            files = backupDir.listFiles(new FilenameFilter() {
-                @Override
-                public boolean accept(File dir, String name) {
-                    return name.toLowerCase().endsWith(".zip");
-                }
-            });
+            files = backupDir.listFiles((dir, name) -> name.toLowerCase().endsWith(".zip"));
         } catch (NullPointerException e) {
             // Silent block
         }
 
         if (files == null || files.length < 1) {
             backupsDialog.setMessage(R.string.create_a_backup_first);
-            backupsDialog.setNegativeButton(R.string.btn_cancel, new DialogInterface.OnClickListener() {
-                public void onClick(DialogInterface dialog, int id) {
-                    dialog.dismiss();
-                }
-            });
+            backupsDialog.setNegativeButton(R.string.btn_cancel, (dialog, id) -> dialog.dismiss());
 
             return backupsDialog.create();
         }
@@ -57,25 +45,18 @@ public class SelectHSBackupDialog extends DialogFragment {
         final View dialog_view = getActivity().getLayoutInflater().inflate(R.layout.layout_hs_backups_list, null);
 
         backupsDialog.setView(dialog_view);
-        backupsDialog.setPositiveButton(R.string.btn_okay, new DialogInterface.OnClickListener() {
-            public void onClick(DialogInterface dialog, int id) {
-                dialog.dismiss();
-            }
-        });
+        backupsDialog.setPositiveButton(R.string.btn_okay, (dialog, id) -> dialog.dismiss());
 
-        ListView backups = (ListView) dialog_view.findViewById(R.id.listview_hs_backups);
+        ListView backups = dialog_view.findViewById(R.id.listview_hs_backups);
 
         List<File> zips = new ArrayList<>();
         Collections.addAll(zips, files);
 
         backups.setAdapter(new BackupAdapter(getContext(), R.layout.layout_hs_backups_list_item, zips));
-        backups.setOnItemClickListener(new AdapterView.OnItemClickListener() {
-            @Override
-            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
-                BackupUtils backupUtils = new BackupUtils(view.getContext().getApplicationContext());
-                File p = (File) parent.getItemAtPosition(position);
-                backupUtils.restoreZipBackup(p);
-            }
+        backups.setOnItemClickListener((parent, view, position, id) -> {
+            BackupUtils backupUtils = new BackupUtils(view.getContext().getApplicationContext());
+            File p = (File) parent.getItemAtPosition(position);
+            backupUtils.restoreZipBackup(p);
         });
 
         return backupsDialog.create();
diff --git a/app/src/main/java/org/torproject/android/ui/hiddenservices/permissions/PermissionManager.java b/app/src/main/java/org/torproject/android/ui/hiddenservices/permissions/PermissionManager.java
index eb1a40b4..95bacd59 100644
--- a/app/src/main/java/org/torproject/android/ui/hiddenservices/permissions/PermissionManager.java
+++ b/app/src/main/java/org/torproject/android/ui/hiddenservices/permissions/PermissionManager.java
@@ -14,7 +14,7 @@ import android.provider.Settings;
 import com.google.android.material.snackbar.Snackbar;
 import androidx.core.app.ActivityCompat;
 import androidx.fragment.app.FragmentActivity;
-import android.view.View;
+
 import org.torproject.android.R;
 
 public class PermissionManager {
@@ -38,14 +38,9 @@ public class PermissionManager {
             Snackbar.make(mActivity.findViewById(android.R.id.content),
                     R.string.please_grant_permissions_for_external_storage,
                     Snackbar.LENGTH_INDEFINITE).setAction(R.string.activate,
-                    new View.OnClickListener() {
-                        @Override
-                        public void onClick(View v) {
-                            ActivityCompat.requestPermissions(mActivity,
-                                    new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
-                                    mAction);
-                        }
-                    }).show();
+                    v -> ActivityCompat.requestPermissions(mActivity,
+                            new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
+                            mAction)).show();
         } else {
             ActivityCompat.requestPermissions(mActivity,
                     new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
@@ -65,14 +60,11 @@ public class PermissionManager {
         Snackbar.make(activity.findViewById(android.R.id.content),
                 R.string.consider_disable_battery_optimizations,
                 VERY_LONG_LENGTH).setAction(R.string.disable,
-                new View.OnClickListener() {
-                    @Override
-                    public void onClick(View v) {
-                        Intent intent = new Intent();
-                        intent.setAction(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS);
-                        intent.setData(Uri.parse("package:" + packageName));
-                        mContext.startActivity(intent);
-                    }
+                v -> {
+                    Intent intent = new Intent();
+                    intent.setAction(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS);
+                    intent.setData(Uri.parse("package:" + packageName));
+                    mContext.startActivity(intent);
                 }).show();
     }
 
@@ -89,13 +81,10 @@ public class PermissionManager {
         Snackbar.make(activity.findViewById(android.R.id.content),
                 R.string.consider_enable_battery_optimizations,
                 VERY_LONG_LENGTH).setAction(R.string.enable,
-                new View.OnClickListener() {
-                    @Override
-                    public void onClick(View v) {
-                        Intent intent = new Intent();
-                        intent.setAction(Settings.ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS);
-                        mContext.startActivity(intent);
-                    }
+                v -> {
+                    Intent intent = new Intent();
+                    intent.setAction(Settings.ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS);
+                    mContext.startActivity(intent);
                 }).show();
     }
 }
diff --git a/app/src/main/java/org/torproject/android/ui/hiddenservices/storage/ExternalStorage.java b/app/src/main/java/org/torproject/android/ui/hiddenservices/storage/ExternalStorage.java
index c50108b7..f3780f87 100644
--- a/app/src/main/java/org/torproject/android/ui/hiddenservices/storage/ExternalStorage.java
+++ b/app/src/main/java/org/torproject/android/ui/hiddenservices/storage/ExternalStorage.java
@@ -20,15 +20,9 @@ public class ExternalStorage {
     }
 
     /* Checks if external storage is available for read and write */
-    public static boolean isExternalStorageWritable() {
+    private static boolean isExternalStorageWritable() {
         String state = Environment.getExternalStorageState();
         return Environment.MEDIA_MOUNTED.equals(state);
     }
 
-    /* Checks if external storage is available to at least read */
-    public static boolean isExternalStorageReadable() {
-        String state = Environment.getExternalStorageState();
-        return Environment.MEDIA_MOUNTED.equals(state) ||
-                Environment.MEDIA_MOUNTED_READ_ONLY.equals(state);
-    }
 }
diff --git a/app/src/main/java/org/torproject/android/ui/onboarding/BridgeWizardActivity.java b/app/src/main/java/org/torproject/android/ui/onboarding/BridgeWizardActivity.java
index 7f7561ba..6b76a3f2 100644
--- a/app/src/main/java/org/torproject/android/ui/onboarding/BridgeWizardActivity.java
+++ b/app/src/main/java/org/torproject/android/ui/onboarding/BridgeWizardActivity.java
@@ -53,53 +53,34 @@ public class BridgeWizardActivity extends AppCompatActivity {
 
         setTitle(getString(R.string.bridges));
 
-        findViewById(R.id.btnMoat).setOnClickListener(new View.OnClickListener() {
-            @Override
-            public void onClick(View v) {
-                startActivityForResult(new Intent(BridgeWizardActivity.this, MoatActivity.class),
-                        MOAT_REQUEST_CODE);
-            }
-        });
+        findViewById(R.id.btnMoat).setOnClickListener(v -> startActivityForResult(new Intent(BridgeWizardActivity.this, MoatActivity.class),
+                MOAT_REQUEST_CODE));
 
         mBtDirect = findViewById(R.id.btnBridgesDirect);
-        mBtDirect.setOnClickListener(new View.OnClickListener() {
-            @Override
-            public void onClick(View v) {
-                Prefs.setBridgesList("");
-                Prefs.putBridgesEnabled(false);
-                testBridgeConnection();
-            }
+        mBtDirect.setOnClickListener(v -> {
+            Prefs.setBridgesList("");
+            Prefs.putBridgesEnabled(false);
+            testBridgeConnection();
         });
 
         mBtObfs4 = findViewById(R.id.btnBridgesObfs4);
-        mBtObfs4.setOnClickListener(new View.OnClickListener() {
-            @Override
-            public void onClick(View v) {
-                Prefs.setBridgesList("obfs4");
-                Prefs.putBridgesEnabled(true);
-                testBridgeConnection();
-            }
+        mBtObfs4.setOnClickListener(v -> {
+            Prefs.setBridgesList("obfs4");
+            Prefs.putBridgesEnabled(true);
+            testBridgeConnection();
         });
 
 
         mBtMeek = findViewById(R.id.btnBridgesMeek);
-        mBtMeek.setOnClickListener(new View.OnClickListener() {
-            @Override
-            public void onClick(View v) {
-                Prefs.setBridgesList("meek");
-                Prefs.putBridgesEnabled(true);
-                testBridgeConnection();
-            }
+        mBtMeek.setOnClickListener(v -> {
+            Prefs.setBridgesList("meek");
+            Prefs.putBridgesEnabled(true);
+            testBridgeConnection();
         });
 
 
         mBtCustom = findViewById(R.id.btnCustomBridges);
-        mBtCustom.setOnClickListener(new View.OnClickListener() {
-            @Override
-            public void onClick(View view) {
-                startActivity(new Intent(BridgeWizardActivity.this, CustomBridgesActivity.class));
-            }
-        });
+        mBtCustom.setOnClickListener(view -> startActivity(new Intent(BridgeWizardActivity.this, CustomBridgesActivity.class)));
     }
 
     @Override
diff --git a/app/src/main/java/org/torproject/android/ui/onboarding/CustomBridgesActivity.java b/app/src/main/java/org/torproject/android/ui/onboarding/CustomBridgesActivity.java
index 5e2b3dd6..c581fd53 100644
--- a/app/src/main/java/org/torproject/android/ui/onboarding/CustomBridgesActivity.java
+++ b/app/src/main/java/org/torproject/android/ui/onboarding/CustomBridgesActivity.java
@@ -226,15 +226,12 @@ public class CustomBridgesActivity extends AppCompatActivity implements View.OnC
         et.setOverScrollMode(View.OVER_SCROLL_ALWAYS);
         et.setScrollBarStyle(View.SCROLLBARS_INSIDE_INSET);
         et.setMovementMethod(ScrollingMovementMethod.getInstance());
-        et.setOnTouchListener(new View.OnTouchListener() {
-            @Override
-            public boolean onTouch(View v, MotionEvent event) {
-                v.getParent().requestDisallowInterceptTouchEvent(true);
-                if ((event.getAction() & MotionEvent.ACTION_UP) != 0 && (event.getActionMasked() & MotionEvent.ACTION_UP) != 0) {
-                    v.getParent().requestDisallowInterceptTouchEvent(false);
-                }
-                return false;
+        et.setOnTouchListener((v, event) -> {
+            v.getParent().requestDisallowInterceptTouchEvent(true);
+            if ((event.getAction() & MotionEvent.ACTION_UP) != 0 && (event.getActionMasked() & MotionEvent.ACTION_UP) != 0) {
+                v.getParent().requestDisallowInterceptTouchEvent(false);
             }
+            return false;
         });
     }
 }
diff --git a/app/src/main/java/org/torproject/android/ui/onboarding/MoatActivity.java b/app/src/main/java/org/torproject/android/ui/onboarding/MoatActivity.java
index 69e9e9e2..588c6952 100644
--- a/app/src/main/java/org/torproject/android/ui/onboarding/MoatActivity.java
+++ b/app/src/main/java/org/torproject/android/ui/onboarding/MoatActivity.java
@@ -34,7 +34,6 @@ import com.android.volley.DefaultRetryPolicy;
 import com.android.volley.Request;
 import com.android.volley.RequestQueue;
 import com.android.volley.Response;
-import com.android.volley.VolleyError;
 import com.android.volley.toolbox.JsonObjectRequest;
 import com.android.volley.toolbox.Volley;
 
@@ -243,31 +242,28 @@ public class MoatActivity extends AppCompatActivity implements View.OnClickListe
     private void fetchCaptcha() {
         JsonObjectRequest request = buildRequest("fetch",
                 "\"type\": \"client-transports\", \"supported\": [\"obfs4\"]",
-                new Response.Listener<JSONObject>() {
-                    @Override
-                    public void onResponse(JSONObject response) {
-                        mRequestInProgress = false;
-                        invalidateOptionsMenu();
-                        mProgressBar.setVisibility(View.GONE);
-
-                        try {
-                            JSONObject data = response.getJSONArray("data").getJSONObject(0);
-                            mChallenge = data.getString("challenge");
-
-                            mCaptcha = Base64.decode(data.getString("image"), Base64.DEFAULT);
-                            mIvCaptcha.setImageBitmap(BitmapFactory.decodeByteArray(mCaptcha, 0, mCaptcha.length));
-                            mIvCaptcha.setVisibility(View.VISIBLE);
-                            mEtSolution.setText(null);
-                            mEtSolution.setEnabled(true);
-                            mBtRequest.setEnabled(true);
-
-                        } catch (JSONException e) {
-                            Log.d(MoatActivity.class.getSimpleName(), "Error decoding answer: " + response.toString());
-
-                            displayError(e, response);
-                        }
-
+                response -> {
+                    mRequestInProgress = false;
+                    invalidateOptionsMenu();
+                    mProgressBar.setVisibility(View.GONE);
+
+                    try {
+                        JSONObject data = response.getJSONArray("data").getJSONObject(0);
+                        mChallenge = data.getString("challenge");
+
+                        mCaptcha = Base64.decode(data.getString("image"), Base64.DEFAULT);
+                        mIvCaptcha.setImageBitmap(BitmapFactory.decodeByteArray(mCaptcha, 0, mCaptcha.length));
+                        mIvCaptcha.setVisibility(View.VISIBLE);
+                        mEtSolution.setText(null);
+                        mEtSolution.setEnabled(true);
+                        mBtRequest.setEnabled(true);
+
+                    } catch (JSONException e) {
+                        Log.d(MoatActivity.class.getSimpleName(), "Error decoding answer: " + response.toString());
+
+                        displayError(e, response);
                     }
+
                 });
 
         if (request != null) {
@@ -288,38 +284,35 @@ public class MoatActivity extends AppCompatActivity implements View.OnClickListe
         JsonObjectRequest request = buildRequest("check",
                 "\"id\": \"2\", \"type\": \"moat-solution\", \"transport\": \"obfs4\", \"challenge\": \""
                         + mChallenge + "\", \"solution\": \"" + solution + "\", \"qrcode\": \"false\"",
-                new Response.Listener<JSONObject>() {
-                    @Override
-                    public void onResponse(JSONObject response) {
-                        mRequestInProgress = false;
-                        invalidateOptionsMenu();
-                        mProgressBar.setVisibility(View.GONE);
+                response -> {
+                    mRequestInProgress = false;
+                    invalidateOptionsMenu();
+                    mProgressBar.setVisibility(View.GONE);
 
-                        try {
-                            JSONArray bridges = response.getJSONArray("data").getJSONObject(0).getJSONArray("bridges");
+                    try {
+                        JSONArray bridges = response.getJSONArray("data").getJSONObject(0).getJSONArray("bridges");
 
-                            Log.d(MoatActivity.class.getSimpleName(), "Bridges: " + bridges.toString());
+                        Log.d(MoatActivity.class.getSimpleName(), "Bridges: " + bridges.toString());
 
-                            StringBuilder sb = new StringBuilder();
+                        StringBuilder sb = new StringBuilder();
 
-                            for (int i = 0; i < bridges.length(); i++) {
-                                sb.append(bridges.getString(i)).append("\n");
-                            }
+                        for (int i = 0; i < bridges.length(); i++) {
+                            sb.append(bridges.getString(i)).append("\n");
+                        }
 
-                            Prefs.setBridgesList(sb.toString());
-                            Prefs.putBridgesEnabled(true);
+                        Prefs.setBridgesList(sb.toString());
+                        Prefs.putBridgesEnabled(true);
 
-                            sendIntentToService(TorServiceConstants.CMD_SIGNAL_HUP);
+                        sendIntentToService(TorServiceConstants.CMD_SIGNAL_HUP);
 
-                            mSuccess = true;
-                            setResult(RESULT_OK);
-                            finish();
-                        }
-                        catch (JSONException e) {
-                            Log.d(MoatActivity.class.getSimpleName(), "Error decoding answer: " + response.toString());
+                        mSuccess = true;
+                        setResult(RESULT_OK);
+                        finish();
+                    }
+                    catch (JSONException e) {
+                        Log.d(MoatActivity.class.getSimpleName(), "Error decoding answer: " + response.toString());
 
-                            displayError(e, response);
-                        }
+                        displayError(e, response);
                     }
                 });
 
@@ -350,17 +343,14 @@ public class MoatActivity extends AppCompatActivity implements View.OnClickListe
                 moatBaseUrl + "/" + endpoint,
                 requestBody,
                 listener,
-                new Response.ErrorListener() {
-                    @Override
-                    public void onErrorResponse(VolleyError error) {
-                        mRequestInProgress = false;
-                        invalidateOptionsMenu();
-                        mProgressBar.setVisibility(View.GONE);
+                error -> {
+                    mRequestInProgress = false;
+                    invalidateOptionsMenu();
+                    mProgressBar.setVisibility(View.GONE);
 
-                        Log.d(MoatActivity.class.getSimpleName(), "Error response.");
+                    Log.d(MoatActivity.class.getSimpleName(), "Error response.");
 
-                        displayError(error, null);
-                    }
+                    displayError(error, null);
                 }
         ) {
             public String getBodyContentType() {
diff --git a/app/src/main/java/org/torproject/android/ui/onboarding/OnboardingActivity.java b/app/src/main/java/org/torproject/android/ui/onboarding/OnboardingActivity.java
index 6380753d..f1f0fabc 100644
--- a/app/src/main/java/org/torproject/android/ui/onboarding/OnboardingActivity.java
+++ b/app/src/main/java/org/torproject/android/ui/onboarding/OnboardingActivity.java
@@ -4,7 +4,6 @@ import android.content.Context;
 import android.content.Intent;
 import android.content.SharedPreferences;
 import android.os.Bundle;
-import android.view.View;
 
 import androidx.annotation.Nullable;
 import androidx.fragment.app.Fragment;
@@ -52,12 +51,7 @@ public class OnboardingActivity extends AppIntro {
 
             cs2 = CustomSlideBigText.newInstance(R.layout.custom_slide_big_text);
             cs2.setTitle(getString(R.string.bridges_sometimes));
-            cs2.showButton(getString(R.string.action_more), new View.OnClickListener() {
-                @Override
-                public void onClick(View v) {
-                    startActivity(new Intent(OnboardingActivity.this, BridgeWizardActivity.class));
-                }
-            });
+            cs2.showButton(getString(R.string.action_more), v -> startActivity(new Intent(OnboardingActivity.this, BridgeWizardActivity.class)));
             addSlide(cs2);
 
             if (PermissionManager.isLollipopOrHigher()) {
@@ -65,12 +59,7 @@ public class OnboardingActivity extends AppIntro {
                 cs3 = CustomSlideBigText.newInstance(R.layout.custom_slide_big_text);
                 cs3.setTitle(getString(R.string.vpn_setup));
                 cs3.setSubTitle(getString(R.string.vpn_setup_sub));
-                cs3.showButton(getString(R.string.action_vpn_choose), new View.OnClickListener() {
-                    @Override
-                    public void onClick(View v) {
-                        startActivityForResult(new Intent(OnboardingActivity.this, AppManagerActivity.class), 9999);
-                    }
-                });
+                cs3.showButton(getString(R.string.action_vpn_choose), v -> startActivityForResult(new Intent(OnboardingActivity.this, AppManagerActivity.class), 9999));
                 addSlide(cs3);
 
             }
diff --git a/orbotservice/src/androidTest/java/org/torproject/android/service/ApplicationTest.java b/orbotservice/src/androidTest/java/org/torproject/android/service/ApplicationTest.java
deleted file mode 100644
index 70ee563e..00000000
--- a/orbotservice/src/androidTest/java/org/torproject/android/service/ApplicationTest.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package org.torproject.android.service;
-
-import android.app.Application;
-import android.test.ApplicationTestCase;
-
-/**
- * <a href="http://d.android.com/tools/testing/testing_android.html";>Testing Fundamentals</a>
- */
-public class ApplicationTest extends ApplicationTestCase<Application> {
-    public ApplicationTest() {
-        super(Application.class);
-    }
-}
\ No newline at end of file
diff --git a/orbotservice/src/main/java/org/torproject/android/service/OrbotService.java b/orbotservice/src/main/java/org/torproject/android/service/OrbotService.java
index d2d0eb67..294259a5 100644
--- a/orbotservice/src/main/java/org/torproject/android/service/OrbotService.java
+++ b/orbotservice/src/main/java/org/torproject/android/service/OrbotService.java
@@ -452,13 +452,7 @@ public class OrbotService extends VpnService implements TorServiceConstants, Orb
 
     private void stopTor ()
     {
-        new Thread(new Runnable ()
-        {
-            public void run ()
-            {
-                stopTorAsync();
-            }
-        }).start();
+        new Thread(() -> stopTorAsync()).start();
 
     }
 
@@ -589,21 +583,17 @@ public class OrbotService extends VpnService implements TorServiceConstants, Orb
 
             pluggableTransportInstall();
 
-            new Thread(new Runnable ()
-            {
-                public void run ()
+            new Thread(() -> {
+                try
                 {
-                    try
-                    {
-                        findExistingTorDaemon();
-                    }
-                    catch (Exception e)
-                    {
-                        Log.e(OrbotConstants.TAG,"error onBind",e);
-                        logNotice("error finding exiting process: " + e.toString());
-                    }
-                    
+                    findExistingTorDaemon();
                 }
+                catch (Exception e)
+                {
+                    Log.e(OrbotConstants.TAG,"error onBind",e);
+                    logNotice("error finding exiting process: " + e.toString());
+                }
+
             }).start();
 
             try {
diff --git a/orbotservice/src/main/java/org/torproject/android/service/TorEventHandler.java b/orbotservice/src/main/java/org/torproject/android/service/TorEventHandler.java
index d8f50d19..ce7a6633 100644
--- a/orbotservice/src/main/java/org/torproject/android/service/TorEventHandler.java
+++ b/orbotservice/src/main/java/org/torproject/android/service/TorEventHandler.java
@@ -6,7 +6,6 @@ import net.freehaven.tor.control.EventHandler;
 
 import org.torproject.android.service.util.ExternalIPFetcher;
 import org.torproject.android.service.util.Prefs;
-import org.w3c.dom.Text;
 
 import java.text.NumberFormat;
 import java.util.HashMap;
diff --git a/orbotservice/src/main/java/org/torproject/android/service/util/ExternalIPFetcher.java b/orbotservice/src/main/java/org/torproject/android/service/util/ExternalIPFetcher.java
index 698f02af..aa176b2c 100644
--- a/orbotservice/src/main/java/org/torproject/android/service/util/ExternalIPFetcher.java
+++ b/orbotservice/src/main/java/org/torproject/android/service/util/ExternalIPFetcher.java
@@ -2,7 +2,6 @@ package org.torproject.android.service.util;
 
 import org.json.JSONArray;
 import org.json.JSONObject;
-import org.torproject.android.service.OrbotService;
 import org.torproject.android.service.TorEventHandler;
 import org.torproject.android.service.OrbotService;
 
diff --git a/orbotservice/src/main/java/org/torproject/android/service/util/TorServiceUtils.java b/orbotservice/src/main/java/org/torproject/android/service/util/TorServiceUtils.java
index 018d7e42..2efe5a9f 100644
--- a/orbotservice/src/main/java/org/torproject/android/service/util/TorServiceUtils.java
+++ b/orbotservice/src/main/java/org/torproject/android/service/util/TorServiceUtils.java
@@ -2,9 +2,6 @@
 /* See LICENSE for licensing information */
 package org.torproject.android.service.util;
 
-import android.content.Context;
-import android.content.SharedPreferences;
-import org.torproject.android.service.OrbotConstants;
 import org.torproject.android.service.TorServiceConstants;
 
 import java.net.ConnectException;
diff --git a/orbotservice/src/main/java/org/torproject/android/service/vpn/VpnUtils.java b/orbotservice/src/main/java/org/torproject/android/service/vpn/VpnUtils.java
index 3be8fe4a..68841fda 100644
--- a/orbotservice/src/main/java/org/torproject/android/service/vpn/VpnUtils.java
+++ b/orbotservice/src/main/java/org/torproject/android/service/vpn/VpnUtils.java
@@ -1,6 +1,5 @@
 package org.torproject.android.service.vpn;
 
-import android.app.ActivityManager;
 import android.content.Context;
 import android.content.SharedPreferences;
 import android.util.Log;
@@ -13,9 +12,7 @@ import java.io.IOException;
 import java.io.InputStreamReader;
 import java.util.List;
 
-import static android.content.Context.ACTIVITY_SERVICE;
 import static java.lang.Runtime.getRuntime;
-import static org.torproject.android.service.vpn.VpnConstants.SHELL_CMD_PS;
 import static org.torproject.android.service.vpn.VpnPrefs.PREF_TOR_SHARED_PREFS;
 
 public class VpnUtils {



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits