checkstyle: Add indentation
This commit is contained in:
parent
04ea84640e
commit
561d7833d1
@ -25,90 +25,90 @@ import android.provider.ContactsContract;
|
|||||||
* @author dswitkin@google.com (Daniel Switkin)
|
* @author dswitkin@google.com (Daniel Switkin)
|
||||||
*/
|
*/
|
||||||
public final class Contents {
|
public final class Contents {
|
||||||
private 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:
|
|
||||||
* <p/>
|
|
||||||
* import android.provider.Contacts;
|
|
||||||
* <p/>
|
|
||||||
* 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() {
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
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
|
* Use Intent.putExtra(DATA, string) where string is the phone number to call.
|
||||||
* phone numbers and addresses.
|
*/
|
||||||
*/
|
public static final String PHONE = "PHONE_TYPE";
|
||||||
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,
|
* An SMS type. Use Intent.putExtra(DATA, string) where string is the number to SMS.
|
||||||
ContactsContract.Intents.Insert.SECONDARY_PHONE_TYPE,
|
*/
|
||||||
ContactsContract.Intents.Insert.TERTIARY_PHONE_TYPE
|
public static final String SMS = "SMS_TYPE";
|
||||||
};
|
|
||||||
|
|
||||||
public static final String[] EMAIL_KEYS = {
|
/**
|
||||||
ContactsContract.Intents.Insert.EMAIL,
|
* A contact. Send a request to encode it as follows:
|
||||||
ContactsContract.Intents.Insert.SECONDARY_EMAIL,
|
* <p/>
|
||||||
ContactsContract.Intents.Insert.TERTIARY_EMAIL
|
* import android.provider.Contacts;
|
||||||
};
|
* <p/>
|
||||||
|
* 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,
|
* A geographic location. Use as follows:
|
||||||
ContactsContract.Intents.Insert.SECONDARY_EMAIL_TYPE,
|
* Bundle bundle = new Bundle();
|
||||||
ContactsContract.Intents.Insert.TERTIARY_EMAIL_TYPE
|
* 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
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -83,118 +83,118 @@ public final class QRCodeEncoder {
|
|||||||
|
|
||||||
private void encodeQRCodeContents(String data, Bundle bundle, String type) {
|
private void encodeQRCodeContents(String data, Bundle bundle, String type) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case Contents.Type.TEXT:
|
case Contents.Type.TEXT:
|
||||||
if (data != null && data.length() > 0) {
|
if (data != null && data.length() > 0) {
|
||||||
contents = data;
|
contents = data;
|
||||||
displayContents = data;
|
displayContents = data;
|
||||||
title = "Text";
|
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);
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
String address = trim(bundle.getString(ContactsContract.Intents.Insert.POSTAL));
|
case Contents.Type.EMAIL:
|
||||||
if (address != null) {
|
data = trim(data);
|
||||||
newContents.append("ADR:").append(escapeMECARD(address)).append(';');
|
if (data != null) {
|
||||||
newDisplayContents.append('\n').append(address);
|
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<String> uniquePhones = new HashSet<>(Contents.PHONE_KEYS.length);
|
newContents.append("MECARD:");
|
||||||
for (int x = 0; x < Contents.PHONE_KEYS.length; x++) {
|
|
||||||
String phone = trim(bundle.getString(Contents.PHONE_KEYS[x]));
|
String name = trim(bundle.getString(ContactsContract.Intents.Insert.NAME));
|
||||||
if (phone != null) {
|
if (name != null) {
|
||||||
uniquePhones.add(phone);
|
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<String> 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<String> 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) {
|
break;
|
||||||
newContents.append("TEL:").append(escapeMECARD(phone)).append(';');
|
|
||||||
newDisplayContents.append('\n').append(PhoneNumberUtils.formatNumber(phone));
|
|
||||||
}
|
|
||||||
|
|
||||||
Collection<String> 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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,401 +106,401 @@ import java.util.Map;
|
|||||||
* @author Isaac Potoczny-Jones
|
* @author Isaac Potoczny-Jones
|
||||||
* @author Brad Drehmer
|
* @author Brad Drehmer
|
||||||
* @author gcstang
|
* @author gcstang
|
||||||
*/
|
*/
|
||||||
public class IntentIntegrator {
|
public class IntentIntegrator {
|
||||||
|
|
||||||
public static final int REQUEST_CODE = 0x0000c0de; // Only use bottom 16 bits
|
public static final int REQUEST_CODE = 0x0000c0de; // Only use bottom 16 bits
|
||||||
private static final String TAG = IntentIntegrator.class.getSimpleName();
|
private static final String TAG = IntentIntegrator.class.getSimpleName();
|
||||||
|
|
||||||
public static final String DEFAULT_TITLE = "Install Barcode Scanner?";
|
public static final String DEFAULT_TITLE = "Install Barcode Scanner?";
|
||||||
public static final String DEFAULT_MESSAGE =
|
public static final String DEFAULT_MESSAGE =
|
||||||
"This application requires Barcode Scanner. Would you like to install it?";
|
"This application requires Barcode Scanner. Would you like to install it?";
|
||||||
public static final String DEFAULT_YES = "Yes";
|
public static final String DEFAULT_YES = "Yes";
|
||||||
public static final String DEFAULT_NO = "No";
|
public static final String DEFAULT_NO = "No";
|
||||||
|
|
||||||
private static final String BS_PACKAGE = "com.google.zxing.client.android";
|
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 BSPLUS_PACKAGE = "com.srowen.bs.android";
|
||||||
|
|
||||||
// supported barcode formats
|
// supported barcode formats
|
||||||
public static final Collection<String> PRODUCT_CODE_TYPES = list("UPC_A", "UPC_E", "EAN_8", "EAN_13", "RSS_14");
|
public static final Collection<String> PRODUCT_CODE_TYPES = list("UPC_A", "UPC_E", "EAN_8", "EAN_13", "RSS_14");
|
||||||
public static final Collection<String> ONE_D_CODE_TYPES =
|
public static final Collection<String> ONE_D_CODE_TYPES =
|
||||||
list("UPC_A", "UPC_E", "EAN_8", "EAN_13", "CODE_39", "CODE_93", "CODE_128",
|
list("UPC_A", "UPC_E", "EAN_8", "EAN_13", "CODE_39", "CODE_93", "CODE_128",
|
||||||
"ITF", "RSS_14", "RSS_EXPANDED");
|
"ITF", "RSS_14", "RSS_EXPANDED");
|
||||||
public static final Collection<String> QR_CODE_TYPES = Collections.singleton("QR_CODE");
|
public static final Collection<String> QR_CODE_TYPES = Collections.singleton("QR_CODE");
|
||||||
public static final Collection<String> DATA_MATRIX_TYPES = Collections.singleton("DATA_MATRIX");
|
public static final Collection<String> DATA_MATRIX_TYPES = Collections.singleton("DATA_MATRIX");
|
||||||
|
|
||||||
public static final Collection<String> ALL_CODE_TYPES = null;
|
public static final Collection<String> ALL_CODE_TYPES = null;
|
||||||
|
|
||||||
public static final List<String> TARGET_BARCODE_SCANNER_ONLY = Collections.singletonList(BS_PACKAGE);
|
public static final List<String> TARGET_BARCODE_SCANNER_ONLY = Collections.singletonList(BS_PACKAGE);
|
||||||
public static final List<String> TARGET_ALL_KNOWN = list(
|
public static final List<String> TARGET_ALL_KNOWN = list(
|
||||||
BSPLUS_PACKAGE, // Barcode Scanner+
|
BSPLUS_PACKAGE, // Barcode Scanner+
|
||||||
BSPLUS_PACKAGE + ".simple", // Barcode Scanner+ Simple
|
BSPLUS_PACKAGE + ".simple", // Barcode Scanner+ Simple
|
||||||
BS_PACKAGE // Barcode Scanner
|
BS_PACKAGE // Barcode Scanner
|
||||||
// What else supports this intent?
|
// What else supports this intent?
|
||||||
);
|
);
|
||||||
|
|
||||||
private final Activity activity;
|
private final Activity activity;
|
||||||
private final Fragment fragment;
|
private final Fragment fragment;
|
||||||
|
|
||||||
private String title;
|
private String title;
|
||||||
private String message;
|
private String message;
|
||||||
private String buttonYes;
|
private String buttonYes;
|
||||||
private String buttonNo;
|
private String buttonNo;
|
||||||
private List<String> targetApplications;
|
private List<String> targetApplications;
|
||||||
private final Map<String, Object> moreExtras = new HashMap<>(3);
|
private final Map<String, Object> moreExtras = new HashMap<>(3);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param activity {@link Activity} invoking the integration
|
* @param activity {@link Activity} invoking the integration
|
||||||
*/
|
*/
|
||||||
public IntentIntegrator(Activity activity) {
|
public IntentIntegrator(Activity activity) {
|
||||||
this.activity = activity;
|
this.activity = activity;
|
||||||
this.fragment = null;
|
this.fragment = null;
|
||||||
initializeConfiguration();
|
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<String> getTargetApplications() {
|
|
||||||
return targetApplications;
|
|
||||||
}
|
|
||||||
|
|
||||||
public final void setTargetApplications(List<String> targetApplications) {
|
|
||||||
if (targetApplications.isEmpty()) {
|
|
||||||
throw new IllegalArgumentException("No target applications");
|
|
||||||
}
|
}
|
||||||
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<String, ?> getMoreExtras() {
|
private void initializeConfiguration() {
|
||||||
return moreExtras;
|
title = DEFAULT_TITLE;
|
||||||
}
|
message = DEFAULT_MESSAGE;
|
||||||
|
buttonYes = DEFAULT_YES;
|
||||||
|
buttonNo = DEFAULT_NO;
|
||||||
|
targetApplications = TARGET_ALL_KNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
public final void addExtra(String key, Object value) {
|
public String getTitle() {
|
||||||
moreExtras.put(key, value);
|
return title;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void setTitle(String title) {
|
||||||
* Initiates a scan for all known barcode types with the default camera.
|
this.title = title;
|
||||||
*
|
}
|
||||||
* @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 setTitleByID(int titleID) {
|
||||||
* Initiates a scan for all known barcode types with the specified camera.
|
title = activity.getString(titleID);
|
||||||
*
|
}
|
||||||
* @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 String getMessage() {
|
||||||
* Initiates a scan, using the default camera, only for a certain set of barcode types, given as strings corresponding
|
return message;
|
||||||
* 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<String> desiredBarcodeFormats) {
|
|
||||||
return initiateScan(desiredBarcodeFormats, -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
public void setMessage(String message) {
|
||||||
* Initiates a scan, using the specified camera, only for a certain set of barcode types, given as strings corresponding
|
this.message = message;
|
||||||
* 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<String> desiredBarcodeFormats, int cameraId) {
|
|
||||||
Intent intentScan = new Intent(BS_PACKAGE + ".SCAN");
|
|
||||||
intentScan.addCategory(Intent.CATEGORY_DEFAULT);
|
|
||||||
|
|
||||||
// check which types of codes to scan for
|
public void setMessageByID(int messageID) {
|
||||||
if (desiredBarcodeFormats != null) {
|
message = activity.getString(messageID);
|
||||||
// set the desired barcode types
|
}
|
||||||
StringBuilder joinedByComma = new StringBuilder();
|
|
||||||
for (String format : desiredBarcodeFormats) {
|
public String getButtonYes() {
|
||||||
if (joinedByComma.length() > 0) {
|
return buttonYes;
|
||||||
joinedByComma.append(',');
|
}
|
||||||
|
|
||||||
|
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<String> getTargetApplications() {
|
||||||
|
return targetApplications;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void setTargetApplications(List<String> targetApplications) {
|
||||||
|
if (targetApplications.isEmpty()) {
|
||||||
|
throw new IllegalArgumentException("No target applications");
|
||||||
}
|
}
|
||||||
joinedByComma.append(format);
|
this.targetApplications = targetApplications;
|
||||||
}
|
|
||||||
intentScan.putExtra("SCAN_FORMATS", joinedByComma.toString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// check requested camera ID
|
public void setSingleTargetApplication(String targetApplication) {
|
||||||
if (cameraId >= 0) {
|
this.targetApplications = Collections.singletonList(targetApplication);
|
||||||
intentScan.putExtra("SCAN_CAMERA_ID", cameraId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String targetAppPackage = findTargetAppPackage(intentScan);
|
public Map<String, ?> getMoreExtras() {
|
||||||
if (targetAppPackage == null) {
|
return moreExtras;
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
public final void addExtra(String key, Object value) {
|
||||||
* Start an activity. This method is defined to allow different methods of activity starting for
|
moreExtras.put(key, value);
|
||||||
* 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);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private String findTargetAppPackage(Intent intent) {
|
/**
|
||||||
PackageManager pm = activity.getPackageManager();
|
* Initiates a scan for all known barcode types with the default camera.
|
||||||
List<ResolveInfo> availableApps = pm.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
|
*
|
||||||
if (availableApps != null) {
|
* @return the {@link AlertDialog} that was shown to the user prompting them to download the app
|
||||||
for (String targetApp : targetApplications) {
|
* if a prompt was needed, or null otherwise.
|
||||||
if (contains(availableApps, targetApp)) {
|
*/
|
||||||
return targetApp;
|
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<String> 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<String> 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<ResolveInfo> availableApps, String targetApp) {
|
// check requested camera ID
|
||||||
for (ResolveInfo availableApp : availableApps) {
|
if (cameraId >= 0) {
|
||||||
String packageName = availableApp.activityInfo.packageName;
|
intentScan.putExtra("SCAN_CAMERA_ID", cameraId);
|
||||||
if (targetApp.equals(packageName)) {
|
}
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private AlertDialog showDownloadDialog() {
|
String targetAppPackage = findTargetAppPackage(intentScan);
|
||||||
AlertDialog.Builder downloadDialog = new AlertDialog.Builder(activity);
|
if (targetAppPackage == null) {
|
||||||
downloadDialog.setTitle(title);
|
return showDownloadDialog();
|
||||||
downloadDialog.setMessage(message);
|
}
|
||||||
downloadDialog.setPositiveButton(buttonYes, new DialogInterface.OnClickListener() {
|
intentScan.setPackage(targetAppPackage);
|
||||||
@Override
|
intentScan.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||||
public void onClick(DialogInterface dialogInterface, int i) {
|
intentScan.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
|
||||||
String packageName;
|
attachMoreExtras(intentScan);
|
||||||
if (targetApplications.contains(BS_PACKAGE)) {
|
startActivityForResult(intentScan, REQUEST_CODE);
|
||||||
// Prefer to suggest download of BS if it's anywhere in the list
|
return null;
|
||||||
packageName = BS_PACKAGE;
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 {
|
} else {
|
||||||
// Otherwise, first option:
|
fragment.startActivityForResult(intent, code);
|
||||||
packageName = targetApplications.get(0);
|
|
||||||
}
|
}
|
||||||
Uri uri = Uri.parse("market://details?id=" + packageName);
|
}
|
||||||
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
|
|
||||||
try {
|
private String findTargetAppPackage(Intent intent) {
|
||||||
if (fragment == null) {
|
PackageManager pm = activity.getPackageManager();
|
||||||
|
List<ResolveInfo> 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<ResolveInfo> 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();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Call this from your {@link Activity}'s
|
||||||
|
* {@link Activity#onActivityResult(int, int, Intent)} method.</p>
|
||||||
|
*
|
||||||
|
* @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);
|
activity.startActivity(intent);
|
||||||
} else {
|
} else {
|
||||||
fragment.startActivity(intent);
|
fragment.startActivity(intent);
|
||||||
}
|
|
||||||
} catch (ActivityNotFoundException anfe) {
|
|
||||||
// Hmm, market is not installed
|
|
||||||
Log.w(TAG, "Google Play is not installed; cannot install " + packageName);
|
|
||||||
}
|
}
|
||||||
}
|
return null;
|
||||||
});
|
|
||||||
downloadDialog.setNegativeButton(buttonNo, null);
|
|
||||||
downloadDialog.setCancelable(true);
|
|
||||||
return downloadDialog.show();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>Call this from your {@link Activity}'s
|
|
||||||
* {@link Activity#onActivityResult(int, int, Intent)} method.</p>
|
|
||||||
*
|
|
||||||
* @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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
private static List<String> list(String... values) {
|
||||||
/**
|
return Collections.unmodifiableList(Arrays.asList(values));
|
||||||
* 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 {
|
|
||||||
fragment.startActivity(intent);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static List<String> list(String... values) {
|
private void attachMoreExtras(Intent intent) {
|
||||||
return Collections.unmodifiableList(Arrays.asList(values));
|
for (Map.Entry<String, Object> entry : moreExtras.entrySet()) {
|
||||||
}
|
String key = entry.getKey();
|
||||||
|
Object value = entry.getValue();
|
||||||
private void attachMoreExtras(Intent intent) {
|
// Kind of hacky
|
||||||
for (Map.Entry<String, Object> entry : moreExtras.entrySet()) {
|
if (value instanceof Integer) {
|
||||||
String key = entry.getKey();
|
intent.putExtra(key, (Integer) value);
|
||||||
Object value = entry.getValue();
|
} else if (value instanceof Long) {
|
||||||
// Kind of hacky
|
intent.putExtra(key, (Long) value);
|
||||||
if (value instanceof Integer) {
|
} else if (value instanceof Boolean) {
|
||||||
intent.putExtra(key, (Integer) value);
|
intent.putExtra(key, (Boolean) value);
|
||||||
} else if (value instanceof Long) {
|
} else if (value instanceof Double) {
|
||||||
intent.putExtra(key, (Long) value);
|
intent.putExtra(key, (Double) value);
|
||||||
} else if (value instanceof Boolean) {
|
} else if (value instanceof Float) {
|
||||||
intent.putExtra(key, (Boolean) value);
|
intent.putExtra(key, (Float) value);
|
||||||
} else if (value instanceof Double) {
|
} else if (value instanceof Bundle) {
|
||||||
intent.putExtra(key, (Double) value);
|
intent.putExtra(key, (Bundle) value);
|
||||||
} else if (value instanceof Float) {
|
} else {
|
||||||
intent.putExtra(key, (Float) value);
|
intent.putExtra(key, value.toString());
|
||||||
} else if (value instanceof Bundle) {
|
}
|
||||||
intent.putExtra(key, (Bundle) value);
|
}
|
||||||
} else {
|
|
||||||
intent.putExtra(key, value.toString());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -23,67 +23,67 @@ package com.google.zxing.integration.android;
|
|||||||
*/
|
*/
|
||||||
public final class IntentResult {
|
public final class IntentResult {
|
||||||
|
|
||||||
private final String contents;
|
private final String contents;
|
||||||
private final String formatName;
|
private final String formatName;
|
||||||
private final byte[] rawBytes;
|
private final byte[] rawBytes;
|
||||||
private final Integer orientation;
|
private final Integer orientation;
|
||||||
private final String errorCorrectionLevel;
|
private final String errorCorrectionLevel;
|
||||||
|
|
||||||
IntentResult() {
|
IntentResult() {
|
||||||
this(null, null, null, null, null);
|
this(null, null, null, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
IntentResult(String contents,
|
IntentResult(String contents,
|
||||||
String formatName,
|
String formatName,
|
||||||
byte[] rawBytes,
|
byte[] rawBytes,
|
||||||
Integer orientation,
|
Integer orientation,
|
||||||
String errorCorrectionLevel) {
|
String errorCorrectionLevel) {
|
||||||
this.contents = contents;
|
this.contents = contents;
|
||||||
this.formatName = formatName;
|
this.formatName = formatName;
|
||||||
this.rawBytes = rawBytes;
|
this.rawBytes = rawBytes;
|
||||||
this.orientation = orientation;
|
this.orientation = orientation;
|
||||||
this.errorCorrectionLevel = errorCorrectionLevel;
|
this.errorCorrectionLevel = errorCorrectionLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return raw content of barcode
|
* @return raw content of barcode
|
||||||
*/
|
*/
|
||||||
public String getContents() {
|
public String getContents() {
|
||||||
return contents;
|
return contents;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return name of format, like "QR_CODE", "UPC_A". See {@code BarcodeFormat} for more format names.
|
* @return name of format, like "QR_CODE", "UPC_A". See {@code BarcodeFormat} for more format names.
|
||||||
*/
|
*/
|
||||||
public String getFormatName() {
|
public String getFormatName() {
|
||||||
return formatName;
|
return formatName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return raw bytes of the barcode content, if applicable, or null otherwise
|
* @return raw bytes of the barcode content, if applicable, or null otherwise
|
||||||
*/
|
*/
|
||||||
public byte[] getRawBytes() {
|
public byte[] getRawBytes() {
|
||||||
return rawBytes;
|
return rawBytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return rotation of the image, in degrees, which resulted in a successful scan. May be null.
|
* @return rotation of the image, in degrees, which resulted in a successful scan. May be null.
|
||||||
*/
|
*/
|
||||||
public Integer getOrientation() {
|
public Integer getOrientation() {
|
||||||
return orientation;
|
return orientation;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return name of the error correction level used in the barcode, if applicable
|
* @return name of the error correction level used in the barcode, if applicable
|
||||||
*/
|
*/
|
||||||
public String getErrorCorrectionLevel() {
|
public String getErrorCorrectionLevel() {
|
||||||
return errorCorrectionLevel;
|
return errorCorrectionLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
int rawBytesLength = rawBytes == null ? 0 : rawBytes.length;
|
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';
|
return "Format: " + formatName + '\n' + "Contents: " + contents + '\n' + "Raw bytes: (" + rawBytesLength + " bytes)\n" + "Orientation: " + orientation + '\n' + "EC level: " + errorCorrectionLevel + '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -769,57 +769,57 @@ public class AppDetails extends AppCompatActivity implements ProgressListener, A
|
|||||||
|
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
|
|
||||||
case android.R.id.home:
|
case android.R.id.home:
|
||||||
if (getIntent().hasExtra(EXTRA_HINT_SEARCHING)) {
|
if (getIntent().hasExtra(EXTRA_HINT_SEARCHING)) {
|
||||||
finish();
|
finish();
|
||||||
} else {
|
} else {
|
||||||
navigateUp();
|
navigateUp();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case LAUNCH:
|
case LAUNCH:
|
||||||
launchApk(app.id);
|
launchApk(app.id);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case SHARE:
|
case SHARE:
|
||||||
shareApp(app);
|
shareApp(app);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case INSTALL:
|
case INSTALL:
|
||||||
// Note that this handles updating as well as installing.
|
// Note that this handles updating as well as installing.
|
||||||
if (app.suggestedVercode > 0) {
|
if (app.suggestedVercode > 0) {
|
||||||
final Apk apkToInstall = ApkProvider.Helper.find(this, app.id, app.suggestedVercode);
|
final Apk apkToInstall = ApkProvider.Helper.find(this, app.id, app.suggestedVercode);
|
||||||
install(apkToInstall);
|
install(apkToInstall);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case UNINSTALL:
|
case UNINSTALL:
|
||||||
removeApk(app.id);
|
removeApk(app.id);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case IGNOREALL:
|
case IGNOREALL:
|
||||||
app.ignoreAllUpdates ^= true;
|
app.ignoreAllUpdates ^= true;
|
||||||
item.setChecked(app.ignoreAllUpdates);
|
item.setChecked(app.ignoreAllUpdates);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case IGNORETHIS:
|
case IGNORETHIS:
|
||||||
if (app.ignoreThisUpdate >= app.suggestedVercode)
|
if (app.ignoreThisUpdate >= app.suggestedVercode)
|
||||||
app.ignoreThisUpdate = 0;
|
app.ignoreThisUpdate = 0;
|
||||||
else
|
else
|
||||||
app.ignoreThisUpdate = app.suggestedVercode;
|
app.ignoreThisUpdate = app.suggestedVercode;
|
||||||
item.setChecked(app.ignoreThisUpdate > 0);
|
item.setChecked(app.ignoreThisUpdate > 0);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case SEND_VIA_BLUETOOTH:
|
case SEND_VIA_BLUETOOTH:
|
||||||
/*
|
/*
|
||||||
* If Bluetooth has not been enabled/turned on, then
|
* If Bluetooth has not been enabled/turned on, then
|
||||||
* enabling device discoverability will automatically enable Bluetooth
|
* enabling device discoverability will automatically enable Bluetooth
|
||||||
*/
|
*/
|
||||||
Intent discoverBt = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
|
Intent discoverBt = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
|
||||||
discoverBt.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 121);
|
discoverBt.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 121);
|
||||||
startActivityForResult(discoverBt, REQUEST_ENABLE_BLUETOOTH);
|
startActivityForResult(discoverBt, REQUEST_ENABLE_BLUETOOTH);
|
||||||
// if this is successful, the Bluetooth transfer is started
|
// if this is successful, the Bluetooth transfer is started
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
@ -937,19 +937,19 @@ public class AppDetails extends AppCompatActivity implements ProgressListener, A
|
|||||||
if (operation == InstallerCallback.OPERATION_INSTALL) {
|
if (operation == InstallerCallback.OPERATION_INSTALL) {
|
||||||
title = R.string.install_error_title;
|
title = R.string.install_error_title;
|
||||||
switch (errorCode) {
|
switch (errorCode) {
|
||||||
case ERROR_CODE_CANNOT_PARSE:
|
case ERROR_CODE_CANNOT_PARSE:
|
||||||
body = R.string.install_error_cannot_parse;
|
body = R.string.install_error_cannot_parse;
|
||||||
break;
|
break;
|
||||||
default: // ERROR_CODE_OTHER
|
default: // ERROR_CODE_OTHER
|
||||||
body = R.string.install_error_unknown;
|
body = R.string.install_error_unknown;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else { // InstallerCallback.OPERATION_DELETE
|
} else { // InstallerCallback.OPERATION_DELETE
|
||||||
title = R.string.uninstall_error_title;
|
title = R.string.uninstall_error_title;
|
||||||
switch (errorCode) {
|
switch (errorCode) {
|
||||||
default: // ERROR_CODE_OTHER
|
default: // ERROR_CODE_OTHER
|
||||||
body = R.string.uninstall_error_unknown;
|
body = R.string.uninstall_error_unknown;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
runOnUiThread(new Runnable() {
|
runOnUiThread(new Runnable() {
|
||||||
@ -1000,21 +1000,21 @@ public class AppDetails extends AppCompatActivity implements ProgressListener, A
|
|||||||
|
|
||||||
boolean finished = false;
|
boolean finished = false;
|
||||||
switch (event.type) {
|
switch (event.type) {
|
||||||
case ApkDownloader.EVENT_ERROR:
|
case ApkDownloader.EVENT_ERROR:
|
||||||
final int res;
|
final int res;
|
||||||
if (event.getData().getInt(ApkDownloader.EVENT_DATA_ERROR_TYPE) == ApkDownloader.ERROR_HASH_MISMATCH)
|
if (event.getData().getInt(ApkDownloader.EVENT_DATA_ERROR_TYPE) == ApkDownloader.ERROR_HASH_MISMATCH)
|
||||||
res = R.string.corrupt_download;
|
res = R.string.corrupt_download;
|
||||||
else
|
else
|
||||||
res = R.string.details_notinstalled;
|
res = R.string.details_notinstalled;
|
||||||
// this must be on the main UI thread
|
// this must be on the main UI thread
|
||||||
Toast.makeText(this, res, Toast.LENGTH_LONG).show();
|
Toast.makeText(this, res, Toast.LENGTH_LONG).show();
|
||||||
cleanUpFinishedDownload();
|
cleanUpFinishedDownload();
|
||||||
finished = true;
|
finished = true;
|
||||||
break;
|
break;
|
||||||
case ApkDownloader.EVENT_APK_DOWNLOAD_COMPLETE:
|
case ApkDownloader.EVENT_APK_DOWNLOAD_COMPLETE:
|
||||||
downloadCompleteInstallApk();
|
downloadCompleteInstallApk();
|
||||||
finished = true;
|
finished = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (finished) {
|
if (finished) {
|
||||||
@ -1032,9 +1032,9 @@ public class AppDetails extends AppCompatActivity implements ProgressListener, A
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch (requestCode) {
|
switch (requestCode) {
|
||||||
case REQUEST_ENABLE_BLUETOOTH:
|
case REQUEST_ENABLE_BLUETOOTH:
|
||||||
fdroidApp.sendViaBluetooth(this, resultCode, app.id);
|
fdroidApp.sendViaBluetooth(this, resultCode, app.id);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1381,18 +1381,18 @@ public class AppDetails extends AppCompatActivity implements ProgressListener, A
|
|||||||
|
|
||||||
private String descAntiFeature(String af) {
|
private String descAntiFeature(String af) {
|
||||||
switch (af) {
|
switch (af) {
|
||||||
case "Ads":
|
case "Ads":
|
||||||
return getString(R.string.antiadslist);
|
return getString(R.string.antiadslist);
|
||||||
case "Tracking":
|
case "Tracking":
|
||||||
return getString(R.string.antitracklist);
|
return getString(R.string.antitracklist);
|
||||||
case "NonFreeNet":
|
case "NonFreeNet":
|
||||||
return getString(R.string.antinonfreenetlist);
|
return getString(R.string.antinonfreenetlist);
|
||||||
case "NonFreeAdd":
|
case "NonFreeAdd":
|
||||||
return getString(R.string.antinonfreeadlist);
|
return getString(R.string.antinonfreeadlist);
|
||||||
case "NonFreeDep":
|
case "NonFreeDep":
|
||||||
return getString(R.string.antinonfreedeplist);
|
return getString(R.string.antinonfreedeplist);
|
||||||
case "UpstreamNonFree":
|
case "UpstreamNonFree":
|
||||||
return getString(R.string.antiupstreamnonfreelist);
|
return getString(R.string.antiupstreamnonfreelist);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -130,43 +130,43 @@ public class FDroid extends ActionBarActivity {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
switch (host) {
|
switch (host) {
|
||||||
case "f-droid.org":
|
case "f-droid.org":
|
||||||
// http://f-droid.org/app/app.id
|
// http://f-droid.org/app/app.id
|
||||||
if (path.startsWith("/repository/browse")) {
|
if (path.startsWith("/repository/browse")) {
|
||||||
// http://f-droid.org/repository/browse?fdid=app.id
|
// http://f-droid.org/repository/browse?fdid=app.id
|
||||||
appId = data.getQueryParameter("fdid");
|
appId = data.getQueryParameter("fdid");
|
||||||
} else if (path.startsWith("/app")) {
|
} else if (path.startsWith("/app")) {
|
||||||
appId = data.getLastPathSegment();
|
appId = data.getLastPathSegment();
|
||||||
if (appId != null && appId.equals("app")) {
|
if (appId != null && appId.equals("app")) {
|
||||||
appId = null;
|
appId = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
break;
|
case "details":
|
||||||
case "details":
|
// market://details?id=app.id
|
||||||
// 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
|
|
||||||
appId = data.getQueryParameter("id");
|
appId = data.getQueryParameter("id");
|
||||||
} else if (path.startsWith("/store/search")) {
|
break;
|
||||||
// http://play.google.com/store/search?q=foo
|
case "search":
|
||||||
|
// market://search?q=query
|
||||||
query = data.getQueryParameter("q");
|
query = data.getQueryParameter("q");
|
||||||
}
|
break;
|
||||||
break;
|
case "play.google.com":
|
||||||
case "apps":
|
if (path.startsWith("/store/apps/details")) {
|
||||||
case "amazon.com":
|
// http://play.google.com/store/apps/details?id=app.id
|
||||||
case "www.amazon.com":
|
appId = data.getQueryParameter("id");
|
||||||
// amzn://apps/android?p=app.id
|
} else if (path.startsWith("/store/search")) {
|
||||||
// http://amazon.com/gp/mas/dl/android?p=app.id
|
// http://play.google.com/store/search?q=foo
|
||||||
appId = data.getQueryParameter("p");
|
query = data.getQueryParameter("q");
|
||||||
query = data.getQueryParameter("s");
|
}
|
||||||
break;
|
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")) {
|
} else if (scheme.equals("fdroid.app")) {
|
||||||
// fdroid.app:app.id
|
// fdroid.app:app.id
|
||||||
@ -247,57 +247,57 @@ public class FDroid extends ActionBarActivity {
|
|||||||
|
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
|
|
||||||
case R.id.action_update_repo:
|
case R.id.action_update_repo:
|
||||||
UpdateService.updateNow(this);
|
UpdateService.updateNow(this);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case R.id.action_manage_repos:
|
case R.id.action_manage_repos:
|
||||||
startActivity(new Intent(this, ManageReposActivity.class));
|
startActivity(new Intent(this, ManageReposActivity.class));
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case R.id.action_settings:
|
case R.id.action_settings:
|
||||||
Intent prefs = new Intent(getBaseContext(), PreferencesActivity.class);
|
Intent prefs = new Intent(getBaseContext(), PreferencesActivity.class);
|
||||||
startActivityForResult(prefs, REQUEST_PREFS);
|
startActivityForResult(prefs, REQUEST_PREFS);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case R.id.action_swap:
|
case R.id.action_swap:
|
||||||
startActivity(new Intent(this, SwapWorkflowActivity.class));
|
startActivity(new Intent(this, SwapWorkflowActivity.class));
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case R.id.action_search:
|
case R.id.action_search:
|
||||||
onSearchRequested();
|
onSearchRequested();
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case R.id.action_bluetooth_apk:
|
case R.id.action_bluetooth_apk:
|
||||||
/*
|
/*
|
||||||
* If Bluetooth has not been enabled/turned on, then enabling
|
* If Bluetooth has not been enabled/turned on, then enabling
|
||||||
* device discoverability will automatically enable Bluetooth
|
* device discoverability will automatically enable Bluetooth
|
||||||
*/
|
*/
|
||||||
Intent discoverBt = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
|
Intent discoverBt = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
|
||||||
discoverBt.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 121);
|
discoverBt.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 121);
|
||||||
startActivityForResult(discoverBt, REQUEST_ENABLE_BLUETOOTH);
|
startActivityForResult(discoverBt, REQUEST_ENABLE_BLUETOOTH);
|
||||||
// if this is successful, the Bluetooth transfer is started
|
// if this is successful, the Bluetooth transfer is started
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case R.id.action_about:
|
case R.id.action_about:
|
||||||
View view = LayoutInflater.from(this).inflate(R.layout.about, null);
|
View view = LayoutInflater.from(this).inflate(R.layout.about, null);
|
||||||
|
|
||||||
String versionName = Utils.getVersionName(this);
|
String versionName = Utils.getVersionName(this);
|
||||||
if (versionName == null) {
|
if (versionName == null) {
|
||||||
versionName = getString(R.string.unknown);
|
versionName = getString(R.string.unknown);
|
||||||
}
|
}
|
||||||
((TextView) view.findViewById(R.id.version)).setText(versionName);
|
((TextView) view.findViewById(R.id.version)).setText(versionName);
|
||||||
|
|
||||||
AlertDialog alrt = new AlertDialog.Builder(this).setView(view).create();
|
AlertDialog alrt = new AlertDialog.Builder(this).setView(view).create();
|
||||||
alrt.setTitle(R.string.about_title);
|
alrt.setTitle(R.string.about_title);
|
||||||
alrt.setButton(AlertDialog.BUTTON_NEGATIVE, getString(R.string.ok),
|
alrt.setButton(AlertDialog.BUTTON_NEGATIVE, getString(R.string.ok),
|
||||||
new DialogInterface.OnClickListener() {
|
new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int whichButton) {
|
public void onClick(DialogInterface dialog, int whichButton) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
alrt.show();
|
alrt.show();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
@ -306,25 +306,25 @@ public class FDroid extends ActionBarActivity {
|
|||||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
|
|
||||||
switch (requestCode) {
|
switch (requestCode) {
|
||||||
case REQUEST_PREFS:
|
case REQUEST_PREFS:
|
||||||
// The automatic update settings may have changed, so reschedule (or
|
// The automatic update settings may have changed, so reschedule (or
|
||||||
// unschedule) the service accordingly. It's cheap, so no need to
|
// unschedule) the service accordingly. It's cheap, so no need to
|
||||||
// check if the particular setting has actually been changed.
|
// check if the particular setting has actually been changed.
|
||||||
UpdateService.schedule(getBaseContext());
|
UpdateService.schedule(getBaseContext());
|
||||||
|
|
||||||
if ((resultCode & PreferencesActivity.RESULT_RESTART) != 0) {
|
if ((resultCode & PreferencesActivity.RESULT_RESTART) != 0) {
|
||||||
((FDroidApp) getApplication()).reloadTheme();
|
((FDroidApp) getApplication()).reloadTheme();
|
||||||
final Intent intent = getIntent();
|
final Intent intent = getIntent();
|
||||||
overridePendingTransition(0, 0);
|
overridePendingTransition(0, 0);
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
|
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
|
||||||
finish();
|
finish();
|
||||||
overridePendingTransition(0, 0);
|
overridePendingTransition(0, 0);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case REQUEST_ENABLE_BLUETOOTH:
|
case REQUEST_ENABLE_BLUETOOTH:
|
||||||
fdroidApp.sendViaBluetooth(this, resultCode, "org.fdroid.fdroid");
|
fdroidApp.sendViaBluetooth(this, resultCode, "org.fdroid.fdroid");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ public class FDroidApp extends Application {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void applyTheme(Activity activity) {
|
public void applyTheme(Activity activity) {
|
||||||
activity.setTheme(getCurThemeResId());
|
activity.setTheme(getCurThemeResId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Theme getCurTheme() {
|
public static Theme getCurTheme() {
|
||||||
@ -253,18 +253,18 @@ public class FDroidApp extends Application {
|
|||||||
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext())
|
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext())
|
||||||
.imageDownloader(new IconDownloader(getApplicationContext()))
|
.imageDownloader(new IconDownloader(getApplicationContext()))
|
||||||
.diskCache(new LimitedAgeDiskCache(
|
.diskCache(new LimitedAgeDiskCache(
|
||||||
new File(StorageUtils.getCacheDirectory(getApplicationContext(), true),
|
new File(StorageUtils.getCacheDirectory(getApplicationContext(), true),
|
||||||
"icons"),
|
"icons"),
|
||||||
null,
|
null,
|
||||||
new FileNameGenerator() {
|
new FileNameGenerator() {
|
||||||
@Override
|
@Override
|
||||||
public String generate(String imageUri) {
|
public String generate(String imageUri) {
|
||||||
return imageUri.substring(
|
return imageUri.substring(
|
||||||
imageUri.lastIndexOf('/') + 1);
|
imageUri.lastIndexOf('/') + 1);
|
||||||
} },
|
} },
|
||||||
// 30 days in secs: 30*24*60*60 = 2592000
|
// 30 days in secs: 30*24*60*60 = 2592000
|
||||||
2592000)
|
2592000)
|
||||||
)
|
)
|
||||||
.threadPoolSize(4)
|
.threadPoolSize(4)
|
||||||
.threadPriority(Thread.NORM_PRIORITY - 2) // Default is NORM_PRIORITY - 1
|
.threadPriority(Thread.NORM_PRIORITY - 2) // Default is NORM_PRIORITY - 1
|
||||||
.build();
|
.build();
|
||||||
|
@ -25,36 +25,36 @@ import java.util.List;
|
|||||||
public class FDroidCertPins {
|
public class FDroidCertPins {
|
||||||
public static final String[] DEFAULT_PINS = {
|
public static final String[] DEFAULT_PINS = {
|
||||||
|
|
||||||
// OU=PositiveSSL, CN=f-droid.org
|
// OU=PositiveSSL, CN=f-droid.org
|
||||||
// Fingerprint: 84B91CDF2312CB9BA7F3BE803783302F8D8C299F
|
// Fingerprint: 84B91CDF2312CB9BA7F3BE803783302F8D8C299F
|
||||||
"638F93856E1F5EDFCBD40C46D4160CFF21B0713A",
|
"638F93856E1F5EDFCBD40C46D4160CFF21B0713A",
|
||||||
|
|
||||||
// OU=PositiveSSL, CN=f-droid.org
|
// OU=PositiveSSL, CN=f-droid.org
|
||||||
"83a288fdbf7fb27ca2268d553168eb8f38298910",
|
"83a288fdbf7fb27ca2268d553168eb8f38298910",
|
||||||
|
|
||||||
// OU=Gandi Standard SSL, CN=guardianproject.info
|
// OU=Gandi Standard SSL, CN=guardianproject.info
|
||||||
"cf2f8e226027599a1a933701418c58ec688a8305",
|
"cf2f8e226027599a1a933701418c58ec688a8305",
|
||||||
|
|
||||||
// C=US, ST=Washington, L=Seattle, O=Amazon.com Inc., CN=s3.amazonaws.com
|
// C=US, ST=Washington, L=Seattle, O=Amazon.com Inc., CN=s3.amazonaws.com
|
||||||
"5e77905babb66ca7082979435afbe4edf3f5af12",
|
"5e77905babb66ca7082979435afbe4edf3f5af12",
|
||||||
|
|
||||||
// OU=Domain Control Validated - RapidSSL(R), CN=www.psiphon.ca
|
// OU=Domain Control Validated - RapidSSL(R), CN=www.psiphon.ca
|
||||||
"3aa1726e64d54bf58bf68fe23208928fd0d9cf8a",
|
"3aa1726e64d54bf58bf68fe23208928fd0d9cf8a",
|
||||||
|
|
||||||
// OU=EssentialSSL Wildcard, CN=*.panicbutton.io
|
// OU=EssentialSSL Wildcard, CN=*.panicbutton.io
|
||||||
"cdae8cc70af09a55a7642d13f84241cba1c3a3e6",
|
"cdae8cc70af09a55a7642d13f84241cba1c3a3e6",
|
||||||
|
|
||||||
// C=IL, O=StartCom Ltd., OU=Secure Digital Certificate Signing, CN=StartCom Certification Authority
|
// C=IL, O=StartCom Ltd., OU=Secure Digital Certificate Signing, CN=StartCom Certification Authority
|
||||||
// https://cert.startcom.org/
|
// https://cert.startcom.org/
|
||||||
"234b71255613e130dde34269c9cc30d46f0841e0",
|
"234b71255613e130dde34269c9cc30d46f0841e0",
|
||||||
|
|
||||||
// C=US, O=Internet Security Research Group, CN=ISRG Root X1
|
// C=US, O=Internet Security Research Group, CN=ISRG Root X1
|
||||||
// https://letsencrypt.org
|
// https://letsencrypt.org
|
||||||
"f816513cfd1b449f2e6b28a197221fb81f514e3c",
|
"f816513cfd1b449f2e6b28a197221fb81f514e3c",
|
||||||
|
|
||||||
// C=US, O=IdenTrust, CN=IdenTrust Commercial Root CA 1
|
// C=US, O=IdenTrust, CN=IdenTrust Commercial Root CA 1
|
||||||
// cross-signer for https://letsencrypt.org
|
// cross-signer for https://letsencrypt.org
|
||||||
"87e3bf322427c1405d2736c381e01d1a71d4a039",
|
"87e3bf322427c1405d2736c381e01d1a71d4a039",
|
||||||
};
|
};
|
||||||
|
|
||||||
public static List<String> PINLIST = null;
|
public static List<String> PINLIST = null;
|
||||||
|
@ -256,35 +256,35 @@ public final class Preferences implements SharedPreferences.OnSharedPreferenceCh
|
|||||||
uninitialize(key);
|
uninitialize(key);
|
||||||
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case PREF_COMPACT_LAYOUT:
|
case PREF_COMPACT_LAYOUT:
|
||||||
for (ChangeListener listener : compactLayoutListeners) {
|
for (ChangeListener listener : compactLayoutListeners) {
|
||||||
listener.onPreferenceChange();
|
listener.onPreferenceChange();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PREF_ROOTED:
|
case PREF_ROOTED:
|
||||||
for (ChangeListener listener : filterAppsRequiringRootListeners) {
|
for (ChangeListener listener : filterAppsRequiringRootListeners) {
|
||||||
listener.onPreferenceChange();
|
listener.onPreferenceChange();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PREF_UPD_HISTORY:
|
case PREF_UPD_HISTORY:
|
||||||
for (ChangeListener listener : updateHistoryListeners) {
|
for (ChangeListener listener : updateHistoryListeners) {
|
||||||
listener.onPreferenceChange();
|
listener.onPreferenceChange();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PREF_LOCAL_REPO_NAME:
|
case PREF_LOCAL_REPO_NAME:
|
||||||
for (ChangeListener listener : localRepoNameListeners) {
|
for (ChangeListener listener : localRepoNameListeners) {
|
||||||
listener.onPreferenceChange();
|
listener.onPreferenceChange();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PREF_LOCAL_REPO_HTTPS:
|
case PREF_LOCAL_REPO_HTTPS:
|
||||||
for (ChangeListener listener : localRepoHttpsListeners) {
|
for (ChangeListener listener : localRepoHttpsListeners) {
|
||||||
listener.onPreferenceChange();
|
listener.onPreferenceChange();
|
||||||
}
|
}
|
||||||
case PREF_UNSTABLE_UPDATES:
|
case PREF_UNSTABLE_UPDATES:
|
||||||
for (ChangeListener listener : unstableUpdatesListeners) {
|
for (ChangeListener listener : unstableUpdatesListeners) {
|
||||||
listener.onPreferenceChange();
|
listener.onPreferenceChange();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,9 +64,9 @@ public class PreferencesActivity extends ActionBarActivity {
|
|||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
case android.R.id.home:
|
case android.R.id.home:
|
||||||
NavUtils.navigateUpFromSameTask(this);
|
NavUtils.navigateUpFromSameTask(this);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
|
@ -228,7 +228,7 @@ public class RepoUpdater {
|
|||||||
private ContentValues values;
|
private ContentValues values;
|
||||||
|
|
||||||
public void rememberUpdate() {
|
public void rememberUpdate() {
|
||||||
RepoProvider.Helper.update(context, repo, values);
|
RepoProvider.Helper.update(context, repo, values);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -109,123 +109,123 @@ public class RepoXMLHandler extends DefaultHandler {
|
|||||||
final String str = curchars.toString().trim();
|
final String str = curchars.toString().trim();
|
||||||
if (curapk != null) {
|
if (curapk != null) {
|
||||||
switch (localName) {
|
switch (localName) {
|
||||||
case "version":
|
case "version":
|
||||||
curapk.version = str;
|
curapk.version = str;
|
||||||
break;
|
break;
|
||||||
case "versioncode":
|
case "versioncode":
|
||||||
curapk.vercode = Utils.parseInt(str, -1);
|
curapk.vercode = Utils.parseInt(str, -1);
|
||||||
break;
|
break;
|
||||||
case "size":
|
case "size":
|
||||||
curapk.size = Utils.parseInt(str, 0);
|
curapk.size = Utils.parseInt(str, 0);
|
||||||
break;
|
break;
|
||||||
case "hash":
|
case "hash":
|
||||||
if (hashType == null || hashType.equals("md5")) {
|
if (hashType == null || hashType.equals("md5")) {
|
||||||
if (curapk.hash == null) {
|
if (curapk.hash == null) {
|
||||||
|
curapk.hash = str;
|
||||||
|
curapk.hashType = "MD5";
|
||||||
|
}
|
||||||
|
} else if (hashType.equals("sha256")) {
|
||||||
curapk.hash = str;
|
curapk.hash = str;
|
||||||
curapk.hashType = "MD5";
|
curapk.hashType = "SHA-256";
|
||||||
}
|
}
|
||||||
} else if (hashType.equals("sha256")) {
|
break;
|
||||||
curapk.hash = str;
|
case "sig":
|
||||||
curapk.hashType = "SHA-256";
|
curapk.sig = str;
|
||||||
}
|
break;
|
||||||
break;
|
case "srcname":
|
||||||
case "sig":
|
curapk.srcname = str;
|
||||||
curapk.sig = str;
|
break;
|
||||||
break;
|
case "apkname":
|
||||||
case "srcname":
|
curapk.apkName = str;
|
||||||
curapk.srcname = str;
|
break;
|
||||||
break;
|
case "sdkver":
|
||||||
case "apkname":
|
curapk.minSdkVersion = Utils.parseInt(str, 0);
|
||||||
curapk.apkName = str;
|
break;
|
||||||
break;
|
case "maxsdkver":
|
||||||
case "sdkver":
|
curapk.maxSdkVersion = Utils.parseInt(str, 0);
|
||||||
curapk.minSdkVersion = Utils.parseInt(str, 0);
|
break;
|
||||||
break;
|
case "added":
|
||||||
case "maxsdkver":
|
curapk.added = Utils.parseDate(str, null);
|
||||||
curapk.maxSdkVersion = Utils.parseInt(str, 0);
|
break;
|
||||||
break;
|
case "permissions":
|
||||||
case "added":
|
curapk.permissions = Utils.CommaSeparatedList.make(str);
|
||||||
curapk.added = Utils.parseDate(str, null);
|
break;
|
||||||
break;
|
case "features":
|
||||||
case "permissions":
|
curapk.features = Utils.CommaSeparatedList.make(str);
|
||||||
curapk.permissions = Utils.CommaSeparatedList.make(str);
|
break;
|
||||||
break;
|
case "nativecode":
|
||||||
case "features":
|
curapk.nativecode = Utils.CommaSeparatedList.make(str);
|
||||||
curapk.features = Utils.CommaSeparatedList.make(str);
|
break;
|
||||||
break;
|
|
||||||
case "nativecode":
|
|
||||||
curapk.nativecode = Utils.CommaSeparatedList.make(str);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
} else if (curapp != null) {
|
} else if (curapp != null) {
|
||||||
switch (localName) {
|
switch (localName) {
|
||||||
case "name":
|
case "name":
|
||||||
curapp.name = str;
|
curapp.name = str;
|
||||||
break;
|
break;
|
||||||
case "icon":
|
case "icon":
|
||||||
curapp.icon = str;
|
curapp.icon = str;
|
||||||
break;
|
break;
|
||||||
case "description":
|
case "description":
|
||||||
// This is the old-style description. We'll read it
|
// This is the old-style description. We'll read it
|
||||||
// if present, to support old repos, but in newer
|
// if present, to support old repos, but in newer
|
||||||
// repos it will get overwritten straight away!
|
// repos it will get overwritten straight away!
|
||||||
curapp.description = "<p>" + str + "</p>";
|
curapp.description = "<p>" + str + "</p>";
|
||||||
break;
|
break;
|
||||||
case "desc":
|
case "desc":
|
||||||
// New-style description.
|
// New-style description.
|
||||||
curapp.description = str;
|
curapp.description = str;
|
||||||
break;
|
break;
|
||||||
case "summary":
|
case "summary":
|
||||||
curapp.summary = str;
|
curapp.summary = str;
|
||||||
break;
|
break;
|
||||||
case "license":
|
case "license":
|
||||||
curapp.license = str;
|
curapp.license = str;
|
||||||
break;
|
break;
|
||||||
case "source":
|
case "source":
|
||||||
curapp.sourceURL = str;
|
curapp.sourceURL = str;
|
||||||
break;
|
break;
|
||||||
case "changelog":
|
case "changelog":
|
||||||
curapp.changelogURL = str;
|
curapp.changelogURL = str;
|
||||||
break;
|
break;
|
||||||
case "donate":
|
case "donate":
|
||||||
curapp.donateURL = str;
|
curapp.donateURL = str;
|
||||||
break;
|
break;
|
||||||
case "bitcoin":
|
case "bitcoin":
|
||||||
curapp.bitcoinAddr = str;
|
curapp.bitcoinAddr = str;
|
||||||
break;
|
break;
|
||||||
case "litecoin":
|
case "litecoin":
|
||||||
curapp.litecoinAddr = str;
|
curapp.litecoinAddr = str;
|
||||||
break;
|
break;
|
||||||
case "flattr":
|
case "flattr":
|
||||||
curapp.flattrID = str;
|
curapp.flattrID = str;
|
||||||
break;
|
break;
|
||||||
case "web":
|
case "web":
|
||||||
curapp.webURL = str;
|
curapp.webURL = str;
|
||||||
break;
|
break;
|
||||||
case "tracker":
|
case "tracker":
|
||||||
curapp.trackerURL = str;
|
curapp.trackerURL = str;
|
||||||
break;
|
break;
|
||||||
case "added":
|
case "added":
|
||||||
curapp.added = Utils.parseDate(str, null);
|
curapp.added = Utils.parseDate(str, null);
|
||||||
break;
|
break;
|
||||||
case "lastupdated":
|
case "lastupdated":
|
||||||
curapp.lastUpdated = Utils.parseDate(str, null);
|
curapp.lastUpdated = Utils.parseDate(str, null);
|
||||||
break;
|
break;
|
||||||
case "marketversion":
|
case "marketversion":
|
||||||
curapp.upstreamVersion = str;
|
curapp.upstreamVersion = str;
|
||||||
break;
|
break;
|
||||||
case "marketvercode":
|
case "marketvercode":
|
||||||
curapp.upstreamVercode = Utils.parseInt(str, -1);
|
curapp.upstreamVercode = Utils.parseInt(str, -1);
|
||||||
break;
|
break;
|
||||||
case "categories":
|
case "categories":
|
||||||
curapp.categories = Utils.CommaSeparatedList.make(str);
|
curapp.categories = Utils.CommaSeparatedList.make(str);
|
||||||
break;
|
break;
|
||||||
case "antifeatures":
|
case "antifeatures":
|
||||||
curapp.antiFeatures = Utils.CommaSeparatedList.make(str);
|
curapp.antiFeatures = Utils.CommaSeparatedList.make(str);
|
||||||
break;
|
break;
|
||||||
case "requirements":
|
case "requirements":
|
||||||
curapp.requirements = Utils.CommaSeparatedList.make(str);
|
curapp.requirements = Utils.CommaSeparatedList.make(str);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if (localName.equals("description")) {
|
} else if (localName.equals("description")) {
|
||||||
description = cleanWhiteSpace(str);
|
description = cleanWhiteSpace(str);
|
||||||
|
@ -86,13 +86,13 @@ public class SearchResults extends ActionBarActivity {
|
|||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
|
|
||||||
case android.R.id.home:
|
case android.R.id.home:
|
||||||
NavUtils.navigateUpFromSameTask(this);
|
NavUtils.navigateUpFromSameTask(this);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case SEARCH:
|
case SEARCH:
|
||||||
onSearchRequested();
|
onSearchRequested();
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
|
@ -643,9 +643,9 @@ public class UpdateService extends IntentService implements ProgressListener {
|
|||||||
*/
|
*/
|
||||||
private List<Apk> getKnownApks(List<Apk> apks) {
|
private List<Apk> getKnownApks(List<Apk> apks) {
|
||||||
final String[] fields = {
|
final String[] fields = {
|
||||||
ApkProvider.DataColumns.APK_ID,
|
ApkProvider.DataColumns.APK_ID,
|
||||||
ApkProvider.DataColumns.VERSION,
|
ApkProvider.DataColumns.VERSION,
|
||||||
ApkProvider.DataColumns.VERSION_CODE
|
ApkProvider.DataColumns.VERSION_CODE
|
||||||
};
|
};
|
||||||
return ApkProvider.Helper.knownApks(this, apks, fields);
|
return ApkProvider.Helper.knownApks(this, apks, fields);
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,7 @@ public final class Utils {
|
|||||||
new SimpleDateFormat("yyyy-MM-dd_HH:mm:ss", Locale.ENGLISH);
|
new SimpleDateFormat("yyyy-MM-dd_HH:mm:ss", Locale.ENGLISH);
|
||||||
|
|
||||||
private static final String[] FRIENDLY_SIZE_FORMAT = {
|
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/";
|
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,
|
public void handleTag(boolean opening, String tag, Editable output,
|
||||||
XMLReader reader) {
|
XMLReader reader) {
|
||||||
switch (tag) {
|
switch (tag) {
|
||||||
case "ul":
|
case "ul":
|
||||||
if (opening)
|
if (opening)
|
||||||
listNum = -1;
|
listNum = -1;
|
||||||
else
|
else
|
||||||
output.append('\n');
|
output.append('\n');
|
||||||
break;
|
break;
|
||||||
case "ol":
|
case "ol":
|
||||||
if (opening)
|
if (opening)
|
||||||
listNum = 1;
|
listNum = 1;
|
||||||
else
|
else
|
||||||
output.append('\n');
|
output.append('\n');
|
||||||
break;
|
break;
|
||||||
case "li":
|
case "li":
|
||||||
if (opening) {
|
if (opening) {
|
||||||
if (listNum == -1) {
|
if (listNum == -1) {
|
||||||
output.append("\t• ");
|
output.append("\t• ");
|
||||||
|
} else {
|
||||||
|
output.append("\t").append(Integer.toString(listNum)).append(". ");
|
||||||
|
listNum++;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
output.append("\t").append(Integer.toString(listNum)).append(". ");
|
output.append('\n');
|
||||||
listNum++;
|
|
||||||
}
|
}
|
||||||
} else {
|
break;
|
||||||
output.append('\n');
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -60,66 +60,66 @@ public class Apk extends ValueObject implements Comparable<Apk> {
|
|||||||
|
|
||||||
for (int i = 0; i < cursor.getColumnCount(); i++) {
|
for (int i = 0; i < cursor.getColumnCount(); i++) {
|
||||||
switch (cursor.getColumnName(i)) {
|
switch (cursor.getColumnName(i)) {
|
||||||
case ApkProvider.DataColumns.HASH:
|
case ApkProvider.DataColumns.HASH:
|
||||||
hash = cursor.getString(i);
|
hash = cursor.getString(i);
|
||||||
break;
|
break;
|
||||||
case ApkProvider.DataColumns.HASH_TYPE:
|
case ApkProvider.DataColumns.HASH_TYPE:
|
||||||
hashType = cursor.getString(i);
|
hashType = cursor.getString(i);
|
||||||
break;
|
break;
|
||||||
case ApkProvider.DataColumns.ADDED_DATE:
|
case ApkProvider.DataColumns.ADDED_DATE:
|
||||||
added = Utils.parseDate(cursor.getString(i), null);
|
added = Utils.parseDate(cursor.getString(i), null);
|
||||||
break;
|
break;
|
||||||
case ApkProvider.DataColumns.FEATURES:
|
case ApkProvider.DataColumns.FEATURES:
|
||||||
features = Utils.CommaSeparatedList.make(cursor.getString(i));
|
features = Utils.CommaSeparatedList.make(cursor.getString(i));
|
||||||
break;
|
break;
|
||||||
case ApkProvider.DataColumns.APK_ID:
|
case ApkProvider.DataColumns.APK_ID:
|
||||||
id = cursor.getString(i);
|
id = cursor.getString(i);
|
||||||
break;
|
break;
|
||||||
case ApkProvider.DataColumns.IS_COMPATIBLE:
|
case ApkProvider.DataColumns.IS_COMPATIBLE:
|
||||||
compatible = cursor.getInt(i) == 1;
|
compatible = cursor.getInt(i) == 1;
|
||||||
break;
|
break;
|
||||||
case ApkProvider.DataColumns.MIN_SDK_VERSION:
|
case ApkProvider.DataColumns.MIN_SDK_VERSION:
|
||||||
minSdkVersion = cursor.getInt(i);
|
minSdkVersion = cursor.getInt(i);
|
||||||
break;
|
break;
|
||||||
case ApkProvider.DataColumns.MAX_SDK_VERSION:
|
case ApkProvider.DataColumns.MAX_SDK_VERSION:
|
||||||
maxSdkVersion = cursor.getInt(i);
|
maxSdkVersion = cursor.getInt(i);
|
||||||
break;
|
break;
|
||||||
case ApkProvider.DataColumns.NAME:
|
case ApkProvider.DataColumns.NAME:
|
||||||
apkName = cursor.getString(i);
|
apkName = cursor.getString(i);
|
||||||
break;
|
break;
|
||||||
case ApkProvider.DataColumns.PERMISSIONS:
|
case ApkProvider.DataColumns.PERMISSIONS:
|
||||||
permissions = Utils.CommaSeparatedList.make(cursor.getString(i));
|
permissions = Utils.CommaSeparatedList.make(cursor.getString(i));
|
||||||
break;
|
break;
|
||||||
case ApkProvider.DataColumns.NATIVE_CODE:
|
case ApkProvider.DataColumns.NATIVE_CODE:
|
||||||
nativecode = Utils.CommaSeparatedList.make(cursor.getString(i));
|
nativecode = Utils.CommaSeparatedList.make(cursor.getString(i));
|
||||||
break;
|
break;
|
||||||
case ApkProvider.DataColumns.INCOMPATIBLE_REASONS:
|
case ApkProvider.DataColumns.INCOMPATIBLE_REASONS:
|
||||||
incompatible_reasons = Utils.CommaSeparatedList.make(cursor.getString(i));
|
incompatible_reasons = Utils.CommaSeparatedList.make(cursor.getString(i));
|
||||||
break;
|
break;
|
||||||
case ApkProvider.DataColumns.REPO_ID:
|
case ApkProvider.DataColumns.REPO_ID:
|
||||||
repo = cursor.getInt(i);
|
repo = cursor.getInt(i);
|
||||||
break;
|
break;
|
||||||
case ApkProvider.DataColumns.SIGNATURE:
|
case ApkProvider.DataColumns.SIGNATURE:
|
||||||
sig = cursor.getString(i);
|
sig = cursor.getString(i);
|
||||||
break;
|
break;
|
||||||
case ApkProvider.DataColumns.SIZE:
|
case ApkProvider.DataColumns.SIZE:
|
||||||
size = cursor.getInt(i);
|
size = cursor.getInt(i);
|
||||||
break;
|
break;
|
||||||
case ApkProvider.DataColumns.SOURCE_NAME:
|
case ApkProvider.DataColumns.SOURCE_NAME:
|
||||||
srcname = cursor.getString(i);
|
srcname = cursor.getString(i);
|
||||||
break;
|
break;
|
||||||
case ApkProvider.DataColumns.VERSION:
|
case ApkProvider.DataColumns.VERSION:
|
||||||
version = cursor.getString(i);
|
version = cursor.getString(i);
|
||||||
break;
|
break;
|
||||||
case ApkProvider.DataColumns.VERSION_CODE:
|
case ApkProvider.DataColumns.VERSION_CODE:
|
||||||
vercode = cursor.getInt(i);
|
vercode = cursor.getInt(i);
|
||||||
break;
|
break;
|
||||||
case ApkProvider.DataColumns.REPO_VERSION:
|
case ApkProvider.DataColumns.REPO_VERSION:
|
||||||
repoVersion = cursor.getInt(i);
|
repoVersion = cursor.getInt(i);
|
||||||
break;
|
break;
|
||||||
case ApkProvider.DataColumns.REPO_ADDRESS:
|
case ApkProvider.DataColumns.REPO_ADDRESS:
|
||||||
repoAddress = cursor.getString(i);
|
repoAddress = cursor.getString(i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -389,28 +389,28 @@ public class ApkProvider extends FDroidProvider {
|
|||||||
QuerySelection query = new QuerySelection(selection, selectionArgs);
|
QuerySelection query = new QuerySelection(selection, selectionArgs);
|
||||||
|
|
||||||
switch (matcher.match(uri)) {
|
switch (matcher.match(uri)) {
|
||||||
case CODE_LIST:
|
case CODE_LIST:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CODE_SINGLE:
|
case CODE_SINGLE:
|
||||||
query = query.add(querySingle(uri));
|
query = query.add(querySingle(uri));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CODE_APP:
|
case CODE_APP:
|
||||||
query = query.add(queryApp(uri.getLastPathSegment()));
|
query = query.add(queryApp(uri.getLastPathSegment()));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CODE_APKS:
|
case CODE_APKS:
|
||||||
query = query.add(queryApks(uri.getLastPathSegment()));
|
query = query.add(queryApks(uri.getLastPathSegment()));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CODE_REPO:
|
case CODE_REPO:
|
||||||
query = query.add(queryRepo(Long.parseLong(uri.getLastPathSegment())));
|
query = query.add(queryRepo(Long.parseLong(uri.getLastPathSegment())));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
Log.e(TAG, "Invalid URI for apk content provider: " + uri);
|
Log.e(TAG, "Invalid URI for apk content provider: " + uri);
|
||||||
throw new UnsupportedOperationException("Invalid URI for apk content provider: " + uri);
|
throw new UnsupportedOperationException("Invalid URI for apk content provider: " + uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
Query queryBuilder = new Query();
|
Query queryBuilder = new Query();
|
||||||
@ -458,27 +458,27 @@ public class ApkProvider extends FDroidProvider {
|
|||||||
|
|
||||||
switch (matcher.match(uri)) {
|
switch (matcher.match(uri)) {
|
||||||
|
|
||||||
case CODE_REPO:
|
case CODE_REPO:
|
||||||
query = query.add(queryRepo(Long.parseLong(uri.getLastPathSegment())));
|
query = query.add(queryRepo(Long.parseLong(uri.getLastPathSegment())));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CODE_APP:
|
case CODE_APP:
|
||||||
query = query.add(queryApp(uri.getLastPathSegment()));
|
query = query.add(queryApp(uri.getLastPathSegment()));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CODE_APKS:
|
case CODE_APKS:
|
||||||
query = query.add(queryApks(uri.getLastPathSegment()));
|
query = query.add(queryApks(uri.getLastPathSegment()));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CODE_LIST:
|
case CODE_LIST:
|
||||||
throw new UnsupportedOperationException("Can't delete all apks.");
|
throw new UnsupportedOperationException("Can't delete all apks.");
|
||||||
|
|
||||||
case CODE_SINGLE:
|
case CODE_SINGLE:
|
||||||
throw new UnsupportedOperationException("Can't delete individual apks.");
|
throw new UnsupportedOperationException("Can't delete individual apks.");
|
||||||
|
|
||||||
default:
|
default:
|
||||||
Log.e(TAG, "Invalid URI for apk content provider: " + uri);
|
Log.e(TAG, "Invalid URI for apk content provider: " + uri);
|
||||||
throw new UnsupportedOperationException("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());
|
int rowsAffected = write().delete(getTableName(), query.getSelection(), query.getArgs());
|
||||||
|
@ -119,100 +119,100 @@ public class App extends ValueObject implements Comparable<App> {
|
|||||||
for (int i = 0; i < cursor.getColumnCount(); i++) {
|
for (int i = 0; i < cursor.getColumnCount(); i++) {
|
||||||
String n = cursor.getColumnName(i);
|
String n = cursor.getColumnName(i);
|
||||||
switch (n) {
|
switch (n) {
|
||||||
case AppProvider.DataColumns.IS_COMPATIBLE:
|
case AppProvider.DataColumns.IS_COMPATIBLE:
|
||||||
compatible = cursor.getInt(i) == 1;
|
compatible = cursor.getInt(i) == 1;
|
||||||
break;
|
break;
|
||||||
case AppProvider.DataColumns.APP_ID:
|
case AppProvider.DataColumns.APP_ID:
|
||||||
id = cursor.getString(i);
|
id = cursor.getString(i);
|
||||||
break;
|
break;
|
||||||
case AppProvider.DataColumns.NAME:
|
case AppProvider.DataColumns.NAME:
|
||||||
name = cursor.getString(i);
|
name = cursor.getString(i);
|
||||||
break;
|
break;
|
||||||
case AppProvider.DataColumns.SUMMARY:
|
case AppProvider.DataColumns.SUMMARY:
|
||||||
summary = cursor.getString(i);
|
summary = cursor.getString(i);
|
||||||
break;
|
break;
|
||||||
case AppProvider.DataColumns.ICON:
|
case AppProvider.DataColumns.ICON:
|
||||||
icon = cursor.getString(i);
|
icon = cursor.getString(i);
|
||||||
break;
|
break;
|
||||||
case AppProvider.DataColumns.DESCRIPTION:
|
case AppProvider.DataColumns.DESCRIPTION:
|
||||||
description = cursor.getString(i);
|
description = cursor.getString(i);
|
||||||
break;
|
break;
|
||||||
case AppProvider.DataColumns.LICENSE:
|
case AppProvider.DataColumns.LICENSE:
|
||||||
license = cursor.getString(i);
|
license = cursor.getString(i);
|
||||||
break;
|
break;
|
||||||
case AppProvider.DataColumns.WEB_URL:
|
case AppProvider.DataColumns.WEB_URL:
|
||||||
webURL = cursor.getString(i);
|
webURL = cursor.getString(i);
|
||||||
break;
|
break;
|
||||||
case AppProvider.DataColumns.TRACKER_URL:
|
case AppProvider.DataColumns.TRACKER_URL:
|
||||||
trackerURL = cursor.getString(i);
|
trackerURL = cursor.getString(i);
|
||||||
break;
|
break;
|
||||||
case AppProvider.DataColumns.SOURCE_URL:
|
case AppProvider.DataColumns.SOURCE_URL:
|
||||||
sourceURL = cursor.getString(i);
|
sourceURL = cursor.getString(i);
|
||||||
break;
|
break;
|
||||||
case AppProvider.DataColumns.CHANGELOG_URL:
|
case AppProvider.DataColumns.CHANGELOG_URL:
|
||||||
changelogURL = cursor.getString(i);
|
changelogURL = cursor.getString(i);
|
||||||
break;
|
break;
|
||||||
case AppProvider.DataColumns.DONATE_URL:
|
case AppProvider.DataColumns.DONATE_URL:
|
||||||
donateURL = cursor.getString(i);
|
donateURL = cursor.getString(i);
|
||||||
break;
|
break;
|
||||||
case AppProvider.DataColumns.BITCOIN_ADDR:
|
case AppProvider.DataColumns.BITCOIN_ADDR:
|
||||||
bitcoinAddr = cursor.getString(i);
|
bitcoinAddr = cursor.getString(i);
|
||||||
break;
|
break;
|
||||||
case AppProvider.DataColumns.LITECOIN_ADDR:
|
case AppProvider.DataColumns.LITECOIN_ADDR:
|
||||||
litecoinAddr = cursor.getString(i);
|
litecoinAddr = cursor.getString(i);
|
||||||
break;
|
break;
|
||||||
case AppProvider.DataColumns.FLATTR_ID:
|
case AppProvider.DataColumns.FLATTR_ID:
|
||||||
flattrID = cursor.getString(i);
|
flattrID = cursor.getString(i);
|
||||||
break;
|
break;
|
||||||
case AppProvider.DataColumns.SuggestedApk.VERSION:
|
case AppProvider.DataColumns.SuggestedApk.VERSION:
|
||||||
suggestedVersion = cursor.getString(i);
|
suggestedVersion = cursor.getString(i);
|
||||||
break;
|
break;
|
||||||
case AppProvider.DataColumns.SUGGESTED_VERSION_CODE:
|
case AppProvider.DataColumns.SUGGESTED_VERSION_CODE:
|
||||||
suggestedVercode = cursor.getInt(i);
|
suggestedVercode = cursor.getInt(i);
|
||||||
break;
|
break;
|
||||||
case AppProvider.DataColumns.UPSTREAM_VERSION_CODE:
|
case AppProvider.DataColumns.UPSTREAM_VERSION_CODE:
|
||||||
upstreamVercode = cursor.getInt(i);
|
upstreamVercode = cursor.getInt(i);
|
||||||
break;
|
break;
|
||||||
case AppProvider.DataColumns.UPSTREAM_VERSION:
|
case AppProvider.DataColumns.UPSTREAM_VERSION:
|
||||||
upstreamVersion = cursor.getString(i);
|
upstreamVersion = cursor.getString(i);
|
||||||
break;
|
break;
|
||||||
case AppProvider.DataColumns.ADDED:
|
case AppProvider.DataColumns.ADDED:
|
||||||
added = Utils.parseDate(cursor.getString(i), null);
|
added = Utils.parseDate(cursor.getString(i), null);
|
||||||
break;
|
break;
|
||||||
case AppProvider.DataColumns.LAST_UPDATED:
|
case AppProvider.DataColumns.LAST_UPDATED:
|
||||||
lastUpdated = Utils.parseDate(cursor.getString(i), null);
|
lastUpdated = Utils.parseDate(cursor.getString(i), null);
|
||||||
break;
|
break;
|
||||||
case AppProvider.DataColumns.CATEGORIES:
|
case AppProvider.DataColumns.CATEGORIES:
|
||||||
categories = Utils.CommaSeparatedList.make(cursor.getString(i));
|
categories = Utils.CommaSeparatedList.make(cursor.getString(i));
|
||||||
break;
|
break;
|
||||||
case AppProvider.DataColumns.ANTI_FEATURES:
|
case AppProvider.DataColumns.ANTI_FEATURES:
|
||||||
antiFeatures = Utils.CommaSeparatedList.make(cursor.getString(i));
|
antiFeatures = Utils.CommaSeparatedList.make(cursor.getString(i));
|
||||||
break;
|
break;
|
||||||
case AppProvider.DataColumns.REQUIREMENTS:
|
case AppProvider.DataColumns.REQUIREMENTS:
|
||||||
requirements = Utils.CommaSeparatedList.make(cursor.getString(i));
|
requirements = Utils.CommaSeparatedList.make(cursor.getString(i));
|
||||||
break;
|
break;
|
||||||
case AppProvider.DataColumns.IGNORE_ALLUPDATES:
|
case AppProvider.DataColumns.IGNORE_ALLUPDATES:
|
||||||
ignoreAllUpdates = cursor.getInt(i) == 1;
|
ignoreAllUpdates = cursor.getInt(i) == 1;
|
||||||
break;
|
break;
|
||||||
case AppProvider.DataColumns.IGNORE_THISUPDATE:
|
case AppProvider.DataColumns.IGNORE_THISUPDATE:
|
||||||
ignoreThisUpdate = cursor.getInt(i);
|
ignoreThisUpdate = cursor.getInt(i);
|
||||||
break;
|
break;
|
||||||
case AppProvider.DataColumns.ICON_URL:
|
case AppProvider.DataColumns.ICON_URL:
|
||||||
iconUrl = cursor.getString(i);
|
iconUrl = cursor.getString(i);
|
||||||
break;
|
break;
|
||||||
case AppProvider.DataColumns.ICON_URL_LARGE:
|
case AppProvider.DataColumns.ICON_URL_LARGE:
|
||||||
iconUrlLarge = cursor.getString(i);
|
iconUrlLarge = cursor.getString(i);
|
||||||
break;
|
break;
|
||||||
case AppProvider.DataColumns.InstalledApp.VERSION_CODE:
|
case AppProvider.DataColumns.InstalledApp.VERSION_CODE:
|
||||||
installedVersionCode = cursor.getInt(i);
|
installedVersionCode = cursor.getInt(i);
|
||||||
break;
|
break;
|
||||||
case AppProvider.DataColumns.InstalledApp.VERSION_NAME:
|
case AppProvider.DataColumns.InstalledApp.VERSION_NAME:
|
||||||
installedVersionName = cursor.getString(i);
|
installedVersionName = cursor.getString(i);
|
||||||
break;
|
break;
|
||||||
case "_id":
|
case "_id":
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Log.e(TAG, "Unknown column name " + n);
|
Log.e(TAG, "Unknown column name " + n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -212,14 +212,14 @@ public class AppProvider extends FDroidProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String[] ALL = {
|
String[] ALL = {
|
||||||
_ID, IS_COMPATIBLE, APP_ID, NAME, SUMMARY, ICON, DESCRIPTION,
|
_ID, IS_COMPATIBLE, APP_ID, NAME, SUMMARY, ICON, DESCRIPTION,
|
||||||
LICENSE, WEB_URL, TRACKER_URL, SOURCE_URL, CHANGELOG_URL, DONATE_URL,
|
LICENSE, WEB_URL, TRACKER_URL, SOURCE_URL, CHANGELOG_URL, DONATE_URL,
|
||||||
BITCOIN_ADDR, LITECOIN_ADDR, FLATTR_ID,
|
BITCOIN_ADDR, LITECOIN_ADDR, FLATTR_ID,
|
||||||
UPSTREAM_VERSION, UPSTREAM_VERSION_CODE, ADDED, LAST_UPDATED,
|
UPSTREAM_VERSION, UPSTREAM_VERSION_CODE, ADDED, LAST_UPDATED,
|
||||||
CATEGORIES, ANTI_FEATURES, REQUIREMENTS, IGNORE_ALLUPDATES,
|
CATEGORIES, ANTI_FEATURES, REQUIREMENTS, IGNORE_ALLUPDATES,
|
||||||
IGNORE_THISUPDATE, ICON_URL, ICON_URL_LARGE,
|
IGNORE_THISUPDATE, ICON_URL, ICON_URL_LARGE,
|
||||||
SUGGESTED_VERSION_CODE, SuggestedApk.VERSION,
|
SUGGESTED_VERSION_CODE, SuggestedApk.VERSION,
|
||||||
InstalledApp.VERSION_CODE, InstalledApp.VERSION_NAME
|
InstalledApp.VERSION_CODE, InstalledApp.VERSION_NAME
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -345,24 +345,24 @@ public class AppProvider extends FDroidProvider {
|
|||||||
@Override
|
@Override
|
||||||
public void addField(String field) {
|
public void addField(String field) {
|
||||||
switch (field) {
|
switch (field) {
|
||||||
case DataColumns.SuggestedApk.VERSION:
|
case DataColumns.SuggestedApk.VERSION:
|
||||||
addSuggestedApkVersionField();
|
addSuggestedApkVersionField();
|
||||||
break;
|
break;
|
||||||
case DataColumns.InstalledApp.VERSION_NAME:
|
case DataColumns.InstalledApp.VERSION_NAME:
|
||||||
addInstalledAppVersionName();
|
addInstalledAppVersionName();
|
||||||
break;
|
break;
|
||||||
case DataColumns.InstalledApp.VERSION_CODE:
|
case DataColumns.InstalledApp.VERSION_CODE:
|
||||||
addInstalledAppVersionCode();
|
addInstalledAppVersionCode();
|
||||||
break;
|
break;
|
||||||
case DataColumns._COUNT:
|
case DataColumns._COUNT:
|
||||||
appendCountField();
|
appendCountField();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (field.equals(DataColumns.CATEGORIES)) {
|
if (field.equals(DataColumns.CATEGORIES)) {
|
||||||
categoryFieldAdded = true;
|
categoryFieldAdded = true;
|
||||||
}
|
}
|
||||||
appendField(field, "fdroid_app");
|
appendField(field, "fdroid_app");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -655,10 +655,10 @@ public class AppProvider extends FDroidProvider {
|
|||||||
" fdroid_app.categories LIKE ? OR " + // Last category e.g. "%,internet"
|
" fdroid_app.categories LIKE ? OR " + // Last category e.g. "%,internet"
|
||||||
" fdroid_app.categories LIKE ? "; // One of many categories e.g. "%,internet,%"
|
" fdroid_app.categories LIKE ? "; // One of many categories e.g. "%,internet,%"
|
||||||
final String[] args = {
|
final String[] args = {
|
||||||
category,
|
category,
|
||||||
category + ",%",
|
category + ",%",
|
||||||
"%," + category,
|
"%," + category,
|
||||||
"%," + category + ",%",
|
"%," + category + ",%",
|
||||||
};
|
};
|
||||||
return new AppQuerySelection(selection, args);
|
return new AppQuerySelection(selection, args);
|
||||||
}
|
}
|
||||||
@ -682,70 +682,70 @@ public class AppProvider extends FDroidProvider {
|
|||||||
boolean includeSwap = true;
|
boolean includeSwap = true;
|
||||||
|
|
||||||
switch (matcher.match(uri)) {
|
switch (matcher.match(uri)) {
|
||||||
case CODE_LIST:
|
case CODE_LIST:
|
||||||
includeSwap = false;
|
includeSwap = false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CODE_SINGLE:
|
case CODE_SINGLE:
|
||||||
selection = selection.add(querySingle(uri.getLastPathSegment()));
|
selection = selection.add(querySingle(uri.getLastPathSegment()));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CAN_UPDATE:
|
case CAN_UPDATE:
|
||||||
selection = selection.add(queryCanUpdate());
|
selection = selection.add(queryCanUpdate());
|
||||||
includeSwap = false;
|
includeSwap = false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case REPO:
|
case REPO:
|
||||||
selection = selection.add(queryRepo(Long.parseLong(uri.getLastPathSegment())));
|
selection = selection.add(queryRepo(Long.parseLong(uri.getLastPathSegment())));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case INSTALLED:
|
case INSTALLED:
|
||||||
selection = selection.add(queryInstalled());
|
selection = selection.add(queryInstalled());
|
||||||
includeSwap = false;
|
includeSwap = false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SEARCH:
|
case SEARCH:
|
||||||
selection = selection.add(querySearch(uri.getLastPathSegment()));
|
selection = selection.add(querySearch(uri.getLastPathSegment()));
|
||||||
includeSwap = false;
|
includeSwap = false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SEARCH_REPO:
|
case SEARCH_REPO:
|
||||||
selection = selection.add(querySearch(uri.getPathSegments().get(2)));
|
selection = selection.add(querySearch(uri.getPathSegments().get(2)));
|
||||||
selection = selection.add(queryRepo(Long.parseLong(uri.getPathSegments().get(1))));
|
selection = selection.add(queryRepo(Long.parseLong(uri.getPathSegments().get(1))));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NO_APKS:
|
case NO_APKS:
|
||||||
selection = selection.add(queryNoApks());
|
selection = selection.add(queryNoApks());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case APPS:
|
case APPS:
|
||||||
selection = selection.add(queryApps(uri.getLastPathSegment()));
|
selection = selection.add(queryApps(uri.getLastPathSegment()));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IGNORED:
|
case IGNORED:
|
||||||
selection = selection.add(queryIgnored());
|
selection = selection.add(queryIgnored());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CATEGORY:
|
case CATEGORY:
|
||||||
selection = selection.add(queryCategory(uri.getLastPathSegment()));
|
selection = selection.add(queryCategory(uri.getLastPathSegment()));
|
||||||
includeSwap = false;
|
includeSwap = false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RECENTLY_UPDATED:
|
case RECENTLY_UPDATED:
|
||||||
sortOrder = " fdroid_app.lastUpdated DESC";
|
sortOrder = " fdroid_app.lastUpdated DESC";
|
||||||
selection = selection.add(queryRecentlyUpdated());
|
selection = selection.add(queryRecentlyUpdated());
|
||||||
includeSwap = false;
|
includeSwap = false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NEWLY_ADDED:
|
case NEWLY_ADDED:
|
||||||
sortOrder = " fdroid_app.added DESC";
|
sortOrder = " fdroid_app.added DESC";
|
||||||
selection = selection.add(queryNewlyAdded());
|
selection = selection.add(queryNewlyAdded());
|
||||||
includeSwap = false;
|
includeSwap = false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
Log.e(TAG, "Invalid URI for app content provider: " + uri);
|
Log.e(TAG, "Invalid URI for app content provider: " + uri);
|
||||||
throw new UnsupportedOperationException("Invalid URI for app content provider: " + uri);
|
throw new UnsupportedOperationException("Invalid URI for app content provider: " + uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!includeSwap) {
|
if (!includeSwap) {
|
||||||
@ -773,12 +773,12 @@ public class AppProvider extends FDroidProvider {
|
|||||||
QuerySelection query = new QuerySelection(where, whereArgs);
|
QuerySelection query = new QuerySelection(where, whereArgs);
|
||||||
switch (matcher.match(uri)) {
|
switch (matcher.match(uri)) {
|
||||||
|
|
||||||
case NO_APKS:
|
case NO_APKS:
|
||||||
query = query.add(queryNoApks());
|
query = query.add(queryNoApks());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new UnsupportedOperationException("Delete not supported for " + uri + ".");
|
throw new UnsupportedOperationException("Delete not supported for " + uri + ".");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -801,16 +801,16 @@ public class AppProvider extends FDroidProvider {
|
|||||||
QuerySelection query = new QuerySelection(where, whereArgs);
|
QuerySelection query = new QuerySelection(where, whereArgs);
|
||||||
switch (matcher.match(uri)) {
|
switch (matcher.match(uri)) {
|
||||||
|
|
||||||
case CALC_APP_DETAILS_FROM_INDEX:
|
case CALC_APP_DETAILS_FROM_INDEX:
|
||||||
updateAppDetails();
|
updateAppDetails();
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
case CODE_SINGLE:
|
case CODE_SINGLE:
|
||||||
query = query.add(querySingle(uri.getLastPathSegment()));
|
query = query.add(querySingle(uri.getLastPathSegment()));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new UnsupportedOperationException("Update not supported for " + uri + ".");
|
throw new UnsupportedOperationException("Update not supported for " + uri + ".");
|
||||||
|
|
||||||
}
|
}
|
||||||
int count = write().update(getTableName(), values, query.getSelection(), query.getArgs());
|
int count = write().update(getTableName(), values, query.getSelection(), query.getArgs());
|
||||||
|
@ -86,13 +86,13 @@ public abstract class FDroidProvider extends ContentProvider {
|
|||||||
public String getType(Uri uri) {
|
public String getType(Uri uri) {
|
||||||
String type;
|
String type;
|
||||||
switch (getMatcher().match(uri)) {
|
switch (getMatcher().match(uri)) {
|
||||||
case CODE_LIST:
|
case CODE_LIST:
|
||||||
type = "dir";
|
type = "dir";
|
||||||
break;
|
break;
|
||||||
case CODE_SINGLE:
|
case CODE_SINGLE:
|
||||||
default:
|
default:
|
||||||
type = "item";
|
type = "item";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return "vnd.android.cursor." + type + "/vnd." + AUTHORITY + "." + getProviderName();
|
return "vnd.android.cursor." + type + "/vnd." + AUTHORITY + "." + getProviderName();
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ public class InstalledAppProvider extends FDroidProvider {
|
|||||||
String APPLICATION_LABEL = "applicationLabel";
|
String APPLICATION_LABEL = "applicationLabel";
|
||||||
|
|
||||||
String[] ALL = {
|
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);
|
QuerySelection selection = new QuerySelection(customSelection, selectionArgs);
|
||||||
switch (matcher.match(uri)) {
|
switch (matcher.match(uri)) {
|
||||||
case CODE_LIST:
|
case CODE_LIST:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CODE_SINGLE:
|
case CODE_SINGLE:
|
||||||
selection = selection.add(queryApp(uri.getLastPathSegment()));
|
selection = selection.add(queryApp(uri.getLastPathSegment()));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CODE_SEARCH:
|
case CODE_SEARCH:
|
||||||
selection = selection.add(querySearch(uri.getLastPathSegment()));
|
selection = selection.add(querySearch(uri.getLastPathSegment()));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
String message = "Invalid URI for installed app content provider: " + uri;
|
String message = "Invalid URI for installed app content provider: " + uri;
|
||||||
Log.e(TAG, message);
|
Log.e(TAG, message);
|
||||||
throw new UnsupportedOperationException(message);
|
throw new UnsupportedOperationException(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
Cursor cursor = read().query(getTableName(), projection, selection.getSelection(), selection.getArgs(), null, null, sortOrder);
|
Cursor cursor = read().query(getTableName(), projection, selection.getSelection(), selection.getArgs(), null, null, sortOrder);
|
||||||
|
@ -46,45 +46,45 @@ public class Repo extends ValueObject {
|
|||||||
|
|
||||||
for (int i = 0; i < cursor.getColumnCount(); i++) {
|
for (int i = 0; i < cursor.getColumnCount(); i++) {
|
||||||
switch (cursor.getColumnName(i)) {
|
switch (cursor.getColumnName(i)) {
|
||||||
case RepoProvider.DataColumns._ID:
|
case RepoProvider.DataColumns._ID:
|
||||||
id = cursor.getInt(i);
|
id = cursor.getInt(i);
|
||||||
break;
|
break;
|
||||||
case RepoProvider.DataColumns.LAST_ETAG:
|
case RepoProvider.DataColumns.LAST_ETAG:
|
||||||
lastetag = cursor.getString(i);
|
lastetag = cursor.getString(i);
|
||||||
break;
|
break;
|
||||||
case RepoProvider.DataColumns.ADDRESS:
|
case RepoProvider.DataColumns.ADDRESS:
|
||||||
address = cursor.getString(i);
|
address = cursor.getString(i);
|
||||||
break;
|
break;
|
||||||
case RepoProvider.DataColumns.DESCRIPTION:
|
case RepoProvider.DataColumns.DESCRIPTION:
|
||||||
description = cursor.getString(i);
|
description = cursor.getString(i);
|
||||||
break;
|
break;
|
||||||
case RepoProvider.DataColumns.FINGERPRINT:
|
case RepoProvider.DataColumns.FINGERPRINT:
|
||||||
fingerprint = cursor.getString(i);
|
fingerprint = cursor.getString(i);
|
||||||
break;
|
break;
|
||||||
case RepoProvider.DataColumns.IN_USE:
|
case RepoProvider.DataColumns.IN_USE:
|
||||||
inuse = cursor.getInt(i) == 1;
|
inuse = cursor.getInt(i) == 1;
|
||||||
break;
|
break;
|
||||||
case RepoProvider.DataColumns.LAST_UPDATED:
|
case RepoProvider.DataColumns.LAST_UPDATED:
|
||||||
lastUpdated = Utils.parseTime(cursor.getString(i), null);
|
lastUpdated = Utils.parseTime(cursor.getString(i), null);
|
||||||
break;
|
break;
|
||||||
case RepoProvider.DataColumns.MAX_AGE:
|
case RepoProvider.DataColumns.MAX_AGE:
|
||||||
maxage = cursor.getInt(i);
|
maxage = cursor.getInt(i);
|
||||||
break;
|
break;
|
||||||
case RepoProvider.DataColumns.VERSION:
|
case RepoProvider.DataColumns.VERSION:
|
||||||
version = cursor.getInt(i);
|
version = cursor.getInt(i);
|
||||||
break;
|
break;
|
||||||
case RepoProvider.DataColumns.NAME:
|
case RepoProvider.DataColumns.NAME:
|
||||||
name = cursor.getString(i);
|
name = cursor.getString(i);
|
||||||
break;
|
break;
|
||||||
case RepoProvider.DataColumns.PUBLIC_KEY:
|
case RepoProvider.DataColumns.PUBLIC_KEY:
|
||||||
pubkey = cursor.getString(i);
|
pubkey = cursor.getString(i);
|
||||||
break;
|
break;
|
||||||
case RepoProvider.DataColumns.PRIORITY:
|
case RepoProvider.DataColumns.PRIORITY:
|
||||||
priority = cursor.getInt(i);
|
priority = cursor.getInt(i);
|
||||||
break;
|
break;
|
||||||
case RepoProvider.DataColumns.IS_SWAP:
|
case RepoProvider.DataColumns.IS_SWAP:
|
||||||
isSwap = cursor.getInt(i) == 1;
|
isSwap = cursor.getInt(i) == 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -281,22 +281,22 @@ public class RepoProvider extends FDroidProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch (matcher.match(uri)) {
|
switch (matcher.match(uri)) {
|
||||||
case CODE_LIST:
|
case CODE_LIST:
|
||||||
// Do nothing (don't restrict query)
|
// Do nothing (don't restrict query)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CODE_SINGLE:
|
case CODE_SINGLE:
|
||||||
selection = (selection == null ? "" : selection + " AND ") +
|
selection = (selection == null ? "" : selection + " AND ") +
|
||||||
DataColumns._ID + " = " + uri.getLastPathSegment();
|
DataColumns._ID + " = " + uri.getLastPathSegment();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CODE_ALL_EXCEPT_SWAP:
|
case CODE_ALL_EXCEPT_SWAP:
|
||||||
selection = DataColumns.IS_SWAP + " = 0 OR " + DataColumns.IS_SWAP + " IS NULL ";
|
selection = DataColumns.IS_SWAP + " = 0 OR " + DataColumns.IS_SWAP + " IS NULL ";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
Log.e(TAG, "Invalid URI for repo content provider: " + uri);
|
Log.e(TAG, "Invalid URI for repo content provider: " + uri);
|
||||||
throw new UnsupportedOperationException("Invalid URI for repo content provider: " + uri);
|
throw new UnsupportedOperationException("Invalid URI for repo content provider: " + uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
Cursor cursor = read().query(getTableName(), projection, selection,
|
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) {
|
public int delete(Uri uri, String where, String[] whereArgs) {
|
||||||
|
|
||||||
switch (matcher.match(uri)) {
|
switch (matcher.match(uri)) {
|
||||||
case CODE_LIST:
|
case CODE_LIST:
|
||||||
// Don't support deleting of multiple repos.
|
// Don't support deleting of multiple repos.
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
case CODE_SINGLE:
|
case CODE_SINGLE:
|
||||||
where = (where == null ? "" : where + " AND ") +
|
where = (where == null ? "" : where + " AND ") +
|
||||||
"_ID = " + uri.getLastPathSegment();
|
"_ID = " + uri.getLastPathSegment();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
Log.e(TAG, "Invalid URI for repo content provider: " + uri);
|
Log.e(TAG, "Invalid URI for repo content provider: " + uri);
|
||||||
throw new UnsupportedOperationException("Invalid URI for repo content provider: " + uri);
|
throw new UnsupportedOperationException("Invalid URI for repo content provider: " + uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
int rowsAffected = write().delete(getTableName(), where, whereArgs);
|
int rowsAffected = write().delete(getTableName(), where, whereArgs);
|
||||||
|
@ -91,16 +91,16 @@ public class DefaultInstaller extends Installer {
|
|||||||
* never executed on Androids before 4.0
|
* never executed on Androids before 4.0
|
||||||
*/
|
*/
|
||||||
switch (requestCode) {
|
switch (requestCode) {
|
||||||
case REQUEST_CODE_INSTALL:
|
case REQUEST_CODE_INSTALL:
|
||||||
mCallback.onSuccess(InstallerCallback.OPERATION_INSTALL);
|
mCallback.onSuccess(InstallerCallback.OPERATION_INSTALL);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
case REQUEST_CODE_DELETE:
|
case REQUEST_CODE_DELETE:
|
||||||
mCallback.onSuccess(InstallerCallback.OPERATION_DELETE);
|
mCallback.onSuccess(InstallerCallback.OPERATION_DELETE);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,34 +99,34 @@ public class DefaultSdk14Installer extends Installer {
|
|||||||
@Override
|
@Override
|
||||||
public boolean handleOnActivityResult(int requestCode, int resultCode, Intent data) {
|
public boolean handleOnActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
switch (requestCode) {
|
switch (requestCode) {
|
||||||
case REQUEST_CODE_INSTALL:
|
case REQUEST_CODE_INSTALL:
|
||||||
if (resultCode == Activity.RESULT_OK) {
|
if (resultCode == Activity.RESULT_OK) {
|
||||||
mCallback.onSuccess(InstallerCallback.OPERATION_INSTALL);
|
mCallback.onSuccess(InstallerCallback.OPERATION_INSTALL);
|
||||||
} else if (resultCode == Activity.RESULT_CANCELED) {
|
} else if (resultCode == Activity.RESULT_CANCELED) {
|
||||||
mCallback.onError(InstallerCallback.OPERATION_INSTALL,
|
mCallback.onError(InstallerCallback.OPERATION_INSTALL,
|
||||||
InstallerCallback.ERROR_CODE_CANCELED);
|
InstallerCallback.ERROR_CODE_CANCELED);
|
||||||
} else {
|
} else {
|
||||||
mCallback.onError(InstallerCallback.OPERATION_INSTALL,
|
mCallback.onError(InstallerCallback.OPERATION_INSTALL,
|
||||||
InstallerCallback.ERROR_CODE_OTHER);
|
InstallerCallback.ERROR_CODE_OTHER);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
case REQUEST_CODE_DELETE:
|
case REQUEST_CODE_DELETE:
|
||||||
if (resultCode == Activity.RESULT_OK) {
|
if (resultCode == Activity.RESULT_OK) {
|
||||||
mCallback.onSuccess(InstallerCallback.OPERATION_DELETE);
|
mCallback.onSuccess(InstallerCallback.OPERATION_DELETE);
|
||||||
} else if (resultCode == Activity.RESULT_CANCELED) {
|
} else if (resultCode == Activity.RESULT_CANCELED) {
|
||||||
mCallback.onError(InstallerCallback.OPERATION_DELETE,
|
mCallback.onError(InstallerCallback.OPERATION_DELETE,
|
||||||
InstallerCallback.ERROR_CODE_CANCELED);
|
InstallerCallback.ERROR_CODE_CANCELED);
|
||||||
} else {
|
} else {
|
||||||
// UninstallAppProgress actually returns
|
// UninstallAppProgress actually returns
|
||||||
// Activity.RESULT_FIRST_USER if something breaks
|
// Activity.RESULT_FIRST_USER if something breaks
|
||||||
mCallback.onError(InstallerCallback.OPERATION_DELETE,
|
mCallback.onError(InstallerCallback.OPERATION_DELETE,
|
||||||
InstallerCallback.ERROR_CODE_OTHER);
|
InstallerCallback.ERROR_CODE_OTHER);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,7 +161,7 @@ public final class LocalRepoKeyStore {
|
|||||||
KeyManager wrappedKeyManager = new KerplappKeyManager(
|
KeyManager wrappedKeyManager = new KerplappKeyManager(
|
||||||
(X509KeyManager) defaultKeyManager);
|
(X509KeyManager) defaultKeyManager);
|
||||||
keyManagers = new KeyManager[] {
|
keyManagers = new KeyManager[] {
|
||||||
wrappedKeyManager
|
wrappedKeyManager
|
||||||
};
|
};
|
||||||
} catch (UnrecoverableKeyException | KeyStoreException | NoSuchAlgorithmException | CertificateException | OperatorCreationException | IOException e) {
|
} catch (UnrecoverableKeyException | KeyStoreException | NoSuchAlgorithmException | CertificateException | OperatorCreationException | IOException e) {
|
||||||
Log.e(TAG, "Error loading keystore", 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,
|
private void addToStore(String alias, KeyPair kp, Certificate cert) throws KeyStoreException,
|
||||||
NoSuchAlgorithmException, CertificateException, IOException, UnrecoverableKeyException {
|
NoSuchAlgorithmException, CertificateException, IOException, UnrecoverableKeyException {
|
||||||
Certificate[] chain = {
|
Certificate[] chain = {
|
||||||
cert
|
cert
|
||||||
};
|
};
|
||||||
keyStore.setKeyEntry(alias, kp.getPrivate(),
|
keyStore.setKeyEntry(alias, kp.getPrivate(),
|
||||||
"".toCharArray(), chain);
|
"".toCharArray(), chain);
|
||||||
@ -274,7 +274,7 @@ public final class LocalRepoKeyStore {
|
|||||||
KeyManager defaultKeyManager = keyManagerFactory.getKeyManagers()[0];
|
KeyManager defaultKeyManager = keyManagerFactory.getKeyManagers()[0];
|
||||||
KeyManager wrappedKeyManager = new KerplappKeyManager((X509KeyManager) defaultKeyManager);
|
KeyManager wrappedKeyManager = new KerplappKeyManager((X509KeyManager) defaultKeyManager);
|
||||||
keyManagers = new KeyManager[] {
|
keyManagers = new KeyManager[] {
|
||||||
wrappedKeyManager
|
wrappedKeyManager
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ public class BluetoothDownloader extends Downloader {
|
|||||||
details != null &&
|
details != null &&
|
||||||
details.getCacheTag() != null &&
|
details.getCacheTag() != null &&
|
||||||
details.getCacheTag().equals(getCacheTag())
|
details.getCacheTag().equals(getCacheTag())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -54,18 +54,18 @@ public class LocalHTTPD extends NanoHTTPD {
|
|||||||
while (st.hasMoreTokens()) {
|
while (st.hasMoreTokens()) {
|
||||||
String tok = st.nextToken();
|
String tok = st.nextToken();
|
||||||
switch (tok) {
|
switch (tok) {
|
||||||
case "/":
|
case "/":
|
||||||
newUri += "/";
|
newUri += "/";
|
||||||
break;
|
break;
|
||||||
case " ":
|
case " ":
|
||||||
newUri += "%20";
|
newUri += "%20";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
try {
|
try {
|
||||||
newUri += URLEncoder.encode(tok, "UTF-8");
|
newUri += URLEncoder.encode(tok, "UTF-8");
|
||||||
} catch (UnsupportedEncodingException ignored) {
|
} catch (UnsupportedEncodingException ignored) {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return newUri;
|
return newUri;
|
||||||
@ -105,13 +105,13 @@ public class LocalHTTPD extends NanoHTTPD {
|
|||||||
private Response handlePost(IHTTPSession session) {
|
private Response handlePost(IHTTPSession session) {
|
||||||
Uri uri = Uri.parse(session.getUri());
|
Uri uri = Uri.parse(session.getUri());
|
||||||
switch (uri.getPath()) {
|
switch (uri.getPath()) {
|
||||||
case "/request-swap":
|
case "/request-swap":
|
||||||
if (!session.getParms().containsKey("repo")) {
|
if (!session.getParms().containsKey("repo")) {
|
||||||
Log.e(TAG, "Malformed /request-swap request to local repo HTTP server. Should have posted a 'repo' parameter.");
|
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.");
|
return new Response(Response.Status.BAD_REQUEST, MIME_PLAINTEXT, "Requires 'repo' parameter to be posted.");
|
||||||
}
|
}
|
||||||
requestSwap(session.getParms().get("repo"));
|
requestSwap(session.getParms().get("repo"));
|
||||||
return new Response(Response.Status.OK, MIME_PLAINTEXT, "Swap request received.");
|
return new Response(Response.Status.OK, MIME_PLAINTEXT, "Swap request received.");
|
||||||
}
|
}
|
||||||
return new Response("");
|
return new Response("");
|
||||||
}
|
}
|
||||||
|
@ -21,8 +21,8 @@ public class TorHttpDownloader extends HttpDownloader {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setupConnection() throws IOException {
|
protected void setupConnection() throws IOException {
|
||||||
SocketAddress sa = new InetSocketAddress("127.0.0.1", 8118);
|
SocketAddress sa = new InetSocketAddress("127.0.0.1", 8118);
|
||||||
Proxy tor = new Proxy(Proxy.Type.HTTP, sa);
|
Proxy tor = new Proxy(Proxy.Type.HTTP, sa);
|
||||||
connection = (HttpURLConnection) sourceUrl.openConnection(tor);
|
connection = (HttpURLConnection) sourceUrl.openConnection(tor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -353,14 +353,14 @@ public class AppSecurityPermissions {
|
|||||||
|
|
||||||
private List<MyPermissionInfo> getPermissionList(MyPermissionGroupInfo grp, int which) {
|
private List<MyPermissionInfo> getPermissionList(MyPermissionGroupInfo grp, int which) {
|
||||||
switch (which) {
|
switch (which) {
|
||||||
case WHICH_NEW:
|
case WHICH_NEW:
|
||||||
return grp.mNewPermissions;
|
return grp.mNewPermissions;
|
||||||
case WHICH_PERSONAL:
|
case WHICH_PERSONAL:
|
||||||
return grp.mPersonalPermissions;
|
return grp.mPersonalPermissions;
|
||||||
case WHICH_DEVICE:
|
case WHICH_DEVICE:
|
||||||
return grp.mDevicePermissions;
|
return grp.mDevicePermissions;
|
||||||
default:
|
default:
|
||||||
return grp.mAllPermissions;
|
return grp.mAllPermissions;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,12 +34,12 @@ public class AppListFragmentPagerAdapter extends FragmentPagerAdapter {
|
|||||||
@Override
|
@Override
|
||||||
public Fragment getItem(int i) {
|
public Fragment getItem(int i) {
|
||||||
switch (i) {
|
switch (i) {
|
||||||
case TabManager.INDEX_AVAILABLE:
|
case TabManager.INDEX_AVAILABLE:
|
||||||
return new AvailableAppsFragment();
|
return new AvailableAppsFragment();
|
||||||
case TabManager.INDEX_INSTALLED:
|
case TabManager.INDEX_INSTALLED:
|
||||||
return new InstalledAppsFragment();
|
return new InstalledAppsFragment();
|
||||||
default:
|
default:
|
||||||
return new CanUpdateAppsFragment();
|
return new CanUpdateAppsFragment();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,14 +49,14 @@ public class AppListFragmentPagerAdapter extends FragmentPagerAdapter {
|
|||||||
@Override
|
@Override
|
||||||
public String getPageTitle(int i) {
|
public String getPageTitle(int i) {
|
||||||
switch (i) {
|
switch (i) {
|
||||||
case TabManager.INDEX_AVAILABLE:
|
case TabManager.INDEX_AVAILABLE:
|
||||||
return parent.getString(R.string.tab_available_apps);
|
return parent.getString(R.string.tab_available_apps);
|
||||||
case TabManager.INDEX_INSTALLED:
|
case TabManager.INDEX_INSTALLED:
|
||||||
return parent.getString(R.string.tab_installed_apps);
|
return parent.getString(R.string.tab_installed_apps);
|
||||||
case TabManager.INDEX_CAN_UPDATE:
|
case TabManager.INDEX_CAN_UPDATE:
|
||||||
return getUpdateTabTitle();
|
return getUpdateTabTitle();
|
||||||
default:
|
default:
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,17 +155,17 @@ public class ManageReposActivity extends ActionBarActivity {
|
|||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
case android.R.id.home:
|
case android.R.id.home:
|
||||||
Intent destIntent = new Intent(this, FDroid.class);
|
Intent destIntent = new Intent(this, FDroid.class);
|
||||||
setResult(RESULT_OK, destIntent);
|
setResult(RESULT_OK, destIntent);
|
||||||
NavUtils.navigateUpTo(this, destIntent);
|
NavUtils.navigateUpTo(this, destIntent);
|
||||||
return true;
|
return true;
|
||||||
case R.id.action_add_repo:
|
case R.id.action_add_repo:
|
||||||
showAddRepo();
|
showAddRepo();
|
||||||
return true;
|
return true;
|
||||||
case R.id.action_update_repo:
|
case R.id.action_update_repo:
|
||||||
UpdateService.updateNow(this);
|
UpdateService.updateNow(this);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
@ -649,11 +649,11 @@ public class ManageReposActivity extends ActionBarActivity {
|
|||||||
Uri uri = RepoProvider.allExceptSwapUri();
|
Uri uri = RepoProvider.allExceptSwapUri();
|
||||||
Utils.debugLog(TAG, "Creating repo loader '" + uri + "'.");
|
Utils.debugLog(TAG, "Creating repo loader '" + uri + "'.");
|
||||||
final String[] projection = {
|
final String[] projection = {
|
||||||
RepoProvider.DataColumns._ID,
|
RepoProvider.DataColumns._ID,
|
||||||
RepoProvider.DataColumns.NAME,
|
RepoProvider.DataColumns.NAME,
|
||||||
RepoProvider.DataColumns.PUBLIC_KEY,
|
RepoProvider.DataColumns.PUBLIC_KEY,
|
||||||
RepoProvider.DataColumns.FINGERPRINT,
|
RepoProvider.DataColumns.FINGERPRINT,
|
||||||
RepoProvider.DataColumns.IN_USE
|
RepoProvider.DataColumns.IN_USE
|
||||||
};
|
};
|
||||||
return new CursorLoader(getActivity(), uri, projection, null, null, null);
|
return new CursorLoader(getActivity(), uri, projection, null, null, null);
|
||||||
}
|
}
|
||||||
|
@ -47,23 +47,23 @@ public class RepoDetailsActivity extends ActionBarActivity {
|
|||||||
* all of this info, otherwise they will be hidden.
|
* all of this info, otherwise they will be hidden.
|
||||||
*/
|
*/
|
||||||
private static final int[] SHOW_IF_EXISTS = {
|
private static final int[] SHOW_IF_EXISTS = {
|
||||||
R.id.label_repo_name,
|
R.id.label_repo_name,
|
||||||
R.id.text_repo_name,
|
R.id.text_repo_name,
|
||||||
R.id.text_description,
|
R.id.text_description,
|
||||||
R.id.label_num_apps,
|
R.id.label_num_apps,
|
||||||
R.id.text_num_apps,
|
R.id.text_num_apps,
|
||||||
R.id.label_last_update,
|
R.id.label_last_update,
|
||||||
R.id.text_last_update,
|
R.id.text_last_update,
|
||||||
R.id.label_repo_fingerprint,
|
R.id.label_repo_fingerprint,
|
||||||
R.id.text_repo_fingerprint,
|
R.id.text_repo_fingerprint,
|
||||||
R.id.text_repo_fingerprint_description
|
R.id.text_repo_fingerprint_description
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* If the repo has <em>not</em> been updated yet, then we only show
|
* If the repo has <em>not</em> been updated yet, then we only show
|
||||||
* these, otherwise they are hidden.
|
* these, otherwise they are hidden.
|
||||||
*/
|
*/
|
||||||
private static final int[] HIDE_IF_EXISTS = {
|
private static final int[] HIDE_IF_EXISTS = {
|
||||||
R.id.text_not_yet_updated,
|
R.id.text_not_yet_updated,
|
||||||
};
|
};
|
||||||
private Repo repo;
|
private Repo repo;
|
||||||
private long repoId;
|
private long repoId;
|
||||||
@ -95,9 +95,9 @@ public class RepoDetailsActivity extends ActionBarActivity {
|
|||||||
|
|
||||||
repoId = getIntent().getLongExtra(ARG_REPO_ID, 0);
|
repoId = getIntent().getLongExtra(ARG_REPO_ID, 0);
|
||||||
final String[] projection = {
|
final String[] projection = {
|
||||||
RepoProvider.DataColumns.NAME,
|
RepoProvider.DataColumns.NAME,
|
||||||
RepoProvider.DataColumns.ADDRESS,
|
RepoProvider.DataColumns.ADDRESS,
|
||||||
RepoProvider.DataColumns.FINGERPRINT
|
RepoProvider.DataColumns.FINGERPRINT
|
||||||
};
|
};
|
||||||
repo = RepoProvider.Helper.findById(this, repoId, projection);
|
repo = RepoProvider.Helper.findById(this, repoId, projection);
|
||||||
|
|
||||||
@ -317,22 +317,22 @@ public class RepoDetailsActivity extends ActionBarActivity {
|
|||||||
|
|
||||||
private void promptForDelete() {
|
private void promptForDelete() {
|
||||||
new AlertDialog.Builder(this)
|
new AlertDialog.Builder(this)
|
||||||
.setTitle(R.string.repo_confirm_delete_title)
|
.setTitle(R.string.repo_confirm_delete_title)
|
||||||
.setMessage(R.string.repo_confirm_delete_body)
|
.setMessage(R.string.repo_confirm_delete_body)
|
||||||
.setPositiveButton(R.string.delete, new DialogInterface.OnClickListener() {
|
.setPositiveButton(R.string.delete, new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
RepoProvider.Helper.remove(getApplicationContext(), repoId);
|
RepoProvider.Helper.remove(getApplicationContext(), repoId);
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
}).setNegativeButton(android.R.string.cancel,
|
}).setNegativeButton(android.R.string.cancel,
|
||||||
new DialogInterface.OnClickListener() {
|
new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
// Do nothing...
|
// Do nothing...
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
).show();
|
).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -34,21 +34,21 @@ public abstract class AppListFragment extends ThemeableListFragment implements
|
|||||||
private static final int REQUEST_APPDETAILS = 0;
|
private static final int REQUEST_APPDETAILS = 0;
|
||||||
|
|
||||||
public static final String[] APP_PROJECTION = {
|
public static final String[] APP_PROJECTION = {
|
||||||
AppProvider.DataColumns._ID, // Required for cursor loader to work.
|
AppProvider.DataColumns._ID, // Required for cursor loader to work.
|
||||||
AppProvider.DataColumns.APP_ID,
|
AppProvider.DataColumns.APP_ID,
|
||||||
AppProvider.DataColumns.NAME,
|
AppProvider.DataColumns.NAME,
|
||||||
AppProvider.DataColumns.SUMMARY,
|
AppProvider.DataColumns.SUMMARY,
|
||||||
AppProvider.DataColumns.IS_COMPATIBLE,
|
AppProvider.DataColumns.IS_COMPATIBLE,
|
||||||
AppProvider.DataColumns.LICENSE,
|
AppProvider.DataColumns.LICENSE,
|
||||||
AppProvider.DataColumns.ICON,
|
AppProvider.DataColumns.ICON,
|
||||||
AppProvider.DataColumns.ICON_URL,
|
AppProvider.DataColumns.ICON_URL,
|
||||||
AppProvider.DataColumns.InstalledApp.VERSION_CODE,
|
AppProvider.DataColumns.InstalledApp.VERSION_CODE,
|
||||||
AppProvider.DataColumns.InstalledApp.VERSION_NAME,
|
AppProvider.DataColumns.InstalledApp.VERSION_NAME,
|
||||||
AppProvider.DataColumns.SuggestedApk.VERSION,
|
AppProvider.DataColumns.SuggestedApk.VERSION,
|
||||||
AppProvider.DataColumns.SUGGESTED_VERSION_CODE,
|
AppProvider.DataColumns.SUGGESTED_VERSION_CODE,
|
||||||
AppProvider.DataColumns.IGNORE_ALLUPDATES,
|
AppProvider.DataColumns.IGNORE_ALLUPDATES,
|
||||||
AppProvider.DataColumns.IGNORE_THISUPDATE,
|
AppProvider.DataColumns.IGNORE_THISUPDATE,
|
||||||
AppProvider.DataColumns.REQUIREMENTS, // Needed for filtering apps that require root.
|
AppProvider.DataColumns.REQUIREMENTS, // Needed for filtering apps that require root.
|
||||||
};
|
};
|
||||||
|
|
||||||
public static final String APP_SORT = AppProvider.DataColumns.NAME;
|
public static final String APP_SORT = AppProvider.DataColumns.NAME;
|
||||||
|
@ -72,108 +72,108 @@ public class PreferencesFragment extends PreferenceFragment
|
|||||||
int result = 0;
|
int result = 0;
|
||||||
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case Preferences.PREF_UPD_INTERVAL:
|
case Preferences.PREF_UPD_INTERVAL:
|
||||||
ListPreference listPref = (ListPreference) findPreference(
|
ListPreference listPref = (ListPreference) findPreference(
|
||||||
Preferences.PREF_UPD_INTERVAL);
|
Preferences.PREF_UPD_INTERVAL);
|
||||||
int interval = Integer.parseInt(listPref.getValue());
|
int interval = Integer.parseInt(listPref.getValue());
|
||||||
Preference onlyOnWifi = findPreference(
|
Preference onlyOnWifi = findPreference(
|
||||||
Preferences.PREF_UPD_WIFI_ONLY);
|
Preferences.PREF_UPD_WIFI_ONLY);
|
||||||
onlyOnWifi.setEnabled(interval > 0);
|
onlyOnWifi.setEnabled(interval > 0);
|
||||||
if (interval == 0) {
|
if (interval == 0) {
|
||||||
listPref.setSummary(R.string.update_interval_zero);
|
listPref.setSummary(R.string.update_interval_zero);
|
||||||
} else {
|
} else {
|
||||||
listPref.setSummary(listPref.getEntry());
|
listPref.setSummary(listPref.getEntry());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Preferences.PREF_UPD_WIFI_ONLY:
|
case Preferences.PREF_UPD_WIFI_ONLY:
|
||||||
checkSummary(key, R.string.automatic_scan_wifi_on);
|
checkSummary(key, R.string.automatic_scan_wifi_on);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Preferences.PREF_UPD_NOTIFY:
|
case Preferences.PREF_UPD_NOTIFY:
|
||||||
checkSummary(key, R.string.notify_on);
|
checkSummary(key, R.string.notify_on);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Preferences.PREF_UPD_HISTORY:
|
case Preferences.PREF_UPD_HISTORY:
|
||||||
textSummary(key, R.string.update_history_summ);
|
textSummary(key, R.string.update_history_summ);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Preferences.PREF_COMPACT_LAYOUT:
|
case Preferences.PREF_COMPACT_LAYOUT:
|
||||||
checkSummary(key, R.string.compactlayout_on);
|
checkSummary(key, R.string.compactlayout_on);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Preferences.PREF_THEME:
|
case Preferences.PREF_THEME:
|
||||||
entrySummary(key);
|
entrySummary(key);
|
||||||
if (changing) {
|
if (changing) {
|
||||||
result |= PreferencesActivity.RESULT_RESTART;
|
result |= PreferencesActivity.RESULT_RESTART;
|
||||||
getActivity().setResult(result);
|
getActivity().setResult(result);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Preferences.PREF_INCOMP_VER:
|
case Preferences.PREF_INCOMP_VER:
|
||||||
checkSummary(key, R.string.show_incompat_versions_on);
|
checkSummary(key, R.string.show_incompat_versions_on);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Preferences.PREF_ROOTED:
|
case Preferences.PREF_ROOTED:
|
||||||
checkSummary(key, R.string.rooted_on);
|
checkSummary(key, R.string.rooted_on);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Preferences.PREF_IGN_TOUCH:
|
case Preferences.PREF_IGN_TOUCH:
|
||||||
checkSummary(key, R.string.ignoreTouch_on);
|
checkSummary(key, R.string.ignoreTouch_on);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Preferences.PREF_LOCAL_REPO_NAME:
|
case Preferences.PREF_LOCAL_REPO_NAME:
|
||||||
textSummary(key, R.string.local_repo_name_summary);
|
textSummary(key, R.string.local_repo_name_summary);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Preferences.PREF_LOCAL_REPO_HTTPS:
|
case Preferences.PREF_LOCAL_REPO_HTTPS:
|
||||||
checkSummary(key, R.string.local_repo_https_on);
|
checkSummary(key, R.string.local_repo_https_on);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Preferences.PREF_LANGUAGE:
|
case Preferences.PREF_LANGUAGE:
|
||||||
langSpinner(key);
|
langSpinner(key);
|
||||||
entrySummary(key);
|
entrySummary(key);
|
||||||
if (changing) {
|
if (changing) {
|
||||||
result |= PreferencesActivity.RESULT_RESTART;
|
result |= PreferencesActivity.RESULT_RESTART;
|
||||||
getActivity().setResult(result);
|
getActivity().setResult(result);
|
||||||
FDroidApp.updateLanguage(this.getActivity());
|
FDroidApp.updateLanguage(this.getActivity());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Preferences.PREF_CACHE_APK:
|
case Preferences.PREF_CACHE_APK:
|
||||||
checkSummary(key, R.string.cache_downloaded_on);
|
checkSummary(key, R.string.cache_downloaded_on);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Preferences.PREF_EXPERT:
|
case Preferences.PREF_EXPERT:
|
||||||
checkSummary(key, R.string.expert_on);
|
checkSummary(key, R.string.expert_on);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Preferences.PREF_PRIVILEGED_INSTALLER:
|
case Preferences.PREF_PRIVILEGED_INSTALLER:
|
||||||
checkSummary(key, R.string.system_installer_on);
|
checkSummary(key, R.string.system_installer_on);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Preferences.PREF_ENABLE_PROXY:
|
case Preferences.PREF_ENABLE_PROXY:
|
||||||
CheckBoxPreference checkPref = (CheckBoxPreference) findPreference(key);
|
CheckBoxPreference checkPref = (CheckBoxPreference) findPreference(key);
|
||||||
checkPref.setSummary(R.string.enable_proxy_summary);
|
checkPref.setSummary(R.string.enable_proxy_summary);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Preferences.PREF_PROXY_HOST:
|
case Preferences.PREF_PROXY_HOST:
|
||||||
EditTextPreference textPref = (EditTextPreference) findPreference(key);
|
EditTextPreference textPref = (EditTextPreference) findPreference(key);
|
||||||
String text = Preferences.get().getProxyHost();
|
String text = Preferences.get().getProxyHost();
|
||||||
if (TextUtils.isEmpty(text) || text.equals(Preferences.DEFAULT_PROXY_HOST))
|
if (TextUtils.isEmpty(text) || text.equals(Preferences.DEFAULT_PROXY_HOST))
|
||||||
textPref.setSummary(R.string.proxy_host_summary);
|
textPref.setSummary(R.string.proxy_host_summary);
|
||||||
else
|
else
|
||||||
textPref.setSummary(text);
|
textPref.setSummary(text);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Preferences.PREF_PROXY_PORT:
|
case Preferences.PREF_PROXY_PORT:
|
||||||
EditTextPreference textPref2 = (EditTextPreference) findPreference(key);
|
EditTextPreference textPref2 = (EditTextPreference) findPreference(key);
|
||||||
int port = Preferences.get().getProxyPort();
|
int port = Preferences.get().getProxyPort();
|
||||||
if (port == Preferences.DEFAULT_PROXY_PORT)
|
if (port == Preferences.DEFAULT_PROXY_PORT)
|
||||||
textPref2.setSummary(R.string.proxy_port_summary);
|
textPref2.setSummary(R.string.proxy_port_summary);
|
||||||
else
|
else
|
||||||
textPref2.setSummary(String.valueOf(port));
|
textPref2.setSummary(String.valueOf(port));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -234,17 +234,17 @@ public class SwapWorkflowActivity extends AppCompatActivity {
|
|||||||
.setTitle(R.string.swap_join_same_wifi)
|
.setTitle(R.string.swap_join_same_wifi)
|
||||||
.setMessage(R.string.swap_join_same_wifi_desc)
|
.setMessage(R.string.swap_join_same_wifi_desc)
|
||||||
.setNeutralButton(R.string.cancel, new DialogInterface.OnClickListener() {
|
.setNeutralButton(R.string.cancel, new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
// Do nothing
|
// 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));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
).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() {
|
).setNegativeButton(R.string.wifi_ap, new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
@ -142,12 +142,12 @@ public class PrivilegedService extends Service {
|
|||||||
// get internal methods via reflection
|
// get internal methods via reflection
|
||||||
try {
|
try {
|
||||||
Class<?>[] installTypes = {
|
Class<?>[] installTypes = {
|
||||||
Uri.class, IPackageInstallObserver.class, int.class,
|
Uri.class, IPackageInstallObserver.class, int.class,
|
||||||
String.class
|
String.class
|
||||||
};
|
};
|
||||||
Class<?>[] deleteTypes = {
|
Class<?>[] deleteTypes = {
|
||||||
String.class, IPackageDeleteObserver.class,
|
String.class, IPackageDeleteObserver.class,
|
||||||
int.class
|
int.class
|
||||||
};
|
};
|
||||||
|
|
||||||
PackageManager pm = getPackageManager();
|
PackageManager pm = getPackageManager();
|
||||||
|
@ -34,6 +34,8 @@
|
|||||||
<!--<module name="MethodLength" />-->
|
<!--<module name="MethodLength" />-->
|
||||||
<!--<module name="ParameterNumber" />-->
|
<!--<module name="ParameterNumber" />-->
|
||||||
|
|
||||||
|
<module name="Indentation" />
|
||||||
|
|
||||||
<module name="EmptyForIteratorPad" />
|
<module name="EmptyForIteratorPad" />
|
||||||
<module name="GenericWhitespace" />
|
<module name="GenericWhitespace" />
|
||||||
<module name="MethodParamPad" />
|
<module name="MethodParamPad" />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user