本文整理汇总了Java中com.google.android.apps.dashclock.api.ExtensionData.status方法的典型用法代码示例。如果您正苦于以下问题:Java ExtensionData.status方法的具体用法?Java ExtensionData.status怎么用?Java ExtensionData.status使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.android.apps.dashclock.api.ExtensionData
的用法示例。
在下文中一共展示了ExtensionData.status方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onUpdateData
import com.google.android.apps.dashclock.api.ExtensionData; //导入方法依赖的package包/类
@Override
protected void onUpdateData(int reason) {
sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
Countdown countdown = new Countdown(this, getCountdownNumber());
int[] diffs = countdown.getTimeRemaining();
ExtensionData extensionData = new ExtensionData();
extensionData.status(countdown.getStatus(diffs));
extensionData.expandedTitle(sharedPreferences.getString("pref_title_" + getCountdownNumber(), getString(R.string.no_countdown_title)));
extensionData.expandedBody(countdown.getBody(diffs));
extensionData.icon(sharedPreferences.getInt("pref_icon_" + getCountdownNumber(), R.drawable.ic_launcher));
extensionData.clickIntent(getClickIntent());
extensionData.visible(true);
publishUpdate(extensionData);
}
示例2: update
import com.google.android.apps.dashclock.api.ExtensionData; //导入方法依赖的package包/类
/**
* Updated the notification data copy and also updates the notification in the notification
* shade.
* <br />
* All the extension data is consumed and used for building the notification. The title of the
* extension data becomes the notification's title, the body of the extension data becomes the
* notification's content, the click intent of the extension data becomes the notification's
* click intent, the icon of the extension data becomes the notification's icon and the status
* of the extension data becomes the notifications info only if the status does not match the
* title or the body (to prevent redundant information cluttering up the notification.)
*
* @param component the component name of the extension
* @param data the data passed from the extension
*/
@SuppressWarnings("deprecation")
private void update(ComponentName component, ExtensionData data) {
if (data != null && data.visible()) {
int colour = getResources().getColor(R.color.notification_color);
NotificationCompat.Builder notification = new NotificationCompat.Builder(this);
notification.setColor(colour);
notification.setCategory(NotificationCompat.CATEGORY_SERVICE);
notification.setPriority(Integer.MIN_VALUE);
notification.setOnlyAlertOnce(true);
notification.setOngoing(true);
notification.setShowWhen(true);
PendingIntent click = PendingIntent.getActivity(getApplicationContext(), 0, data.clickIntent(), 0);
Bitmap icon = Utils.loadExtensionIcon(getApplicationContext(), component, data.icon(), null, colour);
notification.setStyle(new BigTextStyle().bigText(data.expandedBody()));
notification.setSmallIcon(R.drawable.ic_notification);
notification.setContentTitle(data.expandedTitle());
notification.setContentText(data.expandedBody());
notification.setGroup("dashbar");
if (data.status() != null && !data.status().equalsIgnoreCase(data.expandedBody())
&& !data.status().equalsIgnoreCase(data.expandedTitle())) {
notification.setContentInfo(data.status());
}
notification.setContentIntent(click);
notification.setLargeIcon(icon);
mNotifier.notify(component.getPackageName(), 1, notification.build());
}
}
示例3: expandedTitleOrStatus
import com.google.android.apps.dashclock.api.ExtensionData; //导入方法依赖的package包/类
public static String expandedTitleOrStatus(ExtensionData data) {
String expandedTitle = data.expandedTitle();
if (TextUtils.isEmpty(expandedTitle)) {
expandedTitle = data.status();
if (!TextUtils.isEmpty(expandedTitle)) {
expandedTitle = expandedTitle.replace("\n", " ");
}
}
return expandedTitle;
}
示例4: onUpdateData
import com.google.android.apps.dashclock.api.ExtensionData; //导入方法依赖的package包/类
@Override
protected void onUpdateData(int intReason) {
Log.d(getTag(), "Checking for any wireless displays on the network");
final ExtensionData edtInformation = new ExtensionData();
setUpdateWhenScreenOn(true);
try {
Integer intDisplays = hndDiscoverer.getDetectedDisplays();
if (hndDiscoverer.getDetectedDisplays() > 0) {
edtInformation.expandedTitle(getString(R.string.found_devices));
} else {
edtInformation.expandedTitle(getString(R.string.no_devices));
}
edtInformation.expandedBody(getQuantityString(R.plurals.devices, intDisplays, intDisplays));
edtInformation.status(hndDiscoverer.getDetectedDisplays().toString());
edtInformation.visible(true);
} catch (Exception e) {
edtInformation.visible(false);
Log.e(getTag(), "Encountered an error", e);
ACRA.getErrorReporter().handleSilentException(e);
}
edtInformation.icon(R.drawable.ic_dashclock);
edtInformation.clickIntent(new Intent().setComponent(new ComponentName("com.android.settings", "com.android.settings.Settings$WifiDisplaySettingsActivity")));
doUpdate(edtInformation);
}
示例5: onUpdateData
import com.google.android.apps.dashclock.api.ExtensionData; //导入方法依赖的package包/类
@Override
protected void onUpdateData(int intReason) {
Log.d(getTag(), "Calculating the amount of data transferred");
ExtensionData edtInformation = new ExtensionData();
setUpdateWhenScreenOn(true);
try {
ComponentName cmpActivity = new ComponentName("com.android.settings", "com.android.settings.Settings$DataUsageSummaryActivity");
Long lngMobile = this.lngMobile + TrafficStats.getMobileRxBytes() + TrafficStats.getMobileTxBytes();
Long lngTotal = this.lngTotal + TrafficStats.getTotalRxBytes() + TrafficStats.getTotalTxBytes();
Long lngWifi = lngTotal - lngMobile;
String strMobile = Formatter.formatFileSize(getApplicationContext(), lngMobile);
String strTotal = Formatter.formatFileSize(getApplicationContext(), lngTotal);
String strWifi = Formatter.formatFileSize(getApplicationContext(), lngWifi);
edtInformation.expandedTitle(String.format(getString(R.string.status), strTotal));
edtInformation.status(strTotal);
edtInformation.expandedBody(String.format(getString(R.string.message), strMobile, strWifi));
edtInformation.visible(true);
edtInformation.clickIntent(new Intent().setComponent(cmpActivity));
} catch (Exception e) {
edtInformation.visible(false);
Log.e(getTag(), "Encountered an error", e);
ACRA.getErrorReporter().handleSilentException(e);
}
edtInformation.icon(R.drawable.ic_dashclock);
doUpdate(edtInformation);
}
示例6: onUpdateData
import com.google.android.apps.dashclock.api.ExtensionData; //导入方法依赖的package包/类
@Override
protected void onUpdateData(int intReason) {
Log.d(getTag(), "Getting the status of the processes");
ExtensionData edtInformation = new ExtensionData();
setUpdateWhenScreenOn(true);
try {
Log.d(getTag(), "Calculating the number of tasks and services");
ActivityManager mgrActivity = (ActivityManager) this.getSystemService(ACTIVITY_SERVICE);
Integer intServices = mgrActivity.getRunningServices(Integer.MAX_VALUE).size();
Integer intRecents = mgrActivity.getRecentTasks(Integer.MAX_VALUE, 2).size() - 1;
Integer intProcess = mgrActivity.getRunningAppProcesses().size();
String strServices = getQuantityString(R.plurals.service, intServices, intServices);
String strRecents = getQuantityString(R.plurals.activity, intRecents, intRecents);
Log.d(getTag(), String.format("%d running processes", intProcess));
edtInformation.clickIntent(new Intent(Intent.ACTION_VIEW).setClassName("com.android.settings", "com.android.settings.RunningServices"));
edtInformation.status(Integer.toString(intRecents + intServices));
edtInformation.expandedTitle(getString(R.string.and, strRecents, strServices));
edtInformation.expandedBody(getQuantityString(R.plurals.process, intProcess, intProcess));
edtInformation.visible(true);
} catch (Exception e) {
edtInformation.visible(false);
Log.e(getTag(), "Encountered an error", e);
ACRA.getErrorReporter().handleSilentException(e);
}
edtInformation.icon(R.drawable.ic_dashclock);
doUpdate(edtInformation);
}
示例7: onUpdateData
import com.google.android.apps.dashclock.api.ExtensionData; //导入方法依赖的package包/类
@Override
protected void onUpdateData(int intReason) {
Log.d(getTag(), "Fetching processor and memory utilisation information");
final ExtensionData edtInformation = new ExtensionData();
setUpdateWhenScreenOn(true);
try {
ActivityManager mgrActivity = ((ActivityManager) getSystemService(Context.ACTIVITY_SERVICE));
MemoryInfo memInformation = new MemoryInfo();
mgrActivity.getMemoryInfo(memInformation);
Long lngFree = memInformation.availMem / 1048576L;
Long lngTotal = memInformation.totalMem / 1048576L;
Integer intLevel = (int) ((100.0 * (lngFree / (lngTotal + 0.01))) / 25);
edtInformation.status(hndNotifier.getUsagePercentage().toString());
edtInformation.expandedTitle(getString(R.string.processor, hndNotifier.getUsagePercentage()));
edtInformation.expandedBody(getString(R.string.memory, lngFree, lngTotal));
edtInformation.visible(true);
notBuilder = notBuilder.setContentTitle(getResources().getStringArray(R.array.usage)[intLevel]);
notBuilder = notBuilder.setContentText(getString(R.string.memory, lngFree, lngTotal));
} catch (Exception e) {
edtInformation.visible(false);
Log.e(getTag(), "Encountered an error", e);
ACRA.getErrorReporter().handleSilentException(e);
}
edtInformation.icon(R.drawable.ic_dashclock);
doUpdate(edtInformation);
}
示例8: onUpdateData
import com.google.android.apps.dashclock.api.ExtensionData; //导入方法依赖的package包/类
@Override
protected void onUpdateData(int intReason) {
Log.d(getTag(), "Calculating the number of warnings and failures");
final ExtensionData edtInformation = new ExtensionData();
setUpdateWhenScreenOn(true);
try {
Integer intFailures = getSet("failure", new HashSet<String>()).size();
Integer intWarnings = getSet("warning", new HashSet<String>()).size();
if (intFailures + intWarnings > 0) {
Log.d(getTag(), String.format("Found %d warnings and %d failures", intWarnings, intFailures));
String strFailures = getQuantityString(R.plurals.failure, intFailures, intFailures);
String strWarnings = getQuantityString(R.plurals.warning, intWarnings, intWarnings);
String strBookmark = DateUtils.formatDateTime(this, speSettings.getLong("bookmark", Long.MIN_VALUE), 17);
edtInformation.clickIntent(new Intent(this, WarningActivity.class).addCategory(Intent.CATEGORY_LAUNCHER));
edtInformation.expandedBody(getString(R.string.body, strBookmark));
edtInformation.expandedTitle(getString(R.string.title, strFailures, strWarnings));
edtInformation.status(String.valueOf(intFailures + intWarnings));
edtInformation.visible(true);
} else {
Log.d(getTag(), "Found no warnings or failures");
edtInformation.visible(false);
}
} catch (Exception e) {
edtInformation.visible(true);
Log.e(getTag(), "Encountered an error", e);
ACRA.getErrorReporter().handleSilentException(e);
}
edtInformation.icon(R.drawable.ic_dashclock);
doUpdate(edtInformation);
}
示例9: onUpdateData
import com.google.android.apps.dashclock.api.ExtensionData; //导入方法依赖的package包/类
@Override
protected void onUpdateData(int intReason) {
Log.d(getTag(), "Fetching wireless debugging status");
ExtensionData edtInformation = new ExtensionData();
setUpdateWhenScreenOn(false);
try {
Integer intPort = Settings.Secure.getInt(getContentResolver(), "adb_port", -1);
if (intPort > 0) {
Log.d(getTag(), "Wireless debugging is enabled");
WifiManager wm = (WifiManager) getSystemService(WIFI_SERVICE);
Log.d(getTag(), "Checking if wireless connectivity is enabled");
if (wm.isWifiEnabled()) {
String strIP = Formatter.formatIpAddress(wm.getConnectionInfo().getIpAddress());
Log.d(getTag(), "Wireless connectivity is enabled");
edtInformation.status(getString(R.string.enabled));
edtInformation.expandedBody(getString(R.string.portno, strIP, intPort));
edtInformation.visible(true);
} else {
Log.d(getTag(), "Wireless connectivity isn't enabled");
edtInformation.status(getString(R.string.disabled));
edtInformation.expandedBody(getString(R.string.plugin));
edtInformation.visible(getBoolean("always", true));
}
} else {
Log.d(getTag(), "Wireless debugging is disabled");
edtInformation.status(getString(R.string.disabled));
edtInformation.expandedBody(getString(R.string.plugin));
edtInformation.visible(getBoolean("always", true));
}
edtInformation.clickIntent(new Intent(Settings.ACTION_APPLICATION_DEVELOPMENT_SETTINGS));
} catch (Exception e) {
edtInformation.visible(false);
Log.e(getTag(), "Encountered an error", e);
ACRA.getErrorReporter().handleSilentException(e);
}
edtInformation.icon(R.drawable.ic_dashclock);
doUpdate(edtInformation);
}
示例10: onUpdateData
import com.google.android.apps.dashclock.api.ExtensionData; //导入方法依赖的package包/类
@SuppressLint("SimpleDateFormat")
@Override
protected void onUpdateData(int intReason) {
Log.d(getTag(), "Checking nightly commits");
ExtensionData edtInformation = new ExtensionData();
setUpdateWhenScreenOn(false);
try {
Log.d(getTag(), "Checking if it is a nightly build");
if (HelperFunctions.getType().equalsIgnoreCase("NIGHTLY")) {
Date datBuild = new SimpleDateFormat("yyyyMMdd").parse(HelperFunctions.getDate());
Integer intDays = Days.daysBetween(new DateTime(datBuild), new DateTime(new Date())).getDays();
Log.d(getTag(), "Checking if it is older than zero days");
if (intDays > 0) {
ComponentName cmpActivity = new ComponentName("com.cyanogenmod.updater", "com.cyanogenmod.updater.UpdatesSettings");
edtInformation.clickIntent(new Intent().setComponent(cmpActivity));
edtInformation.visible(true);
edtInformation.expandedTitle(getQuantityString(R.plurals.changes, intDays, intDays));
edtInformation.expandedBody(HelperFunctions.getBuildString());
edtInformation.status(intDays.toString());
} else {
Log.d(getTag(), "It isn't older than zero days");
}
} else {
Log.d(getTag(), "Not a nightly build");
}
} catch (Exception e) {
edtInformation.visible(false);
Log.e(getTag(), "Encountered an error", e);
ACRA.getErrorReporter().handleSilentException(e);
}
edtInformation.icon(R.drawable.ic_dashclock);
doUpdate(edtInformation);
}
示例11: onUpdateData
import com.google.android.apps.dashclock.api.ExtensionData; //导入方法依赖的package包/类
@Override
protected void onUpdateData(int intReason) {
Log.d(getTag(), "Fetching near-field communication information");
ExtensionData edtInformation = new ExtensionData();
setUpdateWhenScreenOn(true);
try {
BluetoothAdapter bluAdapter = BluetoothAdapter.getDefaultAdapter();
if (bluAdapter != null) {
Log.d(getTag(), "Checking if the bluetooth radio is enabled");
edtInformation.clickIntent(new Intent(Settings.ACTION_BLUETOOTH_SETTINGS));
if (bluAdapter.isEnabled()) {
Log.d(getTag(), "Bluetooth radio is enabled");
if (booConnected) {
edtInformation.expandedTitle(getString(R.string.device_connected));
} else {
edtInformation.expandedTitle(getString(R.string.not_connected));
}
edtInformation.visible(true);
edtInformation.status(getString(R.string.enabled));
edtInformation.expandedBody(getString(R.string.visible_as, bluAdapter.getName()));
} else {
Log.d(getTag(), "Bluetooth radio is disabled");
edtInformation.visible(getBoolean("always", true));
edtInformation.status(getString(R.string.disabled));
edtInformation.expandedTitle(getString(R.string.not_enabled));
edtInformation.expandedBody(getString(R.string.tap_enable, bluAdapter.getName()));
}
} else {
Log.d(getTag(), "Device doesn't have a bluetooth radio");
}
} catch (Exception e) {
edtInformation.visible(false);
Log.e(getTag(), "Encountered an error", e);
ACRA.getErrorReporter().handleSilentException(e);
}
edtInformation.icon(R.drawable.ic_dashclock);
doUpdate(edtInformation);
}
示例12: onUpdateData
import com.google.android.apps.dashclock.api.ExtensionData; //导入方法依赖的package包/类
@Override
protected void onUpdateData(int intReason) {
Log.d(getTag(), "Fetching near-field communication information");
ExtensionData edtInformation = new ExtensionData();
setUpdateWhenScreenOn(false);
try {
NfcManager nfcManager = (NfcManager) getSystemService(Context.NFC_SERVICE);
if (nfcManager != null && nfcManager.getDefaultAdapter() != null) {
Log.d(getTag(), "Checking if near-field communication is enabled");
if (nfcManager.getDefaultAdapter().isEnabled()) {
Log.d(getTag(), "Near-field communication is enabled");
edtInformation.visible(true);
edtInformation.status(getString(R.string.title));
edtInformation.clickIntent(new Intent("android.settings.NFC_SETTINGS"));
if (nfcManager.getDefaultAdapter().isNdefPushEnabled()) {
edtInformation.expandedBody(getString(R.string.beam_enabled));
} else {
edtInformation.expandedBody(getString(R.string.beam_disabled));
}
} else {
Log.d(getTag(), "Near-field communication is disabled");
}
} else {
Log.d(getTag(), "Device doesn't support near-field communication");
}
} catch (Exception e) {
edtInformation.visible(false);
Log.e(getTag(), "Encountered an error", e);
ACRA.getErrorReporter().handleSilentException(e);
}
edtInformation.icon(R.drawable.ic_dashclock);
doUpdate(edtInformation);
}
示例13: onUpdateData
import com.google.android.apps.dashclock.api.ExtensionData; //导入方法依赖的package包/类
@Override
protected void onUpdateData(int arg0) {
Log.d(getTag(), "Calculating the amount of available storage on device");
ExtensionData edtInformation = new ExtensionData();
setUpdateWhenScreenOn(false);
try {
File filExternal = Environment.getExternalStorageDirectory();
StatFs sfsExternal = new StatFs(filExternal.getAbsolutePath());
Long lngBlize = (long) sfsExternal.getBlockSize();
Long lngAblock = (long) sfsExternal.getAvailableBlocks();
Long lngTblock = (long) sfsExternal.getBlockCount();
Long lngTotal = lngTblock * lngBlize;
Long lngFree = lngAblock * lngBlize;
if (lngTotal > 0L) {
String strTotal = Formatter.formatFileSize(getApplicationContext(), lngTotal);
String strFree = Formatter.formatFileSize(getApplicationContext(), lngFree);
Integer intPercent = (int) (0.5d + (double) lngFree * 100 / (double) lngTotal);
Log.v(getTag(), String.format("%s of %s free on the storage", strFree, strTotal));
if (Environment.isExternalStorageEmulated()) {
edtInformation.expandedBody(getString(R.string.internal, strFree, strTotal));
} else {
edtInformation.expandedBody(getString(R.string.external, strFree, strTotal));
}
edtInformation.visible(true);
edtInformation.expandedTitle(getString(R.string.available_space, intPercent));
edtInformation.status(intPercent.toString());
edtInformation.clickIntent(new Intent(Settings.ACTION_INTERNAL_STORAGE_SETTINGS));
}
} catch (Exception e) {
edtInformation.visible(false);
Log.e(getTag(), "Encountered an error", e);
ACRA.getErrorReporter().handleSilentException(e);
}
edtInformation.icon(R.drawable.ic_dashclock);
doUpdate(edtInformation);
}
示例14: onUpdateData
import com.google.android.apps.dashclock.api.ExtensionData; //导入方法依赖的package包/类
@Override
protected void onUpdateData(int intReason) {
Log.d(getTag(), "Fetching wireless network information");
ExtensionData edtInformation = new ExtensionData();
setUpdateWhenScreenOn(true);
try {
Log.d(getTag(), "Checking if connected to a wifi network");
ConnectivityManager mgrConnect = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
if (mgrConnect != null) {
NetworkInfo nifWifi = mgrConnect.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
if (nifWifi != null && nifWifi.isConnected()) {
Log.d(getTag(), "Connected to a wireless network");
WifiManager wifManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
WifiInfo wifInfo = wifManager.getConnectionInfo();
List<ScanResult> networks = wifManager.getScanResults();
String security = null;
if (networks != null) {
for (ScanResult network : networks) {
if (network.BSSID.equalsIgnoreCase(wifInfo.getBSSID())) {
String capabilities = network.capabilities;
Log.d(getTag(), "Current network security is " + capabilities);
if (capabilities.contains("WEP")) {
security = "WEP";
} else if (capabilities.contains("WPA2-PSK")) {
security = "WPA2-PSK";
} else if (capabilities.contains("WPA2")) {
security = "WPA2";
} else if (capabilities.contains("WPA")) {
security = "WPA";
} else {
security = null;
}
}
}
}
if (wifInfo != null && !wifInfo.getSSID().trim().isEmpty()) {
Log.d(getTag(), wifInfo.getSSID().replaceAll("^\"|\"$", ""));
edtInformation.visible(true);
edtInformation.status(wifInfo.getLinkSpeed() + WifiInfo.LINK_SPEED_UNITS);
edtInformation.expandedTitle(wifInfo.getSSID().replaceAll("^\"|\"$", ""));
if (security == null) {
edtInformation.expandedBody(getString(R.string.unsecured_network, wifInfo.getLinkSpeed(), WifiInfo.LINK_SPEED_UNITS));
} else {
edtInformation.expandedBody(getString(R.string.secured_network, security, wifInfo.getLinkSpeed(), WifiInfo.LINK_SPEED_UNITS));
}
edtInformation.clickIntent(new Intent(Settings.ACTION_WIFI_SETTINGS));
}
} else {
Log.d(getTag(), "Not connected to a wireless network");
}
} else {
Log.d(getTag(), "No wireless connection available");
}
} catch (Exception e) {
edtInformation.visible(false);
Log.e(getTag(), "Encountered an error", e);
ACRA.getErrorReporter().handleSilentException(e);
}
edtInformation.icon(R.drawable.ic_dashclock);
doUpdate(edtInformation);
}