diff options
author | Alex Ning <chineseperson5@gmail.com> | 2020-06-15 06:48:16 +0000 |
---|---|---|
committer | Alex Ning <chineseperson5@gmail.com> | 2020-06-15 06:48:16 +0000 |
commit | e8e85b963143d111b13373ea225fe948e316de8e (patch) | |
tree | 599e1d02835fc9f478506153d6814d24137e8b25 /app/src/main | |
parent | 4d753fc562864a44a1ee30fbaad785311b5e790a (diff) | |
download | infinity-for-reddit-e8e85b963143d111b13373ea225fe948e316de8e.tar infinity-for-reddit-e8e85b963143d111b13373ea225fe948e316de8e.tar.gz infinity-for-reddit-e8e85b963143d111b13373ea225fe948e316de8e.tar.bz2 infinity-for-reddit-e8e85b963143d111b13373ea225fe948e316de8e.tar.lz infinity-for-reddit-e8e85b963143d111b13373ea225fe948e316de8e.tar.xz infinity-for-reddit-e8e85b963143d111b13373ea225fe948e316de8e.tar.zst infinity-for-reddit-e8e85b963143d111b13373ea225fe948e316de8e.zip |
Set image as wallpaper.
Diffstat (limited to '')
18 files changed, 463 insertions, 12 deletions
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 2a2a74bd..ff60bc3f 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -4,6 +4,8 @@ package="ml.docilealligator.infinityforreddit"> <uses-permission android:name="android.permission.INTERNET" /> + <uses-permission android:name="android.permission.SET_WALLPAPER" /> + <uses-permission android:name="android.permission.SET_WALLPAPER_HINTS" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="22" /> diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewGIFActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewGIFActivity.java index cafbaed4..a1802a90 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewGIFActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewGIFActivity.java @@ -218,7 +218,7 @@ public class ViewGIFActivity extends AppCompatActivity { return true; case R.id.action_share_view_gif_activity: - Toast.makeText(ViewGIFActivity.this, R.string.save_gif_before_sharing, Toast.LENGTH_SHORT).show(); + Toast.makeText(ViewGIFActivity.this, R.string.save_gif_first, Toast.LENGTH_SHORT).show(); glide.asGif().load(mImageUrl).listener(new RequestListener<GifDrawable>() { @Override public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<GifDrawable> target, boolean isFirstResource) { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewImageActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewImageActivity.java index ea3bde7f..76acf253 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewImageActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewImageActivity.java @@ -2,21 +2,26 @@ package ml.docilealligator.infinityforreddit.Activity; import android.Manifest; import android.app.DownloadManager; +import android.app.WallpaperManager; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.content.pm.PackageManager; import android.graphics.Bitmap; +import android.graphics.Rect; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; +import android.media.ThumbnailUtils; import android.net.Uri; import android.os.Build; import android.os.Bundle; import android.os.Environment; import android.text.Html; +import android.util.DisplayMetrics; import android.view.Menu; import android.view.MenuItem; import android.view.View; +import android.view.WindowManager; import android.widget.LinearLayout; import android.widget.ProgressBar; import android.widget.Toast; @@ -41,6 +46,7 @@ import com.bumptech.glide.request.transition.Transition; import com.thefuntasty.hauler.HaulerView; import java.io.File; +import java.io.IOException; import javax.inject.Inject; import javax.inject.Named; @@ -48,6 +54,7 @@ import javax.inject.Named; import butterknife.BindView; import butterknife.ButterKnife; import ml.docilealligator.infinityforreddit.AsyncTask.SaveImageToFileAsyncTask; +import ml.docilealligator.infinityforreddit.BottomSheetFragment.SetAsWallpaperBottomSheetFragment; import ml.docilealligator.infinityforreddit.BuildConfig; import ml.docilealligator.infinityforreddit.Font.ContentFontFamily; import ml.docilealligator.infinityforreddit.Font.ContentFontStyle; @@ -57,9 +64,10 @@ import ml.docilealligator.infinityforreddit.Font.TitleFontFamily; import ml.docilealligator.infinityforreddit.Font.TitleFontStyle; import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.R; +import ml.docilealligator.infinityforreddit.SetAsWallpaperCallback; import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; -public class ViewImageActivity extends AppCompatActivity { +public class ViewImageActivity extends AppCompatActivity implements SetAsWallpaperCallback { public static final String IMAGE_URL_KEY = "IUK"; public static final String FILE_NAME_KEY = "FNK"; @@ -224,7 +232,7 @@ public class ViewImageActivity extends AppCompatActivity { @Override public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) { if (getExternalCacheDir() != null) { - Toast.makeText(ViewImageActivity.this, R.string.save_image_before_sharing, Toast.LENGTH_SHORT).show(); + Toast.makeText(ViewImageActivity.this, R.string.save_image_first, Toast.LENGTH_SHORT).show(); new SaveImageToFileAsyncTask(resource, getExternalCacheDir().getPath(), mImageFileName, new SaveImageToFileAsyncTask.SaveImageToFileAsyncTaskListener() { @Override @@ -257,6 +265,15 @@ public class ViewImageActivity extends AppCompatActivity { } }); return true; + + case R.id.action_set_wallpaper_view_image_activity: + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { + SetAsWallpaperBottomSheetFragment setAsWallpaperBottomSheetFragment = new SetAsWallpaperBottomSheetFragment(); + setAsWallpaperBottomSheetFragment.show(getSupportFragmentManager(), setAsWallpaperBottomSheetFragment.getTag()); + } else { + setAsWallpaper(2); + } + return true; } return false; @@ -317,4 +334,84 @@ public class ViewImageActivity extends AppCompatActivity { manager.enqueue(request); Toast.makeText(this, R.string.download_started, Toast.LENGTH_SHORT).show(); } + + private void setAsWallpaper(int setTo) { + Toast.makeText(ViewImageActivity.this, R.string.save_image_first, Toast.LENGTH_SHORT).show(); + glide.asBitmap().load(mImageUrl).into(new CustomTarget<Bitmap>() { + @Override + public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) { + WallpaperManager manager = WallpaperManager.getInstance(ViewImageActivity.this); + + DisplayMetrics metrics = new DisplayMetrics(); + WindowManager windowManager = (WindowManager) getSystemService(Context.WINDOW_SERVICE); + + Rect rect = null; + + if (windowManager != null) { + windowManager.getDefaultDisplay().getMetrics(metrics); + int height = metrics.heightPixels; + int width = metrics.widthPixels; + + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) { + resource = ThumbnailUtils.extractThumbnail(resource, width, height); + } + + float imageAR = (float) resource.getWidth() / (float) resource.getHeight(); + float screenAR = (float) width / (float) height; + + if (imageAR > screenAR) { + int desiredWidth = (int) (resource.getHeight() * screenAR); + rect = new Rect((resource.getWidth() - desiredWidth) / 2, 0, resource.getWidth(), resource.getHeight()); + } else { + int desiredHeight = (int) (resource.getWidth() / screenAR); + rect = new Rect(0, (resource.getHeight() - desiredHeight) / 2, resource.getWidth(), (resource.getHeight() + desiredHeight) / 2); + } + } + try { + switch (setTo) { + case 0: + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { + manager.setBitmap(resource, rect, true, WallpaperManager.FLAG_SYSTEM); + } + break; + case 1: + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { + manager.setBitmap(resource, rect, true, WallpaperManager.FLAG_LOCK); + } + break; + case 2: + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { + manager.setBitmap(resource, rect, true, WallpaperManager.FLAG_SYSTEM | WallpaperManager.FLAG_LOCK); + } else { + manager.setBitmap(resource); + } + break; + } + Toast.makeText(ViewImageActivity.this, R.string.wallpaper_set, Toast.LENGTH_SHORT).show(); + } catch (IOException e) { + Toast.makeText(ViewImageActivity.this, R.string.error_set_wallpaper, Toast.LENGTH_SHORT).show(); + } + } + + @Override + public void onLoadCleared(@Nullable Drawable placeholder) { + + } + }); + } + + @Override + public void setToHomeScreen(int viewPagerPosition) { + setAsWallpaper(0); + } + + @Override + public void setToLockScreen(int viewPagerPosition) { + setAsWallpaper(1); + } + + @Override + public void setToBoth(int viewPagerPosition) { + setAsWallpaper(2); + } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewImgurMediaActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewImgurMediaActivity.java index f38315db..c4b0e38d 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewImgurMediaActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewImgurMediaActivity.java @@ -1,17 +1,27 @@ package ml.docilealligator.infinityforreddit.Activity; +import android.app.WallpaperManager; +import android.content.Context; import android.content.SharedPreferences; +import android.graphics.Bitmap; +import android.graphics.Rect; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; +import android.media.ThumbnailUtils; import android.os.AsyncTask; +import android.os.Build; import android.os.Bundle; +import android.util.DisplayMetrics; import android.view.Menu; import android.view.MenuItem; import android.view.View; +import android.view.WindowManager; import android.widget.LinearLayout; import android.widget.ProgressBar; +import android.widget.Toast; import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.AppCompatActivity; import androidx.fragment.app.Fragment; @@ -19,12 +29,16 @@ import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentStatePagerAdapter; import androidx.viewpager.widget.ViewPager; +import com.bumptech.glide.Glide; +import com.bumptech.glide.request.target.CustomTarget; +import com.bumptech.glide.request.transition.Transition; import com.thefuntasty.hauler.HaulerView; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; +import java.io.IOException; import java.util.ArrayList; import javax.inject.Inject; @@ -44,6 +58,7 @@ import ml.docilealligator.infinityforreddit.Fragment.ViewImgurVideoFragment; import ml.docilealligator.infinityforreddit.ImgurMedia; import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.R; +import ml.docilealligator.infinityforreddit.SetAsWallpaperCallback; import ml.docilealligator.infinityforreddit.Utils.APIUtils; import ml.docilealligator.infinityforreddit.Utils.JSONUtils; import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; @@ -52,7 +67,7 @@ import retrofit2.Callback; import retrofit2.Response; import retrofit2.Retrofit; -public class ViewImgurMediaActivity extends AppCompatActivity { +public class ViewImgurMediaActivity extends AppCompatActivity implements SetAsWallpaperCallback { public static final String EXTRA_IMGUR_TYPE = "EIT"; public static final String EXTRA_IMGUR_ID = "EII"; @@ -300,6 +315,90 @@ public class ViewImgurMediaActivity extends AppCompatActivity { outState.putParcelableArrayList(IMGUR_IMAGES_STATE, images); } + public void setAsWallpaper(String link, int setTo) { + Toast.makeText(ViewImgurMediaActivity.this, R.string.save_image_first, Toast.LENGTH_SHORT).show(); + Glide.with(this).asBitmap().load(link).into(new CustomTarget<Bitmap>() { + @Override + public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) { + WallpaperManager manager = WallpaperManager.getInstance(ViewImgurMediaActivity.this); + + DisplayMetrics metrics = new DisplayMetrics(); + WindowManager windowManager = (WindowManager) getSystemService(Context.WINDOW_SERVICE); + + Rect rect = null; + + if (windowManager != null) { + windowManager.getDefaultDisplay().getMetrics(metrics); + int height = metrics.heightPixels; + int width = metrics.widthPixels; + + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) { + resource = ThumbnailUtils.extractThumbnail(resource, width, height); + } + + float imageAR = (float) resource.getWidth() / (float) resource.getHeight(); + float screenAR = (float) width / (float) height; + + if (imageAR > screenAR) { + int desiredWidth = (int) (resource.getHeight() * screenAR); + rect = new Rect((resource.getWidth() - desiredWidth) / 2, 0, resource.getWidth(), resource.getHeight()); + } else { + int desiredHeight = (int) (resource.getWidth() / screenAR); + rect = new Rect(0, (resource.getHeight() - desiredHeight) / 2, resource.getWidth(), (resource.getHeight() + desiredHeight) / 2); + } + } + try { + switch (setTo) { + case 0: + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { + manager.setBitmap(resource, rect, true, WallpaperManager.FLAG_SYSTEM); + } + break; + case 1: + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { + manager.setBitmap(resource, rect, true, WallpaperManager.FLAG_LOCK); + } + break; + case 2: + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { + manager.setBitmap(resource, rect, true, WallpaperManager.FLAG_SYSTEM | WallpaperManager.FLAG_LOCK); + } else { + manager.setBitmap(resource); + } + break; + } + Toast.makeText(ViewImgurMediaActivity.this, R.string.wallpaper_set, Toast.LENGTH_SHORT).show(); + } catch (IOException e) { + Toast.makeText(ViewImgurMediaActivity.this, R.string.error_set_wallpaper, Toast.LENGTH_SHORT).show(); + } + } + + @Override + public void onLoadCleared(@Nullable Drawable placeholder) { + + } + }); + } + + @Override + public void setToHomeScreen(int viewPagerPosition) { + setAsWallpaper(images.get(viewPagerPosition).getLink(), 0); + } + + @Override + public void setToLockScreen(int viewPagerPosition) { + setAsWallpaper(images.get(viewPagerPosition).getLink(), 1); + } + + @Override + public void setToBoth(int viewPagerPosition) { + setAsWallpaper(images.get(viewPagerPosition).getLink(), 2); + } + + public int getCurrentPagePosition() { + return viewPager.getCurrentItem(); + } + private class SectionsPagerAdapter extends FragmentStatePagerAdapter { SectionsPagerAdapter(@NonNull FragmentManager fm) { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/SetAsWallpaperBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/SetAsWallpaperBottomSheetFragment.java new file mode 100644 index 00000000..db6e80e9 --- /dev/null +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/SetAsWallpaperBottomSheetFragment.java @@ -0,0 +1,79 @@ +package ml.docilealligator.infinityforreddit.BottomSheetFragment; + +import android.app.Activity; +import android.content.Context; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +import androidx.annotation.NonNull; + +import com.deishelon.roundedbottomsheet.RoundedBottomSheetDialogFragment; + +import butterknife.BindView; +import butterknife.ButterKnife; +import ml.docilealligator.infinityforreddit.R; +import ml.docilealligator.infinityforreddit.SetAsWallpaperCallback; + +public class SetAsWallpaperBottomSheetFragment extends RoundedBottomSheetDialogFragment { + + public static final String EXTRA_VIEW_PAGER_POSITION = "EVPP"; + + @BindView(R.id.home_screen_text_view_set_as_wallpaper_bottom_sheet_fragment) + TextView homeScreenTextvView; + @BindView(R.id.lock_screen_text_view_set_as_wallpaper_bottom_sheet_fragment) + TextView lockScreenTextView; + @BindView(R.id.both_text_view_set_as_wallpaper_bottom_sheet_fragment) + TextView bothTextView; + private Activity mActivity; + + public SetAsWallpaperBottomSheetFragment() { + // Required empty public constructor + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + View rootView = inflater.inflate(R.layout.fragment_set_as_wallpaper_bottom_sheet, container, false); + ButterKnife.bind(this, rootView); + + Bundle bundle = getArguments(); + int viewPagerPosition = bundle == null ? -1 : bundle.getInt(EXTRA_VIEW_PAGER_POSITION); + + bothTextView.setOnClickListener(view -> { + if (mActivity instanceof SetAsWallpaperCallback) { + ((SetAsWallpaperCallback) mActivity).setToBoth(viewPagerPosition); + } + dismiss(); + }); + + if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) { + homeScreenTextvView.setVisibility(View.VISIBLE); + lockScreenTextView.setVisibility(View.VISIBLE); + + homeScreenTextvView.setOnClickListener(view -> { + if (mActivity instanceof SetAsWallpaperCallback) { + ((SetAsWallpaperCallback) mActivity).setToHomeScreen(viewPagerPosition); + } + dismiss(); + }); + + lockScreenTextView.setOnClickListener(view -> { + if (mActivity instanceof SetAsWallpaperCallback) { + ((SetAsWallpaperCallback) mActivity).setToLockScreen(viewPagerPosition); + } + dismiss(); + }); + } + + return rootView; + } + + @Override + public void onAttach(@NonNull Context context) { + super.onAttach(context); + this.mActivity = (Activity) context; + } +}
\ No newline at end of file diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/ViewImgurImageFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/ViewImgurImageFragment.java index ae047287..0319c904 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/ViewImgurImageFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/ViewImgurImageFragment.java @@ -1,7 +1,6 @@ package ml.docilealligator.infinityforreddit.Fragment; import android.Manifest; -import android.app.Activity; import android.app.DownloadManager; import android.content.Context; import android.content.Intent; @@ -43,7 +42,9 @@ import java.io.File; import butterknife.BindView; import butterknife.ButterKnife; +import ml.docilealligator.infinityforreddit.Activity.ViewImgurMediaActivity; import ml.docilealligator.infinityforreddit.AsyncTask.SaveImageToFileAsyncTask; +import ml.docilealligator.infinityforreddit.BottomSheetFragment.SetAsWallpaperBottomSheetFragment; import ml.docilealligator.infinityforreddit.BuildConfig; import ml.docilealligator.infinityforreddit.ImgurMedia; import ml.docilealligator.infinityforreddit.R; @@ -60,7 +61,7 @@ public class ViewImgurImageFragment extends Fragment { @BindView(R.id.load_image_error_linear_layout_view_imgur_image_fragment) LinearLayout errorLinearLayout; - private Activity activity; + private ViewImgurMediaActivity activity; private RequestManager glide; private ImgurMedia imgurMedia; private boolean isDownloading = false; @@ -143,7 +144,7 @@ public class ViewImgurImageFragment extends Fragment { @Override public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) { if (activity.getExternalCacheDir() != null) { - Toast.makeText(activity, R.string.save_image_before_sharing, Toast.LENGTH_SHORT).show(); + Toast.makeText(activity, R.string.save_image_first, Toast.LENGTH_SHORT).show(); new SaveImageToFileAsyncTask(resource, activity.getExternalCacheDir().getPath(), imgurMedia.getFileName(), new SaveImageToFileAsyncTask.SaveImageToFileAsyncTaskListener() { @@ -177,6 +178,17 @@ public class ViewImgurImageFragment extends Fragment { } }); return true; + case R.id.action_set_wallpaper_view_imgur_image_fragments: + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { + SetAsWallpaperBottomSheetFragment setAsWallpaperBottomSheetFragment = new SetAsWallpaperBottomSheetFragment(); + Bundle bundle = new Bundle(); + bundle.putInt(SetAsWallpaperBottomSheetFragment.EXTRA_VIEW_PAGER_POSITION, activity.getCurrentPagePosition()); + setAsWallpaperBottomSheetFragment.setArguments(bundle); + setAsWallpaperBottomSheetFragment.show(activity.getSupportFragmentManager(), setAsWallpaperBottomSheetFragment.getTag()); + } else { + activity.setAsWallpaper(imgurMedia.getLink(), 2); + } + return true; } return false; @@ -241,6 +253,6 @@ public class ViewImgurImageFragment extends Fragment { @Override public void onAttach(@NonNull Context context) { super.onAttach(context); - activity = (Activity) context; + activity = (ViewImgurMediaActivity) context; } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/SetAsWallpaperCallback.java b/app/src/main/java/ml/docilealligator/infinityforreddit/SetAsWallpaperCallback.java new file mode 100644 index 00000000..7fb6e324 --- /dev/null +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/SetAsWallpaperCallback.java @@ -0,0 +1,7 @@ +package ml.docilealligator.infinityforreddit; + +public interface SetAsWallpaperCallback { + void setToHomeScreen(int viewPagerPosition); + void setToLockScreen(int viewPagerPosition); + void setToBoth(int viewPagerPosition); +}
\ No newline at end of file diff --git a/app/src/main/res/drawable-night/ic_home_black_24dp.xml b/app/src/main/res/drawable-night/ic_home_black_24dp.xml new file mode 100644 index 00000000..a35f1eff --- /dev/null +++ b/app/src/main/res/drawable-night/ic_home_black_24dp.xml @@ -0,0 +1,9 @@ +<vector xmlns:android="http://schemas.android.com/apk/res/android" + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + <path + android:pathData="M12,5.69l5,4.5V18h-2v-6H9v6H7v-7.81l5,-4.5M12,3L2,12h3v8h6v-6h2v6h6v-8h3L12,3z" + android:fillColor="#000000"/> +</vector> diff --git a/app/src/main/res/drawable-night/ic_wallpaper_both_black_24dp.xml b/app/src/main/res/drawable-night/ic_wallpaper_both_black_24dp.xml new file mode 100644 index 00000000..d41e02ac --- /dev/null +++ b/app/src/main/res/drawable-night/ic_wallpaper_both_black_24dp.xml @@ -0,0 +1,9 @@ +<vector xmlns:android="http://schemas.android.com/apk/res/android" + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + <path + android:pathData="M17,1.01L7,1c-1.1,0 -2,0.9 -2,2v18c0,1.1 0.9,2 2,2h10c1.1,0 2,-0.9 2,-2V3c0,-1.1 -0.9,-1.99 -2,-1.99zM17,19H7V5h10v14z" + android:fillColor="#FFFFFF"/> +</vector> diff --git a/app/src/main/res/drawable-night/ic_wallpaper_home_screen_black_24dp.xml b/app/src/main/res/drawable-night/ic_wallpaper_home_screen_black_24dp.xml new file mode 100644 index 00000000..c112c91b --- /dev/null +++ b/app/src/main/res/drawable-night/ic_wallpaper_home_screen_black_24dp.xml @@ -0,0 +1,9 @@ +<vector xmlns:android="http://schemas.android.com/apk/res/android" + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + <path + android:pathData="M12,5.69l5,4.5V18h-2v-6H9v6H7v-7.81l5,-4.5M12,3L2,12h3v8h6v-6h2v6h6v-8h3L12,3z" + android:fillColor="#FFFFFF"/> +</vector> diff --git a/app/src/main/res/drawable-night/ic_wallpaper_lock_screen_black_24dp.xml b/app/src/main/res/drawable-night/ic_wallpaper_lock_screen_black_24dp.xml new file mode 100644 index 00000000..c771c895 --- /dev/null +++ b/app/src/main/res/drawable-night/ic_wallpaper_lock_screen_black_24dp.xml @@ -0,0 +1,9 @@ +<vector xmlns:android="http://schemas.android.com/apk/res/android" + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + <path + android:pathData="M18,8h-1L17,6c0,-2.76 -2.24,-5 -5,-5S7,3.24 7,6v2L6,8c-1.1,0 -2,0.9 -2,2v10c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2L20,10c0,-1.1 -0.9,-2 -2,-2zM9,6c0,-1.66 1.34,-3 3,-3s3,1.34 3,3v2L9,8L9,6zM18,20L6,20L6,10h12v10zM12,17c1.1,0 2,-0.9 2,-2s-0.9,-2 -2,-2 -2,0.9 -2,2 0.9,2 2,2z" + android:fillColor="#FFFFFF"/> +</vector> diff --git a/app/src/main/res/drawable/ic_wallpaper_both_black_24dp.xml b/app/src/main/res/drawable/ic_wallpaper_both_black_24dp.xml new file mode 100644 index 00000000..98044749 --- /dev/null +++ b/app/src/main/res/drawable/ic_wallpaper_both_black_24dp.xml @@ -0,0 +1,9 @@ +<vector xmlns:android="http://schemas.android.com/apk/res/android" + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + <path + android:pathData="M17,1.01L7,1c-1.1,0 -2,0.9 -2,2v18c0,1.1 0.9,2 2,2h10c1.1,0 2,-0.9 2,-2V3c0,-1.1 -0.9,-1.99 -2,-1.99zM17,19H7V5h10v14z" + android:fillColor="#000000"/> +</vector> diff --git a/app/src/main/res/drawable/ic_wallpaper_home_screen_black_24dp.xml b/app/src/main/res/drawable/ic_wallpaper_home_screen_black_24dp.xml new file mode 100644 index 00000000..a35f1eff --- /dev/null +++ b/app/src/main/res/drawable/ic_wallpaper_home_screen_black_24dp.xml @@ -0,0 +1,9 @@ +<vector xmlns:android="http://schemas.android.com/apk/res/android" + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + <path + android:pathData="M12,5.69l5,4.5V18h-2v-6H9v6H7v-7.81l5,-4.5M12,3L2,12h3v8h6v-6h2v6h6v-8h3L12,3z" + android:fillColor="#000000"/> +</vector> diff --git a/app/src/main/res/drawable/ic_wallpaper_lock_screen_black_24dp.xml b/app/src/main/res/drawable/ic_wallpaper_lock_screen_black_24dp.xml new file mode 100644 index 00000000..fb71425e --- /dev/null +++ b/app/src/main/res/drawable/ic_wallpaper_lock_screen_black_24dp.xml @@ -0,0 +1,9 @@ +<vector xmlns:android="http://schemas.android.com/apk/res/android" + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + <path + android:pathData="M18,8h-1L17,6c0,-2.76 -2.24,-5 -5,-5S7,3.24 7,6v2L6,8c-1.1,0 -2,0.9 -2,2v10c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2L20,10c0,-1.1 -0.9,-2 -2,-2zM9,6c0,-1.66 1.34,-3 3,-3s3,1.34 3,3v2L9,8L9,6zM18,20L6,20L6,10h12v10zM12,17c1.1,0 2,-0.9 2,-2s-0.9,-2 -2,-2 -2,0.9 -2,2 0.9,2 2,2z" + android:fillColor="#000000"/> +</vector> diff --git a/app/src/main/res/layout/fragment_set_as_wallpaper_bottom_sheet.xml b/app/src/main/res/layout/fragment_set_as_wallpaper_bottom_sheet.xml new file mode 100644 index 00000000..b8854ade --- /dev/null +++ b/app/src/main/res/layout/fragment_set_as_wallpaper_bottom_sheet.xml @@ -0,0 +1,74 @@ +<?xml version="1.0" encoding="utf-8"?> +<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:paddingBottom="8dp" + android:overScrollMode="never"> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical"> + + <TextView + android:id="@+id/home_screen_text_view_set_as_wallpaper_bottom_sheet_fragment" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:gravity="center_vertical" + android:paddingTop="16dp" + android:paddingBottom="16dp" + android:paddingStart="32dp" + android:paddingEnd="32dp" + android:text="@string/set_to_home_screen" + android:textColor="?attr/primaryTextColor" + android:textSize="?attr/font_default" + android:fontFamily="?attr/font_family" + android:drawableStart="@drawable/ic_wallpaper_home_screen_black_24dp" + android:drawablePadding="48dp" + android:clickable="true" + android:focusable="true" + android:background="?attr/selectableItemBackground" + android:visibility="gone" /> + + <TextView + android:id="@+id/lock_screen_text_view_set_as_wallpaper_bottom_sheet_fragment" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:gravity="center_vertical" + android:paddingTop="16dp" + android:paddingBottom="16dp" + android:paddingStart="32dp" + android:paddingEnd="32dp" + android:text="@string/set_to_lock_screen" + android:textColor="?attr/primaryTextColor" + android:textSize="?attr/font_default" + android:fontFamily="?attr/font_family" + android:drawableStart="@drawable/ic_wallpaper_lock_screen_black_24dp" + android:drawablePadding="48dp" + android:clickable="true" + android:focusable="true" + android:background="?attr/selectableItemBackground" + android:visibility="gone" /> + + <TextView + android:id="@+id/both_text_view_set_as_wallpaper_bottom_sheet_fragment" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:gravity="center_vertical" + android:paddingTop="16dp" + android:paddingBottom="16dp" + android:paddingStart="32dp" + android:paddingEnd="32dp" + android:text="@string/set_to_both" + android:textColor="?attr/primaryTextColor" + android:textSize="?attr/font_default" + android:fontFamily="?attr/font_family" + android:drawableStart="@drawable/ic_wallpaper_both_black_24dp" + android:drawablePadding="48dp" + android:clickable="true" + android:focusable="true" + android:background="?attr/selectableItemBackground" /> + + </LinearLayout> + +</androidx.core.widget.NestedScrollView>
\ No newline at end of file diff --git a/app/src/main/res/menu/view_image_activity.xml b/app/src/main/res/menu/view_image_activity.xml index 1f86092b..0c080ae9 100644 --- a/app/src/main/res/menu/view_image_activity.xml +++ b/app/src/main/res/menu/view_image_activity.xml @@ -14,4 +14,10 @@ android:title="@string/action_share" android:icon="@drawable/ic_share_toolbar_white_24dp" app:showAsAction="ifRoom" /> + + <item + android:id="@+id/action_set_wallpaper_view_image_activity" + android:orderInCategory="3" + android:title="@string/action_set_wallpaper" + app:showAsAction="never" /> </menu>
\ No newline at end of file diff --git a/app/src/main/res/menu/view_imgur_image_fragments.xml b/app/src/main/res/menu/view_imgur_image_fragments.xml index 806e91f5..bba34621 100644 --- a/app/src/main/res/menu/view_imgur_image_fragments.xml +++ b/app/src/main/res/menu/view_imgur_image_fragments.xml @@ -14,4 +14,10 @@ android:title="@string/action_share" android:icon="@drawable/ic_share_toolbar_white_24dp" app:showAsAction="ifRoom" /> + + <item + android:id="@+id/action_set_wallpaper_view_imgur_image_fragments" + android:orderInCategory="3" + android:title="@string/action_set_wallpaper" + app:showAsAction="never" /> </menu>
\ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index f79e18a9..032a47eb 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -61,6 +61,7 @@ <string name="action_share">Share</string> <string name="action_preview">Preview</string> <string name="action_report">Report</string> + <string name="action_set_wallpaper">Set as Wallpaper</string> <string name="parse_json_response_error">Error occurred when parsing the JSON response</string> <string name="retrieve_token_error">Error Retrieving the token</string> @@ -518,8 +519,8 @@ <string name="cannot_save_image">Cannot save the image</string> <string name="cannot_save_gif">Cannot save the gif</string> <string name="cannot_get_storage">Cannot access the app storage</string> - <string name="save_image_before_sharing">Saving the image. Please wait.</string> - <string name="save_gif_before_sharing">Saving the gif. Please wait.</string> + <string name="save_image_first">Saving the image. Please wait.</string> + <string name="save_gif_first">Saving the gif. Please wait.</string> <string name="theme_name_description">Tap to change the name of this theme.</string> <string name="theme_item_is_light_theme">Set as Light Theme</string> @@ -763,7 +764,12 @@ <string name="downloading_reddit_video_failed_cannot_save_audio">Download failed: cannot save audio to cache directory</string> <string name="downloading_reddit_video_failed_cannot_mux">Download failed: cannot mux video and audio</string> <string name="downloading_reddit_video_failed_cannot_save_mux_video">Download failed: cannot save the video to public directory</string> - <!-- TODO: Remove or change this placeholder text --> - <string name="hello_blank_fragment">Hello blank fragment</string> + + <string name="wallpaper_set">Wallpaper set</string> + <string name="error_set_wallpaper">Cannot set wallpaper</string> + + <string name="set_to_home_screen">Set to Home Screen</string> + <string name="set_to_lock_screen">Set to Lock Screen</string> + <string name="set_to_both">Set to Both</string> </resources> |