diff --git a/F-Droid/src/com/google/zxing/encode/Contents.java b/F-Droid/src/com/google/zxing/encode/Contents.java index 6271fa9af..bc10515b4 100755 --- a/F-Droid/src/com/google/zxing/encode/Contents.java +++ b/F-Droid/src/com/google/zxing/encode/Contents.java @@ -25,90 +25,90 @@ import android.provider.ContactsContract; * @author dswitkin@google.com (Daniel Switkin) */ public final class Contents { - private Contents() { - } - - public static final class Type { - /** - * Plain text. Use Intent.putExtra(DATA, string). This can be used for URLs too, but string - * must include "http://" or "https://". - */ - public static final String TEXT = "TEXT_TYPE"; - - /** - * An email type. Use Intent.putExtra(DATA, string) where string is the email address. - */ - public static final String EMAIL = "EMAIL_TYPE"; - - /** - * Use Intent.putExtra(DATA, string) where string is the phone number to call. - */ - public static final String PHONE = "PHONE_TYPE"; - - /** - * An SMS type. Use Intent.putExtra(DATA, string) where string is the number to SMS. - */ - public static final String SMS = "SMS_TYPE"; - - /** - * A contact. Send a request to encode it as follows: - *

- * import android.provider.Contacts; - *

- * Intent intent = new Intent(Intents.Encode.ACTION); - * intent.putExtra(Intents.Encode.TYPE, CONTACT); - * Bundle bundle = new Bundle(); - * bundle.putString(Contacts.Intents.Insert.NAME, "Jenny"); - * bundle.putString(Contacts.Intents.Insert.PHONE, "8675309"); - * bundle.putString(Contacts.Intents.Insert.EMAIL, "jenny@the80s.com"); - * bundle.putString(Contacts.Intents.Insert.POSTAL, "123 Fake St. San Francisco, CA 94102"); - * intent.putExtra(Intents.Encode.DATA, bundle); - */ - public static final String CONTACT = "CONTACT_TYPE"; - - /** - * A geographic location. Use as follows: - * Bundle bundle = new Bundle(); - * bundle.putFloat("LAT", latitude); - * bundle.putFloat("LONG", longitude); - * intent.putExtra(Intents.Encode.DATA, bundle); - */ - public static final String LOCATION = "LOCATION_TYPE"; - - private Type() { + private Contents() { } - } - public static final String URL_KEY = "URL_KEY"; + public static final class Type { + /** + * Plain text. Use Intent.putExtra(DATA, string). This can be used for URLs too, but string + * must include "http://" or "https://". + */ + public static final String TEXT = "TEXT_TYPE"; - public static final String NOTE_KEY = "NOTE_KEY"; + /** + * An email type. Use Intent.putExtra(DATA, string) where string is the email address. + */ + public static final String EMAIL = "EMAIL_TYPE"; - /** - * When using Type.CONTACT, these arrays provide the keys for adding or retrieving multiple - * phone numbers and addresses. - */ - public static final String[] PHONE_KEYS = { - ContactsContract.Intents.Insert.PHONE, - ContactsContract.Intents.Insert.SECONDARY_PHONE, - ContactsContract.Intents.Insert.TERTIARY_PHONE - }; + /** + * Use Intent.putExtra(DATA, string) where string is the phone number to call. + */ + public static final String PHONE = "PHONE_TYPE"; - public static final String[] PHONE_TYPE_KEYS = { - ContactsContract.Intents.Insert.PHONE_TYPE, - ContactsContract.Intents.Insert.SECONDARY_PHONE_TYPE, - ContactsContract.Intents.Insert.TERTIARY_PHONE_TYPE - }; + /** + * An SMS type. Use Intent.putExtra(DATA, string) where string is the number to SMS. + */ + public static final String SMS = "SMS_TYPE"; - public static final String[] EMAIL_KEYS = { - ContactsContract.Intents.Insert.EMAIL, - ContactsContract.Intents.Insert.SECONDARY_EMAIL, - ContactsContract.Intents.Insert.TERTIARY_EMAIL - }; + /** + * A contact. Send a request to encode it as follows: + *

+ * import android.provider.Contacts; + *

+ * Intent intent = new Intent(Intents.Encode.ACTION); + * intent.putExtra(Intents.Encode.TYPE, CONTACT); + * Bundle bundle = new Bundle(); + * bundle.putString(Contacts.Intents.Insert.NAME, "Jenny"); + * bundle.putString(Contacts.Intents.Insert.PHONE, "8675309"); + * bundle.putString(Contacts.Intents.Insert.EMAIL, "jenny@the80s.com"); + * bundle.putString(Contacts.Intents.Insert.POSTAL, "123 Fake St. San Francisco, CA 94102"); + * intent.putExtra(Intents.Encode.DATA, bundle); + */ + public static final String CONTACT = "CONTACT_TYPE"; - public static final String[] EMAIL_TYPE_KEYS = { - ContactsContract.Intents.Insert.EMAIL_TYPE, - ContactsContract.Intents.Insert.SECONDARY_EMAIL_TYPE, - ContactsContract.Intents.Insert.TERTIARY_EMAIL_TYPE - }; + /** + * A geographic location. Use as follows: + * Bundle bundle = new Bundle(); + * bundle.putFloat("LAT", latitude); + * bundle.putFloat("LONG", longitude); + * intent.putExtra(Intents.Encode.DATA, bundle); + */ + public static final String LOCATION = "LOCATION_TYPE"; + + private Type() { + } + } + + public static final String URL_KEY = "URL_KEY"; + + public static final String NOTE_KEY = "NOTE_KEY"; + + /** + * When using Type.CONTACT, these arrays provide the keys for adding or retrieving multiple + * phone numbers and addresses. + */ + public static final String[] PHONE_KEYS = { + ContactsContract.Intents.Insert.PHONE, + ContactsContract.Intents.Insert.SECONDARY_PHONE, + ContactsContract.Intents.Insert.TERTIARY_PHONE + }; + + public static final String[] PHONE_TYPE_KEYS = { + ContactsContract.Intents.Insert.PHONE_TYPE, + ContactsContract.Intents.Insert.SECONDARY_PHONE_TYPE, + ContactsContract.Intents.Insert.TERTIARY_PHONE_TYPE + }; + + public static final String[] EMAIL_KEYS = { + ContactsContract.Intents.Insert.EMAIL, + ContactsContract.Intents.Insert.SECONDARY_EMAIL, + ContactsContract.Intents.Insert.TERTIARY_EMAIL + }; + + public static final String[] EMAIL_TYPE_KEYS = { + ContactsContract.Intents.Insert.EMAIL_TYPE, + ContactsContract.Intents.Insert.SECONDARY_EMAIL_TYPE, + ContactsContract.Intents.Insert.TERTIARY_EMAIL_TYPE + }; } diff --git a/F-Droid/src/com/google/zxing/encode/QRCodeEncoder.java b/F-Droid/src/com/google/zxing/encode/QRCodeEncoder.java index 3a444df58..b5d927499 100755 --- a/F-Droid/src/com/google/zxing/encode/QRCodeEncoder.java +++ b/F-Droid/src/com/google/zxing/encode/QRCodeEncoder.java @@ -83,118 +83,118 @@ public final class QRCodeEncoder { private void encodeQRCodeContents(String data, Bundle bundle, String type) { switch (type) { - case Contents.Type.TEXT: - if (data != null && data.length() > 0) { - contents = data; - displayContents = data; - title = "Text"; - } - break; - case Contents.Type.EMAIL: - data = trim(data); - if (data != null) { - contents = "mailto:" + data; - displayContents = data; - title = "E-Mail"; - } - break; - case Contents.Type.PHONE: - data = trim(data); - if (data != null) { - contents = "tel:" + data; - displayContents = PhoneNumberUtils.formatNumber(data); - title = "Phone"; - } - break; - case Contents.Type.SMS: - data = trim(data); - if (data != null) { - contents = "sms:" + data; - displayContents = PhoneNumberUtils.formatNumber(data); - title = "SMS"; - } - break; - case Contents.Type.CONTACT: - if (bundle != null) { - StringBuilder newContents = new StringBuilder(100); - StringBuilder newDisplayContents = new StringBuilder(100); - - newContents.append("MECARD:"); - - String name = trim(bundle.getString(ContactsContract.Intents.Insert.NAME)); - if (name != null) { - newContents.append("N:").append(escapeMECARD(name)).append(';'); - newDisplayContents.append(name); + case Contents.Type.TEXT: + if (data != null && data.length() > 0) { + contents = data; + displayContents = data; + title = "Text"; } - - String address = trim(bundle.getString(ContactsContract.Intents.Insert.POSTAL)); - if (address != null) { - newContents.append("ADR:").append(escapeMECARD(address)).append(';'); - newDisplayContents.append('\n').append(address); + break; + case Contents.Type.EMAIL: + data = trim(data); + if (data != null) { + contents = "mailto:" + data; + displayContents = data; + title = "E-Mail"; } + break; + case Contents.Type.PHONE: + data = trim(data); + if (data != null) { + contents = "tel:" + data; + displayContents = PhoneNumberUtils.formatNumber(data); + title = "Phone"; + } + break; + case Contents.Type.SMS: + data = trim(data); + if (data != null) { + contents = "sms:" + data; + displayContents = PhoneNumberUtils.formatNumber(data); + title = "SMS"; + } + break; + case Contents.Type.CONTACT: + if (bundle != null) { + StringBuilder newContents = new StringBuilder(100); + StringBuilder newDisplayContents = new StringBuilder(100); - Collection uniquePhones = new HashSet<>(Contents.PHONE_KEYS.length); - for (int x = 0; x < Contents.PHONE_KEYS.length; x++) { - String phone = trim(bundle.getString(Contents.PHONE_KEYS[x])); - if (phone != null) { - uniquePhones.add(phone); + newContents.append("MECARD:"); + + String name = trim(bundle.getString(ContactsContract.Intents.Insert.NAME)); + if (name != null) { + newContents.append("N:").append(escapeMECARD(name)).append(';'); + newDisplayContents.append(name); + } + + String address = trim(bundle.getString(ContactsContract.Intents.Insert.POSTAL)); + if (address != null) { + newContents.append("ADR:").append(escapeMECARD(address)).append(';'); + newDisplayContents.append('\n').append(address); + } + + Collection uniquePhones = new HashSet<>(Contents.PHONE_KEYS.length); + for (int x = 0; x < Contents.PHONE_KEYS.length; x++) { + String phone = trim(bundle.getString(Contents.PHONE_KEYS[x])); + if (phone != null) { + uniquePhones.add(phone); + } + } + for (String phone : uniquePhones) { + newContents.append("TEL:").append(escapeMECARD(phone)).append(';'); + newDisplayContents.append('\n').append(PhoneNumberUtils.formatNumber(phone)); + } + + Collection uniqueEmails = new HashSet<>(Contents.EMAIL_KEYS.length); + for (int x = 0; x < Contents.EMAIL_KEYS.length; x++) { + String email = trim(bundle.getString(Contents.EMAIL_KEYS[x])); + if (email != null) { + uniqueEmails.add(email); + } + } + for (String email : uniqueEmails) { + newContents.append("EMAIL:").append(escapeMECARD(email)).append(';'); + newDisplayContents.append('\n').append(email); + } + + String url = trim(bundle.getString(Contents.URL_KEY)); + if (url != null) { + // escapeMECARD(url) -> wrong escape e.g. http\://zxing.google.com + newContents.append("URL:").append(url).append(';'); + newDisplayContents.append('\n').append(url); + } + + String note = trim(bundle.getString(Contents.NOTE_KEY)); + if (note != null) { + newContents.append("NOTE:").append(escapeMECARD(note)).append(';'); + newDisplayContents.append('\n').append(note); + } + + // Make sure we've encoded at least one field. + if (newDisplayContents.length() > 0) { + newContents.append(';'); + contents = newContents.toString(); + displayContents = newDisplayContents.toString(); + title = "Contact"; + } else { + contents = null; + displayContents = null; + } + + } + break; + case Contents.Type.LOCATION: + if (bundle != null) { + // These must use Bundle.getFloat(), not getDouble(), it's part of the API. + float latitude = bundle.getFloat("LAT", Float.MAX_VALUE); + float longitude = bundle.getFloat("LONG", Float.MAX_VALUE); + if (latitude != Float.MAX_VALUE && longitude != Float.MAX_VALUE) { + contents = "geo:" + latitude + ',' + longitude; + displayContents = latitude + "," + longitude; + title = "Location"; } } - for (String phone : uniquePhones) { - newContents.append("TEL:").append(escapeMECARD(phone)).append(';'); - newDisplayContents.append('\n').append(PhoneNumberUtils.formatNumber(phone)); - } - - Collection uniqueEmails = new HashSet<>(Contents.EMAIL_KEYS.length); - for (int x = 0; x < Contents.EMAIL_KEYS.length; x++) { - String email = trim(bundle.getString(Contents.EMAIL_KEYS[x])); - if (email != null) { - uniqueEmails.add(email); - } - } - for (String email : uniqueEmails) { - newContents.append("EMAIL:").append(escapeMECARD(email)).append(';'); - newDisplayContents.append('\n').append(email); - } - - String url = trim(bundle.getString(Contents.URL_KEY)); - if (url != null) { - // escapeMECARD(url) -> wrong escape e.g. http\://zxing.google.com - newContents.append("URL:").append(url).append(';'); - newDisplayContents.append('\n').append(url); - } - - String note = trim(bundle.getString(Contents.NOTE_KEY)); - if (note != null) { - newContents.append("NOTE:").append(escapeMECARD(note)).append(';'); - newDisplayContents.append('\n').append(note); - } - - // Make sure we've encoded at least one field. - if (newDisplayContents.length() > 0) { - newContents.append(';'); - contents = newContents.toString(); - displayContents = newDisplayContents.toString(); - title = "Contact"; - } else { - contents = null; - displayContents = null; - } - - } - break; - case Contents.Type.LOCATION: - if (bundle != null) { - // These must use Bundle.getFloat(), not getDouble(), it's part of the API. - float latitude = bundle.getFloat("LAT", Float.MAX_VALUE); - float longitude = bundle.getFloat("LONG", Float.MAX_VALUE); - if (latitude != Float.MAX_VALUE && longitude != Float.MAX_VALUE) { - contents = "geo:" + latitude + ',' + longitude; - displayContents = latitude + "," + longitude; - title = "Location"; - } - } - break; + break; } } diff --git a/F-Droid/src/com/google/zxing/integration/android/IntentIntegrator.java b/F-Droid/src/com/google/zxing/integration/android/IntentIntegrator.java index 4eb9415ef..a3d043dec 100644 --- a/F-Droid/src/com/google/zxing/integration/android/IntentIntegrator.java +++ b/F-Droid/src/com/google/zxing/integration/android/IntentIntegrator.java @@ -106,401 +106,401 @@ import java.util.Map; * @author Isaac Potoczny-Jones * @author Brad Drehmer * @author gcstang - */ +*/ public class IntentIntegrator { - public static final int REQUEST_CODE = 0x0000c0de; // Only use bottom 16 bits - private static final String TAG = IntentIntegrator.class.getSimpleName(); + public static final int REQUEST_CODE = 0x0000c0de; // Only use bottom 16 bits + private static final String TAG = IntentIntegrator.class.getSimpleName(); - public static final String DEFAULT_TITLE = "Install Barcode Scanner?"; - public static final String DEFAULT_MESSAGE = - "This application requires Barcode Scanner. Would you like to install it?"; - public static final String DEFAULT_YES = "Yes"; - public static final String DEFAULT_NO = "No"; + public static final String DEFAULT_TITLE = "Install Barcode Scanner?"; + public static final String DEFAULT_MESSAGE = + "This application requires Barcode Scanner. Would you like to install it?"; + public static final String DEFAULT_YES = "Yes"; + public static final String DEFAULT_NO = "No"; - private static final String BS_PACKAGE = "com.google.zxing.client.android"; - private static final String BSPLUS_PACKAGE = "com.srowen.bs.android"; + private static final String BS_PACKAGE = "com.google.zxing.client.android"; + private static final String BSPLUS_PACKAGE = "com.srowen.bs.android"; - // supported barcode formats - public static final Collection PRODUCT_CODE_TYPES = list("UPC_A", "UPC_E", "EAN_8", "EAN_13", "RSS_14"); - public static final Collection ONE_D_CODE_TYPES = - list("UPC_A", "UPC_E", "EAN_8", "EAN_13", "CODE_39", "CODE_93", "CODE_128", - "ITF", "RSS_14", "RSS_EXPANDED"); - public static final Collection QR_CODE_TYPES = Collections.singleton("QR_CODE"); - public static final Collection DATA_MATRIX_TYPES = Collections.singleton("DATA_MATRIX"); + // supported barcode formats + public static final Collection PRODUCT_CODE_TYPES = list("UPC_A", "UPC_E", "EAN_8", "EAN_13", "RSS_14"); + public static final Collection ONE_D_CODE_TYPES = + list("UPC_A", "UPC_E", "EAN_8", "EAN_13", "CODE_39", "CODE_93", "CODE_128", + "ITF", "RSS_14", "RSS_EXPANDED"); + public static final Collection QR_CODE_TYPES = Collections.singleton("QR_CODE"); + public static final Collection DATA_MATRIX_TYPES = Collections.singleton("DATA_MATRIX"); - public static final Collection ALL_CODE_TYPES = null; + public static final Collection ALL_CODE_TYPES = null; - public static final List TARGET_BARCODE_SCANNER_ONLY = Collections.singletonList(BS_PACKAGE); - public static final List TARGET_ALL_KNOWN = list( - BSPLUS_PACKAGE, // Barcode Scanner+ - BSPLUS_PACKAGE + ".simple", // Barcode Scanner+ Simple - BS_PACKAGE // Barcode Scanner - // What else supports this intent? - ); + public static final List TARGET_BARCODE_SCANNER_ONLY = Collections.singletonList(BS_PACKAGE); + public static final List TARGET_ALL_KNOWN = list( + BSPLUS_PACKAGE, // Barcode Scanner+ + BSPLUS_PACKAGE + ".simple", // Barcode Scanner+ Simple + BS_PACKAGE // Barcode Scanner + // What else supports this intent? + ); - private final Activity activity; - private final Fragment fragment; + private final Activity activity; + private final Fragment fragment; - private String title; - private String message; - private String buttonYes; - private String buttonNo; - private List targetApplications; - private final Map moreExtras = new HashMap<>(3); + private String title; + private String message; + private String buttonYes; + private String buttonNo; + private List targetApplications; + private final Map moreExtras = new HashMap<>(3); - /** - * @param activity {@link Activity} invoking the integration - */ - public IntentIntegrator(Activity activity) { - this.activity = activity; - this.fragment = null; - initializeConfiguration(); - } - - /** - * @param fragment {@link Fragment} invoking the integration. - * {@link #startActivityForResult(Intent, int)} will be called on the {@link Fragment} instead - * of an {@link Activity} - */ - public IntentIntegrator(Fragment fragment) { - this.activity = fragment.getActivity(); - this.fragment = fragment; - initializeConfiguration(); - } - - private void initializeConfiguration() { - title = DEFAULT_TITLE; - message = DEFAULT_MESSAGE; - buttonYes = DEFAULT_YES; - buttonNo = DEFAULT_NO; - targetApplications = TARGET_ALL_KNOWN; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public void setTitleByID(int titleID) { - title = activity.getString(titleID); - } - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } - - public void setMessageByID(int messageID) { - message = activity.getString(messageID); - } - - public String getButtonYes() { - return buttonYes; - } - - public void setButtonYes(String buttonYes) { - this.buttonYes = buttonYes; - } - - public void setButtonYesByID(int buttonYesID) { - buttonYes = activity.getString(buttonYesID); - } - - public String getButtonNo() { - return buttonNo; - } - - public void setButtonNo(String buttonNo) { - this.buttonNo = buttonNo; - } - - public void setButtonNoByID(int buttonNoID) { - buttonNo = activity.getString(buttonNoID); - } - - public Collection getTargetApplications() { - return targetApplications; - } - - public final void setTargetApplications(List targetApplications) { - if (targetApplications.isEmpty()) { - throw new IllegalArgumentException("No target applications"); + /** + * @param activity {@link Activity} invoking the integration + */ + public IntentIntegrator(Activity activity) { + this.activity = activity; + this.fragment = null; + initializeConfiguration(); } - this.targetApplications = targetApplications; - } - public void setSingleTargetApplication(String targetApplication) { - this.targetApplications = Collections.singletonList(targetApplication); - } + /** + * @param fragment {@link Fragment} invoking the integration. + * {@link #startActivityForResult(Intent, int)} will be called on the {@link Fragment} instead + * of an {@link Activity} + */ + public IntentIntegrator(Fragment fragment) { + this.activity = fragment.getActivity(); + this.fragment = fragment; + initializeConfiguration(); + } - public Map getMoreExtras() { - return moreExtras; - } + private void initializeConfiguration() { + title = DEFAULT_TITLE; + message = DEFAULT_MESSAGE; + buttonYes = DEFAULT_YES; + buttonNo = DEFAULT_NO; + targetApplications = TARGET_ALL_KNOWN; + } - public final void addExtra(String key, Object value) { - moreExtras.put(key, value); - } + public String getTitle() { + return title; + } - /** - * Initiates a scan for all known barcode types with the default camera. - * - * @return the {@link AlertDialog} that was shown to the user prompting them to download the app - * if a prompt was needed, or null otherwise. - */ - public final AlertDialog initiateScan() { - return initiateScan(ALL_CODE_TYPES, -1); - } + public void setTitle(String title) { + this.title = title; + } - /** - * Initiates a scan for all known barcode types with the specified camera. - * - * @param cameraId camera ID of the camera to use. A negative value means "no preference". - * @return the {@link AlertDialog} that was shown to the user prompting them to download the app - * if a prompt was needed, or null otherwise. - */ - public final AlertDialog initiateScan(int cameraId) { - return initiateScan(ALL_CODE_TYPES, cameraId); - } + public void setTitleByID(int titleID) { + title = activity.getString(titleID); + } - /** - * Initiates a scan, using the default camera, only for a certain set of barcode types, given as strings corresponding - * to their names in ZXing's {@code BarcodeFormat} class like "UPC_A". You can supply constants - * like {@link #PRODUCT_CODE_TYPES} for example. - * - * @param desiredBarcodeFormats names of {@code BarcodeFormat}s to scan for - * @return the {@link AlertDialog} that was shown to the user prompting them to download the app - * if a prompt was needed, or null otherwise. - */ - public final AlertDialog initiateScan(Collection desiredBarcodeFormats) { - return initiateScan(desiredBarcodeFormats, -1); - } + public String getMessage() { + return message; + } - /** - * Initiates a scan, using the specified camera, only for a certain set of barcode types, given as strings corresponding - * to their names in ZXing's {@code BarcodeFormat} class like "UPC_A". You can supply constants - * like {@link #PRODUCT_CODE_TYPES} for example. - * - * @param desiredBarcodeFormats names of {@code BarcodeFormat}s to scan for - * @param cameraId camera ID of the camera to use. A negative value means "no preference". - * @return the {@link AlertDialog} that was shown to the user prompting them to download the app - * if a prompt was needed, or null otherwise - */ - public final AlertDialog initiateScan(Collection desiredBarcodeFormats, int cameraId) { - Intent intentScan = new Intent(BS_PACKAGE + ".SCAN"); - intentScan.addCategory(Intent.CATEGORY_DEFAULT); + public void setMessage(String message) { + this.message = message; + } - // check which types of codes to scan for - if (desiredBarcodeFormats != null) { - // set the desired barcode types - StringBuilder joinedByComma = new StringBuilder(); - for (String format : desiredBarcodeFormats) { - if (joinedByComma.length() > 0) { - joinedByComma.append(','); + public void setMessageByID(int messageID) { + message = activity.getString(messageID); + } + + public String getButtonYes() { + return buttonYes; + } + + public void setButtonYes(String buttonYes) { + this.buttonYes = buttonYes; + } + + public void setButtonYesByID(int buttonYesID) { + buttonYes = activity.getString(buttonYesID); + } + + public String getButtonNo() { + return buttonNo; + } + + public void setButtonNo(String buttonNo) { + this.buttonNo = buttonNo; + } + + public void setButtonNoByID(int buttonNoID) { + buttonNo = activity.getString(buttonNoID); + } + + public Collection getTargetApplications() { + return targetApplications; + } + + public final void setTargetApplications(List targetApplications) { + if (targetApplications.isEmpty()) { + throw new IllegalArgumentException("No target applications"); } - joinedByComma.append(format); - } - intentScan.putExtra("SCAN_FORMATS", joinedByComma.toString()); + this.targetApplications = targetApplications; } - // check requested camera ID - if (cameraId >= 0) { - intentScan.putExtra("SCAN_CAMERA_ID", cameraId); + public void setSingleTargetApplication(String targetApplication) { + this.targetApplications = Collections.singletonList(targetApplication); } - String targetAppPackage = findTargetAppPackage(intentScan); - if (targetAppPackage == null) { - return showDownloadDialog(); + public Map getMoreExtras() { + return moreExtras; } - intentScan.setPackage(targetAppPackage); - intentScan.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); - intentScan.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); - attachMoreExtras(intentScan); - startActivityForResult(intentScan, REQUEST_CODE); - return null; - } - /** - * Start an activity. This method is defined to allow different methods of activity starting for - * newer versions of Android and for compatibility library. - * - * @param intent Intent to start. - * @param code Request code for the activity - * @see android.app.Activity#startActivityForResult(Intent, int) - * @see android.app.Fragment#startActivityForResult(Intent, int) - */ - protected void startActivityForResult(Intent intent, int code) { - if (fragment == null) { - activity.startActivityForResult(intent, code); - } else { - fragment.startActivityForResult(intent, code); + public final void addExtra(String key, Object value) { + moreExtras.put(key, value); } - } - private String findTargetAppPackage(Intent intent) { - PackageManager pm = activity.getPackageManager(); - List availableApps = pm.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); - if (availableApps != null) { - for (String targetApp : targetApplications) { - if (contains(availableApps, targetApp)) { - return targetApp; + /** + * Initiates a scan for all known barcode types with the default camera. + * + * @return the {@link AlertDialog} that was shown to the user prompting them to download the app + * if a prompt was needed, or null otherwise. + */ + public final AlertDialog initiateScan() { + return initiateScan(ALL_CODE_TYPES, -1); + } + + /** + * Initiates a scan for all known barcode types with the specified camera. + * + * @param cameraId camera ID of the camera to use. A negative value means "no preference". + * @return the {@link AlertDialog} that was shown to the user prompting them to download the app + * if a prompt was needed, or null otherwise. + */ + public final AlertDialog initiateScan(int cameraId) { + return initiateScan(ALL_CODE_TYPES, cameraId); + } + + /** + * Initiates a scan, using the default camera, only for a certain set of barcode types, given as strings corresponding + * to their names in ZXing's {@code BarcodeFormat} class like "UPC_A". You can supply constants + * like {@link #PRODUCT_CODE_TYPES} for example. + * + * @param desiredBarcodeFormats names of {@code BarcodeFormat}s to scan for + * @return the {@link AlertDialog} that was shown to the user prompting them to download the app + * if a prompt was needed, or null otherwise. + */ + public final AlertDialog initiateScan(Collection desiredBarcodeFormats) { + return initiateScan(desiredBarcodeFormats, -1); + } + + /** + * Initiates a scan, using the specified camera, only for a certain set of barcode types, given as strings corresponding + * to their names in ZXing's {@code BarcodeFormat} class like "UPC_A". You can supply constants + * like {@link #PRODUCT_CODE_TYPES} for example. + * + * @param desiredBarcodeFormats names of {@code BarcodeFormat}s to scan for + * @param cameraId camera ID of the camera to use. A negative value means "no preference". + * @return the {@link AlertDialog} that was shown to the user prompting them to download the app + * if a prompt was needed, or null otherwise + */ + public final AlertDialog initiateScan(Collection desiredBarcodeFormats, int cameraId) { + Intent intentScan = new Intent(BS_PACKAGE + ".SCAN"); + intentScan.addCategory(Intent.CATEGORY_DEFAULT); + + // check which types of codes to scan for + if (desiredBarcodeFormats != null) { + // set the desired barcode types + StringBuilder joinedByComma = new StringBuilder(); + for (String format : desiredBarcodeFormats) { + if (joinedByComma.length() > 0) { + joinedByComma.append(','); + } + joinedByComma.append(format); + } + intentScan.putExtra("SCAN_FORMATS", joinedByComma.toString()); } - } - } - return null; - } - private static boolean contains(Iterable availableApps, String targetApp) { - for (ResolveInfo availableApp : availableApps) { - String packageName = availableApp.activityInfo.packageName; - if (targetApp.equals(packageName)) { - return true; - } - } - return false; - } + // check requested camera ID + if (cameraId >= 0) { + intentScan.putExtra("SCAN_CAMERA_ID", cameraId); + } - private AlertDialog showDownloadDialog() { - AlertDialog.Builder downloadDialog = new AlertDialog.Builder(activity); - downloadDialog.setTitle(title); - downloadDialog.setMessage(message); - downloadDialog.setPositiveButton(buttonYes, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialogInterface, int i) { - String packageName; - if (targetApplications.contains(BS_PACKAGE)) { - // Prefer to suggest download of BS if it's anywhere in the list - packageName = BS_PACKAGE; + String targetAppPackage = findTargetAppPackage(intentScan); + if (targetAppPackage == null) { + return showDownloadDialog(); + } + intentScan.setPackage(targetAppPackage); + intentScan.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); + intentScan.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); + attachMoreExtras(intentScan); + startActivityForResult(intentScan, REQUEST_CODE); + return null; + } + + /** + * Start an activity. This method is defined to allow different methods of activity starting for + * newer versions of Android and for compatibility library. + * + * @param intent Intent to start. + * @param code Request code for the activity + * @see android.app.Activity#startActivityForResult(Intent, int) + * @see android.app.Fragment#startActivityForResult(Intent, int) + */ + protected void startActivityForResult(Intent intent, int code) { + if (fragment == null) { + activity.startActivityForResult(intent, code); } else { - // Otherwise, first option: - packageName = targetApplications.get(0); + fragment.startActivityForResult(intent, code); } - Uri uri = Uri.parse("market://details?id=" + packageName); - Intent intent = new Intent(Intent.ACTION_VIEW, uri); - try { - if (fragment == null) { + } + + private String findTargetAppPackage(Intent intent) { + PackageManager pm = activity.getPackageManager(); + List availableApps = pm.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); + if (availableApps != null) { + for (String targetApp : targetApplications) { + if (contains(availableApps, targetApp)) { + return targetApp; + } + } + } + return null; + } + + private static boolean contains(Iterable availableApps, String targetApp) { + for (ResolveInfo availableApp : availableApps) { + String packageName = availableApp.activityInfo.packageName; + if (targetApp.equals(packageName)) { + return true; + } + } + return false; + } + + private AlertDialog showDownloadDialog() { + AlertDialog.Builder downloadDialog = new AlertDialog.Builder(activity); + downloadDialog.setTitle(title); + downloadDialog.setMessage(message); + downloadDialog.setPositiveButton(buttonYes, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + String packageName; + if (targetApplications.contains(BS_PACKAGE)) { + // Prefer to suggest download of BS if it's anywhere in the list + packageName = BS_PACKAGE; + } else { + // Otherwise, first option: + packageName = targetApplications.get(0); + } + Uri uri = Uri.parse("market://details?id=" + packageName); + Intent intent = new Intent(Intent.ACTION_VIEW, uri); + try { + if (fragment == null) { + activity.startActivity(intent); + } else { + fragment.startActivity(intent); + } + } catch (ActivityNotFoundException anfe) { + // Hmm, market is not installed + Log.w(TAG, "Google Play is not installed; cannot install " + packageName); + } + } + }); + downloadDialog.setNegativeButton(buttonNo, null); + downloadDialog.setCancelable(true); + return downloadDialog.show(); + } + + + /** + *

Call this from your {@link Activity}'s + * {@link Activity#onActivityResult(int, int, Intent)} method.

+ * + * @param requestCode request code from {@code onActivityResult()} + * @param resultCode result code from {@code onActivityResult()} + * @param intent {@link Intent} from {@code onActivityResult()} + * @return null if the event handled here was not related to this class, or + * else an {@link IntentResult} containing the result of the scan. If the user cancelled scanning, + * the fields will be null. + */ + public static IntentResult parseActivityResult(int requestCode, int resultCode, Intent intent) { + if (requestCode == REQUEST_CODE) { + if (resultCode == Activity.RESULT_OK) { + String contents = intent.getStringExtra("SCAN_RESULT"); + String formatName = intent.getStringExtra("SCAN_RESULT_FORMAT"); + byte[] rawBytes = intent.getByteArrayExtra("SCAN_RESULT_BYTES"); + int intentOrientation = intent.getIntExtra("SCAN_RESULT_ORIENTATION", Integer.MIN_VALUE); + Integer orientation = intentOrientation == Integer.MIN_VALUE ? null : intentOrientation; + String errorCorrectionLevel = intent.getStringExtra("SCAN_RESULT_ERROR_CORRECTION_LEVEL"); + return new IntentResult(contents, + formatName, + rawBytes, + orientation, + errorCorrectionLevel); + } + return new IntentResult(); + } + return null; + } + + + /** + * Defaults to type "TEXT_TYPE". + * + * @param text the text string to encode as a barcode + * @return the {@link AlertDialog} that was shown to the user prompting them to download the app + * if a prompt was needed, or null otherwise + * @see #shareText(CharSequence, CharSequence) + */ + public final AlertDialog shareText(CharSequence text) { + return shareText(text, "TEXT_TYPE"); + } + + /** + * Shares the given text by encoding it as a barcode, such that another user can + * scan the text off the screen of the device. + * + * @param text the text string to encode as a barcode + * @param type type of data to encode. See {@code com.google.zxing.client.android.Contents.Type} constants. + * @return the {@link AlertDialog} that was shown to the user prompting them to download the app + * if a prompt was needed, or null otherwise + */ + public final AlertDialog shareText(CharSequence text, CharSequence type) { + Intent intent = new Intent(); + intent.addCategory(Intent.CATEGORY_DEFAULT); + intent.setAction(BS_PACKAGE + ".ENCODE"); + intent.putExtra("ENCODE_TYPE", type); + intent.putExtra("ENCODE_DATA", text); + String targetAppPackage = findTargetAppPackage(intent); + if (targetAppPackage == null) { + return showDownloadDialog(); + } + intent.setPackage(targetAppPackage); + intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); + intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); + attachMoreExtras(intent); + if (fragment == null) { activity.startActivity(intent); - } else { + } else { fragment.startActivity(intent); - } - } catch (ActivityNotFoundException anfe) { - // Hmm, market is not installed - Log.w(TAG, "Google Play is not installed; cannot install " + packageName); } - } - }); - downloadDialog.setNegativeButton(buttonNo, null); - downloadDialog.setCancelable(true); - return downloadDialog.show(); - } - - - /** - *

Call this from your {@link Activity}'s - * {@link Activity#onActivityResult(int, int, Intent)} method.

- * - * @param requestCode request code from {@code onActivityResult()} - * @param resultCode result code from {@code onActivityResult()} - * @param intent {@link Intent} from {@code onActivityResult()} - * @return null if the event handled here was not related to this class, or - * else an {@link IntentResult} containing the result of the scan. If the user cancelled scanning, - * the fields will be null. - */ - public static IntentResult parseActivityResult(int requestCode, int resultCode, Intent intent) { - if (requestCode == REQUEST_CODE) { - if (resultCode == Activity.RESULT_OK) { - String contents = intent.getStringExtra("SCAN_RESULT"); - String formatName = intent.getStringExtra("SCAN_RESULT_FORMAT"); - byte[] rawBytes = intent.getByteArrayExtra("SCAN_RESULT_BYTES"); - int intentOrientation = intent.getIntExtra("SCAN_RESULT_ORIENTATION", Integer.MIN_VALUE); - Integer orientation = intentOrientation == Integer.MIN_VALUE ? null : intentOrientation; - String errorCorrectionLevel = intent.getStringExtra("SCAN_RESULT_ERROR_CORRECTION_LEVEL"); - return new IntentResult(contents, - formatName, - rawBytes, - orientation, - errorCorrectionLevel); - } - return new IntentResult(); + return null; } - return null; - } - - /** - * Defaults to type "TEXT_TYPE". - * - * @param text the text string to encode as a barcode - * @return the {@link AlertDialog} that was shown to the user prompting them to download the app - * if a prompt was needed, or null otherwise - * @see #shareText(CharSequence, CharSequence) - */ - public final AlertDialog shareText(CharSequence text) { - return shareText(text, "TEXT_TYPE"); - } - - /** - * Shares the given text by encoding it as a barcode, such that another user can - * scan the text off the screen of the device. - * - * @param text the text string to encode as a barcode - * @param type type of data to encode. See {@code com.google.zxing.client.android.Contents.Type} constants. - * @return the {@link AlertDialog} that was shown to the user prompting them to download the app - * if a prompt was needed, or null otherwise - */ - public final AlertDialog shareText(CharSequence text, CharSequence type) { - Intent intent = new Intent(); - intent.addCategory(Intent.CATEGORY_DEFAULT); - intent.setAction(BS_PACKAGE + ".ENCODE"); - intent.putExtra("ENCODE_TYPE", type); - intent.putExtra("ENCODE_DATA", text); - String targetAppPackage = findTargetAppPackage(intent); - if (targetAppPackage == null) { - return showDownloadDialog(); + private static List list(String... values) { + return Collections.unmodifiableList(Arrays.asList(values)); } - intent.setPackage(targetAppPackage); - intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); - intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); - attachMoreExtras(intent); - if (fragment == null) { - activity.startActivity(intent); - } else { - fragment.startActivity(intent); - } - return null; - } - private static List list(String... values) { - return Collections.unmodifiableList(Arrays.asList(values)); - } - - private void attachMoreExtras(Intent intent) { - for (Map.Entry entry : moreExtras.entrySet()) { - String key = entry.getKey(); - Object value = entry.getValue(); - // Kind of hacky - if (value instanceof Integer) { - intent.putExtra(key, (Integer) value); - } else if (value instanceof Long) { - intent.putExtra(key, (Long) value); - } else if (value instanceof Boolean) { - intent.putExtra(key, (Boolean) value); - } else if (value instanceof Double) { - intent.putExtra(key, (Double) value); - } else if (value instanceof Float) { - intent.putExtra(key, (Float) value); - } else if (value instanceof Bundle) { - intent.putExtra(key, (Bundle) value); - } else { - intent.putExtra(key, value.toString()); - } + private void attachMoreExtras(Intent intent) { + for (Map.Entry entry : moreExtras.entrySet()) { + String key = entry.getKey(); + Object value = entry.getValue(); + // Kind of hacky + if (value instanceof Integer) { + intent.putExtra(key, (Integer) value); + } else if (value instanceof Long) { + intent.putExtra(key, (Long) value); + } else if (value instanceof Boolean) { + intent.putExtra(key, (Boolean) value); + } else if (value instanceof Double) { + intent.putExtra(key, (Double) value); + } else if (value instanceof Float) { + intent.putExtra(key, (Float) value); + } else if (value instanceof Bundle) { + intent.putExtra(key, (Bundle) value); + } else { + intent.putExtra(key, value.toString()); + } + } } - } } diff --git a/F-Droid/src/com/google/zxing/integration/android/IntentResult.java b/F-Droid/src/com/google/zxing/integration/android/IntentResult.java index a7e73eb7d..a67734393 100644 --- a/F-Droid/src/com/google/zxing/integration/android/IntentResult.java +++ b/F-Droid/src/com/google/zxing/integration/android/IntentResult.java @@ -23,67 +23,67 @@ package com.google.zxing.integration.android; */ public final class IntentResult { - private final String contents; - private final String formatName; - private final byte[] rawBytes; - private final Integer orientation; - private final String errorCorrectionLevel; + private final String contents; + private final String formatName; + private final byte[] rawBytes; + private final Integer orientation; + private final String errorCorrectionLevel; - IntentResult() { - this(null, null, null, null, null); - } + IntentResult() { + this(null, null, null, null, null); + } - IntentResult(String contents, - String formatName, - byte[] rawBytes, - Integer orientation, - String errorCorrectionLevel) { - this.contents = contents; - this.formatName = formatName; - this.rawBytes = rawBytes; - this.orientation = orientation; - this.errorCorrectionLevel = errorCorrectionLevel; - } + IntentResult(String contents, + String formatName, + byte[] rawBytes, + Integer orientation, + String errorCorrectionLevel) { + this.contents = contents; + this.formatName = formatName; + this.rawBytes = rawBytes; + this.orientation = orientation; + this.errorCorrectionLevel = errorCorrectionLevel; + } - /** - * @return raw content of barcode - */ - public String getContents() { - return contents; - } + /** + * @return raw content of barcode + */ + public String getContents() { + return contents; + } - /** - * @return name of format, like "QR_CODE", "UPC_A". See {@code BarcodeFormat} for more format names. - */ - public String getFormatName() { - return formatName; - } + /** + * @return name of format, like "QR_CODE", "UPC_A". See {@code BarcodeFormat} for more format names. + */ + public String getFormatName() { + return formatName; + } - /** - * @return raw bytes of the barcode content, if applicable, or null otherwise - */ - public byte[] getRawBytes() { - return rawBytes; - } + /** + * @return raw bytes of the barcode content, if applicable, or null otherwise + */ + public byte[] getRawBytes() { + return rawBytes; + } - /** - * @return rotation of the image, in degrees, which resulted in a successful scan. May be null. - */ - public Integer getOrientation() { - return orientation; - } + /** + * @return rotation of the image, in degrees, which resulted in a successful scan. May be null. + */ + public Integer getOrientation() { + return orientation; + } - /** - * @return name of the error correction level used in the barcode, if applicable - */ - public String getErrorCorrectionLevel() { - return errorCorrectionLevel; - } + /** + * @return name of the error correction level used in the barcode, if applicable + */ + public String getErrorCorrectionLevel() { + return errorCorrectionLevel; + } - @Override - public String toString() { - int rawBytesLength = rawBytes == null ? 0 : rawBytes.length; - return "Format: " + formatName + '\n' + "Contents: " + contents + '\n' + "Raw bytes: (" + rawBytesLength + " bytes)\n" + "Orientation: " + orientation + '\n' + "EC level: " + errorCorrectionLevel + '\n'; - } + @Override + public String toString() { + int rawBytesLength = rawBytes == null ? 0 : rawBytes.length; + return "Format: " + formatName + '\n' + "Contents: " + contents + '\n' + "Raw bytes: (" + rawBytesLength + " bytes)\n" + "Orientation: " + orientation + '\n' + "EC level: " + errorCorrectionLevel + '\n'; + } } diff --git a/F-Droid/src/org/fdroid/fdroid/AppDetails.java b/F-Droid/src/org/fdroid/fdroid/AppDetails.java index 47d6a9f43..12f4d9157 100644 --- a/F-Droid/src/org/fdroid/fdroid/AppDetails.java +++ b/F-Droid/src/org/fdroid/fdroid/AppDetails.java @@ -769,57 +769,57 @@ public class AppDetails extends AppCompatActivity implements ProgressListener, A switch (item.getItemId()) { - case android.R.id.home: - if (getIntent().hasExtra(EXTRA_HINT_SEARCHING)) { - finish(); - } else { - navigateUp(); - } - return true; + case android.R.id.home: + if (getIntent().hasExtra(EXTRA_HINT_SEARCHING)) { + finish(); + } else { + navigateUp(); + } + return true; - case LAUNCH: - launchApk(app.id); - return true; + case LAUNCH: + launchApk(app.id); + return true; - case SHARE: - shareApp(app); - return true; + case SHARE: + shareApp(app); + return true; - case INSTALL: - // Note that this handles updating as well as installing. - if (app.suggestedVercode > 0) { - final Apk apkToInstall = ApkProvider.Helper.find(this, app.id, app.suggestedVercode); - install(apkToInstall); - } - return true; + case INSTALL: + // Note that this handles updating as well as installing. + if (app.suggestedVercode > 0) { + final Apk apkToInstall = ApkProvider.Helper.find(this, app.id, app.suggestedVercode); + install(apkToInstall); + } + return true; - case UNINSTALL: - removeApk(app.id); - return true; + case UNINSTALL: + removeApk(app.id); + return true; - case IGNOREALL: - app.ignoreAllUpdates ^= true; - item.setChecked(app.ignoreAllUpdates); - return true; + case IGNOREALL: + app.ignoreAllUpdates ^= true; + item.setChecked(app.ignoreAllUpdates); + return true; - case IGNORETHIS: - if (app.ignoreThisUpdate >= app.suggestedVercode) - app.ignoreThisUpdate = 0; - else - app.ignoreThisUpdate = app.suggestedVercode; - item.setChecked(app.ignoreThisUpdate > 0); - return true; + case IGNORETHIS: + if (app.ignoreThisUpdate >= app.suggestedVercode) + app.ignoreThisUpdate = 0; + else + app.ignoreThisUpdate = app.suggestedVercode; + item.setChecked(app.ignoreThisUpdate > 0); + return true; - case SEND_VIA_BLUETOOTH: - /* - * If Bluetooth has not been enabled/turned on, then - * enabling device discoverability will automatically enable Bluetooth - */ - Intent discoverBt = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE); - discoverBt.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 121); - startActivityForResult(discoverBt, REQUEST_ENABLE_BLUETOOTH); - // if this is successful, the Bluetooth transfer is started - return true; + case SEND_VIA_BLUETOOTH: + /* + * If Bluetooth has not been enabled/turned on, then + * enabling device discoverability will automatically enable Bluetooth + */ + Intent discoverBt = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE); + discoverBt.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 121); + startActivityForResult(discoverBt, REQUEST_ENABLE_BLUETOOTH); + // if this is successful, the Bluetooth transfer is started + return true; } return super.onOptionsItemSelected(item); @@ -937,19 +937,19 @@ public class AppDetails extends AppCompatActivity implements ProgressListener, A if (operation == InstallerCallback.OPERATION_INSTALL) { title = R.string.install_error_title; switch (errorCode) { - case ERROR_CODE_CANNOT_PARSE: - body = R.string.install_error_cannot_parse; - break; - default: // ERROR_CODE_OTHER - body = R.string.install_error_unknown; - break; + case ERROR_CODE_CANNOT_PARSE: + body = R.string.install_error_cannot_parse; + break; + default: // ERROR_CODE_OTHER + body = R.string.install_error_unknown; + break; } } else { // InstallerCallback.OPERATION_DELETE title = R.string.uninstall_error_title; switch (errorCode) { - default: // ERROR_CODE_OTHER - body = R.string.uninstall_error_unknown; - break; + default: // ERROR_CODE_OTHER + body = R.string.uninstall_error_unknown; + break; } } runOnUiThread(new Runnable() { @@ -1000,21 +1000,21 @@ public class AppDetails extends AppCompatActivity implements ProgressListener, A boolean finished = false; switch (event.type) { - case ApkDownloader.EVENT_ERROR: - final int res; - if (event.getData().getInt(ApkDownloader.EVENT_DATA_ERROR_TYPE) == ApkDownloader.ERROR_HASH_MISMATCH) - res = R.string.corrupt_download; - else - res = R.string.details_notinstalled; - // this must be on the main UI thread - Toast.makeText(this, res, Toast.LENGTH_LONG).show(); - cleanUpFinishedDownload(); - finished = true; - break; - case ApkDownloader.EVENT_APK_DOWNLOAD_COMPLETE: - downloadCompleteInstallApk(); - finished = true; - break; + case ApkDownloader.EVENT_ERROR: + final int res; + if (event.getData().getInt(ApkDownloader.EVENT_DATA_ERROR_TYPE) == ApkDownloader.ERROR_HASH_MISMATCH) + res = R.string.corrupt_download; + else + res = R.string.details_notinstalled; + // this must be on the main UI thread + Toast.makeText(this, res, Toast.LENGTH_LONG).show(); + cleanUpFinishedDownload(); + finished = true; + break; + case ApkDownloader.EVENT_APK_DOWNLOAD_COMPLETE: + downloadCompleteInstallApk(); + finished = true; + break; } if (finished) { @@ -1032,9 +1032,9 @@ public class AppDetails extends AppCompatActivity implements ProgressListener, A } switch (requestCode) { - case REQUEST_ENABLE_BLUETOOTH: - fdroidApp.sendViaBluetooth(this, resultCode, app.id); - break; + case REQUEST_ENABLE_BLUETOOTH: + fdroidApp.sendViaBluetooth(this, resultCode, app.id); + break; } } @@ -1381,18 +1381,18 @@ public class AppDetails extends AppCompatActivity implements ProgressListener, A private String descAntiFeature(String af) { switch (af) { - case "Ads": - return getString(R.string.antiadslist); - case "Tracking": - return getString(R.string.antitracklist); - case "NonFreeNet": - return getString(R.string.antinonfreenetlist); - case "NonFreeAdd": - return getString(R.string.antinonfreeadlist); - case "NonFreeDep": - return getString(R.string.antinonfreedeplist); - case "UpstreamNonFree": - return getString(R.string.antiupstreamnonfreelist); + case "Ads": + return getString(R.string.antiadslist); + case "Tracking": + return getString(R.string.antitracklist); + case "NonFreeNet": + return getString(R.string.antinonfreenetlist); + case "NonFreeAdd": + return getString(R.string.antinonfreeadlist); + case "NonFreeDep": + return getString(R.string.antinonfreedeplist); + case "UpstreamNonFree": + return getString(R.string.antiupstreamnonfreelist); } return null; } diff --git a/F-Droid/src/org/fdroid/fdroid/FDroid.java b/F-Droid/src/org/fdroid/fdroid/FDroid.java index 529c66211..6eb43c770 100644 --- a/F-Droid/src/org/fdroid/fdroid/FDroid.java +++ b/F-Droid/src/org/fdroid/fdroid/FDroid.java @@ -130,43 +130,43 @@ public class FDroid extends ActionBarActivity { return; } switch (host) { - case "f-droid.org": - // http://f-droid.org/app/app.id - if (path.startsWith("/repository/browse")) { - // http://f-droid.org/repository/browse?fdid=app.id - appId = data.getQueryParameter("fdid"); - } else if (path.startsWith("/app")) { - appId = data.getLastPathSegment(); - if (appId != null && appId.equals("app")) { - appId = null; + case "f-droid.org": + // http://f-droid.org/app/app.id + if (path.startsWith("/repository/browse")) { + // http://f-droid.org/repository/browse?fdid=app.id + appId = data.getQueryParameter("fdid"); + } else if (path.startsWith("/app")) { + appId = data.getLastPathSegment(); + if (appId != null && appId.equals("app")) { + appId = null; + } } - } - break; - case "details": - // market://details?id=app.id - appId = data.getQueryParameter("id"); - break; - case "search": - // market://search?q=query - query = data.getQueryParameter("q"); - break; - case "play.google.com": - if (path.startsWith("/store/apps/details")) { - // http://play.google.com/store/apps/details?id=app.id + break; + case "details": + // market://details?id=app.id appId = data.getQueryParameter("id"); - } else if (path.startsWith("/store/search")) { - // http://play.google.com/store/search?q=foo + break; + case "search": + // market://search?q=query query = data.getQueryParameter("q"); - } - break; - case "apps": - case "amazon.com": - case "www.amazon.com": - // amzn://apps/android?p=app.id - // http://amazon.com/gp/mas/dl/android?p=app.id - appId = data.getQueryParameter("p"); - query = data.getQueryParameter("s"); - break; + break; + case "play.google.com": + if (path.startsWith("/store/apps/details")) { + // http://play.google.com/store/apps/details?id=app.id + appId = data.getQueryParameter("id"); + } else if (path.startsWith("/store/search")) { + // http://play.google.com/store/search?q=foo + query = data.getQueryParameter("q"); + } + break; + case "apps": + case "amazon.com": + case "www.amazon.com": + // amzn://apps/android?p=app.id + // http://amazon.com/gp/mas/dl/android?p=app.id + appId = data.getQueryParameter("p"); + query = data.getQueryParameter("s"); + break; } } else if (scheme.equals("fdroid.app")) { // fdroid.app:app.id @@ -247,57 +247,57 @@ public class FDroid extends ActionBarActivity { switch (item.getItemId()) { - case R.id.action_update_repo: - UpdateService.updateNow(this); - return true; + case R.id.action_update_repo: + UpdateService.updateNow(this); + return true; - case R.id.action_manage_repos: - startActivity(new Intent(this, ManageReposActivity.class)); - return true; + case R.id.action_manage_repos: + startActivity(new Intent(this, ManageReposActivity.class)); + return true; - case R.id.action_settings: - Intent prefs = new Intent(getBaseContext(), PreferencesActivity.class); - startActivityForResult(prefs, REQUEST_PREFS); - return true; + case R.id.action_settings: + Intent prefs = new Intent(getBaseContext(), PreferencesActivity.class); + startActivityForResult(prefs, REQUEST_PREFS); + return true; - case R.id.action_swap: - startActivity(new Intent(this, SwapWorkflowActivity.class)); - return true; + case R.id.action_swap: + startActivity(new Intent(this, SwapWorkflowActivity.class)); + return true; - case R.id.action_search: - onSearchRequested(); - return true; + case R.id.action_search: + onSearchRequested(); + return true; - case R.id.action_bluetooth_apk: - /* - * If Bluetooth has not been enabled/turned on, then enabling - * device discoverability will automatically enable Bluetooth - */ - Intent discoverBt = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE); - discoverBt.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 121); - startActivityForResult(discoverBt, REQUEST_ENABLE_BLUETOOTH); - // if this is successful, the Bluetooth transfer is started - return true; + case R.id.action_bluetooth_apk: + /* + * If Bluetooth has not been enabled/turned on, then enabling + * device discoverability will automatically enable Bluetooth + */ + Intent discoverBt = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE); + discoverBt.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 121); + startActivityForResult(discoverBt, REQUEST_ENABLE_BLUETOOTH); + // if this is successful, the Bluetooth transfer is started + return true; - case R.id.action_about: - View view = LayoutInflater.from(this).inflate(R.layout.about, null); + case R.id.action_about: + View view = LayoutInflater.from(this).inflate(R.layout.about, null); - String versionName = Utils.getVersionName(this); - if (versionName == null) { - versionName = getString(R.string.unknown); - } - ((TextView) view.findViewById(R.id.version)).setText(versionName); + String versionName = Utils.getVersionName(this); + if (versionName == null) { + versionName = getString(R.string.unknown); + } + ((TextView) view.findViewById(R.id.version)).setText(versionName); - AlertDialog alrt = new AlertDialog.Builder(this).setView(view).create(); - alrt.setTitle(R.string.about_title); - alrt.setButton(AlertDialog.BUTTON_NEGATIVE, getString(R.string.ok), - new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int whichButton) { - } - }); - alrt.show(); - return true; + AlertDialog alrt = new AlertDialog.Builder(this).setView(view).create(); + alrt.setTitle(R.string.about_title); + alrt.setButton(AlertDialog.BUTTON_NEGATIVE, getString(R.string.ok), + new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int whichButton) { + } + }); + alrt.show(); + return true; } return super.onOptionsItemSelected(item); } @@ -306,25 +306,25 @@ public class FDroid extends ActionBarActivity { protected void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { - case REQUEST_PREFS: - // The automatic update settings may have changed, so reschedule (or - // unschedule) the service accordingly. It's cheap, so no need to - // check if the particular setting has actually been changed. - UpdateService.schedule(getBaseContext()); + case REQUEST_PREFS: + // The automatic update settings may have changed, so reschedule (or + // unschedule) the service accordingly. It's cheap, so no need to + // check if the particular setting has actually been changed. + UpdateService.schedule(getBaseContext()); - if ((resultCode & PreferencesActivity.RESULT_RESTART) != 0) { - ((FDroidApp) getApplication()).reloadTheme(); - final Intent intent = getIntent(); - overridePendingTransition(0, 0); - intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); - finish(); - overridePendingTransition(0, 0); - startActivity(intent); - } - break; - case REQUEST_ENABLE_BLUETOOTH: - fdroidApp.sendViaBluetooth(this, resultCode, "org.fdroid.fdroid"); - break; + if ((resultCode & PreferencesActivity.RESULT_RESTART) != 0) { + ((FDroidApp) getApplication()).reloadTheme(); + final Intent intent = getIntent(); + overridePendingTransition(0, 0); + intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); + finish(); + overridePendingTransition(0, 0); + startActivity(intent); + } + break; + case REQUEST_ENABLE_BLUETOOTH: + fdroidApp.sendViaBluetooth(this, resultCode, "org.fdroid.fdroid"); + break; } } diff --git a/F-Droid/src/org/fdroid/fdroid/FDroidApp.java b/F-Droid/src/org/fdroid/fdroid/FDroidApp.java index d9f03fdd1..ad6bf43f6 100644 --- a/F-Droid/src/org/fdroid/fdroid/FDroidApp.java +++ b/F-Droid/src/org/fdroid/fdroid/FDroidApp.java @@ -101,7 +101,7 @@ public class FDroidApp extends Application { } public void applyTheme(Activity activity) { - activity.setTheme(getCurThemeResId()); + activity.setTheme(getCurThemeResId()); } public static Theme getCurTheme() { @@ -253,18 +253,18 @@ public class FDroidApp extends Application { ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext()) .imageDownloader(new IconDownloader(getApplicationContext())) .diskCache(new LimitedAgeDiskCache( - new File(StorageUtils.getCacheDirectory(getApplicationContext(), true), - "icons"), - null, - new FileNameGenerator() { - @Override - public String generate(String imageUri) { - return imageUri.substring( - imageUri.lastIndexOf('/') + 1); - } }, - // 30 days in secs: 30*24*60*60 = 2592000 - 2592000) - ) + new File(StorageUtils.getCacheDirectory(getApplicationContext(), true), + "icons"), + null, + new FileNameGenerator() { + @Override + public String generate(String imageUri) { + return imageUri.substring( + imageUri.lastIndexOf('/') + 1); + } }, + // 30 days in secs: 30*24*60*60 = 2592000 + 2592000) + ) .threadPoolSize(4) .threadPriority(Thread.NORM_PRIORITY - 2) // Default is NORM_PRIORITY - 1 .build(); diff --git a/F-Droid/src/org/fdroid/fdroid/FDroidCertPins.java b/F-Droid/src/org/fdroid/fdroid/FDroidCertPins.java index a8db3b4ff..3a8c786d1 100644 --- a/F-Droid/src/org/fdroid/fdroid/FDroidCertPins.java +++ b/F-Droid/src/org/fdroid/fdroid/FDroidCertPins.java @@ -25,36 +25,36 @@ import java.util.List; public class FDroidCertPins { public static final String[] DEFAULT_PINS = { - // OU=PositiveSSL, CN=f-droid.org - // Fingerprint: 84B91CDF2312CB9BA7F3BE803783302F8D8C299F - "638F93856E1F5EDFCBD40C46D4160CFF21B0713A", + // OU=PositiveSSL, CN=f-droid.org + // Fingerprint: 84B91CDF2312CB9BA7F3BE803783302F8D8C299F + "638F93856E1F5EDFCBD40C46D4160CFF21B0713A", - // OU=PositiveSSL, CN=f-droid.org - "83a288fdbf7fb27ca2268d553168eb8f38298910", + // OU=PositiveSSL, CN=f-droid.org + "83a288fdbf7fb27ca2268d553168eb8f38298910", - // OU=Gandi Standard SSL, CN=guardianproject.info - "cf2f8e226027599a1a933701418c58ec688a8305", + // OU=Gandi Standard SSL, CN=guardianproject.info + "cf2f8e226027599a1a933701418c58ec688a8305", - // C=US, ST=Washington, L=Seattle, O=Amazon.com Inc., CN=s3.amazonaws.com - "5e77905babb66ca7082979435afbe4edf3f5af12", + // C=US, ST=Washington, L=Seattle, O=Amazon.com Inc., CN=s3.amazonaws.com + "5e77905babb66ca7082979435afbe4edf3f5af12", - // OU=Domain Control Validated - RapidSSL(R), CN=www.psiphon.ca - "3aa1726e64d54bf58bf68fe23208928fd0d9cf8a", + // OU=Domain Control Validated - RapidSSL(R), CN=www.psiphon.ca + "3aa1726e64d54bf58bf68fe23208928fd0d9cf8a", - // OU=EssentialSSL Wildcard, CN=*.panicbutton.io - "cdae8cc70af09a55a7642d13f84241cba1c3a3e6", + // OU=EssentialSSL Wildcard, CN=*.panicbutton.io + "cdae8cc70af09a55a7642d13f84241cba1c3a3e6", - // C=IL, O=StartCom Ltd., OU=Secure Digital Certificate Signing, CN=StartCom Certification Authority - // https://cert.startcom.org/ - "234b71255613e130dde34269c9cc30d46f0841e0", + // C=IL, O=StartCom Ltd., OU=Secure Digital Certificate Signing, CN=StartCom Certification Authority + // https://cert.startcom.org/ + "234b71255613e130dde34269c9cc30d46f0841e0", - // C=US, O=Internet Security Research Group, CN=ISRG Root X1 - // https://letsencrypt.org - "f816513cfd1b449f2e6b28a197221fb81f514e3c", + // C=US, O=Internet Security Research Group, CN=ISRG Root X1 + // https://letsencrypt.org + "f816513cfd1b449f2e6b28a197221fb81f514e3c", - // C=US, O=IdenTrust, CN=IdenTrust Commercial Root CA 1 - // cross-signer for https://letsencrypt.org - "87e3bf322427c1405d2736c381e01d1a71d4a039", + // C=US, O=IdenTrust, CN=IdenTrust Commercial Root CA 1 + // cross-signer for https://letsencrypt.org + "87e3bf322427c1405d2736c381e01d1a71d4a039", }; public static List PINLIST = null; diff --git a/F-Droid/src/org/fdroid/fdroid/Preferences.java b/F-Droid/src/org/fdroid/fdroid/Preferences.java index 419724d33..62eff87cf 100644 --- a/F-Droid/src/org/fdroid/fdroid/Preferences.java +++ b/F-Droid/src/org/fdroid/fdroid/Preferences.java @@ -256,35 +256,35 @@ public final class Preferences implements SharedPreferences.OnSharedPreferenceCh uninitialize(key); switch (key) { - case PREF_COMPACT_LAYOUT: - for (ChangeListener listener : compactLayoutListeners) { - listener.onPreferenceChange(); - } - break; - case PREF_ROOTED: - for (ChangeListener listener : filterAppsRequiringRootListeners) { - listener.onPreferenceChange(); - } - break; - case PREF_UPD_HISTORY: - for (ChangeListener listener : updateHistoryListeners) { - listener.onPreferenceChange(); - } - break; - case PREF_LOCAL_REPO_NAME: - for (ChangeListener listener : localRepoNameListeners) { - listener.onPreferenceChange(); - } - break; - case PREF_LOCAL_REPO_HTTPS: - for (ChangeListener listener : localRepoHttpsListeners) { - listener.onPreferenceChange(); - } - case PREF_UNSTABLE_UPDATES: - for (ChangeListener listener : unstableUpdatesListeners) { - listener.onPreferenceChange(); - } - break; + case PREF_COMPACT_LAYOUT: + for (ChangeListener listener : compactLayoutListeners) { + listener.onPreferenceChange(); + } + break; + case PREF_ROOTED: + for (ChangeListener listener : filterAppsRequiringRootListeners) { + listener.onPreferenceChange(); + } + break; + case PREF_UPD_HISTORY: + for (ChangeListener listener : updateHistoryListeners) { + listener.onPreferenceChange(); + } + break; + case PREF_LOCAL_REPO_NAME: + for (ChangeListener listener : localRepoNameListeners) { + listener.onPreferenceChange(); + } + break; + case PREF_LOCAL_REPO_HTTPS: + for (ChangeListener listener : localRepoHttpsListeners) { + listener.onPreferenceChange(); + } + case PREF_UNSTABLE_UPDATES: + for (ChangeListener listener : unstableUpdatesListeners) { + listener.onPreferenceChange(); + } + break; } } diff --git a/F-Droid/src/org/fdroid/fdroid/PreferencesActivity.java b/F-Droid/src/org/fdroid/fdroid/PreferencesActivity.java index 4950225a4..d23862669 100644 --- a/F-Droid/src/org/fdroid/fdroid/PreferencesActivity.java +++ b/F-Droid/src/org/fdroid/fdroid/PreferencesActivity.java @@ -64,9 +64,9 @@ public class PreferencesActivity extends ActionBarActivity { @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { - case android.R.id.home: - NavUtils.navigateUpFromSameTask(this); - return true; + case android.R.id.home: + NavUtils.navigateUpFromSameTask(this); + return true; } return super.onOptionsItemSelected(item); } diff --git a/F-Droid/src/org/fdroid/fdroid/RepoUpdater.java b/F-Droid/src/org/fdroid/fdroid/RepoUpdater.java index a332ab73c..fded677cd 100644 --- a/F-Droid/src/org/fdroid/fdroid/RepoUpdater.java +++ b/F-Droid/src/org/fdroid/fdroid/RepoUpdater.java @@ -228,7 +228,7 @@ public class RepoUpdater { private ContentValues values; public void rememberUpdate() { - RepoProvider.Helper.update(context, repo, values); + RepoProvider.Helper.update(context, repo, values); } } diff --git a/F-Droid/src/org/fdroid/fdroid/RepoXMLHandler.java b/F-Droid/src/org/fdroid/fdroid/RepoXMLHandler.java index 038eb7851..547beb089 100644 --- a/F-Droid/src/org/fdroid/fdroid/RepoXMLHandler.java +++ b/F-Droid/src/org/fdroid/fdroid/RepoXMLHandler.java @@ -109,123 +109,123 @@ public class RepoXMLHandler extends DefaultHandler { final String str = curchars.toString().trim(); if (curapk != null) { switch (localName) { - case "version": - curapk.version = str; - break; - case "versioncode": - curapk.vercode = Utils.parseInt(str, -1); - break; - case "size": - curapk.size = Utils.parseInt(str, 0); - break; - case "hash": - if (hashType == null || hashType.equals("md5")) { - if (curapk.hash == null) { + case "version": + curapk.version = str; + break; + case "versioncode": + curapk.vercode = Utils.parseInt(str, -1); + break; + case "size": + curapk.size = Utils.parseInt(str, 0); + break; + case "hash": + if (hashType == null || hashType.equals("md5")) { + if (curapk.hash == null) { + curapk.hash = str; + curapk.hashType = "MD5"; + } + } else if (hashType.equals("sha256")) { curapk.hash = str; - curapk.hashType = "MD5"; + curapk.hashType = "SHA-256"; } - } else if (hashType.equals("sha256")) { - curapk.hash = str; - curapk.hashType = "SHA-256"; - } - break; - case "sig": - curapk.sig = str; - break; - case "srcname": - curapk.srcname = str; - break; - case "apkname": - curapk.apkName = str; - break; - case "sdkver": - curapk.minSdkVersion = Utils.parseInt(str, 0); - break; - case "maxsdkver": - curapk.maxSdkVersion = Utils.parseInt(str, 0); - break; - case "added": - curapk.added = Utils.parseDate(str, null); - break; - case "permissions": - curapk.permissions = Utils.CommaSeparatedList.make(str); - break; - case "features": - curapk.features = Utils.CommaSeparatedList.make(str); - break; - case "nativecode": - curapk.nativecode = Utils.CommaSeparatedList.make(str); - break; + break; + case "sig": + curapk.sig = str; + break; + case "srcname": + curapk.srcname = str; + break; + case "apkname": + curapk.apkName = str; + break; + case "sdkver": + curapk.minSdkVersion = Utils.parseInt(str, 0); + break; + case "maxsdkver": + curapk.maxSdkVersion = Utils.parseInt(str, 0); + break; + case "added": + curapk.added = Utils.parseDate(str, null); + break; + case "permissions": + curapk.permissions = Utils.CommaSeparatedList.make(str); + break; + case "features": + curapk.features = Utils.CommaSeparatedList.make(str); + break; + case "nativecode": + curapk.nativecode = Utils.CommaSeparatedList.make(str); + break; } } else if (curapp != null) { switch (localName) { - case "name": - curapp.name = str; - break; - case "icon": - curapp.icon = str; - break; - case "description": - // This is the old-style description. We'll read it - // if present, to support old repos, but in newer - // repos it will get overwritten straight away! - curapp.description = "

" + str + "

"; - break; - case "desc": - // New-style description. - curapp.description = str; - break; - case "summary": - curapp.summary = str; - break; - case "license": - curapp.license = str; - break; - case "source": - curapp.sourceURL = str; - break; - case "changelog": - curapp.changelogURL = str; - break; - case "donate": - curapp.donateURL = str; - break; - case "bitcoin": - curapp.bitcoinAddr = str; - break; - case "litecoin": - curapp.litecoinAddr = str; - break; - case "flattr": - curapp.flattrID = str; - break; - case "web": - curapp.webURL = str; - break; - case "tracker": - curapp.trackerURL = str; - break; - case "added": - curapp.added = Utils.parseDate(str, null); - break; - case "lastupdated": - curapp.lastUpdated = Utils.parseDate(str, null); - break; - case "marketversion": - curapp.upstreamVersion = str; - break; - case "marketvercode": - curapp.upstreamVercode = Utils.parseInt(str, -1); - break; - case "categories": - curapp.categories = Utils.CommaSeparatedList.make(str); - break; - case "antifeatures": - curapp.antiFeatures = Utils.CommaSeparatedList.make(str); - break; - case "requirements": - curapp.requirements = Utils.CommaSeparatedList.make(str); - break; + case "name": + curapp.name = str; + break; + case "icon": + curapp.icon = str; + break; + case "description": + // This is the old-style description. We'll read it + // if present, to support old repos, but in newer + // repos it will get overwritten straight away! + curapp.description = "

" + str + "

"; + break; + case "desc": + // New-style description. + curapp.description = str; + break; + case "summary": + curapp.summary = str; + break; + case "license": + curapp.license = str; + break; + case "source": + curapp.sourceURL = str; + break; + case "changelog": + curapp.changelogURL = str; + break; + case "donate": + curapp.donateURL = str; + break; + case "bitcoin": + curapp.bitcoinAddr = str; + break; + case "litecoin": + curapp.litecoinAddr = str; + break; + case "flattr": + curapp.flattrID = str; + break; + case "web": + curapp.webURL = str; + break; + case "tracker": + curapp.trackerURL = str; + break; + case "added": + curapp.added = Utils.parseDate(str, null); + break; + case "lastupdated": + curapp.lastUpdated = Utils.parseDate(str, null); + break; + case "marketversion": + curapp.upstreamVersion = str; + break; + case "marketvercode": + curapp.upstreamVercode = Utils.parseInt(str, -1); + break; + case "categories": + curapp.categories = Utils.CommaSeparatedList.make(str); + break; + case "antifeatures": + curapp.antiFeatures = Utils.CommaSeparatedList.make(str); + break; + case "requirements": + curapp.requirements = Utils.CommaSeparatedList.make(str); + break; } } else if (localName.equals("description")) { description = cleanWhiteSpace(str); diff --git a/F-Droid/src/org/fdroid/fdroid/SearchResults.java b/F-Droid/src/org/fdroid/fdroid/SearchResults.java index 76453bf07..e78b05b5e 100644 --- a/F-Droid/src/org/fdroid/fdroid/SearchResults.java +++ b/F-Droid/src/org/fdroid/fdroid/SearchResults.java @@ -86,13 +86,13 @@ public class SearchResults extends ActionBarActivity { public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { - case android.R.id.home: - NavUtils.navigateUpFromSameTask(this); - return true; + case android.R.id.home: + NavUtils.navigateUpFromSameTask(this); + return true; - case SEARCH: - onSearchRequested(); - return true; + case SEARCH: + onSearchRequested(); + return true; } return super.onOptionsItemSelected(item); diff --git a/F-Droid/src/org/fdroid/fdroid/UpdateService.java b/F-Droid/src/org/fdroid/fdroid/UpdateService.java index 35a9014a6..acb741e04 100644 --- a/F-Droid/src/org/fdroid/fdroid/UpdateService.java +++ b/F-Droid/src/org/fdroid/fdroid/UpdateService.java @@ -643,9 +643,9 @@ public class UpdateService extends IntentService implements ProgressListener { */ private List getKnownApks(List apks) { final String[] fields = { - ApkProvider.DataColumns.APK_ID, - ApkProvider.DataColumns.VERSION, - ApkProvider.DataColumns.VERSION_CODE + ApkProvider.DataColumns.APK_ID, + ApkProvider.DataColumns.VERSION, + ApkProvider.DataColumns.VERSION_CODE }; return ApkProvider.Helper.knownApks(this, apks, fields); } diff --git a/F-Droid/src/org/fdroid/fdroid/Utils.java b/F-Droid/src/org/fdroid/fdroid/Utils.java index 615ccb590..425f8b801 100644 --- a/F-Droid/src/org/fdroid/fdroid/Utils.java +++ b/F-Droid/src/org/fdroid/fdroid/Utils.java @@ -83,7 +83,7 @@ public final class Utils { new SimpleDateFormat("yyyy-MM-dd_HH:mm:ss", Locale.ENGLISH); private static final String[] FRIENDLY_SIZE_FORMAT = { - "%.0f B", "%.0f KiB", "%.1f MiB", "%.2f GiB" }; + "%.0f B", "%.0f KiB", "%.1f MiB", "%.2f GiB" }; public static final String FALLBACK_ICONS_DIR = "/icons/"; @@ -611,30 +611,30 @@ public final class Utils { public void handleTag(boolean opening, String tag, Editable output, XMLReader reader) { switch (tag) { - case "ul": - if (opening) - listNum = -1; - else - output.append('\n'); - break; - case "ol": - if (opening) - listNum = 1; - else - output.append('\n'); - break; - case "li": - if (opening) { - if (listNum == -1) { - output.append("\t• "); + case "ul": + if (opening) + listNum = -1; + else + output.append('\n'); + break; + case "ol": + if (opening) + listNum = 1; + else + output.append('\n'); + break; + case "li": + if (opening) { + if (listNum == -1) { + output.append("\t• "); + } else { + output.append("\t").append(Integer.toString(listNum)).append(". "); + listNum++; + } } else { - output.append("\t").append(Integer.toString(listNum)).append(". "); - listNum++; + output.append('\n'); } - } else { - output.append('\n'); - } - break; + break; } } } diff --git a/F-Droid/src/org/fdroid/fdroid/data/Apk.java b/F-Droid/src/org/fdroid/fdroid/data/Apk.java index 45a8d9311..9152c0e77 100644 --- a/F-Droid/src/org/fdroid/fdroid/data/Apk.java +++ b/F-Droid/src/org/fdroid/fdroid/data/Apk.java @@ -60,66 +60,66 @@ public class Apk extends ValueObject implements Comparable { for (int i = 0; i < cursor.getColumnCount(); i++) { switch (cursor.getColumnName(i)) { - case ApkProvider.DataColumns.HASH: - hash = cursor.getString(i); - break; - case ApkProvider.DataColumns.HASH_TYPE: - hashType = cursor.getString(i); - break; - case ApkProvider.DataColumns.ADDED_DATE: - added = Utils.parseDate(cursor.getString(i), null); - break; - case ApkProvider.DataColumns.FEATURES: - features = Utils.CommaSeparatedList.make(cursor.getString(i)); - break; - case ApkProvider.DataColumns.APK_ID: - id = cursor.getString(i); - break; - case ApkProvider.DataColumns.IS_COMPATIBLE: - compatible = cursor.getInt(i) == 1; - break; - case ApkProvider.DataColumns.MIN_SDK_VERSION: - minSdkVersion = cursor.getInt(i); - break; - case ApkProvider.DataColumns.MAX_SDK_VERSION: - maxSdkVersion = cursor.getInt(i); - break; - case ApkProvider.DataColumns.NAME: - apkName = cursor.getString(i); - break; - case ApkProvider.DataColumns.PERMISSIONS: - permissions = Utils.CommaSeparatedList.make(cursor.getString(i)); - break; - case ApkProvider.DataColumns.NATIVE_CODE: - nativecode = Utils.CommaSeparatedList.make(cursor.getString(i)); - break; - case ApkProvider.DataColumns.INCOMPATIBLE_REASONS: - incompatible_reasons = Utils.CommaSeparatedList.make(cursor.getString(i)); - break; - case ApkProvider.DataColumns.REPO_ID: - repo = cursor.getInt(i); - break; - case ApkProvider.DataColumns.SIGNATURE: - sig = cursor.getString(i); - break; - case ApkProvider.DataColumns.SIZE: - size = cursor.getInt(i); - break; - case ApkProvider.DataColumns.SOURCE_NAME: - srcname = cursor.getString(i); - break; - case ApkProvider.DataColumns.VERSION: - version = cursor.getString(i); - break; - case ApkProvider.DataColumns.VERSION_CODE: - vercode = cursor.getInt(i); - break; - case ApkProvider.DataColumns.REPO_VERSION: - repoVersion = cursor.getInt(i); - break; - case ApkProvider.DataColumns.REPO_ADDRESS: - repoAddress = cursor.getString(i); - break; + case ApkProvider.DataColumns.HASH: + hash = cursor.getString(i); + break; + case ApkProvider.DataColumns.HASH_TYPE: + hashType = cursor.getString(i); + break; + case ApkProvider.DataColumns.ADDED_DATE: + added = Utils.parseDate(cursor.getString(i), null); + break; + case ApkProvider.DataColumns.FEATURES: + features = Utils.CommaSeparatedList.make(cursor.getString(i)); + break; + case ApkProvider.DataColumns.APK_ID: + id = cursor.getString(i); + break; + case ApkProvider.DataColumns.IS_COMPATIBLE: + compatible = cursor.getInt(i) == 1; + break; + case ApkProvider.DataColumns.MIN_SDK_VERSION: + minSdkVersion = cursor.getInt(i); + break; + case ApkProvider.DataColumns.MAX_SDK_VERSION: + maxSdkVersion = cursor.getInt(i); + break; + case ApkProvider.DataColumns.NAME: + apkName = cursor.getString(i); + break; + case ApkProvider.DataColumns.PERMISSIONS: + permissions = Utils.CommaSeparatedList.make(cursor.getString(i)); + break; + case ApkProvider.DataColumns.NATIVE_CODE: + nativecode = Utils.CommaSeparatedList.make(cursor.getString(i)); + break; + case ApkProvider.DataColumns.INCOMPATIBLE_REASONS: + incompatible_reasons = Utils.CommaSeparatedList.make(cursor.getString(i)); + break; + case ApkProvider.DataColumns.REPO_ID: + repo = cursor.getInt(i); + break; + case ApkProvider.DataColumns.SIGNATURE: + sig = cursor.getString(i); + break; + case ApkProvider.DataColumns.SIZE: + size = cursor.getInt(i); + break; + case ApkProvider.DataColumns.SOURCE_NAME: + srcname = cursor.getString(i); + break; + case ApkProvider.DataColumns.VERSION: + version = cursor.getString(i); + break; + case ApkProvider.DataColumns.VERSION_CODE: + vercode = cursor.getInt(i); + break; + case ApkProvider.DataColumns.REPO_VERSION: + repoVersion = cursor.getInt(i); + break; + case ApkProvider.DataColumns.REPO_ADDRESS: + repoAddress = cursor.getString(i); + break; } } } diff --git a/F-Droid/src/org/fdroid/fdroid/data/ApkProvider.java b/F-Droid/src/org/fdroid/fdroid/data/ApkProvider.java index 777c9d63b..8ec79b903 100644 --- a/F-Droid/src/org/fdroid/fdroid/data/ApkProvider.java +++ b/F-Droid/src/org/fdroid/fdroid/data/ApkProvider.java @@ -389,28 +389,28 @@ public class ApkProvider extends FDroidProvider { QuerySelection query = new QuerySelection(selection, selectionArgs); switch (matcher.match(uri)) { - case CODE_LIST: - break; + case CODE_LIST: + break; - case CODE_SINGLE: - query = query.add(querySingle(uri)); - break; + case CODE_SINGLE: + query = query.add(querySingle(uri)); + break; - case CODE_APP: - query = query.add(queryApp(uri.getLastPathSegment())); - break; + case CODE_APP: + query = query.add(queryApp(uri.getLastPathSegment())); + break; - case CODE_APKS: - query = query.add(queryApks(uri.getLastPathSegment())); - break; + case CODE_APKS: + query = query.add(queryApks(uri.getLastPathSegment())); + break; - case CODE_REPO: - query = query.add(queryRepo(Long.parseLong(uri.getLastPathSegment()))); - break; + case CODE_REPO: + query = query.add(queryRepo(Long.parseLong(uri.getLastPathSegment()))); + break; - default: - Log.e(TAG, "Invalid URI for apk content provider: " + uri); - throw new UnsupportedOperationException("Invalid URI for apk content provider: " + uri); + default: + Log.e(TAG, "Invalid URI for apk content provider: " + uri); + throw new UnsupportedOperationException("Invalid URI for apk content provider: " + uri); } Query queryBuilder = new Query(); @@ -458,27 +458,27 @@ public class ApkProvider extends FDroidProvider { switch (matcher.match(uri)) { - case CODE_REPO: - query = query.add(queryRepo(Long.parseLong(uri.getLastPathSegment()))); - break; + case CODE_REPO: + query = query.add(queryRepo(Long.parseLong(uri.getLastPathSegment()))); + break; - case CODE_APP: - query = query.add(queryApp(uri.getLastPathSegment())); - break; + case CODE_APP: + query = query.add(queryApp(uri.getLastPathSegment())); + break; - case CODE_APKS: - query = query.add(queryApks(uri.getLastPathSegment())); - break; + case CODE_APKS: + query = query.add(queryApks(uri.getLastPathSegment())); + break; - case CODE_LIST: - throw new UnsupportedOperationException("Can't delete all apks."); + case CODE_LIST: + throw new UnsupportedOperationException("Can't delete all apks."); - case CODE_SINGLE: - throw new UnsupportedOperationException("Can't delete individual apks."); + case CODE_SINGLE: + throw new UnsupportedOperationException("Can't delete individual apks."); - default: - Log.e(TAG, "Invalid URI for apk content provider: " + uri); - throw new UnsupportedOperationException("Invalid URI for apk content provider: " + uri); + default: + Log.e(TAG, "Invalid URI for apk content provider: " + uri); + throw new UnsupportedOperationException("Invalid URI for apk content provider: " + uri); } int rowsAffected = write().delete(getTableName(), query.getSelection(), query.getArgs()); diff --git a/F-Droid/src/org/fdroid/fdroid/data/App.java b/F-Droid/src/org/fdroid/fdroid/data/App.java index 5b1bdb4ea..0f2b4afb3 100644 --- a/F-Droid/src/org/fdroid/fdroid/data/App.java +++ b/F-Droid/src/org/fdroid/fdroid/data/App.java @@ -119,100 +119,100 @@ public class App extends ValueObject implements Comparable { for (int i = 0; i < cursor.getColumnCount(); i++) { String n = cursor.getColumnName(i); switch (n) { - case AppProvider.DataColumns.IS_COMPATIBLE: - compatible = cursor.getInt(i) == 1; - break; - case AppProvider.DataColumns.APP_ID: - id = cursor.getString(i); - break; - case AppProvider.DataColumns.NAME: - name = cursor.getString(i); - break; - case AppProvider.DataColumns.SUMMARY: - summary = cursor.getString(i); - break; - case AppProvider.DataColumns.ICON: - icon = cursor.getString(i); - break; - case AppProvider.DataColumns.DESCRIPTION: - description = cursor.getString(i); - break; - case AppProvider.DataColumns.LICENSE: - license = cursor.getString(i); - break; - case AppProvider.DataColumns.WEB_URL: - webURL = cursor.getString(i); - break; - case AppProvider.DataColumns.TRACKER_URL: - trackerURL = cursor.getString(i); - break; - case AppProvider.DataColumns.SOURCE_URL: - sourceURL = cursor.getString(i); - break; - case AppProvider.DataColumns.CHANGELOG_URL: - changelogURL = cursor.getString(i); - break; - case AppProvider.DataColumns.DONATE_URL: - donateURL = cursor.getString(i); - break; - case AppProvider.DataColumns.BITCOIN_ADDR: - bitcoinAddr = cursor.getString(i); - break; - case AppProvider.DataColumns.LITECOIN_ADDR: - litecoinAddr = cursor.getString(i); - break; - case AppProvider.DataColumns.FLATTR_ID: - flattrID = cursor.getString(i); - break; - case AppProvider.DataColumns.SuggestedApk.VERSION: - suggestedVersion = cursor.getString(i); - break; - case AppProvider.DataColumns.SUGGESTED_VERSION_CODE: - suggestedVercode = cursor.getInt(i); - break; - case AppProvider.DataColumns.UPSTREAM_VERSION_CODE: - upstreamVercode = cursor.getInt(i); - break; - case AppProvider.DataColumns.UPSTREAM_VERSION: - upstreamVersion = cursor.getString(i); - break; - case AppProvider.DataColumns.ADDED: - added = Utils.parseDate(cursor.getString(i), null); - break; - case AppProvider.DataColumns.LAST_UPDATED: - lastUpdated = Utils.parseDate(cursor.getString(i), null); - break; - case AppProvider.DataColumns.CATEGORIES: - categories = Utils.CommaSeparatedList.make(cursor.getString(i)); - break; - case AppProvider.DataColumns.ANTI_FEATURES: - antiFeatures = Utils.CommaSeparatedList.make(cursor.getString(i)); - break; - case AppProvider.DataColumns.REQUIREMENTS: - requirements = Utils.CommaSeparatedList.make(cursor.getString(i)); - break; - case AppProvider.DataColumns.IGNORE_ALLUPDATES: - ignoreAllUpdates = cursor.getInt(i) == 1; - break; - case AppProvider.DataColumns.IGNORE_THISUPDATE: - ignoreThisUpdate = cursor.getInt(i); - break; - case AppProvider.DataColumns.ICON_URL: - iconUrl = cursor.getString(i); - break; - case AppProvider.DataColumns.ICON_URL_LARGE: - iconUrlLarge = cursor.getString(i); - break; - case AppProvider.DataColumns.InstalledApp.VERSION_CODE: - installedVersionCode = cursor.getInt(i); - break; - case AppProvider.DataColumns.InstalledApp.VERSION_NAME: - installedVersionName = cursor.getString(i); - break; - case "_id": - break; - default: - Log.e(TAG, "Unknown column name " + n); + case AppProvider.DataColumns.IS_COMPATIBLE: + compatible = cursor.getInt(i) == 1; + break; + case AppProvider.DataColumns.APP_ID: + id = cursor.getString(i); + break; + case AppProvider.DataColumns.NAME: + name = cursor.getString(i); + break; + case AppProvider.DataColumns.SUMMARY: + summary = cursor.getString(i); + break; + case AppProvider.DataColumns.ICON: + icon = cursor.getString(i); + break; + case AppProvider.DataColumns.DESCRIPTION: + description = cursor.getString(i); + break; + case AppProvider.DataColumns.LICENSE: + license = cursor.getString(i); + break; + case AppProvider.DataColumns.WEB_URL: + webURL = cursor.getString(i); + break; + case AppProvider.DataColumns.TRACKER_URL: + trackerURL = cursor.getString(i); + break; + case AppProvider.DataColumns.SOURCE_URL: + sourceURL = cursor.getString(i); + break; + case AppProvider.DataColumns.CHANGELOG_URL: + changelogURL = cursor.getString(i); + break; + case AppProvider.DataColumns.DONATE_URL: + donateURL = cursor.getString(i); + break; + case AppProvider.DataColumns.BITCOIN_ADDR: + bitcoinAddr = cursor.getString(i); + break; + case AppProvider.DataColumns.LITECOIN_ADDR: + litecoinAddr = cursor.getString(i); + break; + case AppProvider.DataColumns.FLATTR_ID: + flattrID = cursor.getString(i); + break; + case AppProvider.DataColumns.SuggestedApk.VERSION: + suggestedVersion = cursor.getString(i); + break; + case AppProvider.DataColumns.SUGGESTED_VERSION_CODE: + suggestedVercode = cursor.getInt(i); + break; + case AppProvider.DataColumns.UPSTREAM_VERSION_CODE: + upstreamVercode = cursor.getInt(i); + break; + case AppProvider.DataColumns.UPSTREAM_VERSION: + upstreamVersion = cursor.getString(i); + break; + case AppProvider.DataColumns.ADDED: + added = Utils.parseDate(cursor.getString(i), null); + break; + case AppProvider.DataColumns.LAST_UPDATED: + lastUpdated = Utils.parseDate(cursor.getString(i), null); + break; + case AppProvider.DataColumns.CATEGORIES: + categories = Utils.CommaSeparatedList.make(cursor.getString(i)); + break; + case AppProvider.DataColumns.ANTI_FEATURES: + antiFeatures = Utils.CommaSeparatedList.make(cursor.getString(i)); + break; + case AppProvider.DataColumns.REQUIREMENTS: + requirements = Utils.CommaSeparatedList.make(cursor.getString(i)); + break; + case AppProvider.DataColumns.IGNORE_ALLUPDATES: + ignoreAllUpdates = cursor.getInt(i) == 1; + break; + case AppProvider.DataColumns.IGNORE_THISUPDATE: + ignoreThisUpdate = cursor.getInt(i); + break; + case AppProvider.DataColumns.ICON_URL: + iconUrl = cursor.getString(i); + break; + case AppProvider.DataColumns.ICON_URL_LARGE: + iconUrlLarge = cursor.getString(i); + break; + case AppProvider.DataColumns.InstalledApp.VERSION_CODE: + installedVersionCode = cursor.getInt(i); + break; + case AppProvider.DataColumns.InstalledApp.VERSION_NAME: + installedVersionName = cursor.getString(i); + break; + case "_id": + break; + default: + Log.e(TAG, "Unknown column name " + n); } } } diff --git a/F-Droid/src/org/fdroid/fdroid/data/AppProvider.java b/F-Droid/src/org/fdroid/fdroid/data/AppProvider.java index 43d9e0962..ddb8aff20 100644 --- a/F-Droid/src/org/fdroid/fdroid/data/AppProvider.java +++ b/F-Droid/src/org/fdroid/fdroid/data/AppProvider.java @@ -212,14 +212,14 @@ public class AppProvider extends FDroidProvider { } String[] ALL = { - _ID, IS_COMPATIBLE, APP_ID, NAME, SUMMARY, ICON, DESCRIPTION, - LICENSE, WEB_URL, TRACKER_URL, SOURCE_URL, CHANGELOG_URL, DONATE_URL, - BITCOIN_ADDR, LITECOIN_ADDR, FLATTR_ID, - UPSTREAM_VERSION, UPSTREAM_VERSION_CODE, ADDED, LAST_UPDATED, - CATEGORIES, ANTI_FEATURES, REQUIREMENTS, IGNORE_ALLUPDATES, - IGNORE_THISUPDATE, ICON_URL, ICON_URL_LARGE, - SUGGESTED_VERSION_CODE, SuggestedApk.VERSION, - InstalledApp.VERSION_CODE, InstalledApp.VERSION_NAME + _ID, IS_COMPATIBLE, APP_ID, NAME, SUMMARY, ICON, DESCRIPTION, + LICENSE, WEB_URL, TRACKER_URL, SOURCE_URL, CHANGELOG_URL, DONATE_URL, + BITCOIN_ADDR, LITECOIN_ADDR, FLATTR_ID, + UPSTREAM_VERSION, UPSTREAM_VERSION_CODE, ADDED, LAST_UPDATED, + CATEGORIES, ANTI_FEATURES, REQUIREMENTS, IGNORE_ALLUPDATES, + IGNORE_THISUPDATE, ICON_URL, ICON_URL_LARGE, + SUGGESTED_VERSION_CODE, SuggestedApk.VERSION, + InstalledApp.VERSION_CODE, InstalledApp.VERSION_NAME }; } @@ -345,24 +345,24 @@ public class AppProvider extends FDroidProvider { @Override public void addField(String field) { switch (field) { - case DataColumns.SuggestedApk.VERSION: - addSuggestedApkVersionField(); - break; - case DataColumns.InstalledApp.VERSION_NAME: - addInstalledAppVersionName(); - break; - case DataColumns.InstalledApp.VERSION_CODE: - addInstalledAppVersionCode(); - break; - case DataColumns._COUNT: - appendCountField(); - break; - default: - if (field.equals(DataColumns.CATEGORIES)) { - categoryFieldAdded = true; - } - appendField(field, "fdroid_app"); - break; + case DataColumns.SuggestedApk.VERSION: + addSuggestedApkVersionField(); + break; + case DataColumns.InstalledApp.VERSION_NAME: + addInstalledAppVersionName(); + break; + case DataColumns.InstalledApp.VERSION_CODE: + addInstalledAppVersionCode(); + break; + case DataColumns._COUNT: + appendCountField(); + break; + default: + if (field.equals(DataColumns.CATEGORIES)) { + categoryFieldAdded = true; + } + appendField(field, "fdroid_app"); + break; } } @@ -655,10 +655,10 @@ public class AppProvider extends FDroidProvider { " fdroid_app.categories LIKE ? OR " + // Last category e.g. "%,internet" " fdroid_app.categories LIKE ? "; // One of many categories e.g. "%,internet,%" final String[] args = { - category, - category + ",%", - "%," + category, - "%," + category + ",%", + category, + category + ",%", + "%," + category, + "%," + category + ",%", }; return new AppQuerySelection(selection, args); } @@ -682,70 +682,70 @@ public class AppProvider extends FDroidProvider { boolean includeSwap = true; switch (matcher.match(uri)) { - case CODE_LIST: - includeSwap = false; - break; + case CODE_LIST: + includeSwap = false; + break; - case CODE_SINGLE: - selection = selection.add(querySingle(uri.getLastPathSegment())); - break; + case CODE_SINGLE: + selection = selection.add(querySingle(uri.getLastPathSegment())); + break; - case CAN_UPDATE: - selection = selection.add(queryCanUpdate()); - includeSwap = false; - break; + case CAN_UPDATE: + selection = selection.add(queryCanUpdate()); + includeSwap = false; + break; - case REPO: - selection = selection.add(queryRepo(Long.parseLong(uri.getLastPathSegment()))); - break; + case REPO: + selection = selection.add(queryRepo(Long.parseLong(uri.getLastPathSegment()))); + break; - case INSTALLED: - selection = selection.add(queryInstalled()); - includeSwap = false; - break; + case INSTALLED: + selection = selection.add(queryInstalled()); + includeSwap = false; + break; - case SEARCH: - selection = selection.add(querySearch(uri.getLastPathSegment())); - includeSwap = false; - break; + case SEARCH: + selection = selection.add(querySearch(uri.getLastPathSegment())); + includeSwap = false; + break; - case SEARCH_REPO: - selection = selection.add(querySearch(uri.getPathSegments().get(2))); - selection = selection.add(queryRepo(Long.parseLong(uri.getPathSegments().get(1)))); - break; + case SEARCH_REPO: + selection = selection.add(querySearch(uri.getPathSegments().get(2))); + selection = selection.add(queryRepo(Long.parseLong(uri.getPathSegments().get(1)))); + break; - case NO_APKS: - selection = selection.add(queryNoApks()); - break; + case NO_APKS: + selection = selection.add(queryNoApks()); + break; - case APPS: - selection = selection.add(queryApps(uri.getLastPathSegment())); - break; + case APPS: + selection = selection.add(queryApps(uri.getLastPathSegment())); + break; - case IGNORED: - selection = selection.add(queryIgnored()); - break; + case IGNORED: + selection = selection.add(queryIgnored()); + break; - case CATEGORY: - selection = selection.add(queryCategory(uri.getLastPathSegment())); - includeSwap = false; - break; + case CATEGORY: + selection = selection.add(queryCategory(uri.getLastPathSegment())); + includeSwap = false; + break; - case RECENTLY_UPDATED: - sortOrder = " fdroid_app.lastUpdated DESC"; - selection = selection.add(queryRecentlyUpdated()); - includeSwap = false; - break; + case RECENTLY_UPDATED: + sortOrder = " fdroid_app.lastUpdated DESC"; + selection = selection.add(queryRecentlyUpdated()); + includeSwap = false; + break; - case NEWLY_ADDED: - sortOrder = " fdroid_app.added DESC"; - selection = selection.add(queryNewlyAdded()); - includeSwap = false; - break; + case NEWLY_ADDED: + sortOrder = " fdroid_app.added DESC"; + selection = selection.add(queryNewlyAdded()); + includeSwap = false; + break; - default: - Log.e(TAG, "Invalid URI for app content provider: " + uri); - throw new UnsupportedOperationException("Invalid URI for app content provider: " + uri); + default: + Log.e(TAG, "Invalid URI for app content provider: " + uri); + throw new UnsupportedOperationException("Invalid URI for app content provider: " + uri); } if (!includeSwap) { @@ -773,12 +773,12 @@ public class AppProvider extends FDroidProvider { QuerySelection query = new QuerySelection(where, whereArgs); switch (matcher.match(uri)) { - case NO_APKS: - query = query.add(queryNoApks()); - break; + case NO_APKS: + query = query.add(queryNoApks()); + break; - default: - throw new UnsupportedOperationException("Delete not supported for " + uri + "."); + default: + throw new UnsupportedOperationException("Delete not supported for " + uri + "."); } @@ -801,16 +801,16 @@ public class AppProvider extends FDroidProvider { QuerySelection query = new QuerySelection(where, whereArgs); switch (matcher.match(uri)) { - case CALC_APP_DETAILS_FROM_INDEX: - updateAppDetails(); - return 0; + case CALC_APP_DETAILS_FROM_INDEX: + updateAppDetails(); + return 0; - case CODE_SINGLE: - query = query.add(querySingle(uri.getLastPathSegment())); - break; + case CODE_SINGLE: + query = query.add(querySingle(uri.getLastPathSegment())); + break; - default: - throw new UnsupportedOperationException("Update not supported for " + uri + "."); + default: + throw new UnsupportedOperationException("Update not supported for " + uri + "."); } int count = write().update(getTableName(), values, query.getSelection(), query.getArgs()); diff --git a/F-Droid/src/org/fdroid/fdroid/data/FDroidProvider.java b/F-Droid/src/org/fdroid/fdroid/data/FDroidProvider.java index 4d243f75d..660a6420b 100644 --- a/F-Droid/src/org/fdroid/fdroid/data/FDroidProvider.java +++ b/F-Droid/src/org/fdroid/fdroid/data/FDroidProvider.java @@ -86,13 +86,13 @@ public abstract class FDroidProvider extends ContentProvider { public String getType(Uri uri) { String type; switch (getMatcher().match(uri)) { - case CODE_LIST: - type = "dir"; - break; - case CODE_SINGLE: - default: - type = "item"; - break; + case CODE_LIST: + type = "dir"; + break; + case CODE_SINGLE: + default: + type = "item"; + break; } return "vnd.android.cursor." + type + "/vnd." + AUTHORITY + "." + getProviderName(); } diff --git a/F-Droid/src/org/fdroid/fdroid/data/InstalledAppProvider.java b/F-Droid/src/org/fdroid/fdroid/data/InstalledAppProvider.java index 47b19eb41..b2552fe23 100644 --- a/F-Droid/src/org/fdroid/fdroid/data/InstalledAppProvider.java +++ b/F-Droid/src/org/fdroid/fdroid/data/InstalledAppProvider.java @@ -61,7 +61,7 @@ public class InstalledAppProvider extends FDroidProvider { String APPLICATION_LABEL = "applicationLabel"; String[] ALL = { - _ID, APP_ID, VERSION_CODE, VERSION_NAME, APPLICATION_LABEL, + _ID, APP_ID, VERSION_CODE, VERSION_NAME, APPLICATION_LABEL, }; } @@ -142,21 +142,21 @@ public class InstalledAppProvider extends FDroidProvider { QuerySelection selection = new QuerySelection(customSelection, selectionArgs); switch (matcher.match(uri)) { - case CODE_LIST: - break; + case CODE_LIST: + break; - case CODE_SINGLE: - selection = selection.add(queryApp(uri.getLastPathSegment())); - break; + case CODE_SINGLE: + selection = selection.add(queryApp(uri.getLastPathSegment())); + break; - case CODE_SEARCH: - selection = selection.add(querySearch(uri.getLastPathSegment())); - break; + case CODE_SEARCH: + selection = selection.add(querySearch(uri.getLastPathSegment())); + break; - default: - String message = "Invalid URI for installed app content provider: " + uri; - Log.e(TAG, message); - throw new UnsupportedOperationException(message); + default: + String message = "Invalid URI for installed app content provider: " + uri; + Log.e(TAG, message); + throw new UnsupportedOperationException(message); } Cursor cursor = read().query(getTableName(), projection, selection.getSelection(), selection.getArgs(), null, null, sortOrder); diff --git a/F-Droid/src/org/fdroid/fdroid/data/Repo.java b/F-Droid/src/org/fdroid/fdroid/data/Repo.java index 87cee2e8a..b187240c5 100644 --- a/F-Droid/src/org/fdroid/fdroid/data/Repo.java +++ b/F-Droid/src/org/fdroid/fdroid/data/Repo.java @@ -46,45 +46,45 @@ public class Repo extends ValueObject { for (int i = 0; i < cursor.getColumnCount(); i++) { switch (cursor.getColumnName(i)) { - case RepoProvider.DataColumns._ID: - id = cursor.getInt(i); - break; - case RepoProvider.DataColumns.LAST_ETAG: - lastetag = cursor.getString(i); - break; - case RepoProvider.DataColumns.ADDRESS: - address = cursor.getString(i); - break; - case RepoProvider.DataColumns.DESCRIPTION: - description = cursor.getString(i); - break; - case RepoProvider.DataColumns.FINGERPRINT: - fingerprint = cursor.getString(i); - break; - case RepoProvider.DataColumns.IN_USE: - inuse = cursor.getInt(i) == 1; - break; - case RepoProvider.DataColumns.LAST_UPDATED: - lastUpdated = Utils.parseTime(cursor.getString(i), null); - break; - case RepoProvider.DataColumns.MAX_AGE: - maxage = cursor.getInt(i); - break; - case RepoProvider.DataColumns.VERSION: - version = cursor.getInt(i); - break; - case RepoProvider.DataColumns.NAME: - name = cursor.getString(i); - break; - case RepoProvider.DataColumns.PUBLIC_KEY: - pubkey = cursor.getString(i); - break; - case RepoProvider.DataColumns.PRIORITY: - priority = cursor.getInt(i); - break; - case RepoProvider.DataColumns.IS_SWAP: - isSwap = cursor.getInt(i) == 1; - break; + case RepoProvider.DataColumns._ID: + id = cursor.getInt(i); + break; + case RepoProvider.DataColumns.LAST_ETAG: + lastetag = cursor.getString(i); + break; + case RepoProvider.DataColumns.ADDRESS: + address = cursor.getString(i); + break; + case RepoProvider.DataColumns.DESCRIPTION: + description = cursor.getString(i); + break; + case RepoProvider.DataColumns.FINGERPRINT: + fingerprint = cursor.getString(i); + break; + case RepoProvider.DataColumns.IN_USE: + inuse = cursor.getInt(i) == 1; + break; + case RepoProvider.DataColumns.LAST_UPDATED: + lastUpdated = Utils.parseTime(cursor.getString(i), null); + break; + case RepoProvider.DataColumns.MAX_AGE: + maxage = cursor.getInt(i); + break; + case RepoProvider.DataColumns.VERSION: + version = cursor.getInt(i); + break; + case RepoProvider.DataColumns.NAME: + name = cursor.getString(i); + break; + case RepoProvider.DataColumns.PUBLIC_KEY: + pubkey = cursor.getString(i); + break; + case RepoProvider.DataColumns.PRIORITY: + priority = cursor.getInt(i); + break; + case RepoProvider.DataColumns.IS_SWAP: + isSwap = cursor.getInt(i) == 1; + break; } } } diff --git a/F-Droid/src/org/fdroid/fdroid/data/RepoProvider.java b/F-Droid/src/org/fdroid/fdroid/data/RepoProvider.java index e38f403fb..ee1d44841 100644 --- a/F-Droid/src/org/fdroid/fdroid/data/RepoProvider.java +++ b/F-Droid/src/org/fdroid/fdroid/data/RepoProvider.java @@ -281,22 +281,22 @@ public class RepoProvider extends FDroidProvider { } switch (matcher.match(uri)) { - case CODE_LIST: - // Do nothing (don't restrict query) - break; + case CODE_LIST: + // Do nothing (don't restrict query) + break; - case CODE_SINGLE: - selection = (selection == null ? "" : selection + " AND ") + + case CODE_SINGLE: + selection = (selection == null ? "" : selection + " AND ") + DataColumns._ID + " = " + uri.getLastPathSegment(); - break; + break; - case CODE_ALL_EXCEPT_SWAP: - selection = DataColumns.IS_SWAP + " = 0 OR " + DataColumns.IS_SWAP + " IS NULL "; - break; + case CODE_ALL_EXCEPT_SWAP: + selection = DataColumns.IS_SWAP + " = 0 OR " + DataColumns.IS_SWAP + " IS NULL "; + break; - default: - Log.e(TAG, "Invalid URI for repo content provider: " + uri); - throw new UnsupportedOperationException("Invalid URI for repo content provider: " + uri); + default: + Log.e(TAG, "Invalid URI for repo content provider: " + uri); + throw new UnsupportedOperationException("Invalid URI for repo content provider: " + uri); } Cursor cursor = read().query(getTableName(), projection, selection, @@ -346,18 +346,18 @@ public class RepoProvider extends FDroidProvider { public int delete(Uri uri, String where, String[] whereArgs) { switch (matcher.match(uri)) { - case CODE_LIST: - // Don't support deleting of multiple repos. - return 0; + case CODE_LIST: + // Don't support deleting of multiple repos. + return 0; - case CODE_SINGLE: - where = (where == null ? "" : where + " AND ") + + case CODE_SINGLE: + where = (where == null ? "" : where + " AND ") + "_ID = " + uri.getLastPathSegment(); - break; + break; - default: - Log.e(TAG, "Invalid URI for repo content provider: " + uri); - throw new UnsupportedOperationException("Invalid URI for repo content provider: " + uri); + default: + Log.e(TAG, "Invalid URI for repo content provider: " + uri); + throw new UnsupportedOperationException("Invalid URI for repo content provider: " + uri); } int rowsAffected = write().delete(getTableName(), where, whereArgs); diff --git a/F-Droid/src/org/fdroid/fdroid/installer/DefaultInstaller.java b/F-Droid/src/org/fdroid/fdroid/installer/DefaultInstaller.java index ce3b8205c..b25009ffc 100644 --- a/F-Droid/src/org/fdroid/fdroid/installer/DefaultInstaller.java +++ b/F-Droid/src/org/fdroid/fdroid/installer/DefaultInstaller.java @@ -91,16 +91,16 @@ public class DefaultInstaller extends Installer { * never executed on Androids before 4.0 */ switch (requestCode) { - case REQUEST_CODE_INSTALL: - mCallback.onSuccess(InstallerCallback.OPERATION_INSTALL); + case REQUEST_CODE_INSTALL: + mCallback.onSuccess(InstallerCallback.OPERATION_INSTALL); - return true; - case REQUEST_CODE_DELETE: - mCallback.onSuccess(InstallerCallback.OPERATION_DELETE); + return true; + case REQUEST_CODE_DELETE: + mCallback.onSuccess(InstallerCallback.OPERATION_DELETE); - return true; - default: - return false; + return true; + default: + return false; } } diff --git a/F-Droid/src/org/fdroid/fdroid/installer/DefaultSdk14Installer.java b/F-Droid/src/org/fdroid/fdroid/installer/DefaultSdk14Installer.java index ba64aaedb..d59b4f574 100644 --- a/F-Droid/src/org/fdroid/fdroid/installer/DefaultSdk14Installer.java +++ b/F-Droid/src/org/fdroid/fdroid/installer/DefaultSdk14Installer.java @@ -99,34 +99,34 @@ public class DefaultSdk14Installer extends Installer { @Override public boolean handleOnActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { - case REQUEST_CODE_INSTALL: - if (resultCode == Activity.RESULT_OK) { - mCallback.onSuccess(InstallerCallback.OPERATION_INSTALL); - } else if (resultCode == Activity.RESULT_CANCELED) { - mCallback.onError(InstallerCallback.OPERATION_INSTALL, - InstallerCallback.ERROR_CODE_CANCELED); - } else { - mCallback.onError(InstallerCallback.OPERATION_INSTALL, - InstallerCallback.ERROR_CODE_OTHER); - } + case REQUEST_CODE_INSTALL: + if (resultCode == Activity.RESULT_OK) { + mCallback.onSuccess(InstallerCallback.OPERATION_INSTALL); + } else if (resultCode == Activity.RESULT_CANCELED) { + mCallback.onError(InstallerCallback.OPERATION_INSTALL, + InstallerCallback.ERROR_CODE_CANCELED); + } else { + mCallback.onError(InstallerCallback.OPERATION_INSTALL, + InstallerCallback.ERROR_CODE_OTHER); + } - return true; - case REQUEST_CODE_DELETE: - if (resultCode == Activity.RESULT_OK) { - mCallback.onSuccess(InstallerCallback.OPERATION_DELETE); - } else if (resultCode == Activity.RESULT_CANCELED) { - mCallback.onError(InstallerCallback.OPERATION_DELETE, - InstallerCallback.ERROR_CODE_CANCELED); - } else { - // UninstallAppProgress actually returns - // Activity.RESULT_FIRST_USER if something breaks - mCallback.onError(InstallerCallback.OPERATION_DELETE, - InstallerCallback.ERROR_CODE_OTHER); - } + return true; + case REQUEST_CODE_DELETE: + if (resultCode == Activity.RESULT_OK) { + mCallback.onSuccess(InstallerCallback.OPERATION_DELETE); + } else if (resultCode == Activity.RESULT_CANCELED) { + mCallback.onError(InstallerCallback.OPERATION_DELETE, + InstallerCallback.ERROR_CODE_CANCELED); + } else { + // UninstallAppProgress actually returns + // Activity.RESULT_FIRST_USER if something breaks + mCallback.onError(InstallerCallback.OPERATION_DELETE, + InstallerCallback.ERROR_CODE_OTHER); + } - return true; - default: - return false; + return true; + default: + return false; } } diff --git a/F-Droid/src/org/fdroid/fdroid/localrepo/LocalRepoKeyStore.java b/F-Droid/src/org/fdroid/fdroid/localrepo/LocalRepoKeyStore.java index 9b40f5d14..236d54656 100644 --- a/F-Droid/src/org/fdroid/fdroid/localrepo/LocalRepoKeyStore.java +++ b/F-Droid/src/org/fdroid/fdroid/localrepo/LocalRepoKeyStore.java @@ -161,7 +161,7 @@ public final class LocalRepoKeyStore { KeyManager wrappedKeyManager = new KerplappKeyManager( (X509KeyManager) defaultKeyManager); keyManagers = new KeyManager[] { - wrappedKeyManager + wrappedKeyManager }; } catch (UnrecoverableKeyException | KeyStoreException | NoSuchAlgorithmException | CertificateException | OperatorCreationException | IOException e) { Log.e(TAG, "Error loading keystore", e); @@ -255,7 +255,7 @@ public final class LocalRepoKeyStore { private void addToStore(String alias, KeyPair kp, Certificate cert) throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException, UnrecoverableKeyException { Certificate[] chain = { - cert + cert }; keyStore.setKeyEntry(alias, kp.getPrivate(), "".toCharArray(), chain); @@ -274,7 +274,7 @@ public final class LocalRepoKeyStore { KeyManager defaultKeyManager = keyManagerFactory.getKeyManagers()[0]; KeyManager wrappedKeyManager = new KerplappKeyManager((X509KeyManager) defaultKeyManager); keyManagers = new KeyManager[] { - wrappedKeyManager + wrappedKeyManager }; } diff --git a/F-Droid/src/org/fdroid/fdroid/net/BluetoothDownloader.java b/F-Droid/src/org/fdroid/fdroid/net/BluetoothDownloader.java index 1ca007557..c337fe0fd 100644 --- a/F-Droid/src/org/fdroid/fdroid/net/BluetoothDownloader.java +++ b/F-Droid/src/org/fdroid/fdroid/net/BluetoothDownloader.java @@ -92,7 +92,7 @@ public class BluetoothDownloader extends Downloader { details != null && details.getCacheTag() != null && details.getCacheTag().equals(getCacheTag()) - ); + ); } @Override diff --git a/F-Droid/src/org/fdroid/fdroid/net/LocalHTTPD.java b/F-Droid/src/org/fdroid/fdroid/net/LocalHTTPD.java index af3c8eb11..243464f9d 100644 --- a/F-Droid/src/org/fdroid/fdroid/net/LocalHTTPD.java +++ b/F-Droid/src/org/fdroid/fdroid/net/LocalHTTPD.java @@ -54,18 +54,18 @@ public class LocalHTTPD extends NanoHTTPD { while (st.hasMoreTokens()) { String tok = st.nextToken(); switch (tok) { - case "/": - newUri += "/"; - break; - case " ": - newUri += "%20"; - break; - default: - try { - newUri += URLEncoder.encode(tok, "UTF-8"); - } catch (UnsupportedEncodingException ignored) { - } - break; + case "/": + newUri += "/"; + break; + case " ": + newUri += "%20"; + break; + default: + try { + newUri += URLEncoder.encode(tok, "UTF-8"); + } catch (UnsupportedEncodingException ignored) { + } + break; } } return newUri; @@ -105,13 +105,13 @@ public class LocalHTTPD extends NanoHTTPD { private Response handlePost(IHTTPSession session) { Uri uri = Uri.parse(session.getUri()); switch (uri.getPath()) { - case "/request-swap": - if (!session.getParms().containsKey("repo")) { - Log.e(TAG, "Malformed /request-swap request to local repo HTTP server. Should have posted a 'repo' parameter."); - return new Response(Response.Status.BAD_REQUEST, MIME_PLAINTEXT, "Requires 'repo' parameter to be posted."); - } - requestSwap(session.getParms().get("repo")); - return new Response(Response.Status.OK, MIME_PLAINTEXT, "Swap request received."); + case "/request-swap": + if (!session.getParms().containsKey("repo")) { + Log.e(TAG, "Malformed /request-swap request to local repo HTTP server. Should have posted a 'repo' parameter."); + return new Response(Response.Status.BAD_REQUEST, MIME_PLAINTEXT, "Requires 'repo' parameter to be posted."); + } + requestSwap(session.getParms().get("repo")); + return new Response(Response.Status.OK, MIME_PLAINTEXT, "Swap request received."); } return new Response(""); } diff --git a/F-Droid/src/org/fdroid/fdroid/net/TorHttpDownloader.java b/F-Droid/src/org/fdroid/fdroid/net/TorHttpDownloader.java index c0eaf4d45..50bb50fa5 100644 --- a/F-Droid/src/org/fdroid/fdroid/net/TorHttpDownloader.java +++ b/F-Droid/src/org/fdroid/fdroid/net/TorHttpDownloader.java @@ -21,8 +21,8 @@ public class TorHttpDownloader extends HttpDownloader { @Override protected void setupConnection() throws IOException { - SocketAddress sa = new InetSocketAddress("127.0.0.1", 8118); - Proxy tor = new Proxy(Proxy.Type.HTTP, sa); - connection = (HttpURLConnection) sourceUrl.openConnection(tor); + SocketAddress sa = new InetSocketAddress("127.0.0.1", 8118); + Proxy tor = new Proxy(Proxy.Type.HTTP, sa); + connection = (HttpURLConnection) sourceUrl.openConnection(tor); } } diff --git a/F-Droid/src/org/fdroid/fdroid/privileged/views/AppSecurityPermissions.java b/F-Droid/src/org/fdroid/fdroid/privileged/views/AppSecurityPermissions.java index c86d12353..032a9c4be 100644 --- a/F-Droid/src/org/fdroid/fdroid/privileged/views/AppSecurityPermissions.java +++ b/F-Droid/src/org/fdroid/fdroid/privileged/views/AppSecurityPermissions.java @@ -353,14 +353,14 @@ public class AppSecurityPermissions { private List getPermissionList(MyPermissionGroupInfo grp, int which) { switch (which) { - case WHICH_NEW: - return grp.mNewPermissions; - case WHICH_PERSONAL: - return grp.mPersonalPermissions; - case WHICH_DEVICE: - return grp.mDevicePermissions; - default: - return grp.mAllPermissions; + case WHICH_NEW: + return grp.mNewPermissions; + case WHICH_PERSONAL: + return grp.mPersonalPermissions; + case WHICH_DEVICE: + return grp.mDevicePermissions; + default: + return grp.mAllPermissions; } } diff --git a/F-Droid/src/org/fdroid/fdroid/views/AppListFragmentPagerAdapter.java b/F-Droid/src/org/fdroid/fdroid/views/AppListFragmentPagerAdapter.java index 58e5eff3b..09f39f68d 100644 --- a/F-Droid/src/org/fdroid/fdroid/views/AppListFragmentPagerAdapter.java +++ b/F-Droid/src/org/fdroid/fdroid/views/AppListFragmentPagerAdapter.java @@ -34,12 +34,12 @@ public class AppListFragmentPagerAdapter extends FragmentPagerAdapter { @Override public Fragment getItem(int i) { switch (i) { - case TabManager.INDEX_AVAILABLE: - return new AvailableAppsFragment(); - case TabManager.INDEX_INSTALLED: - return new InstalledAppsFragment(); - default: - return new CanUpdateAppsFragment(); + case TabManager.INDEX_AVAILABLE: + return new AvailableAppsFragment(); + case TabManager.INDEX_INSTALLED: + return new InstalledAppsFragment(); + default: + return new CanUpdateAppsFragment(); } } @@ -49,14 +49,14 @@ public class AppListFragmentPagerAdapter extends FragmentPagerAdapter { @Override public String getPageTitle(int i) { switch (i) { - case TabManager.INDEX_AVAILABLE: - return parent.getString(R.string.tab_available_apps); - case TabManager.INDEX_INSTALLED: - return parent.getString(R.string.tab_installed_apps); - case TabManager.INDEX_CAN_UPDATE: - return getUpdateTabTitle(); - default: - return ""; + case TabManager.INDEX_AVAILABLE: + return parent.getString(R.string.tab_available_apps); + case TabManager.INDEX_INSTALLED: + return parent.getString(R.string.tab_installed_apps); + case TabManager.INDEX_CAN_UPDATE: + return getUpdateTabTitle(); + default: + return ""; } } diff --git a/F-Droid/src/org/fdroid/fdroid/views/ManageReposActivity.java b/F-Droid/src/org/fdroid/fdroid/views/ManageReposActivity.java index 481a1c1b6..7533da338 100644 --- a/F-Droid/src/org/fdroid/fdroid/views/ManageReposActivity.java +++ b/F-Droid/src/org/fdroid/fdroid/views/ManageReposActivity.java @@ -155,17 +155,17 @@ public class ManageReposActivity extends ActionBarActivity { @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { - case android.R.id.home: - Intent destIntent = new Intent(this, FDroid.class); - setResult(RESULT_OK, destIntent); - NavUtils.navigateUpTo(this, destIntent); - return true; - case R.id.action_add_repo: - showAddRepo(); - return true; - case R.id.action_update_repo: - UpdateService.updateNow(this); - return true; + case android.R.id.home: + Intent destIntent = new Intent(this, FDroid.class); + setResult(RESULT_OK, destIntent); + NavUtils.navigateUpTo(this, destIntent); + return true; + case R.id.action_add_repo: + showAddRepo(); + return true; + case R.id.action_update_repo: + UpdateService.updateNow(this); + return true; } return super.onOptionsItemSelected(item); } @@ -649,11 +649,11 @@ public class ManageReposActivity extends ActionBarActivity { Uri uri = RepoProvider.allExceptSwapUri(); Utils.debugLog(TAG, "Creating repo loader '" + uri + "'."); final String[] projection = { - RepoProvider.DataColumns._ID, - RepoProvider.DataColumns.NAME, - RepoProvider.DataColumns.PUBLIC_KEY, - RepoProvider.DataColumns.FINGERPRINT, - RepoProvider.DataColumns.IN_USE + RepoProvider.DataColumns._ID, + RepoProvider.DataColumns.NAME, + RepoProvider.DataColumns.PUBLIC_KEY, + RepoProvider.DataColumns.FINGERPRINT, + RepoProvider.DataColumns.IN_USE }; return new CursorLoader(getActivity(), uri, projection, null, null, null); } diff --git a/F-Droid/src/org/fdroid/fdroid/views/RepoDetailsActivity.java b/F-Droid/src/org/fdroid/fdroid/views/RepoDetailsActivity.java index a0959f03a..05149e763 100644 --- a/F-Droid/src/org/fdroid/fdroid/views/RepoDetailsActivity.java +++ b/F-Droid/src/org/fdroid/fdroid/views/RepoDetailsActivity.java @@ -47,23 +47,23 @@ public class RepoDetailsActivity extends ActionBarActivity { * all of this info, otherwise they will be hidden. */ private static final int[] SHOW_IF_EXISTS = { - R.id.label_repo_name, - R.id.text_repo_name, - R.id.text_description, - R.id.label_num_apps, - R.id.text_num_apps, - R.id.label_last_update, - R.id.text_last_update, - R.id.label_repo_fingerprint, - R.id.text_repo_fingerprint, - R.id.text_repo_fingerprint_description + R.id.label_repo_name, + R.id.text_repo_name, + R.id.text_description, + R.id.label_num_apps, + R.id.text_num_apps, + R.id.label_last_update, + R.id.text_last_update, + R.id.label_repo_fingerprint, + R.id.text_repo_fingerprint, + R.id.text_repo_fingerprint_description }; /** * If the repo has not been updated yet, then we only show * these, otherwise they are hidden. */ private static final int[] HIDE_IF_EXISTS = { - R.id.text_not_yet_updated, + R.id.text_not_yet_updated, }; private Repo repo; private long repoId; @@ -95,9 +95,9 @@ public class RepoDetailsActivity extends ActionBarActivity { repoId = getIntent().getLongExtra(ARG_REPO_ID, 0); final String[] projection = { - RepoProvider.DataColumns.NAME, - RepoProvider.DataColumns.ADDRESS, - RepoProvider.DataColumns.FINGERPRINT + RepoProvider.DataColumns.NAME, + RepoProvider.DataColumns.ADDRESS, + RepoProvider.DataColumns.FINGERPRINT }; repo = RepoProvider.Helper.findById(this, repoId, projection); @@ -317,22 +317,22 @@ public class RepoDetailsActivity extends ActionBarActivity { private void promptForDelete() { new AlertDialog.Builder(this) - .setTitle(R.string.repo_confirm_delete_title) - .setMessage(R.string.repo_confirm_delete_body) - .setPositiveButton(R.string.delete, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - RepoProvider.Helper.remove(getApplicationContext(), repoId); - finish(); - } - }).setNegativeButton(android.R.string.cancel, + .setTitle(R.string.repo_confirm_delete_title) + .setMessage(R.string.repo_confirm_delete_body) + .setPositiveButton(R.string.delete, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + RepoProvider.Helper.remove(getApplicationContext(), repoId); + finish(); + } + }).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // Do nothing... } } - ).show(); + ).show(); } } diff --git a/F-Droid/src/org/fdroid/fdroid/views/fragments/AppListFragment.java b/F-Droid/src/org/fdroid/fdroid/views/fragments/AppListFragment.java index ef1effad9..ffd2ed9dd 100644 --- a/F-Droid/src/org/fdroid/fdroid/views/fragments/AppListFragment.java +++ b/F-Droid/src/org/fdroid/fdroid/views/fragments/AppListFragment.java @@ -34,21 +34,21 @@ public abstract class AppListFragment extends ThemeableListFragment implements private static final int REQUEST_APPDETAILS = 0; public static final String[] APP_PROJECTION = { - AppProvider.DataColumns._ID, // Required for cursor loader to work. - AppProvider.DataColumns.APP_ID, - AppProvider.DataColumns.NAME, - AppProvider.DataColumns.SUMMARY, - AppProvider.DataColumns.IS_COMPATIBLE, - AppProvider.DataColumns.LICENSE, - AppProvider.DataColumns.ICON, - AppProvider.DataColumns.ICON_URL, - AppProvider.DataColumns.InstalledApp.VERSION_CODE, - AppProvider.DataColumns.InstalledApp.VERSION_NAME, - AppProvider.DataColumns.SuggestedApk.VERSION, - AppProvider.DataColumns.SUGGESTED_VERSION_CODE, - AppProvider.DataColumns.IGNORE_ALLUPDATES, - AppProvider.DataColumns.IGNORE_THISUPDATE, - AppProvider.DataColumns.REQUIREMENTS, // Needed for filtering apps that require root. + AppProvider.DataColumns._ID, // Required for cursor loader to work. + AppProvider.DataColumns.APP_ID, + AppProvider.DataColumns.NAME, + AppProvider.DataColumns.SUMMARY, + AppProvider.DataColumns.IS_COMPATIBLE, + AppProvider.DataColumns.LICENSE, + AppProvider.DataColumns.ICON, + AppProvider.DataColumns.ICON_URL, + AppProvider.DataColumns.InstalledApp.VERSION_CODE, + AppProvider.DataColumns.InstalledApp.VERSION_NAME, + AppProvider.DataColumns.SuggestedApk.VERSION, + AppProvider.DataColumns.SUGGESTED_VERSION_CODE, + AppProvider.DataColumns.IGNORE_ALLUPDATES, + AppProvider.DataColumns.IGNORE_THISUPDATE, + AppProvider.DataColumns.REQUIREMENTS, // Needed for filtering apps that require root. }; public static final String APP_SORT = AppProvider.DataColumns.NAME; diff --git a/F-Droid/src/org/fdroid/fdroid/views/fragments/PreferencesFragment.java b/F-Droid/src/org/fdroid/fdroid/views/fragments/PreferencesFragment.java index a70f3544a..f89b1a401 100644 --- a/F-Droid/src/org/fdroid/fdroid/views/fragments/PreferencesFragment.java +++ b/F-Droid/src/org/fdroid/fdroid/views/fragments/PreferencesFragment.java @@ -72,108 +72,108 @@ public class PreferencesFragment extends PreferenceFragment int result = 0; switch (key) { - case Preferences.PREF_UPD_INTERVAL: - ListPreference listPref = (ListPreference) findPreference( - Preferences.PREF_UPD_INTERVAL); - int interval = Integer.parseInt(listPref.getValue()); - Preference onlyOnWifi = findPreference( - Preferences.PREF_UPD_WIFI_ONLY); - onlyOnWifi.setEnabled(interval > 0); - if (interval == 0) { - listPref.setSummary(R.string.update_interval_zero); - } else { - listPref.setSummary(listPref.getEntry()); - } - break; + case Preferences.PREF_UPD_INTERVAL: + ListPreference listPref = (ListPreference) findPreference( + Preferences.PREF_UPD_INTERVAL); + int interval = Integer.parseInt(listPref.getValue()); + Preference onlyOnWifi = findPreference( + Preferences.PREF_UPD_WIFI_ONLY); + onlyOnWifi.setEnabled(interval > 0); + if (interval == 0) { + listPref.setSummary(R.string.update_interval_zero); + } else { + listPref.setSummary(listPref.getEntry()); + } + break; - case Preferences.PREF_UPD_WIFI_ONLY: - checkSummary(key, R.string.automatic_scan_wifi_on); - break; + case Preferences.PREF_UPD_WIFI_ONLY: + checkSummary(key, R.string.automatic_scan_wifi_on); + break; - case Preferences.PREF_UPD_NOTIFY: - checkSummary(key, R.string.notify_on); - break; + case Preferences.PREF_UPD_NOTIFY: + checkSummary(key, R.string.notify_on); + break; - case Preferences.PREF_UPD_HISTORY: - textSummary(key, R.string.update_history_summ); - break; + case Preferences.PREF_UPD_HISTORY: + textSummary(key, R.string.update_history_summ); + break; - case Preferences.PREF_COMPACT_LAYOUT: - checkSummary(key, R.string.compactlayout_on); - break; + case Preferences.PREF_COMPACT_LAYOUT: + checkSummary(key, R.string.compactlayout_on); + break; - case Preferences.PREF_THEME: - entrySummary(key); - if (changing) { - result |= PreferencesActivity.RESULT_RESTART; - getActivity().setResult(result); - } - break; + case Preferences.PREF_THEME: + entrySummary(key); + if (changing) { + result |= PreferencesActivity.RESULT_RESTART; + getActivity().setResult(result); + } + break; - case Preferences.PREF_INCOMP_VER: - checkSummary(key, R.string.show_incompat_versions_on); - break; + case Preferences.PREF_INCOMP_VER: + checkSummary(key, R.string.show_incompat_versions_on); + break; - case Preferences.PREF_ROOTED: - checkSummary(key, R.string.rooted_on); - break; + case Preferences.PREF_ROOTED: + checkSummary(key, R.string.rooted_on); + break; - case Preferences.PREF_IGN_TOUCH: - checkSummary(key, R.string.ignoreTouch_on); - break; + case Preferences.PREF_IGN_TOUCH: + checkSummary(key, R.string.ignoreTouch_on); + break; - case Preferences.PREF_LOCAL_REPO_NAME: - textSummary(key, R.string.local_repo_name_summary); - break; + case Preferences.PREF_LOCAL_REPO_NAME: + textSummary(key, R.string.local_repo_name_summary); + break; - case Preferences.PREF_LOCAL_REPO_HTTPS: - checkSummary(key, R.string.local_repo_https_on); - break; + case Preferences.PREF_LOCAL_REPO_HTTPS: + checkSummary(key, R.string.local_repo_https_on); + break; - case Preferences.PREF_LANGUAGE: - langSpinner(key); - entrySummary(key); - if (changing) { - result |= PreferencesActivity.RESULT_RESTART; - getActivity().setResult(result); - FDroidApp.updateLanguage(this.getActivity()); - } - break; + case Preferences.PREF_LANGUAGE: + langSpinner(key); + entrySummary(key); + if (changing) { + result |= PreferencesActivity.RESULT_RESTART; + getActivity().setResult(result); + FDroidApp.updateLanguage(this.getActivity()); + } + break; - case Preferences.PREF_CACHE_APK: - checkSummary(key, R.string.cache_downloaded_on); - break; + case Preferences.PREF_CACHE_APK: + checkSummary(key, R.string.cache_downloaded_on); + break; - case Preferences.PREF_EXPERT: - checkSummary(key, R.string.expert_on); - break; + case Preferences.PREF_EXPERT: + checkSummary(key, R.string.expert_on); + break; - case Preferences.PREF_PRIVILEGED_INSTALLER: - checkSummary(key, R.string.system_installer_on); - break; + case Preferences.PREF_PRIVILEGED_INSTALLER: + checkSummary(key, R.string.system_installer_on); + break; - case Preferences.PREF_ENABLE_PROXY: - CheckBoxPreference checkPref = (CheckBoxPreference) findPreference(key); - checkPref.setSummary(R.string.enable_proxy_summary); - break; + case Preferences.PREF_ENABLE_PROXY: + CheckBoxPreference checkPref = (CheckBoxPreference) findPreference(key); + checkPref.setSummary(R.string.enable_proxy_summary); + break; - case Preferences.PREF_PROXY_HOST: - EditTextPreference textPref = (EditTextPreference) findPreference(key); - String text = Preferences.get().getProxyHost(); - if (TextUtils.isEmpty(text) || text.equals(Preferences.DEFAULT_PROXY_HOST)) - textPref.setSummary(R.string.proxy_host_summary); - else - textPref.setSummary(text); - break; + case Preferences.PREF_PROXY_HOST: + EditTextPreference textPref = (EditTextPreference) findPreference(key); + String text = Preferences.get().getProxyHost(); + if (TextUtils.isEmpty(text) || text.equals(Preferences.DEFAULT_PROXY_HOST)) + textPref.setSummary(R.string.proxy_host_summary); + else + textPref.setSummary(text); + break; - case Preferences.PREF_PROXY_PORT: - EditTextPreference textPref2 = (EditTextPreference) findPreference(key); - int port = Preferences.get().getProxyPort(); - if (port == Preferences.DEFAULT_PROXY_PORT) - textPref2.setSummary(R.string.proxy_port_summary); - else - textPref2.setSummary(String.valueOf(port)); - break; + case Preferences.PREF_PROXY_PORT: + EditTextPreference textPref2 = (EditTextPreference) findPreference(key); + int port = Preferences.get().getProxyPort(); + if (port == Preferences.DEFAULT_PROXY_PORT) + textPref2.setSummary(R.string.proxy_port_summary); + else + textPref2.setSummary(String.valueOf(port)); + break; } } diff --git a/F-Droid/src/org/fdroid/fdroid/views/swap/SwapWorkflowActivity.java b/F-Droid/src/org/fdroid/fdroid/views/swap/SwapWorkflowActivity.java index 900c3a170..cbe4eaa49 100644 --- a/F-Droid/src/org/fdroid/fdroid/views/swap/SwapWorkflowActivity.java +++ b/F-Droid/src/org/fdroid/fdroid/views/swap/SwapWorkflowActivity.java @@ -234,17 +234,17 @@ public class SwapWorkflowActivity extends AppCompatActivity { .setTitle(R.string.swap_join_same_wifi) .setMessage(R.string.swap_join_same_wifi_desc) .setNeutralButton(R.string.cancel, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - // Do nothing - } - } - ).setPositiveButton(R.string.wifi, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - startActivity(new Intent(WifiManager.ACTION_PICK_WIFI_NETWORK)); - } + @Override + public void onClick(DialogInterface dialog, int which) { + // Do nothing } + } + ).setPositiveButton(R.string.wifi, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + startActivity(new Intent(WifiManager.ACTION_PICK_WIFI_NETWORK)); + } + } ).setNegativeButton(R.string.wifi_ap, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { diff --git a/Privileged-Extension/src/main/java/org/fdroid/fdroid/privileged/PrivilegedService.java b/Privileged-Extension/src/main/java/org/fdroid/fdroid/privileged/PrivilegedService.java index 57f878e29..29e1a3228 100644 --- a/Privileged-Extension/src/main/java/org/fdroid/fdroid/privileged/PrivilegedService.java +++ b/Privileged-Extension/src/main/java/org/fdroid/fdroid/privileged/PrivilegedService.java @@ -142,12 +142,12 @@ public class PrivilegedService extends Service { // get internal methods via reflection try { Class[] installTypes = { - Uri.class, IPackageInstallObserver.class, int.class, - String.class + Uri.class, IPackageInstallObserver.class, int.class, + String.class }; Class[] deleteTypes = { - String.class, IPackageDeleteObserver.class, - int.class + String.class, IPackageDeleteObserver.class, + int.class }; PackageManager pm = getPackageManager(); diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml index b977150f0..0bd1953f7 100644 --- a/config/checkstyle/checkstyle.xml +++ b/config/checkstyle/checkstyle.xml @@ -34,6 +34,8 @@ + +