Simplify a few elses
Mostly just dropping them after returns.
This commit is contained in:
		
							parent
							
								
									603a5b25e4
								
							
						
					
					
						commit
						8d4e785185
					
				@ -150,11 +150,10 @@ public class PrivilegedInstaller extends Installer {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        boolean hasPermissions = returnBundle.getBoolean("has_permissions", false);
 | 
					        boolean hasPermissions = returnBundle.getBoolean("has_permissions", false);
 | 
				
			||||||
        if (hasPermissions) {
 | 
					        if (!hasPermissions) {
 | 
				
			||||||
            return IS_EXTENSION_INSTALLED_YES;
 | 
					 | 
				
			||||||
        } else {
 | 
					 | 
				
			||||||
            return IS_EXTENSION_INSTALLED_PERMISSIONS_PROBLEM;
 | 
					            return IS_EXTENSION_INSTALLED_PERMISSIONS_PROBLEM;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        return IS_EXTENSION_INSTALLED_YES;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
 | 
				
			|||||||
@ -34,13 +34,12 @@ public final class BluetoothSwap extends SwapType {
 | 
				
			|||||||
        BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
 | 
					        BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
 | 
				
			||||||
        if (adapter == null) {
 | 
					        if (adapter == null) {
 | 
				
			||||||
            return new NoBluetoothType(context);
 | 
					            return new NoBluetoothType(context);
 | 
				
			||||||
        } else {
 | 
					        }
 | 
				
			||||||
        if (mInstance == null)
 | 
					        if (mInstance == null)
 | 
				
			||||||
            mInstance = new BluetoothSwap(context, adapter);
 | 
					            mInstance = new BluetoothSwap(context, adapter);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return mInstance;
 | 
					        return mInstance;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private BluetoothSwap(@NonNull Context context, @NonNull BluetoothAdapter adapter) {
 | 
					    private BluetoothSwap(@NonNull Context context, @NonNull BluetoothAdapter adapter) {
 | 
				
			||||||
        super(context);
 | 
					        super(context);
 | 
				
			||||||
 | 
				
			|||||||
@ -344,10 +344,9 @@ public class AsyncDownloaderFromAndroid implements AsyncDownloader {
 | 
				
			|||||||
                int status = c.getInt(c.getColumnIndex(DownloadManager.COLUMN_STATUS));
 | 
					                int status = c.getInt(c.getColumnIndex(DownloadManager.COLUMN_STATUS));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                if (status == DownloadManager.STATUS_SUCCESSFUL) {
 | 
					                if (status == DownloadManager.STATUS_SUCCESSFUL) {
 | 
				
			||||||
                    return 0; //Download is valid, celebrate
 | 
					                    return 0; // Download is valid, celebrate
 | 
				
			||||||
                } else {
 | 
					 | 
				
			||||||
                    return c.getInt(c.getColumnIndex(DownloadManager.COLUMN_REASON));
 | 
					 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					                return c.getInt(c.getColumnIndex(DownloadManager.COLUMN_REASON));
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        } finally {
 | 
					        } finally {
 | 
				
			||||||
            c.close();
 | 
					            c.close();
 | 
				
			||||||
 | 
				
			|||||||
@ -41,11 +41,11 @@ public class DownloaderFactory {
 | 
				
			|||||||
        if (isBluetoothAddress(url)) {
 | 
					        if (isBluetoothAddress(url)) {
 | 
				
			||||||
            String macAddress = url.getHost().replace("-", ":");
 | 
					            String macAddress = url.getHost().replace("-", ":");
 | 
				
			||||||
            return new BluetoothDownloader(context, macAddress, url, destFile);
 | 
					            return new BluetoothDownloader(context, macAddress, url, destFile);
 | 
				
			||||||
        } else if (isOnionAddress(url)) {
 | 
					 | 
				
			||||||
            return new TorHttpDownloader(context, url, destFile);
 | 
					 | 
				
			||||||
        } else {
 | 
					 | 
				
			||||||
            return new HttpDownloader(context, url, destFile);
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        if (isOnionAddress(url)) {
 | 
				
			||||||
 | 
					            return new TorHttpDownloader(context, url, destFile);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return new HttpDownloader(context, url, destFile);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private static boolean isBluetoothAddress(URL url) {
 | 
					    private static boolean isBluetoothAddress(URL url) {
 | 
				
			||||||
@ -60,9 +60,8 @@ public class DownloaderFactory {
 | 
				
			|||||||
            throws IOException {
 | 
					            throws IOException {
 | 
				
			||||||
        if (canUseDownloadManager(url)) {
 | 
					        if (canUseDownloadManager(url)) {
 | 
				
			||||||
            return new AsyncDownloaderFromAndroid(context, listener, title, id, url.toString(), destFile);
 | 
					            return new AsyncDownloaderFromAndroid(context, listener, title, id, url.toString(), destFile);
 | 
				
			||||||
        } else {
 | 
					 | 
				
			||||||
            return new AsyncDownloadWrapper(create(context, url, destFile), listener);
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        return new AsyncDownloadWrapper(create(context, url, destFile), listener);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    static boolean isOnionAddress(URL url) {
 | 
					    static boolean isOnionAddress(URL url) {
 | 
				
			||||||
 | 
				
			|||||||
@ -221,14 +221,13 @@ public class WifiStateChangeService extends Service {
 | 
				
			|||||||
    private String formatIpAddress(int ipAddress) {
 | 
					    private String formatIpAddress(int ipAddress) {
 | 
				
			||||||
        if (ipAddress == 0) {
 | 
					        if (ipAddress == 0) {
 | 
				
			||||||
            return null;
 | 
					            return null;
 | 
				
			||||||
        } else {
 | 
					        }
 | 
				
			||||||
        return String.format(Locale.ENGLISH, "%d.%d.%d.%d",
 | 
					        return String.format(Locale.ENGLISH, "%d.%d.%d.%d",
 | 
				
			||||||
                ipAddress & 0xff,
 | 
					                ipAddress & 0xff,
 | 
				
			||||||
                ipAddress >> 8 & 0xff,
 | 
					                ipAddress >> 8 & 0xff,
 | 
				
			||||||
                ipAddress >> 16 & 0xff,
 | 
					                ipAddress >> 16 & 0xff,
 | 
				
			||||||
                ipAddress >> 24 & 0xff);
 | 
					                ipAddress >> 24 & 0xff);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private String printWifiState(int wifiState) {
 | 
					    private String printWifiState(int wifiState) {
 | 
				
			||||||
        switch (wifiState) {
 | 
					        switch (wifiState) {
 | 
				
			||||||
 | 
				
			|||||||
@ -234,14 +234,12 @@ public class BluetoothServer extends Thread {
 | 
				
			|||||||
                    if (f.canRead()) {
 | 
					                    if (f.canRead()) {
 | 
				
			||||||
                        // No index file, list the directory if it is readable
 | 
					                        // No index file, list the directory if it is readable
 | 
				
			||||||
                        return createResponse(NanoHTTPD.Response.Status.NOT_FOUND, NanoHTTPD.MIME_HTML, "");
 | 
					                        return createResponse(NanoHTTPD.Response.Status.NOT_FOUND, NanoHTTPD.MIME_HTML, "");
 | 
				
			||||||
                    } else {
 | 
					                    }
 | 
				
			||||||
                    return createResponse(NanoHTTPD.Response.Status.FORBIDDEN, NanoHTTPD.MIME_PLAINTEXT,
 | 
					                    return createResponse(NanoHTTPD.Response.Status.FORBIDDEN, NanoHTTPD.MIME_PLAINTEXT,
 | 
				
			||||||
                            "FORBIDDEN: No directory listing.");
 | 
					                            "FORBIDDEN: No directory listing.");
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                } else {
 | 
					 | 
				
			||||||
                return respond(headers, uri + indexFile);
 | 
					                return respond(headers, uri + indexFile);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
            Response response = serveFile(uri, headers, f, getMimeTypeForFile(uri));
 | 
					            Response response = serveFile(uri, headers, f, getMimeTypeForFile(uri));
 | 
				
			||||||
            return response != null ? response :
 | 
					            return response != null ? response :
 | 
				
			||||||
 | 
				
			|||||||
@ -75,13 +75,11 @@ public final class Request {
 | 
				
			|||||||
        if (method.equals(Methods.HEAD)) {
 | 
					        if (method.equals(Methods.HEAD)) {
 | 
				
			||||||
            Utils.debugLog(TAG, "Request was a " + Methods.HEAD + " request, not including anything other than headers and status...");
 | 
					            Utils.debugLog(TAG, "Request was a " + Methods.HEAD + " request, not including anything other than headers and status...");
 | 
				
			||||||
            return new Response(responseCode, headers);
 | 
					            return new Response(responseCode, headers);
 | 
				
			||||||
        } else {
 | 
					        }
 | 
				
			||||||
        Utils.debugLog(TAG, "Request was a " + Methods.GET + " request, so including content stream in response...");
 | 
					        Utils.debugLog(TAG, "Request was a " + Methods.GET + " request, so including content stream in response...");
 | 
				
			||||||
        return new Response(responseCode, headers, connection.getInputStream());
 | 
					        return new Response(responseCode, headers, connection.getInputStream());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Helper function used by listenForRequest().
 | 
					     * Helper function used by listenForRequest().
 | 
				
			||||||
     * The reason it is here is because the listenForRequest() is a static function, which would
 | 
					     * The reason it is here is because the listenForRequest() is a static function, which would
 | 
				
			||||||
 | 
				
			|||||||
@ -49,11 +49,11 @@ abstract class InstallExtension {
 | 
				
			|||||||
    public static InstallExtension create(final Context context) {
 | 
					    public static InstallExtension create(final Context context) {
 | 
				
			||||||
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
 | 
					        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
 | 
				
			||||||
            return new LollipopImpl(context);
 | 
					            return new LollipopImpl(context);
 | 
				
			||||||
        } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
 | 
					 | 
				
			||||||
            return new KitKatToLollipopImpl(context);
 | 
					 | 
				
			||||||
        } else {
 | 
					 | 
				
			||||||
            return new PreKitKatImpl(context);
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
 | 
				
			||||||
 | 
					            return new KitKatToLollipopImpl(context);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return new PreKitKatImpl(context);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    final void runInstall(String apkPath) {
 | 
					    final void runInstall(String apkPath) {
 | 
				
			||||||
 | 
				
			|||||||
@ -99,18 +99,17 @@ public class AppSecurityPermissions {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        public Drawable loadGroupIcon(PackageManager pm) {
 | 
					        public Drawable loadGroupIcon(PackageManager pm) {
 | 
				
			||||||
            if (icon != 0) {
 | 
					            if (icon != 0) {
 | 
				
			||||||
                //return loadUnbadgedIcon(pm);
 | 
					                // return loadUnbadgedIcon(pm);
 | 
				
			||||||
                return loadIcon(pm);
 | 
					                return loadIcon(pm);
 | 
				
			||||||
            } else {
 | 
					            }
 | 
				
			||||||
            ApplicationInfo appInfo;
 | 
					            ApplicationInfo appInfo;
 | 
				
			||||||
            try {
 | 
					            try {
 | 
				
			||||||
                appInfo = pm.getApplicationInfo(packageName, 0);
 | 
					                appInfo = pm.getApplicationInfo(packageName, 0);
 | 
				
			||||||
                    //return appInfo.loadUnbadgedIcon(pm);
 | 
					                // return appInfo.loadUnbadgedIcon(pm);
 | 
				
			||||||
                return appInfo.loadIcon(pm);
 | 
					                return appInfo.loadIcon(pm);
 | 
				
			||||||
            } catch (NameNotFoundException e) {
 | 
					            } catch (NameNotFoundException e) {
 | 
				
			||||||
                // ignore
 | 
					                // ignore
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            return null;
 | 
					            return null;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -28,14 +28,13 @@ public abstract class ThemeableListFragment extends ListFragment {
 | 
				
			|||||||
    private View headerView;
 | 
					    private View headerView;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private View getHeaderView(LayoutInflater inflater, ViewGroup container) {
 | 
					    private View getHeaderView(LayoutInflater inflater, ViewGroup container) {
 | 
				
			||||||
        if (getHeaderLayout() > 0) {
 | 
					        if (getHeaderLayout() == 0) {
 | 
				
			||||||
 | 
					            return null;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        if (headerView == null) {
 | 
					        if (headerView == null) {
 | 
				
			||||||
            headerView = inflater.inflate(getHeaderLayout(), null, false);
 | 
					            headerView = inflater.inflate(getHeaderLayout(), null, false);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        return headerView;
 | 
					        return headerView;
 | 
				
			||||||
        } else {
 | 
					 | 
				
			||||||
            return null;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private LayoutInflater getThemedInflater(Context context) {
 | 
					    private LayoutInflater getThemedInflater(Context context) {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user