Code cleanup.

This commit is contained in:
akwizgran
2016-09-27 11:51:24 +01:00
parent 9e3db12ea2
commit 133722dd2c

View File

@@ -1,6 +1,5 @@
package org.briarproject.android.util; package org.briarproject.android.util;
import android.annotation.SuppressLint;
import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothAdapter;
import android.content.Context; import android.content.Context;
import android.os.Build; import android.os.Build;
@@ -53,10 +52,9 @@ public class AndroidUtils {
private static final String STORED_REPORTS = "dev-reports"; private static final String STORED_REPORTS = "dev-reports";
@SuppressLint("NewApi")
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public static Collection<String> getSupportedArchitectures() { public static Collection<String> getSupportedArchitectures() {
List<String> abis = new ArrayList<String>(); List<String> abis = new ArrayList<>();
if (Build.VERSION.SDK_INT >= 21) { if (Build.VERSION.SDK_INT >= 21) {
abis.addAll(Arrays.asList(Build.SUPPORTED_ABIS)); abis.addAll(Arrays.asList(Build.SUPPORTED_ABIS));
} else { } else {
@@ -67,17 +65,12 @@ public class AndroidUtils {
} }
public static void setError(TextInputLayout til, String error, public static void setError(TextInputLayout til, String error,
boolean condition) { boolean set) {
if (condition) { if (set) {
if (til.getError() == null) if (til.getError() == null) til.setError(error);
til.setError(error); } else {
} else
til.setError(null); til.setError(null);
} }
public static void setError(TextInputLayout til, int res,
boolean condition) {
setError(til, til.getContext().getString(res), condition);
} }
public static String getBluetoothAddress(Context ctx, public static String getBluetoothAddress(Context ctx,
@@ -128,9 +121,8 @@ public class AndroidUtils {
MIN_RESOLUTION, WEEK_IN_MILLIS, flags).toString(); MIN_RESOLUTION, WEEK_IN_MILLIS, flags).toString();
} }
// otherwise just show "...ago" or date string // otherwise just show "...ago" or date string
return DateUtils return DateUtils.getRelativeTimeSpanString(time,
.getRelativeTimeSpanString(time, System.currentTimeMillis(), System.currentTimeMillis(), MIN_RESOLUTION, flags).toString();
MIN_RESOLUTION, flags).toString();
} }
public static SpannableStringBuilder getTeaser(Context ctx, Spanned body) { public static SpannableStringBuilder getTeaser(Context ctx, Spanned body) {