mirror of
https://github.com/f-droid/fdroidclient.git
synced 2026-04-20 06:47:06 -04:00
Merge branch 'Use_toArray' into 'master'
Pass empty arrays to toArray(). See merge request fdroid/fdroidclient!1115
This commit is contained in:
@@ -19,6 +19,10 @@
|
||||
|
||||
package org.fdroid.fdroid.installer;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import android.app.Instrumentation;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
@@ -26,6 +30,7 @@ import android.util.Log;
|
||||
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
|
||||
import org.fdroid.fdroid.AssetUtils;
|
||||
import org.fdroid.fdroid.compat.FileCompatTest;
|
||||
import org.fdroid.fdroid.data.Apk;
|
||||
@@ -40,10 +45,6 @@ import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
/**
|
||||
* This test checks the ApkVerifier by parsing a repo from permissionsRepo.xml
|
||||
* and checking the listed permissions against the ones specified in apks' AndroidManifest,
|
||||
@@ -110,14 +111,14 @@ public class ApkVerifierTest {
|
||||
if (Build.VERSION.SDK_INT >= 23) {
|
||||
permissionsList.add("android.permission.ACCESS_FINE_LOCATION");
|
||||
}
|
||||
apk.requestedPermissions = permissionsList.toArray(new String[permissionsList.size()]);
|
||||
apk.requestedPermissions = permissionsList.toArray(new String[0]);
|
||||
|
||||
Uri uri = Uri.fromFile(minMaxApk);
|
||||
ApkVerifier apkVerifier = new ApkVerifier(instrumentation.getContext(), uri, apk);
|
||||
apkVerifier.verifyApk();
|
||||
|
||||
permissionsList.add("ADDITIONAL_PERMISSION");
|
||||
apk.requestedPermissions = permissionsList.toArray(new String[permissionsList.size()]);
|
||||
apk.requestedPermissions = permissionsList.toArray(new String[0]);
|
||||
apkVerifier.verifyApk();
|
||||
}
|
||||
|
||||
@@ -307,7 +308,7 @@ public class ApkVerifierTest {
|
||||
+ Build.VERSION.SDK_INT + ")");
|
||||
}
|
||||
}
|
||||
String[] expectedPermissions = expectedSet.toArray(new String[expectedSet.size()]);
|
||||
String[] expectedPermissions = expectedSet.toArray(new String[0]);
|
||||
assertTrue(ApkVerifier.requestedPermissionsEqual(expectedPermissions, apk.requestedPermissions));
|
||||
|
||||
String[] badPermissions = Arrays.copyOf(expectedPermissions, expectedPermissions.length + 1);
|
||||
@@ -383,7 +384,7 @@ public class ApkVerifierTest {
|
||||
+ Build.VERSION.SDK_INT + ")");
|
||||
}
|
||||
}
|
||||
String[] expectedPermissions = expectedSet.toArray(new String[expectedSet.size()]);
|
||||
String[] expectedPermissions = expectedSet.toArray(new String[0]);
|
||||
assertTrue(ApkVerifier.requestedPermissionsEqual(expectedPermissions, apk.requestedPermissions));
|
||||
|
||||
expectedSet = new TreeSet<>(Arrays.asList(
|
||||
|
||||
@@ -15,13 +15,6 @@ import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.util.TypedValue;
|
||||
|
||||
import org.fdroid.fdroid.Preferences;
|
||||
import org.fdroid.fdroid.R;
|
||||
import org.fdroid.fdroid.installer.PrivilegedInstaller;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Set;
|
||||
|
||||
import androidx.annotation.ColorInt;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
@@ -32,6 +25,14 @@ import androidx.preference.ListPreference;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceCategory;
|
||||
import androidx.preference.PreferenceFragmentCompat;
|
||||
|
||||
import org.fdroid.fdroid.Preferences;
|
||||
import org.fdroid.fdroid.R;
|
||||
import org.fdroid.fdroid.installer.PrivilegedInstaller;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Set;
|
||||
|
||||
import info.guardianproject.panic.Panic;
|
||||
import info.guardianproject.panic.PanicResponder;
|
||||
|
||||
@@ -174,8 +175,8 @@ public class PanicPreferencesFragment extends PreferenceFragmentCompat
|
||||
entryValues.add(resolveInfo.activityInfo.packageName);
|
||||
}
|
||||
|
||||
prefApp.setEntries(entries.toArray(new CharSequence[entries.size()]));
|
||||
prefApp.setEntryValues(entryValues.toArray(new CharSequence[entryValues.size()]));
|
||||
prefApp.setEntries(entries.toArray(new CharSequence[0]));
|
||||
prefApp.setEntryValues(entryValues.toArray(new CharSequence[0]));
|
||||
prefApp.setDefaultValue(Panic.PACKAGE_NAME_NONE);
|
||||
|
||||
if (entries.size() <= 1) {
|
||||
|
||||
@@ -7,6 +7,8 @@ import android.content.res.Resources;
|
||||
import android.os.Build;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashSet;
|
||||
@@ -15,8 +17,6 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
public final class Languages {
|
||||
public static final String TAG = "Languages";
|
||||
|
||||
@@ -136,7 +136,7 @@ public final class Languages {
|
||||
* match what is returned by {@link Languages#getSupportedLocales()}.
|
||||
*/
|
||||
public String[] getAllNames() {
|
||||
return nameMap.values().toArray(new String[nameMap.size()]);
|
||||
return nameMap.values().toArray(new String[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -144,7 +144,7 @@ public final class Languages {
|
||||
*/
|
||||
public String[] getSupportedLocales() {
|
||||
Set<String> keys = nameMap.keySet();
|
||||
return keys.toArray(new String[keys.size()]);
|
||||
return keys.toArray(new String[0]);
|
||||
}
|
||||
|
||||
private String capitalize(final String line) {
|
||||
|
||||
@@ -34,6 +34,12 @@ import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.app.JobIntentService;
|
||||
import androidx.core.app.NotificationCompat;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||
|
||||
import org.fdroid.CompatibilityChecker;
|
||||
import org.fdroid.CompatibilityCheckerImpl;
|
||||
import org.fdroid.database.DbUpdateChecker;
|
||||
@@ -58,12 +64,6 @@ import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.app.JobIntentService;
|
||||
import androidx.core.app.NotificationCompat;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.rxjava3.core.Single;
|
||||
import io.reactivex.rxjava3.disposables.Disposable;
|
||||
@@ -296,7 +296,7 @@ public class UpdateService extends JobIntentService {
|
||||
private void sendRepoErrorStatus(int statusCode, ArrayList<CharSequence> repoErrors) {
|
||||
Intent intent = new Intent(LOCAL_ACTION_STATUS);
|
||||
intent.putExtra(EXTRA_STATUS_CODE, statusCode);
|
||||
intent.putExtra(EXTRA_REPO_ERRORS, repoErrors.toArray(new CharSequence[repoErrors.size()]));
|
||||
intent.putExtra(EXTRA_REPO_ERRORS, repoErrors.toArray(new CharSequence[0]));
|
||||
LocalBroadcastManager.getInstance(this).sendBroadcast(intent);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,10 @@ import android.os.Parcelable;
|
||||
import android.text.TextUtils;
|
||||
import android.webkit.MimeTypeMap;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
|
||||
import org.fdroid.database.AppManifest;
|
||||
import org.fdroid.database.AppVersion;
|
||||
import org.fdroid.database.Repository;
|
||||
@@ -32,10 +36,6 @@ import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
|
||||
/**
|
||||
* Represents a single package of an application. This represents one particular
|
||||
* package of a given application, for info about the app in general, see
|
||||
@@ -462,7 +462,7 @@ public class Apk implements Comparable<Apk>, Parcelable {
|
||||
// so we don't make any changes for apps targetting 33 or above
|
||||
}
|
||||
|
||||
requestedPermissions = set.toArray(new String[set.size()]);
|
||||
requestedPermissions = set.toArray(new String[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,6 +16,11 @@ import android.os.Parcelable;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.os.ConfigurationCompat;
|
||||
import androidx.core.os.LocaleListCompat;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.RequestBuilder;
|
||||
|
||||
@@ -40,11 +45,6 @@ import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.os.ConfigurationCompat;
|
||||
import androidx.core.os.LocaleListCompat;
|
||||
|
||||
/**
|
||||
* Represents an application, its availability, and its current installed state.
|
||||
* This represents the app in general, for a specific version of this app, see
|
||||
|
||||
@@ -24,6 +24,16 @@ import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.app.NavUtils;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.google.android.material.appbar.MaterialToolbar;
|
||||
import com.google.android.material.textfield.TextInputLayout;
|
||||
|
||||
@@ -46,16 +56,6 @@ import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.app.NavUtils;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.rxjava3.core.Single;
|
||||
import io.reactivex.rxjava3.disposables.Disposable;
|
||||
|
||||
Reference in New Issue
Block a user