Skip to content
This repository was archived by the owner on Dec 3, 2024. It is now read-only.

Commit 9b04374

Browse files
authored
Remove code in outdated version checks (#2038)
Refactor code inside `if-else` blocks that checks for versions that are no longer relevant. Few lines could be deleted some others were just un-wrapped from the if-else blocks. The `if-else` blocks inside `PRNGFixes` file were left out as this file is should be deleted in #2036
1 parent eb0e1d6 commit 9b04374

File tree

4 files changed

+7
-31
lines changed

4 files changed

+7
-31
lines changed

app/src/main/java/com/nutomic/syncthingandroid/activities/FolderPickerActivity.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ protected void onCreate(Bundle savedInstanceState) {
104104
}
105105

106106
Boolean prefUseRoot = PreferenceManager.getDefaultSharedPreferences(this).getBoolean(Constants.PREF_USE_ROOT, false);
107-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && !prefUseRoot) {
107+
if (!prefUseRoot) {
108108
Toast.makeText(this, R.string.kitkat_external_storage_warning, Toast.LENGTH_LONG)
109109
.show();
110110
}
@@ -118,10 +118,8 @@ protected void onCreate(Bundle savedInstanceState) {
118118
@SuppressLint("NewApi")
119119
private void populateRoots() {
120120
ArrayList<File> roots = new ArrayList<>();
121-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
122-
roots.addAll(Arrays.asList(getExternalFilesDirs(null)));
123-
roots.remove(getExternalFilesDir(null));
124-
}
121+
roots.addAll(Arrays.asList(getExternalFilesDirs(null)));
122+
roots.remove(getExternalFilesDir(null));
125123

126124
String rootDir = getIntent().getStringExtra(EXTRA_ROOT_DIRECTORY);
127125
if (getIntent().hasExtra(EXTRA_ROOT_DIRECTORY) && !TextUtils.isEmpty(rootDir)) {
@@ -132,9 +130,7 @@ private void populateRoots() {
132130
roots.add(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES));
133131
roots.add(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS));
134132
roots.add(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM));
135-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
136-
roots.add(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS));
137-
}
133+
roots.add(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS));
138134

139135
// Add paths that might not be accessible to Syncthing.
140136
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);

app/src/main/java/com/nutomic/syncthingandroid/activities/WebGuiActivity.java

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,6 @@ public class WebGuiActivity extends StateDialogActivity
7777
@Override
7878
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
7979
try {
80-
int sdk = android.os.Build.VERSION.SDK_INT;
81-
if (sdk < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
82-
// The mX509Certificate field is not available for ICS- devices
83-
Log.w(TAG, "Skipping certificate check for devices <ICS");
84-
handler.proceed();
85-
return;
86-
}
8780
// Use reflection to access the private mX509Certificate field of SslCertificate
8881
SslCertificate sslCert = error.getCertificate();
8982
Field f = sslCert.getClass().getDeclaredField("mX509Certificate");
@@ -252,11 +245,6 @@ private void loadCaCert() {
252245
*/
253246
@SuppressLint("PrivateApi")
254247
public static boolean setWebViewProxy(Context appContext, String host, int port, String exclusionList) {
255-
if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
256-
// Not supported on android version lower than KitKat.
257-
return false;
258-
}
259-
260248
Properties properties = System.getProperties();
261249
properties.setProperty("http.proxyHost", host);
262250
properties.setProperty("http.proxyPort", Integer.toString(port));
@@ -282,11 +270,7 @@ public static boolean setWebViewProxy(Context appContext, String host, int port,
282270
Intent intent = new Intent(Proxy.PROXY_CHANGE_ACTION);
283271

284272
String CLASS_NAME;
285-
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) {
286-
CLASS_NAME = "android.net.ProxyProperties";
287-
} else {
288-
CLASS_NAME = "android.net.ProxyInfo";
289-
}
273+
CLASS_NAME = "android.net.ProxyInfo";
290274
Class cls = Class.forName(CLASS_NAME);
291275
Constructor constructor = cls.getConstructor(String.class, Integer.TYPE, String.class);
292276
constructor.setAccessible(true);

app/src/main/java/com/nutomic/syncthingandroid/fragments/DrawerFragment.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -284,10 +284,6 @@ private void doExit() {
284284
}
285285
Log.i(TAG, "Exiting app on user request");
286286
mActivity.stopService(new Intent(mActivity, SyncthingService.class));
287-
if(android.os.Build.VERSION.SDK_INT >= 21) {
288-
mActivity.finishAndRemoveTask();
289-
} else {
290-
mActivity.finish();
291-
}
287+
mActivity.finishAndRemoveTask();
292288
}
293289
}

app/src/main/java/com/nutomic/syncthingandroid/util/Util.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ public static void dismissDialogSafe(Dialog dialog, Activity activity) {
218218
if (activity.isFinishing())
219219
return;
220220

221-
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN && activity.isDestroyed())
221+
if (activity.isDestroyed())
222222
return;
223223

224224
dialog.dismiss();

0 commit comments

Comments
 (0)