Apply a bunch of Android Studio fixes
This commit is contained in:
parent
a67fdfeb89
commit
e3175530ed
@ -1,7 +1,6 @@
|
|||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent" >
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
<fragment
|
<fragment
|
||||||
android:id="@+id/fragment_app_list"
|
android:id="@+id/fragment_app_list"
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
android:orientation="vertical"
|
||||||
android:orientation="vertical"
|
android:layout_width="match_parent"
|
||||||
android:layout_width="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:paddingTop="38.8dp"> <!-- 69px * 96dpi / 160dpi -->
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:paddingTop="38.8dp"> <!-- 69px * 96dpi / 160dpi -->
|
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<resources xmlns:android="http://schemas.android.com/apk/res/android">
|
<resources>
|
||||||
|
|
||||||
<style name="AppBaseThemeDark" parent="Theme.AppCompat">
|
<style name="AppBaseThemeDark" parent="Theme.AppCompat">
|
||||||
<!-- API 11 theme customizations go here -->
|
<!-- API 11 theme customizations go here -->
|
||||||
|
@ -150,7 +150,7 @@ public class AppDetails extends ActionBarActivity implements ProgressListener, A
|
|||||||
|
|
||||||
class ApkListAdapter extends ArrayAdapter<Apk> {
|
class ApkListAdapter extends ArrayAdapter<Apk> {
|
||||||
|
|
||||||
private LayoutInflater mInflater = (LayoutInflater) mctx.getSystemService(
|
private final LayoutInflater mInflater = (LayoutInflater) mctx.getSystemService(
|
||||||
Context.LAYOUT_INFLATER_SERVICE);
|
Context.LAYOUT_INFLATER_SERVICE);
|
||||||
|
|
||||||
public ApkListAdapter(Context context, App app) {
|
public ApkListAdapter(Context context, App app) {
|
||||||
@ -331,8 +331,8 @@ public class AppDetails extends ActionBarActivity implements ProgressListener, A
|
|||||||
*/
|
*/
|
||||||
private static class ConfigurationChangeHelper {
|
private static class ConfigurationChangeHelper {
|
||||||
|
|
||||||
public ApkDownloader downloader;
|
public final ApkDownloader downloader;
|
||||||
public App app;
|
public final App app;
|
||||||
|
|
||||||
public ConfigurationChangeHelper(ApkDownloader downloader, App app) {
|
public ConfigurationChangeHelper(ApkDownloader downloader, App app) {
|
||||||
this.downloader = downloader;
|
this.downloader = downloader;
|
||||||
@ -941,7 +941,7 @@ public class AppDetails extends ActionBarActivity implements ProgressListener, A
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Installer.InstallerCallback myInstallerCallback = new Installer.InstallerCallback() {
|
final Installer.InstallerCallback myInstallerCallback = new Installer.InstallerCallback() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(final int operation) {
|
public void onSuccess(final int operation) {
|
||||||
|
@ -18,11 +18,11 @@ public class CompatibilityChecker extends Compatibility {
|
|||||||
|
|
||||||
private static final String TAG = "fdroid.Compatibility";
|
private static final String TAG = "fdroid.Compatibility";
|
||||||
|
|
||||||
private Context context;
|
private final Context context;
|
||||||
private Set<String> features;
|
private final Set<String> features;
|
||||||
private String[] cpuAbis;
|
private final String[] cpuAbis;
|
||||||
private String cpuAbisDesc;
|
private final String cpuAbisDesc;
|
||||||
private boolean ignoreTouchscreen;
|
private final boolean ignoreTouchscreen;
|
||||||
|
|
||||||
public CompatibilityChecker(Context ctx) {
|
public CompatibilityChecker(Context ctx) {
|
||||||
|
|
||||||
|
@ -191,7 +191,7 @@ public class FDroid extends ActionBarActivity {
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
case R.id.action_about:
|
case R.id.action_about:
|
||||||
View view = null;
|
View view;
|
||||||
if (Build.VERSION.SDK_INT >= 11) {
|
if (Build.VERSION.SDK_INT >= 11) {
|
||||||
LayoutInflater li = LayoutInflater.from(this);
|
LayoutInflater li = LayoutInflater.from(this);
|
||||||
view = li.inflate(R.layout.about, null);
|
view = li.inflate(R.layout.about, null);
|
||||||
@ -211,7 +211,7 @@ public class FDroid extends ActionBarActivity {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Builder p = null;
|
Builder p;
|
||||||
if (Build.VERSION.SDK_INT >= 11) {
|
if (Build.VERSION.SDK_INT >= 11) {
|
||||||
p = new AlertDialog.Builder(this).setView(view);
|
p = new AlertDialog.Builder(this).setView(view);
|
||||||
} else {
|
} else {
|
||||||
|
@ -65,11 +65,11 @@ public class FDroidApp extends Application {
|
|||||||
public static String ipAddressString = null;
|
public static String ipAddressString = null;
|
||||||
public static String ssid = "";
|
public static String ssid = "";
|
||||||
public static String bssid = "";
|
public static String bssid = "";
|
||||||
public static Repo repo = new Repo();
|
public static final Repo repo = new Repo();
|
||||||
public static Set<String> selectedApps = null; // init in SelectLocalAppsFragment
|
public static Set<String> selectedApps = null; // init in SelectLocalAppsFragment
|
||||||
|
|
||||||
// Leaving the fully qualified class name here to help clarify the difference between spongy/bouncy castle.
|
// Leaving the fully qualified class name here to help clarify the difference between spongy/bouncy castle.
|
||||||
private static org.spongycastle.jce.provider.BouncyCastleProvider spongyCastleProvider;
|
private static final org.spongycastle.jce.provider.BouncyCastleProvider spongyCastleProvider;
|
||||||
private static Messenger localRepoServiceMessenger = null;
|
private static Messenger localRepoServiceMessenger = null;
|
||||||
private static boolean localRepoServiceIsBound = false;
|
private static boolean localRepoServiceIsBound = false;
|
||||||
|
|
||||||
@ -276,7 +276,7 @@ public class FDroidApp extends Application {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ServiceConnection serviceConnection = new ServiceConnection() {
|
private static final ServiceConnection serviceConnection = new ServiceConnection() {
|
||||||
@Override
|
@Override
|
||||||
public void onServiceConnected(ComponentName className, IBinder service) {
|
public void onServiceConnected(ComponentName className, IBinder service) {
|
||||||
localRepoServiceMessenger = new Messenger(service);
|
localRepoServiceMessenger = new Messenger(service);
|
||||||
|
@ -98,7 +98,7 @@ public class Hasher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String hex(Certificate cert) {
|
public static String hex(Certificate cert) {
|
||||||
byte[] encoded = null;
|
byte[] encoded;
|
||||||
try {
|
try {
|
||||||
encoded = cert.getEncoded();
|
encoded = cert.getEncoded();
|
||||||
} catch(CertificateEncodingException e) {
|
} catch(CertificateEncodingException e) {
|
||||||
|
@ -78,14 +78,14 @@ public class Preferences implements SharedPreferences.OnSharedPreferenceChangeLi
|
|||||||
private boolean compactLayout = DEFAULT_COMPACT_LAYOUT;
|
private boolean compactLayout = DEFAULT_COMPACT_LAYOUT;
|
||||||
private boolean filterAppsRequiringRoot = DEFAULT_ROOTED;
|
private boolean filterAppsRequiringRoot = DEFAULT_ROOTED;
|
||||||
|
|
||||||
private Map<String,Boolean> initialized = new HashMap<>();
|
private final Map<String,Boolean> initialized = new HashMap<>();
|
||||||
|
|
||||||
private List<ChangeListener> compactLayoutListeners = new ArrayList<>();
|
private final List<ChangeListener> compactLayoutListeners = new ArrayList<>();
|
||||||
private List<ChangeListener> filterAppsRequiringRootListeners = new ArrayList<>();
|
private final List<ChangeListener> filterAppsRequiringRootListeners = new ArrayList<>();
|
||||||
private List<ChangeListener> updateHistoryListeners = new ArrayList<>();
|
private final List<ChangeListener> updateHistoryListeners = new ArrayList<>();
|
||||||
private List<ChangeListener> localRepoBonjourListeners = new ArrayList<>();
|
private final List<ChangeListener> localRepoBonjourListeners = new ArrayList<>();
|
||||||
private List<ChangeListener> localRepoNameListeners = new ArrayList<>();
|
private final List<ChangeListener> localRepoNameListeners = new ArrayList<>();
|
||||||
private List<ChangeListener> localRepoHttpsListeners = new ArrayList<>();
|
private final List<ChangeListener> localRepoHttpsListeners = new ArrayList<>();
|
||||||
|
|
||||||
private boolean isInitialized(String key) {
|
private boolean isInitialized(String key) {
|
||||||
return initialized.containsKey(key) && initialized.get(key);
|
return initialized.containsKey(key) && initialized.get(key);
|
||||||
|
@ -23,7 +23,7 @@ public interface ProgressListener {
|
|||||||
// that function can initialize "total" and progressively
|
// that function can initialize "total" and progressively
|
||||||
// update "progress"
|
// update "progress"
|
||||||
public int progress;
|
public int progress;
|
||||||
public int total;
|
public final int total;
|
||||||
|
|
||||||
public Event(String type) {
|
public Event(String type) {
|
||||||
this(type, NO_VALUE, NO_VALUE, null);
|
this(type, NO_VALUE, NO_VALUE, null);
|
||||||
|
@ -20,8 +20,8 @@ import com.google.zxing.encode.QRCodeEncoder;
|
|||||||
public class QrGenAsyncTask extends AsyncTask<String, Void, Void> {
|
public class QrGenAsyncTask extends AsyncTask<String, Void, Void> {
|
||||||
private static final String TAG = "fdroid.QrGenAsyncTask";
|
private static final String TAG = "fdroid.QrGenAsyncTask";
|
||||||
|
|
||||||
private Activity activity;
|
private final Activity activity;
|
||||||
private int viewId;
|
private final int viewId;
|
||||||
private Bitmap qrBitmap;
|
private Bitmap qrBitmap;
|
||||||
|
|
||||||
public QrGenAsyncTask(Activity activity, int viewId) {
|
public QrGenAsyncTask(Activity activity, int viewId) {
|
||||||
@ -63,7 +63,7 @@ public class QrGenAsyncTask extends AsyncTask<String, Void, Void> {
|
|||||||
} catch (WriterException e) {
|
} catch (WriterException e) {
|
||||||
Log.e(TAG, e.getMessage());
|
Log.e(TAG, e.getMessage());
|
||||||
}
|
}
|
||||||
return (Void) null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -36,14 +36,14 @@ import java.util.List;
|
|||||||
public class RepoXMLHandler extends DefaultHandler {
|
public class RepoXMLHandler extends DefaultHandler {
|
||||||
|
|
||||||
// The repo we're processing.
|
// The repo we're processing.
|
||||||
private Repo repo;
|
private final Repo repo;
|
||||||
|
|
||||||
private List<App> apps = new ArrayList<>();
|
private final List<App> apps = new ArrayList<>();
|
||||||
private List<Apk> apksList = new ArrayList<>();
|
private final List<Apk> apksList = new ArrayList<>();
|
||||||
|
|
||||||
private App curapp = null;
|
private App curapp = null;
|
||||||
private Apk curapk = null;
|
private Apk curapk = null;
|
||||||
private StringBuilder curchars = new StringBuilder();
|
private final StringBuilder curchars = new StringBuilder();
|
||||||
|
|
||||||
// After processing the XML, these will be -1 if the index didn't specify
|
// After processing the XML, these will be -1 if the index didn't specify
|
||||||
// them - otherwise it will be the value specified.
|
// them - otherwise it will be the value specified.
|
||||||
@ -61,7 +61,7 @@ public class RepoXMLHandler extends DefaultHandler {
|
|||||||
private String hashType;
|
private String hashType;
|
||||||
|
|
||||||
private int progressCounter = 0;
|
private int progressCounter = 0;
|
||||||
private ProgressListener progressListener;
|
private final ProgressListener progressListener;
|
||||||
|
|
||||||
private int totalAppCount;
|
private int totalAppCount;
|
||||||
|
|
||||||
|
@ -56,7 +56,6 @@ import org.fdroid.fdroid.net.Downloader;
|
|||||||
import org.fdroid.fdroid.updater.RepoUpdater;
|
import org.fdroid.fdroid.updater.RepoUpdater;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -143,8 +143,8 @@ public final class Utils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean copy(File inFile, File outFile) {
|
public static boolean copy(File inFile, File outFile) {
|
||||||
InputStream input = null;
|
InputStream input;
|
||||||
OutputStream output = null;
|
OutputStream output;
|
||||||
try {
|
try {
|
||||||
input = new FileInputStream(inFile);
|
input = new FileInputStream(inFile);
|
||||||
output = new FileOutputStream(outFile);
|
output = new FileOutputStream(outFile);
|
||||||
@ -358,7 +358,7 @@ public final class Utils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class CommaSeparatedList implements Iterable<String> {
|
public static class CommaSeparatedList implements Iterable<String> {
|
||||||
private String value;
|
private final String value;
|
||||||
|
|
||||||
private CommaSeparatedList(String list) {
|
private CommaSeparatedList(String list) {
|
||||||
value = list;
|
value = list;
|
||||||
|
@ -18,8 +18,8 @@ public class TabManager {
|
|||||||
public static final int INDEX_INSTALLED = 1;
|
public static final int INDEX_INSTALLED = 1;
|
||||||
public static final int INDEX_CAN_UPDATE = 2;
|
public static final int INDEX_CAN_UPDATE = 2;
|
||||||
|
|
||||||
private ViewPager pager;
|
private final ViewPager pager;
|
||||||
private FDroid parent;
|
private final FDroid parent;
|
||||||
private final ActionBar actionBar;
|
private final ActionBar actionBar;
|
||||||
private Spinner actionBarSpinner = null;
|
private Spinner actionBarSpinner = null;
|
||||||
|
|
||||||
|
@ -278,8 +278,9 @@ public class App extends ValueObject implements Comparable<App> {
|
|||||||
if (features != null && features.length > 0) {
|
if (features != null && features.length > 0) {
|
||||||
List<String> featureNames = new ArrayList<>(features.length);
|
List<String> featureNames = new ArrayList<>(features.length);
|
||||||
|
|
||||||
for (int i = 0; i < features.length; i++)
|
for (FeatureInfo feature : features) {
|
||||||
featureNames.add(features[i].name);
|
featureNames.add(feature.name);
|
||||||
|
}
|
||||||
|
|
||||||
apk.features = Utils.CommaSeparatedList.make(featureNames);
|
apk.features = Utils.CommaSeparatedList.make(featureNames);
|
||||||
}
|
}
|
||||||
|
@ -581,7 +581,7 @@ public class AppProvider extends FDroidProvider {
|
|||||||
} else {
|
} else {
|
||||||
selection.append(" AND ");
|
selection.append(" AND ");
|
||||||
}
|
}
|
||||||
selection.append(column + " like ?");
|
selection.append(column).append(" like ?");
|
||||||
selectionKeywords[iKeyword] = keyword;
|
selectionKeywords[iKeyword] = keyword;
|
||||||
iKeyword++;
|
iKeyword++;
|
||||||
}
|
}
|
||||||
|
@ -101,7 +101,7 @@ public class DBHelper extends SQLiteOpenHelper {
|
|||||||
|
|
||||||
private static final int DB_VERSION = 47;
|
private static final int DB_VERSION = 47;
|
||||||
|
|
||||||
private Context context;
|
private final Context context;
|
||||||
|
|
||||||
public DBHelper(Context context) {
|
public DBHelper(Context context) {
|
||||||
super(context, DATABASE_NAME, null, DB_VERSION);
|
super(context, DATABASE_NAME, null, DB_VERSION);
|
||||||
|
@ -24,10 +24,10 @@ public class InstalledAppCacheUpdater {
|
|||||||
|
|
||||||
private static final String TAG = "fdroid.InstalledAppCacheUpdater";
|
private static final String TAG = "fdroid.InstalledAppCacheUpdater";
|
||||||
|
|
||||||
private Context context;
|
private final Context context;
|
||||||
|
|
||||||
private List<PackageInfo> toInsert = new ArrayList<>();
|
private final List<PackageInfo> toInsert = new ArrayList<>();
|
||||||
private List<String> toDelete = new ArrayList<>();
|
private final List<String> toDelete = new ArrayList<>();
|
||||||
|
|
||||||
protected InstalledAppCacheUpdater(Context context) {
|
protected InstalledAppCacheUpdater(Context context) {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
|
@ -5,8 +5,8 @@ import java.util.List;
|
|||||||
|
|
||||||
abstract class QueryBuilder {
|
abstract class QueryBuilder {
|
||||||
|
|
||||||
private List<String> fields = new ArrayList<>();
|
private final List<String> fields = new ArrayList<>();
|
||||||
private StringBuilder tables = new StringBuilder(getRequiredTables());
|
private final StringBuilder tables = new StringBuilder(getRequiredTables());
|
||||||
private String selection = null;
|
private String selection = null;
|
||||||
private String orderBy = null;
|
private String orderBy = null;
|
||||||
|
|
||||||
|
@ -28,8 +28,8 @@ import android.os.AsyncTask;
|
|||||||
|
|
||||||
public class CheckRootAsyncTask extends AsyncTask<Void, Void, Boolean> {
|
public class CheckRootAsyncTask extends AsyncTask<Void, Void, Boolean> {
|
||||||
ProgressDialog mDialog;
|
ProgressDialog mDialog;
|
||||||
Context mContext;
|
final Context mContext;
|
||||||
CheckRootCallback mCallback;
|
final CheckRootCallback mCallback;
|
||||||
|
|
||||||
public interface CheckRootCallback {
|
public interface CheckRootCallback {
|
||||||
public void onRootCheck(boolean rootGranted);
|
public void onRootCheck(boolean rootGranted);
|
||||||
|
@ -36,9 +36,9 @@ import android.util.Log;
|
|||||||
* instantiate a working Installer based on F-Droids granted permissions.
|
* instantiate a working Installer based on F-Droids granted permissions.
|
||||||
*/
|
*/
|
||||||
abstract public class Installer {
|
abstract public class Installer {
|
||||||
protected Context mContext;
|
protected final Context mContext;
|
||||||
protected PackageManager mPm;
|
protected final PackageManager mPm;
|
||||||
protected InstallerCallback mCallback;
|
protected final InstallerCallback mCallback;
|
||||||
|
|
||||||
public static final String TAG = "fdroid.Installer";
|
public static final String TAG = "fdroid.Installer";
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ public class LocalRepoManager {
|
|||||||
"swap-tick-not-done.png"
|
"swap-tick-not-done.png"
|
||||||
};
|
};
|
||||||
|
|
||||||
private Map<String, App> apps = new HashMap<>();
|
private final Map<String, App> apps = new HashMap<>();
|
||||||
|
|
||||||
public final SanitizedFile xmlIndex;
|
public final SanitizedFile xmlIndex;
|
||||||
private SanitizedFile xmlIndexJar = null;
|
private SanitizedFile xmlIndexJar = null;
|
||||||
|
@ -45,7 +45,7 @@ public class LocalRepoService extends Service {
|
|||||||
private Notification notification;
|
private Notification notification;
|
||||||
// Unique Identification Number for the Notification.
|
// Unique Identification Number for the Notification.
|
||||||
// We use it on Notification start, and to cancel it.
|
// We use it on Notification start, and to cancel it.
|
||||||
private int NOTIFICATION = R.string.local_repo_running;
|
private final int NOTIFICATION = R.string.local_repo_running;
|
||||||
|
|
||||||
private Handler webServerThreadHandler = null;
|
private Handler webServerThreadHandler = null;
|
||||||
private LocalHTTPD localHttpd;
|
private LocalHTTPD localHttpd;
|
||||||
@ -90,7 +90,7 @@ public class LocalRepoService extends Service {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private BroadcastReceiver onWifiChange = new BroadcastReceiver() {
|
private final BroadcastReceiver onWifiChange = new BroadcastReceiver() {
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent i) {
|
public void onReceive(Context context, Intent i) {
|
||||||
stopNetworkServices();
|
stopNetworkServices();
|
||||||
@ -109,7 +109,7 @@ public class LocalRepoService extends Service {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private ChangeListener localRepoHttpsChangeListener = new ChangeListener() {
|
private final ChangeListener localRepoHttpsChangeListener = new ChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onPreferenceChange() {
|
public void onPreferenceChange() {
|
||||||
Log.i(TAG, "onPreferenceChange");
|
Log.i(TAG, "onPreferenceChange");
|
||||||
|
@ -59,9 +59,9 @@ public class ApkDownloader implements AsyncDownloadWrapper.Listener {
|
|||||||
*/
|
*/
|
||||||
public static final String EVENT_DATA_ERROR_TYPE = "apkDownloadErrorType";
|
public static final String EVENT_DATA_ERROR_TYPE = "apkDownloadErrorType";
|
||||||
|
|
||||||
private Apk curApk;
|
private final Apk curApk;
|
||||||
private String repoAddress;
|
private final String repoAddress;
|
||||||
private SanitizedFile localFile;
|
private final SanitizedFile localFile;
|
||||||
|
|
||||||
private ProgressListener listener;
|
private ProgressListener listener;
|
||||||
private AsyncDownloadWrapper dlWrapper = null;
|
private AsyncDownloadWrapper dlWrapper = null;
|
||||||
@ -69,7 +69,7 @@ public class ApkDownloader implements AsyncDownloadWrapper.Listener {
|
|||||||
private int totalSize = 0;
|
private int totalSize = 0;
|
||||||
private boolean isComplete = false;
|
private boolean isComplete = false;
|
||||||
|
|
||||||
private long id = ++downloadIdCounter;
|
private final long id = ++downloadIdCounter;
|
||||||
|
|
||||||
public void setProgressListener(ProgressListener listener) {
|
public void setProgressListener(ProgressListener listener) {
|
||||||
this.listener = listener;
|
this.listener = listener;
|
||||||
|
@ -26,8 +26,8 @@ public class AsyncDownloadWrapper extends Handler {
|
|||||||
private static final int MSG_ERROR = 4;
|
private static final int MSG_ERROR = 4;
|
||||||
private static final String MSG_DATA = "data";
|
private static final String MSG_DATA = "data";
|
||||||
|
|
||||||
private Downloader downloader;
|
private final Downloader downloader;
|
||||||
private Listener listener;
|
private final Listener listener;
|
||||||
private DownloadThread downloadThread = null;
|
private DownloadThread downloadThread = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -24,7 +24,7 @@ public abstract class Downloader {
|
|||||||
|
|
||||||
private ProgressListener progressListener = null;
|
private ProgressListener progressListener = null;
|
||||||
private Bundle eventData = null;
|
private Bundle eventData = null;
|
||||||
private File outputFile;
|
private final File outputFile;
|
||||||
|
|
||||||
protected URL sourceUrl;
|
protected URL sourceUrl;
|
||||||
protected String cacheTag = null;
|
protected String cacheTag = null;
|
||||||
|
@ -40,15 +40,19 @@ public class LocalHTTPD extends NanoHTTPD {
|
|||||||
StringTokenizer st = new StringTokenizer(uri, "/ ", true);
|
StringTokenizer st = new StringTokenizer(uri, "/ ", true);
|
||||||
while (st.hasMoreTokens()) {
|
while (st.hasMoreTokens()) {
|
||||||
String tok = st.nextToken();
|
String tok = st.nextToken();
|
||||||
if (tok.equals("/"))
|
switch (tok) {
|
||||||
|
case "/":
|
||||||
newUri += "/";
|
newUri += "/";
|
||||||
else if (tok.equals(" "))
|
break;
|
||||||
|
case " ":
|
||||||
newUri += "%20";
|
newUri += "%20";
|
||||||
else {
|
break;
|
||||||
|
default:
|
||||||
try {
|
try {
|
||||||
newUri += URLEncoder.encode(tok, "UTF-8");
|
newUri += URLEncoder.encode(tok, "UTF-8");
|
||||||
} catch (UnsupportedEncodingException ignored) {
|
} catch (UnsupportedEncodingException ignored) {
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return newUri;
|
return newUri;
|
||||||
@ -147,8 +151,7 @@ public class LocalHTTPD extends NanoHTTPD {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Response response = null;
|
Response response = serveFile(uri, headers, f, getMimeTypeForFile(uri));
|
||||||
response = serveFile(uri, headers, f, getMimeTypeForFile(uri));
|
|
||||||
return response != null ? response :
|
return response != null ? response :
|
||||||
createResponse(Response.Status.NOT_FOUND, NanoHTTPD.MIME_PLAINTEXT,
|
createResponse(Response.Status.NOT_FOUND, NanoHTTPD.MIME_PLAINTEXT,
|
||||||
"Error 404, file not found.");
|
"Error 404, file not found.");
|
||||||
|
@ -127,9 +127,9 @@ public class MDnsHelper implements ServiceListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class RepoScanListAdapter extends BaseAdapter {
|
public static class RepoScanListAdapter extends BaseAdapter {
|
||||||
private Context mContext;
|
private final Context mContext;
|
||||||
private LayoutInflater mLayoutInflater;
|
private final LayoutInflater mLayoutInflater;
|
||||||
private List<DiscoveredRepo> mEntries = new ArrayList<>();
|
private final List<DiscoveredRepo> mEntries = new ArrayList<>();
|
||||||
|
|
||||||
public RepoScanListAdapter(Context context) {
|
public RepoScanListAdapter(Context context) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
|
@ -54,8 +54,8 @@ public class LocalRepoActivity extends ActionBarActivity {
|
|||||||
|
|
||||||
private Timer stopTimer;
|
private Timer stopTimer;
|
||||||
|
|
||||||
private int SET_IP_ADDRESS = 7345;
|
private final int SET_IP_ADDRESS = 7345;
|
||||||
private int UPDATE_REPO = 7346;
|
private final int UPDATE_REPO = 7346;
|
||||||
|
|
||||||
/** Called when the activity is first created. */
|
/** Called when the activity is first created. */
|
||||||
@Override
|
@Override
|
||||||
@ -108,14 +108,14 @@ public class LocalRepoActivity extends ActionBarActivity {
|
|||||||
LocalBroadcastManager.getInstance(this).unregisterReceiver(onLocalRepoChange);
|
LocalBroadcastManager.getInstance(this).unregisterReceiver(onLocalRepoChange);
|
||||||
}
|
}
|
||||||
|
|
||||||
private BroadcastReceiver onWifiChange = new BroadcastReceiver() {
|
private final BroadcastReceiver onWifiChange = new BroadcastReceiver() {
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent i) {
|
public void onReceive(Context context, Intent i) {
|
||||||
resetNetworkInfo();
|
resetNetworkInfo();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private BroadcastReceiver onLocalRepoChange = new BroadcastReceiver() {
|
private final BroadcastReceiver onLocalRepoChange = new BroadcastReceiver() {
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent i) {
|
public void onReceive(Context context, Intent i) {
|
||||||
String state = i.getStringExtra(LocalRepoService.STATE);
|
String state = i.getStringExtra(LocalRepoService.STATE);
|
||||||
@ -185,7 +185,7 @@ public class LocalRepoActivity extends ActionBarActivity {
|
|||||||
setUIFromWifi();
|
setUIFromWifi();
|
||||||
} else if (requestCode == UPDATE_REPO) {
|
} else if (requestCode == UPDATE_REPO) {
|
||||||
setUIFromWifi();
|
setUIFromWifi();
|
||||||
new UpdateAsyncTask(this, FDroidApp.selectedApps.toArray(new String[0]))
|
new UpdateAsyncTask(this, FDroidApp.selectedApps.toArray(new String[FDroidApp.selectedApps.size()]))
|
||||||
.execute();
|
.execute();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -277,9 +277,9 @@ public class LocalRepoActivity extends ActionBarActivity {
|
|||||||
|
|
||||||
class UpdateAsyncTask extends AsyncTask<Void, String, Void> {
|
class UpdateAsyncTask extends AsyncTask<Void, String, Void> {
|
||||||
private static final String TAG = "fdroid.LocalRepoActivity.UpdateAsyncTask";
|
private static final String TAG = "fdroid.LocalRepoActivity.UpdateAsyncTask";
|
||||||
private ProgressDialog progressDialog;
|
private final ProgressDialog progressDialog;
|
||||||
private String[] selectedApps;
|
private final String[] selectedApps;
|
||||||
private Uri sharingUri;
|
private final Uri sharingUri;
|
||||||
|
|
||||||
public UpdateAsyncTask(Context c, String[] apps) {
|
public UpdateAsyncTask(Context c, String[] apps) {
|
||||||
selectedApps = apps;
|
selectedApps = apps;
|
||||||
|
@ -52,7 +52,7 @@ public class QrWizardDownloadActivity extends ActionBarActivity {
|
|||||||
LocalBroadcastManager.getInstance(this).unregisterReceiver(onWifiChange);
|
LocalBroadcastManager.getInstance(this).unregisterReceiver(onWifiChange);
|
||||||
}
|
}
|
||||||
|
|
||||||
private BroadcastReceiver onWifiChange = new BroadcastReceiver() {
|
private final BroadcastReceiver onWifiChange = new BroadcastReceiver() {
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent i) {
|
public void onReceive(Context context, Intent i) {
|
||||||
Log.i(TAG, "onWifiChange.onReceive()");
|
Log.i(TAG, "onWifiChange.onReceive()");
|
||||||
|
@ -63,7 +63,7 @@ public class QrWizardWifiNetworkActivity extends ActionBarActivity {
|
|||||||
LocalBroadcastManager.getInstance(this).unregisterReceiver(onWifiChange);
|
LocalBroadcastManager.getInstance(this).unregisterReceiver(onWifiChange);
|
||||||
}
|
}
|
||||||
|
|
||||||
private BroadcastReceiver onWifiChange = new BroadcastReceiver() {
|
private final BroadcastReceiver onWifiChange = new BroadcastReceiver() {
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent i) {
|
public void onReceive(Context context, Intent i) {
|
||||||
Log.i(TAG, "onWifiChange.onReceive()");
|
Log.i(TAG, "onWifiChange.onReceive()");
|
||||||
|
@ -58,7 +58,7 @@ public class SelectLocalAppsActivity extends ActionBarActivity {
|
|||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ActionMode.Callback mActionModeCallback = new ActionMode.Callback() {
|
public final ActionMode.Callback mActionModeCallback = new ActionMode.Callback() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
|
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
|
||||||
|
@ -71,7 +71,7 @@ public class AvailableAppsFragment extends AppListFragment implements
|
|||||||
|
|
||||||
private class CategoryObserver extends ContentObserver {
|
private class CategoryObserver extends ContentObserver {
|
||||||
|
|
||||||
private ArrayAdapter<String> adapter;
|
private final ArrayAdapter<String> adapter;
|
||||||
|
|
||||||
public CategoryObserver(ArrayAdapter<String> adapter) {
|
public CategoryObserver(ArrayAdapter<String> adapter) {
|
||||||
super(null);
|
super(null);
|
||||||
|
@ -293,7 +293,7 @@ public class RepoDetailsFragment extends Fragment {
|
|||||||
|
|
||||||
@TargetApi(16)
|
@TargetApi(16)
|
||||||
private void prepareNfcMenuItems(Menu menu) {
|
private void prepareNfcMenuItems(Menu menu) {
|
||||||
boolean needsEnableNfcMenuItem = false;
|
boolean needsEnableNfcMenuItem;
|
||||||
NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(getActivity());
|
NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(getActivity());
|
||||||
if (nfcAdapter == null) {
|
if (nfcAdapter == null) {
|
||||||
return;
|
return;
|
||||||
|
@ -24,7 +24,7 @@ import org.fdroid.fdroid.net.WifiStateChangeService;
|
|||||||
|
|
||||||
public class JoinWifiFragment extends Fragment {
|
public class JoinWifiFragment extends Fragment {
|
||||||
|
|
||||||
private BroadcastReceiver onWifiChange = new BroadcastReceiver() {
|
private final BroadcastReceiver onWifiChange = new BroadcastReceiver() {
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
refreshWifiState();
|
refreshWifiState();
|
||||||
|
@ -43,7 +43,7 @@ public class WifiQrFragment extends Fragment {
|
|||||||
|
|
||||||
private static final String TAG = "fdroid.WifiQrFragment";
|
private static final String TAG = "fdroid.WifiQrFragment";
|
||||||
|
|
||||||
private BroadcastReceiver onWifiChange = new BroadcastReceiver() {
|
private final BroadcastReceiver onWifiChange = new BroadcastReceiver() {
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent i) {
|
public void onReceive(Context context, Intent i) {
|
||||||
setUIFromWifi();
|
setUIFromWifi();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user