本文整理汇总了Java中android.app.WallpaperInfo类的典型用法代码示例。如果您正苦于以下问题:Java WallpaperInfo类的具体用法?Java WallpaperInfo怎么用?Java WallpaperInfo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
WallpaperInfo类属于android.app包,在下文中一共展示了WallpaperInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onResume
import android.app.WallpaperInfo; //导入依赖的package包/类
@Override
public void onResume() {
super.onResume();
Set<String> transitions = Preferences.General.Transitions.getSelectedTransitions(getActivity());
Set<String> effects = Preferences.General.Effects.getSelectedEffects(getActivity());
Set<String> borders = Preferences.General.Borders.getSelectedBorders(getActivity());
mTransitionsTypes.setValues(transitions);
updateTransitionTypeSummary(transitions);
mEffectsTypes.setValues(effects);
updateEffectTypeSummary(effects);
mBordersTypes.setValues(borders);
updateBorderTypeSummary(borders);
// Update set wallpaper status
WallpaperInfo info = WallpaperManager.getInstance(getActivity()).getWallpaperInfo();
mSetAsWallpaper.setEnabled(info == null
|| !info.getPackageName().equals(getActivity().getPackageName()));
}
示例2: onCreateOptionsMenu
import android.app.WallpaperInfo; //导入依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_main, menu);
applyItem = menu.findItem(R.id.action_apply);
setBagelItem = menu.findItem(R.id.action_set);
deleteItem = menu.findItem(R.id.action_delete);
WallpaperInfo info = WallpaperManager.getInstance(this).getWallpaperInfo();
applyItem.setVisible(info == null || !info.getPackageName().matches(getPackageName()));
return super.onCreateOptionsMenu(menu);
}
示例3: setTransparent
import android.app.WallpaperInfo; //导入依赖的package包/类
public void setTransparent() {
if (status != null && wallpaperManager != null) {
Drawable backgroundDrawable;
WallpaperInfo wallpaperInfo = wallpaperManager.getWallpaperInfo();
if (wallpaperInfo != null)
backgroundDrawable = wallpaperInfo.loadThumbnail(getContext().getPackageManager());
else {
try {
backgroundDrawable = wallpaperManager.getDrawable();
} catch (SecurityException e) {
setColor(getDefaultColor());
return;
}
}
Bitmap background = ImageUtils.cropBitmapToBar(getContext(), ImageUtils.drawableToBitmap(backgroundDrawable));
if (background != null) {
int color = ColorUtils.getAverageColor(background);
Boolean transparent = PreferenceUtils.getBooleanPreference(getContext(), PreferenceUtils.PreferenceIdentifier.STATUS_HOME_TRANSPARENT);
if (transparent == null || transparent) {
status.setBackground(new BitmapDrawable(getResources(), background));
setDarkMode(!ColorUtils.isColorDark(color));
StatusView.this.color = color;
} else setColor(color);
} else setColor(getDefaultColor());
}
}
示例4: isWallpaperActivated
import android.app.WallpaperInfo; //导入依赖的package包/类
public static boolean isWallpaperActivated() {
final WallpaperManager wallpaperManager = WallpaperManager.getInstance(sApplication);
final WallpaperInfo wallpaperInfo = wallpaperManager.getWallpaperInfo();
boolean active = wallpaperInfo != null && sApplication.getPackageName().equalsIgnoreCase(wallpaperInfo.getPackageName());
LWQLoggerHelper.get().logWallpaperActive(active);
return active;
}
示例5: onActivityResult
import android.app.WallpaperInfo; //导入依赖的package包/类
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == IMAGE_PICK && resultCode == RESULT_OK) {
if (data != null && data.getData() != null) {
Uri uri = data.getData();
addTemporaryWallpaperTile(uri, false);
}
} else if (requestCode == PICK_WALLPAPER_THIRD_PARTY_ACTIVITY) {
setResult(RESULT_OK);
finish();
} else if (requestCode == PICK_LIVE_WALLPAPER) {
WallpaperManager wm = WallpaperManager.getInstance(this);
final WallpaperInfo oldLiveWallpaper = mLiveWallpaperInfoOnPickerLaunch;
final WallpaperInfo clickedWallpaper = mLastClickedLiveWallpaperInfo;
WallpaperInfo newLiveWallpaper = wm.getWallpaperInfo();
// Try to figure out if a live wallpaper was set;
if (newLiveWallpaper != null &&
(oldLiveWallpaper == null
|| !oldLiveWallpaper.getComponent()
.equals(newLiveWallpaper.getComponent())
|| clickedWallpaper.getComponent()
.equals(oldLiveWallpaper.getComponent()))) {
// Return if a live wallpaper was set
setResult(RESULT_OK);
finish();
}
}
}
示例6: toast4Live
import android.app.WallpaperInfo; //导入依赖的package包/类
private void toast4Live() {
if (bundle == null) {
try {
WallpaperInfo info = wm.getWallpaperInfo();
if (info != null) {
info.toString();
mUtils.sendToast(mResources.getString(R.string.last_known_current_live));
}
} catch (NullPointerException ignore) {
}
}
}
示例7: setWallpaper
import android.app.WallpaperInfo; //导入依赖的package包/类
private void setWallpaper() {
final WallpaperManager wallpaperManager = WallpaperManager.getInstance(this);
final WallpaperInfo wallpaperInfo = wallpaperManager.getWallpaperInfo();
String wallpaperId;
if (isCustom) {
wallpaperId = Constants.BG_CUSTOM_ID;
} else {
wallpaperId = catalogItem.getId();
}
sharedPreferences.edit().putString(PREF_BACKGROUND, wallpaperId).apply();
boolean zeroAsLive = true;
// Check if Zero is the current live wallpaper
if (wallpaperInfo == null) {
zeroAsLive = false;
} else {
if (!wallpaperInfo.getServiceName().equals(SERVICE_NAME)) {
zeroAsLive = false;
}
}
if (!zeroAsLive) {
// Show dialog
new AlertDialog.Builder(this)
.setTitle(R.string.set_dialog_notzero_title)
.setMessage(R.string.set_dialog_notzero_message)
.setPositiveButton(R.string.common_ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// Show live-wallpaper preview
openLWSetter(context);
}
})
.setNegativeButton(R.string.common_cancel, null)
.show();
} else {
Toast.makeText(context, R.string.set_alert_changed, Toast.LENGTH_SHORT).show();
}
}
示例8: LiveWallpaperInfo
import android.app.WallpaperInfo; //导入依赖的package包/类
public LiveWallpaperInfo(Drawable thumbnail, WallpaperInfo info) {
mThumbnail = thumbnail;
mInfo = info;
}
示例9: onActivityResult
import android.app.WallpaperInfo; //导入依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_OK) {
switch (requestCode) {
case REQUEST_IMAGE:
int size = prefs.getInt(Bagels.BAGELS_SIZE_KEY, 0);
SharedPreferences.Editor editor = prefs.edit();
for (int i = 1; i <= size; i++) {
editor.putString(Bagels.BAGELS_KEY + i, prefs.getString(Bagels.BAGELS_KEY + (i - 1), null));
}
String path = data.getDataString();
try {
Cursor cursor = getContentResolver().query(data.getData(), null, null, null, null);
String documentId;
if (cursor != null) {
cursor.moveToFirst();
documentId = cursor.getString(0);
documentId = documentId.substring(documentId.lastIndexOf(":") + 1);
cursor.close();
} else break;
cursor = getContentResolver().query(android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI, null, MediaStore.Images.Media._ID + " = ? ", new String[]{documentId}, null);
if (cursor != null) {
cursor.moveToFirst();
path = cursor.getString(cursor.getColumnIndex(MediaStore.Images.Media.DATA));
cursor.close();
}
} catch (Exception e) {
e.printStackTrace();
}
editor.putString(Bagels.BAGELS_KEY + 0, path).putInt(Bagels.BAGELS_SIZE_KEY, size + 1).apply();
((Bagels) getApplicationContext()).getBagels(new Bagels.BagelsListener() {
@Override
public void onBagels(List<Bagel> bagels) {
adapter = new BagelAdapter(getSupportFragmentManager(), bagels);
if (viewPager != null) {
viewPager.setAdapter(adapter);
onPageChange(viewPager.getCurrentItem());
}
}
});
break;
case REQUEST_WALLPAPER:
WallpaperInfo info = WallpaperManager.getInstance(this).getWallpaperInfo();
applyItem.setVisible(info == null || !info.getPackageName().matches(getPackageName()));
break;
}
}
}
示例10: LiveWallpaperTile
import android.app.WallpaperInfo; //导入依赖的package包/类
public LiveWallpaperTile(Drawable thumbnail, WallpaperInfo info, Intent intent) {
mThumbnail = thumbnail;
mInfo = info;
}
示例11: onLiveWallpaperPickerLaunch
import android.app.WallpaperInfo; //导入依赖的package包/类
public void onLiveWallpaperPickerLaunch(WallpaperInfo info) {
mLastClickedLiveWallpaperInfo = info;
mLiveWallpaperInfoOnPickerLaunch = WallpaperManager.getInstance(this).getWallpaperInfo();
}
示例12: isCurrent
import android.app.WallpaperInfo; //导入依赖的package包/类
public static boolean isCurrent(Context context) {
WallpaperManager wm = WallpaperManager.getInstance(context);
WallpaperInfo wi = wm.getWallpaperInfo();
return wi != null && new ComponentName(context, EarthWallpaperService.class)
.equals(wi.getComponent());
}
示例13: onReceive
import android.app.WallpaperInfo; //导入依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction() != null) {
mUtils = new Utils(context);
prefs = context.getSharedPreferences(C.PREF, Context.MODE_PRIVATE);
if (String.valueOf(intent.getAction()).equals("com.lithidsw.wallbox.UPDATE_RANDOMIZER_WALL")) {
int interval = prefs.getInt(C.PREF_RANDOMIZER_INTERVAL, 0);
if (interval > 0) {
final Context con = context;
Thread thread = new Thread() {
@Override
public void run() {
String item = new Utils(con).setRandomizerWallpaperFromFile();
if (item != null) {
prefs.edit().putString(C.PREF_LAST_RANDOMIZER_MD5, item).commit();
}
}
};
thread.start();
}
}
if (String.valueOf(intent.getAction()).equals("com.lithidsw.wallbox.UPDATE_SATURATE_WALL")) {
WallpaperManager wm = WallpaperManager.getInstance(context);
try {
WallpaperInfo info = wm.getWallpaperInfo();
info.toString();
mUtils.stopSaturatedAlarms();
prefs.edit().putBoolean(C.PREF_SATURATE_START, false).commit();
} catch (NullPointerException e) {
int randInt = prefs.getInt(C.PREF_RANDOMIZER_INTERVAL, 0);
if (randInt <= 0) {
mUtils.setSaturatedWallpaperFromFile(false);
} else {
mUtils.setSaturatedWallpaperFromFile(true);
}
}
}
}
}
示例14: init
import android.app.WallpaperInfo; //导入依赖的package包/类
public void init ()
{
WallpaperManager wpman = WallpaperManager.getInstance (this.context);
this.img = wpman.getDrawable ();
try
{
//TODO// Huge memory hog! Need to get rid of this. //
SharedPreferences prefs = this.context.getSharedPreferences ("prefs", Context.MODE_PRIVATE);
this.mode = prefs.getString ("unitywallpaper_blur", "darken");
if (mode.equals ("scale"))
{
Drawable blurred = wpman.getDrawable ();
BitmapDrawable bmdBlurred = (BitmapDrawable) blurred;
Bitmap bmBlurred = bmdBlurred.getBitmap ();
float origWidth = bmBlurred.getWidth ();
float origHeight = bmBlurred.getHeight ();
int width = 200;
int height = (int) (origHeight * (200F / origWidth));
bmBlurred = Bitmap.createScaledBitmap (bmBlurred, width, height, true);
bmBlurred = Bitmap.createScaledBitmap (bmBlurred, (int) origWidth, (int) origHeight, true);
bmdBlurred = new BitmapDrawable (bmBlurred);
this.blurred = bmdBlurred;
}
}
catch (OutOfMemoryError ex) // I'd prefer the image not being blurred over the app crashing //
{
this.blurred = null;
ex.printStackTrace ();
}
WallpaperInfo info = wpman.getWallpaperInfo ();
this.liveWallpaper = (info != null);
}
示例15: wallpaperIsUsed
import android.app.WallpaperInfo; //导入依赖的package包/类
/**
* 判断是否是使用我们的壁纸
*
* @param paramContext
* @return
*/
public static boolean wallpaperIsUsed(Context paramContext) {
WallpaperInfo localWallpaperInfo = WallpaperManager.getInstance(paramContext).getWallpaperInfo();
return ((localWallpaperInfo != null) && (localWallpaperInfo.getPackageName().equals(paramContext.getPackageName())) &&
(localWallpaperInfo.getServiceName().equals(LiveWallpaperService.class.getCanonicalName())));
}