本文整理汇总了Java中org.fdroid.fdroid.Utils类的典型用法代码示例。如果您正苦于以下问题:Java Utils类的具体用法?Java Utils怎么用?Java Utils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Utils类属于org.fdroid.fdroid包,在下文中一共展示了Utils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onReceive
import org.fdroid.fdroid.Utils; //导入依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
if (intent != null) {
String action = intent.getAction();
if (Intent.ACTION_PACKAGE_ADDED.equals(action)) {
InstalledAppProviderService.insert(context, intent.getData());
} else if (Intent.ACTION_PACKAGE_REMOVED.equals(action)) {
if (TextUtils.equals(context.getPackageName(), intent.getData().getSchemeSpecificPart())) {
Utils.debugLog(TAG, "Ignoring request to remove ourselves from cache.");
} else {
InstalledAppProviderService.delete(context, intent.getData());
}
} else {
Utils.debugLog(TAG, "unsupported action: " + action + " " + intent);
}
}
}
示例2: processIntent
import org.fdroid.fdroid.Utils; //导入依赖的package包/类
private void processIntent(Intent i) {
if (NfcAdapter.ACTION_NDEF_DISCOVERED.equals(i.getAction())) {
Parcelable[] rawMsgs =
i.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES);
NdefMessage msg = (NdefMessage) rawMsgs[0];
String url = new String(msg.getRecords()[0].getPayload());
Utils.debugLog(TAG, "Got this URL: " + url);
Toast.makeText(this, "Got this URL: " + url, Toast.LENGTH_LONG).show();
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
intent.setClass(this, ManageReposActivity.class);
startActivity(intent);
finish();
}
}
示例3: setupRepoFingerprint
import org.fdroid.fdroid.Utils; //导入依赖的package包/类
private void setupRepoFingerprint(View parent, Repo repo) {
TextView repoFingerprintView = (TextView) parent.findViewById(R.id.text_repo_fingerprint);
TextView repoFingerprintDescView = (TextView) parent.findViewById(R.id.text_repo_fingerprint_description);
String repoFingerprint;
// TODO show the current state of the signature check, not just whether there is a key or not
if (TextUtils.isEmpty(repo.fingerprint) && TextUtils.isEmpty(repo.signingCertificate)) {
repoFingerprint = getResources().getString(R.string.unsigned);
repoFingerprintView.setTextColor(getResources().getColor(R.color.unsigned));
repoFingerprintDescView.setVisibility(View.VISIBLE);
repoFingerprintDescView.setText(getResources().getString(R.string.unsigned_description));
} else {
// this is based on repo.fingerprint always existing, which it should
repoFingerprint = Utils.formatFingerprint(this, repo.fingerprint);
repoFingerprintDescView.setVisibility(View.GONE);
}
repoFingerprintView.setText(repoFingerprint);
}
示例4: updateAndEnableExistingRepo
import org.fdroid.fdroid.Utils; //导入依赖的package包/类
/**
* Seeing as this repo already exists, we will force it to be enabled again.
*/
private void updateAndEnableExistingRepo(String url, String fingerprint) {
if (fingerprint != null) {
fingerprint = fingerprint.trim();
if (TextUtils.isEmpty(fingerprint)) {
fingerprint = null;
} else {
fingerprint = fingerprint.toUpperCase(Locale.ENGLISH);
}
}
Utils.debugLog(TAG, "Enabling existing repo: " + url);
Repo repo = RepoProvider.Helper.findByAddress(context, url);
ContentValues values = new ContentValues(2);
values.put(RepoTable.Cols.IN_USE, 1);
values.put(RepoTable.Cols.FINGERPRINT, fingerprint);
RepoProvider.Helper.update(context, repo, values);
notifyDataSetChanged();
finishedAddingRepo();
}
示例5: requestedPermissionsEqual
import org.fdroid.fdroid.Utils; //导入依赖的package包/类
/**
* Compares to sets of APK permissions to see if they are an exact match. The
* data format is {@link String} arrays but they are in effect sets. This is the
* same data format as {@link android.content.pm.PackageInfo#requestedPermissions}
*/
public static boolean requestedPermissionsEqual(@Nullable String[] expected, @Nullable String[] actual) {
Utils.debugLog(TAG, "Checking permissions");
Utils.debugLog(TAG, "Actual:\n " + (actual == null ? "None" : TextUtils.join("\n ", actual)));
Utils.debugLog(TAG, "Expected:\n " + (expected == null ? "None" : TextUtils.join("\n ", expected)));
if (expected == null && actual == null) {
return true;
}
if (expected == null || actual == null) {
return false;
}
if (expected.length != actual.length) {
return false;
}
HashSet<String> expectedSet = new HashSet<>(Arrays.asList(expected));
HashSet<String> actualSet = new HashSet<>(Arrays.asList(actual));
return expectedSet.equals(actualSet);
}
示例6: startBluetoothSwap
import org.fdroid.fdroid.Utils; //导入依赖的package包/类
/**
* The process for setting up bluetooth is as follows:
* * Assume we have bluetooth available (otherwise the button which allowed us to start
* the bluetooth process should not have been available).
* * Ask user to enable (if not enabled yet).
* * Start bluetooth server socket.
* * Enable bluetooth discoverability, so that people can connect to our server socket.
*
* Note that this is a little different than the usual process for bluetooth _clients_, which
* involves pairing and connecting with other devices.
*/
public void startBluetoothSwap() {
Utils.debugLog(TAG, "Initiating Bluetooth swap, will ensure the Bluetooth devices is enabled and discoverable before starting server.");
BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
if (adapter != null) {
if (adapter.isEnabled()) {
Utils.debugLog(TAG, "Bluetooth enabled, will check if device is discoverable with device.");
ensureBluetoothDiscoverableThenStart();
} else {
Utils.debugLog(TAG, "Bluetooth disabled, asking user to enable it.");
Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(enableBtIntent, REQUEST_BLUETOOTH_ENABLE_FOR_SWAP);
}
}
}
示例7: ensureBluetoothDiscoverableThenStart
import org.fdroid.fdroid.Utils; //导入依赖的package包/类
private void ensureBluetoothDiscoverableThenStart() {
Utils.debugLog(TAG, "Ensuring Bluetooth is in discoverable mode.");
if (BluetoothAdapter.getDefaultAdapter().getScanMode() != BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE) {
// TODO: Listen for BluetoothAdapter.ACTION_SCAN_MODE_CHANGED and respond if discovery
// is cancelled prematurely.
// 3600 is new maximum! TODO: What about when this expires? What if user manually disables discovery?
final int discoverableTimeout = 3600;
Utils.debugLog(TAG, "Not currently in discoverable mode, so prompting user to enable.");
Intent intent = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
intent.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, discoverableTimeout);
startActivityForResult(intent, REQUEST_BLUETOOTH_DISCOVERABLE);
}
if (service == null) {
throw new IllegalStateException("Can't start Bluetooth swap because service is null for some strange reason.");
}
service.getBluetoothSwap().startInBackground();
}
示例8: onCreate
import org.fdroid.fdroid.Utils; //导入依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
Utils.debugLog(TAG, "creating Service");
localBroadcastManager = LocalBroadcastManager.getInstance(this);
appUpdateStatusManager = AppUpdateStatusManager.getInstance(this);
BroadcastReceiver br = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String packageName = intent.getData().getSchemeSpecificPart();
for (AppUpdateStatusManager.AppUpdateStatus status : appUpdateStatusManager.getByPackageName(packageName)) {
appUpdateStatusManager.updateApk(status.getUniqueKey(), AppUpdateStatusManager.Status.Installed, null);
}
}
};
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(Intent.ACTION_PACKAGE_ADDED);
intentFilter.addDataScheme("package");
registerReceiver(br, intentFilter);
}
示例9: uiInitBluetooth
import org.fdroid.fdroid.Utils; //导入依赖的package包/类
private void uiInitBluetooth() {
if (bluetooth != null) {
textBluetoothVisible = (TextView) findViewById(R.id.bluetooth_visible);
viewBluetoothId = (TextView) findViewById(R.id.device_id_bluetooth);
viewBluetoothId.setText(bluetooth.getName());
viewBluetoothId.setVisibility(bluetooth.isEnabled() ? View.VISIBLE : View.GONE);
int textResource = getManager().isBluetoothDiscoverable() ? R.string.swap_visible_bluetooth : R.string.swap_not_visible_bluetooth;
textBluetoothVisible.setText(textResource);
bluetoothSwitch = (SwitchCompat) findViewById(R.id.switch_bluetooth);
Utils.debugLog(TAG, getManager().isBluetoothDiscoverable() ? "Initially marking switch as checked, because Bluetooth is discoverable." : "Initially marking switch as not-checked, because Bluetooth is not discoverable.");
bluetoothSwitch.setOnCheckedChangeListener(onBluetoothSwitchToggled);
setBluetoothSwitchState(getManager().isBluetoothDiscoverable(), true);
LocalBroadcastManager.getInstance(getContext()).registerReceiver(onBluetoothSwapStateChanged, new IntentFilter(SwapService.BLUETOOTH_STATE_CHANGE));
} else {
findViewById(R.id.bluetooth_info).setVisibility(View.GONE);
}
}
示例10: onReceive
import org.fdroid.fdroid.Utils; //导入依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
if (intent.hasExtra(SwapService.EXTRA_STARTING)) {
Utils.debugLog(TAG, "Bluetooth service is starting (setting toggle to disabled, not checking because we will wait for an intent that bluetooth is actually enabled)");
bluetoothSwitch.setEnabled(false);
textBluetoothVisible.setText(R.string.swap_setting_up_bluetooth);
// bluetoothSwitch.setChecked(true);
} else {
if (intent.hasExtra(SwapService.EXTRA_STARTED)) {
Utils.debugLog(TAG, "Bluetooth service has started (updating text to visible, but not marking as checked).");
textBluetoothVisible.setText(R.string.swap_visible_bluetooth);
bluetoothSwitch.setEnabled(true);
// bluetoothSwitch.setChecked(true);
} else {
Utils.debugLog(TAG, "Bluetooth service has stopped (setting switch to not-visible).");
textBluetoothVisible.setText(R.string.swap_not_visible_bluetooth);
setBluetoothSwitchState(false, true);
}
}
}
示例11: onCheckedChanged
import org.fdroid.fdroid.Utils; //导入依赖的package包/类
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
Utils.debugLog(TAG, "Received onCheckChanged(true) for Bluetooth swap, prompting user as to whether they want to enable Bluetooth.");
getActivity().startBluetoothSwap();
textBluetoothVisible.setText(R.string.swap_visible_bluetooth);
viewBluetoothId.setVisibility(View.VISIBLE);
Utils.debugLog(TAG, "Received onCheckChanged(true) for Bluetooth swap (prompting user or setup Bluetooth complete)");
// TODO: When they deny the request for enabling bluetooth, we need to disable this switch...
} else {
Utils.debugLog(TAG, "Received onCheckChanged(false) for Bluetooth swap, disabling Bluetooth swap.");
getManager().getBluetoothSwap().stop();
textBluetoothVisible.setText(R.string.swap_not_visible_bluetooth);
viewBluetoothId.setVisibility(View.GONE);
Utils.debugLog(TAG, "Received onCheckChanged(false) for Bluetooth swap, Bluetooth swap disabled successfully.");
}
}
示例12: symlinkRuntime
import org.fdroid.fdroid.Utils; //导入依赖的package包/类
static void symlinkRuntime(SanitizedFile source, SanitizedFile dest) {
String[] commands = {
FDroidApp.SYSTEM_DIR_NAME + "/bin/ln",
"-s",
source.getAbsolutePath(),
dest.getAbsolutePath(),
};
try {
Utils.debugLog(TAG, "Executing command: " + commands[0] + " " + commands[1]
+ " " + commands[2] + " " + commands[3]);
Process proc = Runtime.getRuntime().exec(commands);
Utils.consumeStream(proc.getInputStream());
Utils.consumeStream(proc.getErrorStream());
} catch (IOException e) {
// Do nothing
}
}
示例13: onReceive
import org.fdroid.fdroid.Utils; //导入依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
int statusCode = intent.getIntExtra(UpdateService.EXTRA_STATUS_CODE, -1);
switch (statusCode) {
case UpdateService.STATUS_COMPLETE_WITH_CHANGES:
Utils.debugLog(TAG, "Swap repo has updates, notifying the list adapter.");
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
adapter.notifyDataSetChanged();
}
});
break;
case UpdateService.STATUS_ERROR_GLOBAL:
// TODO: Well, if we can't get the index, we probably can't swapp apps.
// Tell the user something helpful?
break;
case UpdateService.STATUS_COMPLETE_AND_SAME:
schedulePollForUpdates();
break;
}
}
示例14: lastUpdated
import org.fdroid.fdroid.Utils; //导入依赖的package包/类
@Test
public void lastUpdated() {
assertNull(RepoProvider.Helper.lastUpdate(context));
Repo gpRepo = RepoProvider.Helper.findByAddress(context, "https://guardianproject.info/fdroid/repo");
// Set date to 2017-04-05 11:56:38
setLastUpdate(gpRepo, new Date(1491357408643L));
// GP is not yet enabled, so it is not counted.
assertNull(RepoProvider.Helper.lastUpdate(context));
// Set date to 2017-04-04 11:56:38
Repo fdroidRepo = RepoProvider.Helper.findByAddress(context, "https://f-droid.org/repo");
setLastUpdate(fdroidRepo, new Date(1491357408643L - (1000 * 60 * 60 * 24)));
assertEquals("2017-04-04", Utils.formatDate(RepoProvider.Helper.lastUpdate(context), null));
setEnabled(gpRepo, true);
assertEquals("2017-04-05", Utils.formatDate(RepoProvider.Helper.lastUpdate(context), null));
}
示例15: addAppPrefsTable
import org.fdroid.fdroid.Utils; //导入依赖的package包/类
private void addAppPrefsTable(SQLiteDatabase db, int oldVersion) {
if (oldVersion >= 60) {
return;
}
Utils.debugLog(TAG, "Creating app preferences table");
db.execSQL(CREATE_TABLE_APP_PREFS);
Utils.debugLog(TAG, "Migrating app preferences to separate table");
db.execSQL(
"INSERT INTO " + AppPrefsTable.NAME + " ("
+ AppPrefsTable.Cols.PACKAGE_NAME + ", "
+ AppPrefsTable.Cols.IGNORE_THIS_UPDATE + ", "
+ AppPrefsTable.Cols.IGNORE_ALL_UPDATES
+ ") SELECT "
+ "id, "
+ "ignoreThisUpdate, "
+ "ignoreAllUpdates "
+ "FROM " + AppMetadataTable.NAME + " "
+ "WHERE ignoreThisUpdate > 0 OR ignoreAllUpdates > 0"
);
resetTransient(db);
}