mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 04:43:54 +01:00
Added progress dialog for setting wallpaper (#3427)
* Added progress dialog for setting wallpaper * Updated dialog strings
This commit is contained in:
parent
39cb190571
commit
3d0048a771
2 changed files with 19 additions and 0 deletions
|
|
@ -1,5 +1,6 @@
|
|||
package fr.free.nrw.commons.utils;
|
||||
|
||||
import android.app.ProgressDialog;
|
||||
import android.app.WallpaperManager;
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
|
|
@ -68,6 +69,8 @@ public class ImageUtils {
|
|||
public static final int FILE_NAME_EXISTS = -4;
|
||||
static final int NO_CATEGORY_SELECTED = -5;
|
||||
|
||||
private static ProgressDialog progressDialog;
|
||||
|
||||
@IntDef(
|
||||
flag = true,
|
||||
value = {
|
||||
|
|
@ -188,6 +191,7 @@ public class ImageUtils {
|
|||
* @param imageUrl Url of the image
|
||||
*/
|
||||
public static void setWallpaperFromImageUrl(Context context, Uri imageUrl) {
|
||||
showSettingWallpaperProgressBar(context);
|
||||
Timber.d("Trying to set wallpaper from url %s", imageUrl.toString());
|
||||
ImageRequest imageRequest = ImageRequestBuilder
|
||||
.newBuilderWithSource(imageUrl)
|
||||
|
|
@ -224,11 +228,23 @@ public class ImageUtils {
|
|||
try {
|
||||
wallpaperManager.setBitmap(bitmap);
|
||||
ViewUtil.showLongToast(context, context.getString(R.string.wallpaper_set_successfully));
|
||||
if (progressDialog != null && progressDialog.isShowing()) {
|
||||
progressDialog.dismiss();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
Timber.e(e, "Error setting wallpaper");
|
||||
ViewUtil.showLongToast(context, context.getString(R.string.wallpaper_set_unsuccessfully));
|
||||
if (progressDialog != null) {
|
||||
progressDialog.cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void showSettingWallpaperProgressBar(Context context) {
|
||||
progressDialog = ProgressDialog.show(context, context.getString(R.string.setting_wallpaper_dialog_title),
|
||||
context.getString(R.string.setting_wallpaper_dialog_message), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Result variable is a result of an or operation of all possible problems. Ie. if result
|
||||
* is 0001 means IMAGE_DARK
|
||||
|
|
|
|||
|
|
@ -593,4 +593,7 @@ Upload your first media by tapping on the add button.</string>
|
|||
<string name="upload_nearby_place_found_description">Is this a photo of Place %1$s?</string>
|
||||
<string name="remove_bookmark">Removed from bookmarks</string>
|
||||
<string name="add_bookmark">Added to bookmarks</string>
|
||||
<string name="wallpaper_set_unsuccessfully">Something went wrong. Could not set the wallpaper</string>
|
||||
<string name="setting_wallpaper_dialog_title">Set as Wallpaper</string>
|
||||
<string name="setting_wallpaper_dialog_message">Setting Wallpaper. Please wait…</string>
|
||||
</resources>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue