android.app.WallpaperInfo Java Examples

The following examples show how to use android.app.WallpaperInfo. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WallpaperManagerService.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@Override
public WallpaperInfo getWallpaperInfo(int userId) {
    userId = ActivityManager.handleIncomingUser(Binder.getCallingPid(),
            Binder.getCallingUid(), userId, false, true, "getWallpaperInfo", null);
    synchronized (mLock) {
        WallpaperData wallpaper = mWallpaperMap.get(userId);
        if (wallpaper != null && wallpaper.connection != null) {
            return wallpaper.connection.mInfo;
        }
        return null;
    }
}
 
Example #2
Source File: MainActivity.java    From alynx-live-wallpaper with Apache License 2.0 5 votes vote down vote up
@Override
public void onApplyButtonClicked(@NonNull final WallpaperCard wallpaperCard) {
    final WallpaperInfo info = WallpaperManager.getInstance(this).getWallpaperInfo();
    if (info == null || !Objects.equals(info.getPackageName(), getPackageName())) {
        final AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(R.string.choose_wallpaper_title);
        builder.setMessage(R.string.choose_wallpaper);
        builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                // Only after user click OK, we change currentWallpaperCard.
                LWApplication.setCurrentWallpaperCard(getApplicationContext(), wallpaperCard);
                cardAdapter.notifyDataSetChanged();
                LWApplication.setPreviewWallpaperCard(wallpaperCard);
                Intent intent = new Intent(WallpaperManager.ACTION_LIVE_WALLPAPER_CHOOSER);
                startActivity(intent);
            }
        });
        addDialog = builder.create();
        addDialog.show();
    } else {
        LWApplication.setCurrentWallpaperCard(this, wallpaperCard);
        cardAdapter.notifyDataSetChanged();
        // Display a notice for user.
        Snackbar.make(
            coordinatorLayout,
            String.format(
                getResources().getString(R.string.applied_wallpaper),
                wallpaperCard.getName()
            ),
            Snackbar.LENGTH_LONG
        ).show();
    }
}
 
Example #3
Source File: StatusView.java    From Status with Apache License 2.0 5 votes vote down vote up
public void setTransparent() {
    if (backgroundImage == 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;
            }
        }

        backgroundImage = ImageUtils.cropBitmapToBar(getContext(), me.jfenn.androidutils.ImageUtils.drawableToBitmap(backgroundDrawable));
    }

    if (backgroundImage != null) {
        int color = ColorUtils.getAverageColor(backgroundImage);

        setColor(color);
        if (isTransparentHome)
            needsBackgroundImageDraw = true;
        else backgroundImage = null;
    } else setColor(backgroundColor.getDefault());

    postInvalidate();
}
 
Example #4
Source File: WallpaperPickerActivity.java    From TurboLauncher with Apache License 2.0 5 votes vote down vote up
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();
        }
    }
}
 
Example #5
Source File: WallpaperPickerActivity.java    From LB-Launcher with Apache License 2.0 5 votes vote down vote up
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();
        }
    }
}
 
Example #6
Source File: WallpaperManagerService.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
public WallpaperConnection(WallpaperInfo info, WallpaperData wallpaper) {
    mInfo = info;
    mWallpaper = wallpaper;
}
 
Example #7
Source File: LiveWallpaperListAdapter.java    From Trebuchet with GNU General Public License v3.0 4 votes vote down vote up
public LiveWallpaperTile(Drawable thumbnail, WallpaperInfo info, Intent intent) {
    mThumbnail = thumbnail;
    mInfo = info;
}
 
Example #8
Source File: WallpaperPickerActivity.java    From TurboLauncher with Apache License 2.0 4 votes vote down vote up
public void onLiveWallpaperPickerLaunch(WallpaperInfo info) {
    mLastClickedLiveWallpaperInfo = info;
    mLiveWallpaperInfoOnPickerLaunch = WallpaperManager.getInstance(this).getWallpaperInfo();
}
 
Example #9
Source File: LiveWallpaperListAdapter.java    From TurboLauncher with Apache License 2.0 4 votes vote down vote up
public LiveWallpaperTile(Drawable thumbnail, WallpaperInfo info, Intent intent) {
    mThumbnail = thumbnail;
    mInfo = info;
}
 
Example #10
Source File: WallpaperUtil.java    From earth with GNU General Public License v3.0 4 votes vote down vote up
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());
}
 
Example #11
Source File: WallpaperPickerActivity.java    From LB-Launcher with Apache License 2.0 4 votes vote down vote up
public void onLiveWallpaperPickerLaunch(WallpaperInfo info) {
    mLastClickedLiveWallpaperInfo = info;
    mLiveWallpaperInfoOnPickerLaunch = WallpaperManager.getInstance(this).getWallpaperInfo();
}
 
Example #12
Source File: LiveWallpaperListAdapter.java    From LB-Launcher with Apache License 2.0 4 votes vote down vote up
public LiveWallpaperTile(Drawable thumbnail, WallpaperInfo info, Intent intent) {
    mThumbnail = thumbnail;
    mInfo = info;
}
 
Example #13
Source File: WallpaperUtil.java    From LiveWallpaper with Apache License 2.0 2 votes vote down vote up
/**
 * 判断是否是使用我们的壁纸
 *
 * @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())));
}