Make some declaration accesses weaker

As suggested by Android Studio.
This commit is contained in:
Daniel Martí 2016-02-28 14:19:02 +00:00
parent 982bf42a4b
commit 9c86655af0
20 changed files with 61 additions and 58 deletions

View File

@ -1043,7 +1043,7 @@ public class AppDetails extends AppCompatActivity implements ProgressListener, A
public static class AppDetailsSummaryFragment extends Fragment {
protected final Preferences prefs;
final Preferences prefs;
private AppDetailsData data;
private static final int MAX_LINES = 5;
private static boolean viewAllDescription;
@ -1076,11 +1076,11 @@ public class AppDetails extends AppCompatActivity implements ProgressListener, A
data = (AppDetailsData) activity;
}
protected App getApp() {
App getApp() {
return data.getApp();
}
protected ApkListAdapter getApks() {
ApkListAdapter getApks() {
return data.getApks();
}
@ -1436,7 +1436,7 @@ public class AppDetails extends AppCompatActivity implements ProgressListener, A
private TextView progressSize;
private TextView progressPercent;
private ImageButton cancelButton;
protected final DisplayImageOptions displayImageOptions;
final DisplayImageOptions displayImageOptions;
public static boolean installed;
public static boolean updateWanted;
@ -1678,19 +1678,19 @@ public class AppDetails extends AppCompatActivity implements ProgressListener, A
installListener = (AppInstallListener) activity;
}
protected void install(final Apk apk) {
void install(final Apk apk) {
installListener.install(apk);
}
protected void remove() {
void remove() {
installListener.removeApk(getApp().packageName);
}
protected App getApp() {
App getApp() {
return data.getApp();
}
protected ApkListAdapter getApks() {
ApkListAdapter getApks() {
return data.getApks();
}

View File

@ -362,7 +362,7 @@ public class FDroidApp extends Application {
/**
* Set the proxy settings based on whether Tor should be enabled or not.
*/
public static void configureTor(boolean enabled) {
private static void configureTor(boolean enabled) {
useTor = enabled;
if (useTor) {
NetCipher.useTor();

View File

@ -22,7 +22,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class FDroidCertPins {
class FDroidCertPins {
private static final String[] DEFAULT_PINS = {
// OU=PositiveSSL, CN=f-droid.org

View File

@ -77,7 +77,7 @@ public final class Preferences implements SharedPreferences.OnSharedPreferenceCh
public static final String DEFAULT_THEME = "light";
public static final String DEFAULT_PROXY_HOST = "127.0.0.1";
public static final int DEFAULT_PROXY_PORT = 8118;
public static final boolean DEFAULT_SHOW_NFC_DURING_SWAP = true;
private static final boolean DEFAULT_SHOW_NFC_DURING_SWAP = true;
private static final boolean DEFAULT_FIRST_TIME = true;
private static final boolean DEFAULT_POST_PRIVILEGED_INSTALL = false;

View File

@ -54,10 +54,13 @@ public class RepoUpdater {
public static final String PROGRESS_COMMITTING = "committing";
public static final String PROGRESS_DATA_REPO_ADDRESS = "repoAddress";
@NonNull protected final Context context;
@NonNull protected final Repo repo;
protected boolean hasChanged;
@Nullable protected ProgressListener progressListener;
@NonNull
private final Context context;
@NonNull
private final Repo repo;
private boolean hasChanged;
@Nullable
private ProgressListener progressListener;
private String cacheTag;
private X509Certificate signingCertFromJar;
@ -82,7 +85,7 @@ public class RepoUpdater {
return hasChanged;
}
protected URL getIndexAddress() throws MalformedURLException {
private URL getIndexAddress() throws MalformedURLException {
String urlString = repo.address + "/index.jar";
String versionName = Utils.getVersionName(context);
if (versionName != null) {
@ -91,7 +94,7 @@ public class RepoUpdater {
return new URL(urlString);
}
Downloader downloadIndex() throws UpdateException {
private Downloader downloadIndex() throws UpdateException {
Downloader downloader = null;
try {
downloader = DownloaderFactory.create(context,

View File

@ -35,11 +35,11 @@ public class TabManager {
this.pager = pager;
}
protected CharSequence getLabel(int index) {
private CharSequence getLabel(int index) {
return pager.getAdapter().getPageTitle(index);
}
public void removeNotification(int id) {
private void removeNotification(int id) {
parent.removeNotification(id);
}

View File

@ -13,7 +13,7 @@ import org.fdroid.fdroid.Utils;
import java.util.ArrayList;
import java.util.List;
public class DBHelper extends SQLiteOpenHelper {
class DBHelper extends SQLiteOpenHelper {
private static final String TAG = "DBHelper";

View File

@ -32,7 +32,7 @@ public class InstalledAppCacheUpdater {
private final List<PackageInfo> toInsert = new ArrayList<>();
private final List<String> toDelete = new ArrayList<>();
protected InstalledAppCacheUpdater(Context context) {
private InstalledAppCacheUpdater(Context context) {
this.context = context;
}
@ -59,7 +59,7 @@ public class InstalledAppCacheUpdater {
updater.startBackgroundWorker();
}
protected boolean update() {
private boolean update() {
long startTime = System.currentTimeMillis();
@ -72,13 +72,13 @@ public class InstalledAppCacheUpdater {
return hasChanged();
}
protected void notifyProviders() {
private void notifyProviders() {
Utils.debugLog(TAG, "Installed app cache has changed, notifying content providers (so they can update the relevant views).");
context.getContentResolver().notifyChange(AppProvider.getContentUri(), null);
context.getContentResolver().notifyChange(ApkProvider.getContentUri(), null);
}
protected void startBackgroundWorker() {
private void startBackgroundWorker() {
new PostponedWorker().execute();
}

View File

@ -4,7 +4,7 @@ import android.database.Cursor;
class ValueObject {
protected void checkCursorPosition(Cursor cursor) throws IllegalArgumentException {
void checkCursorPosition(Cursor cursor) throws IllegalArgumentException {
if (cursor.getPosition() == -1) {
throw new IllegalArgumentException(
"Cursor position is -1. " +

View File

@ -37,9 +37,9 @@ import java.util.List;
* instantiate a working Installer based on F-Droids granted permissions.
*/
public abstract class Installer {
protected final Context mContext;
protected final PackageManager mPm;
protected final InstallerCallback mCallback;
final Context mContext;
final PackageManager mPm;
final InstallerCallback mCallback;
private static final String TAG = "Installer";
@ -88,7 +88,7 @@ public abstract class Installer {
void onError(int operation, int errorCode);
}
public Installer(Context context, PackageManager pm, InstallerCallback callback)
Installer(Context context, PackageManager pm, InstallerCallback callback)
throws AndroidNotCompatibleException {
this.mContext = context;
this.mPm = pm;

View File

@ -104,7 +104,7 @@ class BluetoothFinder extends PeerFinder {
}
public void cancel() {
private void cancel() {
if (adapter != null) {
Utils.debugLog(TAG, "Stopping bluetooth discovery.");
adapter.cancelDiscovery();

View File

@ -59,7 +59,7 @@ public class BonjourPeer extends WifiPeer {
dest.writeParcelable(serviceInfo, flags);
}
protected BonjourPeer(Parcel in) {
private BonjourPeer(Parcel in) {
this((ServiceInfo) in.readParcelable(FDroidServiceInfo.class.getClassLoader()));
}

View File

@ -103,7 +103,7 @@ public class BonjourBroadcast extends SwapType {
if (FDroidApp.ipAddressString != null) {
try {
return InetAddress.getByName(FDroidApp.ipAddressString);
} catch (UnknownHostException e) { }
} catch (UnknownHostException ignored) { }
}
return null;

View File

@ -191,7 +191,7 @@ public class AsyncDownloaderFromAndroid implements AsyncDownloader {
return 0;
}
protected void sendProgress(int bytesRead, int totalBytes) {
private void sendProgress(int bytesRead, int totalBytes) {
Intent intent = new Intent(Downloader.LOCAL_ACTION_PROGRESS);
intent.putExtra(Downloader.EXTRA_ADDRESS, remoteAddress);
intent.putExtra(Downloader.EXTRA_BYTES_READ, bytesRead);
@ -321,7 +321,7 @@ public class AsyncDownloaderFromAndroid implements AsyncDownloader {
* Check if a specific download is complete.
* @return -1 if download is not complete, otherwise the download id
*/
public static long isDownloadComplete(Context context, String uniqueDownloadId) {
private static long isDownloadComplete(Context context, String uniqueDownloadId) {
DownloadManager dm = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);
DownloadManager.Query query = new DownloadManager.Query();
query.setFilterByStatus(DownloadManager.STATUS_SUCCESSFUL);

View File

@ -33,8 +33,8 @@ public abstract class Downloader {
protected final URL sourceUrl;
protected String cacheTag;
protected int bytesRead;
protected int totalBytes;
private int bytesRead;
private int totalBytes;
protected abstract InputStream getDownloadersInputStream() throws IOException;
@ -84,7 +84,7 @@ public abstract class Downloader {
public abstract boolean hasChanged();
public abstract int totalDownloadSize();
protected abstract int totalDownloadSize();
/**
* Helper function for synchronous downloads (i.e. those *not* using AsyncDownloadWrapper),
@ -149,7 +149,7 @@ public abstract class Downloader {
* keeping track of the number of bytes that have flowed through for the
* progress counter.
*/
protected void copyInputToOutputStream(InputStream input, int bufferSize) throws IOException, InterruptedException {
private void copyInputToOutputStream(InputStream input, int bufferSize) throws IOException, InterruptedException {
int bytesRead = 0;
this.totalBytes = totalDownloadSize();
@ -186,7 +186,7 @@ public abstract class Downloader {
outputStream.close();
}
protected void sendProgress(int bytesRead, int totalBytes) {
private void sendProgress(int bytesRead, int totalBytes) {
this.bytesRead = bytesRead;
Intent intent = new Intent(LOCAL_ACTION_PROGRESS);
intent.putExtra(EXTRA_ADDRESS, sourceUrl.toString());

View File

@ -216,7 +216,7 @@ public class LocalHTTPD extends NanoHTTPD {
* Serves file from homeDir and its' subdirectories (only). Uses only URI,
* ignores all headers and HTTP parameters.
*/
Response serveFile(String uri, Map<String, String> header, File file, String mime) {
private Response serveFile(String uri, Map<String, String> header, File file, String mime) {
Response res;
try {
// Calculate etag
@ -306,7 +306,7 @@ public class LocalHTTPD extends NanoHTTPD {
return res;
}
public static String getMimeTypeForFile(String uri) {
private static String getMimeTypeForFile(String uri) {
String type = null;
String extension = MimeTypeMap.getFileExtensionFromUrl(uri);
if (extension != null) {

View File

@ -197,7 +197,7 @@ public class WifiStateChangeService extends Service {
}
@TargetApi(9)
public void setIpInfoFromNetworkInterface() {
private void setIpInfoFromNetworkInterface() {
try {
for (Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces(); networkInterfaces.hasMoreElements();) {
NetworkInterface netIf = networkInterfaces.nextElement();

View File

@ -38,7 +38,7 @@ import eu.chainfire.libsuperuser.Shell;
*/
abstract class InstallExtension {
protected final Context context;
final Context context;
private static final String APK_FILE_NAME = "FDroidPrivileged.apk";
@ -67,7 +67,7 @@ abstract class InstallExtension {
protected abstract String getSystemFolder();
protected void onPreInstall() {
void onPreInstall() {
// To be overridden by relevant base class[es]
}
@ -79,7 +79,7 @@ abstract class InstallExtension {
return context.getString(R.string.system_install_installing);
}
protected String getInstallPath() {
String getInstallPath() {
return getSystemFolder() + APK_FILE_NAME;
}
@ -95,14 +95,14 @@ abstract class InstallExtension {
return commands;
}
protected List<String> getCopyToSystemCommands(String apkPath) {
List<String> getCopyToSystemCommands(String apkPath) {
final List<String> commands = new ArrayList<>(2);
commands.add("cat " + apkPath + " > " + getInstallPath() + ".tmp");
commands.add("chmod 644 " + getInstallPath() + ".tmp");
return commands;
}
protected List<String> getPostInstallCommands() {
List<String> getPostInstallCommands() {
final List<String> commands = new ArrayList<>(1);
commands.add("am start -n org.fdroid.fdroid/.privileged.install.InstallExtensionDialogActivity --ez "
+ InstallExtensionDialogActivity.ACTION_POST_INSTALL + " true");
@ -121,13 +121,13 @@ abstract class InstallExtension {
return commands;
}
protected List<String> getCleanUninstallCommands() {
List<String> getCleanUninstallCommands() {
final List<String> commands = new ArrayList<>(1);
commands.add("rm -f " + getInstallPath());
return commands;
}
protected List<String> getPostUninstallCommands() {
List<String> getPostUninstallCommands() {
return new ArrayList<>(0);
}

View File

@ -59,7 +59,7 @@ public class InstallExtensionDialogActivity extends FragmentActivity {
public static final String ACTION_POST_INSTALL = "post_install";
public static final String ACTION_FIRST_TIME = "first_time";
String apkFile;
private String apkFile;
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -113,7 +113,7 @@ public class InstallExtensionDialogActivity extends FragmentActivity {
}
}
public static void runFirstTime(final Context context) {
private static void runFirstTime(final Context context) {
// don't do a "real" root access, just look up if "su" is present and has a version!
// a real check would annoy the user
AsyncTask<Void, Void, Boolean> checkRoot = new AsyncTask<Void, Void, Boolean>() {
@ -202,7 +202,7 @@ public class InstallExtensionDialogActivity extends FragmentActivity {
builder.create().show();
}
public void askBeforeInstall() {
private void askBeforeInstall() {
// hack to get theme applied (which is not automatically applied due to activity's Theme.NoDisplay
ContextThemeWrapper theme = new ContextThemeWrapper(this, FDroidApp.getCurThemeResId());
@ -229,7 +229,7 @@ public class InstallExtensionDialogActivity extends FragmentActivity {
/**
* 1. Check for root access
*/
public final AsyncTask<Void, Void, Boolean> checkRootTask = new AsyncTask<Void, Void, Boolean>() {
private final AsyncTask<Void, Void, Boolean> checkRootTask = new AsyncTask<Void, Void, Boolean>() {
ProgressDialog mProgressDialog;
@Override
@ -299,7 +299,7 @@ public class InstallExtensionDialogActivity extends FragmentActivity {
/**
* 2. Install into system
*/
final AsyncTask<Void, Void, Void> installTask = new AsyncTask<Void, Void, Void>() {
private final AsyncTask<Void, Void, Void> installTask = new AsyncTask<Void, Void, Void>() {
ProgressDialog mProgressDialog;
@Override
@ -413,7 +413,7 @@ public class InstallExtensionDialogActivity extends FragmentActivity {
}
}
final AsyncTask<Void, Void, Void> uninstallTask = new AsyncTask<Void, Void, Void>() {
private final AsyncTask<Void, Void, Void> uninstallTask = new AsyncTask<Void, Void, Void>() {
ProgressDialog mProgressDialog;
@Override

View File

@ -119,7 +119,7 @@ public class StartSwapView extends ScrollView implements SwapWorkflowActivity.In
* When peers are emitted by the peer finder, add them to the adapter
* so that they will show up in the list of peers.
*/
private Subscriber<Peer> onPeerFound = new Subscriber<Peer>() {
private final Subscriber<Peer> onPeerFound = new Subscriber<Peer>() {
@Override
public void onCompleted() {
@ -185,7 +185,7 @@ public class StartSwapView extends ScrollView implements SwapWorkflowActivity.In
onWifiNetworkChanged, new IntentFilter(WifiStateChangeService.BROADCAST));
}
private BroadcastReceiver onWifiNetworkChanged = new BroadcastReceiver() {
private final BroadcastReceiver onWifiNetworkChanged = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
uiUpdateWifiNetwork();
@ -271,7 +271,7 @@ public class StartSwapView extends ScrollView implements SwapWorkflowActivity.In
/**
* @see StartSwapView#onWifiSwapStateChanged
*/
private BroadcastReceiver onBluetoothSwapStateChanged = new BroadcastReceiver() {
private final BroadcastReceiver onBluetoothSwapStateChanged = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if (intent.hasExtra(SwapService.EXTRA_STARTING)) {