List of usage examples for android.app WallpaperManager getInstance
public static WallpaperManager getInstance(Context context)
From source file:io.github.tjg1.nori.fragment.ImageFragment.java
/** * Downloads the full-resolution image in the background and sets it as the wallpaper. *//* w w w . ja v a 2 s .c o m*/ protected void setAsWallpaper() { // Fetch and set full-screen image as wallpaper on background thread. final Context context = getContext(); final String imageUrl = image.fileUrl; final WallpaperManager wallpaperManager = WallpaperManager.getInstance(getContext()); new AsyncTask<Void, Void, Exception>() { @Override protected Exception doInBackground(Void... ignored) { try { InputStream inputStream = new URL(imageUrl).openStream(); wallpaperManager.setStream(inputStream); } catch (IOException e) { return e; } return null; } @Override protected void onPostExecute(Exception error) { if (error != null) { // Show error message to the user. View view = getView(); if (view != null) { Snackbar.make(view, String.format(context.getString(R.string.toast_couldNotSetWallpaper), error.getLocalizedMessage()), Snackbar.LENGTH_LONG).show(); } } } }.execute(); }
From source file:com.designrifts.ultimatethemeui.fragments.FragmentTheme.java
private void applySmartTheme() { WallpaperManager setDefaultWallpaper = WallpaperManager.getInstance(getActivity().getApplicationContext()); try {//w ww. jav a 2 s . c o m Intent smart = getActivity().getPackageManager().getLaunchIntentForPackage("ginlemon.flowerfree"); Intent smartpro = getActivity().getPackageManager().getLaunchIntentForPackage("ginlemon.flowerpro"); if (smart != null) { Intent smartlauncherIntent = new Intent(SMART_PACKAGE); smartlauncherIntent.putExtra("package", getActivity().getPackageName()); startActivity(smartlauncherIntent); setDefaultWallpaper.setResource(R.drawable.wallpaper_default); } else if (smartpro != null) { Intent smartlauncherIntent = new Intent(SMART_PACKAGE); smartlauncherIntent.putExtra("package", getActivity().getPackageName()); startActivity(smartlauncherIntent); setDefaultWallpaper.setResource(R.drawable.wallpaper_default); } else { // Direct users to get Smart Launcher String playStoreUrl = "https://play.google.com/store/apps/details?id=ginlemon.flowerfree"; startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(playStoreUrl))); } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } //finish(); }
From source file:com.chale22.ico01.fragments.FragmentTheme.java
private void applySmartTheme() { WallpaperManager setDefaultWallpaper = WallpaperManager.getInstance(getActivity().getApplicationContext()); try {//from ww w .j a va 2 s.c om Intent smart = getActivity().getPackageManager().getLaunchIntentForPackage("ginlemon.flowerfree"); Intent smartpro = getActivity().getPackageManager().getLaunchIntentForPackage("ginlemon.flowerpro"); if (smart != null) { Intent smartlauncherIntent = new Intent(SMART_PACKAGE); smartlauncherIntent.putExtra("package", getActivity().getPackageName()); startActivity(smartlauncherIntent); setDefaultWallpaper.setResource(R.drawable.wall_1); } else if (smartpro != null) { Intent smartlauncherIntent = new Intent(SMART_PACKAGE); smartlauncherIntent.putExtra("package", getActivity().getPackageName()); startActivity(smartlauncherIntent); setDefaultWallpaper.setResource(R.drawable.wall_1); } else { // Direct users to get Smart Launcher String playStoreUrl = "https://play.google.com/store/apps/details?id=ginlemon.flowerfree"; startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(playStoreUrl))); } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } //finish(); }
From source file:org.meepo.sexygirl.ImagePagerActivity.java
private void setWallpaper(final Image image) { new AsyncTask<String, Void, Void>() { @Override//from w w w . j a v a2s. c o m protected Void doInBackground(String... strings) { WallpaperManager wallpaperManager = WallpaperManager.getInstance(ImagePagerActivity.this); try { URL url = new URL(image.getUrl()); Bitmap bitmap = BitmapFactory.decodeStream(url.openStream()); wallpaperManager.setBitmap(bitmap); ImagePagerActivity.this.runOnUiThread(new Runnable() { @Override public void run() { Toast.makeText(ImagePagerActivity.this, "?", Toast.LENGTH_SHORT).show(); } }); } catch (Exception e) { e.printStackTrace(); ImagePagerActivity.this.runOnUiThread(new Runnable() { @Override public void run() { Toast.makeText(ImagePagerActivity.this, "", Toast.LENGTH_SHORT).show(); } }); } return null; } }.execute(); }
From source file:ooo.oxo.mr.ViewerActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); binding = DataBindingUtil.setContentView(this, R.layout.viewer_activity); setTitle(null);//w w w. j a v a 2 s.com binding.toolbar.setNavigationOnClickListener(v -> supportFinishAfterTransition()); binding.toolbar.inflateMenu(R.menu.viewer); binding.puller.setCallback(this); supportPostponeEnterTransition(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { getWindow().getEnterTransition().addListener(new SimpleTransitionListener() { @Override @TargetApi(Build.VERSION_CODES.LOLLIPOP) public void onTransitionEnd(Transition transition) { getWindow().getEnterTransition().removeListener(this); fadeIn(); } }); } else { fadeIn(); } background = new ColorDrawable(Color.BLACK); binding.getRoot().setBackground(background); adapter = new Adapter(); binding.pager.setAdapter(adapter); binding.pager.setCurrentItem(getIntent().getIntExtra("index", 0)); binding.pager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageScrollStateChanged(int state) { if (state == ViewPager.SCROLL_STATE_DRAGGING) { fadeOut(); } } }); listener = new ObservableListPagerAdapterCallback(adapter); images.addOnListChangedCallback(listener); setEnterSharedElementCallback(new SharedElementCallback() { @Override public void onMapSharedElements(List<String> names, Map<String, View> sharedElements) { Image image = images.get(binding.pager.getCurrentItem()); sharedElements.clear(); sharedElements.put(String.format("%s.image", image.getObjectId()), getCurrent().getSharedElement()); } }); menuItemClicks(R.id.share).compose(bindToLifecycle()) .compose(ensurePermissions(Manifest.permission.WRITE_EXTERNAL_STORAGE)) .map(avoid -> getCurrentImage()) .doOnNext(image -> MobclickAgent.onEvent(this, "share", image.getObjectId())) .observeOn(Schedulers.io()).flatMap(this::saveIfNeeded).observeOn(AndroidSchedulers.mainThread()) .doOnNext(this::notifyMediaScanning).map(Uri::fromFile).retry().subscribe(uri -> { final Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("image/jpeg"); intent.putExtra(Intent.EXTRA_STREAM, uri); startActivity(Intent.createChooser(intent, getString(R.string.share_title))); }); menuItemClicks(R.id.save).compose(bindToLifecycle()) .compose(ensurePermissions(Manifest.permission.WRITE_EXTERNAL_STORAGE)) .map(avoid -> getCurrentImage()) .doOnNext(image -> MobclickAgent.onEvent(this, "save", image.getObjectId())) .observeOn(Schedulers.io()).flatMap(this::saveIfNeeded).observeOn(AndroidSchedulers.mainThread()) .doOnNext(this::notifyMediaScanning).retry().subscribe(file -> { ToastUtil.shorts(this, R.string.save_success, file.getPath()); }); final WallpaperManager wm = WallpaperManager.getInstance(this); menuItemClicks(R.id.set_wallpaper).compose(bindToLifecycle()).map(avoid -> getCurrentImage()) .doOnNext(image -> MobclickAgent.onEvent(this, "set_wallpaper", image.getObjectId())) .observeOn(Schedulers.io()).flatMap(this::download).observeOn(AndroidSchedulers.mainThread()) .map(file -> FileProvider.getUriForFile(this, AUTHORITY_IMAGES, file)).retry().subscribe(uri -> { if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) { startActivity(wm.getCropAndSetWallpaperIntent(uri)); } else { try { wm.setStream(getContentResolver().openInputStream(uri)); ToastUtil.shorts(this, R.string.set_wallpaper_success); } catch (IOException e) { Log.e(TAG, "Failed to set wallpaper", e); ToastUtil.shorts(this, e.getMessage(), e); } } }); }
From source file:de.baumann.thema.FragmentWallpaper.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.wallpaper, container, false); setHasOptionsMenu(true);//from w w w . ja va 2 s .c om final String[] itemTITLE = { getString(R.string.amber) + " - Lollipop", getString(R.string.blue) + " - Lollipop", getString(R.string.green) + " - Lollipop", getString(R.string.grey) + " - Lollipop", getString(R.string.red) + " - Lollipop", getString(R.string.teal) + " - Lollipop", getString(R.string.amber) + " - Marshmallow", getString(R.string.blue) + " - Marshmallow", getString(R.string.green) + " - Marshmallow", getString(R.string.grey) + " - Marshmallow", getString(R.string.red) + " - Marshmallow", getString(R.string.teal) + " - Marshmallow", getString(R.string.amber) + " - Nougat", getString(R.string.blue) + " - Nougat", getString(R.string.green) + " - Nougat", getString(R.string.grey) + " - Nougat", getString(R.string.red) + " - Nougat", getString(R.string.teal) + " - Nougat", }; final String[] itemDES = { "CC license: https://github.com/scoute-dich/Blue-Minimal/blob/master/theme/src/main/res/drawable-nodpi/wp_lp_amber.png", "CC license: https://github.com/scoute-dich/Blue-Minimal/blob/master/theme/src/main/res/drawable-nodpi/wp_lp_blue.png", "CC license: https://github.com/scoute-dich/Blue-Minimal/blob/master/theme/src/main/res/drawable-nodpi/wp_lp_green.png", "CC license: https://github.com/scoute-dich/Blue-Minimal/blob/master/theme/src/main/res/drawable-nodpi/wp_lp_grey.png", "CC license: https://github.com/scoute-dich/Blue-Minimal/blob/master/theme/src/main/res/drawable-nodpi/wp_lp_red.png", "CC license: https://github.com/scoute-dich/Blue-Minimal/blob/master/theme/src/main/res/drawable-nodpi/wp_lp_teal.png", "CC license: https://github.com/scoute-dich/Blue-Minimal/blob/master/theme/src/main/res/drawable-nodpi/wp_mm_amber.png", "CC license: https://github.com/scoute-dich/Blue-Minimal/blob/master/theme/src/main/res/drawable-nodpi/wp_mm_blue.png", "CC license: https://github.com/scoute-dich/Blue-Minimal/blob/master/theme/src/main/res/drawable-nodpi/wp_mm_green.png", "CC license: https://github.com/scoute-dich/Blue-Minimal/blob/master/theme/src/main/res/drawable-nodpi/wp_mm_grey.png", "CC license: https://github.com/scoute-dich/Blue-Minimal/blob/master/theme/src/main/res/drawable-nodpi/wp_mm_red.png", "CC license: https://github.com/scoute-dich/Blue-Minimal/blob/master/theme/src/main/res/drawable-nodpi/wp_mm_teal.png", "CC license: https://github.com/scoute-dich/Blue-Minimal/blob/master/theme/src/main/res/drawable-nodpi/wp_n_amber.png", "CC license: https://github.com/scoute-dich/Blue-Minimal/blob/master/theme/src/main/res/drawable-nodpi/wp_n_blue.png", "CC license: https://github.com/scoute-dich/Blue-Minimal/blob/master/theme/src/main/res/drawable-nodpi/wp_n_green.png", "CC license: https://github.com/scoute-dich/Blue-Minimal/blob/master/theme/src/main/res/drawable-nodpi/wp_n_grey.png", "CC license: https://github.com/scoute-dich/Blue-Minimal/blob/master/theme/src/main/res/drawable-nodpi/wp_mm_red.png", "CC license: https://github.com/scoute-dich/Blue-Minimal/blob/master/theme/src/main/res/drawable-nodpi/wp_mm_teal.png", }; final int[] itemPATH = { R.drawable.wp_lp_amber, R.drawable.wp_lp_blue, R.drawable.wp_lp_green, R.drawable.wp_lp_grey, R.drawable.wp_lp_red, R.drawable.wp_lp_teal, R.drawable.wp_mm_amber, R.drawable.wp_mm_blue, R.drawable.wp_mm_green, R.drawable.wp_mm_grey, R.drawable.wp_mm_red, R.drawable.wp_mm_teal, R.drawable.wp_n_amber, R.drawable.wp_n_blue, R.drawable.wp_n_green, R.drawable.wp_n_grey, R.drawable.wp_n_red, R.drawable.wp_n_teal, }; final int[] itemPATHPREV = { R.drawable.wp_lp_amber_preview, R.drawable.wp_lp_blue_preview, R.drawable.wp_lp_green_preview, R.drawable.wp_lp_grey_preview, R.drawable.wp_lp_red_preview, R.drawable.wp_lp_teal_preview, R.drawable.wp_mm_amber_preview, R.drawable.wp_mm_blue_preview, R.drawable.wp_mm_green_preview, R.drawable.wp_mm_grey_preview, R.drawable.wp_mm_red_preview, R.drawable.wp_mm_teal_preview, R.drawable.wp_n_amber_preview, R.drawable.wp_n_blue_preview, R.drawable.wp_n_green_preview, R.drawable.wp_n_grey_preview, R.drawable.wp_n_red_preview, R.drawable.wp_n_teal_preview, }; imgHeader = (ImageView) rootView.findViewById(R.id.imageView_header); if (imgHeader != null) { TypedArray images = getResources().obtainTypedArray(R.array.splash_images); int choice = (int) (Math.random() * images.length()); imgHeader.setImageResource(images.getResourceId(choice, R.drawable.wp_lp_amber)); images.recycle(); } CustomListAdapter_Wallpaper adapter = new CustomListAdapter_Wallpaper(getActivity(), itemTITLE, itemDES, itemPATH, itemPATHPREV); ListView listView = (ListView) rootView.findViewById(R.id.bookmarks); listView.setAdapter(adapter); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // TODO Auto-generated method stub int Selecteditem = itemPATH[+position]; assert imgHeader != null; imgHeader.setImageResource(Selecteditem); } }); listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { final String SelecteditemUrl = itemDES[+position].substring(12); Uri uri = Uri.parse(SelecteditemUrl); // missing 'http://' will cause crashed Intent intent = new Intent(Intent.ACTION_VIEW, uri); startActivity(intent); return true; } }); FloatingActionButton fab = (FloatingActionButton) rootView.findViewById(R.id.fab_wp); fab.setImageResource(R.drawable.check); fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if ((imgHeader != null ? imgHeader.getDrawable() : null) == null) { Snackbar.make(imgHeader, R.string.check_wallpaper, Snackbar.LENGTH_LONG).show(); } else { Snackbar.make(imgHeader, R.string.applying, Snackbar.LENGTH_LONG).show(); WallpaperManager myWallpaperManager = WallpaperManager.getInstance(getActivity()); try { Bitmap bitmap = ((BitmapDrawable) imgHeader.getDrawable()).getBitmap(); if (bitmap != null) myWallpaperManager.setBitmap(bitmap); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } }); return rootView; }
From source file:com.cuddlesoft.nori.fragment.ImageFragment.java
/** * Downloads the full-resolution image in the background and sets it as the wallpaper. *///from w w w . j av a2s. co m protected void setAsWallpaper() { // Fetch and set full-screen image as wallpaper on background thread. final Context context = getActivity(); final String imageUrl = image.fileUrl; final WallpaperManager wallpaperManager = WallpaperManager.getInstance(getActivity()); new AsyncTask<Void, Void, Exception>() { @Override protected Exception doInBackground(Void... ignored) { try { InputStream inputStream = new URL(imageUrl).openStream(); wallpaperManager.setStream(inputStream); } catch (IOException e) { return e; } return null; } @Override protected void onPostExecute(Exception error) { if (error != null) { // Show error message to the user. Toast.makeText(context, String.format(context.getString(R.string.toast_couldNotSetWallpaper), error.getLocalizedMessage()), Toast.LENGTH_LONG).show(); } } }.execute(); }
From source file:com.example.wojtekswiderski.woahpaper.GcmIntentService.java
public boolean setWallPaper(int start) { DisplayMetrics displayMetrics = getResources().getDisplayMetrics(); int height = displayMetrics.heightPixels; int width = displayMetrics.widthPixels; String url = "https://ajax.googleapis.com/ajax/services/search/images?v=1.0&rsz=1&q=" + word + "&start=" + start;/*from w ww .j a v a 2s .c o m*/ String imageUrl; try { URL obj = new URL(url); HttpURLConnection con = (HttpURLConnection) obj.openConnection(); con.setRequestMethod("GET"); BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream())); String inputLine; StringBuffer response = new StringBuffer(); while ((inputLine = in.readLine()) != null) { response.append(inputLine); } in.close(); JSONObject deliverable; try { deliverable = new JSONObject(response.toString()); imageUrl = deliverable.getJSONObject("responseData").getJSONArray("results").getJSONObject(0) .getString("url"); Log.i(TAG, imageUrl); URL imageObj = new URL(imageUrl); Bitmap bmp = BitmapFactory.decodeStream(imageObj.openConnection().getInputStream()); int x = bmp.getWidth(); int y = bmp.getHeight(); double ratioX = ((double) x) / ((double) width); double ratioY = ((double) y) / ((double) height); Log.i(TAG, "Width: " + width + " Height: " + height); Log.i(TAG, "X: " + x + " Y: " + y); Log.i(TAG, "RatioX: " + ratioX + " RatioY: " + ratioY); if (ratioX > ratioY) { bmp = Bitmap.createScaledBitmap(bmp, (int) (((double) x) / ratioY), height, false); } else { bmp = Bitmap.createScaledBitmap(bmp, width, (int) (((double) y) / ratioX), false); } Log.i(TAG, "newX: " + bmp.getWidth() + " newY: " + bmp.getHeight()); Bitmap bmpBack = Bitmap.createBitmap(getWallpaperDesiredMinimumWidth(), getWallpaperDesiredMinimumHeight(), Bitmap.Config.ARGB_8888); Bitmap bmOverlay = Bitmap.createBitmap(bmpBack.getWidth(), bmpBack.getHeight(), bmpBack.getConfig()); Canvas canvas = new Canvas(bmOverlay); canvas.drawBitmap(bmpBack, new Matrix(), null); canvas.drawBitmap(bmp, getWallpaperDesiredMinimumWidth() / 2 - bmp.getWidth() / 2, 0, null); WallpaperManager wpm = WallpaperManager.getInstance(this); wpm.setBitmap(bmOverlay); } catch (JSONException ex) { Log.e(TAG, "Could not convert to object"); ex.printStackTrace(); return true; } } catch (MalformedURLException ex) { ex.printStackTrace(); Log.e(TAG, "Wrong url"); return true; } catch (IOException ey) { ey.printStackTrace(); Log.e(TAG, "Server down"); return true; } return false; }
From source file:de.baumann.thema.FragmentWallpaper.java
@Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); if (id == R.id.color) { ColorPickerDialogBuilder.with(getActivity()).initialColor(0xff2196f3).setTitle(R.string.custom) .wheelType(ColorPickerView.WHEEL_TYPE.FLOWER).density(9) .setPositiveButton(R.string.yes, new ColorPickerClickListener() { @Override/* w w w.ja v a 2 s . co m*/ public void onClick(DialogInterface dialog, int selectedColor, Integer[] allColors) { try { WallpaperManager wm = WallpaperManager.getInstance(getActivity()); // Create 1x1 bitmap to store the color Bitmap bmp = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888); // Make a canvas with which we can draw to the bitmap Canvas canvas = new Canvas(bmp); // Fill with color and save canvas.drawColor(selectedColor); canvas.save(); wm.setBitmap(bmp); bmp.recycle(); Snackbar.make(imgHeader, R.string.applying, Snackbar.LENGTH_LONG).show(); } catch (IOException e) { // oh lord! } } }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }).build().show(); return false; } if (id == R.id.help) { SpannableString s; if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) { s = new SpannableString( Html.fromHtml(getString(R.string.help_wallpaper), Html.FROM_HTML_MODE_LEGACY)); } else { //noinspection deprecation s = new SpannableString(Html.fromHtml(getString(R.string.help_wallpaper))); } Linkify.addLinks(s, Linkify.WEB_URLS); final AlertDialog.Builder dialog = new AlertDialog.Builder(getActivity()) .setTitle(R.string.title_wallpaper).setMessage(s) .setPositiveButton(getString(R.string.yes), null); dialog.show(); return false; } return super.onOptionsItemSelected(item); }
From source file:com.moonpi.tapunlock.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Get lobster_two asset and create typeface // Set action bar title to lobster_two typeface lobsterTwo = Typeface.createFromAsset(getAssets(), "lobster_two.otf"); int actionBarTitle = Resources.getSystem().getIdentifier("action_bar_title", "id", "android"); actionBarTitleView = (TextView) getWindow().findViewById(actionBarTitle); if (actionBarTitleView != null) { actionBarTitleView.setTypeface(lobsterTwo); actionBarTitleView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 28f); actionBarTitleView.setTextColor(getResources().getColor(R.color.blue)); }//from www . j a v a2 s. c o m setContentView(R.layout.activity_main); // Hide keyboard on app launch this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); // Get NFC service and adapter NfcManager nfcManager = (NfcManager) this.getSystemService(Context.NFC_SERVICE); nfcAdapter = nfcManager.getDefaultAdapter(); // Create PendingIntent for enableForegroundDispatch for NFC tag discovery pIntent = PendingIntent.getActivity(this, 0, new Intent(this, getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0); readFromJSON(); writeToJSON(); readFromJSON(); // If Android 4.2 or bigger if (Build.VERSION.SDK_INT > 16) { // Check if TapUnlock folder exists, if not, create directory File folder = new File(Environment.getExternalStorageDirectory() + "/TapUnlock"); boolean folderSuccess = true; if (!folder.exists()) { folderSuccess = folder.mkdir(); } try { // If blur var bigger than 0 if (settings.getInt("blur") > 0) { // If folder exists or successfully created if (folderSuccess) { // If blurred wallpaper file doesn't exist if (!ImageUtils.doesBlurredWallpaperExist()) { // Get default wallpaper WallpaperManager wallpaperManager = WallpaperManager.getInstance(this); final Drawable wallpaperDrawable = wallpaperManager.peekFastDrawable(); if (wallpaperDrawable != null) { // Default wallpaper to bitmap - fastBlur the bitmap - store bitmap new Thread(new Runnable() { @Override public void run() { Bitmap bitmapToBlur = ImageUtils.drawableToBitmap(wallpaperDrawable); Bitmap blurredWallpaper = null; if (bitmapToBlur != null) blurredWallpaper = ImageUtils.fastBlur(MainActivity.this, bitmapToBlur, blur); if (blurredWallpaper != null) { ImageUtils.storeImage(blurredWallpaper); } } }).start(); } } } } } catch (JSONException e) { e.printStackTrace(); } } // Initialize layout items pinEdit = (EditText) findViewById(R.id.pinEdit); pinEdit.setImeOptions(EditorInfo.IME_ACTION_DONE); Button setPin = (Button) findViewById(R.id.setPin); ImageButton newTag = (ImageButton) findViewById(R.id.newTag); enabled_disabled = (TextView) findViewById(R.id.enabled_disabled); Switch toggle = (Switch) findViewById(R.id.toggle); seekBar = (SeekBar) findViewById(R.id.seekBar); progressBar = (ProgressBar) findViewById(R.id.progressBar); Button refreshWallpaper = (Button) findViewById(R.id.refreshWallpaper); listView = (ListView) findViewById(R.id.listView); backgroundBlurValue = (TextView) findViewById(R.id.backgroundBlurValue); noTags = (TextView) findViewById(R.id.noTags); // Initialize TagAdapter adapter = new TagAdapter(this, tags); registerForContextMenu(listView); // Set listView adapter to TapAdapter object listView.setAdapter(adapter); // Set click, check and seekBar listeners setPin.setOnClickListener(this); newTag.setOnClickListener(this); refreshWallpaper.setOnClickListener(this); toggle.setOnCheckedChangeListener(this); seekBar.setOnSeekBarChangeListener(this); // Set seekBar progress to blur var try { seekBar.setProgress(settings.getInt("blur")); } catch (JSONException e) { e.printStackTrace(); } // Refresh the listView height updateListViewHeight(listView); // If no tags, show 'Press + to add Tags' textView if (tags.length() == 0) noTags.setVisibility(View.VISIBLE); else noTags.setVisibility(View.INVISIBLE); // Scroll up scrollView = (ScrollView) findViewById(R.id.scrollView); scrollView.post(new Runnable() { public void run() { scrollView.scrollTo(0, scrollView.getTop()); scrollView.fullScroll(View.FOCUS_UP); } }); // If lockscreen enabled, initialize switch, text and start service try { if (settings.getBoolean("lockscreen")) { onStart = true; enabled_disabled.setText(R.string.lockscreen_enabled); enabled_disabled.setTextColor(getResources().getColor(R.color.green)); toggle.setChecked(true); } } catch (JSONException e1) { e1.printStackTrace(); } }