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,12 +34,11 @@ 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)
|
|
||||||
mInstance = new BluetoothSwap(context, adapter);
|
|
||||||
|
|
||||||
return mInstance;
|
|
||||||
}
|
}
|
||||||
|
if (mInstance == null)
|
||||||
|
mInstance = new BluetoothSwap(context, adapter);
|
||||||
|
|
||||||
|
return mInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
private BluetoothSwap(@NonNull Context context, @NonNull BluetoothAdapter adapter) {
|
private BluetoothSwap(@NonNull Context context, @NonNull BluetoothAdapter adapter) {
|
||||||
|
@ -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,13 +221,12 @@ 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",
|
|
||||||
ipAddress & 0xff,
|
|
||||||
ipAddress >> 8 & 0xff,
|
|
||||||
ipAddress >> 16 & 0xff,
|
|
||||||
ipAddress >> 24 & 0xff);
|
|
||||||
}
|
}
|
||||||
|
return String.format(Locale.ENGLISH, "%d.%d.%d.%d",
|
||||||
|
ipAddress & 0xff,
|
||||||
|
ipAddress >> 8 & 0xff,
|
||||||
|
ipAddress >> 16 & 0xff,
|
||||||
|
ipAddress >> 24 & 0xff);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String printWifiState(int wifiState) {
|
private String printWifiState(int wifiState) {
|
||||||
|
@ -234,13 +234,11 @@ 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,
|
|
||||||
"FORBIDDEN: No directory listing.");
|
|
||||||
}
|
}
|
||||||
} else {
|
return createResponse(NanoHTTPD.Response.Status.FORBIDDEN, NanoHTTPD.MIME_PLAINTEXT,
|
||||||
return respond(headers, uri + indexFile);
|
"FORBIDDEN: No directory listing.");
|
||||||
}
|
}
|
||||||
|
return respond(headers, uri + indexFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
Response response = serveFile(uri, headers, f, getMimeTypeForFile(uri));
|
Response response = serveFile(uri, headers, f, getMimeTypeForFile(uri));
|
||||||
|
@ -75,11 +75,9 @@ 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...");
|
|
||||||
return new Response(responseCode, headers, connection.getInputStream());
|
|
||||||
}
|
}
|
||||||
|
Utils.debugLog(TAG, "Request was a " + Methods.GET + " request, so including content stream in response...");
|
||||||
|
return new Response(responseCode, headers, connection.getInputStream());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -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,17 +99,16 @@ 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) {
|
||||||
if (headerView == null) {
|
|
||||||
headerView = inflater.inflate(getHeaderLayout(), null, false);
|
|
||||||
}
|
|
||||||
return headerView;
|
|
||||||
} else {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
if (headerView == null) {
|
||||||
|
headerView = inflater.inflate(getHeaderLayout(), null, false);
|
||||||
|
}
|
||||||
|
return headerView;
|
||||||
}
|
}
|
||||||
|
|
||||||
private LayoutInflater getThemedInflater(Context context) {
|
private LayoutInflater getThemedInflater(Context context) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user