Java Code Examples for android.app.WallpaperManager#getDesiredMinimumHeight()

The following examples show how to use android.app.WallpaperManager#getDesiredMinimumHeight() . 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: WallpaperUtils.java    From Trebuchet with GNU General Public License v3.0 6 votes vote down vote up
public static void suggestWallpaperDimension(Resources res,
        final SharedPreferences sharedPrefs,
        WindowManager windowManager,
        final WallpaperManager wallpaperManager, boolean fallBackToDefaults) {
    final Point defaultWallpaperSize = WallpaperUtils.getDefaultWallpaperSize(res, windowManager);
    // If we have saved a wallpaper width/height, use that instead

    int savedWidth = sharedPrefs.getInt(WALLPAPER_WIDTH_KEY, -1);
    int savedHeight = sharedPrefs.getInt(WALLPAPER_HEIGHT_KEY, -1);

    if (savedWidth == -1 || savedHeight == -1) {
        if (!fallBackToDefaults) {
            return;
        } else {
            savedWidth = defaultWallpaperSize.x;
            savedHeight = defaultWallpaperSize.y;
        }
    }

    if (savedWidth != wallpaperManager.getDesiredMinimumWidth() ||
            savedHeight != wallpaperManager.getDesiredMinimumHeight()) {
        wallpaperManager.suggestDesiredDimensions(savedWidth, savedHeight);
    }
}
 
Example 2
Source File: WallpaperCropActivity.java    From LB-Launcher with Apache License 2.0 6 votes vote down vote up
static public void suggestWallpaperDimension(Resources res,
        final SharedPreferences sharedPrefs,
        WindowManager windowManager,
        final WallpaperManager wallpaperManager, boolean fallBackToDefaults) {
    final Point defaultWallpaperSize = getDefaultWallpaperSize(res, windowManager);
    // If we have saved a wallpaper width/height, use that instead

    int savedWidth = sharedPrefs.getInt(WALLPAPER_WIDTH_KEY, -1);
    int savedHeight = sharedPrefs.getInt(WALLPAPER_HEIGHT_KEY, -1);

    if (savedWidth == -1 || savedHeight == -1) {
        if (!fallBackToDefaults) {
            return;
        } else {
            savedWidth = defaultWallpaperSize.x;
            savedHeight = defaultWallpaperSize.y;
        }
    }

    if (savedWidth != wallpaperManager.getDesiredMinimumWidth() ||
            savedHeight != wallpaperManager.getDesiredMinimumHeight()) {
        wallpaperManager.suggestDesiredDimensions(savedWidth, savedHeight);
    }
}
 
Example 3
Source File: WallpaperCropActivity.java    From TurboLauncher with Apache License 2.0 5 votes vote down vote up
static public void suggestWallpaperDimension(Resources res,
        final SharedPreferences sharedPrefs,
        WindowManager windowManager,
        final WallpaperManager wallpaperManager) {
    final Point defaultWallpaperSize = getDefaultWallpaperSize(res, windowManager);
    // If we have saved a wallpaper width/height, use that instead
    int savedWidth = sharedPrefs.getInt(WALLPAPER_WIDTH_KEY, defaultWallpaperSize.x);
    int savedHeight = sharedPrefs.getInt(WALLPAPER_HEIGHT_KEY, defaultWallpaperSize.y);
    if (savedWidth != wallpaperManager.getDesiredMinimumWidth() ||
            savedHeight != wallpaperManager.getDesiredMinimumHeight()) {
        wallpaperManager.suggestDesiredDimensions(savedWidth, savedHeight);
    }
}
 
Example 4
Source File: BiliWallpaperSource.java    From muzei-bilibili with Apache License 2.0 4 votes vote down vote up
@Override
protected void onTryUpdate(int reason) throws RetryException {

    RestAdapter adapter = new RestAdapter.Builder()
            .setEndpoint("http://h.bilibili.com")
            .setExecutors(mExecutor, mMainExecutor)
            .setClient(new ApacheClient(mClient))
            .build();

    BiliWallpaperService service = adapter.create(BiliWallpaperService.class);
    List<Wallpaper> wallpapers = getWallpapers(service);
    if (wallpapers == null) {
        throw new RetryException();
    }
    if (wallpapers.isEmpty()) {
        Log.w(TAG, "No wallpapers returned from API.");
        scheduleUpdate(System.currentTimeMillis() + UPDATE_TIME_MILLIS);
        return;
    }
    wallpapers.remove(0); // first item is banner place holder
    final Wallpaper wallpaper = selectWallpaper(wallpapers);
    final Wallpaper selectedPaper = getDetail(service, wallpaper);
    if (selectedPaper == null) {
        Log.w(TAG, "No details returned for selected paper from API. id=" + wallpaper.il_id);
        throw new RetryException();
    }
    WallpaperManager manager = WallpaperManager.getInstance(getApplicationContext());
    int minimumHeight = manager.getDesiredMinimumHeight();
    final Resolution pic = selectResolution(selectedPaper, minimumHeight);

    publishArtwork(new Artwork.Builder()
            .imageUri((Uri.parse(pic.il_file.replaceFirst("_m\\.", "_l\\."))))
            .title(pic.title)
            .token(String.valueOf(wallpaper.il_id))
            .byline(wallpaper.author_name + ", "
                    + DateFormat.format("yyyy-MM-dd", wallpaper.posttime * 1000)
                    + "\n" + wallpaper.type)
            .viewIntent(new Intent(Intent.ACTION_VIEW,
                    Uri.parse(wallpaper.author_url)))
            .build());
    scheduleUpdate(System.currentTimeMillis() + UPDATE_TIME_MILLIS);
}