diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000000..b1b9eb9a02 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,9 @@ +# editorconfig.org +root = true + +[*] +charset = utf-8 +end_of_line = lf +indent_style = space +insert_final_newline = true +trim_trailing_whitespace = true diff --git a/README.md b/README.md index 0c45e61b53..6d60721a4e 100755 --- a/README.md +++ b/README.md @@ -23,6 +23,17 @@ There is an active community for Slide on the [/r/slideforreddit](https://www.reddit.com/r/slideforreddit/) subreddit, which anybody is welcome to join. +## Sponsors + +Thank you to our awesome Github Sponsors, who help keep the Slide project going + +| | GitHub profile | +| --------- | ------------- | +| **KevinNThomas** | https://github.com/KevinNThomas | +| **andrewkdinh** | https://github.com/andrewkdinh | + +If you're interested in sponsoring our work, check out the sponsor slots for Slide contributors on the right-hand **Sponsorship** menu + ## Contributing ### Issues diff --git a/adaptive.png b/adaptive.png index c03f2e034e..9d62b80ad4 100644 Binary files a/adaptive.png and b/adaptive.png differ diff --git a/app/build.gradle b/app/build.gradle index a2f25f20c1..01a690324a 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,18 +1,19 @@ plugins { id 'com.gladed.androidgitversion' version '0.4.13' - id 'com.github.ben-manes.versions' version '0.28.0' + id 'com.github.ben-manes.versions' version '0.33.0' id 'com.android.application' } android { - compileSdkVersion 28 + compileSdkVersion 29 buildToolsVersion '29.0.3' defaultConfig { - applicationId "me.ccrama.redditslide" + applicationId "bobobo.redditslide" minSdkVersion 16 - targetSdkVersion 28 - versionCode 326 + //Change to 28 for F-Droid, need to add this to the scheme + targetSdkVersion 29 + versionCode 334 versionName androidGitVersion.name() multiDexEnabled true @@ -78,65 +79,71 @@ dependencies { /** Custom **/ implementation 'com.github.ccrama:JRAW:9a2494892d' implementation 'com.github.ccrama:TedBottomPicker:496623c9b6' - implementation 'com.github.ccrama:commonmark-java:07b304b575' - implementation 'com.github.ccrama:PeekAndPop:09adee29f1' + implementation 'com.github.ccrama.commonmark-java:commonmark:07b304b575' + implementation 'com.github.ccrama.commonmark-java:commonmark-ext-gfm-strikethrough:07b304b575' + implementation 'com.github.ccrama.commonmark-java:commonmark-ext-gfm-tables:07b304b575' implementation 'com.github.ccrama:JReadability:bb291880a5' - implementation 'com.github.Alexendoo:Android-RobotoTextView:f6d0eb5ac7' + implementation 'com.github.Alexendoo.Android-RobotoTextView:robototextview:f6d0eb5ac7' /** AndroidX **/ - implementation 'androidx.appcompat:appcompat:1.1.0' + implementation 'androidx.appcompat:appcompat:1.2.0' implementation 'androidx.browser:browser:1.2.0' implementation 'androidx.cardview:cardview:1.0.0' implementation 'androidx.interpolator:interpolator:1.0.0' implementation 'androidx.multidex:multidex:2.0.1' implementation 'androidx.recyclerview:recyclerview:1.1.0' - implementation 'com.google.android.material:material:1.1.0' + implementation 'com.google.android.material:material:1.2.1' /** Third-party (Other) **/ - def exoPlayerVersion = '2.11.7' - implementation "com.google.android.exoplayer:exoplayer-core:${exoPlayerVersion}" - implementation "com.google.android.exoplayer:exoplayer-dash:${exoPlayerVersion}" - implementation "com.google.android.exoplayer:extension-okhttp:${exoPlayerVersion}" - implementation "com.google.android.exoplayer:exoplayer-ui:${exoPlayerVersion}" + def exoPlayerVersion = '2.12.1' + implementation "com.google.android.exoplayer:exoplayer-core:$exoPlayerVersion" + implementation "com.google.android.exoplayer:exoplayer-dash:$exoPlayerVersion" + implementation "com.google.android.exoplayer:exoplayer-ui:$exoPlayerVersion" + implementation "com.google.android.exoplayer:extension-okhttp:$exoPlayerVersion" - implementation 'com.google.guava:guava:29.0-android' + implementation 'com.google.guava:guava:30.0-android' //Updating material-dialogs to any newer version will break all AlertDialogWrapper //noinspection GradleDependency implementation 'com.afollestad.material-dialogs:commons:0.8.6.2' //0.9.6.0 implementation 'com.jakewharton:process-phoenix:2.0.0' - implementation 'com.github.ligi.snackengage:snackengage-core:0.25' - implementation 'com.github.ligi.snackengage:snackengage-playrate:0.25' - implementation 'com.github.rey5137:material:1.3.0' + implementation 'com.github.ligi.snackengage:snackengage-core:0.26' + implementation 'com.github.ligi.snackengage:snackengage-playrate:0.26' + implementation 'com.github.rey5137:material:1.3.1' implementation 'com.nostra13.universalimageloader:universal-image-loader:1.9.5' - implementation 'com.davemorrissey.labs:subsampling-scale-image-view:3.10.0' + implementation 'com.github.davemorrissey:subsampling-scale-image-view:ebce8e0' implementation 'com.cocosw:bottomsheet:1.5.0@aar' implementation 'com.lusfold.androidkeyvaluestore:library:0.1.0@aar' - implementation 'org.apache.commons:commons-lang3:3.10' - implementation 'org.apache.commons:commons-text:1.8' - implementation 'commons-io:commons-io:2.7' + implementation 'org.apache.commons:commons-lang3:3.11' + implementation 'org.apache.commons:commons-text:1.9' + implementation 'commons-io:commons-io:2.8.0' implementation 'jp.wasabeef:blurry:3.0.0' implementation 'com.makeramen:roundedimageview:2.3.0' implementation 'com.getbase:floatingactionbutton:1.10.1' implementation 'com.sothree.slidinguppanel:library:3.4.0' implementation 'com.github.suckgamony.RapidDecoder:library:7cdfca47fa' - implementation 'com.github.dasar:shiftcolorpicker:v0.5' implementation 'com.squareup.okhttp3:okhttp:3.12.12' implementation 'com.google.code.gson:gson:2.8.6' - - implementation 'com.github.ozodrukh:CircularReveal:2.1.0' - compileOnly 'org.jetbrains:annotations:19.0.0' + implementation 'com.github.ozodrukh.CircularReveal:circualreveal:2.1.0' + compileOnly 'org.jetbrains:annotations:20.1.0' implementation 'com.mikepenz:itemanimators:1.1.0@aar' - implementation 'com.neovisionaries:nv-websocket-client:2.9' + implementation 'com.neovisionaries:nv-websocket-client:2.10' implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0' implementation 'me.everything:overscroll-decor-android:1.1.0' - implementation('com.mikepenz:aboutlibraries:8.3.0', { - exclude group: 'org.jetbrains', module: 'annotations' - }) - implementation 'com.googlecode.mp4parser:isoparser:1.1.22' + implementation 'com.mikepenz:aboutlibraries:6.2.3' + implementation 'org.mp4parser:isoparser:1.9.41' + implementation 'org.mp4parser:muxer:1.9.41' /** Testing **/ - testImplementation 'junit:junit:4.13' + testImplementation 'junit:junit:4.13.1' testImplementation 'org.hamcrest:hamcrest:2.2' - testImplementation 'org.robolectric:robolectric:4.3.1' + testImplementation 'org.robolectric:robolectric:4.4' testImplementation 'org.powermock:powermock-module-junit4:2.0.7' } + +/*testImplementation 'junit:junit:4.12' + testImplementation 'org.hamcrest:hamcrest-all:1.3' + testImplementation 'org.mockito:mockito-core:2.23.0' + testImplementation "org.robolectric:robolectric:${robolectricVersion}" + testImplementation "org.robolectric:shadows-multidex:${robolectricVersion}" + testImplementation "org.powermock:powermock-api-mockito2:${powerMockitoVersion}" + testImplementation "org.powermock:powermock-module-junit4:${powerMockitoVersion}" */ \ No newline at end of file diff --git a/app/src/debug/res/drawable/ic_launcher.png b/app/src/debug/res/drawable/ic_launcher.png index 4a159526ed..057ef600bd 100644 Binary files a/app/src/debug/res/drawable/ic_launcher.png and b/app/src/debug/res/drawable/ic_launcher.png differ diff --git a/app/src/debug/res/mipmap-hdpi/ic_launcher.png b/app/src/debug/res/mipmap-hdpi/ic_launcher.png index 23e6b99486..609a949380 100644 Binary files a/app/src/debug/res/mipmap-hdpi/ic_launcher.png and b/app/src/debug/res/mipmap-hdpi/ic_launcher.png differ diff --git a/app/src/debug/res/mipmap-mdpi/ic_launcher.png b/app/src/debug/res/mipmap-mdpi/ic_launcher.png index aa365eb4ae..2885957bf4 100644 Binary files a/app/src/debug/res/mipmap-mdpi/ic_launcher.png and b/app/src/debug/res/mipmap-mdpi/ic_launcher.png differ diff --git a/app/src/debug/res/mipmap-xhdpi/ic_launcher.png b/app/src/debug/res/mipmap-xhdpi/ic_launcher.png index 44ff2abc62..918b5a39bb 100644 Binary files a/app/src/debug/res/mipmap-xhdpi/ic_launcher.png and b/app/src/debug/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/app/src/debug/res/mipmap-xxhdpi/ic_launcher.png b/app/src/debug/res/mipmap-xxhdpi/ic_launcher.png index 9639d22359..e18eec0181 100644 Binary files a/app/src/debug/res/mipmap-xxhdpi/ic_launcher.png and b/app/src/debug/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/app/src/debug/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/debug/res/mipmap-xxxhdpi/ic_launcher.png index 902f2d1669..80826e79b3 100644 Binary files a/app/src/debug/res/mipmap-xxxhdpi/ic_launcher.png and b/app/src/debug/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 79d9729bbe..d1a16d486c 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -18,7 +18,7 @@ android:installLocation="auto" android:label="@string/app_name" android:resizeableActivity="true" - android:roundIcon="@mipmap/icon_round" + android:roundIcon="@mipmap/ic_launcher_round" android:usesCleartextTraffic="true" android:theme="@style/yellow_dark"> + android:roundIcon="@mipmap/ic_launcher_round"> @@ -322,6 +322,14 @@ android:name=".Activities.Album" android:configChanges="keyboard|keyboardHidden|orientation|screenSize|smallestScreenSize|screenLayout|uiMode" android:theme="@style/swipeable"/> + + This class is responsible for accessing the Imgur api to get * the album json data from a URL or Imgur hash. It extends FullScreenActivity and supports swipe @@ -58,7 +60,7 @@ public class Album extends FullScreenActivity implements FolderChooserDialogCrea public static final String EXTRA_URL = "url"; public static final String SUBREDDIT = "subreddit"; private List images; - private int adapterPosition; + private int adapterPosition; @Override public void onFolderSelection(FolderChooserDialogCreate dialog, File folder, boolean isSaveToLocation) { @@ -87,6 +89,9 @@ public boolean onOptionsItemSelected(MenuItem item) { i.putExtra(MediaView.SUBMISSION_URL, getIntent().getStringExtra(MediaView.SUBMISSION_URL)); } + if (submissionTitle != null) { + i.putExtra(EXTRA_SUBMISSION_TITLE, submissionTitle); + } i.putExtra("url", url); startActivity(i); finish(); @@ -120,6 +125,9 @@ public void doImageSave(boolean isGif, String contentUrl) { Intent i = new Intent(this, ImageDownloadNotificationService.class); i.putExtra("actuallyLoaded", contentUrl); if (subreddit != null && !subreddit.isEmpty()) i.putExtra("subreddit", subreddit); + if (submissionTitle != null) { + i.putExtra(EXTRA_SUBMISSION_TITLE, submissionTitle); + } startService(i); } } else { @@ -201,6 +209,7 @@ private void saveImageGallery(final Bitmap bitmap, String URL) { public String url; public String subreddit; + public String submissionTitle; @Override public boolean onCreateOptionsMenu(Menu menu) { @@ -226,9 +235,12 @@ public void onCreate(Bundle savedInstanceState) { //Keep the screen on getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); - if(getIntent().hasExtra(SUBREDDIT)){ + if (getIntent().hasExtra(SUBREDDIT)) { this.subreddit = getIntent().getExtras().getString(SUBREDDIT); } + if (getIntent().hasExtra(EXTRA_SUBMISSION_TITLE)) { + this.submissionTitle = getIntent().getExtras().getString(EXTRA_SUBMISSION_TITLE); + } final ViewPager pager = (ViewPager) findViewById(R.id.images); @@ -238,7 +250,7 @@ public void onCreate(Bundle savedInstanceState) { pager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageScrolled(int position, float positionOffset, - int positionOffsetPixels) { + int positionOffsetPixels) { if (position == 0 && positionOffsetPixels == 0) { finish(); } @@ -282,7 +294,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) { public static class OverviewPagerAdapter extends FragmentStatePagerAdapter { public BlankFragment blankPage; - public AlbumFrag album; + public AlbumFrag album; public OverviewPagerAdapter(FragmentManager fm) { super(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT); @@ -322,11 +334,10 @@ public static class AlbumFrag extends Fragment { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { + Bundle savedInstanceState) { rootView = inflater.inflate(R.layout.fragment_verticalalbum, container, false); - final PreCachingLayoutManager mLayoutManager; - mLayoutManager = new PreCachingLayoutManager(getActivity()); + final PreCachingLayoutManager mLayoutManager = new PreCachingLayoutManager(getActivity()); recyclerView = rootView.findViewById(R.id.images); recyclerView.setLayoutManager(mLayoutManager); ((Album) getActivity()).url = @@ -372,7 +383,7 @@ public void run() { new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, - int which) { + int which) { getActivity().finish(); } }) @@ -381,7 +392,7 @@ public void onClick(DialogInterface dialog, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, - int which) { + int which) { Intent i = new Intent(getActivity(), Website.class); i.putExtra(LinkUtil.EXTRA_URL, url); @@ -404,13 +415,15 @@ public void doWithData(final List jsonElements) { super.doWithData(jsonElements); if (getActivity() != null) { getActivity().findViewById(R.id.progress).setVisibility(View.GONE); - ((Album) getActivity()).images = new ArrayList<>(jsonElements); - AlbumView adapter = new AlbumView(baseActivity, ((Album) getActivity()).images, - getActivity().findViewById(R.id.toolbar).getHeight(), ((Album) getActivity()).subreddit); + Album albumActivity = (Album) getActivity(); + albumActivity.images = new ArrayList<>(jsonElements); + AlbumView adapter = new AlbumView(baseActivity, albumActivity.images, + getActivity().findViewById(R.id.toolbar).getHeight(), + albumActivity.subreddit, albumActivity.submissionTitle); recyclerView.setAdapter(adapter); } } } } -} \ No newline at end of file +} diff --git a/app/src/main/java/me/ccrama/redditslide/Activities/AlbumPager.java b/app/src/main/java/me/ccrama/redditslide/Activities/AlbumPager.java index b7b04113d0..87b3295337 100644 --- a/app/src/main/java/me/ccrama/redditslide/Activities/AlbumPager.java +++ b/app/src/main/java/me/ccrama/redditslide/Activities/AlbumPager.java @@ -8,6 +8,7 @@ import android.graphics.Bitmap; import android.graphics.Color; import android.graphics.PorterDuff; +import android.graphics.PorterDuffColorFilter; import android.graphics.Typeface; import android.graphics.drawable.Drawable; import android.os.AsyncTask; @@ -37,6 +38,8 @@ import com.afollestad.materialdialogs.AlertDialogWrapper; import com.cocosw.bottomsheet.BottomSheet; +import com.davemorrissey.labs.subscaleview.decoder.CompatDecoderFactory; +import com.davemorrissey.labs.subscaleview.decoder.SkiaImageDecoder; import com.devspark.robototextview.RobotoTypefaces; import com.nostra13.universalimageloader.core.DisplayImageOptions; import com.nostra13.universalimageloader.core.assist.FailReason; @@ -78,6 +81,8 @@ import me.ccrama.redditslide.util.ShareUtil; import me.ccrama.redditslide.util.SubmissionParser; +import static me.ccrama.redditslide.Notifications.ImageDownloadNotificationService.*; + /** * Created by ccrama on 1/25/2016.

This is an extension of Album.java which utilizes a @@ -108,6 +113,9 @@ public boolean onOptionsItemSelected(MenuItem item) { if(getIntent().hasExtra(SUBREDDIT)){ i.putExtra(SUBREDDIT, getIntent().getStringExtra(SUBREDDIT)); } + if (getIntent().hasExtra(EXTRA_SUBMISSION_TITLE)) { + i.putExtra(EXTRA_SUBMISSION_TITLE, getIntent().getStringExtra(EXTRA_SUBMISSION_TITLE)); + } i.putExtras(getIntent()); startActivity(i); finish(); @@ -440,15 +448,15 @@ public void showBottomSheetImage(final String contentUrl, final boolean isGif, TypedArray ta = obtainStyledAttributes(attrs); int color = ta.getColor(0, Color.WHITE); - Drawable external = getResources().getDrawable(R.drawable.openexternal); + Drawable external = getResources().getDrawable(R.drawable.open_external); Drawable share = getResources().getDrawable(R.drawable.share); Drawable image = getResources().getDrawable(R.drawable.image); Drawable save = getResources().getDrawable(R.drawable.save); - external.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - share.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - image.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - save.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); + external.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + share.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + image.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + save.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); ta.recycle(); BottomSheet.Builder b = new BottomSheet.Builder(this).title(contentUrl); @@ -495,6 +503,9 @@ public void doImageSave(boolean isGif, String contentUrl, int index) { Intent i = new Intent(this, ImageDownloadNotificationService.class); i.putExtra("actuallyLoaded", contentUrl); if (subreddit != null && !subreddit.isEmpty()) i.putExtra("subreddit", subreddit); + if (getIntent().hasExtra(EXTRA_SUBMISSION_TITLE)) { + i.putExtra(EXTRA_SUBMISSION_TITLE, getIntent().getStringExtra(EXTRA_SUBMISSION_TITLE)); + } i.putExtra("index", index); startService(i); } @@ -527,7 +538,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, && SettingValues.lowResMobile))) { String lqurl = url.substring(0, url.lastIndexOf(".")) + (SettingValues.lqLow ? "m" : (SettingValues.lqMid ? "l" : "h")) - + url.substring(url.lastIndexOf("."), url.length()); + + url.substring(url.lastIndexOf(".")); loadImage(rootView, this, lqurl, ((AlbumPager) getActivity()).images.size() == 1); lq = true; } else { @@ -573,10 +584,10 @@ public void onClick(View v2) { rootView.findViewById(R.id.panel).setVisibility(View.GONE); (rootView.findViewById(R.id.margin)).setPadding(0, 0, 0, 0); } else if (title.isEmpty()) { - setTextWithLinks(description, ((SpoilerRobotoTextView) rootView.findViewById(R.id.title))); + setTextWithLinks(description, rootView.findViewById(R.id.title)); } else { - setTextWithLinks(title, ((SpoilerRobotoTextView) rootView.findViewById(R.id.title))); - setTextWithLinks(description, ((SpoilerRobotoTextView) rootView.findViewById(R.id.body))); + setTextWithLinks(title, rootView.findViewById(R.id.title)); + setTextWithLinks(description, rootView.findViewById(R.id.body)); } { int type = new FontPreferences(getContext()).getFontTypeComment().getTypeface(); @@ -691,11 +702,9 @@ private static void loadImage(final View rootView, Fragment f, String url, boole .imageScaleType(single?ImageScaleType.NONE:ImageScaleType.NONE_SAFE) .cacheInMemory(false) .build(), new ImageLoadingListener() { - private View mView; @Override public void onLoadingStarted(String imageUri, View view) { - mView = view; size.setVisibility(View.VISIBLE); } diff --git a/app/src/main/java/me/ccrama/redditslide/Activities/BaseActivity.java b/app/src/main/java/me/ccrama/redditslide/Activities/BaseActivity.java index d112374e19..11bb5d5fba 100644 --- a/app/src/main/java/me/ccrama/redditslide/Activities/BaseActivity.java +++ b/app/src/main/java/me/ccrama/redditslide/Activities/BaseActivity.java @@ -17,6 +17,7 @@ import androidx.annotation.IdRes; import androidx.annotation.Nullable; +import androidx.annotation.RequiresApi; import androidx.annotation.StringRes; import androidx.appcompat.widget.Toolbar; @@ -33,6 +34,7 @@ import me.ccrama.redditslide.SwipeLayout.app.SwipeBackActivityHelper; import me.ccrama.redditslide.Visuals.FontPreferences; import me.ccrama.redditslide.Visuals.Palette; +import me.ccrama.redditslide.util.LogUtil; /** * This is an activity which is the base for most of Slide's activities. It has support for handling @@ -62,6 +64,9 @@ public void onWindowFocusChanged(final boolean hasFocus) { hideDecor(); } } + if (enableSwipeBackLayout) { + Utils.convertActivityToTranslucent(this); + } } public void hideDecor(){ @@ -481,15 +486,23 @@ public void onNdefPushComplete(NfcEvent arg0) { */ public void setRecentBar(@Nullable String title, int color) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + if (title == null || title.isEmpty()) { + title = getString(R.string.app_name); + } + setRecentBarTaskDescription(title, color); + } + } - if (title == null || title.equals("")) title = getString(R.string.app_name); - - Bitmap bitmap= BitmapFactory.decodeResource(getResources(),( title.equalsIgnoreCase("androidcirclejerk") ? R.drawable.matiasduarte - : R.drawable.ic_launcher)); - - setTaskDescription( - new ActivityManager.TaskDescription(title, bitmap, color)); + @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) + private void setRecentBarTaskDescription(@Nullable String title, int color) { + int icon = title.equalsIgnoreCase("androidcirclejerk") ? R.drawable.matiasduarte + : R.drawable.ic_launcher; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { + setTaskDescription(new ActivityManager.TaskDescription(title, icon, color)); + } else { + Bitmap bitmap = BitmapFactory.decodeResource(getResources(), icon); + setTaskDescription(new ActivityManager.TaskDescription(title, bitmap, color)); bitmap.recycle(); } } diff --git a/app/src/main/java/me/ccrama/redditslide/Activities/CommentSearch.java b/app/src/main/java/me/ccrama/redditslide/Activities/CommentSearch.java index 8566ca7df6..75d0e6e960 100644 --- a/app/src/main/java/me/ccrama/redditslide/Activities/CommentSearch.java +++ b/app/src/main/java/me/ccrama/redditslide/Activities/CommentSearch.java @@ -37,8 +37,7 @@ public void onCreate(Bundle savedInstance) { final EditText search = (EditText) findViewById(R.id.search); RecyclerView rv = (RecyclerView) findViewById(R.id.vertical_content); - final PreCachingLayoutManager mLayoutManager; - mLayoutManager = new PreCachingLayoutManager(this); + final PreCachingLayoutManager mLayoutManager = new PreCachingLayoutManager(this); rv.setLayoutManager(mLayoutManager); ArrayList comments = new ArrayList<>(); List commentsOld = DataShare.sharedComments; diff --git a/app/src/main/java/me/ccrama/redditslide/Activities/CommentsScreen.java b/app/src/main/java/me/ccrama/redditslide/Activities/CommentsScreen.java index 30a0cfaf14..535848d97d 100644 --- a/app/src/main/java/me/ccrama/redditslide/Activities/CommentsScreen.java +++ b/app/src/main/java/me/ccrama/redditslide/Activities/CommentsScreen.java @@ -10,6 +10,7 @@ import android.view.Window; import android.view.inputmethod.InputMethodManager; +import androidx.core.content.ContextCompat; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentStatePagerAdapter; @@ -84,8 +85,10 @@ public boolean dispatchKeyEvent(KeyEvent event) { @Override public void onPause() { super.onPause(); - InputMethodManager imm = (InputMethodManager) getSystemService(BaseActivityAnim.INPUT_METHOD_SERVICE); - imm.hideSoftInputFromWindow(findViewById(android.R.id.content).getWindowToken(), 0); + InputMethodManager imm = ContextCompat.getSystemService(this, InputMethodManager.class); + if (imm != null) { + imm.hideSoftInputFromWindow(findViewById(android.R.id.content).getWindowToken(), 0); + } } @Override @@ -356,7 +359,7 @@ public Fragment getItem(int i) { Fragment f = new CommentPage(); Bundle args = new Bundle(); String name = currentPosts.get(i).getFullName(); - args.putString("id", name.substring(3, name.length())); + args.putString("id", name.substring(3)); args.putBoolean("archived", currentPosts.get(i).isArchived()); args.putBoolean("contest", currentPosts.get(i).getDataNode().get("contest_mode").asBoolean()); diff --git a/app/src/main/java/me/ccrama/redditslide/Activities/CommentsScreenSingle.java b/app/src/main/java/me/ccrama/redditslide/Activities/CommentsScreenSingle.java index 1436152762..096b82e110 100644 --- a/app/src/main/java/me/ccrama/redditslide/Activities/CommentsScreenSingle.java +++ b/app/src/main/java/me/ccrama/redditslide/Activities/CommentsScreenSingle.java @@ -33,6 +33,7 @@ import me.ccrama.redditslide.R; import me.ccrama.redditslide.Reddit; import me.ccrama.redditslide.SettingValues; +import me.ccrama.redditslide.SwipeLayout.Utils; import me.ccrama.redditslide.UserSubscriptions; import me.ccrama.redditslide.util.LogUtil; @@ -50,6 +51,7 @@ public class CommentsScreenSingle extends BaseActivityAnim { private String name; private String context; private int contextNumber; + private Boolean doneTranslucent = false; @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { @@ -200,7 +202,10 @@ public void onPageSelected(int position) { @Override public void onPageScrollStateChanged(int state) { - + if(!doneTranslucent) { + doneTranslucent = true; + Utils.convertActivityToTranslucent(CommentsScreenSingle.this); + } } }); } @@ -290,7 +295,7 @@ public Fragment getCurrentFragment() { @Override public void setPrimaryItem(ViewGroup container, int position, Object object) { - if (getCurrentFragment() != object) { + if (mCurrentFragment != object) { mCurrentFragment = (Fragment) object; } super.setPrimaryItem(container, position, object); @@ -305,7 +310,7 @@ public Fragment getItem(int i) { Fragment f = new CommentPage(); Bundle args = new Bundle(); - if (name.contains("t3_")) name = name.substring(3, name.length()); + if (name.contains("t3_")) name = name.substring(3); args.putString("id", name); args.putString("context", context); diff --git a/app/src/main/java/me/ccrama/redditslide/Activities/CreateMulti.java b/app/src/main/java/me/ccrama/redditslide/Activities/CreateMulti.java index 00e9d764a9..0a3d53d5d3 100644 --- a/app/src/main/java/me/ccrama/redditslide/Activities/CreateMulti.java +++ b/app/src/main/java/me/ccrama/redditslide/Activities/CreateMulti.java @@ -19,6 +19,7 @@ import android.content.Context; import android.content.DialogInterface; import android.graphics.PorterDuff; +import android.graphics.PorterDuffColorFilter; import android.os.AsyncTask; import android.os.Bundle; import android.util.Log; @@ -65,7 +66,6 @@ public class CreateMulti extends BaseActivityAnim { private ArrayList subs; - private boolean delete = false; private CustomAdapter adapter; private EditText title; private RecyclerView recyclerView; @@ -78,7 +78,7 @@ public class CreateMulti extends BaseActivityAnim { @Override protected void onCreate(Bundle savedInstanceState) { - overrideRedditSwipeAnywhere(); + overrideSwipeFromAnywhere(); super.onCreate(savedInstanceState); applyColorTheme(); @@ -120,6 +120,26 @@ public void onComplete(List multis) { recyclerView.setLayoutManager(new LinearLayoutManager(this)); } + @Override + public void onBackPressed() { + new AlertDialogWrapper.Builder(CreateMulti.this).setTitle(R.string.general_confirm_exit) + .setMessage(R.string.multi_save_option) + .setPositiveButton(R.string.btn_yes, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int i) { + MultiredditOverview.multiActivity.finish(); + new SaveMulti().execute(); + } + }) + .setNegativeButton(R.string.btn_no, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int i) { + finish(); + } + }) + .show(); + } + public void showSelectDialog() { //List of all subreddits of the multi List multiSubs = new ArrayList<>(subs); @@ -285,7 +305,8 @@ public void onBindViewHolder(final ViewHolder holder, int position) { holder.text.setText(origPos); holder.itemView.findViewById(R.id.color).setBackgroundResource(R.drawable.circle); - holder.itemView.findViewById(R.id.color).getBackground().setColorFilter(Palette.getColor(origPos), PorterDuff.Mode.MULTIPLY); + holder.itemView.findViewById(R.id.color).getBackground().setColorFilter( + new PorterDuffColorFilter(Palette.getColor(origPos), PorterDuff.Mode.MULTIPLY)); holder.itemView.setOnClickListener(new View.OnClickListener() { @Override @@ -317,7 +338,7 @@ public class ViewHolder extends RecyclerView.ViewHolder { public ViewHolder(View itemView) { super(itemView); - text = (TextView) itemView.findViewById(R.id.name); + text = itemView.findViewById(R.id.name); } @@ -339,24 +360,20 @@ protected Void doInBackground(Void... params) { Log.v(LogUtil.getTag(), "Invalid multi name"); throw new IllegalArgumentException(multiName); } - if (delete) { - Log.v(LogUtil.getTag(), "Deleting"); - new MultiRedditManager(Authentication.reddit).delete(old); - } else { - if (old != null && !old.isEmpty() && !old.replace(" ", "").equals(multiName)) { - Log.v(LogUtil.getTag(), "Renaming"); - new MultiRedditManager(Authentication.reddit).rename(old, multiName); - } - Log.v(LogUtil.getTag(), "Create or Update, Name: " + multiName); - new MultiRedditManager(Authentication.reddit).createOrUpdate(new MultiRedditUpdateRequest.Builder(Authentication.name, multiName).subreddits(subs).build()); - runOnUiThread(new Runnable() { - @Override - public void run() { - Log.v(LogUtil.getTag(), "Update Subreddits"); - new UserSubscriptions.SyncMultireddits(CreateMulti.this).execute(); - } - }); + if (old != null && !old.isEmpty() && !old.replace(" ", "").equals(multiName)) { + Log.v(LogUtil.getTag(), "Renaming"); + new MultiRedditManager(Authentication.reddit).rename(old, multiName); } + Log.v(LogUtil.getTag(), "Create or Update, Name: " + multiName); + new MultiRedditManager(Authentication.reddit).createOrUpdate(new MultiRedditUpdateRequest.Builder(Authentication.name, multiName).subreddits(subs).build()); + runOnUiThread(new Runnable() { + @Override + public void run() { + Log.v(LogUtil.getTag(), "Update Subreddits"); + MultiredditOverview.multiActivity.finish(); + new UserSubscriptions.SyncMultireddits(CreateMulti.this).execute(); + } + }); runOnUiThread(new Runnable() { @Override public void run() { @@ -433,6 +450,7 @@ public boolean onOptionsItemSelected(MenuItem item) { .setPositiveButton(R.string.btn_yes, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { + MultiredditOverview.multiActivity.finish(); new MaterialDialog.Builder(CreateMulti.this) .title(R.string.deleting) .progress(true, 100) diff --git a/app/src/main/java/me/ccrama/redditslide/Activities/Crosspost.java b/app/src/main/java/me/ccrama/redditslide/Activities/Crosspost.java index 0972244ca4..b86f8733ce 100644 --- a/app/src/main/java/me/ccrama/redditslide/Activities/Crosspost.java +++ b/app/src/main/java/me/ccrama/redditslide/Activities/Crosspost.java @@ -208,7 +208,7 @@ protected Void doInBackground(Void... voids) { + ((AutoCompleteTextView) findViewById( R.id.subreddittext)).getText().toString() + "/comments/" - + s.getFullName().substring(3, s.getFullName().length())); + + s.getFullName().substring(3)); Crosspost.this.finish(); } catch (final ApiException e) { e.printStackTrace(); diff --git a/app/src/main/java/me/ccrama/redditslide/Activities/DeleteFile.java b/app/src/main/java/me/ccrama/redditslide/Activities/DeleteFile.java index 359072bef8..ceb13fe455 100644 --- a/app/src/main/java/me/ccrama/redditslide/Activities/DeleteFile.java +++ b/app/src/main/java/me/ccrama/redditslide/Activities/DeleteFile.java @@ -10,6 +10,8 @@ import android.os.Bundle; import android.os.Environment; +import androidx.core.content.ContextCompat; + import java.io.File; /** @@ -33,8 +35,10 @@ public void onCreate(Bundle savedInstance) { super.onCreate(savedInstance); Intent intent = getIntent(); - NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); - manager.cancel(intent.getIntExtra(NOTIFICATION_ID, -1)); + NotificationManager manager = ContextCompat.getSystemService(this, NotificationManager.class); + if (manager != null) { + manager.cancel(intent.getIntExtra(NOTIFICATION_ID, -1)); + } Bundle extras = intent.getExtras(); String image; diff --git a/app/src/main/java/me/ccrama/redditslide/Activities/DonateView.java b/app/src/main/java/me/ccrama/redditslide/Activities/DonateView.java index a936412a79..a8f08daaac 100644 --- a/app/src/main/java/me/ccrama/redditslide/Activities/DonateView.java +++ b/app/src/main/java/me/ccrama/redditslide/Activities/DonateView.java @@ -21,12 +21,12 @@ import me.ccrama.redditslide.Reddit; import me.ccrama.redditslide.SettingValues; import me.ccrama.redditslide.Visuals.Palette; -import me.ccrama.redditslide.util.IabHelper; -import me.ccrama.redditslide.util.IabResult; -import me.ccrama.redditslide.util.Inventory; import me.ccrama.redditslide.util.LogUtil; -import me.ccrama.redditslide.util.Purchase; -import me.ccrama.redditslide.util.SkuDetails; +import me.ccrama.redditslide.util.billing.IabHelper; +import me.ccrama.redditslide.util.billing.IabResult; +import me.ccrama.redditslide.util.billing.Inventory; +import me.ccrama.redditslide.util.billing.Purchase; +import me.ccrama.redditslide.util.billing.SkuDetails; /** @@ -157,4 +157,4 @@ public void onIabPurchaseFinished(IabResult result, } }); } -} \ No newline at end of file +} diff --git a/app/src/main/java/me/ccrama/redditslide/Activities/Draw.java b/app/src/main/java/me/ccrama/redditslide/Activities/Draw.java index c43640c0e6..2dbe9dbe6a 100644 --- a/app/src/main/java/me/ccrama/redditslide/Activities/Draw.java +++ b/app/src/main/java/me/ccrama/redditslide/Activities/Draw.java @@ -4,6 +4,7 @@ import android.graphics.Bitmap; import android.graphics.Color; import android.graphics.PorterDuff; +import android.graphics.PorterDuffColorFilter; import android.net.Uri; import android.os.Bundle; import android.provider.MediaStore; @@ -139,7 +140,7 @@ protected void onActivityResult(int code, int resultC, Intent data) { try { bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(), selectedImageUri) .copy(Bitmap.Config.RGB_565, true); - color.getBackground().setColorFilter(getLastColor(), PorterDuff.Mode.MULTIPLY); + color.getBackground().setColorFilter(new PorterDuffColorFilter(getLastColor(), PorterDuff.Mode.MULTIPLY)); color.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -163,7 +164,7 @@ public void onClick(View v) { @Override public void onColorSelection(@NonNull ColorChooserDialog dialog, @ColorInt int selectedColor) { drawView.setPaintStrokeColor(selectedColor); - color.getBackground().setColorFilter(selectedColor, PorterDuff.Mode.MULTIPLY); + color.getBackground().setColorFilter(new PorterDuffColorFilter(selectedColor, PorterDuff.Mode.MULTIPLY)); Reddit.colors.edit().putInt("drawColor", selectedColor).commit(); } diff --git a/app/src/main/java/me/ccrama/redditslide/Activities/EditCardsLayout.java b/app/src/main/java/me/ccrama/redditslide/Activities/EditCardsLayout.java index 6f209e242d..7b307346a5 100644 --- a/app/src/main/java/me/ccrama/redditslide/Activities/EditCardsLayout.java +++ b/app/src/main/java/me/ccrama/redditslide/Activities/EditCardsLayout.java @@ -129,6 +129,17 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { } }); } + { + SwitchCompat single2 = (SwitchCompat) findViewById(R.id.hidePostAwards); + single2.setChecked(SettingValues.hidePostAwards); + single2.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + SettingValues.hidePostAwards = isChecked; + SettingValues.prefs.edit().putBoolean(SettingValues.PREF_HIDE_POST_AWARDS, isChecked).apply(); + } + }); + } { SwitchCompat single2 = (SwitchCompat) findViewById(R.id.titleTop); single2.setChecked(SettingValues.titleTop); @@ -187,6 +198,8 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { CURRENT_PICTURE.setText(R.string.mode_cropped); } else if (SettingValues.bigPicEnabled) { CURRENT_PICTURE.setText(R.string.mode_bigpic); + } else if (SettingValues.noThumbnails) { + CURRENT_PICTURE.setText(R.string.mode_no_thumbnails); } else { CURRENT_PICTURE.setText(R.string.mode_thumbnail); } @@ -230,12 +243,27 @@ public boolean onMenuItemClick(MenuItem item) { e.apply(); } break; + case R.id.noThumbnails: + layout.removeAllViews(); + layout.addView(CreateCardView.setNoThumbnails(true, layout)); + { + SharedPreferences.Editor e = SettingValues.prefs.edit(); + for (Map.Entry map : SettingValues.prefs.getAll().entrySet()) { + if (map.getKey().startsWith("picsenabled")) { + e.remove(map.getKey()); //reset all overridden values + } + } + e.apply(); + } + break; } if (SettingValues.bigPicCropped) { CURRENT_PICTURE.setText(R.string.mode_cropped); } else if (SettingValues.bigPicEnabled) { CURRENT_PICTURE.setText(R.string.mode_bigpic); + } else if (SettingValues.noThumbnails) { + CURRENT_PICTURE.setText(R.string.mode_no_thumbnails); } else { CURRENT_PICTURE.setText(R.string.mode_thumbnail); } @@ -246,32 +274,34 @@ public boolean onMenuItemClick(MenuItem item) { } }); - final SwitchCompat bigThumbnails = (SwitchCompat) findViewById(R.id.bigThumbnails); - assert bigThumbnails != null; //def won't be null + if (!SettingValues.noThumbnails) { + final SwitchCompat bigThumbnails = (SwitchCompat) findViewById(R.id.bigThumbnails); + assert bigThumbnails != null; //def won't be null - bigThumbnails.setChecked(SettingValues.bigThumbnails); - bigThumbnails.setOnCheckedChangeListener(new SwitchCompat.OnCheckedChangeListener() { - @Override - public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { - SettingValues.prefs.edit().putBoolean("bigThumbnails", isChecked).apply(); - SettingValues.bigThumbnails = isChecked; - - if (!SettingValues.bigPicCropped) { - layout.removeAllViews(); - - layout.addView(CreateCardView.setBigPicEnabled(false, layout)); - { - SharedPreferences.Editor e = SettingValues.prefs.edit(); - for (Map.Entry map : SettingValues.prefs.getAll().entrySet()) { - if (map.getKey().startsWith("picsenabled")) { - e.remove(map.getKey()); //reset all overridden values + bigThumbnails.setChecked(SettingValues.bigThumbnails); + bigThumbnails.setOnCheckedChangeListener(new SwitchCompat.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + SettingValues.prefs.edit().putBoolean("bigThumbnails", isChecked).apply(); + SettingValues.bigThumbnails = isChecked; + + if (!SettingValues.bigPicCropped) { + layout.removeAllViews(); + + layout.addView(CreateCardView.setBigPicEnabled(false, layout)); + { + SharedPreferences.Editor e = SettingValues.prefs.edit(); + for (Map.Entry map : SettingValues.prefs.getAll().entrySet()) { + if (map.getKey().startsWith("picsenabled")) { + e.remove(map.getKey()); //reset all overridden values + } } + e.apply(); } - e.apply(); } } - } - }); + }); + } //Actionbar// ((TextView) findViewById(R.id.actionbar_current)).setText(!SettingValues.actionbarVisible ? (SettingValues.actionbarTap ? getString(R.string.tap_actionbar) : getString(R.string.press_actionbar)) : getString(R.string.always_actionbar)); diff --git a/app/src/main/java/me/ccrama/redditslide/Activities/ForceTouchLink.java b/app/src/main/java/me/ccrama/redditslide/Activities/ForceTouchLink.java index 9ddd5531ba..e2de9feed7 100644 --- a/app/src/main/java/me/ccrama/redditslide/Activities/ForceTouchLink.java +++ b/app/src/main/java/me/ccrama/redditslide/Activities/ForceTouchLink.java @@ -52,6 +52,7 @@ public boolean onTouch(View v, MotionEvent event) { case REDDIT: case IMGUR: case ALBUM: + case REDDIT_GALLERY: case VIDEO: break; case IMAGE: diff --git a/app/src/main/java/me/ccrama/redditslide/Activities/Gallery.java b/app/src/main/java/me/ccrama/redditslide/Activities/Gallery.java index 9139d5f4de..ec528ece14 100644 --- a/app/src/main/java/me/ccrama/redditslide/Activities/Gallery.java +++ b/app/src/main/java/me/ccrama/redditslide/Activities/Gallery.java @@ -99,8 +99,7 @@ public void onCreate(Bundle savedInstance) { @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); - int[] firstVisibleItems; - firstVisibleItems = + int[] firstVisibleItems = ((CatchStaggeredGridLayoutManager) rv.getLayoutManager()).findFirstVisibleItemPositions( null); if (firstVisibleItems != null && firstVisibleItems.length > 0) { @@ -242,6 +241,7 @@ public Fragment getItem(int i) { case EXTERNAL: case SPOILER: case XKCD: + case REDDIT_GALLERY: case DEVIANTART: case EMBEDDED: case LINK: diff --git a/app/src/main/java/me/ccrama/redditslide/Activities/GalleryImage.java b/app/src/main/java/me/ccrama/redditslide/Activities/GalleryImage.java new file mode 100644 index 0000000000..714d3c673c --- /dev/null +++ b/app/src/main/java/me/ccrama/redditslide/Activities/GalleryImage.java @@ -0,0 +1,23 @@ +package me.ccrama.redditslide.Activities; + + +import com.fasterxml.jackson.databind.JsonNode; + +import org.apache.commons.text.StringEscapeUtils; + +import java.io.Serializable; + +/** + * Created by ccrama on 09/22/2020. + */ +public class GalleryImage implements Serializable { + public String url; + public int width; + public int height; + + public GalleryImage(JsonNode data) { + url = StringEscapeUtils.unescapeHtml4(data.get("u").asText()); + width = data.get("x").asInt(); + height = data.get("y").asInt(); + } +} diff --git a/app/src/main/java/me/ccrama/redditslide/Activities/Inbox.java b/app/src/main/java/me/ccrama/redditslide/Activities/Inbox.java index 6c761d20a0..15423f087a 100644 --- a/app/src/main/java/me/ccrama/redditslide/Activities/Inbox.java +++ b/app/src/main/java/me/ccrama/redditslide/Activities/Inbox.java @@ -1,6 +1,5 @@ package me.ccrama.redditslide.Activities; -import android.content.Context; import android.content.Intent; import android.os.AsyncTask; import android.os.Bundle; @@ -13,6 +12,7 @@ import android.view.animation.LinearInterpolator; import android.view.inputmethod.InputMethodManager; +import androidx.core.content.ContextCompat; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentStatePagerAdapter; @@ -278,7 +278,9 @@ public CharSequence getPageTitle(int position) { @Override public void onResume(){ super.onResume(); - InputMethodManager keyboard = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); - keyboard.hideSoftInputFromWindow(getWindow().getAttributes().token, 0); + InputMethodManager keyboard = ContextCompat.getSystemService(this, InputMethodManager.class); + if (keyboard != null) { + keyboard.hideSoftInputFromWindow(getWindow().getAttributes().token, 0); + } } } diff --git a/app/src/main/java/me/ccrama/redditslide/Activities/LiveThread.java b/app/src/main/java/me/ccrama/redditslide/Activities/LiveThread.java index de821e0dc9..b3d0fa074e 100644 --- a/app/src/main/java/me/ccrama/redditslide/Activities/LiveThread.java +++ b/app/src/main/java/me/ccrama/redditslide/Activities/LiveThread.java @@ -7,7 +7,6 @@ import android.graphics.drawable.ColorDrawable; import android.os.AsyncTask; import android.os.Bundle; -import android.text.Html; import android.view.Gravity; import android.view.LayoutInflater; import android.view.Menu; @@ -21,6 +20,7 @@ import android.widget.ImageView; import android.widget.TextView; +import androidx.core.text.HtmlCompat; import androidx.drawerlayout.widget.DrawerLayout; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; @@ -444,9 +444,7 @@ public void onSendingHandshake( } }); ws.connect(); - } catch (IOException e) { - e.printStackTrace(); - } catch (WebSocketException e) { + } catch (IOException | WebSocketException e) { e.printStackTrace(); } return null; @@ -479,7 +477,7 @@ public void onBindViewHolder(final PaginatorAdapter.ItemHolder holder, int posit holder.info.setVisibility(View.GONE); } else { holder.info.setVisibility(View.VISIBLE); - holder.info.setTextHtml(Html.fromHtml(u.getDataNode().get("body_html").asText()), "NO SUBREDDIT"); + holder.info.setTextHtml(HtmlCompat.fromHtml(u.getDataNode().get("body_html").asText(), HtmlCompat.FROM_HTML_MODE_LEGACY), "NO SUBREDDIT"); } holder.title.setOnClickListener(new View.OnClickListener() { @Override @@ -492,7 +490,7 @@ public void onClick(View v) { holder.imageArea.setVisibility(View.GONE); holder.twitterArea.setVisibility(View.GONE); holder.twitterArea.stopLoading(); - if (u.getEmbeds().size() == 0) { + if (u.getEmbeds().isEmpty()) { holder.go.setVisibility(View.GONE); } else { final String url = u.getEmbeds().get(0).getUrl(); @@ -545,7 +543,7 @@ public LoadTwitter(@NotNull WebView view, @NotNull String url) { public void parseJson() { try { JsonObject result = HttpUtil.getJsonObject(client, gson, "https://publish.twitter.com/oembed?url=" + url, null); - LogUtil.v("Got " + Html.fromHtml(result.toString())); + LogUtil.v("Got " + HtmlCompat.fromHtml(result.toString(), HtmlCompat.FROM_HTML_MODE_LEGACY)); twitter = new ObjectMapper().readValue(result.toString(), TwitterObject.class); } catch (Exception e) { e.printStackTrace(); diff --git a/app/src/main/java/me/ccrama/redditslide/Activities/MainActivity.java b/app/src/main/java/me/ccrama/redditslide/Activities/MainActivity.java index 671c33e26f..945d65ac88 100644 --- a/app/src/main/java/me/ccrama/redditslide/Activities/MainActivity.java +++ b/app/src/main/java/me/ccrama/redditslide/Activities/MainActivity.java @@ -280,8 +280,10 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) { View view = MainActivity.this.getCurrentFocus(); if (view != null) { InputMethodManager imm = - (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); - imm.hideSoftInputFromWindow(view.getWindowToken(), 0); + ContextCompat.getSystemService(this, InputMethodManager.class); + if (imm != null) { + imm.hideSoftInputFromWindow(view.getWindowToken(), 0); + } } } else if (requestCode == 2002 && resultCode != RESULT_OK) { mToolbar.performLongClick(); //search was init from the toolbar, so return focus to the toolbar @@ -1307,9 +1309,9 @@ public void networkUnavailable() { public void checkClipboard(){ try { - ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); + ClipboardManager clipboard = ContextCompat.getSystemService(this, ClipboardManager.class); - if (clipboard.hasPrimaryClip()) { + if (clipboard != null && clipboard.hasPrimaryClip()) { ClipData data = clipboard.getPrimaryClip(); final String s = (String) data.getItemAt(0).getText(); if (!s.isEmpty()) { @@ -1341,7 +1343,7 @@ public void onResume() { restartTheme(); //force a restart because we should not be here } - if ((!inNightMode && SettingValues.isNight()) || (inNightMode && !SettingValues.isNight())) { + if (inNightMode != SettingValues.isNight()) { ((SwitchCompat) drawerLayout.findViewById(R.id.toggle_night_mode)).setChecked(SettingValues.isNight()); restartTheme(); } @@ -2226,8 +2228,10 @@ public void onDrawerOpened(View drawerView) { @Override public void onDrawerClosed(View view) { super.onDrawerClosed(view); - InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); - imm.hideSoftInputFromWindow(drawerLayout.getWindowToken(), 0); + InputMethodManager imm = ContextCompat.getSystemService(MainActivity.this, InputMethodManager.class); + if (imm != null) { + imm.hideSoftInputFromWindow(drawerLayout.getWindowToken(), 0); + } } }; @@ -3854,11 +3858,10 @@ public void onClick(DialogInterface dialog, int which) { } public void scrollToTop() { - int[] firstVisibleItems; int pastVisiblesItems = 0; if (((adapter.getCurrentFragment()) == null)) return; - firstVisibleItems = + int[] firstVisibleItems = ((CatchStaggeredGridLayoutManager) (((SubmissionsView) adapter.getCurrentFragment()).rv .getLayoutManager())).findFirstVisibleItemPositions(null); if (firstVisibleItems != null && firstVisibleItems.length > 0) { @@ -4022,9 +4025,10 @@ public boolean onEditorAction(TextView arg0, int arg1, KeyEvent arg2) { drawerSearch.setText(""); View view = MainActivity.this.getCurrentFocus(); if (view != null) { - InputMethodManager imm = (InputMethodManager) getSystemService( - Context.INPUT_METHOD_SERVICE); - imm.hideSoftInputFromWindow(view.getWindowToken(), 0); + InputMethodManager imm = ContextCompat.getSystemService(MainActivity.this, InputMethodManager.class); + if (imm != null) { + imm.hideSoftInputFromWindow(view.getWindowToken(), 0); + } } } } @@ -4159,7 +4163,7 @@ public void onClick(@NonNull MaterialDialog dialog, if (NetworkUtil.isConnected(MainActivity.this)) { if (Authentication.isLoggedIn - && android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) { + && Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) { ShortcutManager shortcutManager = getSystemService(ShortcutManager.class); ArrayList shortcuts = new ArrayList<>(); shortcuts.add(new ShortcutInfo.Builder(this, "inbox").setShortLabel("Inbox") @@ -4200,7 +4204,7 @@ public void onClick(@NonNull MaterialDialog dialog, Collections.reverse(shortcuts); shortcutManager.setDynamicShortcuts(shortcuts); - } else if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) { + } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) { ShortcutManager shortcutManager = getSystemService(ShortcutManager.class); ArrayList shortcuts = new ArrayList<>(); int count = 0; @@ -4239,8 +4243,8 @@ private Icon getIcon(String subreddit, @DrawableRes int overlay) { Bitmap over = drawableToBitmap(ResourcesCompat.getDrawable(getResources(), overlay, null)); Canvas canvas = new Canvas(color); - canvas.drawBitmap(over, color.getWidth() / 2 - (over.getWidth() / 2), - color.getHeight() / 2 - (over.getHeight() / 2), null); + canvas.drawBitmap(over, color.getWidth() / 2.0f - (over.getWidth() / 2.0f), + color.getHeight() / 2.0f - (over.getHeight() / 2.0f), null); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { return Icon.createWithBitmap(color); @@ -4511,10 +4515,11 @@ public boolean onLongClick(View v) { //Get focus of the search field and show the keyboard GO_TO_SUB_FIELD.requestFocus(); - InputMethodManager imm = (InputMethodManager) getSystemService( - Context.INPUT_METHOD_SERVICE); - imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, - InputMethodManager.HIDE_IMPLICIT_ONLY); + InputMethodManager imm = ContextCompat.getSystemService(MainActivity.this, InputMethodManager.class); + if (imm != null) { + imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, + InputMethodManager.HIDE_IMPLICIT_ONLY); + } //Close the search UI and keyboard when clicking the close button @@ -4525,9 +4530,10 @@ public void onClick(View v) { if (view != null) { //Hide the keyboard InputMethodManager imm = - (InputMethodManager) getSystemService( - Context.INPUT_METHOD_SERVICE); - imm.hideSoftInputFromWindow(view.getWindowToken(), 0); + ContextCompat.getSystemService(MainActivity.this, InputMethodManager.class); + if (imm != null) { + imm.hideSoftInputFromWindow(view.getWindowToken(), 0); + } } //run the exit animations @@ -4606,10 +4612,11 @@ public boolean onEditorAction(TextView arg0, int arg1, if (view != null) { //Hide the keyboard InputMethodManager imm = - (InputMethodManager) getSystemService( - Context.INPUT_METHOD_SERVICE); - imm.hideSoftInputFromWindow( - view.getWindowToken(), 0); + ContextCompat.getSystemService(MainActivity.this, InputMethodManager.class); + if (imm != null) { + imm.hideSoftInputFromWindow( + view.getWindowToken(), 0); + } } SUGGESTIONS_BACKGROUND.setVisibility(View.GONE); @@ -4951,8 +4958,10 @@ public void onSingleClick(View v) { badge.setVisibility(View.GONE); } NotificationManager notificationManager = - (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); - notificationManager.cancel(0); + ContextCompat.getSystemService(MainActivity.this, NotificationManager.class); + if (notificationManager != null) { + notificationManager.cancel(0); + } } else if (count != -1) { if (badge != null) { badge.setVisibility(View.VISIBLE); @@ -5269,7 +5278,7 @@ public Fragment getItem(int i) { Fragment f = new CommentPage(); Bundle args = new Bundle(); String name = openingComments.getFullName(); - args.putString("id", name.substring(3, name.length())); + args.putString("id", name.substring(3)); args.putBoolean("archived", openingComments.isArchived()); args.putBoolean("contest", openingComments.getDataNode().get("contest_mode").asBoolean()); diff --git a/app/src/main/java/me/ccrama/redditslide/Activities/MediaView.java b/app/src/main/java/me/ccrama/redditslide/Activities/MediaView.java index 11f78f364f..2d48fe12c5 100644 --- a/app/src/main/java/me/ccrama/redditslide/Activities/MediaView.java +++ b/app/src/main/java/me/ccrama/redditslide/Activities/MediaView.java @@ -2,11 +2,9 @@ import android.animation.Animator; import android.animation.ValueAnimator; -import android.app.Activity; import android.app.Notification; import android.app.NotificationManager; import android.app.PendingIntent; -import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.res.TypedArray; @@ -14,6 +12,7 @@ import android.graphics.Color; import android.graphics.PointF; import android.graphics.PorterDuff; +import android.graphics.PorterDuffColorFilter; import android.graphics.drawable.Drawable; import android.media.MediaScannerConnection; import android.net.Uri; @@ -21,7 +20,6 @@ import android.os.Bundle; import android.os.Environment; import android.os.Handler; -import android.text.Html; import android.util.Log; import android.view.View; import android.view.ViewGroup; @@ -33,10 +31,14 @@ import android.widget.Toast; import androidx.core.app.NotificationCompat; +import androidx.core.content.ContextCompat; +import androidx.core.text.HtmlCompat; import androidx.interpolator.view.animation.FastOutSlowInInterpolator; import com.afollestad.materialdialogs.AlertDialogWrapper; import com.cocosw.bottomsheet.BottomSheet; +import com.davemorrissey.labs.subscaleview.decoder.CompatDecoderFactory; +import com.davemorrissey.labs.subscaleview.decoder.SkiaImageDecoder; import com.google.gson.Gson; import com.google.gson.JsonObject; import com.nostra13.universalimageloader.core.DisplayImageOptions; @@ -82,6 +84,7 @@ import me.ccrama.redditslide.util.ShareUtil; import static me.ccrama.redditslide.Activities.AlbumPager.readableFileSize; +import static me.ccrama.redditslide.Notifications.ImageDownloadNotificationService.*; /** @@ -99,6 +102,8 @@ public class MediaView extends FullScreenActivity public static String fileLoc; public String subreddit; + private String submissionTitle; + private int index; public static Runnable doOnClick; public static boolean didLoadGif; @@ -220,21 +225,21 @@ public void showBottomSheetImage() { TypedArray ta = obtainStyledAttributes(attrs); int color = ta.getColor(0, Color.WHITE); - Drawable external = getResources().getDrawable(R.drawable.openexternal); + Drawable external = getResources().getDrawable(R.drawable.open_external); Drawable share = getResources().getDrawable(R.drawable.share); Drawable image = getResources().getDrawable(R.drawable.image); Drawable save = getResources().getDrawable(R.drawable.save); Drawable collection = getResources().getDrawable(R.drawable.collection); - Drawable file = getResources().getDrawable(R.drawable.savecontent); + Drawable file = getResources().getDrawable(R.drawable.save_content); Drawable thread = getResources().getDrawable(R.drawable.commentchange); - external.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - share.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - image.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - save.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - collection.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - file.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - thread.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); + external.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + share.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + image.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + save.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + collection.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + file.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + thread.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); ta.recycle(); @@ -252,13 +257,14 @@ public void showBottomSheetImage() { && !contentUrl.contains(".mp4") && !contentUrl.contains("streamable.com") && !contentUrl.contains("gfycat.com") + && !contentUrl.contains("redgifs.com") && !contentUrl.contains("v.redd.it")) { String type = contentUrl.substring(contentUrl.lastIndexOf(".") + 1).toUpperCase(); try { if (type.equals("GIFV") && new URL(contentUrl).getHost().equals("i.imgur.com")) { type = "GIF"; contentUrl = contentUrl.replace(".gifv", ".gif"); - //todo possibly share gifs b.sheet(9, share, "Share GIF"); + //todo possibly share gifs b.sheet(9, ic_share, "Share GIF"); } } catch (MalformedURLException e) { e.printStackTrace(); @@ -323,6 +329,8 @@ public void doImageSave() { //always download the original file, or use the cached original if that is currently displayed i.putExtra("actuallyLoaded", contentUrl); if (subreddit != null && !subreddit.isEmpty()) i.putExtra("subreddit", subreddit); + if (submissionTitle != null) i.putExtra(EXTRA_SUBMISSION_TITLE, submissionTitle); + i.putExtra("index", index); startService(i); } } else { @@ -357,10 +365,10 @@ protected Void doInBackground(Void... params) { .randomUUID() .toString() + baseUrl.substring(baseUrl.lastIndexOf("."))); mNotifyManager = - (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); + ContextCompat.getSystemService(MediaView.this, NotificationManager.class); mBuilder = new NotificationCompat.Builder(MediaView.this, Reddit.CHANNEL_IMG); mBuilder.setContentTitle(getString(R.string.mediaview_saving, baseUrl)) - .setSmallIcon(R.drawable.download_png); + .setSmallIcon(R.drawable.save); try { final URL url = @@ -408,14 +416,15 @@ public void onScanCompleted(String path, Uri uri) { Notification notif = new NotificationCompat.Builder( MediaView.this, Reddit.CHANNEL_IMG) .setContentTitle(getString(R.string.gif_saved)) - .setSmallIcon(R.drawable.save_png) + .setSmallIcon(R.drawable.save_content) .setContentIntent(contentIntent) .build(); NotificationManager mNotificationManager = - (NotificationManager) getSystemService( - Activity.NOTIFICATION_SERVICE); - mNotificationManager.notify(1, notif); + ContextCompat.getSystemService(MediaView.this, NotificationManager.class); + if (mNotificationManager != null) { + mNotificationManager.notify(1, notif); + } } }); } catch (Exception e) { @@ -442,7 +451,7 @@ protected Void doInBackground(Void... params) { .randomUUID() .toString() + baseUrl.substring(baseUrl.lastIndexOf("."))); mNotifyManager = - (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); + ContextCompat.getSystemService(MediaView.this, NotificationManager.class); mBuilder = new NotificationCompat.Builder(MediaView.this, Reddit.CHANNEL_IMG); mBuilder.setContentTitle(getString(R.string.mediaview_saving, baseUrl)) .setSmallIcon(R.drawable.save); @@ -487,9 +496,11 @@ public void onScanCompleted(String path, Uri uri) { startActivity( Intent.createChooser(shareIntent, "Share GIF")); NotificationManager mNotificationManager = - (NotificationManager) getSystemService( - Activity.NOTIFICATION_SERVICE); - mNotificationManager.cancel(1); + ContextCompat.getSystemService(MediaView.this, + NotificationManager.class); + if (mNotificationManager != null) { + mNotificationManager.cancel(1); + } } }); } catch (Exception e) { @@ -638,7 +649,7 @@ public void run() { setShareUrl(contentUrl); if (contentUrl.contains("reddituploads.com")) { - contentUrl = Html.fromHtml(contentUrl).toString(); + contentUrl = HtmlCompat.fromHtml(contentUrl, HtmlCompat.FROM_HTML_MODE_LEGACY).toString(); } if (contentUrl != null && shouldTruncate(contentUrl)) { contentUrl = contentUrl.substring(0, contentUrl.lastIndexOf(".")); @@ -660,6 +671,10 @@ public void onClick(View v) { if (getIntent().hasExtra(SUBREDDIT)) { subreddit = getIntent().getExtras().getString(SUBREDDIT); } + if (getIntent().hasExtra(EXTRA_SUBMISSION_TITLE)) { + submissionTitle = getIntent().getExtras().getString(EXTRA_SUBMISSION_TITLE); + } + index = getIntent().getIntExtra("index", -1); findViewById(R.id.mute).setVisibility(View.GONE); if (getIntent().hasExtra(EXTRA_LQ)) { @@ -678,8 +693,8 @@ public void onClick(View v) { || (!NetworkUtil.isConnectedWifi(this) && SettingValues.lowResMobile))) { String url = contentUrl; url = url.substring(0, url.lastIndexOf(".")) + (SettingValues.lqLow ? "m" - : (SettingValues.lqMid ? "l" : "h")) + url.substring(url.lastIndexOf("."), - url.length()); + : (SettingValues.lqMid ? "l" : "h")) + url.substring(url.lastIndexOf(".") + ); displayImage(url); findViewById(R.id.hq).setOnClickListener(new View.OnClickListener() { @@ -729,10 +744,8 @@ public void onClick(View v) { hideOnLongClick(); } - private ContentType.Type contentType = ContentType.Type.IMAGE; - public void doLoad(final String contentUrl) { - contentType = ContentType.getContentType(contentUrl); + ContentType.Type contentType = ContentType.getContentType(contentUrl); switch (contentType) { case DEVIANTART: doLoadDeviantArt(contentUrl); @@ -791,10 +804,10 @@ public void doLoadImgur(String url) { url = url.substring(0, url.length() - 1); } final String finalUrl = url; - String hash = url.substring(url.lastIndexOf("/"), url.length()); + String hash = url.substring(url.lastIndexOf("/")); if (NetworkUtil.isConnected(this)) { - if (hash.startsWith("/")) hash = hash.substring(1, hash.length()); + if (hash.startsWith("/")) hash = hash.substring(1); final String apiUrl = "https://imgur-apiv3.p.mashape.com/3/image/" + hash + ".json"; LogUtil.v(apiUrl); @@ -1187,13 +1200,11 @@ public void onCenterChanged(PointF newCenter, int origin) { .imageScaleType(ImageScaleType.NONE) .cacheInMemory(false) .build(), new ImageLoadingListener() { - private View mView; @Override public void onLoadingStarted(String imageUri, View view) { imageShown = true; size.setVisibility(View.VISIBLE); - mView = view; } @Override @@ -1366,6 +1377,8 @@ public void onFolderSelection(FolderChooserDialogCreate dialog, File folder, boo i.putExtra("actuallyLoaded", contentUrl); i.putExtra("saveToLocation", folder.getAbsolutePath()); if (subreddit != null && !subreddit.isEmpty()) i.putExtra("subreddit", subreddit); + if (submissionTitle != null) i.putExtra(EXTRA_SUBMISSION_TITLE, submissionTitle); + i.putExtra("index", index); startService(i); } else { Reddit.appRestart.edit().putString("imagelocation", folder.getAbsolutePath()).apply(); diff --git a/app/src/main/java/me/ccrama/redditslide/Activities/ModQueue.java b/app/src/main/java/me/ccrama/redditslide/Activities/ModQueue.java index 6b3fd1f78d..d3635f735b 100644 --- a/app/src/main/java/me/ccrama/redditslide/Activities/ModQueue.java +++ b/app/src/main/java/me/ccrama/redditslide/Activities/ModQueue.java @@ -81,7 +81,7 @@ public Fragment getCurrentFragment() { @Override public void setPrimaryItem(ViewGroup container, int position, Object object) { - if (getCurrentFragment() != object) { + if (mCurrentFragment != object) { mCurrentFragment = ((Fragment) object); } super.setPrimaryItem(container, position, object); diff --git a/app/src/main/java/me/ccrama/redditslide/Activities/MultiredditOverview.java b/app/src/main/java/me/ccrama/redditslide/Activities/MultiredditOverview.java index 72767b96c6..bf79b5c54a 100644 --- a/app/src/main/java/me/ccrama/redditslide/Activities/MultiredditOverview.java +++ b/app/src/main/java/me/ccrama/redditslide/Activities/MultiredditOverview.java @@ -1,10 +1,12 @@ package me.ccrama.redditslide.Activities; +import android.app.Activity; import android.content.ActivityNotFoundException; import android.content.DialogInterface; import android.content.Intent; import android.content.res.Configuration; import android.graphics.PorterDuff; +import android.graphics.PorterDuffColorFilter; import android.net.Uri; import android.os.Build; import android.os.Bundle; @@ -67,6 +69,8 @@ public class MultiredditOverview extends BaseActivityAnim { public static final String EXTRA_PROFILE = "profile"; public static final String EXTRA_MULTI = "multi"; + public static Activity multiActivity; + public static MultiReddit searchMulti; public OverviewPagerAdapter adapter; private ViewPager pager; @@ -423,6 +427,8 @@ public void onClick(DialogInterface dialog, int which) { public void onCreate(Bundle savedInstance) { overrideSwipeFromAnywhere(); + multiActivity = this; + super.onCreate(savedInstance); applyColorTheme(""); @@ -656,9 +662,8 @@ private void setDataSet(List data) { @Override public void onTabReselected(TabLayout.Tab tab) { super.onTabReselected(tab); - int[] firstVisibleItems; int pastVisiblesItems = 0; - firstVisibleItems = + int[] firstVisibleItems = ((CatchStaggeredGridLayoutManager) (((MultiredditView) adapter.getCurrentFragment()).rv .getLayoutManager())).findFirstVisibleItemPositions(null); if (firstVisibleItems != null && firstVisibleItems.length > 0) { @@ -711,7 +716,7 @@ public void doDrawerSubs(int position) { convertView.findViewById(R.id.color).setBackgroundResource(R.drawable.circle); convertView.findViewById(R.id.color) .getBackground() - .setColorFilter(Palette.getColor(subreddit), PorterDuff.Mode.MULTIPLY); + .setColorFilter(new PorterDuffColorFilter(Palette.getColor(subreddit), PorterDuff.Mode.MULTIPLY)); convertView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { @@ -782,7 +787,7 @@ public Fragment getCurrentFragment() { @Override public void setPrimaryItem(ViewGroup container, int position, Object object) { - if (getCurrentFragment() != object) { + if (mCurrentFragment != object) { mCurrentFragment = ((Fragment) object); } super.setPrimaryItem(container, position, object); diff --git a/app/src/main/java/me/ccrama/redditslide/Activities/NewsActivity.java b/app/src/main/java/me/ccrama/redditslide/Activities/NewsActivity.java index b63a39d1d7..103854d247 100644 --- a/app/src/main/java/me/ccrama/redditslide/Activities/NewsActivity.java +++ b/app/src/main/java/me/ccrama/redditslide/Activities/NewsActivity.java @@ -251,8 +251,7 @@ public void networkUnavailable() { public void onResume() { super.onResume(); - if ((!inNightMode && SettingValues.isNight()) || (inNightMode - && !SettingValues.isNight())) { + if (inNightMode != SettingValues.isNight()) { restartTheme(); } @@ -376,11 +375,10 @@ public void restartTheme() { } public void scrollToTop() { - int[] firstVisibleItems; int pastVisiblesItems = 0; if (((adapter.getCurrentFragment()) == null)) return; - firstVisibleItems = + int[] firstVisibleItems = ((CatchStaggeredGridLayoutManager) (((NewsView) adapter.getCurrentFragment()).rv.getLayoutManager())) .findFirstVisibleItemPositions(null); if (firstVisibleItems != null && firstVisibleItems.length > 0) { diff --git a/app/src/main/java/me/ccrama/redditslide/Activities/PostReadLater.java b/app/src/main/java/me/ccrama/redditslide/Activities/PostReadLater.java index bd3188fd40..31a3a4eeac 100644 --- a/app/src/main/java/me/ccrama/redditslide/Activities/PostReadLater.java +++ b/app/src/main/java/me/ccrama/redditslide/Activities/PostReadLater.java @@ -16,8 +16,6 @@ */ public class PostReadLater extends BaseActivityAnim { - private ViewPager pager; - @Override public void onCreate(Bundle savedInstance) { overrideSwipeFromAnywhere(); @@ -29,7 +27,7 @@ public void onCreate(Bundle savedInstance) { setupAppBar(R.id.toolbar, "Read later", true, true); mToolbar.setPopupTheme(new ColorPreferences(this).getFontStyle().getBaseId()); - pager = (ViewPager) findViewById(R.id.content_view); + ViewPager pager = (ViewPager) findViewById(R.id.content_view); pager.setAdapter(new ReadLaterAdaptor(getSupportFragmentManager())); } diff --git a/app/src/main/java/me/ccrama/redditslide/Activities/Profile.java b/app/src/main/java/me/ccrama/redditslide/Activities/Profile.java index 21e8b7f39b..dd853694ae 100644 --- a/app/src/main/java/me/ccrama/redditslide/Activities/Profile.java +++ b/app/src/main/java/me/ccrama/redditslide/Activities/Profile.java @@ -915,6 +915,7 @@ public void onAnimationEnd(Animator animation) { ((TextView) dialoglayout.findViewById(R.id.commentkarma)).setText(String.format(Locale.getDefault(), "%d", account.getCommentKarma())); ((TextView) dialoglayout.findViewById(R.id.linkkarma)).setText(String.format(Locale.getDefault(), "%d", account.getLinkKarma())); + ((TextView) dialoglayout.findViewById(R.id.totalKarma)).setText(String.format(Locale.getDefault(), "%d", account.getCommentKarma() + account.getLinkKarma())); builder.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override diff --git a/app/src/main/java/me/ccrama/redditslide/Activities/RedditGallery.java b/app/src/main/java/me/ccrama/redditslide/Activities/RedditGallery.java new file mode 100644 index 0000000000..27943c0d86 --- /dev/null +++ b/app/src/main/java/me/ccrama/redditslide/Activities/RedditGallery.java @@ -0,0 +1,329 @@ +package me.ccrama.redditslide.Activities; + +import android.content.DialogInterface; +import android.content.Intent; +import android.graphics.Color; +import android.os.Bundle; +import android.os.Environment; +import android.view.LayoutInflater; +import android.view.Menu; +import android.view.MenuInflater; +import android.view.MenuItem; +import android.view.View; +import android.view.ViewGroup; +import android.view.WindowManager; +import android.widget.Toast; + +import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentManager; +import androidx.fragment.app.FragmentStatePagerAdapter; +import androidx.recyclerview.widget.RecyclerView; +import androidx.viewpager.widget.ViewPager; + +import com.afollestad.materialdialogs.AlertDialogWrapper; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +import me.ccrama.redditslide.Adapters.RedditGalleryView; +import me.ccrama.redditslide.ColorPreferences; +import me.ccrama.redditslide.Fragments.BlankFragment; +import me.ccrama.redditslide.Fragments.FolderChooserDialogCreate; +import me.ccrama.redditslide.Fragments.SubmissionsView; +import me.ccrama.redditslide.Notifications.ImageDownloadNotificationService; +import me.ccrama.redditslide.R; +import me.ccrama.redditslide.Reddit; +import me.ccrama.redditslide.SettingValues; +import me.ccrama.redditslide.Views.PreCachingLayoutManager; +import me.ccrama.redditslide.Views.ToolbarColorizeHelper; +import me.ccrama.redditslide.util.LinkUtil; + +import static me.ccrama.redditslide.Notifications.ImageDownloadNotificationService.*; + +public class RedditGallery extends FullScreenActivity implements FolderChooserDialogCreate.FolderCallback { + public static final String SUBREDDIT = "subreddit"; + public static final String GALLERY_URLS = "galleryurls"; + private List images; + private int adapterPosition; + + @Override + public void onFolderSelection(FolderChooserDialogCreate dialog, File folder, boolean isSaveToLocation) { + if (folder != null) { + Reddit.appRestart.edit().putString("imagelocation", folder.getAbsolutePath()).apply(); + Toast.makeText(this, + getString(R.string.settings_set_image_location, folder.getAbsolutePath()), + Toast.LENGTH_LONG).show(); + } + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + int id = item.getItemId(); + + if (id == android.R.id.home) { + onBackPressed(); + } + if (id == R.id.slider) { + SettingValues.albumSwipe = true; + SettingValues.prefs.edit().putBoolean(SettingValues.PREF_ALBUM_SWIPE, true).apply(); + Intent i = new Intent(RedditGallery.this, RedditGalleryPager.class); + int adapterPosition = getIntent().getIntExtra(MediaView.ADAPTER_POSITION, -1); + i.putExtra(MediaView.ADAPTER_POSITION, adapterPosition); + if (getIntent().hasExtra(MediaView.SUBMISSION_URL)) { + i.putExtra(MediaView.SUBMISSION_URL, + getIntent().getStringExtra(MediaView.SUBMISSION_URL)); + } + if (subreddit != null && !subreddit.isEmpty()) i.putExtra(RedditGalleryPager.SUBREDDIT, subreddit); + if (submissionTitle != null) i.putExtra(EXTRA_SUBMISSION_TITLE, submissionTitle); + Bundle urlsBundle = new Bundle(); + urlsBundle.putSerializable(RedditGallery.GALLERY_URLS, new ArrayList(images)); + i.putExtras(urlsBundle); + + startActivity(i); + finish(); + } + if (id == R.id.grid) { + mToolbar.findViewById(R.id.grid).callOnClick(); + } + if (id == R.id.comments) { + SubmissionsView.datachanged(adapterPosition); + finish(); + } + if (id == R.id.external) { + LinkUtil.openExternally(url); + } + if (id == R.id.download) { + int index = 0; + for (final GalleryImage elem : images) { + doImageSave(false, elem.url, index); + index++; + } + } + + return super.onOptionsItemSelected(item); + } + + public void doImageSave(boolean isGif, String contentUrl, int index) { + if (!isGif) { + if (Reddit.appRestart.getString("imagelocation", "").isEmpty()) { + showFirstDialog(); + } else if (!new File(Reddit.appRestart.getString("imagelocation", "")).exists()) { + showErrorDialog(); + } else { + Intent i = new Intent(this, ImageDownloadNotificationService.class); + i.putExtra("actuallyLoaded", contentUrl); + if (subreddit != null && !subreddit.isEmpty()) i.putExtra("subreddit", subreddit); + if (submissionTitle != null) i.putExtra(EXTRA_SUBMISSION_TITLE, submissionTitle); + i.putExtra("index", index); + startService(i); + } + } else { + MediaView.doOnClick.run(); + } + } + + public void showFirstDialog() { + try { + new AlertDialogWrapper.Builder(this).setTitle(R.string.set_save_location) + .setMessage(R.string.set_save_location_msg) + .setPositiveButton(R.string.btn_yes, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + new FolderChooserDialogCreate.Builder(RedditGallery.this).chooseButton( + R.string.btn_select) // changes label of the choose button + .initialPath(Environment.getExternalStorageDirectory() + .getPath()) // changes initial path, defaults to external storage directory + .show(); + } + }) + .setNegativeButton(R.string.btn_no, null) + .show(); + } catch (Exception ignored) { + + } + } + + public void showErrorDialog() { + new AlertDialogWrapper.Builder(RedditGallery.this).setTitle(R.string.err_something_wrong) + .setMessage(R.string.err_couldnt_save_choose_new) + .setPositiveButton(R.string.btn_yes, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + new FolderChooserDialogCreate.Builder(RedditGallery.this).chooseButton( + R.string.btn_select) // changes label of the choose button + .initialPath(Environment.getExternalStorageDirectory() + .getPath()) // changes initial path, defaults to external storage directory + .show(); + } + }) + .setNegativeButton(R.string.btn_no, null) + .show(); + } + + public String url; + public String subreddit; + private String submissionTitle; + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + MenuInflater inflater = getMenuInflater(); + inflater.inflate(R.menu.album_vertical, menu); + adapterPosition = getIntent().getIntExtra(MediaView.ADAPTER_POSITION, -1); + if (adapterPosition < 0) { + menu.findItem(R.id.comments).setVisible(false); + } + return true; + } + + public OverviewPagerAdapter album; + + public void onCreate(Bundle savedInstanceState) { + overrideSwipeFromAnywhere(); + super.onCreate(savedInstanceState); + getTheme().applyStyle( + new ColorPreferences(this).getDarkThemeSubreddit(ColorPreferences.FONT_STYLE), + true); + setContentView(R.layout.album); + + //Keep the screen on + getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); + + if(getIntent().hasExtra(SUBREDDIT)){ + this.subreddit = getIntent().getExtras().getString(SUBREDDIT); + } + if (getIntent().hasExtra(EXTRA_SUBMISSION_TITLE)) { + this.submissionTitle = getIntent().getExtras().getString(EXTRA_SUBMISSION_TITLE); + } + + final ViewPager pager = (ViewPager) findViewById(R.id.images); + + album = new OverviewPagerAdapter(getSupportFragmentManager()); + pager.setAdapter(album); + pager.setCurrentItem(1); + pager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { + @Override + public void onPageScrolled(int position, float positionOffset, + int positionOffsetPixels) { + if (position == 0 && positionOffsetPixels == 0) { + finish(); + } + if (position == 0 + && ((OverviewPagerAdapter) pager.getAdapter()).blankPage != null) { + if (((OverviewPagerAdapter) pager.getAdapter()).blankPage + != null) { + ((OverviewPagerAdapter) pager.getAdapter()).blankPage + .doOffset(positionOffset); + } + ((OverviewPagerAdapter) pager.getAdapter()).blankPage.realBack.setBackgroundColor( + adjustAlpha(positionOffset * 0.7f)); + } + } + + @Override + public void onPageSelected(int position) { + } + + @Override + public void onPageScrollStateChanged(int state) { + + } + } + + ); + + if (!Reddit.appRestart.contains("tutorialSwipe")) { + startActivityForResult(new Intent(this, SwipeTutorial.class), 3); + } + } + + @Override + protected void onActivityResult(int requestCode, int resultCode, Intent data) { + super.onActivityResult(requestCode, resultCode, data); + if (requestCode == 3) { + Reddit.appRestart.edit().putBoolean("tutorialSwipe", true).apply(); + + } + } + + public static class OverviewPagerAdapter extends FragmentStatePagerAdapter { + public BlankFragment blankPage; + public AlbumFrag album; + + public OverviewPagerAdapter(FragmentManager fm) { + super(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT); + } + + @Override + public Fragment getItem(int i) { + if (i == 0) { + blankPage = new BlankFragment(); + return blankPage; + } else { + album = new AlbumFrag(); + return album; + + } + } + + @Override + public int getCount() { + + return 2; + } + + } + + public int adjustAlpha(float factor) { + int alpha = Math.round(Color.alpha(Color.BLACK) * factor); + int red = Color.red(Color.BLACK); + int green = Color.green(Color.BLACK); + int blue = Color.blue(Color.BLACK); + return Color.argb(alpha, red, green, blue); + } + + public static class AlbumFrag extends Fragment { + View rootView; + public RecyclerView recyclerView; + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + rootView = inflater.inflate(R.layout.fragment_verticalalbum, container, false); + + final PreCachingLayoutManager mLayoutManager = new PreCachingLayoutManager(getActivity()); + recyclerView = rootView.findViewById(R.id.images); + recyclerView.setLayoutManager(mLayoutManager); + final RedditGallery galleryActivity = (RedditGallery) getActivity(); + galleryActivity.images = (ArrayList) + getActivity().getIntent().getSerializableExtra(RedditGallery.GALLERY_URLS); + + ((BaseActivity) getActivity()).setShareUrl(galleryActivity.url); + + galleryActivity.mToolbar = rootView.findViewById(R.id.toolbar); + galleryActivity.mToolbar.setTitle(R.string.type_album); + ToolbarColorizeHelper.colorizeToolbar(galleryActivity.mToolbar, Color.WHITE, + (getActivity())); + galleryActivity.setSupportActionBar(galleryActivity.mToolbar); + galleryActivity.getSupportActionBar().setDisplayHomeAsUpEnabled(true); + + galleryActivity.mToolbar.setPopupTheme( + new ColorPreferences(getActivity()).getDarkThemeSubreddit( + ColorPreferences.FONT_STYLE)); + + rootView.post(new Runnable() { + @Override + public void run() { + rootView.findViewById(R.id.progress).setVisibility(View.GONE); + RedditGalleryView adapter = new RedditGalleryView(galleryActivity, galleryActivity.images, + rootView.findViewById(R.id.toolbar).getHeight(), galleryActivity.subreddit, + galleryActivity.submissionTitle); + recyclerView.setAdapter(adapter); + } + }); + + return rootView; + } + } + +} diff --git a/app/src/main/java/me/ccrama/redditslide/Activities/RedditGalleryPager.java b/app/src/main/java/me/ccrama/redditslide/Activities/RedditGalleryPager.java new file mode 100644 index 0000000000..682d8dd87b --- /dev/null +++ b/app/src/main/java/me/ccrama/redditslide/Activities/RedditGalleryPager.java @@ -0,0 +1,580 @@ +package me.ccrama.redditslide.Activities; + +import android.app.Dialog; +import android.content.DialogInterface; +import android.content.Intent; +import android.content.res.TypedArray; +import android.graphics.Bitmap; +import android.graphics.Color; +import android.graphics.PorterDuff; +import android.graphics.PorterDuffColorFilter; +import android.graphics.Typeface; +import android.graphics.drawable.Drawable; +import android.os.AsyncTask; +import android.os.Bundle; +import android.os.Environment; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.Menu; +import android.view.MenuInflater; +import android.view.MenuItem; +import android.view.View; +import android.view.ViewGroup; +import android.view.WindowManager; +import android.widget.AdapterView; +import android.widget.GridView; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.ProgressBar; +import android.widget.TextView; +import android.widget.Toast; + +import com.afollestad.materialdialogs.AlertDialogWrapper; +import com.cocosw.bottomsheet.BottomSheet; +import com.devspark.robototextview.RobotoTypefaces; +import com.nostra13.universalimageloader.core.DisplayImageOptions; +import com.nostra13.universalimageloader.core.assist.FailReason; +import com.nostra13.universalimageloader.core.assist.ImageScaleType; +import com.nostra13.universalimageloader.core.imageaware.ImageViewAware; +import com.nostra13.universalimageloader.core.listener.ImageLoadingListener; +import com.nostra13.universalimageloader.core.listener.ImageLoadingProgressListener; +import com.sothree.slidinguppanel.SlidingUpPanelLayout; + +import java.io.File; +import java.net.MalformedURLException; +import java.net.URL; +import java.text.DecimalFormat; +import java.util.ArrayList; +import java.util.List; + +import androidx.appcompat.widget.Toolbar; +import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentManager; +import androidx.fragment.app.FragmentStatePagerAdapter; +import androidx.viewpager.widget.ViewPager; +import me.ccrama.redditslide.Adapters.ImageGridAdapter; +import me.ccrama.redditslide.ColorPreferences; +import me.ccrama.redditslide.Fragments.BlankFragment; +import me.ccrama.redditslide.Fragments.FolderChooserDialogCreate; +import me.ccrama.redditslide.Fragments.SubmissionsView; +import me.ccrama.redditslide.ImgurAlbum.Image; +import me.ccrama.redditslide.Notifications.ImageDownloadNotificationService; +import me.ccrama.redditslide.R; +import me.ccrama.redditslide.Reddit; +import me.ccrama.redditslide.SettingValues; +import me.ccrama.redditslide.SpoilerRobotoTextView; +import me.ccrama.redditslide.Views.ImageSource; +import me.ccrama.redditslide.Views.SubsamplingScaleImageView; +import me.ccrama.redditslide.Views.ToolbarColorizeHelper; +import me.ccrama.redditslide.Visuals.FontPreferences; +import me.ccrama.redditslide.util.LinkUtil; +import me.ccrama.redditslide.util.NetworkUtil; +import me.ccrama.redditslide.util.ShareUtil; +import me.ccrama.redditslide.util.SubmissionParser; + +import static me.ccrama.redditslide.Notifications.ImageDownloadNotificationService.EXTRA_SUBMISSION_TITLE; + +/** + * Created by ccrama on 11/7/2020.

This is an extension of RedditAlbum.java which utilizes a + * ViewPager for Reddit Gallery content instead of a RecyclerView (horizontal vs vertical). + */ +public class RedditGalleryPager extends FullScreenActivity + implements FolderChooserDialogCreate.FolderCallback { + + private static int adapterPosition; + public static final String SUBREDDIT = "subreddit"; + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + int id = item.getItemId(); + + if (id == android.R.id.home) { + onBackPressed(); + } + if (id == R.id.vertical) { + SettingValues.albumSwipe = false; + SettingValues.prefs.edit().putBoolean(SettingValues.PREF_ALBUM_SWIPE, false).apply(); + Intent i = new Intent(RedditGalleryPager.this, RedditGallery.class); + if (getIntent().hasExtra(MediaView.SUBMISSION_URL)) { + i.putExtra(MediaView.SUBMISSION_URL, + getIntent().getStringExtra(MediaView.SUBMISSION_URL)); + } + if(getIntent().hasExtra(SUBREDDIT)){ + i.putExtra(SUBREDDIT, getIntent().getStringExtra(SUBREDDIT)); + } + if (submissionTitle != null) i.putExtra(EXTRA_SUBMISSION_TITLE, submissionTitle); + i.putExtras(getIntent()); + Bundle urlsBundle = new Bundle(); + urlsBundle.putSerializable(RedditGallery.GALLERY_URLS, new ArrayList(images)); + i.putExtras(urlsBundle); + + startActivity(i); + finish(); + } + if (id == R.id.grid) { + mToolbar.findViewById(R.id.grid).callOnClick(); + } + if (id == R.id.external) { + LinkUtil.openExternally(getIntent().getExtras().getString("url", "")); + } + + if (id == R.id.comments) { + int adapterPosition = getIntent().getIntExtra(MediaView.ADAPTER_POSITION, -1); + finish(); + SubmissionsView.datachanged(adapterPosition); + //getIntent().getStringExtra(MediaView.SUBMISSION_SUBREDDIT)); + //SubmissionAdapter.setOpen(this, getIntent().getStringExtra(MediaView.SUBMISSION_URL)); + } + + if (id == R.id.download && images != null) { + int index = 0; + for (final GalleryImage elem : images) { + doImageSave(false, elem.url, index); + index++; + } + } + + return super.onOptionsItemSelected(item); + } + + @Override + protected void onActivityResult(int requestCode, int resultCode, Intent data) { + super.onActivityResult(requestCode, resultCode, data); + if (requestCode == 3) { + Reddit.appRestart.edit().putBoolean("tutorialSwipe", true).apply(); + } + } + + public String subreddit; + private String submissionTitle; + + public void onCreate(Bundle savedInstanceState) { + overrideSwipeFromAnywhere(); + super.onCreate(savedInstanceState); + getTheme().applyStyle( + new ColorPreferences(this).getDarkThemeSubreddit(ColorPreferences.FONT_STYLE), + true); + setContentView(R.layout.album_pager); + + //Keep the screen on + getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); + + if(getIntent().hasExtra(SUBREDDIT)){ + this.subreddit = getIntent().getStringExtra(SUBREDDIT); + } + if (getIntent().hasExtra(EXTRA_SUBMISSION_TITLE)) { + this.submissionTitle = getIntent().getExtras().getString(EXTRA_SUBMISSION_TITLE); + } + + mToolbar = (Toolbar) findViewById(R.id.toolbar); + mToolbar.setTitle(R.string.type_album); + ToolbarColorizeHelper.colorizeToolbar(mToolbar, Color.WHITE, this); + setSupportActionBar(mToolbar); + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + + mToolbar.setPopupTheme( + new ColorPreferences(this).getDarkThemeSubreddit(ColorPreferences.FONT_STYLE)); + + adapterPosition = getIntent().getIntExtra(MediaView.ADAPTER_POSITION, -1); + + String url = getIntent().getExtras().getString("url", ""); + setShareUrl(url); + + if (!Reddit.appRestart.contains("tutorialSwipe")) { + startActivityForResult(new Intent(this, SwipeTutorial.class), 3); + } + + findViewById(R.id.progress).setVisibility(View.GONE); + images = (ArrayList) + getIntent().getSerializableExtra(RedditGallery.GALLERY_URLS); + + p = (ViewPager) findViewById(R.id.images_horizontal); + + if (getSupportActionBar() != null) { + getSupportActionBar().setSubtitle(1 + "/" + images.size()); + } + + GalleryViewPager adapter = new GalleryViewPager(getSupportFragmentManager()); + p.setAdapter(adapter); + p.setCurrentItem(1); + findViewById(R.id.grid).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + LayoutInflater l = getLayoutInflater(); + View body = l.inflate(R.layout.album_grid_dialog, null, false); + AlertDialogWrapper.Builder b = new AlertDialogWrapper.Builder(RedditGalleryPager.this); + GridView gridview = body.findViewById(R.id.images); + gridview.setAdapter(new ImageGridAdapter(RedditGalleryPager.this, true, images)); + + + b.setView(body); + final Dialog d = b.create(); + gridview.setOnItemClickListener(new AdapterView.OnItemClickListener() { + public void onItemClick(AdapterView parent, View v, int position, + long id) { + p.setCurrentItem(position + 1); + d.dismiss(); + } + }); + d.show(); + } + }); + p.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { + @Override + public void onPageScrolled(int position, float positionOffset, + int positionOffsetPixels) { + if (position != 0) { + if (getSupportActionBar() != null) { + getSupportActionBar().setSubtitle((position) + "/" + images.size()); + } + } + if (position == 0 && positionOffset < 0.2) { + finish(); + } + } + + @Override + public void onPageSelected(int position) { + } + + @Override + public void onPageScrollStateChanged(int state) { + + } + }); + adapter.notifyDataSetChanged(); + + } + + ViewPager p; + + private List images; + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + MenuInflater inflater = getMenuInflater(); + inflater.inflate(R.menu.album_pager, menu); + adapterPosition = getIntent().getIntExtra(MediaView.ADAPTER_POSITION, -1); + if (adapterPosition < 0) { + menu.findItem(R.id.comments).setVisible(false); + } + return true; + } + + public class GalleryViewPager extends FragmentStatePagerAdapter { + public GalleryViewPager(FragmentManager m) { + super(m, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT); + } + + @Override + public Fragment getItem(int i) { + + if (i == 0) { + return new BlankFragment(); + } + + i--; + + Fragment f = new ImageFullNoSubmission(); + Bundle args = new Bundle(); + args.putInt("page", i); + f.setArguments(args); + + return f; + } + + + @Override + public int getCount() { + if (images == null) { + return 0; + } + return images.size() + 1; + } + } + + public void showBottomSheetImage(final String contentUrl, final boolean isGif, + final int index) { + + int[] attrs = new int[]{R.attr.tintColor}; + TypedArray ta = obtainStyledAttributes(attrs); + + int color = ta.getColor(0, Color.WHITE); + Drawable external = getResources().getDrawable(R.drawable.open_external); + Drawable share = getResources().getDrawable(R.drawable.share); + Drawable image = getResources().getDrawable(R.drawable.image); + Drawable save = getResources().getDrawable(R.drawable.save); + + external.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + share.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + image.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + save.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + + ta.recycle(); + BottomSheet.Builder b = new BottomSheet.Builder(this).title(contentUrl); + + b.sheet(2, external, getString(R.string.submission_link_extern)); + b.sheet(5, share, getString(R.string.submission_link_share)); + if (!isGif) b.sheet(3, image, getString(R.string.share_image)); + b.sheet(4, save, getString(R.string.submission_save_image)); + b.listener(new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + switch (which) { + case (2): { + LinkUtil.openExternally(contentUrl); + } + break; + case (3): { + ShareUtil.shareImage(contentUrl, RedditGalleryPager.this); + } + break; + case (5): { + Reddit.defaultShareText("", contentUrl, RedditGalleryPager.this); + } + break; + case (4): { + doImageSave(isGif, contentUrl, index); + } + break; + } + } + }); + + b.show(); + + } + + public void doImageSave(boolean isGif, String contentUrl, int index) { + if (!isGif) { + if (Reddit.appRestart.getString("imagelocation", "").isEmpty()) { + showFirstDialog(); + } else if (!new File(Reddit.appRestart.getString("imagelocation", "")).exists()) { + showErrorDialog(); + } else { + Intent i = new Intent(this, ImageDownloadNotificationService.class); + i.putExtra("actuallyLoaded", contentUrl); + if (subreddit != null && !subreddit.isEmpty()) i.putExtra("subreddit", subreddit); + if (submissionTitle != null) i.putExtra(EXTRA_SUBMISSION_TITLE, submissionTitle); + i.putExtra("index", index); + startService(i); + } + } else { + MediaView.doOnClick.run(); + } + } + + public static class ImageFullNoSubmission extends Fragment { + + private int i = 0; + + public ImageFullNoSubmission() { + + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + final ViewGroup rootView = + (ViewGroup) inflater.inflate(R.layout.album_image_pager, container, false); + + final GalleryImage current = ((RedditGalleryPager) getActivity()).images.get(i); + final String url = current.url; + boolean lq = false; + if (SettingValues.loadImageLq && (SettingValues.lowResAlways || (!NetworkUtil.isConnectedWifi(getActivity()) + && SettingValues.lowResMobile))) { + String lqurl = url.substring(0, url.lastIndexOf(".")) + + (SettingValues.lqLow ? "m" : (SettingValues.lqMid ? "l" : "h")) + + url.substring(url.lastIndexOf(".")); + loadImage(rootView, this, lqurl, ((RedditGalleryPager) getActivity()).images.size() == 1); + lq = true; + } else { + loadImage(rootView, this, url, ((RedditGalleryPager) getActivity()).images.size() == 1); + } + + { + rootView.findViewById(R.id.more).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + ((RedditGalleryPager) getActivity()).showBottomSheetImage(url, false, i); + } + }); + { + rootView.findViewById(R.id.save).setOnClickListener(new View.OnClickListener() { + + @Override + public void onClick(View v2) { + ((RedditGalleryPager) getActivity()).doImageSave(false, url, i); + } + + }); + if (!SettingValues.imageDownloadButton) { + rootView.findViewById(R.id.save).setVisibility(View.INVISIBLE); + } + } + + rootView.findViewById(R.id.panel).setVisibility(View.GONE); + (rootView.findViewById(R.id.margin)).setPadding(0, 0, 0, 0); + } + + rootView.findViewById(R.id.hq).setVisibility(View.GONE); + + if (getActivity().getIntent().hasExtra(MediaView.SUBMISSION_URL)) { + rootView.findViewById(R.id.comments).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + getActivity().finish(); + SubmissionsView.datachanged(adapterPosition); + } + }); + } else { + rootView.findViewById(R.id.comments).setVisibility(View.GONE); + } + return rootView; + } + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + Bundle bundle = this.getArguments(); + i = bundle.getInt("page", 0); + } + } + + public static void setTextWithLinks(String s, SpoilerRobotoTextView text) { + String[] parts = s.split("\\s+"); + + StringBuilder b = new StringBuilder(); + for (String item : parts) + try { + URL url = new URL(item); + b.append(" ").append(url).append(""); + } catch (MalformedURLException e) { + b.append(" ").append(item); + } + + text.setTextHtml(b.toString(), "no sub"); + } + + public static String readableFileSize(long size) { + if (size <= 0) return "0"; + final String[] units = new String[]{"B", "kB", "MB", "GB", "TB"}; + int digitGroups = (int) (Math.log10(size) / Math.log10(1024)); + return new DecimalFormat("#,##0.#").format(size / Math.pow(1024, digitGroups)) + + " " + + units[digitGroups]; + } + + private static void loadImage(final View rootView, Fragment f, String url, boolean single) { + final SubsamplingScaleImageView image = rootView.findViewById(R.id.image); + + image.setMinimumDpi(70); + image.setMinimumTileDpi(240); + ImageView fakeImage = new ImageView(f.getActivity()); + final TextView size = rootView.findViewById(R.id.size); + fakeImage.setLayoutParams( + new LinearLayout.LayoutParams(image.getWidth(), image.getHeight())); + fakeImage.setScaleType(ImageView.ScaleType.CENTER_CROP); + ((Reddit) f.getActivity().getApplication()).getImageLoader() + .displayImage(url, new ImageViewAware(fakeImage), + new DisplayImageOptions.Builder().resetViewBeforeLoading(true) + .cacheOnDisk(true) + .imageScaleType(single? ImageScaleType.NONE:ImageScaleType.NONE_SAFE) + .cacheInMemory(false) + .build(), new ImageLoadingListener() { + + @Override + public void onLoadingStarted(String imageUri, View view) { + size.setVisibility(View.VISIBLE); + } + + @Override + public void onLoadingFailed(String imageUri, View view, + FailReason failReason) { + Log.v("Slide", "LOADING FAILED"); + + } + + @Override + public void onLoadingComplete(String imageUri, View view, + Bitmap loadedImage) { + size.setVisibility(View.GONE); + image.setImage(ImageSource.bitmap(loadedImage)); + (rootView.findViewById(R.id.progress)).setVisibility(View.GONE); + } + + @Override + public void onLoadingCancelled(String imageUri, View view) { + Log.v("Slide", "LOADING CANCELLED"); + + } + }, new ImageLoadingProgressListener() { + @Override + public void onProgressUpdate(String imageUri, View view, int current, + int total) { + size.setText(readableFileSize(total)); + + ((ProgressBar) rootView.findViewById(R.id.progress)).setProgress( + Math.round(100.0f * current / total)); + } + }); + } + + public void showFirstDialog() { + runOnUiThread(new Runnable() { + @Override + public void run() { + new AlertDialogWrapper.Builder(RedditGalleryPager.this).setTitle(R.string.set_save_location) + .setMessage(R.string.set_save_location_msg) + .setPositiveButton(R.string.btn_yes, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + new FolderChooserDialogCreate.Builder(RedditGalleryPager.this).chooseButton( + R.string.btn_select) // changes label of the choose button + .initialPath(Environment.getExternalStorageDirectory() + .getPath()) // changes initial path, defaults to external storage directory + .show(); + } + }) + .setNegativeButton(R.string.btn_no, null) + .show(); + } + }); + + } + + public void showErrorDialog() { + runOnUiThread(new Runnable() { + @Override + public void run() { + new AlertDialogWrapper.Builder(RedditGalleryPager.this).setTitle( + R.string.err_something_wrong) + .setMessage(R.string.err_couldnt_save_choose_new) + .setPositiveButton(R.string.btn_yes, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + new FolderChooserDialogCreate.Builder(RedditGalleryPager.this).chooseButton( + R.string.btn_select) // changes label of the choose button + .initialPath(Environment.getExternalStorageDirectory() + .getPath()) // changes initial path, defaults to external storage directory + .show(); + } + }) + .setNegativeButton(R.string.btn_no, null) + .show(); + } + }); + + } + + @Override + public void onFolderSelection(FolderChooserDialogCreate dialog, File folder, boolean isSaveToLocation) { + if (folder != null) { + Reddit.appRestart.edit().putString("imagelocation", folder.getAbsolutePath()).apply(); + Toast.makeText(this, + getString(R.string.settings_set_image_location, folder.getAbsolutePath()) + + folder.getAbsolutePath(), Toast.LENGTH_LONG).show(); + + } + } +} diff --git a/app/src/main/java/me/ccrama/redditslide/Activities/Related.java b/app/src/main/java/me/ccrama/redditslide/Activities/Related.java index ba185d4cbe..6d9bb133ae 100644 --- a/app/src/main/java/me/ccrama/redditslide/Activities/Related.java +++ b/app/src/main/java/me/ccrama/redditslide/Activities/Related.java @@ -79,8 +79,7 @@ public void onClick(DialogInterface dialogInterface, int i) { mToolbar.setPopupTheme(new ColorPreferences(this).getFontStyle().getBaseId()); final RecyclerView rv = ((RecyclerView) findViewById(R.id.vertical_content)); - final PreCachingLayoutManager mLayoutManager; - mLayoutManager = new PreCachingLayoutManager(this); + final PreCachingLayoutManager mLayoutManager = new PreCachingLayoutManager(this); rv.setLayoutManager(mLayoutManager); rv.addOnScrollListener(new ToolbarScrollHideHandler(mToolbar, findViewById(R.id.header)) { @@ -140,4 +139,4 @@ public void onRefresh() { } ); } -} \ No newline at end of file +} diff --git a/app/src/main/java/me/ccrama/redditslide/Activities/Search.java b/app/src/main/java/me/ccrama/redditslide/Activities/Search.java index 3417d4fa9c..6ef72f9481 100644 --- a/app/src/main/java/me/ccrama/redditslide/Activities/Search.java +++ b/app/src/main/java/me/ccrama/redditslide/Activities/Search.java @@ -7,13 +7,13 @@ import android.content.res.Configuration; import android.os.Build; import android.os.Bundle; -import android.text.Html; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; import androidx.annotation.NonNull; +import androidx.core.text.HtmlCompat; import androidx.recyclerview.widget.RecyclerView; import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; @@ -249,7 +249,7 @@ public void onCreate(Bundle savedInstanceState) { time = TimePeriod.ALL; - getSupportActionBar().setTitle(Html.fromHtml(where)); + getSupportActionBar().setTitle(HtmlCompat.fromHtml(where, HtmlCompat.FROM_HTML_MODE_LEGACY)); getSupportActionBar().setDisplayHomeAsUpEnabled(true); assert mToolbar != null; //it won't be, trust me mToolbar.setNavigationOnClickListener(new View.OnClickListener() { @@ -268,8 +268,7 @@ public void onClick(View v) { + StringUtils.capitalize(time.name().toLowerCase(Locale.ENGLISH))); rv = ((RecyclerView) findViewById(R.id.vertical_content)); - final RecyclerView.LayoutManager mLayoutManager; - mLayoutManager = + final RecyclerView.LayoutManager mLayoutManager = createLayoutManager(getNumColumns(getResources().getConfiguration().orientation, Search.this)); rv.setLayoutManager(mLayoutManager); @@ -363,4 +362,4 @@ public static int getNumColumns(final int orientation, Context context) { } return numColumns; } -} \ No newline at end of file +} diff --git a/app/src/main/java/me/ccrama/redditslide/Activities/SendMessage.java b/app/src/main/java/me/ccrama/redditslide/Activities/SendMessage.java index 46de957089..9d86b6b195 100644 --- a/app/src/main/java/me/ccrama/redditslide/Activities/SendMessage.java +++ b/app/src/main/java/me/ccrama/redditslide/Activities/SendMessage.java @@ -200,7 +200,7 @@ public void sendMessage(Captcha captcha, String captchaAttempt) { else { String to = author; if(to.startsWith("/r/")){ - to = to.substring(3, to.length()); + to = to.substring(3); new InboxManager(Authentication.reddit).compose(to, totext, subjecttext, bodytext); } else { diff --git a/app/src/main/java/me/ccrama/redditslide/Activities/Settings.java b/app/src/main/java/me/ccrama/redditslide/Activities/Settings.java index d04ac74fb3..d3e276efaa 100644 --- a/app/src/main/java/me/ccrama/redditslide/Activities/Settings.java +++ b/app/src/main/java/me/ccrama/redditslide/Activities/Settings.java @@ -298,7 +298,7 @@ else if (((TextView) child).getText().toString().toLowerCase().contains(text)) { } /* This child is a View and the previous child was a View, remove duplicates */ - else if (child != null && prev_child_is_View && child.getClass().equals(android.view.View.class)) { + else if (child != null && prev_child_is_View && child.getClass() == View.class) { parent.removeView(child); childRemoved = true; i--; @@ -317,7 +317,7 @@ else if (child instanceof ViewGroup) { } if (child != null && !childRemoved) { - prev_child_is_View = child.getClass().equals(android.view.View.class); + prev_child_is_View = child.getClass() == View.class; } } return foundText; diff --git a/app/src/main/java/me/ccrama/redditslide/Activities/SettingsAbout.java b/app/src/main/java/me/ccrama/redditslide/Activities/SettingsAbout.java index a639d79aad..461f0faa2d 100644 --- a/app/src/main/java/me/ccrama/redditslide/Activities/SettingsAbout.java +++ b/app/src/main/java/me/ccrama/redditslide/Activities/SettingsAbout.java @@ -11,6 +11,8 @@ import android.widget.TextView; import android.widget.Toast; +import androidx.core.content.ContextCompat; + import me.ccrama.redditslide.BuildConfig; import me.ccrama.redditslide.OpenRedditLink; import me.ccrama.redditslide.R; @@ -44,9 +46,11 @@ public boolean onLongClick(View view) { "STACKTRACE", Context.MODE_PRIVATE); String stacktrace = prefs.getString("stacktrace", null); if (stacktrace != null) { - ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); + ClipboardManager clipboard = ContextCompat.getSystemService(SettingsAbout.this, ClipboardManager.class); ClipData clip = ClipData.newPlainText("Stacktrace", stacktrace); - clipboard.setPrimaryClip(clip); + if (clipboard != null) { + clipboard.setPrimaryClip(clip); + } } prefs.edit().clear().apply(); return true; @@ -58,9 +62,11 @@ public boolean onLongClick(View view) { @Override public void onClick(View v) { String versionNumber = version.getText().toString(); - ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); + ClipboardManager clipboard = ContextCompat.getSystemService(SettingsAbout.this, ClipboardManager.class); ClipData clip = ClipData.newPlainText("Version", versionNumber); - clipboard.setPrimaryClip(clip); + if (clipboard != null) { + clipboard.setPrimaryClip(clip); + } Toast.makeText(SettingsAbout.this, R.string.settings_about_version_copied_toast, Toast.LENGTH_SHORT).show(); } diff --git a/app/src/main/java/me/ccrama/redditslide/Activities/SettingsSubreddit.java b/app/src/main/java/me/ccrama/redditslide/Activities/SettingsSubreddit.java index 99a2a5f2ec..1a27a68e0b 100644 --- a/app/src/main/java/me/ccrama/redditslide/Activities/SettingsSubreddit.java +++ b/app/src/main/java/me/ccrama/redditslide/Activities/SettingsSubreddit.java @@ -180,7 +180,7 @@ protected void onPostExecute(Void aVoid) { } else { Snackbar s = Snackbar.make(mToolbar, R.string.err_color_sync_login, Snackbar.LENGTH_SHORT); View view = s.getView(); - TextView tv = (TextView) view.findViewById(com.google.android.material.R.id.snackbar_text); + TextView tv = view.findViewById(com.google.android.material.R.id.snackbar_text); tv.setTextColor(Color.WHITE); s.show(); } diff --git a/app/src/main/java/me/ccrama/redditslide/Activities/Shadowbox.java b/app/src/main/java/me/ccrama/redditslide/Activities/Shadowbox.java index aa9746ab47..4281ba0f0c 100644 --- a/app/src/main/java/me/ccrama/redditslide/Activities/Shadowbox.java +++ b/app/src/main/java/me/ccrama/redditslide/Activities/Shadowbox.java @@ -177,6 +177,7 @@ public Fragment getItem(int i) { case DEVIANTART: case EMBEDDED: case XKCD: + case REDDIT_GALLERY: case VREDDIT_DIRECT: case VREDDIT_REDIRECT: case LINK: diff --git a/app/src/main/java/me/ccrama/redditslide/Activities/ShadowboxComments.java b/app/src/main/java/me/ccrama/redditslide/Activities/ShadowboxComments.java index 07d809138a..4e8b2aa389 100644 --- a/app/src/main/java/me/ccrama/redditslide/Activities/ShadowboxComments.java +++ b/app/src/main/java/me/ccrama/redditslide/Activities/ShadowboxComments.java @@ -66,6 +66,7 @@ public Fragment getItem(int i) { case XKCD: case SPOILER: case DEVIANTART: + case REDDIT_GALLERY: case EMBEDDED: case LINK: case STREAMABLE: diff --git a/app/src/main/java/me/ccrama/redditslide/Activities/Submit.java b/app/src/main/java/me/ccrama/redditslide/Activities/Submit.java index 9061ad120b..312a163a19 100644 --- a/app/src/main/java/me/ccrama/redditslide/Activities/Submit.java +++ b/app/src/main/java/me/ccrama/redditslide/Activities/Submit.java @@ -26,6 +26,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.widget.SwitchCompat; +import androidx.core.content.ContextCompat; import com.afollestad.materialdialogs.AlertDialogWrapper; import com.afollestad.materialdialogs.DialogAction; @@ -288,21 +289,18 @@ protected void onPostExecute(String s) { @Override public void onClick(View view) { TedBottomPicker tedBottomPicker = - new TedBottomPicker.Builder(Submit.this).setOnImageSelectedListener( - new TedBottomPicker.OnImageSelectedListener() { - @Override - public void onImageSelected(List uri) { - handleImageIntent(uri); - } - }) + new TedBottomPicker.Builder(Submit.this) + .setOnImageSelectedListener(Submit.this::handleImageIntent) .setLayoutResource(R.layout.image_sheet_dialog) .setTitle("Choose a photo") .create(); tedBottomPicker.show(getSupportFragmentManager()); InputMethodManager imm = - (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); - imm.hideSoftInputFromWindow(findViewById(R.id.bodytext).getWindowToken(), 0); + ContextCompat.getSystemService(Submit.this, InputMethodManager.class); + if (imm != null) { + imm.hideSoftInputFromWindow(findViewById(R.id.bodytext).getWindowToken(), 0); + } } }); @@ -317,7 +315,7 @@ public void onImageSelected(List uri) { ((EditText) findViewById(R.id.titletext)).setText( data.substring(0, data.indexOf("\n"))); ((EditText) findViewById(R.id.urltext)).setText( - data.substring(data.indexOf("\n"), data.length())); + data.substring(data.indexOf("\n"))); } else { ((EditText) findViewById(R.id.urltext)).setText(data); } @@ -438,7 +436,7 @@ protected Void doInBackground(Void... voids) { "reddit.com/r/" + ((AutoCompleteTextView) findViewById( R.id.subreddittext)).getText().toString() + "/comments/" + s .getFullName() - .substring(3, s.getFullName().length())); + .substring(3)); Submit.this.finish(); } catch (final ApiException e) { Drafts.addDraft(text); @@ -470,7 +468,7 @@ public void run() { "reddit.com/r/" + ((AutoCompleteTextView) findViewById( R.id.subreddittext)).getText().toString() + "/comments/" + s .getFullName() - .substring(3, s.getFullName().length())); + .substring(3)); Submit.this.finish(); } catch (final ApiException e) { @@ -509,7 +507,7 @@ public void run() { "reddit.com/r/" + ((AutoCompleteTextView) findViewById( R.id.subreddittext)).getText().toString() + "/comments/" + s .getFullName() - .substring(3, s.getFullName().length())); + .substring(3)); Submit.this.finish(); } catch (final Exception e) { @@ -672,13 +670,7 @@ protected JSONObject doInBackground(Uri... sub) { .build(); DoEditorActions.ProgressRequestBody body = - new DoEditorActions.ProgressRequestBody(formBody, - new DoEditorActions.ProgressRequestBody.Listener() { - @Override - public void onProgress(int progress) { - publishProgress(progress); - } - }); + new DoEditorActions.ProgressRequestBody(formBody, this::publishProgress); Request request = new Request.Builder().header("Authorization", @@ -894,13 +886,7 @@ public void writeTo(BufferedSink sink) throws IOException { MultipartBody formBody = formBodyBuilder.build(); DoEditorActions.ProgressRequestBody body = - new DoEditorActions.ProgressRequestBody(formBody, - new DoEditorActions.ProgressRequestBody.Listener() { - @Override - public void onProgress(int progress) { - publishProgress(progress); - } - }); + new DoEditorActions.ProgressRequestBody(formBody, this::publishProgress); Request request = new Request.Builder().header("Authorization", diff --git a/app/src/main/java/me/ccrama/redditslide/Activities/SubredditView.java b/app/src/main/java/me/ccrama/redditslide/Activities/SubredditView.java index 750e8ee16d..c08dd3aafb 100644 --- a/app/src/main/java/me/ccrama/redditslide/Activities/SubredditView.java +++ b/app/src/main/java/me/ccrama/redditslide/Activities/SubredditView.java @@ -197,9 +197,8 @@ public void onCreate(Bundle savedInstanceState) { mToolbar.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - int[] firstVisibleItems; int pastVisiblesItems = 0; - firstVisibleItems = + int[] firstVisibleItems = ((CatchStaggeredGridLayoutManager) ((SubmissionsView) (adapter.getCurrentFragment())).rv .getLayoutManager()).findFirstVisibleItemPositions(null); if (firstVisibleItems != null && firstVisibleItems.length > 0) { @@ -1029,8 +1028,7 @@ public void filterContent(final String subreddit) { }; final String FILTER_TITLE = - (subreddit.equals("frontpage")) ? (getString(R.string.content_to_hide, "frontpage")) - : (getString(R.string.content_to_hide, "/r/" + subreddit)); + (getString(R.string.content_to_hide, subreddit.equals("frontpage") ? "frontpage" : "/r/" + subreddit)); new AlertDialogWrapper.Builder(this).setTitle(FILTER_TITLE) .alwaysCallMultiChoiceCallback() @@ -1418,10 +1416,8 @@ public void onClick( final TextView subscribe = (TextView) findViewById(R.id.subscribe); currentlySubbed = - (!Authentication.isLoggedIn && UserSubscriptions.getSubscriptions(this) - .contains(subreddit.getDisplayName().toLowerCase(Locale.ENGLISH))) || ( - Authentication.isLoggedIn - && subreddit.isUserSubscriber()); + Authentication.isLoggedIn ? subreddit.isUserSubscriber() : UserSubscriptions.getSubscriptions(this) + .contains(subreddit.getDisplayName().toLowerCase(Locale.ENGLISH)); doSubscribeButtonText(currentlySubbed, subscribe); assert subscribe != null; @@ -2070,7 +2066,7 @@ public Fragment getItem(int i) { Fragment f = new CommentPage(); Bundle args = new Bundle(); String name = openingComments.getFullName(); - args.putString("id", name.substring(3, name.length())); + args.putString("id", name.substring(3)); args.putBoolean("archived", openingComments.isArchived()); args.putBoolean("contest", openingComments.getDataNode().get("contest_mode").asBoolean()); diff --git a/app/src/main/java/me/ccrama/redditslide/Activities/Tumblr.java b/app/src/main/java/me/ccrama/redditslide/Activities/Tumblr.java index c684b2eb8f..5e38abe42b 100644 --- a/app/src/main/java/me/ccrama/redditslide/Activities/Tumblr.java +++ b/app/src/main/java/me/ccrama/redditslide/Activities/Tumblr.java @@ -326,8 +326,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { rootView = inflater.inflate(R.layout.fragment_verticalalbum, container, false); - final PreCachingLayoutManager mLayoutManager; - mLayoutManager = new PreCachingLayoutManager(getActivity()); + final PreCachingLayoutManager mLayoutManager = new PreCachingLayoutManager(getActivity()); recyclerView = rootView.findViewById(R.id.images); recyclerView.setLayoutManager(mLayoutManager); ((Tumblr) getActivity()).url = @@ -382,4 +381,4 @@ public void doWithData(final List jsonElements) { } } -} \ No newline at end of file +} diff --git a/app/src/main/java/me/ccrama/redditslide/Activities/TumblrPager.java b/app/src/main/java/me/ccrama/redditslide/Activities/TumblrPager.java index 9b0087e309..70a8014e57 100644 --- a/app/src/main/java/me/ccrama/redditslide/Activities/TumblrPager.java +++ b/app/src/main/java/me/ccrama/redditslide/Activities/TumblrPager.java @@ -8,6 +8,7 @@ import android.graphics.Bitmap; import android.graphics.Color; import android.graphics.PorterDuff; +import android.graphics.PorterDuffColorFilter; import android.graphics.Typeface; import android.graphics.drawable.Drawable; import android.os.AsyncTask; @@ -382,7 +383,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, public void run() { } - }, false, true, (TextView) rootView.findViewById(R.id.size), ((TumblrPager) getActivity()).subreddit).execute(url); + }, false, true, rootView.findViewById(R.id.size), ((TumblrPager) getActivity()).subreddit).execute(url); rootView.findViewById(R.id.more).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -416,15 +417,15 @@ public void showBottomSheetImage(final String contentUrl, final boolean isGif, TypedArray ta = obtainStyledAttributes(attrs); int color = ta.getColor(0, Color.WHITE); - Drawable external = getResources().getDrawable(R.drawable.openexternal); + Drawable external = getResources().getDrawable(R.drawable.open_external); Drawable share = getResources().getDrawable(R.drawable.share); Drawable image = getResources().getDrawable(R.drawable.image); Drawable save = getResources().getDrawable(R.drawable.save); - external.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - share.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - image.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - save.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); + external.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + share.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + image.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + save.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); ta.recycle(); BottomSheet.Builder b = new BottomSheet.Builder(this).title(contentUrl); @@ -542,12 +543,12 @@ public void onClick(View v2) { (rootView.findViewById(R.id.margin)).setPadding(0, 0, 0, 0); } else if (title.isEmpty()) { setTextWithLinks(description, - ((SpoilerRobotoTextView) rootView.findViewById(R.id.title))); + rootView.findViewById(R.id.title)); } else { setTextWithLinks(title, - ((SpoilerRobotoTextView) rootView.findViewById(R.id.title))); + rootView.findViewById(R.id.title)); setTextWithLinks(description, - ((SpoilerRobotoTextView) rootView.findViewById(R.id.body))); + rootView.findViewById(R.id.body)); } { int type = new FontPreferences(getContext()).getFontTypeComment().getTypeface(); @@ -657,11 +658,9 @@ private static void loadImage(final View rootView, Fragment f, String url) { .imageScaleType(ImageScaleType.NONE) .cacheInMemory(false) .build(), new ImageLoadingListener() { - private View mView; @Override public void onLoadingStarted(String imageUri, View view) { - mView = view; size.setVisibility(View.VISIBLE); } diff --git a/app/src/main/java/me/ccrama/redditslide/Activities/Wiki.java b/app/src/main/java/me/ccrama/redditslide/Activities/Wiki.java index f3df792b73..0e8ca9df8a 100644 --- a/app/src/main/java/me/ccrama/redditslide/Activities/Wiki.java +++ b/app/src/main/java/me/ccrama/redditslide/Activities/Wiki.java @@ -82,11 +82,11 @@ private void createCustomCss() { TypedArray ta = obtainStyledAttributes( new int[]{R.attr.activity_background, R.attr.fontColor, R.attr.colorAccent}); customCssBuilder.append("html { ") - .append("background: ".concat(getHexFromColorInt(ta.getColor(0, Color.WHITE))).concat(";")) - .append("color: ".concat(getHexFromColorInt(ta.getColor(1, Color.BLACK))).concat(";")) + .append("background: ").append(getHexFromColorInt(ta.getColor(0, Color.WHITE))).append(";") + .append("color: ").append(getHexFromColorInt(ta.getColor(1, Color.BLACK))).append(";") .append("; }"); customCssBuilder.append("a { ") - .append("color: ".concat(getHexFromColorInt(ta.getColor(2, Color.BLUE))).concat(";")) + .append("color: ").append(getHexFromColorInt(ta.getColor(2, Color.BLUE))).append(";") .append("; }"); ta.recycle(); customCssBuilder.append("table, code { display: block; overflow-x: scroll; }"); diff --git a/app/src/main/java/me/ccrama/redditslide/Adapters/AlbumView.java b/app/src/main/java/me/ccrama/redditslide/Adapters/AlbumView.java index 8c76c178c7..f792b20ba9 100644 --- a/app/src/main/java/me/ccrama/redditslide/Adapters/AlbumView.java +++ b/app/src/main/java/me/ccrama/redditslide/Adapters/AlbumView.java @@ -26,6 +26,7 @@ import me.ccrama.redditslide.Activities.Album; import me.ccrama.redditslide.Activities.MediaView; import me.ccrama.redditslide.ImgurAlbum.Image; +import me.ccrama.redditslide.Notifications.ImageDownloadNotificationService; import me.ccrama.redditslide.R; import me.ccrama.redditslide.Reddit; import me.ccrama.redditslide.SettingValues; @@ -34,6 +35,8 @@ import me.ccrama.redditslide.util.LinkUtil; import me.ccrama.redditslide.util.SubmissionParser; +import static me.ccrama.redditslide.Notifications.ImageDownloadNotificationService.*; + public class AlbumView extends RecyclerView.Adapter { private final List users; @@ -42,13 +45,15 @@ public class AlbumView extends RecyclerView.Adapter { public boolean paddingBottom; public int height; public String subreddit; + private final String submissionTitle; - public AlbumView(final Activity context, final List users, int height, String subreddit) { + public AlbumView(final Activity context, final List users, int height, String subreddit, String SubmissionTitle) { this.height = height; main = context; this.users = users; this.subreddit = subreddit; + this.submissionTitle = SubmissionTitle; paddingBottom = main.findViewById(R.id.toolbar) == null; if (context.findViewById(R.id.grid) != null) @@ -181,6 +186,9 @@ public void onClick(View view) { Intent myIntent = new Intent(main, MediaView.class); myIntent.putExtra(MediaView.EXTRA_URL, user.getImageUrl()); myIntent.putExtra(MediaView.SUBREDDIT, subreddit); + if(submissionTitle != null) { + myIntent.putExtra(EXTRA_SUBMISSION_TITLE, submissionTitle); + } main.startActivity(myIntent); } else { LinkUtil.openExternally(user.getImageUrl()); diff --git a/app/src/main/java/me/ccrama/redditslide/Adapters/CommentAdapter.java b/app/src/main/java/me/ccrama/redditslide/Adapters/CommentAdapter.java index db3df1a3e3..c3b0a90e4c 100644 --- a/app/src/main/java/me/ccrama/redditslide/Adapters/CommentAdapter.java +++ b/app/src/main/java/me/ccrama/redditslide/Adapters/CommentAdapter.java @@ -14,6 +14,7 @@ import android.graphics.BitmapFactory; import android.graphics.Color; import android.graphics.PorterDuff; +import android.graphics.PorterDuffColorFilter; import android.graphics.Typeface; import android.net.Uri; import android.os.AsyncTask; @@ -290,9 +291,9 @@ public void doTimes() { lastSeen = HasSeen.getSeenTime(submission); String fullname = submission.getFullName(); if (fullname.contains("t3_")) { - fullname = fullname.substring(3, fullname.length()); + fullname = fullname.substring(3); } - HasSeen.seenTimes.put(fullname, System.currentTimeMillis()); + HasSeen.addSeen(fullname); KVStore.getInstance().insert(fullname, String.valueOf(System.currentTimeMillis())); } if (submission != null) { @@ -408,17 +409,17 @@ public void onSingleClick(View v) { && !comment.getAuthorFlair().getCssClass().isEmpty()) { boolean set = false; for (String s : comment.getAuthorFlair().getCssClass().split(" ")) { + ImageFlairs.FlairImageLoader loader = ImageFlairs.getFlairImageLoader(mContext); File file = DiskCacheUtils.findInCache( comment.getSubredditName().toLowerCase(Locale.ENGLISH) + ":" + s.toLowerCase(Locale.ENGLISH), - ImageFlairs.getFlairImageLoader(mContext).getInstance().getDiskCache()); + loader.getDiskCache()); if (file != null && file.exists()) { set = true; holder.imageFlair.setVisibility(View.VISIBLE); String decodedImgUri = Uri.fromFile(file).toString(); - ImageFlairs.getFlairImageLoader(mContext) - .displayImage(decodedImgUri, holder.imageFlair); + loader.displayImage(decodedImgUri, holder.imageFlair); break; } } @@ -541,6 +542,13 @@ public void onSingleClick(View v) { setCommentStateHighlighted(holder, comment, baseNode, true, false); } + if (SettingValues.collapseDeletedComments) { + if (comment.getBody().startsWith("[removed]") || comment.getBody().startsWith("[deleted]")) { + holder.firstTextView.setVisibility(View.GONE); + holder.commentOverflow.setVisibility(View.GONE); + } + } + } else if (firstHolder instanceof SubmissionViewHolder && submission != null) { submissionViewHolder = (SubmissionViewHolder) firstHolder; new PopulateSubmissionViewHolder().populateSubmissionViewHolder( @@ -575,9 +583,10 @@ public void onSingleClick(View v) { View view = ((Activity) mContext).findViewById(android.R.id.content); if (view != null) { InputMethodManager imm = - (InputMethodManager) mContext.getSystemService( - Context.INPUT_METHOD_SERVICE); - imm.hideSoftInputFromWindow(view.getWindowToken(), 0); + ContextCompat.getSystemService(mContext, InputMethodManager.class); + if (imm != null) { + imm.hideSoftInputFromWindow(view.getWindowToken(), 0); + } } } }); @@ -737,10 +746,11 @@ public void onFocusChange(View v, boolean hasFocus) { }); } replyLine.requestFocus(); - InputMethodManager imm = - (InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE); - imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, - InputMethodManager.HIDE_IMPLICIT_ONLY); + InputMethodManager imm = ContextCompat.getSystemService(mContext, InputMethodManager.class); + if (imm != null) { + imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, + InputMethodManager.HIDE_IMPLICIT_ONLY); + } editingPosition = submissionViewHolder.getAdapterPosition(); @@ -766,9 +776,11 @@ public void onSingleClick(View v) { View view = ((Activity) mContext).findViewById(android.R.id.content); if (view != null) { InputMethodManager imm = - (InputMethodManager) mContext.getSystemService( - Context.INPUT_METHOD_SERVICE); - imm.hideSoftInputFromWindow(view.getWindowToken(), 0); + ContextCompat.getSystemService( + mContext, InputMethodManager.class); + if (imm != null) { + imm.hideSoftInputFromWindow(view.getWindowToken(), 0); + } } } } @@ -776,8 +788,10 @@ public void onSingleClick(View v) { } else { View view = ((Activity) mContext).findViewById(android.R.id.content); if (view != null) { - InputMethodManager imm = (InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE); - imm.hideSoftInputFromWindow(view.getWindowToken(), 0); + InputMethodManager imm = ContextCompat.getSystemService(mContext, InputMethodManager.class); + if (imm != null) { + imm.hideSoftInputFromWindow(view.getWindowToken(), 0); + } } collapseAndHide(replyArea); } @@ -1118,9 +1132,9 @@ public void setCommentStateHighlighted(final CommentViewHolder holder, final Com currentNode = baseNode; LayoutInflater inflater = ((Activity) mContext).getLayoutInflater(); resetMenu(holder.menuArea, false); - final View baseView = (SettingValues.rightHandedCommentMenu) ? inflater.inflate( - R.layout.comment_menu_right_handed, holder.menuArea) - : inflater.inflate(R.layout.comment_menu, holder.menuArea); + final View baseView = inflater.inflate( + SettingValues.rightHandedCommentMenu ? + R.layout.comment_menu_right_handed : R.layout.comment_menu, holder.menuArea); if (!isReplying) { baseView.setVisibility(View.GONE); @@ -1334,10 +1348,11 @@ public void onClick(DialogInterface dialog, int which) { } }); replyLine.requestFocus(); - InputMethodManager imm = (InputMethodManager) mContext.getSystemService( - Context.INPUT_METHOD_SERVICE); - imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, - InputMethodManager.HIDE_IMPLICIT_ONLY); + InputMethodManager imm = ContextCompat.getSystemService(mContext, InputMethodManager.class); + if (imm != null) { + imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, + InputMethodManager.HIDE_IMPLICIT_ONLY); + } currentlyEditingId = n.getFullName(); replyLine.setText(backedText); @@ -1396,7 +1411,7 @@ public void onSingleClick(View v) { Color.WHITE); ((ImageView) replyArea.findViewById(R.id.spoiler)).setColorFilter(Color.WHITE); replyLine.getBackground() - .setColorFilter(Color.WHITE, PorterDuff.Mode.SRC_IN); + .setColorFilter(new PorterDuffColorFilter(Color.WHITE, PorterDuff.Mode.SRC_IN)); } replyArea.setVisibility(View.VISIBLE); @@ -1464,10 +1479,11 @@ public void onClick(DialogInterface dialog, int which) { }); } replyLine.requestFocus(); // TODO: Not working when called a second time - InputMethodManager imm = (InputMethodManager) mContext.getSystemService( - Context.INPUT_METHOD_SERVICE); - imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, - InputMethodManager.HIDE_IMPLICIT_ONLY); + InputMethodManager imm = ContextCompat.getSystemService(mContext, InputMethodManager.class); + if (imm != null) { + imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, + InputMethodManager.HIDE_IMPLICIT_ONLY); + } currentlyEditingId = n.getFullName(); replyLine.addTextChangedListener(new TextWatcher() { @@ -1513,9 +1529,11 @@ public void onSingleClick(View v) { //Hide soft keyboard View view = ((Activity) mContext).findViewById(android.R.id.content); if (view != null) { - InputMethodManager imm = (InputMethodManager) mContext.getSystemService( - Context.INPUT_METHOD_SERVICE); - imm.hideSoftInputFromWindow(view.getWindowToken(), 0); + InputMethodManager imm = ContextCompat.getSystemService( + mContext, InputMethodManager.class); + if (imm != null) { + imm.hideSoftInputFromWindow(view.getWindowToken(), 0); + } } } }); @@ -1529,9 +1547,11 @@ public void onSingleClick(View v) { mPage.overrideFab = false; View view = ((Activity) mContext).findViewById(android.R.id.content); if (view != null) { - InputMethodManager imm = (InputMethodManager) mContext.getSystemService( - Context.INPUT_METHOD_SERVICE); - imm.hideSoftInputFromWindow(view.getWindowToken(), 0); + InputMethodManager imm = ContextCompat.getSystemService( + mContext, InputMethodManager.class); + if (imm != null) { + imm.hideSoftInputFromWindow(view.getWindowToken(), 0); + } } doShowMenu(baseView); } @@ -1709,9 +1729,11 @@ public void onClick(DialogInterface dialog, int which) { View view = ((Activity) mContext).findViewById(android.R.id.content); if (view != null) { InputMethodManager imm = - (InputMethodManager) mContext.getSystemService( - Context.INPUT_METHOD_SERVICE); - imm.hideSoftInputFromWindow(view.getWindowToken(), 0); + ContextCompat.getSystemService( + mContext, InputMethodManager.class); + if (imm != null) { + imm.hideSoftInputFromWindow(view.getWindowToken(), 0); + } } if (mContext instanceof BaseActivity) { ((BaseActivity) mContext).setShareUrl( @@ -1777,9 +1799,11 @@ public void onClick(DialogInterface dialog, int which) { View view = ((Activity) mContext).findViewById(android.R.id.content); if (view != null) { InputMethodManager imm = - (InputMethodManager) mContext.getSystemService( - Context.INPUT_METHOD_SERVICE); - imm.hideSoftInputFromWindow(view.getWindowToken(), 0); + ContextCompat.getSystemService( + mContext, InputMethodManager.class); + if (imm != null) { + imm.hideSoftInputFromWindow(view.getWindowToken(), 0); + } } doLongClick(holder, comment, baseNode); @@ -1834,9 +1858,11 @@ public void onClick(DialogInterface dialog, int which) { View view = ((Activity) mContext).findViewById(android.R.id.content); if (view != null) { InputMethodManager imm = - (InputMethodManager) mContext.getSystemService( - Context.INPUT_METHOD_SERVICE); - imm.hideSoftInputFromWindow(view.getWindowToken(), 0); + ContextCompat.getSystemService( + mContext, InputMethodManager.class); + if (imm != null) { + imm.hideSoftInputFromWindow(view.getWindowToken(), 0); + } } doOnClick(holder, baseNode, comment); @@ -2551,4 +2577,4 @@ private RedditClient getAuthenticatedClient(String profileName) { Authentication.doVerify(token, reddit, true, mContext); return reddit; } -} \ No newline at end of file +} diff --git a/app/src/main/java/me/ccrama/redditslide/Adapters/CommentAdapterHelper.java b/app/src/main/java/me/ccrama/redditslide/Adapters/CommentAdapterHelper.java index 1486d73435..d339e85091 100644 --- a/app/src/main/java/me/ccrama/redditslide/Adapters/CommentAdapterHelper.java +++ b/app/src/main/java/me/ccrama/redditslide/Adapters/CommentAdapterHelper.java @@ -14,10 +14,10 @@ import android.graphics.Bitmap; import android.graphics.Color; import android.graphics.PorterDuff; +import android.graphics.PorterDuffColorFilter; import android.graphics.Typeface; import android.graphics.drawable.Drawable; import android.os.AsyncTask; -import android.text.Html; import android.text.InputType; import android.text.Spannable; import android.text.SpannableStringBuilder; @@ -39,6 +39,8 @@ import android.widget.Toast; import androidx.annotation.NonNull; +import androidx.core.content.ContextCompat; +import androidx.core.text.HtmlCompat; import androidx.fragment.app.FragmentManager; import androidx.interpolator.view.animation.FastOutSlowInInterpolator; @@ -77,12 +79,10 @@ import me.ccrama.redditslide.R; import me.ccrama.redditslide.Reddit; import me.ccrama.redditslide.SettingValues; -import me.ccrama.redditslide.SpoilerRobotoTextView; import me.ccrama.redditslide.TimeUtils; import me.ccrama.redditslide.Toolbox.ToolboxUI; import me.ccrama.redditslide.UserSubscriptions; import me.ccrama.redditslide.UserTags; -import me.ccrama.redditslide.Views.CommentOverflow; import me.ccrama.redditslide.Views.DoEditorActions; import me.ccrama.redditslide.Views.RoundedBackgroundSpan; import me.ccrama.redditslide.Visuals.FontPreferences; @@ -102,29 +102,29 @@ public static void showOverflowBottomSheet(final CommentAdapter adapter, final C int color = ta.getColor(0, Color.WHITE); Drawable profile = mContext.getResources().getDrawable(R.drawable.profile); - Drawable saved = mContext.getResources().getDrawable(R.drawable.iconstarfilled); + Drawable saved = mContext.getResources().getDrawable(R.drawable.star); Drawable gild = mContext.getResources().getDrawable(R.drawable.gild); - Drawable copy = mContext.getResources().getDrawable(R.drawable.ic_content_copy); + Drawable copy = mContext.getResources().getDrawable(R.drawable.copy); Drawable share = mContext.getResources().getDrawable(R.drawable.share); Drawable parent = mContext.getResources().getDrawable(R.drawable.commentchange); Drawable replies = mContext.getResources().getDrawable(R.drawable.notifs); Drawable permalink = mContext.getResources().getDrawable(R.drawable.link); Drawable report = mContext.getResources().getDrawable(R.drawable.report); - profile.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - saved.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - gild.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - report.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - copy.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - share.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - parent.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - permalink.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - replies.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); + profile.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + saved.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + gild.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + report.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + copy.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + share.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + parent.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + permalink.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + replies.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); ta.recycle(); BottomSheet.Builder b = - new BottomSheet.Builder((Activity) mContext).title(Html.fromHtml(n.getBody())); + new BottomSheet.Builder((Activity) mContext).title(HtmlCompat.fromHtml(n.getBody(), HtmlCompat.FROM_HTML_MODE_LEGACY)); if (Authentication.didOnline) { b.sheet(1, profile, "/u/" + n.getAuthor()); @@ -166,7 +166,7 @@ public void onClick(DialogInterface dialog, int which) { //Go to comment permalink String s = "https://reddit.com" + adapter.submission.getPermalink() - + n.getFullName().substring(3, n.getFullName().length()) + + n.getFullName().substring(3) + "?context=3"; new OpenRedditLink(mContext, s); } @@ -180,7 +180,7 @@ public void onClick(DialogInterface dialog, int which) { Intent i = new Intent(mContext, Website.class); i.putExtra(LinkUtil.EXTRA_URL, "https://reddit.com" + adapter.submission.getPermalink() - + n.getFullName().substring(3, n.getFullName().length()) + + n.getFullName().substring(3) + "?context=3&inapp=false"); i.putExtra(LinkUtil.EXTRA_COLOR, Palette.getColor(n.getSubredditName())); mContext.startActivity(i); @@ -292,11 +292,13 @@ public void onClick(DialogInterface dialog, int which) { .substring(showText.getSelectionStart(), showText.getSelectionEnd()); ClipboardManager clipboard = - (ClipboardManager) mContext.getSystemService( - Context.CLIPBOARD_SERVICE); + ContextCompat.getSystemService(mContext, + ClipboardManager.class); ClipData clip = ClipData.newPlainText("Comment text", selected); - clipboard.setPrimaryClip(clip); + if (clipboard != null) { + clipboard.setPrimaryClip(clip); + } Toast.makeText(mContext, R.string.submission_comment_copied, Toast.LENGTH_SHORT).show(); @@ -309,12 +311,14 @@ public void onClick(DialogInterface dialog, int which) { @Override public void onClick(DialogInterface dialog, int which) { ClipboardManager clipboard = - (ClipboardManager) mContext.getSystemService( - Context.CLIPBOARD_SERVICE); + ContextCompat.getSystemService(mContext, + ClipboardManager.class); ClipData clip = ClipData.newPlainText("Comment text", - Html.fromHtml(n.getBody())); - clipboard.setPrimaryClip(clip); + StringEscapeUtils.unescapeHtml4(n.getBody())); + if (clipboard != null) { + clipboard.setPrimaryClip(clip); + } Toast.makeText(mContext, R.string.submission_comment_copied, @@ -327,7 +331,7 @@ public void onClick(DialogInterface dialog, int which) { //Share comment Reddit.defaultShareText(adapter.submission.getTitle(), "https://reddit.com" + adapter.submission.getPermalink() - + n.getFullName().substring(3, n.getFullName().length()) + + n.getFullName().substring(3) + "?context=3", mContext); break; } @@ -390,8 +394,8 @@ private static void viewCommentParent(CommentAdapter adapter, CommentViewHolder Comment parent = o.comment.getComment(); adapter.setViews(parent.getDataNode().get("body_html").asText(), adapter.submission.getSubredditName(), - (SpoilerRobotoTextView) dialoglayout.findViewById(R.id.firstTextView), - (CommentOverflow) dialoglayout.findViewById(R.id.commentOverflow)); + dialoglayout.findViewById(R.id.firstTextView), + dialoglayout.findViewById(R.id.commentOverflow)); builder.setView(dialoglayout); builder.show(); break; @@ -644,33 +648,33 @@ public static void showModBottomSheet(final CommentAdapter adapter, final Contex final Drawable approve = mContext.getResources().getDrawable(R.drawable.support); final Drawable nsfw = mContext.getResources().getDrawable(R.drawable.hide); final Drawable pin = mContext.getResources().getDrawable(R.drawable.sub); - final Drawable distinguish = mContext.getResources().getDrawable(R.drawable.iconstarfilled); + final Drawable distinguish = mContext.getResources().getDrawable(R.drawable.star); final Drawable remove = mContext.getResources().getDrawable(R.drawable.close); final Drawable ban = mContext.getResources().getDrawable(R.drawable.ban); final Drawable spam = mContext.getResources().getDrawable(R.drawable.spam); final Drawable note = mContext.getResources().getDrawable(R.drawable.note); - final Drawable removeReason = mContext.getResources().getDrawable(R.drawable.reportreason); + final Drawable removeReason = mContext.getResources().getDrawable(R.drawable.report_reason); final Drawable lock = mContext.getResources().getDrawable(R.drawable.lock); //Tint drawables - profile.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - report.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - approve.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - nsfw.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - distinguish.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - remove.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - pin.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - ban.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - spam.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - note.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - removeReason.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - lock.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); + profile.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + report.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + approve.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + nsfw.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + distinguish.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + remove.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + pin.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + ban.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + spam.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + note.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + removeReason.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + lock.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); ta.recycle(); //Bottom sheet builder BottomSheet.Builder b = new BottomSheet.Builder((Activity) mContext).title( - Html.fromHtml(comment.getBody())); + HtmlCompat.fromHtml(comment.getBody(), HtmlCompat.FROM_HTML_MODE_LEGACY)); int reportCount = reports.size() + reports2.size(); @@ -1491,7 +1495,7 @@ public static Spannable getScoreString(Comment comment, Context mContext, titleString.append(pinned); titleString.append(" "); } - if (comment.getTimesSilvered() > 0 || comment.getTimesGilded() > 0 || comment.getTimesPlatinized() > 0) { + if (!SettingValues.hideCommentAwards && (comment.getTimesSilvered() > 0 || comment.getTimesGilded() > 0 || comment.getTimesPlatinized() > 0)) { TypedArray a = mContext.obtainStyledAttributes( new FontPreferences(mContext).getPostFontStyle().getResId(), R.styleable.FontStyle); @@ -1589,7 +1593,8 @@ public static Spannable getScoreString(Comment comment, Context mContext, theme.resolveAttribute(R.attr.activity_background, typedValue, true); int color = typedValue.data; SpannableStringBuilder pinned = - new SpannableStringBuilder("\u00A0" + Html.fromHtml(flairText) + "\u00A0"); + new SpannableStringBuilder("\u00A0" + HtmlCompat.fromHtml(flairText, + HtmlCompat.FROM_HTML_MODE_LEGACY) + "\u00A0"); pinned.setSpan( new RoundedBackgroundSpan(holder.firstTextView.getCurrentTextColor(), color, false, mContext), 0, pinned.length(), diff --git a/app/src/main/java/me/ccrama/redditslide/Adapters/CommentAdapterSearch.java b/app/src/main/java/me/ccrama/redditslide/Adapters/CommentAdapterSearch.java index 3b6b5f29b1..f51860ed8d 100644 --- a/app/src/main/java/me/ccrama/redditslide/Adapters/CommentAdapterSearch.java +++ b/app/src/main/java/me/ccrama/redditslide/Adapters/CommentAdapterSearch.java @@ -13,7 +13,6 @@ import android.graphics.BitmapFactory; import android.graphics.Typeface; import android.os.Bundle; -import android.text.Html; import android.text.Spannable; import android.text.SpannableStringBuilder; import android.text.Spanned; @@ -30,6 +29,7 @@ import android.widget.Filterable; import androidx.core.content.ContextCompat; +import androidx.core.text.HtmlCompat; import androidx.recyclerview.widget.RecyclerView; import com.devspark.robototextview.RobotoTypefaces; @@ -48,6 +48,7 @@ import me.ccrama.redditslide.Authentication; import me.ccrama.redditslide.R; +import me.ccrama.redditslide.SettingValues; import me.ccrama.redditslide.TimeUtils; import me.ccrama.redditslide.UserSubscriptions; import me.ccrama.redditslide.UserTags; @@ -187,7 +188,7 @@ public void doScoreText(CommentViewHolder holder, Comment comment, int offset) { titleString.append(pinned); titleString.append(" "); } - if (comment.getTimesSilvered() > 0 || comment.getTimesGilded() > 0 || comment.getTimesPlatinized() > 0) { + if (!SettingValues.hideCommentAwards && (comment.getTimesSilvered() > 0 || comment.getTimesGilded() > 0 || comment.getTimesPlatinized() > 0)) { TypedArray a = mContext.obtainStyledAttributes( new FontPreferences(mContext).getPostFontStyle().getResId(), R.styleable.FontStyle); @@ -260,7 +261,8 @@ public void doScoreText(CommentViewHolder holder, Comment comment, int offset) { theme.resolveAttribute(R.attr.activity_background, typedValue, true); int color = typedValue.data; SpannableStringBuilder pinned = new SpannableStringBuilder( - "\u00A0" + Html.fromHtml(comment.getAuthorFlair().getText()) + "\u00A0"); + "\u00A0" + HtmlCompat.fromHtml(comment.getAuthorFlair().getText(), + HtmlCompat.FROM_HTML_MODE_LEGACY) + "\u00A0"); pinned.setSpan( new RoundedBackgroundSpan(holder.firstTextView.getCurrentTextColor(), color, false, mContext), 0, pinned.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); diff --git a/app/src/main/java/me/ccrama/redditslide/Adapters/CommentViewHolder.java b/app/src/main/java/me/ccrama/redditslide/Adapters/CommentViewHolder.java index be83478cd9..aac56fa274 100644 --- a/app/src/main/java/me/ccrama/redditslide/Adapters/CommentViewHolder.java +++ b/app/src/main/java/me/ccrama/redditslide/Adapters/CommentViewHolder.java @@ -32,14 +32,14 @@ public CommentViewHolder(View v) { super(v); background = v.findViewById(R.id.background); dot = v.findViewById(R.id.dot); - menuArea = (LinearLayout) v.findViewById(R.id.menuarea); - childrenNumber = (TextView) v.findViewById(R.id.commentnumber); - firstTextView = (SpoilerRobotoTextView) v.findViewById(R.id.firstTextView); + menuArea = v.findViewById(R.id.menuarea); + childrenNumber = v.findViewById(R.id.commentnumber); + firstTextView = v.findViewById(R.id.firstTextView); textColorDown = ContextCompat.getColor(v.getContext(), R.color.md_blue_500); textColorRegular = firstTextView.getCurrentTextColor(); textColorUp = ContextCompat.getColor(v.getContext(), R.color.md_orange_500); - content = (TextView) v.findViewById(R.id.content); - imageFlair= (ImageView) v.findViewById(R.id.flair); - commentOverflow = (CommentOverflow) v.findViewById(R.id.commentOverflow); + content = v.findViewById(R.id.content); + imageFlair= v.findViewById(R.id.flair); + commentOverflow = v.findViewById(R.id.commentOverflow); } } diff --git a/app/src/main/java/me/ccrama/redditslide/Adapters/ContributionAdapter.java b/app/src/main/java/me/ccrama/redditslide/Adapters/ContributionAdapter.java index 4cf28f2764..64429e7beb 100644 --- a/app/src/main/java/me/ccrama/redditslide/Adapters/ContributionAdapter.java +++ b/app/src/main/java/me/ccrama/redditslide/Adapters/ContributionAdapter.java @@ -14,7 +14,6 @@ import android.graphics.Color; import android.graphics.Typeface; import android.os.AsyncTask; -import android.text.Html; import android.text.SpannableStringBuilder; import android.text.Spanned; import android.text.style.ForegroundColorSpan; @@ -28,6 +27,7 @@ import android.widget.LinearLayout; import android.widget.TextView; +import androidx.core.text.HtmlCompat; import androidx.recyclerview.widget.RecyclerView; import com.afollestad.materialdialogs.AlertDialogWrapper; @@ -167,7 +167,6 @@ public void run() { submissions[0].saved = false; - v = null; } else { new AccountManager(Authentication.reddit).save(submissions[0]); final Snackbar s = Snackbar.make(v, R.string.submission_info_saved, Snackbar.LENGTH_SHORT); @@ -184,8 +183,8 @@ public void run() { submissions[0].saved = true; - v = null; } + v = null; } catch (Exception e) { return null; } @@ -210,7 +209,7 @@ public boolean onLongClick(View v) { final View dialoglayout = inflater.inflate(R.layout.postmenu, null); AlertDialogWrapper.Builder builder = new AlertDialogWrapper.Builder(mContext); final TextView title = dialoglayout.findViewById(R.id.title); - title.setText(Html.fromHtml(submission.getTitle())); + title.setText(HtmlCompat.fromHtml(submission.getTitle(), HtmlCompat.FROM_HTML_MODE_LEGACY)); ((TextView) dialoglayout.findViewById(R.id.userpopup)).setText("/u/" + submission.getAuthor()); ((TextView) dialoglayout.findViewById(R.id.subpopup)).setText("/r/" + submission.getSubredditName()); @@ -431,7 +430,7 @@ public void onClick(View v) { holder.content.setTypeface(typeface); ((TextView) holder.gild).setText(""); - if (comment.getTimesSilvered() > 0 || comment.getTimesGilded() > 0 || comment.getTimesPlatinized() > 0) { + if (!SettingValues.hideCommentAwards && (comment.getTimesSilvered() > 0 || comment.getTimesGilded() > 0 || comment.getTimesPlatinized() > 0)) { TypedArray a = mContext.obtainStyledAttributes( new FontPreferences(mContext).getPostFontStyle().getResId(), R.styleable.FontStyle); @@ -489,9 +488,9 @@ public void onClick(View v) { holder.gild.setVisibility(View.GONE); if (comment.getSubmissionTitle() != null) - holder.title.setText(Html.fromHtml(comment.getSubmissionTitle())); + holder.title.setText(HtmlCompat.fromHtml(comment.getSubmissionTitle(), HtmlCompat.FROM_HTML_MODE_LEGACY)); else - holder.title.setText(Html.fromHtml(comment.getAuthor())); + holder.title.setText(HtmlCompat.fromHtml(comment.getAuthor(), HtmlCompat.FROM_HTML_MODE_LEGACY)); holder.itemView.setOnClickListener(new View.OnClickListener() { diff --git a/app/src/main/java/me/ccrama/redditslide/Adapters/GalleryView.java b/app/src/main/java/me/ccrama/redditslide/Adapters/GalleryView.java index 1ddf612213..064dc9ac90 100644 --- a/app/src/main/java/me/ccrama/redditslide/Adapters/GalleryView.java +++ b/app/src/main/java/me/ccrama/redditslide/Adapters/GalleryView.java @@ -5,8 +5,9 @@ import android.content.res.TypedArray; import android.graphics.Color; import android.graphics.PorterDuff; +import android.graphics.PorterDuffColorFilter; import android.graphics.drawable.Drawable; -import android.text.Html; +import android.os.Bundle; import android.view.HapticFeedbackConstants; import android.view.LayoutInflater; import android.view.View; @@ -14,9 +15,11 @@ import android.widget.ImageView; import android.widget.RelativeLayout; +import androidx.core.text.HtmlCompat; import androidx.recyclerview.widget.RecyclerView; import com.cocosw.bottomsheet.BottomSheet; +import com.fasterxml.jackson.databind.JsonNode; import net.dean.jraw.models.Submission; import net.dean.jraw.models.Thumbnails; @@ -28,7 +31,10 @@ import me.ccrama.redditslide.Activities.CommentsScreen; import me.ccrama.redditslide.Activities.FullscreenVideo; import me.ccrama.redditslide.Activities.Gallery; +import me.ccrama.redditslide.Activities.GalleryImage; import me.ccrama.redditslide.Activities.MediaView; +import me.ccrama.redditslide.Activities.RedditGallery; +import me.ccrama.redditslide.Activities.RedditGalleryPager; import me.ccrama.redditslide.Activities.Tumblr; import me.ccrama.redditslide.Activities.TumblrPager; import me.ccrama.redditslide.ContentType; @@ -40,6 +46,8 @@ import me.ccrama.redditslide.Visuals.Palette; import me.ccrama.redditslide.util.LinkUtil; +import static me.ccrama.redditslide.Notifications.ImageDownloadNotificationService.EXTRA_SUBMISSION_TITLE; + public class GalleryView extends RecyclerView.Adapter { private final Gallery main; public boolean paddingBottom; @@ -89,6 +97,7 @@ public void onBindViewHolder(RecyclerView.ViewHolder holder2, final int i) { holder.type.setVisibility(View.VISIBLE); switch (ContentType.getContentType(submission)) { + case REDDIT_GALLERY: case ALBUM: holder.type.setImageResource(R.drawable.album); break; @@ -98,7 +107,7 @@ public void onBindViewHolder(RecyclerView.ViewHolder holder2, final int i) { holder.type.setImageResource(R.drawable.world); break; case SELF: - holder.type.setImageResource(R.drawable.fontsizedarker); + holder.type.setImageResource(R.drawable.fontsize); break; case EMBEDDED: case GIF: @@ -149,12 +158,12 @@ public boolean onLongClick(View v) { TypedArray ta = main.obtainStyledAttributes(attrs); int color = ta.getColor(0, Color.WHITE); - Drawable open = main.getResources().getDrawable(R.drawable.ic_open_in_browser); - open.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - Drawable share = main.getResources().getDrawable(R.drawable.ic_share); - share.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - Drawable copy = main.getResources().getDrawable(R.drawable.ic_content_copy); - copy.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); + Drawable open = main.getResources().getDrawable(R.drawable.open_in_browser); + open.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + Drawable share = main.getResources().getDrawable(R.drawable.share); + share.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + Drawable copy = main.getResources().getDrawable(R.drawable.copy); + copy.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); ta.recycle(); @@ -195,6 +204,7 @@ public void onClick(View v) { Intent myIntent = new Intent(main, MediaView.class); myIntent.putExtra(MediaView.SUBREDDIT, subreddit); myIntent.putExtra(MediaView.EXTRA_URL, submission.getUrl()); + myIntent.putExtra(EXTRA_SUBMISSION_TITLE, submission.getTitle()); main.startActivity(myIntent); } else { LinkUtil.openExternally(submission.getUrl()); @@ -208,7 +218,8 @@ public void onClick(View v) { break; case EMBEDDED: if (SettingValues.video) { - String data = Html.fromHtml(submission.getDataNode().get("media_embed").get("content").asText()).toString(); + String data = HtmlCompat.fromHtml(submission.getDataNode().get("media_embed").get("content").asText(), + HtmlCompat.FROM_HTML_MODE_LEGACY).toString(); { Intent i = new Intent(main, FullscreenVideo.class); i.putExtra(FullscreenVideo.EXTRA_HTML, data); @@ -229,12 +240,14 @@ public void onClick(View v) { if (SettingValues.albumSwipe) { Intent i = new Intent(main, AlbumPager.class); i.putExtra(AlbumPager.SUBREDDIT, subreddit); + i.putExtra(EXTRA_SUBMISSION_TITLE, submission.getTitle()); i.putExtra(Album.EXTRA_URL, submission.getUrl()); main.startActivity(i); } else { Intent i = new Intent(main, Album.class); i.putExtra(Album.SUBREDDIT, subreddit); i.putExtra(Album.EXTRA_URL, submission.getUrl()); + i.putExtra(EXTRA_SUBMISSION_TITLE, submission.getTitle()); main.startActivity(i); } } else { @@ -242,6 +255,49 @@ public void onClick(View v) { } break; + case REDDIT_GALLERY: + if (SettingValues.album) { + Intent i; + if (SettingValues.albumSwipe) { + i = new Intent(main, RedditGalleryPager.class); + i.putExtra(AlbumPager.SUBREDDIT, + submission.getSubredditName()); + i.putExtra(EXTRA_SUBMISSION_TITLE, submission.getTitle()); + } else { + i = new Intent(main, RedditGallery.class); + i.putExtra(Album.SUBREDDIT, + submission.getSubredditName()); + i.putExtra(EXTRA_SUBMISSION_TITLE, submission.getTitle()); + } + + i.putExtra(RedditGallery.SUBREDDIT, + submission.getSubredditName()); + + ArrayList urls = new ArrayList<>(); + + JsonNode dataNode = submission.getDataNode(); + if (dataNode.has("gallery_data")) { + for (JsonNode identifier : dataNode.get("gallery_data").get("items")) { + if (dataNode.has("media_metadata") && dataNode.get( + "media_metadata") + .has(identifier.get("media_id").asText())) { + urls.add(new GalleryImage(dataNode.get("media_metadata") + .get(identifier.get("media_id").asText()) + .get("s"))); + } + } + } + + Bundle urlsBundle = new Bundle(); + urlsBundle.putSerializable(RedditGallery.GALLERY_URLS, urls); + i.putExtras(urlsBundle); + + main.startActivity(i); + } else { + LinkUtil.openExternally(submission.getUrl()); + } + break; + case TUMBLR: if (SettingValues.image) { if (SettingValues.albumSwipe) { diff --git a/app/src/main/java/me/ccrama/redditslide/Adapters/ImageGridAdapter.java b/app/src/main/java/me/ccrama/redditslide/Adapters/ImageGridAdapter.java index 503c3ec1cb..a3ccb93271 100644 --- a/app/src/main/java/me/ccrama/redditslide/Adapters/ImageGridAdapter.java +++ b/app/src/main/java/me/ccrama/redditslide/Adapters/ImageGridAdapter.java @@ -14,8 +14,10 @@ import java.util.ArrayList; import java.util.List; +import me.ccrama.redditslide.Activities.GalleryImage; import me.ccrama.redditslide.ImgurAlbum.Image; import me.ccrama.redditslide.Reddit; +import me.ccrama.redditslide.SettingValues; import me.ccrama.redditslide.Tumblr.Photo; /** @@ -27,7 +29,7 @@ public class ImageGridAdapter extends android.widget.BaseAdapter { public static final DisplayImageOptions options = new DisplayImageOptions.Builder().cacheOnDisk(true) .resetViewBeforeLoading(true) - .bitmapConfig(Bitmap.Config.RGB_565) + .bitmapConfig(SettingValues.highColorspaceImages ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565) .imageScaleType(ImageScaleType.EXACTLY) .cacheInMemory(false) .displayer(new FadeInBitmapDisplayer(250)) @@ -41,6 +43,14 @@ public ImageGridAdapter(Context c, List imgurAlbum) { } } + public ImageGridAdapter(Context c, boolean gallery, List redditGallery) { + mContext = c; + jsons = new ArrayList<>(); + for (GalleryImage i : redditGallery) { + jsons.add(i.url); + } + } + public ImageGridAdapter(Context c, List tumblrAlbum, boolean tumblr) { mContext = c; jsons = new ArrayList<>(); diff --git a/app/src/main/java/me/ccrama/redditslide/Adapters/ImageGridAdapterTumblr.java b/app/src/main/java/me/ccrama/redditslide/Adapters/ImageGridAdapterTumblr.java index 8e95595651..b192bd4542 100644 --- a/app/src/main/java/me/ccrama/redditslide/Adapters/ImageGridAdapterTumblr.java +++ b/app/src/main/java/me/ccrama/redditslide/Adapters/ImageGridAdapterTumblr.java @@ -14,6 +14,7 @@ import java.util.List; import me.ccrama.redditslide.Reddit; +import me.ccrama.redditslide.SettingValues; import me.ccrama.redditslide.Tumblr.Photo; /** @@ -25,7 +26,7 @@ public class ImageGridAdapterTumblr extends android.widget.BaseAdapter { public static final DisplayImageOptions options = new DisplayImageOptions.Builder() .cacheOnDisk(true) .resetViewBeforeLoading(true) - .bitmapConfig(Bitmap.Config.RGB_565) + .bitmapConfig(SettingValues.highColorspaceImages ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565) .imageScaleType(ImageScaleType.EXACTLY) .cacheInMemory(false) .displayer(new FadeInBitmapDisplayer(250)) diff --git a/app/src/main/java/me/ccrama/redditslide/Adapters/InboxAdapter.java b/app/src/main/java/me/ccrama/redditslide/Adapters/InboxAdapter.java index 726592622f..f79fa4c785 100644 --- a/app/src/main/java/me/ccrama/redditslide/Adapters/InboxAdapter.java +++ b/app/src/main/java/me/ccrama/redditslide/Adapters/InboxAdapter.java @@ -14,10 +14,10 @@ import android.content.res.TypedArray; import android.graphics.Color; import android.graphics.PorterDuff; +import android.graphics.PorterDuffColorFilter; import android.graphics.Typeface; import android.graphics.drawable.Drawable; import android.os.AsyncTask; -import android.text.Html; import android.text.SpannableStringBuilder; import android.text.Spanned; import android.text.style.ForegroundColorSpan; @@ -34,6 +34,7 @@ import androidx.appcompat.app.AppCompatActivity; import androidx.core.content.ContextCompat; +import androidx.core.text.HtmlCompat; import androidx.recyclerview.widget.RecyclerView; import com.afollestad.materialdialogs.AlertDialogWrapper; @@ -228,7 +229,7 @@ public void onBindViewHolder(final RecyclerView.ViewHolder viewHolder, int pos) if (comment.getDataNode().has("link_title")) { SpannableStringBuilder link = new SpannableStringBuilder(" " - + Html.fromHtml(comment.getDataNode().get("link_title").asText()) + + HtmlCompat.fromHtml(comment.getDataNode().get("link_title").asText(), HtmlCompat.FROM_HTML_MODE_LEGACY) + " "); link.setSpan(new StyleSpan(Typeface.BOLD_ITALIC), 0, link.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); @@ -258,22 +259,22 @@ public boolean onLongClick(View v) { final int color = ta.getColor(0, Color.WHITE); Drawable profile = mContext.getResources().getDrawable(R.drawable.profile); final Drawable reply = mContext.getResources().getDrawable(R.drawable.reply); - Drawable unhide = mContext.getResources().getDrawable(R.drawable.ic_visibility); + Drawable unhide = mContext.getResources().getDrawable(R.drawable.visibility); Drawable hide = mContext.getResources().getDrawable(R.drawable.hide); - Drawable copy = mContext.getResources().getDrawable(R.drawable.ic_content_copy); + Drawable copy = mContext.getResources().getDrawable(R.drawable.copy); Drawable reddit = mContext.getResources().getDrawable(R.drawable.commentchange); - profile.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - hide.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - copy.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - reddit.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - reply.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - unhide.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); + profile.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + hide.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + copy.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + reddit.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + reply.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + unhide.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); ta.recycle(); BottomSheet.Builder b = new BottomSheet.Builder((Activity) mContext).title( - Html.fromHtml(comment.getSubject())); + HtmlCompat.fromHtml(comment.getSubject(), HtmlCompat.FROM_HTML_MODE_LEGACY)); String author = comment.getAuthor(); if (!dataSet.where.contains("mod") @@ -331,11 +332,13 @@ public void onClick(DialogInterface dialog, int which) { break; case 25: { ClipboardManager clipboard = - (ClipboardManager) mContext.getSystemService( - Context.CLIPBOARD_SERVICE); + ContextCompat.getSystemService( + mContext, ClipboardManager.class); ClipData clip = ClipData.newPlainText("Message", comment.getBody()); - clipboard.setPrimaryClip(clip); + if (clipboard != null) { + clipboard.setPrimaryClip(clip); + } Toast.makeText(mContext, mContext.getString(R.string.mail_message_copied), Toast.LENGTH_SHORT).show(); @@ -382,8 +385,8 @@ public void onClick(View v) { if (comment.getDataNode().has("link_title")) { SpannableStringBuilder link = new SpannableStringBuilder( " " - + Html.fromHtml( - comment.getDataNode().get("link_title").asText()) + + HtmlCompat.fromHtml( + comment.getDataNode().get("link_title").asText(), HtmlCompat.FROM_HTML_MODE_LEGACY) + " "); link.setSpan(new StyleSpan(Typeface.BOLD_ITALIC), 0, link.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); @@ -426,7 +429,7 @@ private void doInboxReply(final Message replyTo) { final View dialoglayout = inflater.inflate(R.layout.edit_comment, null); final AlertDialogWrapper.Builder builder = new AlertDialogWrapper.Builder(mContext); - final EditText e = (EditText) dialoglayout.findViewById(R.id.entry); + final EditText e = dialoglayout.findViewById(R.id.entry); DoEditorActions.doActions(e, dialoglayout, ((AppCompatActivity) mContext).getSupportFragmentManager(), (Activity) mContext, @@ -492,7 +495,7 @@ public void onPostExecute(Void voids) { Snackbar s = Snackbar.make(listView, "Reply sent!", Snackbar.LENGTH_LONG); View view = s.getView(); TextView tv = - (TextView) view.findViewById(com.google.android.material.R.id.snackbar_text); + view.findViewById(com.google.android.material.R.id.snackbar_text); tv.setTextColor(Color.WHITE); s.show(); } else { @@ -500,7 +503,7 @@ public void onPostExecute(Void voids) { Snackbar.LENGTH_LONG); View view = s.getView(); TextView tv = - (TextView) view.findViewById(com.google.android.material.R.id.snackbar_text); + view.findViewById(com.google.android.material.R.id.snackbar_text); tv.setTextColor(Color.WHITE); s.show(); Drafts.addDraft(text); @@ -573,4 +576,4 @@ protected Void doInBackground(Message... params) { } -} \ No newline at end of file +} diff --git a/app/src/main/java/me/ccrama/redditslide/Adapters/MarkAsReadService.java b/app/src/main/java/me/ccrama/redditslide/Adapters/MarkAsReadService.java index e085d1da5d..83b214ee1a 100644 --- a/app/src/main/java/me/ccrama/redditslide/Adapters/MarkAsReadService.java +++ b/app/src/main/java/me/ccrama/redditslide/Adapters/MarkAsReadService.java @@ -7,6 +7,8 @@ import android.content.Intent; import android.os.Bundle; +import androidx.core.content.ContextCompat; + import net.dean.jraw.http.NetworkException; import net.dean.jraw.managers.InboxManager; @@ -34,8 +36,10 @@ public static PendingIntent getMarkAsReadIntent(int notificationId, Context cont @Override protected void onHandleIntent(Intent intent) { - NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); - manager.cancel(intent.getIntExtra(NOTIFICATION_ID, -1)); + NotificationManager manager = ContextCompat.getSystemService(this, NotificationManager.class); + if (manager != null) { + manager.cancel(intent.getIntExtra(NOTIFICATION_ID, -1)); + } String[] messages = null; Bundle extras = intent.getExtras(); diff --git a/app/src/main/java/me/ccrama/redditslide/Adapters/MessageViewHolder.java b/app/src/main/java/me/ccrama/redditslide/Adapters/MessageViewHolder.java index 6052e782e3..5c2fe357ab 100644 --- a/app/src/main/java/me/ccrama/redditslide/Adapters/MessageViewHolder.java +++ b/app/src/main/java/me/ccrama/redditslide/Adapters/MessageViewHolder.java @@ -22,13 +22,13 @@ public class MessageViewHolder extends RecyclerView.ViewHolder { public MessageViewHolder(View v) { super(v); - title = (TextView) v.findViewById(R.id.title); + title = v.findViewById(R.id.title); title.setMaxLines(1); title.setEllipsize(TextUtils.TruncateAt.END); - content = (SpoilerRobotoTextView) v.findViewById(R.id.content); - time = (TextView) v.findViewById(R.id.time); - commentOverflow = (CommentOverflow) v.findViewById(R.id.commentOverflow); - user = (TextView) v.findViewById(R.id.user); + content = v.findViewById(R.id.content); + time = v.findViewById(R.id.time); + commentOverflow = v.findViewById(R.id.commentOverflow); + user = v.findViewById(R.id.user); } diff --git a/app/src/main/java/me/ccrama/redditslide/Adapters/ModLogAdapter.java b/app/src/main/java/me/ccrama/redditslide/Adapters/ModLogAdapter.java index 2ae7248589..87a6307e07 100644 --- a/app/src/main/java/me/ccrama/redditslide/Adapters/ModLogAdapter.java +++ b/app/src/main/java/me/ccrama/redditslide/Adapters/ModLogAdapter.java @@ -98,8 +98,8 @@ public static class ModLogViewHolder extends RecyclerView.ViewHolder { public ModLogViewHolder(View itemView) { super(itemView); - body = (SpoilerRobotoTextView) itemView.findViewById(R.id.body); - icon = (ImageView) itemView.findViewById(R.id.action); + body = itemView.findViewById(R.id.body); + icon = itemView.findViewById(R.id.action); } } @@ -210,7 +210,7 @@ public void onClick(View v) { break; case "distinguish": holder.icon.setImageDrawable(ResourcesCompat.getDrawable(mContext.getResources(), - R.drawable.iconstarfilled, null)); + R.drawable.star, null)); break; case "sticky": case "unsticky": diff --git a/app/src/main/java/me/ccrama/redditslide/Adapters/ModeratorAdapter.java b/app/src/main/java/me/ccrama/redditslide/Adapters/ModeratorAdapter.java index 5931263499..5621edecdd 100644 --- a/app/src/main/java/me/ccrama/redditslide/Adapters/ModeratorAdapter.java +++ b/app/src/main/java/me/ccrama/redditslide/Adapters/ModeratorAdapter.java @@ -14,10 +14,10 @@ import android.graphics.BitmapFactory; import android.graphics.Color; import android.graphics.PorterDuff; +import android.graphics.PorterDuffColorFilter; import android.graphics.Typeface; import android.graphics.drawable.Drawable; import android.os.AsyncTask; -import android.text.Html; import android.text.InputType; import android.text.SpannableStringBuilder; import android.text.Spanned; @@ -35,6 +35,7 @@ import androidx.annotation.NonNull; import androidx.core.content.ContextCompat; +import androidx.core.text.HtmlCompat; import androidx.recyclerview.widget.RecyclerView; import com.afollestad.materialdialogs.AlertDialogWrapper; @@ -48,7 +49,6 @@ import net.dean.jraw.managers.AccountManager; import net.dean.jraw.managers.ModerationManager; import net.dean.jraw.models.Comment; -import net.dean.jraw.models.Contribution; import net.dean.jraw.models.DistinguishedStatus; import net.dean.jraw.models.PublicContribution; import net.dean.jraw.models.Submission; @@ -177,7 +177,6 @@ public void run() { submissions[0].saved = false; - v = null; } else { new AccountManager(Authentication.reddit).save(submissions[0]); final Snackbar s = Snackbar.make(v, R.string.submission_info_saved, Snackbar.LENGTH_SHORT); @@ -194,8 +193,8 @@ public void run() { submissions[0].saved = true; - v = null; } + v = null; } catch (Exception e) { return null; } @@ -219,7 +218,7 @@ public boolean onLongClick(View v) { final View dialoglayout = inflater.inflate(R.layout.postmenu, null); AlertDialogWrapper.Builder builder = new AlertDialogWrapper.Builder(mContext); final TextView title = dialoglayout.findViewById(R.id.title); - title.setText(Html.fromHtml(submission.getTitle())); + title.setText(HtmlCompat.fromHtml(submission.getTitle(), HtmlCompat.FROM_HTML_MODE_LEGACY)); ((TextView) dialoglayout.findViewById(R.id.userpopup)).setText("/u/" + submission.getAuthor()); ((TextView) dialoglayout.findViewById(R.id.subpopup)).setText("/r/" + submission.getSubredditName()); @@ -479,7 +478,7 @@ public void onSingleClick(View v) { setViews(comment.getDataNode().get("body_html").asText(), comment.getSubredditName(), holder); ((TextView) holder.gild).setText(""); - if (comment.getTimesSilvered() > 0 || comment.getTimesGilded() > 0 || comment.getTimesPlatinized() > 0) { + if (!SettingValues.hideCommentAwards && (comment.getTimesSilvered() > 0 || comment.getTimesGilded() > 0 || comment.getTimesPlatinized() > 0)) { TypedArray a = mContext.obtainStyledAttributes( new FontPreferences(mContext).getPostFontStyle().getResId(), R.styleable.FontStyle); @@ -537,9 +536,9 @@ public void onSingleClick(View v) { holder.gild.setVisibility(View.GONE); if (comment.getSubmissionTitle() != null) - holder.title.setText(Html.fromHtml(comment.getSubmissionTitle())); + holder.title.setText(HtmlCompat.fromHtml(comment.getSubmissionTitle(), HtmlCompat.FROM_HTML_MODE_LEGACY)); else - holder.title.setText(Html.fromHtml(comment.getAuthor())); + holder.title.setText(HtmlCompat.fromHtml(comment.getAuthor(), HtmlCompat.FROM_HTML_MODE_LEGACY)); holder.itemView.setOnClickListener(new View.OnClickListener() { @@ -613,33 +612,33 @@ public static void showModBottomSheet(final Context mContext, final Drawable approve = mContext.getResources().getDrawable(R.drawable.support); final Drawable nsfw = mContext.getResources().getDrawable(R.drawable.hide); final Drawable pin = mContext.getResources().getDrawable(R.drawable.sub); - final Drawable distinguish = mContext.getResources().getDrawable(R.drawable.iconstarfilled); + final Drawable distinguish = mContext.getResources().getDrawable(R.drawable.star); final Drawable remove = mContext.getResources().getDrawable(R.drawable.close); final Drawable ban = mContext.getResources().getDrawable(R.drawable.ban); final Drawable spam = mContext.getResources().getDrawable(R.drawable.spam); final Drawable note = mContext.getResources().getDrawable(R.drawable.note); - final Drawable removeReason = mContext.getResources().getDrawable(R.drawable.reportreason); + final Drawable removeReason = mContext.getResources().getDrawable(R.drawable.report_reason); final Drawable lock = mContext.getResources().getDrawable(R.drawable.lock); //Tint drawables - profile.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - report.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - approve.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - nsfw.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - distinguish.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - remove.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - pin.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - ban.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - spam.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - note.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - removeReason.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - lock.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); + profile.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + report.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + approve.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + nsfw.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + distinguish.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + remove.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + pin.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + ban.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + spam.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + note.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + removeReason.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + lock.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); ta.recycle(); //Bottom sheet builder BottomSheet.Builder b = new BottomSheet.Builder((Activity) mContext).title( - Html.fromHtml(comment.getBody())); + HtmlCompat.fromHtml(comment.getBody(), HtmlCompat.FROM_HTML_MODE_LEGACY)); int reportCount = reports.size() + reports2.size(); diff --git a/app/src/main/java/me/ccrama/redditslide/Adapters/MoreCommentViewHolder.java b/app/src/main/java/me/ccrama/redditslide/Adapters/MoreCommentViewHolder.java index 873f922e71..86dafdd1e9 100644 --- a/app/src/main/java/me/ccrama/redditslide/Adapters/MoreCommentViewHolder.java +++ b/app/src/main/java/me/ccrama/redditslide/Adapters/MoreCommentViewHolder.java @@ -18,7 +18,7 @@ public class MoreCommentViewHolder extends RecyclerView.ViewHolder { public MoreCommentViewHolder(View v) { super(v); dots = v.findViewById(R.id.dot); - content = (TextView) v.findViewById(R.id.content); + content = v.findViewById(R.id.content); loading = v.findViewById(R.id.loading); } } diff --git a/app/src/main/java/me/ccrama/redditslide/Adapters/MultiredditPosts.java b/app/src/main/java/me/ccrama/redditslide/Adapters/MultiredditPosts.java index 2fe638e7b6..c6772b9c4a 100644 --- a/app/src/main/java/me/ccrama/redditslide/Adapters/MultiredditPosts.java +++ b/app/src/main/java/me/ccrama/redditslide/Adapters/MultiredditPosts.java @@ -3,9 +3,10 @@ import android.content.Context; import android.graphics.Bitmap; import android.os.AsyncTask; -import android.text.Html; import android.view.View; +import androidx.core.text.HtmlCompat; + import com.nostra13.universalimageloader.core.assist.FailReason; import com.nostra13.universalimageloader.core.listener.ImageLoadingListener; @@ -98,19 +99,19 @@ public void loadPhotos(List submissions) { int length = submission.getThumbnails().getVariations().length; if (SettingValues.lqLow && length >= 3) { - url = Html.fromHtml( - submission.getThumbnails().getVariations()[2].getUrl()) + url = HtmlCompat.fromHtml( + submission.getThumbnails().getVariations()[2].getUrl(), HtmlCompat.FROM_HTML_MODE_LEGACY) .toString(); //unescape url characters } else if (SettingValues.lqMid && length >= 4) { - url = Html.fromHtml( - submission.getThumbnails().getVariations()[3].getUrl()) + url = HtmlCompat.fromHtml( + submission.getThumbnails().getVariations()[3].getUrl(), HtmlCompat.FROM_HTML_MODE_LEGACY) .toString(); //unescape url characters } else if (length >= 5) { - url = Html.fromHtml(submission.getThumbnails().getVariations()[ + url = HtmlCompat.fromHtml(submission.getThumbnails().getVariations()[ length - - 1].getUrl()).toString(); //unescape url characters + - 1].getUrl(), HtmlCompat.FROM_HTML_MODE_LEGACY).toString(); //unescape url characters } else { - url = Html.fromHtml(submission.getThumbnails().getSource().getUrl()) + url = HtmlCompat.fromHtml(submission.getThumbnails().getSource().getUrl(), HtmlCompat.FROM_HTML_MODE_LEGACY) .toString(); //unescape url characters } @@ -167,24 +168,24 @@ public void onLoadingCancelled(String imageUri, View view) { int length = submission.getThumbnails().getVariations().length; if (SettingValues.lqLow && length >= 3) { - url = Html.fromHtml( - submission.getThumbnails().getVariations()[2].getUrl()) + url = HtmlCompat.fromHtml( + submission.getThumbnails().getVariations()[2].getUrl(), HtmlCompat.FROM_HTML_MODE_LEGACY) .toString(); //unescape url characters } else if (SettingValues.lqMid && length >= 4) { - url = Html.fromHtml( - submission.getThumbnails().getVariations()[3].getUrl()) + url = HtmlCompat.fromHtml( + submission.getThumbnails().getVariations()[3].getUrl(), HtmlCompat.FROM_HTML_MODE_LEGACY) .toString(); //unescape url characters } else if (length >= 5) { - url = Html.fromHtml(submission.getThumbnails().getVariations()[ + url = HtmlCompat.fromHtml(submission.getThumbnails().getVariations()[ length - - 1].getUrl()).toString(); //unescape url characters + - 1].getUrl(), HtmlCompat.FROM_HTML_MODE_LEGACY).toString(); //unescape url characters } else { - url = Html.fromHtml(submission.getThumbnails().getSource().getUrl()) + url = HtmlCompat.fromHtml(submission.getThumbnails().getSource().getUrl(), HtmlCompat.FROM_HTML_MODE_LEGACY) .toString(); //unescape url characters } } else { - url = Html.fromHtml(submission.getThumbnails().getSource().getUrl()) + url = HtmlCompat.fromHtml(submission.getThumbnails().getSource().getUrl(), HtmlCompat.FROM_HTML_MODE_LEGACY) .toString(); //unescape url characters } diff --git a/app/src/main/java/me/ccrama/redditslide/Adapters/NewsViewHolder.java b/app/src/main/java/me/ccrama/redditslide/Adapters/NewsViewHolder.java index 740c44e96e..a0846cb629 100644 --- a/app/src/main/java/me/ccrama/redditslide/Adapters/NewsViewHolder.java +++ b/app/src/main/java/me/ccrama/redditslide/Adapters/NewsViewHolder.java @@ -23,11 +23,11 @@ public class NewsViewHolder extends RecyclerView.ViewHolder { public NewsViewHolder(View v) { super(v); - title = (SpoilerRobotoTextView) v.findViewById(R.id.title); + title = v.findViewById(R.id.title); comment = v.findViewById(R.id.comments); menu = v.findViewById(R.id.more); - leadImage = (HeaderImageLinkView) v.findViewById(R.id.headerimage); - innerRelative = (RelativeLayout) v.findViewById(R.id.innerrelative); + leadImage = v.findViewById(R.id.headerimage); + innerRelative = v.findViewById(R.id.innerrelative); thumbnail = v.findViewById(R.id.thumbimage2); } } diff --git a/app/src/main/java/me/ccrama/redditslide/Adapters/OfflineSubAdapter.java b/app/src/main/java/me/ccrama/redditslide/Adapters/OfflineSubAdapter.java index e0abcdbf42..a78f61e006 100644 --- a/app/src/main/java/me/ccrama/redditslide/Adapters/OfflineSubAdapter.java +++ b/app/src/main/java/me/ccrama/redditslide/Adapters/OfflineSubAdapter.java @@ -34,15 +34,13 @@ public View getView(int position, View convertView, ViewGroup parent) { } public View getCustomView(int position, View convertView, ViewGroup parent) { - - LayoutInflater inflater = - ( LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); - ViewHolder holder; + if (convertView == null) { - convertView = inflater.inflate(android.R.layout.simple_list_item_1, null); + convertView = LayoutInflater.from(mContext) + .inflate(android.R.layout.simple_list_item_1, null); holder = new ViewHolder(); - holder.txt01 = (TextView) convertView.findViewById(android.R.id.text1); + holder.txt01 = convertView.findViewById(android.R.id.text1); holder.txt01.setTextColor(Color.WHITE); convertView.setTag(holder); } else { @@ -60,4 +58,4 @@ static class ViewHolder { -} \ No newline at end of file +} diff --git a/app/src/main/java/me/ccrama/redditslide/Adapters/ProfileCommentViewHolder.java b/app/src/main/java/me/ccrama/redditslide/Adapters/ProfileCommentViewHolder.java index a69c971dc7..d0ccde77b5 100644 --- a/app/src/main/java/me/ccrama/redditslide/Adapters/ProfileCommentViewHolder.java +++ b/app/src/main/java/me/ccrama/redditslide/Adapters/ProfileCommentViewHolder.java @@ -23,12 +23,12 @@ public class ProfileCommentViewHolder extends RecyclerView.ViewHolder { public ProfileCommentViewHolder(View v) { super(v); - title = (TextView) v.findViewById(R.id.title); + title = v.findViewById(R.id.title); user = v.findViewById(R.id.user); - score = (TextView) v.findViewById(R.id.score); - time = (TextView) v.findViewById(R.id.time); + score = v.findViewById(R.id.score); + time = v.findViewById(R.id.time); gild = v.findViewById(R.id.gildtext); - content = (SpoilerRobotoTextView) v.findViewById(R.id.content); - overflow = (CommentOverflow) v.findViewById(R.id.commentOverflow); + content = v.findViewById(R.id.content); + overflow = v.findViewById(R.id.commentOverflow); } } \ No newline at end of file diff --git a/app/src/main/java/me/ccrama/redditslide/Adapters/RedditGalleryView.java b/app/src/main/java/me/ccrama/redditslide/Adapters/RedditGalleryView.java new file mode 100644 index 0000000000..bdba0aa087 --- /dev/null +++ b/app/src/main/java/me/ccrama/redditslide/Adapters/RedditGalleryView.java @@ -0,0 +1,223 @@ +package me.ccrama.redditslide.Adapters; + +import android.app.Activity; +import android.app.Dialog; +import android.content.Intent; +import android.graphics.Typeface; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.AdapterView; +import android.widget.GridView; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.RelativeLayout; + +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import com.afollestad.materialdialogs.AlertDialogWrapper; +import com.devspark.robototextview.RobotoTypefaces; + +import java.net.MalformedURLException; +import java.net.URL; +import java.util.List; + +import me.ccrama.redditslide.Activities.Album; +import me.ccrama.redditslide.Activities.GalleryImage; +import me.ccrama.redditslide.Activities.MediaView; +import me.ccrama.redditslide.R; +import me.ccrama.redditslide.Reddit; +import me.ccrama.redditslide.SettingValues; +import me.ccrama.redditslide.SpoilerRobotoTextView; +import me.ccrama.redditslide.Visuals.FontPreferences; +import me.ccrama.redditslide.util.LinkUtil; + +import static me.ccrama.redditslide.Notifications.ImageDownloadNotificationService.EXTRA_SUBMISSION_TITLE; + +public class RedditGalleryView extends RecyclerView.Adapter { + private final List images; + + private final Activity main; + + public boolean paddingBottom; + public int height; + public String subreddit; + private final String submissionTitle; + + public RedditGalleryView(final Activity context, final List images, int height, + String subreddit, String submissionTitle) { + this.height = height; + main = context; + this.images = images; + this.subreddit = subreddit; + this.submissionTitle = submissionTitle; + + paddingBottom = main.findViewById(R.id.toolbar) == null; + if (context.findViewById(R.id.grid) != null) + context.findViewById(R.id.grid).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + LayoutInflater l = context.getLayoutInflater(); + View body = l.inflate(R.layout.album_grid_dialog, null, false); + AlertDialogWrapper.Builder b = new AlertDialogWrapper.Builder(context); + GridView gridview = body.findViewById(R.id.images); + gridview.setAdapter(new ImageGridAdapter(context, true, images)); + + + b.setView(body); + final Dialog d = b.create(); + gridview.setOnItemClickListener(new AdapterView.OnItemClickListener() { + public void onItemClick(AdapterView parent, View v, + int position, long id) { + if (context instanceof Album) { + ((LinearLayoutManager) ((Album) context).album.album.recyclerView.getLayoutManager()).scrollToPositionWithOffset(position + 1, context.findViewById(R.id.toolbar).getHeight()); + + + } else { + ((LinearLayoutManager) ((RecyclerView) context.findViewById(R.id.images)).getLayoutManager()).scrollToPositionWithOffset(position + 1, context.findViewById(R.id.toolbar).getHeight()); + } + d.dismiss(); + } + }); + d.show(); + } + }); + } + + @Override + public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { + if (viewType == 1) { + View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.album_image, parent, false); + return new AlbumViewHolder(v); + } else { + View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.spacer, parent, false); + return new SpacerViewHolder(v); + } + } + + public double getHeightFromAspectRatio(int imageHeight, int imageWidth, int viewWidth) { + double ratio = (double) imageHeight / (double) imageWidth; + return (viewWidth * ratio); + + } + + @Override + public int getItemViewType(int position) { + int SPACER = 6; + if (!paddingBottom && position == 0) { + return SPACER; + } else if (paddingBottom && position == getItemCount() - 1) { + return SPACER; + } else { + return 1; + } + } + + @Override + public void onBindViewHolder(RecyclerView.ViewHolder holder2, int i) { + if (holder2 instanceof AlbumViewHolder) { + final int position = paddingBottom ? i : i - 1; + + AlbumViewHolder holder = (AlbumViewHolder) holder2; + + final GalleryImage image = images.get(position); + ((Reddit) main.getApplicationContext()).getImageLoader().displayImage(image.url, holder.image, ImageGridAdapter.options); + holder.body.setVisibility(View.VISIBLE); + holder.text.setVisibility(View.VISIBLE); + View imageView = holder.image; + if (imageView.getWidth() == 0) { + holder.image.setLayoutParams(new LinearLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT)); + } else { + holder.image.setLayoutParams(new LinearLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, (int) getHeightFromAspectRatio(image.height, image.width, imageView.getWidth()))); + } + { + int type = new FontPreferences(holder.body.getContext()).getFontTypeComment().getTypeface(); + Typeface typeface; + if (type >= 0) { + typeface = RobotoTypefaces.obtainTypeface(holder.body.getContext(), type); + } else { + typeface = Typeface.DEFAULT; + } + holder.body.setTypeface(typeface); + } + { + int type = new FontPreferences(holder.body.getContext()).getFontTypeTitle().getTypeface(); + Typeface typeface; + if (type >= 0) { + typeface = RobotoTypefaces.obtainTypeface(holder.body.getContext(), type); + } else { + typeface = Typeface.DEFAULT; + } + holder.text.setTypeface(typeface); + } + holder.text.setVisibility(View.GONE); + holder.body.setVisibility(View.GONE); + + + View.OnClickListener onGifImageClickListener = new View.OnClickListener() { + @Override + public void onClick(View view) { + if (SettingValues.image) { + Intent myIntent = new Intent(main, MediaView.class); + myIntent.putExtra(MediaView.EXTRA_URL, image.url); + myIntent.putExtra(MediaView.SUBREDDIT, subreddit); + if(submissionTitle != null) { + myIntent.putExtra(EXTRA_SUBMISSION_TITLE, submissionTitle); + } + myIntent.putExtra("index", position); + main.startActivity(myIntent); + } else { + LinkUtil.openExternally(image.url); + } + } + }; + + holder.itemView.setOnClickListener(onGifImageClickListener); + } else if (holder2 instanceof SpacerViewHolder) { + holder2.itemView.findViewById(R.id.height).setLayoutParams(new LinearLayout.LayoutParams(holder2.itemView.getWidth(), paddingBottom ? height : main.findViewById(R.id.toolbar).getHeight())); + } + + } + + public static void setTextWithLinks(String s, SpoilerRobotoTextView text) { + String[] parts = s.split("\\s+"); + + StringBuilder b = new StringBuilder(); + for (String item : parts) + try { + URL url = new URL(item); + b.append(" ").append(url).append(""); + } catch (MalformedURLException e) { + b.append(" ").append(item); + } + text.setTextHtml(b.toString(), "no sub"); + } + + @Override + public int getItemCount() { + return images == null ? 0 : images.size() + 1; + } + + public static class SpacerViewHolder extends RecyclerView.ViewHolder { + public SpacerViewHolder(View itemView) { + super(itemView); + } + } + + public static class AlbumViewHolder extends RecyclerView.ViewHolder { + final SpoilerRobotoTextView text; + final SpoilerRobotoTextView body; + final ImageView image; + + public AlbumViewHolder(View itemView) { + super(itemView); + text = itemView.findViewById(R.id.imagetitle); + body = itemView.findViewById(R.id.imageCaption); + image = itemView.findViewById(R.id.image); + + + } + } + +} diff --git a/app/src/main/java/me/ccrama/redditslide/Adapters/SettingsSubAdapter.java b/app/src/main/java/me/ccrama/redditslide/Adapters/SettingsSubAdapter.java index 94f46180e7..d89d73dbad 100644 --- a/app/src/main/java/me/ccrama/redditslide/Adapters/SettingsSubAdapter.java +++ b/app/src/main/java/me/ccrama/redditslide/Adapters/SettingsSubAdapter.java @@ -4,6 +4,7 @@ import android.content.Context; import android.content.DialogInterface; import android.graphics.PorterDuff; +import android.graphics.PorterDuffColorFilter; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -58,7 +59,7 @@ public void onBindViewHolder(ViewHolder holder, int position) { final String subreddit = objects.get(position); convertView.findViewById(R.id.color).setBackgroundResource(R.drawable.circle); - convertView.findViewById(R.id.color).getBackground().setColorFilter(Palette.getColor(subreddit), PorterDuff.Mode.MULTIPLY); + convertView.findViewById(R.id.color).getBackground().setColorFilter(new PorterDuffColorFilter(Palette.getColor(subreddit), PorterDuff.Mode.MULTIPLY)); final String DELETE_SUB_SETTINGS_TITLE = (subreddit.contains("/m/")) ? subreddit : ("/r/" + subreddit); convertView.findViewById(R.id.remove).setOnClickListener(new View.OnClickListener() { diff --git a/app/src/main/java/me/ccrama/redditslide/Adapters/SideArrayAdapter.java b/app/src/main/java/me/ccrama/redditslide/Adapters/SideArrayAdapter.java index 293cc95fed..a429b7b58d 100644 --- a/app/src/main/java/me/ccrama/redditslide/Adapters/SideArrayAdapter.java +++ b/app/src/main/java/me/ccrama/redditslide/Adapters/SideArrayAdapter.java @@ -4,6 +4,7 @@ import android.content.Context; import android.content.Intent; import android.graphics.PorterDuff; +import android.graphics.PorterDuffColorFilter; import android.util.Log; import android.view.LayoutInflater; import android.view.View; @@ -18,6 +19,7 @@ import android.widget.TextView; import androidx.cardview.widget.CardView; +import androidx.core.content.ContextCompat; import org.apache.commons.lang3.StringUtils; @@ -81,6 +83,44 @@ public Filter getFilter() { int height; Map multiToMatch; + private void hideSearchbarUI() { + try { + //Hide the toolbar search UI without an animation because we're starting a new activity + if ((SettingValues.subredditSearchMethod + == Constants.SUBREDDIT_SEARCH_METHOD_TOOLBAR + || SettingValues.subredditSearchMethod + == Constants.SUBREDDIT_SEARCH_METHOD_BOTH) + && ((MainActivity) getContext()).findViewById(R.id.toolbar_search) + .getVisibility() == View.VISIBLE) { + ((MainActivity) getContext()).findViewById( + R.id.toolbar_search_suggestions).setVisibility(View.GONE); + ((MainActivity) getContext()).findViewById(R.id.toolbar_search) + .setVisibility(View.GONE); + ((MainActivity) getContext()).findViewById(R.id.close_search_toolbar) + .setVisibility(View.GONE); + + //Play the exit animations of the search toolbar UI to avoid the animations failing to animate upon the next time + //the search toolbar UI is called. Set animation to 0 because the UI is already hidden. + ((MainActivity) getContext()).exitAnimationsForToolbarSearch(0, + ((CardView) ((MainActivity) getContext()).findViewById( + R.id.toolbar_search_suggestions)), + ((AutoCompleteTextView) ((MainActivity) getContext()).findViewById( + R.id.toolbar_search)), + ((ImageView) ((MainActivity) getContext()).findViewById( + R.id.close_search_toolbar))); + if (SettingValues.single) { + ((MainActivity) getContext()).getSupportActionBar() + .setTitle(((MainActivity) getContext()).selectedSub); + } else { + ((MainActivity) getContext()).getSupportActionBar() + .setTitle(((MainActivity) getContext()).tabViewModeTitle); + } + } + } catch (NullPointerException npe) { + Log.e(getClass().getName(), npe.getMessage()); + } + } + @Override public View getView(final int position, View convertView, ViewGroup parent) { if (position < fitems.size()) { @@ -95,7 +135,7 @@ public View getView(final int position, View convertView, ViewGroup parent) { } else { sub = fitems.get(position); } - final TextView t = ((TextView) convertView.findViewById(R.id.name)); + final TextView t = convertView.findViewById(R.id.name); t.setText(sub); if (height == 0) { @@ -118,48 +158,13 @@ public void onGlobalLayout() { convertView.findViewById(R.id.color).setBackgroundResource(R.drawable.circle); convertView.findViewById(R.id.color) .getBackground() - .setColorFilter(Palette.getColor(subreddit), PorterDuff.Mode.MULTIPLY); + .setColorFilter(new PorterDuffColorFilter(Palette.getColor(subreddit), PorterDuff.Mode.MULTIPLY)); convertView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (base.startsWith(getContext().getString(R.string.search_goto) + " ") || !((MainActivity) getContext()).usedArray.contains(base)) { - try { - //Hide the toolbar search UI without an animation because we're starting a new activity - if ((SettingValues.subredditSearchMethod - == Constants.SUBREDDIT_SEARCH_METHOD_TOOLBAR - || SettingValues.subredditSearchMethod - == Constants.SUBREDDIT_SEARCH_METHOD_BOTH) - && ((MainActivity) getContext()).findViewById( - R.id.toolbar_search).getVisibility() == View.VISIBLE) { - ((MainActivity) getContext()).findViewById( - R.id.toolbar_search_suggestions).setVisibility(View.GONE); - ((MainActivity) getContext()).findViewById(R.id.toolbar_search) - .setVisibility(View.GONE); - ((MainActivity) getContext()).findViewById( - R.id.close_search_toolbar).setVisibility(View.GONE); - - //Play the exit animations of the search toolbar UI to avoid the animations failing to animate upon the next time - //the search toolbar UI is called. Set animation to 0 because the UI is already hidden. - ((MainActivity) getContext()).exitAnimationsForToolbarSearch(0, - ((CardView) ((MainActivity) getContext()).findViewById( - R.id.toolbar_search_suggestions)), - ((AutoCompleteTextView) ((MainActivity) getContext()).findViewById( - R.id.toolbar_search)), - ((ImageView) ((MainActivity) getContext()).findViewById( - R.id.close_search_toolbar))); - if (SettingValues.single) { - ((MainActivity) getContext()).getSupportActionBar() - .setTitle(((MainActivity) getContext()).selectedSub); - } else { - ((MainActivity) getContext()).getSupportActionBar() - .setTitle( - ((MainActivity) getContext()).tabViewModeTitle); - } - } - } catch (NullPointerException npe) { - Log.e(getClass().getName(), npe.getMessage()); - } + hideSearchbarUI(); Intent inte = new Intent(getContext(), SubredditView.class); inte.putExtra(SubredditView.EXTRA_SUBREDDIT, subreddit); ((Activity) getContext()).startActivityForResult(inte, 2001); @@ -199,79 +204,42 @@ public void onClick(View view) { ((MainActivity) getContext()).drawerSearch.setText(""); } } - InputMethodManager imm = (InputMethodManager) getContext().getSystemService( - Context.INPUT_METHOD_SERVICE); - imm.hideSoftInputFromWindow(view.getWindowToken(), 0); + InputMethodManager imm = ContextCompat.getSystemService(getContext(), InputMethodManager.class); + if (imm != null) { + imm.hideSoftInputFromWindow(view.getWindowToken(), 0); + } } }); convertView.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View view) { - try { - //Hide the toolbar search UI without an animation because we're starting a new activity - if ((SettingValues.subredditSearchMethod - == Constants.SUBREDDIT_SEARCH_METHOD_TOOLBAR - || SettingValues.subredditSearchMethod - == Constants.SUBREDDIT_SEARCH_METHOD_BOTH) - && ((MainActivity) getContext()).findViewById(R.id.toolbar_search) - .getVisibility() == View.VISIBLE) { - ((MainActivity) getContext()).findViewById( - R.id.toolbar_search_suggestions).setVisibility(View.GONE); - ((MainActivity) getContext()).findViewById(R.id.toolbar_search) - .setVisibility(View.GONE); - ((MainActivity) getContext()).findViewById(R.id.close_search_toolbar) - .setVisibility(View.GONE); - - //Play the exit animations of the search toolbar UI to avoid the animations failing to animate upon the next time - //the search toolbar UI is called. Set animation to 0 because the UI is already hidden. - ((MainActivity) getContext()).exitAnimationsForToolbarSearch(0, - ((CardView) ((MainActivity) getContext()).findViewById( - R.id.toolbar_search_suggestions)), - ((AutoCompleteTextView) ((MainActivity) getContext()).findViewById( - R.id.toolbar_search)), - ((ImageView) ((MainActivity) getContext()).findViewById( - R.id.close_search_toolbar))); - if (SettingValues.single) { - ((MainActivity) getContext()).getSupportActionBar() - .setTitle(((MainActivity) getContext()).selectedSub); - } else { - ((MainActivity) getContext()).getSupportActionBar() - .setTitle(((MainActivity) getContext()).tabViewModeTitle); - } - } - } catch (NullPointerException npe) { - Log.e(getClass().getName(), npe.getMessage()); - } + hideSearchbarUI(); Intent inte = new Intent(getContext(), SubredditView.class); inte.putExtra(SubredditView.EXTRA_SUBREDDIT, subreddit); ((Activity) getContext()).startActivityForResult(inte, 2001); - InputMethodManager imm = (InputMethodManager) getContext().getSystemService( - Context.INPUT_METHOD_SERVICE); - imm.hideSoftInputFromWindow(view.getWindowToken(), 0); + InputMethodManager imm = ContextCompat.getSystemService(getContext(), InputMethodManager.class); + if (imm != null) { + imm.hideSoftInputFromWindow(view.getWindowToken(), 0); + } return true; } }); } else { + convertView = + LayoutInflater.from(getContext()).inflate(R.layout.spacer, parent, false); + ViewGroup.LayoutParams params = + convertView.findViewById(R.id.height).getLayoutParams(); if ((fitems.size() * height) < parentL.getHeight() && (SettingValues.subredditSearchMethod == Constants.SUBREDDIT_SEARCH_METHOD_DRAWER || SettingValues.subredditSearchMethod == Constants.SUBREDDIT_SEARCH_METHOD_BOTH)) { - convertView = - LayoutInflater.from(getContext()).inflate(R.layout.spacer, parent, false); - ViewGroup.LayoutParams params = - convertView.findViewById(R.id.height).getLayoutParams(); params.height = (parentL.getHeight() - (getCount() - 1) * height); - convertView.setLayoutParams(params); } else { - convertView = - LayoutInflater.from(getContext()).inflate(R.layout.spacer, parent, false); - ViewGroup.LayoutParams params = - convertView.findViewById(R.id.height).getLayoutParams(); params.height = 0; - convertView.setLayoutParams(params); } + convertView.setLayoutParams(params); } return convertView; } @@ -331,4 +299,4 @@ protected void publishResults(CharSequence constraint, FilterResults results) { } } } -} \ No newline at end of file +} diff --git a/app/src/main/java/me/ccrama/redditslide/Adapters/SubChooseAdapter.java b/app/src/main/java/me/ccrama/redditslide/Adapters/SubChooseAdapter.java index 642e3a75e6..d12aa7778d 100644 --- a/app/src/main/java/me/ccrama/redditslide/Adapters/SubChooseAdapter.java +++ b/app/src/main/java/me/ccrama/redditslide/Adapters/SubChooseAdapter.java @@ -82,7 +82,7 @@ public View getView(final int position, View convertView, ViewGroup parent) { ViewHolderItem viewHolderItem; if (convertView == null) { convertView = LayoutInflater.from(getContext()).inflate(R.layout.subforsublist, parent, false); - viewHolderItem = new ViewHolderItem((TextView) convertView.findViewById(R.id.name)); + viewHolderItem = new ViewHolderItem(convertView.findViewById(R.id.name)); convertView.setTag(viewHolderItem); } else { viewHolderItem = (ViewHolderItem) convertView.getTag(); @@ -94,7 +94,8 @@ public View getView(final int position, View convertView, ViewGroup parent) { final String subreddit = fitems.get(position); convertView.findViewById(R.id.color).setBackgroundResource(R.drawable.circle); - convertView.findViewById(R.id.color).getBackground().setColorFilter(Palette.getColor(subreddit), PorterDuff.Mode.MULTIPLY); + convertView.findViewById(R.id.color).getBackground().setColorFilter(new PorterDuffColorFilter( + Palette.getColor(subreddit), PorterDuff.Mode.MULTIPLY)); if(getContext() instanceof SetupWidget){ convertView.setOnClickListener(new View.OnClickListener() { @@ -120,9 +121,8 @@ public void onClick(View v) { src = Shortcut.drawableToBitmap(ContextCompat.getDrawable(getContext(), R.drawable.blackandwhite)); final int overlayColor = Palette.getColor(subreddit); final Paint paint = new Paint(); - Canvas c; final Bitmap bm1 = Bitmap.createBitmap(src.getWidth(), src.getHeight(), Bitmap.Config.ARGB_8888); - c = new Canvas(bm1); + Canvas c = new Canvas(bm1); paint.setColorFilter(new PorterDuffColorFilter(overlayColor, PorterDuff.Mode.OVERLAY)); c.drawBitmap(src, 0, 0, paint); @@ -137,7 +137,7 @@ public void onClick(View v) { ImageUtil.drawWithTargetColor(bm2, bm1, overlayColor, 0); } - final float scale = ((Shortcut)getContext()).getResources().getDisplayMetrics().density; + final float scale = getContext().getResources().getDisplayMetrics().density; int p = (int) (50 * scale + 0.5f); shortcutIntent.putExtra(OpenContent.EXTRA_URL, "reddit.com/r/" + subreddit); Intent intent = new Intent(); @@ -164,7 +164,7 @@ protected FilterResults performFiltering(CharSequence constraint) { FilterResults results = new FilterResults(); String prefix = constraint.toString().toLowerCase(Locale.ENGLISH); - if (prefix == null || prefix.length() == 0) { + if (prefix == null || prefix.isEmpty()) { ArrayList list = new ArrayList<>(baseItems); results.values = list; results.count = list.size(); @@ -201,4 +201,4 @@ protected void publishResults(CharSequence constraint, FilterResults results) { } } } -} \ No newline at end of file +} diff --git a/app/src/main/java/me/ccrama/redditslide/Adapters/SubmissionAdapter.java b/app/src/main/java/me/ccrama/redditslide/Adapters/SubmissionAdapter.java index 01020ed3bc..b4b42db23c 100644 --- a/app/src/main/java/me/ccrama/redditslide/Adapters/SubmissionAdapter.java +++ b/app/src/main/java/me/ccrama/redditslide/Adapters/SubmissionAdapter.java @@ -149,7 +149,7 @@ public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) { @Override public void onSingleClick(View v) { dataSet.loadMore(v.getContext(), - (SubmissionsView) displayer, false, dataSet.subreddit); + displayer, false, dataSet.subreddit); } }); return new SubmissionFooterViewHolder(v); @@ -456,7 +456,6 @@ public void run() { submissions[0].saved = false; - v = null; } else { new AccountManager(Authentication.reddit).save(submissions[0]); final Snackbar s = @@ -474,8 +473,8 @@ public void run() { submissions[0].saved = true; - v = null; } + v = null; } catch (Exception e) { return null; } @@ -496,4 +495,4 @@ public void performClick(int adapterPosition) { } } } -} \ No newline at end of file +} diff --git a/app/src/main/java/me/ccrama/redditslide/Adapters/SubmissionComments.java b/app/src/main/java/me/ccrama/redditslide/Adapters/SubmissionComments.java index aef693323d..1ce051f147 100644 --- a/app/src/main/java/me/ccrama/redditslide/Adapters/SubmissionComments.java +++ b/app/src/main/java/me/ccrama/redditslide/Adapters/SubmissionComments.java @@ -159,7 +159,7 @@ public void loadMoreReplyTop(CommentAdapter adapter, String context) { if (context == null || context.isEmpty()) { Snackbar s = Snackbar.make(page.rv, "Comment submitted", Snackbar.LENGTH_SHORT); View view = s.getView(); - TextView tv = (TextView) view.findViewById(com.google.android.material.R.id.snackbar_text); + TextView tv = view.findViewById(com.google.android.material.R.id.snackbar_text); tv.setTextColor(Color.WHITE); s.show(); } @@ -206,7 +206,7 @@ public JsonNode getSubmissionNode(SubmissionRequest request) { } public void reloadSubmission(CommentAdapter commentAdapter) { - commentAdapter.submission = Authentication.reddit.getSubmission(submission.getFullName().substring(3, submission.getFullName().length())); + commentAdapter.submission = Authentication.reddit.getSubmission(submission.getFullName().substring(3)); } public boolean forceSorting = false; diff --git a/app/src/main/java/me/ccrama/redditslide/Adapters/SubmissionNewsAdapter.java b/app/src/main/java/me/ccrama/redditslide/Adapters/SubmissionNewsAdapter.java index 10a83ed5a1..b983c88283 100644 --- a/app/src/main/java/me/ccrama/redditslide/Adapters/SubmissionNewsAdapter.java +++ b/app/src/main/java/me/ccrama/redditslide/Adapters/SubmissionNewsAdapter.java @@ -325,7 +325,7 @@ public void onClick(DialogInterface dialog, } }); View view = s.getView(); - TextView tv = (TextView) view.findViewById( + TextView tv = view.findViewById( com.google.android.material.R.id.snackbar_text); tv.setTextColor(Color.WHITE); s.show(); @@ -435,7 +435,7 @@ protected Void doInBackground(Submission... submissions) { @Override public void run() { View view = s.getView(); - TextView tv = (TextView) view.findViewById( + TextView tv = view.findViewById( com.google.android.material.R.id.snackbar_text); tv.setTextColor(Color.WHITE); s.show(); @@ -444,7 +444,6 @@ public void run() { submissions[0].saved = false; - v = null; } else { new AccountManager(Authentication.reddit).save(submissions[0]); final Snackbar s = @@ -453,7 +452,7 @@ public void run() { @Override public void run() { View view = s.getView(); - TextView tv = (TextView) view.findViewById( + TextView tv = view.findViewById( com.google.android.material.R.id.snackbar_text); tv.setTextColor(Color.WHITE); s.show(); @@ -462,8 +461,8 @@ public void run() { submissions[0].saved = true; - v = null; } + v = null; } catch (Exception e) { return null; } @@ -484,4 +483,4 @@ public void performClick(int adapterPosition) { } } } -} \ No newline at end of file +} diff --git a/app/src/main/java/me/ccrama/redditslide/Adapters/SubmissionViewHolder.java b/app/src/main/java/me/ccrama/redditslide/Adapters/SubmissionViewHolder.java index 8e0fe5975e..212f8e20db 100644 --- a/app/src/main/java/me/ccrama/redditslide/Adapters/SubmissionViewHolder.java +++ b/app/src/main/java/me/ccrama/redditslide/Adapters/SubmissionViewHolder.java @@ -39,26 +39,26 @@ public class SubmissionViewHolder extends RecyclerView.ViewHolder { public SubmissionViewHolder(View v) { super(v); - title = (SpoilerRobotoTextView) v.findViewById(R.id.title); - info = (TextView) v.findViewById(R.id.information); + title = v.findViewById(R.id.title); + info = v.findViewById(R.id.information); hide = v.findViewById(R.id.hide); menu = v.findViewById(R.id.menu); mod = v.findViewById(R.id.mod); downvote = v.findViewById(R.id.downvote); upvote = v.findViewById(R.id.upvote); - leadImage = (HeaderImageLinkView) v.findViewById(R.id.headerimage); - contentTitle = (TextView) v.findViewById(R.id.contenttitle); + leadImage = v.findViewById(R.id.headerimage); + contentTitle = v.findViewById(R.id.contenttitle); secondMenu = v.findViewById(R.id.secondMenu); - flairText = (TextView) v.findViewById(R.id.text); + flairText = v.findViewById(R.id.text); thumbimage = v.findViewById(R.id.thumbimage2); - contentURL = (TextView) v.findViewById(R.id.contenturl); + contentURL = v.findViewById(R.id.contenturl); save = v.findViewById(R.id.save); edit = v.findViewById(R.id.edit); - body = (SpoilerRobotoTextView) v.findViewById(R.id.body); - score = (TextView) v.findViewById(R.id.score); - comments = (TextView) v.findViewById(R.id.comments); - firstTextView = (SpoilerRobotoTextView) v.findViewById(R.id.firstTextView); - commentOverflow = (CommentOverflow) v.findViewById(R.id.commentOverflow); - innerRelative = (RelativeLayout) v.findViewById(R.id.innerrelative); + body = v.findViewById(R.id.body); + score = v.findViewById(R.id.score); + comments = v.findViewById(R.id.comments); + firstTextView = v.findViewById(R.id.firstTextView); + commentOverflow = v.findViewById(R.id.commentOverflow); + innerRelative = v.findViewById(R.id.innerrelative); } } diff --git a/app/src/main/java/me/ccrama/redditslide/Adapters/SubredditAdapter.java b/app/src/main/java/me/ccrama/redditslide/Adapters/SubredditAdapter.java index 63d671b67c..a49ceb6ba2 100644 --- a/app/src/main/java/me/ccrama/redditslide/Adapters/SubredditAdapter.java +++ b/app/src/main/java/me/ccrama/redditslide/Adapters/SubredditAdapter.java @@ -7,6 +7,7 @@ import android.app.Activity; import android.content.Intent; import android.graphics.PorterDuff; +import android.graphics.PorterDuffColorFilter; import android.os.Handler; import android.view.LayoutInflater; import android.view.View; @@ -113,7 +114,8 @@ public void onBindViewHolder(final RecyclerView.ViewHolder holder2, final int po } holder.color.setBackgroundResource(R.drawable.circle); - holder.color.getBackground().setColorFilter(Palette.getColor(sub.getDisplayName().toLowerCase(Locale.ENGLISH)), PorterDuff.Mode.MULTIPLY); + holder.color.getBackground().setColorFilter(new PorterDuffColorFilter( + Palette.getColor(sub.getDisplayName().toLowerCase(Locale.ENGLISH)), PorterDuff.Mode.MULTIPLY)); holder.itemView.setOnClickListener(new OnSingleClickListener() { @Override public void onSingleClick(View view) { @@ -231,4 +233,4 @@ private void setViews(String rawHTML, String subredditName, SpoilerRobotoTextVie } } -} \ No newline at end of file +} diff --git a/app/src/main/java/me/ccrama/redditslide/Adapters/SubredditListingAdapter.java b/app/src/main/java/me/ccrama/redditslide/Adapters/SubredditListingAdapter.java index 0088ec7a42..d2ec79c546 100644 --- a/app/src/main/java/me/ccrama/redditslide/Adapters/SubredditListingAdapter.java +++ b/app/src/main/java/me/ccrama/redditslide/Adapters/SubredditListingAdapter.java @@ -2,6 +2,7 @@ import android.content.Context; import android.graphics.PorterDuff; +import android.graphics.PorterDuffColorFilter; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -36,11 +37,12 @@ public View getView(final int position, View convertView, ViewGroup parent) { convertView = LayoutInflater.from(getContext()).inflate(R.layout.subforsublist, parent, false); } final TextView t = - ((TextView) convertView.findViewById(R.id.name)); + convertView.findViewById(R.id.name); t.setText(fitems.get(position)); convertView.findViewById(R.id.color).setBackgroundResource(R.drawable.circle); - convertView.findViewById(R.id.color).getBackground().setColorFilter(Palette.getColor(fitems.get(position)), PorterDuff.Mode.MULTIPLY); + convertView.findViewById(R.id.color).getBackground().setColorFilter(new PorterDuffColorFilter( + Palette.getColor(fitems.get(position)), PorterDuff.Mode.MULTIPLY)); return convertView; } diff --git a/app/src/main/java/me/ccrama/redditslide/Adapters/SubredditPosts.java b/app/src/main/java/me/ccrama/redditslide/Adapters/SubredditPosts.java index 97f1cea517..7db761fe8f 100644 --- a/app/src/main/java/me/ccrama/redditslide/Adapters/SubredditPosts.java +++ b/app/src/main/java/me/ccrama/redditslide/Adapters/SubredditPosts.java @@ -3,12 +3,12 @@ import android.content.Context; import android.graphics.Bitmap; import android.os.AsyncTask; -import android.text.Html; import android.util.Log; import android.view.View; import android.widget.Toast; import androidx.appcompat.app.ActionBar; +import androidx.core.text.HtmlCompat; import com.nostra13.universalimageloader.core.assist.FailReason; import com.nostra13.universalimageloader.core.listener.ImageLoadingListener; @@ -34,6 +34,7 @@ import me.ccrama.redditslide.ContentType; import me.ccrama.redditslide.Fragments.SubmissionsView; import me.ccrama.redditslide.HasSeen; +import me.ccrama.redditslide.Hidden; import me.ccrama.redditslide.LastComments; import me.ccrama.redditslide.OfflineSubreddit; import me.ccrama.redditslide.PostLoader; @@ -109,19 +110,19 @@ public void loadPhotos(List submissions) { int length = submission.getThumbnails().getVariations().length; if (SettingValues.lqLow && length >= 3) { - url = Html.fromHtml( - submission.getThumbnails().getVariations()[2].getUrl()) + url = HtmlCompat.fromHtml( + submission.getThumbnails().getVariations()[2].getUrl(), HtmlCompat.FROM_HTML_MODE_LEGACY) .toString(); //unescape url characters } else if (SettingValues.lqMid && length >= 4) { - url = Html.fromHtml( - submission.getThumbnails().getVariations()[3].getUrl()) + url = HtmlCompat.fromHtml( + submission.getThumbnails().getVariations()[3].getUrl(), HtmlCompat.FROM_HTML_MODE_LEGACY) .toString(); //unescape url characters } else if (length >= 5) { - url = Html.fromHtml(submission.getThumbnails().getVariations()[ + url = HtmlCompat.fromHtml(submission.getThumbnails().getVariations()[ length - - 1].getUrl()).toString(); //unescape url characters + - 1].getUrl(), HtmlCompat.FROM_HTML_MODE_LEGACY).toString(); //unescape url characters } else { - url = Html.fromHtml(submission.getThumbnails().getSource().getUrl()) + url = HtmlCompat.fromHtml(submission.getThumbnails().getSource().getUrl(), HtmlCompat.FROM_HTML_MODE_LEGACY) .toString(); //unescape url characters } @@ -178,24 +179,24 @@ public void onLoadingCancelled(String imageUri, View view) { int length = submission.getThumbnails().getVariations().length; if (SettingValues.lqLow && length >= 3) { - url = Html.fromHtml( - submission.getThumbnails().getVariations()[2].getUrl()) + url = HtmlCompat.fromHtml( + submission.getThumbnails().getVariations()[2].getUrl(), HtmlCompat.FROM_HTML_MODE_LEGACY) .toString(); //unescape url characters } else if (SettingValues.lqMid && length >= 4) { - url = Html.fromHtml( - submission.getThumbnails().getVariations()[3].getUrl()) + url = HtmlCompat.fromHtml( + submission.getThumbnails().getVariations()[3].getUrl(), HtmlCompat.FROM_HTML_MODE_LEGACY) .toString(); //unescape url characters } else if (length >= 5) { - url = Html.fromHtml(submission.getThumbnails().getVariations()[ + url = HtmlCompat.fromHtml(submission.getThumbnails().getVariations()[ length - - 1].getUrl()).toString(); //unescape url characters + - 1].getUrl(), HtmlCompat.FROM_HTML_MODE_LEGACY).toString(); //unescape url characters } else { - url = Html.fromHtml(submission.getThumbnails().getSource().getUrl()) + url = HtmlCompat.fromHtml(submission.getThumbnails().getSource().getUrl(), HtmlCompat.FROM_HTML_MODE_LEGACY) .toString(); //unescape url characters } } else { - url = Html.fromHtml(submission.getThumbnails().getSource().getUrl()) + url = HtmlCompat.fromHtml(submission.getThumbnails().getSource().getUrl(), HtmlCompat.FROM_HTML_MODE_LEGACY) .toString(); //unescape url characters } @@ -400,6 +401,14 @@ public void onPostExecute(final List submissions) { @Override protected List doInBackground(String... subredditPaginators) { if (BuildConfig.DEBUG) LogUtil.v("Loading data"); + final AsyncTask hideTask = Hidden.asyncHideQueue(); + if (hideTask != null) { + try { + hideTask.get(); + } catch (Exception e) { + e.printStackTrace(); + } + } if ((!NetworkUtil.isConnected(context) && !Authentication.didOnline) || MainActivity.isRestart) { Log.v(LogUtil.getTag(), "Using offline data"); diff --git a/app/src/main/java/me/ccrama/redditslide/Adapters/SubredditPostsRealm.java b/app/src/main/java/me/ccrama/redditslide/Adapters/SubredditPostsRealm.java index 17845a7e6f..c7ddfc5a86 100644 --- a/app/src/main/java/me/ccrama/redditslide/Adapters/SubredditPostsRealm.java +++ b/app/src/main/java/me/ccrama/redditslide/Adapters/SubredditPostsRealm.java @@ -3,12 +3,12 @@ import android.content.Context; import android.graphics.Bitmap; import android.os.AsyncTask; -import android.text.Html; import android.util.Log; import android.view.View; import android.widget.Toast; import androidx.appcompat.app.ActionBar; +import androidx.core.text.HtmlCompat; import com.nostra13.universalimageloader.core.assist.FailReason; import com.nostra13.universalimageloader.core.listener.ImageLoadingListener; @@ -109,19 +109,19 @@ public void loadPhotos(List submissions) { int length = submission.getThumbnails().getVariations().length; if (SettingValues.lqLow && length >= 3) { - url = Html.fromHtml( - submission.getThumbnails().getVariations()[2].getUrl()) + url = HtmlCompat.fromHtml( + submission.getThumbnails().getVariations()[2].getUrl(), HtmlCompat.FROM_HTML_MODE_LEGACY) .toString(); //unescape url characters } else if (SettingValues.lqMid && length >= 4) { - url = Html.fromHtml( - submission.getThumbnails().getVariations()[3].getUrl()) + url = HtmlCompat.fromHtml( + submission.getThumbnails().getVariations()[3].getUrl(), HtmlCompat.FROM_HTML_MODE_LEGACY) .toString(); //unescape url characters } else if (length >= 5) { - url = Html.fromHtml(submission.getThumbnails().getVariations()[ + url = HtmlCompat.fromHtml(submission.getThumbnails().getVariations()[ length - - 1].getUrl()).toString(); //unescape url characters + - 1].getUrl(), HtmlCompat.FROM_HTML_MODE_LEGACY).toString(); //unescape url characters } else { - url = Html.fromHtml(submission.getThumbnails().getSource().getUrl()) + url = HtmlCompat.fromHtml(submission.getThumbnails().getSource().getUrl(), HtmlCompat.FROM_HTML_MODE_LEGACY) .toString(); //unescape url characters } @@ -178,24 +178,24 @@ public void onLoadingCancelled(String imageUri, View view) { int length = submission.getThumbnails().getVariations().length; if (SettingValues.lqLow && length >= 3) { - url = Html.fromHtml( - submission.getThumbnails().getVariations()[2].getUrl()) + url = HtmlCompat.fromHtml( + submission.getThumbnails().getVariations()[2].getUrl(), HtmlCompat.FROM_HTML_MODE_LEGACY) .toString(); //unescape url characters } else if (SettingValues.lqMid && length >= 4) { - url = Html.fromHtml( - submission.getThumbnails().getVariations()[3].getUrl()) + url = HtmlCompat.fromHtml( + submission.getThumbnails().getVariations()[3].getUrl(), HtmlCompat.FROM_HTML_MODE_LEGACY) .toString(); //unescape url characters } else if (length >= 5) { - url = Html.fromHtml(submission.getThumbnails().getVariations()[ + url = HtmlCompat.fromHtml(submission.getThumbnails().getVariations()[ length - - 1].getUrl()).toString(); //unescape url characters + - 1].getUrl(), HtmlCompat.FROM_HTML_MODE_LEGACY).toString(); //unescape url characters } else { - url = Html.fromHtml(submission.getThumbnails().getSource().getUrl()) + url = HtmlCompat.fromHtml(submission.getThumbnails().getSource().getUrl(), HtmlCompat.FROM_HTML_MODE_LEGACY) .toString(); //unescape url characters } } else { - url = Html.fromHtml(submission.getThumbnails().getSource().getUrl()) + url = HtmlCompat.fromHtml(submission.getThumbnails().getSource().getUrl(), HtmlCompat.FROM_HTML_MODE_LEGACY) .toString(); //unescape url characters } diff --git a/app/src/main/java/me/ccrama/redditslide/Adapters/SubredditViewHolder.java b/app/src/main/java/me/ccrama/redditslide/Adapters/SubredditViewHolder.java index 76bc240a80..381a365981 100644 --- a/app/src/main/java/me/ccrama/redditslide/Adapters/SubredditViewHolder.java +++ b/app/src/main/java/me/ccrama/redditslide/Adapters/SubredditViewHolder.java @@ -23,10 +23,10 @@ public class SubredditViewHolder extends RecyclerView.ViewHolder { public SubredditViewHolder(View v) { super(v); color = v.findViewById(R.id.color); - name = (TextView) v.findViewById(R.id.name); + name = v.findViewById(R.id.name); subscribers = v.findViewById(R.id.subscribers); subbed = v.findViewById(R.id.subbed); - body = (SpoilerRobotoTextView) v.findViewById(R.id.body); - overflow = (CommentOverflow) v.findViewById(R.id.overflow); + body = v.findViewById(R.id.body); + overflow = v.findViewById(R.id.overflow); } } diff --git a/app/src/main/java/me/ccrama/redditslide/Autocache/AutoCacheScheduler.java b/app/src/main/java/me/ccrama/redditslide/Autocache/AutoCacheScheduler.java index 0c77d50a07..b5a4eb2ea0 100644 --- a/app/src/main/java/me/ccrama/redditslide/Autocache/AutoCacheScheduler.java +++ b/app/src/main/java/me/ccrama/redditslide/Autocache/AutoCacheScheduler.java @@ -5,6 +5,8 @@ import android.content.Context; import android.content.Intent; +import androidx.core.content.ContextCompat; + import java.util.Calendar; import me.ccrama.redditslide.Reddit; @@ -25,7 +27,7 @@ public AutoCacheScheduler(Context context) { public void start(Context c) { - AlarmManager manager = (AlarmManager) c.getSystemService(Context.ALARM_SERVICE); + AlarmManager manager = ContextCompat.getSystemService(c, AlarmManager.class); Calendar cal = Calendar.getInstance(); cal.set(Calendar.HOUR_OF_DAY, Reddit.cachedData.getInt("hour", 0)); cal.set(Calendar.MINUTE, Reddit.cachedData.getInt("minute", 0)); @@ -33,14 +35,18 @@ public void start(Context c) { if(cal.getTimeInMillis() = 3) { - url = Html.fromHtml( - submission.getThumbnails().getVariations()[2].getUrl()) + url = HtmlCompat.fromHtml( + submission.getThumbnails().getVariations()[2].getUrl(), HtmlCompat.FROM_HTML_MODE_LEGACY) .toString(); //unescape url characters } else if (SettingValues.lqMid && length >= 4) { - url = Html.fromHtml( - submission.getThumbnails().getVariations()[3].getUrl()) + url = HtmlCompat.fromHtml( + submission.getThumbnails().getVariations()[3].getUrl(), HtmlCompat.FROM_HTML_MODE_LEGACY) .toString(); //unescape url characters } else if (length >= 5) { - url = Html.fromHtml( - submission.getThumbnails().getVariations()[length - 1].getUrl()) + url = HtmlCompat.fromHtml( + submission.getThumbnails().getVariations()[length - 1].getUrl(), HtmlCompat.FROM_HTML_MODE_LEGACY) .toString(); //unescape url characters } else { - url = Html.fromHtml( - submission.getThumbnails().getSource().getUrl()) + url = HtmlCompat.fromHtml( + submission.getThumbnails().getSource().getUrl(), HtmlCompat.FROM_HTML_MODE_LEGACY) .toString(); //unescape url characters } @@ -168,31 +169,31 @@ public void onLoadingCancelled(String imageUri, View view) { int length = submission.getThumbnails().getVariations().length; if (SettingValues.lqLow && length >= 3) { - url = Html.fromHtml( - submission.getThumbnails().getVariations()[2].getUrl()) + url = HtmlCompat.fromHtml( + submission.getThumbnails().getVariations()[2].getUrl(), HtmlCompat.FROM_HTML_MODE_LEGACY) .toString(); //unescape url characters } else if (SettingValues.lqMid && length >= 4) { - url = Html.fromHtml( - submission.getThumbnails().getVariations()[3].getUrl()) + url = HtmlCompat.fromHtml( + submission.getThumbnails().getVariations()[3].getUrl(), HtmlCompat.FROM_HTML_MODE_LEGACY) .toString(); //unescape url characters } else if (length >= 5) { - url = Html.fromHtml( - submission.getThumbnails().getVariations()[length - 1].getUrl()) + url = HtmlCompat.fromHtml( + submission.getThumbnails().getVariations()[length - 1].getUrl(), HtmlCompat.FROM_HTML_MODE_LEGACY) .toString(); //unescape url characters } else { - url = Html.fromHtml( - submission.getThumbnails().getSource().getUrl()) + url = HtmlCompat.fromHtml( + submission.getThumbnails().getSource().getUrl(), HtmlCompat.FROM_HTML_MODE_LEGACY) .toString(); //unescape url characters } } else { - url = Html.fromHtml(submission.getThumbnails().getSource().getUrl()) + url = HtmlCompat.fromHtml(submission.getThumbnails().getSource().getUrl(), HtmlCompat.FROM_HTML_MODE_LEGACY) .toString(); //unescape url characters } @@ -308,14 +309,13 @@ public Void doInBackground(Object[] params) { if (!sub.isEmpty()) { if (!sub.equals(SAVED_SUBMISSIONS)) { - mNotifyManager = (NotificationManager) context.getSystemService( - Context.NOTIFICATION_SERVICE); + mNotifyManager = ContextCompat.getSystemService(context, NotificationManager.class); mBuilder = new NotificationCompat.Builder(context, Reddit.CHANNEL_COMMENT_CACHE); mBuilder.setOngoing(true); mBuilder.setContentTitle(context.getString(R.string.offline_caching_title, sub.equalsIgnoreCase("frontpage") ? fSub : (fSub.contains("/m/") ? fSub : "/r/" + fSub))) - .setSmallIcon(R.drawable.save_png); + .setSmallIcon(R.drawable.save_content); } List submissions = new ArrayList<>(); ArrayList newFullnames = new ArrayList<>(); diff --git a/app/src/main/java/me/ccrama/redditslide/ContentType.java b/app/src/main/java/me/ccrama/redditslide/ContentType.java index 683dd35208..72f7fe8e70 100644 --- a/app/src/main/java/me/ccrama/redditslide/ContentType.java +++ b/app/src/main/java/me/ccrama/redditslide/ContentType.java @@ -131,6 +131,18 @@ public static boolean isImgurLink(String url) { } } + public static boolean isRedditGallery(String url) { + try { + final URI uri = new URI(url); + final String host = uri.getHost().toLowerCase(Locale.ENGLISH); + + return hostContains(host, "reddit.com", "redd.it") && url.contains("/gallery/"); + + } catch (URISyntaxException | NullPointerException e) { + return false; + } + } + /** * Attempt to determine the content type of a link from the URL * @@ -165,6 +177,10 @@ public static Type getContentType(String url) { } } + if (isRedditGallery(url)) { + return Type.REDDIT_GALLERY; + } + if (!scheme.equals("http") && !scheme.equals("https")) { return Type.EXTERNAL; } @@ -253,6 +269,7 @@ public static boolean displayImage(Type t) { switch (t) { case ALBUM: + case REDDIT_GALLERY: case DEVIANTART: case IMAGE: case XKCD: @@ -270,6 +287,7 @@ public static boolean fullImage(Type t) { switch (t) { case ALBUM: + case REDDIT_GALLERY: case DEVIANTART: case GIF: case IMAGE: @@ -298,6 +316,7 @@ public static boolean fullImage(Type t) { public static boolean mediaType(Type t) { switch (t) { case ALBUM: + case REDDIT_GALLERY: case DEVIANTART: case GIF: case IMAGE: @@ -329,6 +348,8 @@ public static int getContentID(Type contentType, boolean nsfw) { switch (contentType) { case ALBUM: return R.string.type_nsfw_album; + case REDDIT_GALLERY: + return R.string.type_nsfw_gallery; case EMBEDDED: return R.string.type_nsfw_emb; case EXTERNAL: @@ -351,6 +372,8 @@ public static int getContentID(Type contentType, boolean nsfw) { switch (contentType) { case ALBUM: return R.string.type_album; + case REDDIT_GALLERY: + return R.string.type_gallery; case XKCD: return R.string.type_xkcd; case DEVIANTART: @@ -463,6 +486,6 @@ public static boolean isImgurHash(String lqUrl) { } public enum Type { - ALBUM, DEVIANTART, EMBEDDED, EXTERNAL, GIF, VREDDIT_DIRECT, VREDDIT_REDIRECT, IMAGE, IMGUR, LINK, NONE, REDDIT, SELF, SPOILER, STREAMABLE, VIDEO, XKCD, TUMBLR + ALBUM, REDDIT_GALLERY, DEVIANTART, EMBEDDED, EXTERNAL, GIF, VREDDIT_DIRECT, VREDDIT_REDIRECT, IMAGE, IMGUR, LINK, NONE, REDDIT, SELF, SPOILER, STREAMABLE, VIDEO, XKCD, TUMBLR } } diff --git a/app/src/main/java/me/ccrama/redditslide/Drafts.java b/app/src/main/java/me/ccrama/redditslide/Drafts.java index 320fb0dde8..73404cd5a8 100644 --- a/app/src/main/java/me/ccrama/redditslide/Drafts.java +++ b/app/src/main/java/me/ccrama/redditslide/Drafts.java @@ -3,7 +3,6 @@ import android.content.SharedPreferences; import java.util.ArrayList; -import java.util.Arrays; /** diff --git a/app/src/main/java/me/ccrama/redditslide/DragSort/DragSortRecycler.java b/app/src/main/java/me/ccrama/redditslide/DragSort/DragSortRecycler.java index 5ed2c70b5d..5648353b42 100644 --- a/app/src/main/java/me/ccrama/redditslide/DragSort/DragSortRecycler.java +++ b/app/src/main/java/me/ccrama/redditslide/DragSort/DragSortRecycler.java @@ -141,7 +141,7 @@ public void getItemOffsets(Rect outRect, View view, RecyclerView rv, RecyclerVie view.setVisibility(View.VISIBLE); //Find middle of the floatingItem - float floatMiddleY = floatingItemBounds.top + floatingItemBounds.height() / 2; + float floatMiddleY = floatingItemBounds.top + floatingItemBounds.height() / 2.0f; //Moving down the list //These will auto-animate if the device continually sends touch motion events @@ -188,7 +188,7 @@ public void getItemOffsets(Rect outRect, View view, RecyclerView rv, RecyclerVie private int getNewPostion(RecyclerView rv) { int itemsOnScreen = rv.getLayoutManager().getChildCount(); - float floatMiddleY = floatingItemBounds.top + floatingItemBounds.height() / 2; + float floatMiddleY = floatingItemBounds.top + floatingItemBounds.height() / 2.0f; int above = 0; int below = Integer.MAX_VALUE; @@ -205,7 +205,7 @@ private int getNewPostion(RecyclerView rv) { if (itemPos == selectedDragItemPos) //Don't check against itself! continue; - float viewMiddleY = view.getTop() + view.getHeight() / 2; + float viewMiddleY = view.getTop() + view.getHeight() / 2.0f; if (floatMiddleY > viewMiddleY) //Is above this item { if (itemPos > above) diff --git a/app/src/main/java/me/ccrama/redditslide/DragSort/ReorderSubreddits.java b/app/src/main/java/me/ccrama/redditslide/DragSort/ReorderSubreddits.java index f023be513f..f1662dbfbd 100644 --- a/app/src/main/java/me/ccrama/redditslide/DragSort/ReorderSubreddits.java +++ b/app/src/main/java/me/ccrama/redditslide/DragSort/ReorderSubreddits.java @@ -22,6 +22,7 @@ import android.content.res.TypedArray; import android.graphics.Color; import android.graphics.PorterDuff; +import android.graphics.PorterDuffColorFilter; import android.graphics.drawable.Drawable; import android.os.AsyncTask; import android.os.Bundle; @@ -898,7 +899,7 @@ public void onCheckedChanged(CompoundButton buttonView, holder.itemView.findViewById(R.id.color).setBackgroundResource(R.drawable.circle); holder.itemView.findViewById(R.id.color) .getBackground() - .setColorFilter(Palette.getColor(origPos), PorterDuff.Mode.MULTIPLY); + .setColorFilter(new PorterDuffColorFilter(Palette.getColor(origPos), PorterDuff.Mode.MULTIPLY)); if (UserSubscriptions.getPinned().contains(origPos)) { holder.itemView.findViewById(R.id.pinned).setVisibility(View.VISIBLE); } else { @@ -1073,8 +1074,8 @@ public class ViewHolder extends RecyclerView.ViewHolder { public ViewHolder(View itemView) { super(itemView); - text = (TextView) itemView.findViewById(R.id.name); - check = (AppCompatCheckBox) itemView.findViewById(R.id.isSubscribed); + text = itemView.findViewById(R.id.name); + check = itemView.findViewById(R.id.isSubscribed); } } diff --git a/app/src/main/java/me/ccrama/redditslide/ForceTouch/PeekView.java b/app/src/main/java/me/ccrama/redditslide/ForceTouch/PeekView.java index 57d9a58157..2e3fd1c0e9 100644 --- a/app/src/main/java/me/ccrama/redditslide/ForceTouch/PeekView.java +++ b/app/src/main/java/me/ccrama/redditslide/ForceTouch/PeekView.java @@ -24,6 +24,7 @@ import androidx.annotation.Nullable; import java.util.HashMap; +import java.util.Map; import jp.wasabeef.blurry.Blurry; import me.ccrama.redditslide.ForceTouch.builder.PeekViewOptions; @@ -48,8 +49,6 @@ public class PeekView extends FrameLayout { public View content; private ViewGroup.LayoutParams contentParams; - private View dim; - private PeekViewOptions options; private int distanceFromTop; private int distanceFromLeft; @@ -138,12 +137,12 @@ public PeekView(Activity context, PeekViewOptions options, @NonNull View content HashMap buttons = new HashMap<>(); public void checkButtons(MotionEvent event) { - for (Integer i : buttons.keySet()) { - View v = content.findViewById(i); + for (Map.Entry entry : buttons.entrySet()) { + View v = content.findViewById(entry.getKey()); Rect outRect = new Rect(); v.getGlobalVisibleRect(outRect); if(outRect.contains((int) event.getX(), (int) event.getY())){ - buttons.get(i).onButtonUp(); + entry.getValue().onButtonUp(); } } } @@ -193,7 +192,7 @@ private void init(Activity context, PeekViewOptions options, @NonNull View conte } // add the background dim to the frame - dim = new View(context); + View dim = new View(context); dim.setBackgroundColor(Color.BLACK); dim.setAlpha(options.getBackgroundDim()); @@ -476,4 +475,4 @@ public void onAnimationRepeat(Animator animator) { } private enum Translation {HORIZONTAL, VERTICAL} -} \ No newline at end of file +} diff --git a/app/src/main/java/me/ccrama/redditslide/ForceTouch/builder/Peek.java b/app/src/main/java/me/ccrama/redditslide/ForceTouch/builder/Peek.java index f464326994..54ba78e691 100644 --- a/app/src/main/java/me/ccrama/redditslide/ForceTouch/builder/Peek.java +++ b/app/src/main/java/me/ccrama/redditslide/ForceTouch/builder/Peek.java @@ -23,11 +23,11 @@ import androidx.annotation.LayoutRes; import androidx.annotation.Nullable; +import androidx.core.view.GestureDetectorCompat; import me.ccrama.redditslide.ForceTouch.PeekView; import me.ccrama.redditslide.ForceTouch.PeekViewActivity; import me.ccrama.redditslide.ForceTouch.callback.OnPeek; -import me.ccrama.redditslide.ForceTouch.util.GestureDetectorCompat; import me.ccrama.redditslide.ForceTouch.util.GestureListener; /** diff --git a/app/src/main/java/me/ccrama/redditslide/ForceTouch/util/GestureDetectorCompat.java b/app/src/main/java/me/ccrama/redditslide/ForceTouch/util/GestureDetectorCompat.java deleted file mode 100644 index 301ef9550e..0000000000 --- a/app/src/main/java/me/ccrama/redditslide/ForceTouch/util/GestureDetectorCompat.java +++ /dev/null @@ -1,562 +0,0 @@ -package me.ccrama.redditslide.ForceTouch.util; - -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import android.content.Context; -import android.os.Build; -import android.os.Handler; -import android.os.Message; -import android.view.GestureDetector; -import android.view.GestureDetector.OnDoubleTapListener; -import android.view.GestureDetector.OnGestureListener; -import android.view.MotionEvent; -import android.view.VelocityTracker; -import android.view.View; -import android.view.ViewConfiguration; - -/** - * Detects various gestures and events using the supplied {@link MotionEvent}s. - * The {@link OnGestureListener} callback will notify users when a particular - * motion event has occurred. This class should only be used with {@link MotionEvent}s - * reported via touch (don't use for trackball events). - * - *

This compatibility implementation of the framework's GestureDetector guarantees - * the newer focal point scrolling behavior from Jellybean MR1 on all platform versions.

- * - * To use this class: - *
    - *
  • Create an instance of the {@code GestureDetectorCompat} for your {@link View} - *
  • In the {@link View#onTouchEvent(MotionEvent)} method ensure you call - * {@link #onTouchEvent(MotionEvent)}. The methods defined in your callback - * will be executed when the events occur. - *
- */ -public class GestureDetectorCompat { - interface GestureDetectorCompatImpl { - boolean isLongpressEnabled(); - boolean onTouchEvent(MotionEvent ev); - void setIsLongpressEnabled(boolean enabled); - void setOnDoubleTapListener(OnDoubleTapListener listener); - } - - static class GestureDetectorCompatImplBase implements GestureDetectorCompatImpl { - private int mTouchSlopSquare; - private int mDoubleTapSlopSquare; - private int mMinimumFlingVelocity; - private int mMaximumFlingVelocity; - - private static final int LONGPRESS_TIMEOUT = 100; - private static final int TAP_TIMEOUT = ViewConfiguration.getTapTimeout(); - private static final int DOUBLE_TAP_TIMEOUT = ViewConfiguration.getDoubleTapTimeout(); - - // constants for Message.what used by GestureHandler below - private static final int SHOW_PRESS = 1; - private static final int LONG_PRESS = 2; - private static final int TAP = 3; - - private final Handler mHandler; - private final OnGestureListener mListener; - private OnDoubleTapListener mDoubleTapListener; - - private boolean mStillDown; - private boolean mDeferConfirmSingleTap; - private boolean mInLongPress; - private boolean mAlwaysInTapRegion; - private boolean mAlwaysInBiggerTapRegion; - - private MotionEvent mCurrentDownEvent; - private MotionEvent mPreviousUpEvent; - - /** - * True when the user is still touching for the second tap (down, move, and - * up events). Can only be true if there is a double tap listener attached. - */ - private boolean mIsDoubleTapping; - - private float mLastFocusX; - private float mLastFocusY; - private float mDownFocusX; - private float mDownFocusY; - - private boolean mIsLongpressEnabled; - - /** - * Determines speed during touch scrolling - */ - private VelocityTracker mVelocityTracker; - - private class GestureHandler extends Handler { - GestureHandler() { - super(); - } - - GestureHandler(Handler handler) { - super(handler.getLooper()); - } - - @Override - public void handleMessage(Message msg) { - switch (msg.what) { - case SHOW_PRESS: - mListener.onShowPress(mCurrentDownEvent); - break; - - case LONG_PRESS: - dispatchLongPress(); - break; - - case TAP: - // If the user's finger is still down, do not count it as a tap - if (mDoubleTapListener != null) { - if (!mStillDown) { - mDoubleTapListener.onSingleTapConfirmed(mCurrentDownEvent); - } else { - mDeferConfirmSingleTap = true; - } - } - break; - - default: - throw new RuntimeException("Unknown message " + msg); //never - } - } - } - - /** - * Creates a GestureDetector with the supplied listener. - * You may only use this constructor from a UI thread (this is the usual situation). - * @see Handler#Handler() - * - * @param context the application's context - * @param listener the listener invoked for all the callbacks, this must - * not be null. - * @param handler the handler to use - * - * @throws NullPointerException if {@code listener} is null. - */ - public GestureDetectorCompatImplBase(Context context, OnGestureListener listener, - Handler handler) { - if (handler != null) { - mHandler = new GestureHandler(handler); - } else { - mHandler = new GestureHandler(); - } - mListener = listener; - if (listener instanceof OnDoubleTapListener) { - setOnDoubleTapListener((OnDoubleTapListener) listener); - } - init(context); - } - - private void init(Context context) { - if (context == null) { - throw new IllegalArgumentException("Context must not be null"); - } - if (mListener == null) { - throw new IllegalArgumentException("OnGestureListener must not be null"); - } - mIsLongpressEnabled = true; - - final ViewConfiguration configuration = ViewConfiguration.get(context); - final int touchSlop = configuration.getScaledTouchSlop(); - final int doubleTapSlop = configuration.getScaledDoubleTapSlop(); - mMinimumFlingVelocity = configuration.getScaledMinimumFlingVelocity(); - mMaximumFlingVelocity = configuration.getScaledMaximumFlingVelocity(); - - mTouchSlopSquare = touchSlop * touchSlop; - mDoubleTapSlopSquare = doubleTapSlop * doubleTapSlop; - } - - /** - * Sets the listener which will be called for double-tap and related - * gestures. - * - * @param onDoubleTapListener the listener invoked for all the callbacks, or - * null to stop listening for double-tap gestures. - */ - public void setOnDoubleTapListener(OnDoubleTapListener onDoubleTapListener) { - mDoubleTapListener = onDoubleTapListener; - } - - /** - * Set whether longpress is enabled, if this is enabled when a user - * presses and holds down you get a longpress event and nothing further. - * If it's disabled the user can press and hold down and then later - * moved their finger and you will get scroll events. By default - * longpress is enabled. - * - * @param isLongpressEnabled whether longpress should be enabled. - */ - public void setIsLongpressEnabled(boolean isLongpressEnabled) { - mIsLongpressEnabled = isLongpressEnabled; - } - - /** - * @return true if longpress is enabled, else false. - */ - public boolean isLongpressEnabled() { - return mIsLongpressEnabled; - } - - /** - * Analyzes the given motion event and if applicable triggers the - * appropriate callbacks on the {@link OnGestureListener} supplied. - * - * @param ev The current motion event. - * @return true if the {@link OnGestureListener} consumed the event, - * else false. - */ - public boolean onTouchEvent(MotionEvent ev) { - final int action = ev.getAction(); - - if (mVelocityTracker == null) { - mVelocityTracker = VelocityTracker.obtain(); - } - mVelocityTracker.addMovement(ev); - - final boolean pointerUp = - (action & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_POINTER_UP; - final int skipIndex = pointerUp ? ev.getActionIndex() : -1; - - // Determine focal point - float sumX = 0, sumY = 0; - final int count = ev.getPointerCount(); - for (int i = 0; i < count; i++) { - if (skipIndex == i) continue; - sumX += ev.getX(i); - sumY += ev.getY(i); - } - final int div = pointerUp ? count - 1 : count; - final float focusX = sumX / div; - final float focusY = sumY / div; - - boolean handled = false; - - switch (action & MotionEvent.ACTION_MASK) { - case MotionEvent.ACTION_POINTER_DOWN: - mDownFocusX = mLastFocusX = focusX; - mDownFocusY = mLastFocusY = focusY; - // Cancel long press and taps - cancelTaps(); - break; - - case MotionEvent.ACTION_POINTER_UP: - mDownFocusX = mLastFocusX = focusX; - mDownFocusY = mLastFocusY = focusY; - - // Check the dot product of current velocities. - // If the pointer that left was opposing another velocity vector, clear. - mVelocityTracker.computeCurrentVelocity(1000, mMaximumFlingVelocity); - final int upIndex = ev.getActionIndex(); - final int id1 = ev.getPointerId(upIndex); - final float x1 = mVelocityTracker.getXVelocity(id1); - final float y1 = mVelocityTracker.getYVelocity(id1); - for (int i = 0; i < count; i++) { - if (i == upIndex) continue; - - final int id2 = ev.getPointerId(i); - final float x = x1 * mVelocityTracker.getXVelocity(id2); - final float y = y1 * mVelocityTracker.getYVelocity(id2); - - final float dot = x + y; - if (dot < 0) { - mVelocityTracker.clear(); - break; - } - } - break; - - case MotionEvent.ACTION_DOWN: - if (mDoubleTapListener != null) { - boolean hadTapMessage = mHandler.hasMessages(TAP); - if (hadTapMessage) mHandler.removeMessages(TAP); - if ((mCurrentDownEvent != null) && (mPreviousUpEvent != null) && hadTapMessage && - isConsideredDoubleTap(mCurrentDownEvent, mPreviousUpEvent, ev)) { - // This is a second tap - mIsDoubleTapping = true; - // Give a callback with the first tap of the double-tap - handled |= mDoubleTapListener.onDoubleTap(mCurrentDownEvent); - // Give a callback with down event of the double-tap - handled |= mDoubleTapListener.onDoubleTapEvent(ev); - } else { - // This is a first tap - mHandler.sendEmptyMessageDelayed(TAP, DOUBLE_TAP_TIMEOUT); - } - } - - mDownFocusX = mLastFocusX = focusX; - mDownFocusY = mLastFocusY = focusY; - if (mCurrentDownEvent != null) { - mCurrentDownEvent.recycle(); - } - mCurrentDownEvent = MotionEvent.obtain(ev); - mAlwaysInTapRegion = true; - mAlwaysInBiggerTapRegion = true; - mStillDown = true; - mInLongPress = false; - mDeferConfirmSingleTap = false; - - if (mIsLongpressEnabled) { - mHandler.removeMessages(LONG_PRESS); - mHandler.sendEmptyMessageAtTime(LONG_PRESS, mCurrentDownEvent.getDownTime() - + TAP_TIMEOUT + LONGPRESS_TIMEOUT); - } - mHandler.sendEmptyMessageAtTime(SHOW_PRESS, mCurrentDownEvent.getDownTime() + TAP_TIMEOUT); - handled |= mListener.onDown(ev); - break; - - case MotionEvent.ACTION_MOVE: - if (mInLongPress) { - break; - } - final float scrollX = mLastFocusX - focusX; - final float scrollY = mLastFocusY - focusY; - if (mIsDoubleTapping) { - // Give the move events of the double-tap - handled |= mDoubleTapListener.onDoubleTapEvent(ev); - } else if (mAlwaysInTapRegion) { - final int deltaX = (int) (focusX - mDownFocusX); - final int deltaY = (int) (focusY - mDownFocusY); - int distance = (deltaX * deltaX) + (deltaY * deltaY); - if (distance > mTouchSlopSquare) { - handled = mListener.onScroll(mCurrentDownEvent, ev, scrollX, scrollY); - mLastFocusX = focusX; - mLastFocusY = focusY; - mAlwaysInTapRegion = false; - mHandler.removeMessages(TAP); - mHandler.removeMessages(SHOW_PRESS); - mHandler.removeMessages(LONG_PRESS); - } - if (distance > mTouchSlopSquare) { - mAlwaysInBiggerTapRegion = false; - } - } else if ((Math.abs(scrollX) >= 1) || (Math.abs(scrollY) >= 1)) { - handled = mListener.onScroll(mCurrentDownEvent, ev, scrollX, scrollY); - mLastFocusX = focusX; - mLastFocusY = focusY; - } - break; - - case MotionEvent.ACTION_UP: - mStillDown = false; - MotionEvent currentUpEvent = MotionEvent.obtain(ev); - if (mIsDoubleTapping) { - // Finally, give the up event of the double-tap - handled |= mDoubleTapListener.onDoubleTapEvent(ev); - } else if (mInLongPress) { - mHandler.removeMessages(TAP); - mInLongPress = false; - } else if (mAlwaysInTapRegion) { - handled = mListener.onSingleTapUp(ev); - if (mDeferConfirmSingleTap && mDoubleTapListener != null) { - mDoubleTapListener.onSingleTapConfirmed(ev); - } - } else { - // A fling must travel the minimum tap distance - final VelocityTracker velocityTracker = mVelocityTracker; - final int pointerId = ev.getPointerId(0); - velocityTracker.computeCurrentVelocity(1000, mMaximumFlingVelocity); - final float velocityY = velocityTracker.getYVelocity(pointerId); - final float velocityX = velocityTracker.getXVelocity(pointerId); - - if ((Math.abs(velocityY) > mMinimumFlingVelocity) - || (Math.abs(velocityX) > mMinimumFlingVelocity)){ - handled = mListener.onFling(mCurrentDownEvent, ev, velocityX, velocityY); - } - } - if (mPreviousUpEvent != null) { - mPreviousUpEvent.recycle(); - } - // Hold the event we obtained above - listeners may have changed the original. - mPreviousUpEvent = currentUpEvent; - if (mVelocityTracker != null) { - // This may have been cleared when we called out to the - // application above. - mVelocityTracker.recycle(); - mVelocityTracker = null; - } - mIsDoubleTapping = false; - mDeferConfirmSingleTap = false; - mHandler.removeMessages(SHOW_PRESS); - mHandler.removeMessages(LONG_PRESS); - break; - - case MotionEvent.ACTION_CANCEL: - cancel(); - break; - } - - return handled; - } - - private void cancel() { - mHandler.removeMessages(SHOW_PRESS); - mHandler.removeMessages(LONG_PRESS); - mHandler.removeMessages(TAP); - mVelocityTracker.recycle(); - mVelocityTracker = null; - mIsDoubleTapping = false; - mStillDown = false; - mAlwaysInTapRegion = false; - mAlwaysInBiggerTapRegion = false; - mDeferConfirmSingleTap = false; - if (mInLongPress) { - mInLongPress = false; - } - } - - private void cancelTaps() { - mHandler.removeMessages(SHOW_PRESS); - mHandler.removeMessages(LONG_PRESS); - mHandler.removeMessages(TAP); - mIsDoubleTapping = false; - mAlwaysInTapRegion = false; - mAlwaysInBiggerTapRegion = false; - mDeferConfirmSingleTap = false; - if (mInLongPress) { - mInLongPress = false; - } - } - - private boolean isConsideredDoubleTap(MotionEvent firstDown, MotionEvent firstUp, - MotionEvent secondDown) { - if (!mAlwaysInBiggerTapRegion) { - return false; - } - - if (secondDown.getEventTime() - firstUp.getEventTime() > DOUBLE_TAP_TIMEOUT) { - return false; - } - - int deltaX = (int) firstDown.getX() - (int) secondDown.getX(); - int deltaY = (int) firstDown.getY() - (int) secondDown.getY(); - return (deltaX * deltaX + deltaY * deltaY < mDoubleTapSlopSquare); - } - - private void dispatchLongPress() { - mHandler.removeMessages(TAP); - mDeferConfirmSingleTap = false; - mInLongPress = true; - mListener.onLongPress(mCurrentDownEvent); - } - } - - static class GestureDetectorCompatImplJellybeanMr2 implements GestureDetectorCompatImpl { - private final GestureDetector mDetector; - - public GestureDetectorCompatImplJellybeanMr2(Context context, OnGestureListener listener, - Handler handler) { - mDetector = new GestureDetector(context, listener, handler); - } - - @Override - public boolean isLongpressEnabled() { - return mDetector.isLongpressEnabled(); - } - - @Override - public boolean onTouchEvent(MotionEvent ev) { - return mDetector.onTouchEvent(ev); - } - - @Override - public void setIsLongpressEnabled(boolean enabled) { - mDetector.setIsLongpressEnabled(enabled); - } - - @Override - public void setOnDoubleTapListener(OnDoubleTapListener listener) { - mDetector.setOnDoubleTapListener(listener); - } - } - - private final GestureDetectorCompatImpl mImpl; - - /** - * Creates a GestureDetectorCompat with the supplied listener. - * As usual, you may only use this constructor from a UI thread. - * @see Handler#Handler() - * - * @param context the application's context - * @param listener the listener invoked for all the callbacks, this must - * not be null. - */ - public GestureDetectorCompat(Context context, OnGestureListener listener) { - this(context, listener, null); - } - - /** - * Creates a GestureDetectorCompat with the supplied listener. - * As usual, you may only use this constructor from a UI thread. - * @see Handler#Handler() - * - * @param context the application's context - * @param listener the listener invoked for all the callbacks, this must - * not be null. - * @param handler the handler that will be used for posting deferred messages - */ - public GestureDetectorCompat(Context context, OnGestureListener listener, Handler handler) { - if (Build.VERSION.SDK_INT > 17) { - mImpl = new GestureDetectorCompatImplJellybeanMr2(context, listener, handler); - } else { - mImpl = new GestureDetectorCompatImplBase(context, listener, handler); - } - } - - /** - * @return true if longpress is enabled, else false. - */ - public boolean isLongpressEnabled() { - return mImpl.isLongpressEnabled(); - } - - /** - * Analyzes the given motion event and if applicable triggers the - * appropriate callbacks on the {@link OnGestureListener} supplied. - * - * @param event The current motion event. - * @return true if the {@link OnGestureListener} consumed the event, - * else false. - */ - public boolean onTouchEvent(MotionEvent event) { - return mImpl.onTouchEvent(event); - } - - /** - * Set whether longpress is enabled, if this is enabled when a user - * presses and holds down you get a longpress event and nothing further. - * If it's disabled the user can press and hold down and then later - * moved their finger and you will get scroll events. By default - * longpress is enabled. - * - * @param enabled whether longpress should be enabled. - */ - public void setIsLongpressEnabled(boolean enabled) { - mImpl.setIsLongpressEnabled(enabled); - } - - /** - * Sets the listener which will be called for double-tap and related - * gestures. - * - * @param listener the listener invoked for all the callbacks, or - * null to stop listening for double-tap gestures. - */ - public void setOnDoubleTapListener(OnDoubleTapListener listener) { - mImpl.setOnDoubleTapListener(listener); - } -} \ No newline at end of file diff --git a/app/src/main/java/me/ccrama/redditslide/Fragments/AlbumFull.java b/app/src/main/java/me/ccrama/redditslide/Fragments/AlbumFull.java index c2276bccfb..3636dfade2 100644 --- a/app/src/main/java/me/ccrama/redditslide/Fragments/AlbumFull.java +++ b/app/src/main/java/me/ccrama/redditslide/Fragments/AlbumFull.java @@ -1,204 +1,204 @@ -package me.ccrama.redditslide.Fragments; - -import android.animation.ValueAnimator; -import android.app.Activity; -import android.content.Intent; -import android.os.AsyncTask; -import android.os.Bundle; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.view.ViewTreeObserver; - -import androidx.fragment.app.Fragment; -import androidx.recyclerview.widget.LinearLayoutManager; -import androidx.recyclerview.widget.RecyclerView; - -import com.sothree.slidinguppanel.SlidingUpPanelLayout; - -import net.dean.jraw.models.Submission; - -import org.jetbrains.annotations.NotNull; - -import java.util.List; - -import me.ccrama.redditslide.Activities.CommentsScreen; -import me.ccrama.redditslide.Activities.Shadowbox; -import me.ccrama.redditslide.Adapters.AlbumView; -import me.ccrama.redditslide.ImgurAlbum.AlbumUtils; -import me.ccrama.redditslide.ImgurAlbum.Image; -import me.ccrama.redditslide.R; -import me.ccrama.redditslide.SubmissionViews.PopulateShadowboxInfo; - - -/** - * Created by ccrama on 6/2/2015. - */ -public class AlbumFull extends Fragment { - - boolean gallery = false; - private View list; - private int i = 0; - private Submission s; - boolean hidden; - View rootView; - - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - rootView = inflater.inflate(R.layout.submission_albumcard, container, false); - PopulateShadowboxInfo.doActionbar(s, rootView, getActivity(), true); - - if (s.getUrl().contains("gallery")) { - gallery = true; - } - - list = rootView.findViewById(R.id.images); - - list.setVisibility(View.VISIBLE); - final LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity()); - layoutManager.setOrientation(LinearLayoutManager.VERTICAL); - ((RecyclerView) list).setLayoutManager(layoutManager); - - ((RecyclerView) list).addOnScrollListener(new RecyclerView.OnScrollListener() { - - @Override - public void onScrolled(RecyclerView recyclerView, int dx, int dy) { - super.onScrolled(recyclerView, dx, dy); - ValueAnimator va = null; - - if (dy > 0 && !hidden) { - hidden = true; - - if (va != null && va.isRunning()) va.cancel(); - - final View base = rootView.findViewById(R.id.base); - va = ValueAnimator.ofFloat(1.0f, 0.2f); - int mDuration = 250; //in millis - va.setDuration(mDuration); - va.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { - public void onAnimationUpdate(ValueAnimator animation) { - Float value = (Float) animation.getAnimatedValue(); - base.setAlpha(value); - } - }); - - va.start(); - - } else if (hidden && dy <= 0) { - final View base = rootView.findViewById(R.id.base); - - if (va != null && va.isRunning()) va.cancel(); - - hidden = false; - va = ValueAnimator.ofFloat(0.2f, 1.0f); - int mDuration = 250; //in millis - va.setDuration(mDuration); - va.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { - public void onAnimationUpdate(ValueAnimator animation) { - Float value = (Float) animation.getAnimatedValue(); - base.setAlpha(value); - } - }); - - va.start(); - } - } - - @Override - public void onScrollStateChanged(RecyclerView recyclerView, int newState) { - super.onScrollStateChanged(recyclerView, newState); - } - }); - - final View.OnClickListener openClick = new View.OnClickListener() { - @Override - public void onClick(View v) { - ((SlidingUpPanelLayout) rootView.findViewById(R.id.sliding_layout)).setPanelState( - SlidingUpPanelLayout.PanelState.EXPANDED); - } - }; - rootView.findViewById(R.id.base).setOnClickListener(openClick); - final View title = rootView.findViewById(R.id.title); - title.getViewTreeObserver() - .addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { - @Override - public void onGlobalLayout() { - ((SlidingUpPanelLayout) rootView.findViewById( - R.id.sliding_layout)).setPanelHeight(title.getMeasuredHeight()); - title.getViewTreeObserver().removeOnGlobalLayoutListener(this); - } - }); - ((SlidingUpPanelLayout) rootView.findViewById(R.id.sliding_layout)).addPanelSlideListener( - new SlidingUpPanelLayout.PanelSlideListener() { - @Override - public void onPanelSlide(View panel, float slideOffset) { - - } - - @Override - public void onPanelStateChanged(View panel, - SlidingUpPanelLayout.PanelState previousState, - SlidingUpPanelLayout.PanelState newState) { - if (newState == SlidingUpPanelLayout.PanelState.EXPANDED) { - rootView.findViewById(R.id.base) - .setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - Intent i2 = - new Intent(getActivity(), CommentsScreen.class); - i2.putExtra(CommentsScreen.EXTRA_PAGE, i); - i2.putExtra(CommentsScreen.EXTRA_SUBREDDIT, - ((Shadowbox) getActivity()).subreddit); - (getActivity()).startActivity(i2); - } - }); - } else { - rootView.findViewById(R.id.base).setOnClickListener(openClick); - } - } - }); - - new LoadIntoRecycler(s.getUrl(), getActivity()).executeOnExecutor( - AsyncTask.THREAD_POOL_EXECUTOR); - - return rootView; - } - - public class LoadIntoRecycler extends AlbumUtils.GetAlbumWithCallback { - - String url; - - public LoadIntoRecycler(@NotNull String url, @NotNull Activity baseActivity) { - super(url, baseActivity); - //todo htis dontClose = true; - this.url = url; - } - - @Override - public void doWithData(final List jsonElements) { - super.doWithData(jsonElements); - AlbumView adapter = new AlbumView(baseActivity, jsonElements, 0, - s.getSubredditName()); - ((RecyclerView) list).setAdapter(adapter); - } - - } - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - Bundle bundle = this.getArguments(); - i = bundle.getInt("page", 0); - if (((Shadowbox) getActivity()).subredditPosts == null - || ((Shadowbox) getActivity()).subredditPosts.getPosts().size() < bundle.getInt( - "page", 0)) { - getActivity().finish(); - } else { - s = ((Shadowbox) getActivity()).subredditPosts.getPosts().get(bundle.getInt("page", 0)); - } - } - - -} +package me.ccrama.redditslide.Fragments; + +import android.animation.ValueAnimator; +import android.app.Activity; +import android.content.Intent; +import android.os.AsyncTask; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.view.ViewTreeObserver; + +import androidx.fragment.app.Fragment; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import com.sothree.slidinguppanel.SlidingUpPanelLayout; + +import net.dean.jraw.models.Submission; + +import org.jetbrains.annotations.NotNull; + +import java.util.List; + +import me.ccrama.redditslide.Activities.CommentsScreen; +import me.ccrama.redditslide.Activities.Shadowbox; +import me.ccrama.redditslide.Adapters.AlbumView; +import me.ccrama.redditslide.ImgurAlbum.AlbumUtils; +import me.ccrama.redditslide.ImgurAlbum.Image; +import me.ccrama.redditslide.R; +import me.ccrama.redditslide.SubmissionViews.PopulateShadowboxInfo; + + +/** + * Created by ccrama on 6/2/2015. + */ +public class AlbumFull extends Fragment { + + boolean gallery = false; + private View list; + private int i = 0; + private Submission s; + boolean hidden; + View rootView; + + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + rootView = inflater.inflate(R.layout.submission_albumcard, container, false); + PopulateShadowboxInfo.doActionbar(s, rootView, getActivity(), true); + + if (s.getUrl().contains("gallery")) { + gallery = true; + } + + list = rootView.findViewById(R.id.images); + + list.setVisibility(View.VISIBLE); + final LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity()); + layoutManager.setOrientation(LinearLayoutManager.VERTICAL); + ((RecyclerView) list).setLayoutManager(layoutManager); + + ((RecyclerView) list).addOnScrollListener(new RecyclerView.OnScrollListener() { + + @Override + public void onScrolled(RecyclerView recyclerView, int dx, int dy) { + super.onScrolled(recyclerView, dx, dy); + ValueAnimator va = null; + + if (dy > 0 && !hidden) { + hidden = true; + + if (va != null && va.isRunning()) va.cancel(); + + final View base = rootView.findViewById(R.id.base); + va = ValueAnimator.ofFloat(1.0f, 0.2f); + int mDuration = 250; //in millis + va.setDuration(mDuration); + va.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { + public void onAnimationUpdate(ValueAnimator animation) { + Float value = (Float) animation.getAnimatedValue(); + base.setAlpha(value); + } + }); + + va.start(); + + } else if (hidden && dy <= 0) { + final View base = rootView.findViewById(R.id.base); + + if (va != null && va.isRunning()) va.cancel(); + + hidden = false; + va = ValueAnimator.ofFloat(0.2f, 1.0f); + int mDuration = 250; //in millis + va.setDuration(mDuration); + va.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { + public void onAnimationUpdate(ValueAnimator animation) { + Float value = (Float) animation.getAnimatedValue(); + base.setAlpha(value); + } + }); + + va.start(); + } + } + + @Override + public void onScrollStateChanged(RecyclerView recyclerView, int newState) { + super.onScrollStateChanged(recyclerView, newState); + } + }); + + final View.OnClickListener openClick = new View.OnClickListener() { + @Override + public void onClick(View v) { + ((SlidingUpPanelLayout) rootView.findViewById(R.id.sliding_layout)).setPanelState( + SlidingUpPanelLayout.PanelState.EXPANDED); + } + }; + rootView.findViewById(R.id.base).setOnClickListener(openClick); + final View title = rootView.findViewById(R.id.title); + title.getViewTreeObserver() + .addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { + @Override + public void onGlobalLayout() { + ((SlidingUpPanelLayout) rootView.findViewById( + R.id.sliding_layout)).setPanelHeight(title.getMeasuredHeight()); + title.getViewTreeObserver().removeOnGlobalLayoutListener(this); + } + }); + ((SlidingUpPanelLayout) rootView.findViewById(R.id.sliding_layout)).addPanelSlideListener( + new SlidingUpPanelLayout.PanelSlideListener() { + @Override + public void onPanelSlide(View panel, float slideOffset) { + + } + + @Override + public void onPanelStateChanged(View panel, + SlidingUpPanelLayout.PanelState previousState, + SlidingUpPanelLayout.PanelState newState) { + if (newState == SlidingUpPanelLayout.PanelState.EXPANDED) { + rootView.findViewById(R.id.base) + .setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Intent i2 = + new Intent(getActivity(), CommentsScreen.class); + i2.putExtra(CommentsScreen.EXTRA_PAGE, i); + i2.putExtra(CommentsScreen.EXTRA_SUBREDDIT, + ((Shadowbox) getActivity()).subreddit); + (getActivity()).startActivity(i2); + } + }); + } else { + rootView.findViewById(R.id.base).setOnClickListener(openClick); + } + } + }); + + new LoadIntoRecycler(s.getUrl(), getActivity()).executeOnExecutor( + AsyncTask.THREAD_POOL_EXECUTOR); + + return rootView; + } + + public class LoadIntoRecycler extends AlbumUtils.GetAlbumWithCallback { + + String url; + + public LoadIntoRecycler(@NotNull String url, @NotNull Activity baseActivity) { + super(url, baseActivity); + //todo htis dontClose = true; + this.url = url; + } + + @Override + public void doWithData(final List jsonElements) { + super.doWithData(jsonElements); + AlbumView adapter = new AlbumView(baseActivity, jsonElements, 0, + s.getSubredditName(), s.getTitle()); + ((RecyclerView) list).setAdapter(adapter); + } + + } + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + Bundle bundle = this.getArguments(); + i = bundle.getInt("page", 0); + if (((Shadowbox) getActivity()).subredditPosts == null + || ((Shadowbox) getActivity()).subredditPosts.getPosts().size() < bundle.getInt( + "page", 0)) { + getActivity().finish(); + } else { + s = ((Shadowbox) getActivity()).subredditPosts.getPosts().get(bundle.getInt("page", 0)); + } + } + + +} diff --git a/app/src/main/java/me/ccrama/redditslide/Fragments/AlbumFullComments.java b/app/src/main/java/me/ccrama/redditslide/Fragments/AlbumFullComments.java index ed28f46da1..8611814c05 100644 --- a/app/src/main/java/me/ccrama/redditslide/Fragments/AlbumFullComments.java +++ b/app/src/main/java/me/ccrama/redditslide/Fragments/AlbumFullComments.java @@ -38,7 +38,6 @@ public class AlbumFullComments extends Fragment { boolean gallery = false; private View list; - private int i = 0; private CommentUrlObject s; boolean hidden; View rootView; @@ -153,10 +152,7 @@ public void onClick(View v) { + c.getDataNode() .get("link_id") .asText() - .substring(3, c.getDataNode() - .get("link_id") - .asText() - .length()) + .substring(3) + "/nothing/" + c.getId() + "?context=3"; @@ -187,7 +183,9 @@ public LoadIntoRecycler(@NotNull String url, @NotNull Activity baseActivity) { @Override public void doWithData(final List jsonElements) { super.doWithData(jsonElements); - AlbumView adapter = new AlbumView(baseActivity, jsonElements, 0, s.getSubredditName()); + //May be a bug with downloading multiple comment albums off the same submission + AlbumView adapter = new AlbumView(baseActivity, jsonElements, 0, s.getSubredditName(), + s.comment.getComment().getSubmissionTitle()); ((RecyclerView) list).setAdapter(adapter); } @@ -197,8 +195,7 @@ public void doWithData(final List jsonElements) { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Bundle bundle = this.getArguments(); - i = bundle.getInt("page", 0); - s = ((ShadowboxComments) getActivity()).comments.get(i); + s = ShadowboxComments.comments.get(bundle.getInt("page", 0)); } diff --git a/app/src/main/java/me/ccrama/redditslide/Fragments/CommentPage.java b/app/src/main/java/me/ccrama/redditslide/Fragments/CommentPage.java index 2eb96d235e..1399700be2 100644 --- a/app/src/main/java/me/ccrama/redditslide/Fragments/CommentPage.java +++ b/app/src/main/java/me/ccrama/redditslide/Fragments/CommentPage.java @@ -10,9 +10,9 @@ import android.content.res.Resources; import android.graphics.Color; import android.graphics.PorterDuff; +import android.graphics.PorterDuffColorFilter; import android.net.Uri; import android.os.AsyncTask; -import android.os.Build; import android.os.Bundle; import android.text.Layout; import android.text.StaticLayout; @@ -119,6 +119,8 @@ import me.ccrama.redditslide.util.OnSingleClickListener; import me.ccrama.redditslide.util.SubmissionParser; +import static me.ccrama.redditslide.Notifications.ImageDownloadNotificationService.EXTRA_SUBMISSION_TITLE; + /** * Fragment which displays comment trees. * @@ -349,7 +351,7 @@ public void onClick(View v) { final int TINT = ContextCompat.getColor(getContext(), R.color.md_grey_600); e.setHintTextColor(TINT); - e.getBackground().setColorFilter(TINT, PorterDuff.Mode.SRC_IN); + e.getBackground().setColorFilter(new PorterDuffColorFilter(TINT, PorterDuff.Mode.SRC_IN)); } DoEditorActions.doActions(e, replyView, @@ -369,7 +371,7 @@ public void onClick(View v) { }); final TextView profile = replyView.findViewById(R.id.profile); final String[] changedProfile = {Authentication.name}; - profile.setText("/u/".concat(changedProfile[0])); + profile.setText("/u/" + changedProfile[0]); profile.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -394,7 +396,7 @@ public void onClick(View v) { public boolean onSelection(MaterialDialog dialog, View itemView, int which, CharSequence text) { changedProfile[0] = keys.get(which); - profile.setText("/u/".concat(changedProfile[0])); + profile.setText("/u/" + changedProfile[0]); return true; } }); @@ -462,11 +464,10 @@ public void onClick(View v) { @Override public void onClick(View v) { if (adapter != null && adapter.currentComments != null) { - int parentCount, opCount, linkCount, awardCount; - parentCount = 0; - opCount = 0; - linkCount = 0; - awardCount = 0; + int parentCount = 0; + int opCount = 0; + int linkCount = 0; + int awardCount = 0; String op = adapter.submission.getAuthor(); for (CommentObject o : adapter.currentComments) { if (o.comment != null && !(o instanceof MoreChildItem)) { @@ -887,6 +888,8 @@ public void onClick(DialogInterface dialog, myIntent.putExtra(MediaView.SUBREDDIT, subreddit); myIntent.putExtra(MediaView.EXTRA_URL, adapter.submission.getUrl()); + myIntent.putExtra(EXTRA_SUBMISSION_TITLE, + adapter.submission.getTitle()); getActivity().startActivity(myIntent); } else { @@ -897,6 +900,7 @@ public void onClick(DialogInterface dialog, case XKCD: Intent i2 = new Intent(getActivity(), MediaView.class); i2.putExtra(MediaView.SUBREDDIT, subreddit); + i2.putExtra(EXTRA_SUBMISSION_TITLE, adapter.submission.getTitle()); if (adapter.submission.getDataNode().has("preview") && adapter.submission.getDataNode() .get("preview") @@ -969,9 +973,9 @@ public void onClick(DialogInterface dialog, .get("selftext_html") .asText(), adapter.submission.getSubredditName(), - (SpoilerRobotoTextView) dialoglayout.findViewById( + dialoglayout.findViewById( R.id.firstTextView), - (CommentOverflow) dialoglayout.findViewById( + dialoglayout.findViewById( R.id.commentOverflow)); builder.setView(dialoglayout); builder.show(); @@ -985,11 +989,13 @@ public void onClick(DialogInterface dialog, i.putExtra(Album.EXTRA_URL, adapter.submission.getUrl()); i.putExtra(AlbumPager.SUBREDDIT, subreddit); + i.putExtra(EXTRA_SUBMISSION_TITLE, adapter.submission.getTitle()); } else { i = new Intent(getActivity(), Album.class); i.putExtra(Album.EXTRA_URL, adapter.submission.getUrl()); i.putExtra(Album.SUBREDDIT, subreddit); + i.putExtra(EXTRA_SUBMISSION_TITLE, adapter.submission.getTitle()); } getActivity().startActivity(i); getActivity().overridePendingTransition( @@ -1401,11 +1407,8 @@ public void onClick( { final TextView subscribe = sidebar.findViewById(R.id.subscribe); - currentlySubbed = (!Authentication.isLoggedIn - && UserSubscriptions.getSubscriptions(getActivity()) - .contains(baseSub.getDisplayName().toLowerCase(Locale.ENGLISH))) || ( - Authentication.isLoggedIn - && baseSub.isUserSubscriber()); + currentlySubbed = Authentication.isLoggedIn ? baseSub.isUserSubscriber() : UserSubscriptions.getSubscriptions(getActivity()) + .contains(baseSub.getDisplayName().toLowerCase(Locale.ENGLISH)); doSubscribeButtonText(currentlySubbed, subscribe); subscribe.setOnClickListener(new View.OnClickListener() { @@ -1656,8 +1659,8 @@ public void onClick( sidebar.findViewById(R.id.sub_title).setVisibility(View.VISIBLE); setViews(baseSub.getDataNode().get("public_description_html").asText(), baseSub.getDisplayName().toLowerCase(Locale.ENGLISH), - ((SpoilerRobotoTextView) sidebar.findViewById(R.id.sub_title)), - (CommentOverflow) sidebar.findViewById( + sidebar.findViewById(R.id.sub_title), + sidebar.findViewById( R.id.sub_title_overflow)); } else { sidebar.findViewById(R.id.sub_title).setVisibility(View.GONE); @@ -2341,17 +2344,11 @@ private int getTextViewMeasuredHeight(TextView tv){ //Since these text views takes the whole width of the screen, we get the width of the screen and subtract right and left padding to get the actual width of the text view int deviceWidth = getResources().getDisplayMetrics().widthPixels - tv.getPaddingLeft() - tv.getPaddingRight(); - float spacingMultiplier, spacingAddition; Layout.Alignment alignment = Layout.Alignment.ALIGN_CENTER; - if(Build.VERSION.SDK_INT >= 16) { - spacingMultiplier = tv.getLineSpacingMultiplier(); - spacingAddition = tv.getLineSpacingExtra(); - } else { - //Default values - spacingMultiplier = 1f; - spacingAddition = 0f; - } + float spacingMultiplier = tv.getLineSpacingMultiplier(); + float spacingAddition = tv.getLineSpacingExtra(); + StaticLayout staticLayout = new StaticLayout(tv.getText(),textPaint,deviceWidth,alignment,spacingMultiplier,spacingAddition,false); //Add top and bottom padding to the height and return the value diff --git a/app/src/main/java/me/ccrama/redditslide/Fragments/ContributionsView.java b/app/src/main/java/me/ccrama/redditslide/Fragments/ContributionsView.java index 0ccaec120e..c383113c31 100644 --- a/app/src/main/java/me/ccrama/redditslide/Fragments/ContributionsView.java +++ b/app/src/main/java/me/ccrama/redditslide/Fragments/ContributionsView.java @@ -5,7 +5,6 @@ import android.view.View; import android.view.ViewGroup; -import androidx.appcompat.widget.Toolbar; import androidx.fragment.app.Fragment; import androidx.recyclerview.widget.RecyclerView; import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; @@ -37,16 +36,15 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa View v = inflater.inflate(R.layout.fragment_verticalcontent, container, false); - final RecyclerView rv = ((RecyclerView) v.findViewById(R.id.vertical_content)); - final PreCachingLayoutManager mLayoutManager; + final RecyclerView rv = v.findViewById(R.id.vertical_content); - mLayoutManager = new PreCachingLayoutManager(getContext()); + final PreCachingLayoutManager mLayoutManager = new PreCachingLayoutManager(getContext()); rv.setLayoutManager(mLayoutManager); rv.setItemViewCacheSize(2); v.findViewById(R.id.post_floating_action_button).setVisibility(View.GONE); - final SwipeRefreshLayout mSwipeRefreshLayout = (SwipeRefreshLayout) v.findViewById(R.id.activity_main_swipe_refresh_layout); + final SwipeRefreshLayout mSwipeRefreshLayout = v.findViewById(R.id.activity_main_swipe_refresh_layout); mSwipeRefreshLayout.setColorSchemeColors(Palette.getColors(id, getActivity())); @@ -84,7 +82,7 @@ public void onRefresh() { } } ); - rv.addOnScrollListener(new ToolbarScrollHideHandler((Toolbar) getActivity().findViewById(R.id.toolbar), getActivity().findViewById(R.id.header)) { + rv.addOnScrollListener(new ToolbarScrollHideHandler(getActivity().findViewById(R.id.toolbar), getActivity().findViewById(R.id.header)) { @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); @@ -121,4 +119,4 @@ public void onCreate(Bundle savedInstanceState) { } -} \ No newline at end of file +} diff --git a/app/src/main/java/me/ccrama/redditslide/Fragments/HistoryView.java b/app/src/main/java/me/ccrama/redditslide/Fragments/HistoryView.java index 95f15ba501..d4968514d2 100644 --- a/app/src/main/java/me/ccrama/redditslide/Fragments/HistoryView.java +++ b/app/src/main/java/me/ccrama/redditslide/Fragments/HistoryView.java @@ -5,7 +5,6 @@ import android.view.View; import android.view.ViewGroup; -import androidx.appcompat.widget.Toolbar; import androidx.fragment.app.Fragment; import androidx.recyclerview.widget.RecyclerView; import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; @@ -33,16 +32,15 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa View v = inflater.inflate(R.layout.fragment_verticalcontent, container, false); - final RecyclerView rv = ((RecyclerView) v.findViewById(R.id.vertical_content)); - final PreCachingLayoutManager mLayoutManager; + final RecyclerView rv = v.findViewById(R.id.vertical_content); - mLayoutManager = new PreCachingLayoutManager(getContext()); + final PreCachingLayoutManager mLayoutManager = new PreCachingLayoutManager(getContext()); rv.setLayoutManager(mLayoutManager); rv.setItemViewCacheSize(2); v.findViewById(R.id.post_floating_action_button).setVisibility(View.GONE); - final SwipeRefreshLayout mSwipeRefreshLayout = (SwipeRefreshLayout) v.findViewById(R.id.activity_main_swipe_refresh_layout); + final SwipeRefreshLayout mSwipeRefreshLayout = v.findViewById(R.id.activity_main_swipe_refresh_layout); mSwipeRefreshLayout.setColorSchemeColors(Palette.getColors("default", getActivity())); @@ -76,7 +74,7 @@ public void onRefresh() { } } ); - rv.addOnScrollListener(new ToolbarScrollHideHandler((Toolbar) getActivity().findViewById(R.id.toolbar), getActivity().findViewById(R.id.header)) { + rv.addOnScrollListener(new ToolbarScrollHideHandler(getActivity().findViewById(R.id.toolbar), getActivity().findViewById(R.id.header)) { @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); @@ -109,4 +107,4 @@ public void onCreate(Bundle savedInstanceState) { } -} \ No newline at end of file +} diff --git a/app/src/main/java/me/ccrama/redditslide/Fragments/Image.java b/app/src/main/java/me/ccrama/redditslide/Fragments/Image.java index 429043aca5..f22582f86e 100644 --- a/app/src/main/java/me/ccrama/redditslide/Fragments/Image.java +++ b/app/src/main/java/me/ccrama/redditslide/Fragments/Image.java @@ -11,6 +11,7 @@ import com.davemorrissey.labs.subscaleview.ImageSource; import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView; +import com.davemorrissey.labs.subscaleview.decoder.CompatDecoderFactory; import com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListener; import me.ccrama.redditslide.R; @@ -30,9 +31,9 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, ViewGroup rootView = (ViewGroup) inflater.inflate( R.layout.submission_imagecard, container, false); - final SubsamplingScaleImageView image = (SubsamplingScaleImageView) rootView.findViewById(R.id.image); - TextView title = (TextView) rootView.findViewById(R.id.title); - TextView desc = (TextView) rootView.findViewById(R.id.desc); + final SubsamplingScaleImageView image = rootView.findViewById(R.id.image); + TextView title = rootView.findViewById(R.id.title); + TextView desc = rootView.findViewById(R.id.desc); title.setVisibility(View.GONE); desc.setVisibility(View.GONE); diff --git a/app/src/main/java/me/ccrama/redditslide/Fragments/InboxPage.java b/app/src/main/java/me/ccrama/redditslide/Fragments/InboxPage.java index 1e53805e1a..d1abbfd82b 100644 --- a/app/src/main/java/me/ccrama/redditslide/Fragments/InboxPage.java +++ b/app/src/main/java/me/ccrama/redditslide/Fragments/InboxPage.java @@ -5,7 +5,6 @@ import android.view.View; import android.view.ViewGroup; -import androidx.appcompat.widget.Toolbar; import androidx.fragment.app.Fragment; import androidx.recyclerview.widget.RecyclerView; import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; @@ -32,12 +31,11 @@ public class InboxPage extends Fragment { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.fragment_verticalcontent, container, false); - final RecyclerView rv = ((RecyclerView) v.findViewById(R.id.vertical_content)); - final PreCachingLayoutManager mLayoutManager; - mLayoutManager = new PreCachingLayoutManager(getActivity()); + final RecyclerView rv = v.findViewById(R.id.vertical_content); + final PreCachingLayoutManager mLayoutManager = new PreCachingLayoutManager(getActivity()); rv.setLayoutManager(mLayoutManager); - final SwipeRefreshLayout mSwipeRefreshLayout = (SwipeRefreshLayout) v.findViewById(R.id.activity_main_swipe_refresh_layout); + final SwipeRefreshLayout mSwipeRefreshLayout = v.findViewById(R.id.activity_main_swipe_refresh_layout); v.findViewById(R.id.post_floating_action_button).setVisibility(View.GONE); mSwipeRefreshLayout.setColorSchemeColors(Palette.getColors(id, getActivity())); @@ -71,7 +69,7 @@ public void onRefresh() { } } ); - rv.addOnScrollListener(new ToolbarScrollHideHandler((Toolbar) (getActivity()).findViewById(R.id.toolbar), getActivity().findViewById(R.id.header)) { + rv.addOnScrollListener(new ToolbarScrollHideHandler((getActivity()).findViewById(R.id.toolbar), getActivity().findViewById(R.id.header)) { @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); @@ -106,4 +104,4 @@ public void onCreate(Bundle savedInstanceState) { Bundle bundle = this.getArguments(); id = bundle.getString("id", ""); } -} \ No newline at end of file +} diff --git a/app/src/main/java/me/ccrama/redditslide/Fragments/ManageOfflineContentFragment.java b/app/src/main/java/me/ccrama/redditslide/Fragments/ManageOfflineContentFragment.java index d21a0d1ebc..147a2f4392 100644 --- a/app/src/main/java/me/ccrama/redditslide/Fragments/ManageOfflineContentFragment.java +++ b/app/src/main/java/me/ccrama/redditslide/Fragments/ManageOfflineContentFragment.java @@ -268,7 +268,7 @@ public void updateFilters() { final View t = context.getLayoutInflater().inflate( R.layout.account_textview, - ((LinearLayout) context.findViewById(R.id.manage_history_domainlist)), + context.findViewById(R.id.manage_history_domainlist), false); ((TextView) t.findViewById(R.id.name)).setText(name); diff --git a/app/src/main/java/me/ccrama/redditslide/Fragments/MediaFragment.java b/app/src/main/java/me/ccrama/redditslide/Fragments/MediaFragment.java index 0268b8b93b..6569b82fca 100644 --- a/app/src/main/java/me/ccrama/redditslide/Fragments/MediaFragment.java +++ b/app/src/main/java/me/ccrama/redditslide/Fragments/MediaFragment.java @@ -6,7 +6,6 @@ import android.graphics.Bitmap; import android.graphics.PointF; import android.os.AsyncTask; -import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.util.Log; @@ -21,6 +20,9 @@ import androidx.fragment.app.Fragment; import com.afollestad.materialdialogs.AlertDialogWrapper; +import com.davemorrissey.labs.subscaleview.decoder.CompatDecoderFactory; +import com.davemorrissey.labs.subscaleview.decoder.SkiaImageDecoder; +import com.fasterxml.jackson.databind.JsonNode; import com.google.common.base.Strings; import com.google.gson.Gson; import com.google.gson.JsonObject; @@ -40,12 +42,16 @@ import java.io.IOException; import java.net.URL; import java.net.URLConnection; +import java.util.ArrayList; import me.ccrama.redditslide.Activities.Album; import me.ccrama.redditslide.Activities.AlbumPager; import me.ccrama.redditslide.Activities.CommentsScreen; import me.ccrama.redditslide.Activities.FullscreenVideo; +import me.ccrama.redditslide.Activities.GalleryImage; import me.ccrama.redditslide.Activities.MediaView; +import me.ccrama.redditslide.Activities.RedditGallery; +import me.ccrama.redditslide.Activities.RedditGalleryPager; import me.ccrama.redditslide.Activities.Shadowbox; import me.ccrama.redditslide.Activities.Tumblr; import me.ccrama.redditslide.Activities.TumblrPager; @@ -68,6 +74,8 @@ import me.ccrama.redditslide.util.NetworkUtil; import okhttp3.OkHttpClient; +import static me.ccrama.redditslide.Notifications.ImageDownloadNotificationService.EXTRA_SUBMISSION_TITLE; + /** * Created by ccrama on 6/2/2015. @@ -145,12 +153,14 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, } PopulateShadowboxInfo.doActionbar(s, rootView, getActivity(), true); + View thumbnailView = (rootView.findViewById(R.id.thumbimage2)); - (rootView.findViewById(R.id.thumbimage2)).setVisibility(View.GONE); + thumbnailView.setVisibility(View.GONE); ImageView typeImage = rootView.findViewById(R.id.type); typeImage.setVisibility(View.VISIBLE); SubsamplingScaleImageView img = rootView.findViewById(R.id.submission_image); + final SlidingUpPanelLayout slideLayout = rootView.findViewById(R.id.sliding_layout); ContentType.Type type = ContentType.getContentType(s); @@ -166,26 +176,27 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, if (Strings.isNullOrEmpty(s.getThumbnail()) || Strings.isNullOrEmpty(firstUrl) || (s.isNsfw() && SettingValues.getIsNSFWEnabled())) { - (rootView.findViewById(R.id.thumbimage2)).setVisibility(View.VISIBLE); - ((ImageView) rootView.findViewById(R.id.thumbimage2)).setImageResource(R.drawable.web); - addClickFunctions((rootView.findViewById(R.id.thumbimage2)), slideLayout, rootView, + thumbnailView.setVisibility(View.VISIBLE); + ((ImageView) thumbnailView).setImageResource(R.drawable.web); + addClickFunctions(thumbnailView, slideLayout, rootView, + type, getActivity(), s); + addClickFunctions(typeImage, slideLayout, rootView, type, getActivity(), s); (rootView.findViewById(R.id.progress)).setVisibility(View.GONE); if ((s.isNsfw() && SettingValues.getIsNSFWEnabled())) { - ((ImageView) rootView.findViewById(R.id.thumbimage2)).setImageResource( + ((ImageView) thumbnailView).setImageResource( R.drawable.nsfw); } else { if (Strings.isNullOrEmpty(firstUrl) && !Strings.isNullOrEmpty(s.getThumbnail())) { ((Reddit) getContext().getApplicationContext()).getImageLoader() .displayImage(s.getThumbnail(), - ((ImageView) rootView.findViewById(R.id.thumbimage2))); + ((ImageView) thumbnailView)); } } } else { - - (rootView.findViewById(R.id.thumbimage2)).setVisibility(View.GONE); + thumbnailView.setVisibility(View.GONE); addClickFunctions(img, slideLayout, rootView, type, getActivity(), s); } @@ -201,6 +212,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, switch (type) { case ALBUM: + case REDDIT_GALLERY: typeImage.setImageResource(R.drawable.album); break; case EXTERNAL: @@ -210,7 +222,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, rootView.findViewById(R.id.submission_image).setAlpha(0.5f); break; case SELF: - typeImage.setImageResource(R.drawable.fontsizedarker); + typeImage.setImageResource(R.drawable.fontsize); break; case EMBEDDED: case VIDEO: @@ -248,9 +260,7 @@ public void onClick(View v) { @Override public void onGlobalLayout() { slideLayout.setPanelHeight(title.getMeasuredHeight()); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { - title.getViewTreeObserver().removeOnGlobalLayoutListener(this); - } + title.getViewTreeObserver().removeOnGlobalLayoutListener(this); } }); slideLayout.addPanelSlideListener(new SlidingUpPanelLayout.PanelSlideListener() { @@ -388,17 +398,62 @@ public void onClick(View v) { Intent i = new Intent(contextActivity, AlbumPager.class); i.putExtra(Album.EXTRA_URL, submission.getUrl()); i.putExtra(AlbumPager.SUBREDDIT, submission.getSubredditName()); + i.putExtra(EXTRA_SUBMISSION_TITLE, submission.getTitle()); contextActivity.startActivity(i); } else { Intent i = new Intent(contextActivity, Album.class); i.putExtra(Album.EXTRA_URL, submission.getUrl()); i.putExtra(Album.SUBREDDIT, submission.getSubredditName()); + i.putExtra(EXTRA_SUBMISSION_TITLE, submission.getTitle()); contextActivity.startActivity(i); } } else { LinkUtil.openExternally(submission.getUrl()); } break; + case REDDIT_GALLERY: + if (SettingValues.album) { + Intent i; + if (SettingValues.albumSwipe) { + i = new Intent(contextActivity, RedditGalleryPager.class); + i.putExtra(AlbumPager.SUBREDDIT, + submission.getSubredditName()); + i.putExtra(EXTRA_SUBMISSION_TITLE, submission.getTitle()); + } else { + i = new Intent(contextActivity, RedditGallery.class); + i.putExtra(Album.SUBREDDIT, + submission.getSubredditName()); + i.putExtra(EXTRA_SUBMISSION_TITLE, submission.getTitle()); + } + + i.putExtra(RedditGallery.SUBREDDIT, + submission.getSubredditName()); + + ArrayList urls = new ArrayList<>(); + + JsonNode dataNode = submission.getDataNode(); + if (dataNode.has("gallery_data")) { + for (JsonNode identifier : dataNode.get("gallery_data").get("items")) { + if (dataNode.has("media_metadata") && dataNode.get( + "media_metadata") + .has(identifier.get("media_id").asText())) { + urls.add(new GalleryImage(dataNode.get("media_metadata") + .get(identifier.get("media_id").asText()) + .get("s"))); + } + } + } + + Bundle urlsBundle = new Bundle(); + urlsBundle.putSerializable(RedditGallery.GALLERY_URLS, urls); + LogUtil.v("Opening gallery with " + urls.size()); + i.putExtras(urlsBundle); + + contextActivity.startActivity(i); + } else { + LinkUtil.openExternally(submission.getUrl()); + } + break; case TUMBLR: if (SettingValues.image) { if (SettingValues.albumSwipe) { @@ -567,11 +622,11 @@ public void doLoadImgur(String url) { url = url.substring(0, url.length() - 1); } final String finalUrl = url; - String hash = url.substring(url.lastIndexOf("/"), url.length()); + String hash = url.substring(url.lastIndexOf("/")); if (NetworkUtil.isConnected(getActivity())) { - if (hash.startsWith("/")) hash = hash.substring(1, hash.length()); + if (hash.startsWith("/")) hash = hash.substring(1); final String apiUrl = "https://imgur-apiv3.p.mashape.com/3/image/" + hash + ".json"; LogUtil.v(apiUrl); @@ -878,12 +933,10 @@ public void onCenterChanged(PointF newCenter, int origin) { .imageScaleType(ImageScaleType.NONE) .cacheInMemory(false) .build(), new ImageLoadingListener() { - private View mView; @Override public void onLoadingStarted(String imageUri, View view) { imageShown = true; - mView = view; } @Override diff --git a/app/src/main/java/me/ccrama/redditslide/Fragments/MediaFragmentComment.java b/app/src/main/java/me/ccrama/redditslide/Fragments/MediaFragmentComment.java index c3f451bfac..f40541fa68 100644 --- a/app/src/main/java/me/ccrama/redditslide/Fragments/MediaFragmentComment.java +++ b/app/src/main/java/me/ccrama/redditslide/Fragments/MediaFragmentComment.java @@ -20,6 +20,8 @@ import androidx.fragment.app.Fragment; import com.afollestad.materialdialogs.AlertDialogWrapper; +import com.davemorrissey.labs.subscaleview.decoder.CompatDecoderFactory; +import com.davemorrissey.labs.subscaleview.decoder.SkiaImageDecoder; import com.google.gson.Gson; import com.google.gson.JsonObject; import com.nostra13.universalimageloader.core.DisplayImageOptions; @@ -42,6 +44,7 @@ import me.ccrama.redditslide.Activities.Website; import me.ccrama.redditslide.Adapters.CommentUrlObject; import me.ccrama.redditslide.ContentType; +import me.ccrama.redditslide.Notifications.ImageDownloadNotificationService; import me.ccrama.redditslide.OpenRedditLink; import me.ccrama.redditslide.R; import me.ccrama.redditslide.Reddit; @@ -58,6 +61,8 @@ import me.ccrama.redditslide.util.NetworkUtil; import okhttp3.OkHttpClient; +import static me.ccrama.redditslide.Notifications.ImageDownloadNotificationService.EXTRA_SUBMISSION_TITLE; + /** * Created by ccrama on 6/2/2015. @@ -75,7 +80,6 @@ public class MediaFragmentComment extends Fragment { private boolean hidden; private long stopPosition; public boolean isGif; - private GifUtils.AsyncLoadGif gif; private CommentUrlObject s; private OkHttpClient client; private Gson gson; @@ -181,10 +185,7 @@ public void onClick(View v) { + c.getDataNode() .get("link_id") .asText() - .substring(3, c.getDataNode() - .get("link_id") - .asText() - .length()) + .substring(3) + "/nothing/" + c.getId() + "?context=3"; @@ -204,7 +205,7 @@ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Bundle bundle = this.getArguments(); i = bundle.getInt("page"); - s = ((ShadowboxComments) getActivity()).comments.get(i); + s = ShadowboxComments.comments.get(i); sub = s.comment.getComment().getSubredditName(); contentUrl = bundle.getString("contentUrl"); client = Reddit.client; @@ -305,11 +306,12 @@ public void onClick(View v) { if (type == ContentType.Type.IMAGE) { if (SettingValues.image) { Intent myIntent = new Intent(contextActivity, MediaView.class); - String url; - url = submission.getUrl(); + String url = submission.getUrl(); myIntent.putExtra(MediaView.EXTRA_DISPLAY_URL, submission.getUrl()); myIntent.putExtra(MediaView.EXTRA_URL, url); myIntent.putExtra(MediaView.SUBREDDIT, submission.getSubredditName()); + //May be a bug with downloading multiple comment albums off the same submission + myIntent.putExtra(EXTRA_SUBMISSION_TITLE, submission.comment.getComment().getSubmissionTitle()); myIntent.putExtra(MediaView.EXTRA_SHARE_URL, submission.getUrl()); contextActivity.startActivity(myIntent); @@ -331,7 +333,7 @@ public void doLoadGif(final String dat) { rootView.findViewById(R.id.submission_image).setVisibility(View.GONE); final ProgressBar loader = rootView.findViewById(R.id.gifprogress); rootView.findViewById(R.id.progress).setVisibility(View.GONE); - gif = new GifUtils.AsyncLoadGif(getActivity(), videoView, loader, + GifUtils.AsyncLoadGif gif = new GifUtils.AsyncLoadGif(getActivity(), videoView, loader, rootView.findViewById(R.id.placeholder), false, true, sub); gif.execute(dat); } @@ -372,11 +374,11 @@ public void doLoadImgur(String url) { url = url.substring(0, url.length() - 1); } final String finalUrl = url; - String hash = url.substring(url.lastIndexOf("/"), url.length()); + String hash = url.substring(url.lastIndexOf("/")); if (NetworkUtil.isConnected(getActivity())) { - if (hash.startsWith("/")) hash = hash.substring(1, hash.length()); + if (hash.startsWith("/")) hash = hash.substring(1); final String apiUrl = "https://imgur-apiv3.p.mashape.com/3/image/" + hash + ".json"; LogUtil.v(apiUrl); @@ -615,12 +617,10 @@ public void onCenterChanged(PointF newCenter, int origin) { .imageScaleType(ImageScaleType.NONE) .cacheInMemory(false) .build(), new ImageLoadingListener() { - private View mView; @Override public void onLoadingStarted(String imageUri, View view) { imageShown = true; - mView = view; } @Override diff --git a/app/src/main/java/me/ccrama/redditslide/Fragments/ModLog.java b/app/src/main/java/me/ccrama/redditslide/Fragments/ModLog.java index 6f2acb6108..fff48ac5d3 100644 --- a/app/src/main/java/me/ccrama/redditslide/Fragments/ModLog.java +++ b/app/src/main/java/me/ccrama/redditslide/Fragments/ModLog.java @@ -29,14 +29,13 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa View v = inflater.inflate(R.layout.fragment_verticalcontent, container, false); - RecyclerView rv = ((RecyclerView) v.findViewById(R.id.vertical_content)); - final PreCachingLayoutManager mLayoutManager; - mLayoutManager = new PreCachingLayoutManager(getActivity()); + RecyclerView rv = v.findViewById(R.id.vertical_content); + final PreCachingLayoutManager mLayoutManager = new PreCachingLayoutManager(getActivity()); rv.setLayoutManager(mLayoutManager); v.findViewById(R.id.post_floating_action_button).setVisibility(View.GONE); - final SwipeRefreshLayout mSwipeRefreshLayout = (SwipeRefreshLayout) v.findViewById(R.id.activity_main_swipe_refresh_layout); + final SwipeRefreshLayout mSwipeRefreshLayout = v.findViewById(R.id.activity_main_swipe_refresh_layout); mSwipeRefreshLayout.setColorSchemeColors(Palette.getColors("mod", getActivity())); @@ -77,4 +76,4 @@ public void onCreate(Bundle savedInstanceState) { } -} \ No newline at end of file +} diff --git a/app/src/main/java/me/ccrama/redditslide/Fragments/ModPage.java b/app/src/main/java/me/ccrama/redditslide/Fragments/ModPage.java index d0923b84a7..c424c27b4a 100644 --- a/app/src/main/java/me/ccrama/redditslide/Fragments/ModPage.java +++ b/app/src/main/java/me/ccrama/redditslide/Fragments/ModPage.java @@ -31,14 +31,13 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa View v = inflater.inflate(R.layout.fragment_verticalcontent, container, false); - RecyclerView rv = ((RecyclerView) v.findViewById(R.id.vertical_content)); - final PreCachingLayoutManager mLayoutManager; - mLayoutManager = new PreCachingLayoutManager(getActivity()); + RecyclerView rv = v.findViewById(R.id.vertical_content); + final PreCachingLayoutManager mLayoutManager = new PreCachingLayoutManager(getActivity()); rv.setLayoutManager(mLayoutManager); v.findViewById(R.id.post_floating_action_button).setVisibility(View.GONE); - final SwipeRefreshLayout mSwipeRefreshLayout = (SwipeRefreshLayout) v.findViewById(R.id.activity_main_swipe_refresh_layout); + final SwipeRefreshLayout mSwipeRefreshLayout = v.findViewById(R.id.activity_main_swipe_refresh_layout); mSwipeRefreshLayout.setColorSchemeColors(Palette.getColors(id, getActivity())); @@ -81,4 +80,4 @@ public void onCreate(Bundle savedInstanceState) { } -} \ No newline at end of file +} diff --git a/app/src/main/java/me/ccrama/redditslide/Fragments/MultiredditView.java b/app/src/main/java/me/ccrama/redditslide/Fragments/MultiredditView.java index e1e661e9f2..ae8555473e 100644 --- a/app/src/main/java/me/ccrama/redditslide/Fragments/MultiredditView.java +++ b/app/src/main/java/me/ccrama/redditslide/Fragments/MultiredditView.java @@ -13,7 +13,7 @@ import android.widget.TextView; import androidx.annotation.NonNull; -import androidx.appcompat.widget.Toolbar; +import androidx.core.view.MarginLayoutParamsCompat; import androidx.fragment.app.Fragment; import androidx.interpolator.view.animation.LinearOutSlowInInterpolator; import androidx.recyclerview.widget.RecyclerView; @@ -235,9 +235,7 @@ public void onClick(View v) { */ if (SettingValues.defaultCardView == CreateCardView.CardEnum.LIST) { RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { - params.setMarginStart(0); - } + MarginLayoutParamsCompat.setMarginStart(params, 0); rv.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY); refreshLayout.setLayoutParams(params); } @@ -289,7 +287,7 @@ public void onRefresh() { fab.show(); } - rv.addOnScrollListener(new ToolbarScrollHideHandler((Toolbar) (getActivity()).findViewById(R.id.toolbar), getActivity().findViewById(R.id.header)) { + rv.addOnScrollListener(new ToolbarScrollHideHandler((getActivity()).findViewById(R.id.toolbar), getActivity().findViewById(R.id.header)) { @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); @@ -297,13 +295,12 @@ public void onScrolled(RecyclerView recyclerView, int dx, int dy) { visibleItemCount = rv.getLayoutManager().getChildCount(); totalItemCount = rv.getLayoutManager().getItemCount(); - int[] firstVisibleItems; - firstVisibleItems = ((CatchStaggeredGridLayoutManager) rv.getLayoutManager()).findFirstVisibleItemPositions(null); + int[] firstVisibleItems = ((CatchStaggeredGridLayoutManager) rv.getLayoutManager()).findFirstVisibleItemPositions(null); if (firstVisibleItems != null && firstVisibleItems.length > 0) { for (int firstVisibleItem : firstVisibleItems) { pastVisiblesItems = firstVisibleItem; if (SettingValues.scrollSeen && pastVisiblesItems > 0 && SettingValues.storeHistory) { - HasSeen.addSeenScrolling(posts.posts.get(pastVisiblesItems - 1).getFullName()); + HasSeen.addSeenScrolling(posts.posts.get(pastVisiblesItems - 1)); } } } diff --git a/app/src/main/java/me/ccrama/redditslide/Fragments/NewsView.java b/app/src/main/java/me/ccrama/redditslide/Fragments/NewsView.java index ed6b3bab0b..ebc0059062 100644 --- a/app/src/main/java/me/ccrama/redditslide/Fragments/NewsView.java +++ b/app/src/main/java/me/ccrama/redditslide/Fragments/NewsView.java @@ -98,9 +98,8 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, final Context contextThemeWrapper = new ContextThemeWrapper(getActivity(), new ColorPreferences(inflater.getContext()).getThemeSubreddit(id)); - final View v = ((LayoutInflater) contextThemeWrapper.getSystemService( - Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.fragment_verticalcontent, - container, false); + final View v = LayoutInflater.from(contextThemeWrapper) + .inflate(R.layout.fragment_verticalcontent, container, false); if (getActivity() instanceof MainActivity) { v.findViewById(R.id.back).setBackgroundResource(0); @@ -109,8 +108,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, rv.setHasFixedSize(true); - final RecyclerView.LayoutManager mLayoutManager; - mLayoutManager = createLayoutManager( + final RecyclerView.LayoutManager mLayoutManager = createLayoutManager( getNumColumns(getResources().getConfiguration().orientation, getActivity())); if (!(getActivity() instanceof SubredditView)) { @@ -133,11 +131,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { - params.setMarginStart(0); - } else { - MarginLayoutParamsCompat.setMarginStart(params, 0); - } + MarginLayoutParamsCompat.setMarginStart(params, 0); rv.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY); mSwipeRefreshLayout.setLayoutParams(params); } @@ -210,7 +204,7 @@ public boolean onTouch(View v, MotionEvent event) { android.view.ViewConfiguration.getLongPressTimeout()); } if (((event.getAction() == MotionEvent.ACTION_MOVE) - && Math.abs(event.getY() - origY) > fab.getHeight() / 2) + && Math.abs(event.getY() - origY) > fab.getHeight() / 2.0f) || (event.getAction() == MotionEvent.ACTION_UP)) { handler.removeCallbacks(mLongPressRunnable); } @@ -349,12 +343,7 @@ public void run() { adapter.setHasStableIds(true); rv.setAdapter(adapter); posts.loadMore(getActivity(), this, true); - mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { - @Override - public void onRefresh() { - refresh(); - } - }); + mSwipeRefreshLayout.setOnRefreshListener(this::refresh); } public void doAdapter(boolean force18) { @@ -370,12 +359,7 @@ public void run() { adapter.setHasStableIds(true); rv.setAdapter(adapter); posts.loadMore(getActivity(), this, true); - mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { - @Override - public void onRefresh() { - refresh(); - } - }); + mSwipeRefreshLayout.setOnRefreshListener(this::refresh); } public List clearSeenPosts(boolean forever) { @@ -567,10 +551,8 @@ public void onScrolled(RecyclerView recyclerView, int dx, int dy) { visibleItemCount = rv.getLayoutManager().getChildCount(); totalItemCount = rv.getLayoutManager().getItemCount(); - int[] firstVisibleItems; - firstVisibleItems = - ((CatchStaggeredGridLayoutManager) rv.getLayoutManager()).findFirstVisibleItemPositions( - null); + int[] firstVisibleItems = ((CatchStaggeredGridLayoutManager) rv.getLayoutManager()).findFirstVisibleItemPositions( + null); if (firstVisibleItems != null && firstVisibleItems.length > 0) { for (int firstVisibleItem : firstVisibleItems) { pastVisiblesItems = firstVisibleItem; @@ -578,8 +560,7 @@ public void onScrolled(RecyclerView recyclerView, int dx, int dy) { && pastVisiblesItems > 0 && SettingValues.storeHistory) { HasSeen.addSeenScrolling( - posts.posts.get(pastVisiblesItems - 1) - .getFullName()); + posts.posts.get(pastVisiblesItems - 1)); } } } @@ -660,4 +641,4 @@ public static void currentPosition(int adapterPosition) { public static void currentSubmission(Submission current) { currentSubmission = current; } -} \ No newline at end of file +} diff --git a/app/src/main/java/me/ccrama/redditslide/Fragments/ReadLaterView.java b/app/src/main/java/me/ccrama/redditslide/Fragments/ReadLaterView.java index 68402e2a9a..ce60bab2d9 100644 --- a/app/src/main/java/me/ccrama/redditslide/Fragments/ReadLaterView.java +++ b/app/src/main/java/me/ccrama/redditslide/Fragments/ReadLaterView.java @@ -5,7 +5,6 @@ import android.view.View; import android.view.ViewGroup; -import androidx.appcompat.widget.Toolbar; import androidx.fragment.app.Fragment; import androidx.recyclerview.widget.RecyclerView; import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; @@ -32,14 +31,13 @@ public class ReadLaterView extends Fragment { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.fragment_verticalcontent, container, false); - final RecyclerView rv = ((RecyclerView) v.findViewById(R.id.vertical_content)); - final PreCachingLayoutManager mLayoutManager; + final RecyclerView rv = v.findViewById(R.id.vertical_content); - mLayoutManager = new PreCachingLayoutManager(getContext()); + final PreCachingLayoutManager mLayoutManager = new PreCachingLayoutManager(getContext()); rv.setLayoutManager(mLayoutManager); v.findViewById(R.id.post_floating_action_button).setVisibility(View.GONE); - final SwipeRefreshLayout mSwipeRefreshLayout = (SwipeRefreshLayout) v.findViewById(R.id.activity_main_swipe_refresh_layout); + final SwipeRefreshLayout mSwipeRefreshLayout = v.findViewById(R.id.activity_main_swipe_refresh_layout); mSwipeRefreshLayout.setColorSchemeColors(Palette.getColors("default", getActivity())); @@ -73,7 +71,7 @@ public void onRefresh() { } } ); - rv.addOnScrollListener(new ToolbarScrollHideHandler((Toolbar) getActivity().findViewById(R.id.toolbar), getActivity().findViewById(R.id.header)) { + rv.addOnScrollListener(new ToolbarScrollHideHandler(getActivity().findViewById(R.id.toolbar), getActivity().findViewById(R.id.header)) { @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); @@ -106,4 +104,4 @@ public void onCreate(Bundle savedInstanceState) { } -} \ No newline at end of file +} diff --git a/app/src/main/java/me/ccrama/redditslide/Fragments/SelftextFull.java b/app/src/main/java/me/ccrama/redditslide/Fragments/SelftextFull.java index b41d5836a3..a909f34893 100644 --- a/app/src/main/java/me/ccrama/redditslide/Fragments/SelftextFull.java +++ b/app/src/main/java/me/ccrama/redditslide/Fragments/SelftextFull.java @@ -88,7 +88,7 @@ private void setViews(String rawHTML, String subredditName, View base) { startIndex = 1; } - CommentOverflow overflow = (CommentOverflow) base.findViewById(R.id.commentOverflow); + CommentOverflow overflow = base.findViewById(R.id.commentOverflow); if (blocks.size() > 1) { if (startIndex == 0) { overflow.setViews(blocks, subredditName); diff --git a/app/src/main/java/me/ccrama/redditslide/Fragments/SettingsCommentsFragment.java b/app/src/main/java/me/ccrama/redditslide/Fragments/SettingsCommentsFragment.java index 4602418f11..69da79e6d9 100644 --- a/app/src/main/java/me/ccrama/redditslide/Fragments/SettingsCommentsFragment.java +++ b/app/src/main/java/me/ccrama/redditslide/Fragments/SettingsCommentsFragment.java @@ -127,6 +127,17 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { } }); } + { + SwitchCompat single = context.findViewById(R.id.settings_comments_hide_awards); + single.setChecked(SettingValues.hideCommentAwards); + single.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + SettingValues.hideCommentAwards = isChecked; + SettingValues.prefs.edit().putBoolean(SettingValues.PREF_HIDE_COMMENT_AWARDS, isChecked).apply(); + } + }); + } { SwitchCompat single = context.findViewById(R.id.settings_comments_autohidenav); single.setChecked(SettingValues.commentAutoHide); @@ -219,6 +230,17 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { } }); } + { + SwitchCompat single = context.findViewById(R.id.settings_comments_collapse_deleted); + single.setChecked(SettingValues.collapseDeletedComments); + single.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + SettingValues.collapseDeletedComments = isChecked; + SettingValues.prefs.edit().putBoolean(SettingValues.PREF_COLLAPSE_DELETED_COMMENTS, isChecked).apply(); + } + }); + } } } diff --git a/app/src/main/java/me/ccrama/redditslide/Fragments/SettingsFontFragment.java b/app/src/main/java/me/ccrama/redditslide/Fragments/SettingsFontFragment.java index 044e92b32f..18008d3182 100644 --- a/app/src/main/java/me/ccrama/redditslide/Fragments/SettingsFontFragment.java +++ b/app/src/main/java/me/ccrama/redditslide/Fragments/SettingsFontFragment.java @@ -44,7 +44,7 @@ public SettingsFontFragment(Activity context) { } public void Bind() { - final TextView colorComment = (TextView) context.findViewById(R.id.settings_font_commentFont); + final TextView colorComment = context.findViewById(R.id.settings_font_commentFont); colorComment.setText(new FontPreferences(context).getCommentFontStyle().getTitle()); context.findViewById(R.id.settings_font_commentfontsize).setOnClickListener(new View.OnClickListener() { @Override @@ -72,7 +72,7 @@ public boolean onMenuItemClick(MenuItem item) { popup.show(); } }); - final TextView colorPost = (TextView) context.findViewById(R.id.settings_font_postFont); + final TextView colorPost = context.findViewById(R.id.settings_font_postFont); colorPost.setText(new FontPreferences(context).getPostFontStyle().getTitle()); context.findViewById(R.id.settings_font_postfontsize).setOnClickListener(new View.OnClickListener() { @Override @@ -304,7 +304,7 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { }); { - SwitchCompat single = (SwitchCompat) context.findViewById(R.id.settings_font_linktype); + SwitchCompat single = context.findViewById(R.id.settings_font_linktype); single.setChecked(SettingValues.typeInText); single.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override @@ -315,7 +315,7 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { }); } { - SwitchCompat single = (SwitchCompat) context.findViewById(R.id.settings_font_enlarge_links); + SwitchCompat single = context.findViewById(R.id.settings_font_enlarge_links); single.setChecked(SettingValues.largeLinks); single.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override diff --git a/app/src/main/java/me/ccrama/redditslide/Fragments/SettingsGeneralFragment.java b/app/src/main/java/me/ccrama/redditslide/Fragments/SettingsGeneralFragment.java index ce67837280..98423f75bd 100644 --- a/app/src/main/java/me/ccrama/redditslide/Fragments/SettingsGeneralFragment.java +++ b/app/src/main/java/me/ccrama/redditslide/Fragments/SettingsGeneralFragment.java @@ -44,6 +44,7 @@ import me.ccrama.redditslide.CaseInsensitiveArrayList; import me.ccrama.redditslide.Constants; import me.ccrama.redditslide.Fragments.FolderChooserDialogCreate.FolderCallback; +import me.ccrama.redditslide.ImageLoaderUtils; import me.ccrama.redditslide.Notifications.CheckForMail; import me.ccrama.redditslide.Notifications.NotificationJobScheduler; import me.ccrama.redditslide.R; @@ -90,7 +91,7 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { checkBox.setText(context.getString(R.string.settings_mail_check)); } else { checkBox.setChecked(true); - landscape.setValue(Reddit.notificationTime / 15, false); + landscape.setValue(Reddit.notificationTime / 15.0f, false); checkBox.setText(context.getString(R.string.settings_notification_newline, TimeUtils.getTimeInHoursAndMins(Reddit.notificationTime, context.getBaseContext()))); @@ -221,6 +222,28 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { }); } } + { + SwitchCompat single = context.findViewById(R.id.settings_general_high_colorspace); + + if (single != null) { + single.setChecked(SettingValues.highColorspaceImages); + single.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + SettingsThemeFragment.changed = true; + SettingValues.highColorspaceImages = isChecked; + + Reddit application = (Reddit) context.getApplication(); + ImageLoaderUtils.initImageLoader(application.getApplicationContext()); + application.defaultImageLoader = ImageLoaderUtils.imageLoader; + + SettingValues.prefs.edit() + .putBoolean(SettingValues.PREF_HIGH_COLORSPACE_IMAGES, isChecked) + .apply(); + } + }); + } + } { SwitchCompat single = context.findViewById(R.id.settings_general_forcelanguage); diff --git a/app/src/main/java/me/ccrama/redditslide/Fragments/SettingsHistoryFragment.java b/app/src/main/java/me/ccrama/redditslide/Fragments/SettingsHistoryFragment.java index a8beb22566..265724f53b 100644 --- a/app/src/main/java/me/ccrama/redditslide/Fragments/SettingsHistoryFragment.java +++ b/app/src/main/java/me/ccrama/redditslide/Fragments/SettingsHistoryFragment.java @@ -23,7 +23,7 @@ public SettingsHistoryFragment(Activity context) { public void Bind() { { - SwitchCompat storeHistory = ((SwitchCompat) context.findViewById(R.id.settings_history_storehistory)); + SwitchCompat storeHistory = context.findViewById(R.id.settings_history_storehistory); storeHistory.setChecked(SettingValues.storeHistory); storeHistory.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override @@ -33,17 +33,23 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { context.findViewById(R.id.settings_history_scrollseen).setEnabled(true); + context.findViewById(R.id.settings_history_scrollseenhide).setEnabled(true); context.findViewById(R.id.settings_history_storensfw).setEnabled(true); } else { ((SwitchCompat) context.findViewById(R.id.settings_history_storensfw)).setChecked(false); - ((SwitchCompat) context.findViewById(R.id.settings_history_storensfw)).setEnabled(false); + context.findViewById(R.id.settings_history_storensfw).setEnabled(false); SettingValues.storeNSFWHistory = false; SettingValues.prefs.edit().putBoolean(SettingValues.PREF_STORE_NSFW_HISTORY, false).apply(); ((SwitchCompat) context.findViewById(R.id.settings_history_scrollseen)).setChecked(false); - ((SwitchCompat) context.findViewById(R.id.settings_history_scrollseen)).setEnabled(false); + context.findViewById(R.id.settings_history_scrollseen).setEnabled(false); SettingValues.scrollSeen = false; SettingValues.prefs.edit().putBoolean(SettingValues.PREF_SCROLL_SEEN, false).apply(); + + ((SwitchCompat) context.findViewById(R.id.settings_history_scrollseenhide)).setChecked(false); + ((SwitchCompat) context.findViewById(R.id.settings_history_scrollseenhide)).setEnabled(false); + SettingValues.scrollSeenHide = false; + SettingValues.prefs.edit().putBoolean(SettingValues.PREF_SCROLL_SEEN_HIDE, false).apply(); } } }); @@ -65,7 +71,7 @@ public void onClick(View v) { } }); { - SwitchCompat nsfw = ((SwitchCompat) context.findViewById(R.id.settings_history_storensfw)); + SwitchCompat nsfw = context.findViewById(R.id.settings_history_storensfw); nsfw.setChecked(SettingValues.storeNSFWHistory); nsfw.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override @@ -77,7 +83,7 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { } { - SwitchCompat single = (SwitchCompat) context.findViewById(R.id.settings_history_scrollseen); + SwitchCompat single = context.findViewById(R.id.settings_history_scrollseen); single.setChecked(SettingValues.scrollSeen); single.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override @@ -88,6 +94,19 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { } }); } + + { + SwitchCompat single = (SwitchCompat) context.findViewById(R.id.settings_history_scrollseenhide); + single.setChecked(SettingValues.scrollSeenHide); + single.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + SettingValues.scrollSeenHide = isChecked; + SettingValues.prefs.edit().putBoolean(SettingValues.PREF_SCROLL_SEEN_HIDE, isChecked).apply(); + + } + }); + } } } diff --git a/app/src/main/java/me/ccrama/redditslide/Fragments/SettingsThemeFragment.java b/app/src/main/java/me/ccrama/redditslide/Fragments/SettingsThemeFragment.java index 458a72283c..32f5cd124d 100644 --- a/app/src/main/java/me/ccrama/redditslide/Fragments/SettingsThemeFragment.java +++ b/app/src/main/java/me/ccrama/redditslide/Fragments/SettingsThemeFragment.java @@ -474,7 +474,7 @@ public void onCheckedChanged(CompoundButton buttonView, //set the currently selected pref startSpinner.setSelection(startAdapter.getPosition( - Integer.toString(SettingValues.nightStart).concat("pm"))); + SettingValues.nightStart + "pm")); startSpinner.setOnItemSelectedListener( new AdapterView.OnItemSelectedListener() { @@ -522,7 +522,7 @@ public void onNothingSelected(AdapterView parent) { //set the currently selected pref endSpinner.setSelection(endAdapter.getPosition( - Integer.toString(SettingValues.nightEnd).concat("am"))); + SettingValues.nightEnd + "am")); endSpinner.setOnItemSelectedListener( new AdapterView.OnItemSelectedListener() { diff --git a/app/src/main/java/me/ccrama/redditslide/Fragments/SubmissionsView.java b/app/src/main/java/me/ccrama/redditslide/Fragments/SubmissionsView.java index 2e5f3a901b..3d58274b37 100644 --- a/app/src/main/java/me/ccrama/redditslide/Fragments/SubmissionsView.java +++ b/app/src/main/java/me/ccrama/redditslide/Fragments/SubmissionsView.java @@ -100,9 +100,8 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, final Context contextThemeWrapper = new ContextThemeWrapper(getActivity(), new ColorPreferences(inflater.getContext()).getThemeSubreddit(id)); - final View v = ((LayoutInflater) contextThemeWrapper.getSystemService( - Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.fragment_verticalcontent, - container, false); + final View v = LayoutInflater.from(contextThemeWrapper) + .inflate(R.layout.fragment_verticalcontent, container, false); if (getActivity() instanceof MainActivity) { v.findViewById(R.id.back).setBackgroundResource(0); @@ -111,8 +110,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, rv.setHasFixedSize(true); - final RecyclerView.LayoutManager mLayoutManager; - mLayoutManager = + final RecyclerView.LayoutManager mLayoutManager = createLayoutManager(getNumColumns(getResources().getConfiguration().orientation, getActivity())); if (!(getActivity() instanceof SubredditView)) { @@ -135,11 +133,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { - params.setMarginStart(0); - } else { - MarginLayoutParamsCompat.setMarginStart(params, 0); - } + MarginLayoutParamsCompat.setMarginStart(params, 0); rv.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY); mSwipeRefreshLayout.setLayoutParams(params); } @@ -275,7 +269,7 @@ public boolean onTouch(View v, MotionEvent event) { origY = event.getY(); handler.postDelayed(mLongPressRunnable, android.view.ViewConfiguration.getLongPressTimeout()); } - if (((event.getAction() == MotionEvent.ACTION_MOVE) && Math.abs(event.getY() - origY) > fab.getHeight()/2)|| (event.getAction() == MotionEvent.ACTION_UP)) { + if (((event.getAction() == MotionEvent.ACTION_MOVE) && Math.abs(event.getY() - origY) > fab.getHeight()/2.0f)|| (event.getAction() == MotionEvent.ACTION_UP)) { handler.removeCallbacks(mLongPressRunnable); } return false; @@ -410,12 +404,7 @@ public void run() { adapter.setHasStableIds(true); rv.setAdapter(adapter); posts.loadMore(getActivity(), this, true); - mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { - @Override - public void onRefresh() { - refresh(); - } - }); + mSwipeRefreshLayout.setOnRefreshListener(this::refresh); } public void doAdapter(boolean force18) { @@ -431,12 +420,7 @@ public void run() { adapter.setHasStableIds(true); rv.setAdapter(adapter); posts.loadMore(getActivity(), this, true); - mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { - @Override - public void onRefresh() { - refresh(); - } - }); + mSwipeRefreshLayout.setOnRefreshListener(this::refresh); } public List clearSeenPosts(boolean forever) { @@ -624,8 +608,7 @@ public void onScrolled(RecyclerView recyclerView, int dx, int dy) { visibleItemCount = rv.getLayoutManager().getChildCount(); totalItemCount = rv.getLayoutManager().getItemCount(); - int[] firstVisibleItems; - firstVisibleItems = + int[] firstVisibleItems = ((CatchStaggeredGridLayoutManager) rv.getLayoutManager()).findFirstVisibleItemPositions( null); if (firstVisibleItems != null && firstVisibleItems.length > 0) { @@ -634,8 +617,7 @@ public void onScrolled(RecyclerView recyclerView, int dx, int dy) { if (SettingValues.scrollSeen && pastVisiblesItems > 0 && SettingValues.storeHistory) { - HasSeen.addSeenScrolling(posts.posts.get(pastVisiblesItems - 1) - .getFullName()); + HasSeen.addSeenScrolling(posts.posts.get(pastVisiblesItems - 1)); } } } @@ -719,4 +701,4 @@ public static void currentPosition(int adapterPosition) { public static void currentSubmission(Submission current) { currentSubmission = current; } -} \ No newline at end of file +} diff --git a/app/src/main/java/me/ccrama/redditslide/Fragments/SubredditListView.java b/app/src/main/java/me/ccrama/redditslide/Fragments/SubredditListView.java index 3f80734e71..2a91d75720 100644 --- a/app/src/main/java/me/ccrama/redditslide/Fragments/SubredditListView.java +++ b/app/src/main/java/me/ccrama/redditslide/Fragments/SubredditListView.java @@ -45,15 +45,15 @@ public class SubredditListView extends Fragment { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final Context contextThemeWrapper = new ContextThemeWrapper(getActivity(), new ColorPreferences(inflater.getContext()).getThemeSubreddit(where)); - View v = ((LayoutInflater) contextThemeWrapper.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.fragment_verticalcontent, container, false); + View v = LayoutInflater.from(contextThemeWrapper).inflate(R.layout.fragment_verticalcontent, container, false); - rv = ((RecyclerView) v.findViewById(R.id.vertical_content)); + rv = v.findViewById(R.id.vertical_content); final RecyclerView.LayoutManager mLayoutManager = new PreCachingLayoutManager(getActivity()); rv.setLayoutManager(mLayoutManager); rv.setItemAnimator(new SlideUpAlphaAnimator().withInterpolator(new LinearOutSlowInInterpolator())); - mSwipeRefreshLayout = (SwipeRefreshLayout) v.findViewById(R.id.activity_main_swipe_refresh_layout); + mSwipeRefreshLayout = v.findViewById(R.id.activity_main_swipe_refresh_layout); mSwipeRefreshLayout.setColorSchemeColors(Palette.getColors("no sub", getContext())); //If we use 'findViewById(R.id.header).getMeasuredHeight()', 0 is always returned. @@ -82,14 +82,7 @@ public void run() { adapter = new SubredditAdapter(getActivity(), posts, rv, where, this); rv.setAdapter(adapter); posts.loadMore(mSwipeRefreshLayout.getContext(), true, where); - mSwipeRefreshLayout.setOnRefreshListener( - new SwipeRefreshLayout.OnRefreshListener() { - @Override - public void onRefresh() { - refresh(); - } - } - ); + mSwipeRefreshLayout.setOnRefreshListener(this::refresh); rv.addOnScrollListener(new ToolbarScrollHideHandler(((BaseActivity) getActivity()).mToolbar, getActivity().findViewById(R.id.header)) { @Override @@ -146,4 +139,4 @@ public void updateError() { mSwipeRefreshLayout.setRefreshing(false); adapter.setError(true); } -} \ No newline at end of file +} diff --git a/app/src/main/java/me/ccrama/redditslide/Fragments/WikiPage.java b/app/src/main/java/me/ccrama/redditslide/Fragments/WikiPage.java index 463f5e6f18..f18870a5fe 100644 --- a/app/src/main/java/me/ccrama/redditslide/Fragments/WikiPage.java +++ b/app/src/main/java/me/ccrama/redditslide/Fragments/WikiPage.java @@ -12,6 +12,7 @@ import androidx.annotation.NonNull; import androidx.fragment.app.Fragment; +import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; import net.dean.jraw.managers.WikiManager; @@ -24,7 +25,6 @@ import me.ccrama.redditslide.Constants; import me.ccrama.redditslide.OpenRedditLink; import me.ccrama.redditslide.R; -import me.ccrama.redditslide.Views.GeneralSwipeRefreshLayout; import me.ccrama.redditslide.Visuals.Palette; @@ -36,7 +36,7 @@ public class WikiPage extends Fragment { private WikiPageListener listener; private WebView webView; - private GeneralSwipeRefreshLayout ref; + private SwipeRefreshLayout ref; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { @@ -113,10 +113,11 @@ public void onPageFinished(WebView webView, String url) { private void onDomRetrieved(String dom) { webView.loadDataWithBaseURL( wikiUrl, - "".concat(Wiki.getGlobalCustomCss()) - .concat(Wiki.getGlobalCustomJavaScript()) - .concat("") - .concat(dom), + "" + + Wiki.getGlobalCustomCss() + + Wiki.getGlobalCustomJavaScript() + + "" + + dom, "text/html", "utf-8", null); @@ -128,7 +129,7 @@ public void onCreate(Bundle savedInstanceState) { Bundle bundle = this.getArguments(); title = bundle.getString("title", ""); subreddit = bundle.getString("subreddit", ""); - wikiUrl = "https://www.reddit.com/r/".concat(subreddit).concat("/wiki/"); + wikiUrl = "https://www.reddit.com/r/" + subreddit + "/wiki/"; } public void setListener(WikiPageListener listener) { @@ -168,4 +169,4 @@ public interface WikiPageListener { void overflowTouched(); } -} \ No newline at end of file +} diff --git a/app/src/main/java/me/ccrama/redditslide/HasSeen.java b/app/src/main/java/me/ccrama/redditslide/HasSeen.java index 2c0d0055cd..c5e50e5a15 100644 --- a/app/src/main/java/me/ccrama/redditslide/HasSeen.java +++ b/app/src/main/java/me/ccrama/redditslide/HasSeen.java @@ -15,6 +15,7 @@ import java.util.HashSet; import java.util.List; +import me.ccrama.redditslide.SettingValues; import me.ccrama.redditslide.Synccit.SynccitRead; import static com.lusfold.androidkeyvaluestore.core.KVManagerImpl.COLUMN_KEY; @@ -27,14 +28,19 @@ */ public class HasSeen { - public static HashSet hasSeen; - public static HashMap seenTimes; + private static HashSet hasSeen; + private static HashMap seenTimes; - public static void setHasSeenContrib(List submissions) { + private static void ensureInitialized() { if (hasSeen == null) { hasSeen = new HashSet<>(); seenTimes = new HashMap<>(); } + } + + public static void setHasSeenContrib(List submissions) { + ensureInitialized(); + KVManger m = KVStore.getInstance(); for (Contribution s : submissions) { if (s instanceof Submission) { @@ -64,39 +70,11 @@ public static void setHasSeenContrib(List submissions) { } public static void setHasSeenSubmission(List submissions) { - if (hasSeen == null) { - hasSeen = new HashSet<>(); - seenTimes = new HashMap<>(); - } - KVManger m = KVStore.getInstance(); - for (Contribution s : submissions) { - String fullname = s.getFullName(); - if (fullname.contains("t3_")) { - fullname = fullname.substring(3); - } - // Check if KVStore has a key containing the fullname - // This is necessary because the KVStore library is limited and Carlos didn't realize the performance impact - Cursor cur = m.execQuery("SELECT * FROM ? WHERE ? LIKE '%?%' LIMIT 1", - new String[] { TABLE_NAME, COLUMN_KEY, fullname }); - boolean contains = cur != null && cur.getCount() > 0; - CursorUtils.closeCursorQuietly(cur); - - if (contains) { - hasSeen.add(fullname); - String value = m.get(fullname); - try { - if (value != null) seenTimes.put(fullname, Long.valueOf(value)); - } catch (Exception ignored) { - } - } - } + setHasSeenContrib((List)((Object)submissions)); } public static boolean getSeen(Submission s) { - if (hasSeen == null) { - hasSeen = new HashSet<>(); - seenTimes = new HashMap<>(); - } + ensureInitialized(); String fullname = s.getFullName(); if (fullname.contains("t3_")) { @@ -109,10 +87,7 @@ public static boolean getSeen(Submission s) { } public static boolean getSeen(String s) { - if (hasSeen == null) { - hasSeen = new HashSet<>(); - seenTimes = new HashMap<>(); - } + ensureInitialized(); Uri uri = formatRedditUrl(s); String fullname = s; @@ -151,10 +126,7 @@ public static boolean getSeen(String s) { } public static long getSeenTime(Submission s) { - if (hasSeen == null) { - hasSeen = new HashSet<>(); - seenTimes = new HashMap<>(); - } + ensureInitialized(); String fullname = s.getFullName(); if (fullname.contains("t3_")) { fullname = fullname.substring(3); @@ -171,12 +143,7 @@ public static long getSeenTime(Submission s) { } public static void addSeen(String fullname) { - if (hasSeen == null) { - hasSeen = new HashSet<>(); - } - if (seenTimes == null) { - seenTimes = new HashMap<>(); - } + ensureInitialized(); if (fullname.contains("t3_")) { fullname = fullname.substring(3); @@ -197,16 +164,13 @@ public static void addSeen(String fullname) { } } - public static void addSeenScrolling(String fullname) { - if (hasSeen == null) { - hasSeen = new HashSet<>(); - } - if (seenTimes == null) { - seenTimes = new HashMap<>(); - } - + public static void addSeenScrolling(final Submission submission) { + ensureInitialized(); + boolean hide = false; + String fullname = submission.getFullName(); if (fullname.contains("t3_")) { fullname = fullname.substring(3); + hide = true; } hasSeen.add(fullname); @@ -218,5 +182,8 @@ public static void addSeenScrolling(String fullname) { SynccitRead.newVisited.add(fullname); SynccitRead.visitedIds.add(fullname); } + if (hide && SettingValues.scrollSeenHide) { + Hidden.addSubmissionToHideQueue(submission); + } } } diff --git a/app/src/main/java/me/ccrama/redditslide/Hidden.java b/app/src/main/java/me/ccrama/redditslide/Hidden.java index 19dc293877..fe637b0697 100644 --- a/app/src/main/java/me/ccrama/redditslide/Hidden.java +++ b/app/src/main/java/me/ccrama/redditslide/Hidden.java @@ -1,27 +1,33 @@ package me.ccrama.redditslide; import android.os.AsyncTask; +import android.util.Log; import net.dean.jraw.managers.AccountManager; import net.dean.jraw.models.Contribution; import net.dean.jraw.models.Submission; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; import java.util.HashSet; +import java.util.LinkedList; import java.util.Set; /** * Created by carlo_000 on 10/16/2015. */ public class Hidden { - public static final Set id = new HashSet<>(); + private static final Set id = new HashSet<>(); + private static final HashMap hideQueue = new HashMap<>(); - public static void setHidden(final Contribution s) { + private static void setHiddenAsync(boolean hidden, final Submission contribution) { new AsyncTask() { @Override protected Void doInBackground(Void[] params) { try { - id.add(s.getFullName()); - new AccountManager(Authentication.reddit).hide(true, (Submission) s); + + new AccountManager(Authentication.reddit).hide(hidden, contribution); } catch (Exception e) { e.printStackTrace(); } @@ -30,13 +36,43 @@ protected Void doInBackground(Void[] params) { }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } + public static void setHidden(final Contribution s) { + id.add(s.getFullName()); + setHiddenAsync(true, (Submission) s); + } + public static void undoHidden(final Contribution s) { - new AsyncTask() { + id.remove(s.getFullName()); + setHiddenAsync(false, (Submission) s); + } + + public static boolean getHidden(final String fullname) { + return id.contains(fullname); + } + + public static void addSubmissionToHideQueue(final Submission submission) { + if (hideQueue.containsKey(submission.getFullName())) { + return; + } + Log.i("HideDebug", "Added " + submission.getFullName() + " to hide queue"); + hideQueue.put(submission.getFullName(), submission); + } + + public static AsyncTask asyncHideQueue() { + if (hideQueue.isEmpty()) { + return null; + } + + final ArrayList submissions = new ArrayList<>(hideQueue.values()); + final Submission firstSubmission = submissions.get(0); + final Submission[] remainingSubmissions = submissions.subList(1, submissions.size()).toArray(new Submission[0]); + hideQueue.clear(); + + return new AsyncTask() { @Override protected Void doInBackground(Void[] params) { try { - id.remove(s.getFullName()); - new AccountManager(Authentication.reddit).hide(false, (Submission) s); + new AccountManager(Authentication.reddit).hide(true, firstSubmission, remainingSubmissions); } catch (Exception e) { e.printStackTrace(); } diff --git a/app/src/main/java/me/ccrama/redditslide/ImageFlairs.java b/app/src/main/java/me/ccrama/redditslide/ImageFlairs.java index 5745211b8e..29293c5428 100644 --- a/app/src/main/java/me/ccrama/redditslide/ImageFlairs.java +++ b/app/src/main/java/me/ccrama/redditslide/ImageFlairs.java @@ -26,6 +26,8 @@ import net.dean.jraw.http.MediaTypes; import net.dean.jraw.http.RestResponse; +import org.json.JSONObject; + import java.io.File; import java.io.IOException; import java.util.ArrayList; @@ -109,13 +111,15 @@ static class StylesheetFetchTask extends AsyncTask @Override protected FlairStylesheet doInBackground(Void... params) { try { - HttpRequest r = new HttpRequest.Builder().host("reddit.com") + HttpRequest r = new HttpRequest.Builder().host("old.reddit.com") .path("/r/" + subreddit + "/stylesheet") .expected(MediaTypes.CSS.type()) .build(); + + RestResponse response = Authentication.reddit.execute(r); - String stylesheet = response.getRaw(); + String stylesheet = response.getRaw(); ArrayList allImages = new ArrayList<>(); FlairStylesheet flairStylesheet = new FlairStylesheet(stylesheet); int count = 0; @@ -521,7 +525,7 @@ Dimensions getBackgroundOffset(String classDefinitionString) { /** * Request a flair by flair id. `.into` can be chained onto this method call. * - * @param id + * @param sub * @param context * @return */ @@ -656,7 +660,7 @@ public static class FlairImageLoader extends ImageLoader { private volatile static FlairImageLoader instance; - /** Returns singletone class instance */ + /** Returns singleton class instance */ public static FlairImageLoader getInstance() { if (instance == null) { synchronized (ImageLoader.class) { @@ -692,9 +696,8 @@ public static FlairImageLoader initFlairImageLoader(Context context) { long discCacheSize = 1024 * 1024 * 100; //100 MB limit DiskCache discCache; File dir = getCacheDirectory(context); - int threadPoolSize; discCacheSize *= 100; - threadPoolSize = 7; + int threadPoolSize = 7; if (discCacheSize > 0) { try { dir.mkdir(); diff --git a/app/src/main/java/me/ccrama/redditslide/ImageLoaderUnescape.java b/app/src/main/java/me/ccrama/redditslide/ImageLoaderUnescape.java new file mode 100644 index 0000000000..17140aad0d --- /dev/null +++ b/app/src/main/java/me/ccrama/redditslide/ImageLoaderUnescape.java @@ -0,0 +1,33 @@ +package me.ccrama.redditslide; + +import com.nostra13.universalimageloader.core.DisplayImageOptions; +import com.nostra13.universalimageloader.core.ImageLoader; +import com.nostra13.universalimageloader.core.assist.ImageSize; +import com.nostra13.universalimageloader.core.imageaware.ImageAware; +import com.nostra13.universalimageloader.core.listener.ImageLoadingListener; +import com.nostra13.universalimageloader.core.listener.ImageLoadingProgressListener; + +import org.apache.commons.text.StringEscapeUtils; + +public class ImageLoaderUnescape extends ImageLoader { + + private volatile static ImageLoaderUnescape instance; + + public static ImageLoaderUnescape getInstance() { + if (instance == null) { + synchronized (ImageLoader.class) { + if (instance == null) { + instance = new ImageLoaderUnescape(); + } + } + } + return instance; + } + + @Override + public void displayImage(String uri, ImageAware imageAware, DisplayImageOptions options, + ImageSize targetSize, ImageLoadingListener listener, ImageLoadingProgressListener progressListener) { + String newUri = StringEscapeUtils.unescapeHtml4(uri); + super.displayImage(newUri, imageAware, options, targetSize, listener, progressListener); + } +} diff --git a/app/src/main/java/me/ccrama/redditslide/ImageLoaderUtils.java b/app/src/main/java/me/ccrama/redditslide/ImageLoaderUtils.java index 2b4b94fe23..2db133b9c7 100644 --- a/app/src/main/java/me/ccrama/redditslide/ImageLoaderUtils.java +++ b/app/src/main/java/me/ccrama/redditslide/ImageLoaderUtils.java @@ -2,8 +2,11 @@ import android.content.Context; import android.graphics.Bitmap; +import android.graphics.ImageDecoder; import android.os.Environment; +import com.davemorrissey.labs.subscaleview.decoder.CompatDecoderFactory; +import com.davemorrissey.labs.subscaleview.decoder.SkiaImageDecoder; import com.nostra13.universalimageloader.cache.disc.DiskCache; import com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiskCache; import com.nostra13.universalimageloader.cache.disc.impl.ext.LruDiskCache; @@ -12,27 +15,23 @@ import com.nostra13.universalimageloader.core.ImageLoader; import com.nostra13.universalimageloader.core.ImageLoaderConfiguration; import com.nostra13.universalimageloader.core.assist.ImageScaleType; -import com.nostra13.universalimageloader.core.assist.ImageSize; import com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer; -import com.nostra13.universalimageloader.core.imageaware.ImageAware; -import com.nostra13.universalimageloader.core.listener.ImageLoadingListener; -import com.nostra13.universalimageloader.core.listener.ImageLoadingProgressListener; - -import org.apache.commons.text.StringEscapeUtils; import java.io.File; import java.io.IOException; +import me.ccrama.redditslide.Views.SubsamplingScaleImageView; import me.ccrama.redditslide.util.OkHttpImageDownloader; /** * Created by carlo_000 on 10/19/2015. */ - /*Adapted from https://github.com/Kennyc1012/Opengur */ +/*Adapted from https://github.com/Kennyc1012/Opengur */ public class ImageLoaderUtils { public static ImageLoaderUnescape imageLoader; + public static DisplayImageOptions options; private ImageLoaderUtils() { } @@ -43,19 +42,20 @@ public static File getCacheDirectory(Context context) { } return context.getCacheDir(); } + public static File getCacheDirectoryGif(Context context) { if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED) && context.getExternalCacheDir() != null) { return new File(context.getExternalCacheDir() + File.separator + "gifs"); } return new File(context.getCacheDir() + File.separator + "gifs"); } + public static void initImageLoader(Context context) { long discCacheSize = 1024 * 1024; DiskCache discCache; File dir = getCacheDirectory(context); - int threadPoolSize; discCacheSize *= 100; - threadPoolSize = 7; + int threadPoolSize = 7; if (discCacheSize > 0) { try { dir.mkdir(); @@ -69,12 +69,16 @@ public static void initImageLoader(Context context) { options = new DisplayImageOptions.Builder() .cacheOnDisk(true) - .bitmapConfig(Bitmap.Config.RGB_565) - .imageScaleType(ImageScaleType.IN_SAMPLE_POWER_OF_2) + .bitmapConfig(SettingValues.highColorspaceImages ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565) + .imageScaleType(SettingValues.highColorspaceImages ? ImageScaleType.NONE_SAFE : ImageScaleType.IN_SAMPLE_POWER_OF_2) .cacheInMemory(false) .resetViewBeforeLoading(false) .displayer(new FadeInBitmapDisplayer(250)) .build(); + + if(SettingValues.highColorspaceImages) { + SubsamplingScaleImageView.setPreferredBitmapConfig(Bitmap.Config.ARGB_8888); + } ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context) .threadPoolSize(threadPoolSize) .denyCacheImageMultipleSizesInMemory() @@ -90,34 +94,5 @@ public static void initImageLoader(Context context) { imageLoader = ImageLoaderUnescape.getInstance(); imageLoader.init(config); - } - public static DisplayImageOptions options; - } - -class ImageLoaderUnescape extends ImageLoader { - - @Override - public void displayImage(String uri, ImageAware imageAware, DisplayImageOptions options, - ImageSize targetSize, ImageLoadingListener listener, ImageLoadingProgressListener progressListener) { - String newUri = StringEscapeUtils.unescapeHtml4(uri); - super.displayImage(newUri, imageAware, options, targetSize, listener, progressListener); - } - - private volatile static ImageLoaderUnescape instance; - - public static ImageLoaderUnescape getInstance() { - if (instance == null) { - synchronized (ImageLoader.class) { - if (instance == null) { - instance = new ImageLoaderUnescape(); - } - } - } - return instance; - } - - - -} \ No newline at end of file diff --git a/app/src/main/java/me/ccrama/redditslide/ImgurAlbum/AlbumUtils.java b/app/src/main/java/me/ccrama/redditslide/ImgurAlbum/AlbumUtils.java index 0eca6d7d68..d976916961 100644 --- a/app/src/main/java/me/ccrama/redditslide/ImgurAlbum/AlbumUtils.java +++ b/app/src/main/java/me/ccrama/redditslide/ImgurAlbum/AlbumUtils.java @@ -36,12 +36,12 @@ private static String getHash(String s) { if(s.contains("/comment/")){ s = s.substring(0, s.indexOf("/comment")); } - String next = s.substring(s.lastIndexOf("/"), s.length()); + String next = s.substring(s.lastIndexOf("/")); if (next.contains(".")) { next = next.substring(0, next.indexOf(".")); } if (next.startsWith("/")) { - next = next.substring(1, next.length()); + next = next.substring(1); } if (next.length() < 5) { return getHash(s.replace(next, "")); @@ -84,8 +84,8 @@ public GetAlbumWithCallback(@NotNull String url, @NotNull Activity baseActivity) rawDat = rawDat.substring(0, rawDat.length() - 1); } - if (rawDat.substring(rawDat.lastIndexOf("/")+1, rawDat.length()).length() < 4) { - rawDat = rawDat.replace(rawDat.substring(rawDat.lastIndexOf("/"), rawDat.length()), ""); + if (rawDat.substring(rawDat.lastIndexOf("/")+1).length() < 4) { + rawDat = rawDat.replace(rawDat.substring(rawDat.lastIndexOf("/")), ""); } if (rawDat.contains("?")) { rawDat = rawDat.substring(0, rawDat.indexOf("?")); @@ -122,7 +122,7 @@ public Image convertToSingle(SingleImage data) { toDo.setHash(getHash(data.getLink())); } toDo.setTitle(data.getTitle()); - toDo.setExt(data.getLink().substring(data.getLink().lastIndexOf("."), data.getLink().length())); + toDo.setExt(data.getLink().substring(data.getLink().lastIndexOf("."))); toDo.setHeight(data.getHeight()); toDo.setWidth(data.getWidth()); return toDo; @@ -182,7 +182,7 @@ public void run() { @Override protected ArrayList doInBackground(final String... sub) { if (hash.startsWith("/")) { - hash = hash.substring(1, hash.length()); + hash = hash.substring(1); } if (hash.contains(",")) { target = new JsonElement[hash.split(",").length]; diff --git a/app/src/main/java/me/ccrama/redditslide/ImgurAlbum/Image.java b/app/src/main/java/me/ccrama/redditslide/ImgurAlbum/Image.java index 4da76933b5..ec9d491369 100644 --- a/app/src/main/java/me/ccrama/redditslide/ImgurAlbum/Image.java +++ b/app/src/main/java/me/ccrama/redditslide/ImgurAlbum/Image.java @@ -239,10 +239,10 @@ public void setAdditionalProperty(String name, Object value) { } public String getImageUrl() { - return "https://i.imgur.com/" + getHash() + getExt(); + return "https://i.imgur.com/" + hash + ext; } public String getThumbnailUrl() { - return "https://i.imgur.com/" + getHash() + "s" + getExt(); + return "https://i.imgur.com/" + hash + "s" + ext; } } diff --git a/app/src/main/java/me/ccrama/redditslide/Notifications/CheckForMail.java b/app/src/main/java/me/ccrama/redditslide/Notifications/CheckForMail.java index 9b66cbd4b9..5f3e7a55f7 100644 --- a/app/src/main/java/me/ccrama/redditslide/Notifications/CheckForMail.java +++ b/app/src/main/java/me/ccrama/redditslide/Notifications/CheckForMail.java @@ -14,10 +14,12 @@ import android.content.res.Resources; import android.net.Uri; import android.os.AsyncTask; +import android.os.Build; import android.text.Html; import androidx.core.app.NotificationCompat; import androidx.core.app.NotificationManagerCompat; +import androidx.core.content.ContextCompat; import net.dean.jraw.models.Message; import net.dean.jraw.models.Submission; @@ -147,7 +149,7 @@ public void onPostExecute(List messages) { .setGroupSummary(true) .setGroupAlertBehavior(NotificationCompat.GROUP_ALERT_SUMMARY) - .addAction(R.drawable.ic_check_all_black, + .addAction(R.drawable.check_all, c.getString(R.string.mail_mark_read), readPI); if (!SettingValues.notifSound) { builder.setSound(null); @@ -157,7 +159,7 @@ public void onPostExecute(List messages) { notificationManager.notify(0, notification); } - if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { for (Message m : messages) { NotificationCompat.BigTextStyle notiStyle = new NotificationCompat.BigTextStyle(); @@ -195,8 +197,9 @@ public void onPostExecute(List messages) { PendingIntent openPi = PendingIntent.getActivity(c, 3 + (int) m.getCreated().getTime(), openPIBase, 0); - notiStyle.bigText(Html.fromHtml(StringEscapeUtils.unescapeHtml4( - m.getDataNode().get("body_html").asText()))); + + String unescape = StringEscapeUtils.unescapeHtml4(m.getDataNode().get("body_html").asText()); + notiStyle.bigText(Html.fromHtml(unescape, Html.FROM_HTML_MODE_LEGACY)); PendingIntent readPISingle = MarkAsReadService.getMarkAsReadIntent( 2 + (int) m.getCreated().getTime(), c, @@ -210,13 +213,11 @@ public void onPostExecute(List messages) { .setWhen(System.currentTimeMillis()) .setAutoCancel(true) .setContentTitle(contentTitle) - .setContentText(Html.fromHtml( - StringEscapeUtils.unescapeHtml4( - m.getDataNode().get("body_html").asText()))) + .setContentText(Html.fromHtml(unescape, Html.FROM_HTML_MODE_LEGACY)) .setStyle(notiStyle) .setGroup("MESSAGES") .setGroupAlertBehavior(NotificationCompat.GROUP_ALERT_SUMMARY) - .addAction(R.drawable.ic_check_all_black, + .addAction(R.drawable.check_all, c.getString(R.string.mail_mark_read), readPISingle); if (!SettingValues.notifSound) { builder.setSound(null); @@ -256,7 +257,7 @@ public void onPostExecute(List messages) { if (messages != null && !messages.isEmpty()) { Collections.reverse(messages); NotificationManager notificationManager = - (NotificationManager) c.getSystemService(Context.NOTIFICATION_SERVICE); + ContextCompat.getSystemService(c, NotificationManager.class); Intent notificationIntent = new Intent(c, ModQueue.class); @@ -280,7 +281,7 @@ public void onPostExecute(List messages) { NotificationCompat.Builder builder = new NotificationCompat.Builder(c, Reddit.CHANNEL_MODMAIL).setContentIntent(intent) - .setSmallIcon(R.drawable.mod_png) + .setSmallIcon(R.drawable.mod) .setTicker(res.getQuantityString( R.plurals.mod_mail_notification_title, amount, amount)) .setWhen(System.currentTimeMillis()) @@ -296,21 +297,24 @@ public void onPostExecute(List messages) { } Notification notification = builder.build(); - notificationManager.notify(1, notification); + if (notificationManager != null) { + notificationManager.notify(1, notification); + } } - if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { for (Message m : messages) { NotificationCompat.BigTextStyle notiStyle = new NotificationCompat.BigTextStyle(); notiStyle.setBigContentTitle( c.getString(R.string.mod_mail_notification_msg, m.getAuthor())); - notiStyle.bigText(Html.fromHtml(StringEscapeUtils.unescapeHtml4( - m.getDataNode().get("body_html").asText()))); + + String unescape = StringEscapeUtils.unescapeHtml4(m.getDataNode().get("body_html").asText()); + notiStyle.bigText(Html.fromHtml(unescape, Html.FROM_HTML_MODE_LEGACY)); NotificationCompat.Builder builder = new NotificationCompat.Builder(c, Reddit.CHANNEL_MODMAIL).setContentIntent(intent) - .setSmallIcon(R.drawable.mod_png) + .setSmallIcon(R.drawable.mod) .setTicker(res.getQuantityString( R.plurals.mod_mail_notification_title, 1, 1)) .setWhen(System.currentTimeMillis()) @@ -320,13 +324,15 @@ public void onPostExecute(List messages) { .setContentTitle( c.getString(R.string.mail_notification_author, m.getSubject(), m.getAuthor())) - .setContentText(Html.fromHtml(m.getBody())) + .setContentText(Html.fromHtml(m.getBody(), Html.FROM_HTML_MODE_LEGACY)) .setStyle(notiStyle); if (!SettingValues.notifSound) { builder.setSound(null); } Notification notification = builder.build(); - notificationManager.notify((int) m.getCreated().getTime(), notification); + if (notificationManager != null) { + notificationManager.notify((int) m.getCreated().getTime(), notification); + } } } @@ -367,8 +373,7 @@ public AsyncGetSubs(Context context) { public void onPostExecute(List messages) { if (messages != null) { if (!messages.isEmpty()) { - NotificationManager notificationManager = - (NotificationManager) c.getSystemService(Context.NOTIFICATION_SERVICE); + NotificationManager notificationManager = ContextCompat.getSystemService(c, NotificationManager.class); for (Submission s : messages) { Intent readIntent = new Intent(c, OpenContent.class); readIntent.putExtra(OpenContent.EXTRA_URL, @@ -415,8 +420,10 @@ public void onPostExecute(List messages) { R.string.sub_post_notifs_notification_btn, s.getSubredditName()), cancelPi) .build(); - notificationManager.notify((int) (s.getCreated().getTime() / 1000), - notification); + if (notificationManager != null) { + notificationManager.notify((int) (s.getCreated().getTime() / 1000), + notification); + } } } } @@ -478,4 +485,4 @@ protected List doInBackground(Void... params) { } } -} \ No newline at end of file +} diff --git a/app/src/main/java/me/ccrama/redditslide/Notifications/CheckForMailSingle.java b/app/src/main/java/me/ccrama/redditslide/Notifications/CheckForMailSingle.java index fbfc55e4cd..ac75ec89ae 100644 --- a/app/src/main/java/me/ccrama/redditslide/Notifications/CheckForMailSingle.java +++ b/app/src/main/java/me/ccrama/redditslide/Notifications/CheckForMailSingle.java @@ -13,6 +13,7 @@ import android.content.res.Resources; import android.net.Uri; import android.os.AsyncTask; +import android.os.Build; import android.text.Html; import androidx.core.app.NotificationCompat; @@ -118,7 +119,7 @@ public void onPostExecute(List messages) { .setGroup("MESSAGES") .setGroupSummary(true) .setGroupAlertBehavior(NotificationCompat.GROUP_ALERT_SUMMARY) - .addAction(R.drawable.ic_check_all_black, + .addAction(R.drawable.check_all, c.getString(R.string.mail_mark_read), readPI); if (!SettingValues.notifSound) { builder.setSound(null); @@ -128,7 +129,7 @@ public void onPostExecute(List messages) { notificationManager.notify(0, notification); } - if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { NotificationCompat.BigTextStyle notiStyle = new NotificationCompat.BigTextStyle(); String contentTitle; @@ -163,8 +164,9 @@ public void onPostExecute(List messages) { PendingIntent openPi = PendingIntent.getActivity(c, 3 + (int) message.getCreated().getTime(), openPIBase, 0); - notiStyle.bigText(Html.fromHtml(StringEscapeUtils.unescapeHtml4( - message.getDataNode().get("body_html").asText()))); + + String unescape = StringEscapeUtils.unescapeHtml4(message.getDataNode().get("body_html").asText()); + notiStyle.bigText(Html.fromHtml(unescape, Html.FROM_HTML_MODE_LEGACY)); PendingIntent readPISingle = MarkAsReadService.getMarkAsReadIntent( 2 + (int) message.getCreated().getTime(), c, @@ -180,12 +182,11 @@ public void onPostExecute(List messages) { .setWhen(System.currentTimeMillis()) .setAutoCancel(true) .setContentTitle(contentTitle) - .setContentText(Html.fromHtml(StringEscapeUtils.unescapeHtml4( - message.getDataNode().get("body_html").asText()))) + .setContentText(Html.fromHtml(unescape, Html.FROM_HTML_MODE_LEGACY)) .setStyle(notiStyle) .setGroup("MESSAGES") .setGroupAlertBehavior(NotificationCompat.GROUP_ALERT_SUMMARY) - .addAction(R.drawable.ic_check_all_black, + .addAction(R.drawable.check_all, c.getString(R.string.mail_mark_read), readPISingle); if (!SettingValues.notifSound) { builder.setSound(null); @@ -215,4 +216,4 @@ protected List doInBackground(Void... params) { return null; } } -} \ No newline at end of file +} diff --git a/app/src/main/java/me/ccrama/redditslide/Notifications/ImageDownloadNotificationService.java b/app/src/main/java/me/ccrama/redditslide/Notifications/ImageDownloadNotificationService.java index 3a00fa512c..8863dcd786 100644 --- a/app/src/main/java/me/ccrama/redditslide/Notifications/ImageDownloadNotificationService.java +++ b/app/src/main/java/me/ccrama/redditslide/Notifications/ImageDownloadNotificationService.java @@ -4,7 +4,6 @@ import android.app.NotificationManager; import android.app.PendingIntent; import android.app.Service; -import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; @@ -18,6 +17,7 @@ import android.widget.Toast; import androidx.core.app.NotificationCompat; +import androidx.core.content.ContextCompat; import com.google.common.io.Files; import com.nostra13.universalimageloader.core.DisplayImageOptions; @@ -25,12 +25,16 @@ import com.nostra13.universalimageloader.core.listener.ImageLoadingProgressListener; import com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListener; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; import java.util.List; +import java.util.Locale; import java.util.UUID; import me.ccrama.redditslide.Activities.DeleteFile; @@ -45,6 +49,8 @@ */ public class ImageDownloadNotificationService extends Service { + public static final String EXTRA_SUBMISSION_TITLE = "submissionTitle"; + @Override public IBinder onBind(Intent intent) { return null; @@ -63,35 +69,40 @@ private void handleIntent(Intent intent) { new PollTask(actuallyLoaded, intent.getIntExtra("index", -1), subreddit, + intent.getStringExtra(EXTRA_SUBMISSION_TITLE), intent.getStringExtra("saveToLocation")).executeOnExecutor( AsyncTask.THREAD_POOL_EXECUTOR); } private class PollTask extends AsyncTask { - public int id; - private NotificationManager mNotifyManager; + public int id; + private NotificationManager mNotifyManager; private NotificationCompat.Builder mBuilder; - public String actuallyLoaded; - private int index; - private String subreddit; - public String saveToLocation; + public String actuallyLoaded; + private final int index; + private final String subreddit; + private final String submissionTitle; + public String saveToLocation; + private static final String RESERVED_CHARS = "[|\\\\?*<\":>+\\[\\]/']"; - public PollTask(String actuallyLoaded, int index, String subreddit, String saveToLocation) { + public PollTask(String actuallyLoaded, int index, String subreddit, String submissionTitle, String saveToLocation) { this.actuallyLoaded = actuallyLoaded; this.index = index; this.subreddit = subreddit; + this.submissionTitle = submissionTitle; this.saveToLocation = saveToLocation; } public void startNotification() { id = (int) (System.currentTimeMillis() / 1000); - mNotifyManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); + mNotifyManager = ContextCompat.getSystemService( + ImageDownloadNotificationService.this, NotificationManager.class); mBuilder = new NotificationCompat.Builder(getApplicationContext(), Reddit.CHANNEL_IMG); mBuilder.setContentTitle(getString(R.string.mediaview_notif_title)) .setContentText(getString(R.string.mediaview_notif_text)) - .setSmallIcon(R.drawable.save_png); + .setSmallIcon(R.drawable.save_content); } @Override @@ -121,66 +132,21 @@ protected Void doInBackground(Void... params) { @Override public void onLoadingComplete(String imageUri, View view, - final Bitmap loadedImage) { + final Bitmap loadedImage) { File f = ((Reddit) getApplicationContext()).getImageLoader() .getDiskCache() .get(finalUrl); if (f != null && f.exists()) { - File f_out = null; - try { - if(SettingValues.imageSubfolders && !subreddit.isEmpty()){ - File directory; - if (saveToLocation != null) { - directory = new File(new File(saveToLocation, - "") - + (SettingValues.imageSubfolders && !subreddit.isEmpty() ? File.separator + subreddit : "")); - } else { - directory = new File( Reddit.appRestart.getString("imagelocation", - "") - + (SettingValues.imageSubfolders && !subreddit.isEmpty() ?File.separator + subreddit : "")); - } - directory.mkdirs(); - } - if (saveToLocation != null) { - f_out = new File( - saveToLocation - + (SettingValues.imageSubfolders && !subreddit.isEmpty() ?File.separator + subreddit : "") - + File.separator - + (index > -1 ? String.format( - "%03d_", index) : "") - + getFileName(new URL(finalUrl))); - } else { - f_out = new File( - Reddit.appRestart.getString("imagelocation", - "") - + (SettingValues.imageSubfolders && !subreddit.isEmpty() ?File.separator + subreddit : "") - + File.separator - + (index > -1 ? String.format( - "%03d_", index) : "") - + getFileName(new URL(finalUrl))); - } - } catch (MalformedURLException e) { - if (saveToLocation != null) { - f_out = new File( - saveToLocation - + (SettingValues.imageSubfolders && !subreddit.isEmpty() ?File.separator + subreddit : "") - + File.separator - + (index > -1 ? String.format( - "%03d_", index) : "") - + UUID.randomUUID().toString() - + ".png"); - } else { - f_out = new File( - Reddit.appRestart.getString("imagelocation", - "") - + (SettingValues.imageSubfolders && !subreddit.isEmpty() ?File.separator + subreddit : "") - + File.separator - + (index > -1 ? String.format( - "%03d_", index) : "") - + UUID.randomUUID().toString() - + ".png"); - } + if (SettingValues.imageSubfolders && !subreddit.isEmpty()) { + File directory = new File(getFolderPath() + getSubfolderPath()); + directory.mkdirs(); } + + File f_out = new File(getFolderPath() + + getSubfolderPath() + + File.separator + + getFileName(finalUrl)); + LogUtil.v("F out is " + f_out.toString()); try { Files.copy(f, f_out); @@ -200,19 +166,13 @@ public void onLoadingComplete(String imageUri, View view, } } } - }, new ImageLoadingProgressListener() { - @Override - public void onProgressUpdate(String imageUri, View view, - int current, int total) { - latestPercentDone = (int) ((current / (float) total) * 100); - if (percentDone <= latestPercentDone + 30 - || latestPercentDone == 100) { //Do every 10 percent - percentDone = latestPercentDone; - mBuilder.setProgress(100, percentDone, false); - mNotifyManager.notify(id, mBuilder.build()); - } - - + }, (imageUri, view, current, total) -> { + latestPercentDone = (int) ((current / (float) total) * 100); + if (percentDone <= latestPercentDone + 30 + || latestPercentDone == 100) { //Do every 10 percent + percentDone = latestPercentDone; + mBuilder.setProgress(100, percentDone, false); + mNotifyManager.notify(id, mBuilder.build()); } }); } catch (Exception e) { @@ -222,23 +182,62 @@ public void onProgressUpdate(String imageUri, View view, return null; } - public void onError(Exception e){ + private String getFolderPath() { + if (saveToLocation != null) return saveToLocation; + else return Reddit.appRestart.getString("imagelocation", ""); + } + + @NotNull + private String getSubfolderPath() { + return SettingValues.imageSubfolders && !subreddit.isEmpty() ? File.separator + subreddit : ""; + } + + public void onError(Exception e) { e.printStackTrace(); mNotifyManager.cancel(id); stopSelf(); try { Toast.makeText(getBaseContext(), "Error saving image", Toast.LENGTH_LONG).show(); - } catch (Exception ignored) {} + } catch (Exception ignored) { + } } - private String getFileName(URL url) { - if (url == null) return null; - String path = url.getPath(); - String end = path.substring(path.lastIndexOf("/") + 1); - if (!end.endsWith(".png") && !end.endsWith(".jpg") && !end.endsWith(".jpeg")) { - end = end + ".png"; + private String getFileName(String url) { + String extension; + try { + URL parsedUrl = new URL(url); + String path = parsedUrl.getPath(); + if (path.endsWith(".png") || path.endsWith(".jpg") || path.endsWith(".jpeg")) { + extension = path.substring(path.lastIndexOf(".")); + } else { + throw new MalformedURLException(); + } + } catch (MalformedURLException e) { + extension = ".png"; + } + String fileIndex = index > -1 ? String.format(Locale.ENGLISH, "_%03d", index) : ""; + String title = submissionTitle != null && !submissionTitle.replaceAll("\\W+", "").trim().isEmpty() //Replace all non-alphanumeric characters to ensure a valid File URL + ? submissionTitle.replaceAll("\\W+", "") : UUID.randomUUID().toString(); + String finalURL = (title + fileIndex + extension) + .replaceAll(RESERVED_CHARS, "") + .trim(); + + File file = new File(getFolderPath() + + getSubfolderPath() + + File.separator + + finalURL); + int tries = 0; + while(file.exists()) { + tries += 1; + finalURL = (title + fileIndex + "_" + tries + extension ) + .replaceAll(RESERVED_CHARS, "") + .trim(); + file = new File(getFolderPath() + + getSubfolderPath() + + File.separator + + finalURL); } - return end; + return finalURL; } @Override @@ -326,13 +325,13 @@ public void onScanCompleted(String path, Uri uri) { Notification notif = new NotificationCompat.Builder( getApplicationContext(), Reddit.CHANNEL_IMG).setContentTitle( getString(R.string.info_photo_saved)) - .setSmallIcon(R.drawable.save_png) + .setSmallIcon(R.drawable.save_content) .setLargeIcon(loadedImage) .setContentIntent(pContentIntent) - .addAction(R.drawable.ic_share, getString(R.string.share_image), + .addAction(R.drawable.share, getString(R.string.share_image), pShareIntent) //maybe add this in later .addAction(R.drawable.edit, "EDIT", pEditIntent) - .addAction(R.drawable.ic_delete, getString(R.string.btn_delete), + .addAction(R.drawable.delete, getString(R.string.btn_delete), pDeleteIntent) .setStyle(new NotificationCompat.BigPictureStyle().bigPicture( Bitmap.createScaledBitmap(loadedImage, 400, 400, @@ -340,10 +339,13 @@ public void onScanCompleted(String path, Uri uri) { .build(); NotificationManager mNotificationManager = - (NotificationManager) getApplicationContext().getSystemService( - NOTIFICATION_SERVICE); + ContextCompat.getSystemService(getApplicationContext(), + NotificationManager.class); notif.flags |= Notification.FLAG_AUTO_CANCEL; - mNotificationManager.notify(id, notif); + if (mNotificationManager != null) { + mNotificationManager.cancel(id); + mNotificationManager.notify(id, notif); + } loadedImage.recycle(); stopSelf(); } @@ -353,23 +355,18 @@ public void onScanCompleted(String path, Uri uri) { private void saveImageGallery(final Bitmap bitmap, String URL) throws IOException { - File f = new File( - Reddit.appRestart.getString("imagelocation", "") + File.separator + (index > -1 - ? String.format("%03d_", index) : "") + UUID.randomUUID().toString() + ( - URL.endsWith("png") ? ".png" : ".jpg")); - - FileOutputStream out = null; + File f = new File(getFolderPath() + + File.separator + + getFileName("")); f.createNewFile(); - out = new FileOutputStream(f); + FileOutputStream out = new FileOutputStream(f); bitmap.compress( URL.endsWith("png") ? Bitmap.CompressFormat.PNG : Bitmap.CompressFormat.JPEG, 100, out); { try { - if (out != null) { - out.close(); - showNotifPhoto(f, bitmap); - } + out.close(); + showNotifPhoto(f, bitmap); } catch (IOException e) { e.printStackTrace(); onError(e); @@ -384,4 +381,4 @@ public int onStartCommand(Intent intent, int flags, int startId) { handleIntent(intent); return START_NOT_STICKY; } -} \ No newline at end of file +} diff --git a/app/src/main/java/me/ccrama/redditslide/Notifications/NotificationJobScheduler.java b/app/src/main/java/me/ccrama/redditslide/Notifications/NotificationJobScheduler.java index 8e2289ee1e..e867083422 100644 --- a/app/src/main/java/me/ccrama/redditslide/Notifications/NotificationJobScheduler.java +++ b/app/src/main/java/me/ccrama/redditslide/Notifications/NotificationJobScheduler.java @@ -4,7 +4,9 @@ import android.app.PendingIntent; import android.content.Context; import android.content.Intent; -import android.os.Build; + +import androidx.core.app.AlarmManagerCompat; +import androidx.core.content.ContextCompat; import me.ccrama.redditslide.Reddit; @@ -23,18 +25,18 @@ public NotificationJobScheduler(Context context) { } public void start(Context c) { - AlarmManager manager = (AlarmManager) c.getSystemService(Context.ALARM_SERVICE); + AlarmManager manager = ContextCompat.getSystemService(c, AlarmManager.class); int interval = 1000 * 60 * Reddit.notificationTime; long currentTime = System.currentTimeMillis(); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - manager.setAndAllowWhileIdle(AlarmManager.RTC_WAKEUP, currentTime + interval, pendingIntent); - } else { - manager.set(AlarmManager.RTC_WAKEUP, currentTime + interval, pendingIntent); + if (manager != null) { + AlarmManagerCompat.setAndAllowWhileIdle(manager, AlarmManager.RTC_WAKEUP, currentTime + interval, pendingIntent); } } public void cancel(Context c) { - AlarmManager manager = (AlarmManager) c.getSystemService(Context.ALARM_SERVICE); - manager.cancel(pendingIntent); + AlarmManager manager = ContextCompat.getSystemService(c, AlarmManager.class); + if (manager != null) { + manager.cancel(pendingIntent); + } } -} \ No newline at end of file +} diff --git a/app/src/main/java/me/ccrama/redditslide/Notifications/NotificationPiggyback.java b/app/src/main/java/me/ccrama/redditslide/Notifications/NotificationPiggyback.java index 7b3e435902..2d724835a7 100644 --- a/app/src/main/java/me/ccrama/redditslide/Notifications/NotificationPiggyback.java +++ b/app/src/main/java/me/ccrama/redditslide/Notifications/NotificationPiggyback.java @@ -2,7 +2,6 @@ import android.app.AlarmManager; import android.app.PendingIntent; -import android.content.Context; import android.content.Intent; import android.os.Build; import android.service.notification.NotificationListenerService; @@ -10,6 +9,7 @@ import android.text.TextUtils; import androidx.annotation.RequiresApi; +import androidx.core.content.ContextCompat; /** * Created by Carlos on 9/27/2017. @@ -31,8 +31,10 @@ public void onNotificationPosted(StatusBarNotification sbn) { PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 0, alarmIntent, 0); AlarmManager manager = - (AlarmManager) getApplication().getSystemService(Context.ALARM_SERVICE); - manager.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + 100, pendingIntent); + ContextCompat.getSystemService(getApplication(), AlarmManager.class); + if (manager != null) { + manager.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + 100, pendingIntent); + } } } diff --git a/app/src/main/java/me/ccrama/redditslide/Notifications/StartOnBoot.java b/app/src/main/java/me/ccrama/redditslide/Notifications/StartOnBoot.java index b383b5167c..4915ddade4 100644 --- a/app/src/main/java/me/ccrama/redditslide/Notifications/StartOnBoot.java +++ b/app/src/main/java/me/ccrama/redditslide/Notifications/StartOnBoot.java @@ -6,6 +6,8 @@ import android.content.Context; import android.content.Intent; +import androidx.core.content.ContextCompat; + /** * Created by carlo_000 on 10/13/2015. */ @@ -18,10 +20,12 @@ public void onReceive(Context context, Intent intent) { Intent alarmIntent = new Intent(context, NotificationJobScheduler.class); PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, alarmIntent, 0); - AlarmManager manager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); + AlarmManager manager = ContextCompat.getSystemService(context, AlarmManager.class); int interval = 8000; - manager.setInexactRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(), interval, pendingIntent); + if (manager != null) { + manager.setInexactRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(), interval, pendingIntent); + } } } -} \ No newline at end of file +} diff --git a/app/src/main/java/me/ccrama/redditslide/OfflineSubreddit.java b/app/src/main/java/me/ccrama/redditslide/OfflineSubreddit.java index c7982beeb1..b110dbbd29 100644 --- a/app/src/main/java/me/ccrama/redditslide/OfflineSubreddit.java +++ b/app/src/main/java/me/ccrama/redditslide/OfflineSubreddit.java @@ -136,7 +136,7 @@ public void writeToMemory(ArrayList names) { fullNames); Reddit.cachedData.edit().remove(savedSubmissionsSubreddit).apply(); if (!savedSubmissions.equals(fullNames)) { - savedSubmissions = fullNames.concat(savedSubmissions); + savedSubmissions = fullNames + savedSubmissions; } saveToCache(title, savedSubmissions); } else { diff --git a/app/src/main/java/me/ccrama/redditslide/PostMatch.java b/app/src/main/java/me/ccrama/redditslide/PostMatch.java index 558c4712e8..dcffd5ccfd 100644 --- a/app/src/main/java/me/ccrama/redditslide/PostMatch.java +++ b/app/src/main/java/me/ccrama/redditslide/PostMatch.java @@ -85,7 +85,7 @@ public static boolean openExternal(String url) { public static SharedPreferences filters; public static boolean doesMatch(Submission s, String baseSubreddit, boolean ignore18) { - if (Hidden.id.contains(s.getFullName())) return true; // if it's hidden we're not going to show it regardless + if (Hidden.getHidden(s.getFullName())) return true; // if it's hidden we're not going to show it regardless String title = s.getTitle(); String body = s.getSelftext(); @@ -149,6 +149,7 @@ public static boolean doesMatch(Submission s, String baseSubreddit, boolean igno contentMatch = true; } break; + case REDDIT_GALLERY: case ALBUM: if (albums) { contentMatch = true; @@ -197,21 +198,18 @@ public static boolean doesMatch(Submission s) { String domain = s.getUrl(); String subreddit = s.getSubredditName(); - boolean titlec; - boolean bodyc; boolean domainc = false; - boolean subredditc; - titlec = contains(title, SettingValues.titleFilters, false); + boolean titlec = contains(title, SettingValues.titleFilters, false); - bodyc = contains(body, SettingValues.textFilters, false); + boolean bodyc = contains(body, SettingValues.textFilters, false); try { domainc = isDomain(domain.toLowerCase(Locale.ENGLISH), SettingValues.domainFilters); } catch (MalformedURLException ignored) { } - subredditc = subreddit != null && !subreddit.isEmpty() && contains(subreddit, SettingValues.subredditFilters, true); + boolean subredditc = subreddit != null && !subreddit.isEmpty() && contains(subreddit, SettingValues.subredditFilters, true); return (titlec || bodyc || domainc || subredditc); } diff --git a/app/src/main/java/me/ccrama/redditslide/Reddit.java b/app/src/main/java/me/ccrama/redditslide/Reddit.java index d232c08907..d56e02c777 100644 --- a/app/src/main/java/me/ccrama/redditslide/Reddit.java +++ b/app/src/main/java/me/ccrama/redditslide/Reddit.java @@ -23,11 +23,12 @@ import android.os.Environment; import android.os.Handler; import android.os.Looper; -import android.text.Html; import android.util.DisplayMetrics; import android.util.Log; import android.widget.Toast; +import androidx.core.content.ContextCompat; +import androidx.core.text.HtmlCompat; import androidx.multidex.MultiDexApplication; import com.afollestad.materialdialogs.AlertDialogWrapper; @@ -70,18 +71,15 @@ import me.ccrama.redditslide.Visuals.Palette; import me.ccrama.redditslide.util.AdBlocker; import me.ccrama.redditslide.util.GifCache; -import me.ccrama.redditslide.util.IabHelper; -import me.ccrama.redditslide.util.IabResult; import me.ccrama.redditslide.util.LogUtil; import me.ccrama.redditslide.util.NetworkUtil; import me.ccrama.redditslide.util.SortingUtil; import me.ccrama.redditslide.util.UpgradeUtil; +import me.ccrama.redditslide.util.billing.IabHelper; +import me.ccrama.redditslide.util.billing.IabResult; import okhttp3.Dns; import okhttp3.OkHttpClient; -import static android.os.Build.VERSION.SDK_INT; -import static android.os.Build.VERSION_CODES.M; - /** * Created by ccrama on 9/17/2015. */ @@ -121,7 +119,7 @@ public class Reddit extends MultiDexApplication implements Application.ActivityL public static AutoCacheScheduler autoCache; public static boolean peek; public boolean active; - private ImageLoader defaultImageLoader; + public ImageLoader defaultImageLoader; public static OkHttpClient client; public static boolean canUseNightModeAuto = false; @@ -153,7 +151,7 @@ public static int dpToPxHorizontal(int dp) { } public static void defaultShareText(String title, String url, Context c) { - url = StringEscapeUtils.unescapeHtml4(Html.fromHtml(url).toString()); + url = StringEscapeUtils.unescapeHtml4(HtmlCompat.fromHtml(url, HtmlCompat.FROM_HTML_MODE_LEGACY).toString()); Intent sharingIntent = new Intent(Intent.ACTION_SEND); sharingIntent.setType("text/plain"); /* Decode html entities */ @@ -182,7 +180,7 @@ private static boolean isVideoPluginInstalled() { public static HashMap getInstalledBrowsers() { int packageMatcher = - SDK_INT >= M ? PackageManager.MATCH_ALL : PackageManager.GET_DISABLED_COMPONENTS; + Build.VERSION.SDK_INT >= Build.VERSION_CODES.M ? PackageManager.MATCH_ALL : PackageManager.GET_DISABLED_COMPONENTS; HashMap browserMap = new HashMap<>(); @@ -591,7 +589,7 @@ public void doLanguages() { } public boolean isNotificationAccessEnabled() { - ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); + ActivityManager manager = ContextCompat.getSystemService(this, ActivityManager.class); if (manager != null) { for (ActivityManager.RunningServiceInfo service : manager.getRunningServices( Integer.MAX_VALUE)) { @@ -611,7 +609,7 @@ public boolean isNotificationAccessEnabled() { public static final String CHANNEL_SUBCHECKING = "SUB_CHECK_NOTIFY"; public void setupNotificationChannels() { - if (SDK_INT >= android.os.Build.VERSION_CODES.O) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { // Each triple contains the channel ID, name, and importance level List> notificationTripleList = new ArrayList>() {{ @@ -627,8 +625,7 @@ public void setupNotificationChannels() { NotificationManager.IMPORTANCE_LOW)); }}; - NotificationManager notificationManager = - (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); + NotificationManager notificationManager = getSystemService(NotificationManager.class); for (Triple notificationTriple : notificationTripleList) { NotificationChannel notificationChannel = @@ -674,7 +671,7 @@ public void onIabSetupFinished(IabResult result) { public static class GfycatIpv4Dns implements Dns { @Override public List lookup(String hostname) throws UnknownHostException { - if (ContentType.hostContains(hostname, "gfycat.com")) { + if (ContentType.hostContains(hostname, "gfycat.com", "redgifs.com")) { InetAddress[] addresses = InetAddress.getAllByName(hostname); if (addresses == null || addresses.length == 0) { throw new UnknownHostException("Bad host: " + hostname); @@ -706,8 +703,7 @@ public static Context getAppContext() { @TargetApi(Build.VERSION_CODES.M) private static void setCanUseNightModeAuto() { - UiModeManager uiModeManager = - (UiModeManager) getAppContext().getSystemService(Context.UI_MODE_SERVICE); + UiModeManager uiModeManager = getAppContext().getSystemService(UiModeManager.class); if (uiModeManager != null) { uiModeManager.setNightMode(UiModeManager.MODE_NIGHT_AUTO); canUseNightModeAuto = true; diff --git a/app/src/main/java/me/ccrama/redditslide/SettingValues.java b/app/src/main/java/me/ccrama/redditslide/SettingValues.java index 46b52a2bd7..457d3e930f 100644 --- a/app/src/main/java/me/ccrama/redditslide/SettingValues.java +++ b/app/src/main/java/me/ccrama/redditslide/SettingValues.java @@ -52,6 +52,7 @@ public class SettingValues { public static final String PREF_STORE_HISTORY = "storehistory"; public static final String PREF_STORE_NSFW_HISTORY = "storensfw"; public static final String PREF_SCROLL_SEEN = "scrollSeen"; + public static final String PREF_SCROLL_SEEN_HIDE = "scrollSeenHide"; public static final String PREF_TITLE_FILTERS = "titleFilters"; public static final String PREF_TEXT_FILTERS = "textFilters"; public static final String PREF_DOMAIN_FILTERS = "domainFilters"; @@ -59,6 +60,8 @@ public class SettingValues { public static final String PREF_DRAFTS = "drafts"; public static final String PREF_SUBREDDIT_FILTERS = "subredditFilters"; public static final String PREF_ABBREVIATE_SCORES = "abbreviateScores"; + public static final String PREF_HIDE_POST_AWARDS = "hidePostAwards"; + public static final String PREF_HIDE_COMMENT_AWARDS = "hideCommentAwards"; public static final String PREF_FLAIR_FILTERS = "subFlairFilters"; public static final String PREF_COMMENT_LAST_VISIT = "commentLastVisit"; public static final String PREF_VOTES_INFO_LINE = "votesInfoLine"; @@ -66,6 +69,7 @@ public class SettingValues { public static final String PREF_COMMENT_PAGER = "commentPager"; public static final String PREF_COLLAPSE_COMMENTS = "collapseCOmments"; public static final String PREF_COLLAPSE_COMMENTS_DEFAULT = "collapseCommentsDefault"; + public static final String PREF_COLLAPSE_DELETED_COMMENTS = "collapseDeletedComments"; public static final String PREF_RIGHT_HANDED_COMMENT_MENU = "rightHandedCommentMenu"; public static final String PREF_DUAL_PORTRAIT = "dualPortrait"; public static final String PREF_SINGLE_COLUMN_MULTI = "singleColumnMultiWindow"; @@ -73,6 +77,7 @@ public class SettingValues { public static final String PREF_COMMENT_FAB = "commentFab"; public static final String PREF_SWITCH_THUMB = "switchThumb"; public static final String PREF_BIG_THUMBS = "bigThumbnails"; + public static final String PREF_NO_THUMB = "noThumbnails"; public static final String PREF_LOW_RES_ALWAYS = "lowResAlways"; public static final String PREF_LOW_RES_MOBILE = "lowRes"; public static final String PREF_IMAGE_LQ = "imageLq"; @@ -134,6 +139,7 @@ public class SettingValues { public static final String PREF_MOD_TOOLBOX_LOCK = "toolboxLock"; public static final String PREF_MOD_TOOLBOX_MODMAIL = "toolboxModmail"; public static final String PREF_ALWAYS_SHOW_FAB = "alwaysShowFAB"; + public static final String PREF_HIGH_COLORSPACE_IMAGES = "highMemoryImages"; public static CreateCardView.CardEnum defaultCardView; public static Sorting defaultSorting; @@ -176,6 +182,7 @@ public class SettingValues { public static boolean showNSFWContent; public static boolean storeNSFWHistory; public static boolean scrollSeen; + public static boolean scrollSeenHide; public static boolean saveButton; public static boolean voteGestures; public static boolean colorEverywhere; @@ -190,8 +197,11 @@ public class SettingValues { public static boolean readerMode; public static boolean collapseComments; public static boolean collapseCommentsDefault; + public static boolean collapseDeletedComments; public static boolean rightHandedCommentMenu; public static boolean abbreviateScores; + public static boolean hidePostAwards; + public static boolean hideCommentAwards; public static boolean shareLongLink; public static boolean isMuted; public static int subredditSearchMethod; @@ -216,6 +226,7 @@ public class SettingValues { public static boolean loadImageLq; public static boolean ignoreSubSetting; public static boolean hideNSFWCollection; + public static boolean highColorspaceImages; public static boolean fastscroll; public static boolean fab = true; @@ -233,6 +244,7 @@ public class SettingValues { public static boolean albumSwipe; public static boolean switchThumb; public static boolean bigThumbnails; + public static boolean noThumbnails; public static boolean commentPager; public static boolean alphabetizeOnSubscribe; public static boolean colorSubName; @@ -325,7 +337,7 @@ public static void setAllValues(SharedPreferences settings) { // TODO: Remove the old pref check in a later version // This handles forward migration from the old night_mode boolean state - nightModeState = prefs.getInt(PREF_NIGHT_MODE_STATE, prefs.getBoolean(PREF_NIGHT_MODE, false) ? NightModeState.MANUAL.ordinal() : NightModeState.DISABLED.ordinal()); + nightModeState = prefs.getInt(PREF_NIGHT_MODE_STATE, (prefs.getBoolean(PREF_NIGHT_MODE, false) ? NightModeState.MANUAL : NightModeState.DISABLED).ordinal()); nightTheme = prefs.getInt(PREF_NIGHT_THEME, 0); autoTime = prefs.getBoolean(PREF_AUTOTHEME, false); colorBack = prefs.getBoolean(PREF_COLOR_BACK, false); @@ -337,6 +349,7 @@ public static void setAllValues(SharedPreferences settings) { alwaysZoom = prefs.getBoolean(PREF_ZOOM_DEFAULT, true); collapseComments = prefs.getBoolean(PREF_COLLAPSE_COMMENTS, false); collapseCommentsDefault = prefs.getBoolean(PREF_COLLAPSE_COMMENTS_DEFAULT, false); + collapseDeletedComments = prefs.getBoolean(PREF_COLLAPSE_DELETED_COMMENTS, false); rightHandedCommentMenu = prefs.getBoolean(PREF_RIGHT_HANDED_COMMENT_MENU, false); commentAutoHide = prefs.getBoolean(PREF_AUTOHIDE_COMMENTS, false); showCollapseExpand = prefs.getBoolean(PREF_SHOW_COLLAPSE_EXPAND, false); @@ -350,11 +363,15 @@ public static void setAllValues(SharedPreferences settings) { lqMid = prefs.getBoolean(PREF_LQ_MID, true); lqHigh = prefs.getBoolean(PREF_LQ_HIGH, false); lqVideos = prefs.getBoolean(PREF_LQ_VIDEOS, true); + highColorspaceImages = prefs.getBoolean(PREF_HIGH_COLORSPACE_IMAGES, false); noImages = prefs.getBoolean(PREF_NO_IMAGES, false); abbreviateScores = prefs.getBoolean(PREF_ABBREVIATE_SCORES, true); + hidePostAwards = prefs.getBoolean(PREF_HIDE_POST_AWARDS, false); + hideCommentAwards = prefs.getBoolean(PREF_HIDE_COMMENT_AWARDS, false); + lowResAlways = prefs.getBoolean(PREF_LOW_RES_ALWAYS, false); lowResMobile = prefs.getBoolean(PREF_LOW_RES_MOBILE, false); loadImageLq = prefs.getBoolean(PREF_IMAGE_LQ, false); @@ -376,6 +393,7 @@ public static void setAllValues(SharedPreferences settings) { upvotePercentage = prefs.getBoolean(PREF_UPVOTE_PERCENTAGE, false); storeNSFWHistory = prefs.getBoolean(PREF_STORE_NSFW_HISTORY, false); scrollSeen = prefs.getBoolean(PREF_SCROLL_SEEN, false); + scrollSeenHide = prefs.getBoolean(PREF_SCROLL_SEEN_HIDE, false); synccitName = prefs.getString(SYNCCIT_NAME, ""); synccitAuth = prefs.getString(SYNCCIT_AUTH, ""); notifSound = prefs.getBoolean(PREF_SOUND_NOTIFS, false); @@ -406,6 +424,7 @@ public static void setAllValues(SharedPreferences settings) { cropImage = prefs.getBoolean(PREF_CROP_IMAGE, true); switchThumb = prefs.getBoolean(PREF_SWITCH_THUMB, true); bigThumbnails = prefs.getBoolean(PREF_BIG_THUMBS, false); + noThumbnails = prefs.getBoolean(PREF_NO_THUMB, false); swipeAnywhere = true; //override this always now album = prefs.getBoolean(PREF_ALBUM, true); @@ -539,8 +558,7 @@ public static boolean isNight() { } // unset forced state if forcing is now unnecessary - allows for normal night mode on/off transitions - if ((night && forcedNightModeState == ForcedState.FORCED_ON) - || (!night && forcedNightModeState == ForcedState.FORCED_OFF)) { + if (forcedNightModeState == (night ? ForcedState.FORCED_ON : ForcedState.FORCED_OFF)) { forcedNightModeState = ForcedState.NOT_FORCED; } diff --git a/app/src/main/java/me/ccrama/redditslide/SpoilerRobotoTextView.java b/app/src/main/java/me/ccrama/redditslide/SpoilerRobotoTextView.java index a97b04bbc6..250a9fe882 100644 --- a/app/src/main/java/me/ccrama/redditslide/SpoilerRobotoTextView.java +++ b/app/src/main/java/me/ccrama/redditslide/SpoilerRobotoTextView.java @@ -12,12 +12,12 @@ import android.graphics.BitmapFactory; import android.graphics.Color; import android.graphics.PorterDuff; +import android.graphics.PorterDuffColorFilter; import android.graphics.Typeface; import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.AsyncTask; import android.os.Environment; -import android.text.Html; import android.text.Spannable; import android.text.SpannableStringBuilder; import android.text.Spanned; @@ -43,6 +43,7 @@ import androidx.appcompat.view.ContextThemeWrapper; import androidx.core.content.ContextCompat; +import androidx.core.text.HtmlCompat; import com.cocosw.bottomsheet.BottomSheet; import com.devspark.robototextview.widget.RobotoTextView; @@ -147,7 +148,7 @@ public void setTextHtml(CharSequence text) { */ public void setTextHtml(CharSequence baseText, String subreddit) { String text = wrapAlternateSpoilers(saveEmotesFromDestruction(baseText.toString().trim())); - SpannableStringBuilder builder = (SpannableStringBuilder) Html.fromHtml(text); + SpannableStringBuilder builder = (SpannableStringBuilder) HtmlCompat.fromHtml(text, HtmlCompat.FROM_HTML_MODE_LEGACY); replaceQuoteSpans( builder); //replace the
blue line with something more colorful @@ -199,10 +200,9 @@ private void replaceQuoteSpans(Spannable spannable) { spannable.removeSpan(quoteSpan); //If the theme is Light or Sepia, use a darker blue; otherwise, use a lighter blue - final int barColor = - (SettingValues.currentTheme == 1 || SettingValues.currentTheme == 5) - ? ContextCompat.getColor(getContext(), R.color.md_blue_600) - : ContextCompat.getColor(getContext(), R.color.md_blue_400); + final int barColor = ContextCompat.getColor(getContext(), + SettingValues.currentTheme == 1 || SettingValues.currentTheme == 5 + ? R.color.md_blue_600 : R.color.md_blue_400); final int BAR_WIDTH = 4; final int GAP = 5; @@ -261,8 +261,7 @@ private void setEmoteSpans(SpannableStringBuilder builder) { //Make sure bitmap loaded works well with screen density. BitmapFactory.Options options = new BitmapFactory.Options(); DisplayMetrics metrics = new DisplayMetrics(); - ((WindowManager) getContext().getSystemService( - Context.WINDOW_SERVICE)).getDefaultDisplay().getMetrics(metrics); + ContextCompat.getSystemService(getContext(), WindowManager.class).getDefaultDisplay().getMetrics(metrics); options.inDensity = 240; options.inScreenDensity = metrics.densityDpi; options.inScaled = true; @@ -537,10 +536,11 @@ public void onInflated(final PeekView peekView, final View rootView) { @Override public void onButtonUp() { ClipboardManager clipboard = - (ClipboardManager) rootView.getContext() - .getSystemService(Context.CLIPBOARD_SERVICE); + ContextCompat.getSystemService(rootView.getContext(), ClipboardManager.class); ClipData clip = ClipData.newPlainText("Link", url); - clipboard.setPrimaryClip(clip); + if (clipboard != null) { + clipboard.setPrimaryClip(clip); + } Toast.makeText(rootView.getContext(), R.string.submission_link_copied, Toast.LENGTH_SHORT).show(); } @@ -589,12 +589,12 @@ public void onPop() { TypedArray ta = getContext().obtainStyledAttributes(attrs); int color = ta.getColor(0, Color.WHITE); - Drawable open = getResources().getDrawable(R.drawable.ic_open_in_browser); - open.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - Drawable share = getResources().getDrawable(R.drawable.ic_share); - share.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - Drawable copy = getResources().getDrawable(R.drawable.ic_content_copy); - copy.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); + Drawable open = getResources().getDrawable(R.drawable.open_in_browser); + open.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + Drawable share = getResources().getDrawable(R.drawable.share); + share.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + Drawable copy = getResources().getDrawable(R.drawable.copy); + copy.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); ta.recycle(); diff --git a/app/src/main/java/me/ccrama/redditslide/StackRemoteViewsFactory.java b/app/src/main/java/me/ccrama/redditslide/StackRemoteViewsFactory.java new file mode 100644 index 0000000000..a2465136c3 --- /dev/null +++ b/app/src/main/java/me/ccrama/redditslide/StackRemoteViewsFactory.java @@ -0,0 +1,113 @@ +package me.ccrama.redditslide; + +import android.appwidget.AppWidgetManager; +import android.content.Context; +import android.content.Intent; +import android.os.Bundle; +import android.util.Log; +import android.widget.RemoteViews; +import android.widget.RemoteViewsService; + +import androidx.core.text.HtmlCompat; + +import net.dean.jraw.models.Submission; + +import java.util.ArrayList; +import java.util.List; + +import me.ccrama.redditslide.Adapters.SubredditPosts; +import me.ccrama.redditslide.util.LogUtil; + +public class StackRemoteViewsFactory implements RemoteViewsService.RemoteViewsFactory { + private final Context mContext; + private List submissions = new ArrayList<>(); + private SubredditPosts posts; + + public StackRemoteViewsFactory(Context context, Intent intent) { + mContext = context; + int mAppWidgetId = intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID); + } + + public void onCreate() { + + } + + public void onDestroy() { + submissions.clear(); + } + + public int getCount() { + return submissions.size(); + } + + public RemoteViews getViewAt(int position) { + final RemoteViews rv = new RemoteViews(mContext.getPackageName(), R.layout.submission_widget); + + if (position <= getCount()) { + + final Submission submission = submissions.get(position); + + String url = ""; + ContentType.Type type = ContentType.getContentType(submission); + if (type == ContentType.Type.IMAGE) { + url = submission.getUrl(); + } else if (submission.getDataNode().has("preview") && submission.getDataNode().get("preview").get("images").get(0).get("source").has("height") && submission.getDataNode().get("preview").get("images").get(0).get("source").get("height").asInt() > 200) { + + url = submission.getDataNode().get("preview").get("images").get(0).get("source").get("url").asText(); + + } else if (submission.getThumbnail() != null && (submission.getThumbnailType() == Submission.ThumbnailType.URL || submission.getThumbnailType() == Submission.ThumbnailType.NSFW)) { + url = submission.getThumbnail(); + } + try { + + //todo rv.setImageViewBitmap(R.id.thumbnail, Glide.with(mContext).load(url).asBitmap().); + rv.setTextViewText(R.id.title, HtmlCompat.fromHtml(submission.getTitle(), HtmlCompat.FROM_HTML_MODE_LEGACY)); + + + } catch (Exception e) { + Log.v(LogUtil.getTag(), e.toString()); + } + + + rv.setTextViewText(R.id.title, HtmlCompat.fromHtml(submission.getTitle(), HtmlCompat.FROM_HTML_MODE_LEGACY)); + + rv.setTextViewText(R.id.subreddit, submission.getSubredditName()); + rv.setTextViewText(R.id.info, submission.getAuthor() + " " + TimeUtils.getTimeAgo(submission.getCreated().getTime(), mContext)); + + Bundle extras = new Bundle(); + extras.putString("url", submission.getUrl()); + Intent fillInIntent = new Intent(); + fillInIntent.putExtras(extras); + rv.setOnClickFillInIntent(R.id.card, fillInIntent); + } + + return rv; + } + + public RemoteViews getLoadingView() { + return null; + } + + public int getViewTypeCount() { + return 1; + } + + public long getItemId(int position) { + return position; + } + + public boolean hasStableIds() { + return true; + } + + public void onDataSetChanged() { + // if (posts == null) { + // posts = new SubredditPosts("all", StackWidgetService.this); + Log.v(LogUtil.getTag(), "MAKING POSTS"); + // } + // posts.loadMore(mContext, null, true); + //TODO + submissions = posts.posts; + Log.v(LogUtil.getTag(), "POSTS IS SIZE " + submissions.size()); + } +} diff --git a/app/src/main/java/me/ccrama/redditslide/StackWidgetService.java b/app/src/main/java/me/ccrama/redditslide/StackWidgetService.java index 97cf636caa..e382ed9fd9 100644 --- a/app/src/main/java/me/ccrama/redditslide/StackWidgetService.java +++ b/app/src/main/java/me/ccrama/redditslide/StackWidgetService.java @@ -1,22 +1,8 @@ package me.ccrama.redditslide; -import android.appwidget.AppWidgetManager; -import android.content.Context; import android.content.Intent; -import android.os.Bundle; -import android.text.Html; -import android.util.Log; -import android.widget.RemoteViews; import android.widget.RemoteViewsService; -import net.dean.jraw.models.Submission; - -import java.util.ArrayList; -import java.util.List; - -import me.ccrama.redditslide.Adapters.SubredditPosts; -import me.ccrama.redditslide.util.LogUtil; - /** * Created by ccrama on 10/2/2015. */ @@ -26,101 +12,4 @@ public RemoteViewsFactory onGetViewFactory(Intent intent) { return new StackRemoteViewsFactory(this.getApplicationContext(), intent); } - } - -class StackRemoteViewsFactory implements RemoteViewsService.RemoteViewsFactory { - private final Context mContext; - private List submissions = new ArrayList<>(); - private SubredditPosts posts; - - public StackRemoteViewsFactory(Context context, Intent intent) { - mContext = context; - int mAppWidgetId = intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID); - } - - public void onCreate() { - - } - - public void onDestroy() { - submissions.clear(); - } - - public int getCount() { - return submissions.size(); - } - - public RemoteViews getViewAt(int position) { - final RemoteViews rv = new RemoteViews(mContext.getPackageName(), R.layout.submission_widget); - - if (position <= getCount()) { - - final Submission submission = submissions.get(position); - - String url = ""; - ContentType.Type type = ContentType.getContentType(submission); - if (type == ContentType.Type.IMAGE) { - url = submission.getUrl(); - } else if (submission.getDataNode().has("preview") && submission.getDataNode().get("preview").get("images").get(0).get("source").has("height") && submission.getDataNode().get("preview").get("images").get(0).get("source").get("height").asInt() > 200) { - - url = submission.getDataNode().get("preview").get("images").get(0).get("source").get("url").asText(); - - } else if (submission.getThumbnail() != null && (submission.getThumbnailType() == Submission.ThumbnailType.URL || submission.getThumbnailType() == Submission.ThumbnailType.NSFW)) { - url = submission.getThumbnail(); - } - try { - - //todo rv.setImageViewBitmap(R.id.thumbnail, Glide.with(mContext).load(url).asBitmap().); - rv.setTextViewText(R.id.title, Html.fromHtml(submission.getTitle())); - - - } catch (Exception e) { - Log.v(LogUtil.getTag(), e.toString()); - } - - - rv.setTextViewText(R.id.title, Html.fromHtml(submission.getTitle())); - - rv.setTextViewText(R.id.subreddit, submission.getSubredditName()); - rv.setTextViewText(R.id.info, submission.getAuthor() + " " + TimeUtils.getTimeAgo(submission.getCreated().getTime(), mContext)); - - Bundle extras = new Bundle(); - extras.putString("url", submission.getUrl()); - Intent fillInIntent = new Intent(); - fillInIntent.putExtras(extras); - rv.setOnClickFillInIntent(R.id.card, fillInIntent); - } - - return rv; - } - - public RemoteViews getLoadingView() { - return null; - } - - public int getViewTypeCount() { - return 1; - } - - public long getItemId(int position) { - return position; - } - - public boolean hasStableIds() { - return true; - } - - public void onDataSetChanged() { - // if (posts == null) { - // posts = new SubredditPosts("all", StackWidgetService.this); - Log.v(LogUtil.getTag(), "MAKING POSTS"); - // } - // posts.loadMore(mContext, null, true); - //TODO - submissions = posts.posts; - Log.v(LogUtil.getTag(), "POSTS IS SIZE " + submissions.size()); - - - } -} \ No newline at end of file diff --git a/app/src/main/java/me/ccrama/redditslide/SubmissionCache.java b/app/src/main/java/me/ccrama/redditslide/SubmissionCache.java index bb27ea86c6..2122ba191d 100644 --- a/app/src/main/java/me/ccrama/redditslide/SubmissionCache.java +++ b/app/src/main/java/me/ccrama/redditslide/SubmissionCache.java @@ -6,7 +6,6 @@ import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Typeface; -import android.text.Html; import android.text.SpannableStringBuilder; import android.text.Spanned; import android.text.style.ForegroundColorSpan; @@ -15,6 +14,8 @@ import android.text.style.StyleSpan; import android.util.TypedValue; +import androidx.core.text.HtmlCompat; + import com.fasterxml.jackson.databind.JsonNode; import net.dean.jraw.models.DistinguishedStatus; @@ -405,7 +406,7 @@ private static SpannableStringBuilder getInfoSpannable(Submission submission, Co private static SpannableStringBuilder getTitleSpannable(Submission submission, String flairOverride, Context mContext) { SpannableStringBuilder titleString = new SpannableStringBuilder(); - titleString.append(Html.fromHtml(submission.getTitle())); + titleString.append(HtmlCompat.fromHtml(submission.getTitle(), HtmlCompat.FROM_HTML_MODE_LEGACY)); if (submission.isStickied()) { SpannableStringBuilder pinned = new SpannableStringBuilder("\u00A0" @@ -417,8 +418,9 @@ private static SpannableStringBuilder getTitleSpannable(Submission submission, titleString.append(" "); titleString.append(pinned); } - if (submission.getTimesSilvered() > 0 || submission.getTimesGilded() > 0 - || submission.getTimesPlatinized() > 0) { + + if (!SettingValues.hidePostAwards && + (submission.getTimesSilvered() > 0 || submission.getTimesGilded() > 0 || submission.getTimesPlatinized() > 0)) { TypedArray a = mContext.obtainStyledAttributes( new FontPreferences(mContext).getPostFontStyle().getResId(), R.styleable.FontStyle); @@ -520,7 +522,7 @@ private static SpannableStringBuilder getTitleSpannable(Submission submission, flairString = submission.getSubmissionFlair().getText(); } SpannableStringBuilder pinned = - new SpannableStringBuilder("\u00A0" + Html.fromHtml(flairString) + "\u00A0"); + new SpannableStringBuilder("\u00A0" + HtmlCompat.fromHtml(flairString, HtmlCompat.FROM_HTML_MODE_LEGACY) + "\u00A0"); pinned.setSpan(new RoundedBackgroundSpan(font, color, true, mContext), 0, pinned.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); titleString.append(" "); diff --git a/app/src/main/java/me/ccrama/redditslide/SubmissionViews/HeaderImageLinkView.java b/app/src/main/java/me/ccrama/redditslide/SubmissionViews/HeaderImageLinkView.java index f577127f10..30909e97ae 100644 --- a/app/src/main/java/me/ccrama/redditslide/SubmissionViews/HeaderImageLinkView.java +++ b/app/src/main/java/me/ccrama/redditslide/SubmissionViews/HeaderImageLinkView.java @@ -8,9 +8,9 @@ import android.content.res.TypedArray; import android.graphics.Color; import android.graphics.PorterDuff; +import android.graphics.PorterDuffColorFilter; import android.graphics.drawable.Drawable; import android.os.Handler; -import android.text.Html; import android.util.AttributeSet; import android.view.HapticFeedbackConstants; import android.view.MotionEvent; @@ -21,6 +21,7 @@ import androidx.appcompat.view.ContextThemeWrapper; import androidx.core.content.ContextCompat; +import androidx.core.text.HtmlCompat; import com.cocosw.bottomsheet.BottomSheet; import com.fasterxml.jackson.databind.JsonNode; @@ -283,23 +284,23 @@ public void doImageAndText(final Submission submission, boolean full, String bas url = submission.getUrl(); url = url.substring(0, url.lastIndexOf(".")) + (SettingValues.lqLow ? "m" : (SettingValues.lqMid ? "l" : "h")) + url.substring( - url.lastIndexOf("."), url.length()); + url.lastIndexOf(".")); } else { int length = submission.getThumbnails().getVariations().length; if (SettingValues.lqLow && length >= 3) { - url = Html.fromHtml( - submission.getThumbnails().getVariations()[2].getUrl()) + url = HtmlCompat.fromHtml( + submission.getThumbnails().getVariations()[2].getUrl(), HtmlCompat.FROM_HTML_MODE_LEGACY) .toString(); //unescape url characters } else if (SettingValues.lqMid && length >= 4) { - url = Html.fromHtml( - submission.getThumbnails().getVariations()[3].getUrl()) + url = HtmlCompat.fromHtml( + submission.getThumbnails().getVariations()[3].getUrl(), HtmlCompat.FROM_HTML_MODE_LEGACY) .toString(); //unescape url characters } else if (length >= 5) { - url = Html.fromHtml( - submission.getThumbnails().getVariations()[length - 1].getUrl()) + url = HtmlCompat.fromHtml( + submission.getThumbnails().getVariations()[length - 1].getUrl(), HtmlCompat.FROM_HTML_MODE_LEGACY) .toString(); //unescape url characters } else { - url = Html.fromHtml(submission.getThumbnails().getSource().getUrl()) + url = HtmlCompat.fromHtml(submission.getThumbnails().getSource().getUrl(), HtmlCompat.FROM_HTML_MODE_LEGACY) .toString(); //unescape url characters } } @@ -369,30 +370,30 @@ public void doImageAndText(final Submission submission, boolean full, String bas url = submission.getUrl(); url = url.substring(0, url.lastIndexOf(".")) + (SettingValues.lqLow ? "m" : (SettingValues.lqMid ? "l" : "h")) + url.substring( - url.lastIndexOf("."), url.length()); + url.lastIndexOf(".")); } else { int length = submission.getThumbnails().getVariations().length; if (SettingValues.lqLow && length >= 3) { - url = Html.fromHtml( - submission.getThumbnails().getVariations()[2].getUrl()) + url = HtmlCompat.fromHtml( + submission.getThumbnails().getVariations()[2].getUrl(), HtmlCompat.FROM_HTML_MODE_LEGACY) .toString(); //unescape url characters } else if (SettingValues.lqMid && length >= 4) { - url = Html.fromHtml( - submission.getThumbnails().getVariations()[3].getUrl()) + url = HtmlCompat.fromHtml( + submission.getThumbnails().getVariations()[3].getUrl(), HtmlCompat.FROM_HTML_MODE_LEGACY) .toString(); //unescape url characters } else if (length >= 5) { - url = Html.fromHtml( - submission.getThumbnails().getVariations()[length - 1].getUrl()) + url = HtmlCompat.fromHtml( + submission.getThumbnails().getVariations()[length - 1].getUrl(), HtmlCompat.FROM_HTML_MODE_LEGACY) .toString(); //unescape url characters } else { - url = Html.fromHtml(submission.getThumbnails().getSource().getUrl()) + url = HtmlCompat.fromHtml(submission.getThumbnails().getSource().getUrl(), HtmlCompat.FROM_HTML_MODE_LEGACY) .toString(); //unescape url characters } } lq = true; } else { - url = Html.fromHtml(submission.getThumbnails().getSource().getUrl()) + url = HtmlCompat.fromHtml(submission.getThumbnails().getSource().getUrl().isEmpty() ? submission.getThumbnail() : submission.getThumbnails().getSource().getUrl(), HtmlCompat.FROM_HTML_MODE_LEGACY) .toString(); //unescape url characters } if (!SettingValues.isPicsEnabled(baseSub) && !full || forceThumb || (news && submission.getScore() < 5000)) { @@ -429,6 +430,7 @@ public void doImageAndText(final Submission submission, boolean full, String bas && (submission.getThumbnailType() == Submission.ThumbnailType.URL || (!thumbnail .isNull() && submission.isNsfw() && SettingValues.getIsNSFWEnabled()))) { + url = submission.getThumbnail(); if (!full) { thumbImage2.setVisibility(View.VISIBLE); } else { @@ -600,12 +602,12 @@ public void onPop() { TypedArray ta = getContext().obtainStyledAttributes(attrs); int color = ta.getColor(0, Color.WHITE); - Drawable open = getResources().getDrawable(R.drawable.ic_open_in_browser); - open.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - Drawable share = getResources().getDrawable(R.drawable.ic_share); - share.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - Drawable copy = getResources().getDrawable(R.drawable.ic_content_copy); - copy.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); + Drawable open = getResources().getDrawable(R.drawable.open_in_browser); + open.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + Drawable share = getResources().getDrawable(R.drawable.share); + share.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + Drawable copy = getResources().getDrawable(R.drawable.copy); + copy.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); ta.recycle(); @@ -702,14 +704,6 @@ public void run() { }; } - public void setSecondSubtitle(TextView v) { - secondSubTitle = v; - } - - public void setSecondTitle(TextView v) { - secondTitle = v; - } - public void setSubmission(final Submission submission, final boolean full, String baseSub, ContentType.Type type) { this.type = type; @@ -746,8 +740,8 @@ public void setUrl(String url) { public void setWrapArea(View v) { wrapArea = v; - setSecondTitle((TextView) v.findViewById(R.id.contenttitle)); - setSecondSubtitle((TextView) v.findViewById(R.id.contenturl)); + secondTitle = v.findViewById(R.id.contenttitle); + secondSubTitle = v.findViewById(R.id.contenturl); } @@ -767,4 +761,4 @@ private void init() { this.info = findViewById(R.id.subtextimage); this.backdrop = findViewById(R.id.leadimage); } -} \ No newline at end of file +} diff --git a/app/src/main/java/me/ccrama/redditslide/SubmissionViews/OpenVRedditTask.java b/app/src/main/java/me/ccrama/redditslide/SubmissionViews/OpenVRedditTask.java index d1c7d86ccf..58c3db75d7 100644 --- a/app/src/main/java/me/ccrama/redditslide/SubmissionViews/OpenVRedditTask.java +++ b/app/src/main/java/me/ccrama/redditslide/SubmissionViews/OpenVRedditTask.java @@ -27,7 +27,7 @@ protected Void doInBackground(String... urls) { if(url.endsWith("/")){ url = url.substring(0, url.length() - 1); } - String hash = url.substring(url.lastIndexOf("/"), url.length()); + String hash = url.substring(url.lastIndexOf("/")); try { URL newUrl = new URL("https://www.reddit.com/video" + hash); HttpURLConnection ucon = (HttpURLConnection) newUrl.openConnection(); diff --git a/app/src/main/java/me/ccrama/redditslide/SubmissionViews/PopulateNewsViewHolder.java b/app/src/main/java/me/ccrama/redditslide/SubmissionViews/PopulateNewsViewHolder.java index 7a936f0091..c143c0be61 100644 --- a/app/src/main/java/me/ccrama/redditslide/SubmissionViews/PopulateNewsViewHolder.java +++ b/app/src/main/java/me/ccrama/redditslide/SubmissionViews/PopulateNewsViewHolder.java @@ -11,9 +11,9 @@ import android.content.res.TypedArray; import android.graphics.Color; import android.graphics.PorterDuff; +import android.graphics.PorterDuffColorFilter; import android.graphics.drawable.Drawable; import android.os.AsyncTask; -import android.text.Html; import android.text.SpannableStringBuilder; import android.text.style.AbsoluteSizeSpan; import android.util.TypedValue; @@ -29,6 +29,7 @@ import androidx.annotation.Nullable; import androidx.core.content.ContextCompat; import androidx.core.content.res.ResourcesCompat; +import androidx.core.text.HtmlCompat; import androidx.recyclerview.widget.RecyclerView; import com.afollestad.materialdialogs.AlertDialogWrapper; @@ -75,6 +76,7 @@ import me.ccrama.redditslide.HasSeen; import me.ccrama.redditslide.Hidden; import me.ccrama.redditslide.LastComments; +import me.ccrama.redditslide.Notifications.ImageDownloadNotificationService; import me.ccrama.redditslide.OfflineSubreddit; import me.ccrama.redditslide.OpenRedditLink; import me.ccrama.redditslide.PostMatch; @@ -90,6 +92,8 @@ import me.ccrama.redditslide.util.NetworkUtil; import me.ccrama.redditslide.util.OnSingleClickListener; +import static me.ccrama.redditslide.Notifications.ImageDownloadNotificationService.EXTRA_SUBMISSION_TITLE; + /** * Created by ccrama on 9/19/2015. */ @@ -139,6 +143,7 @@ public void onSingleClick(View v) { myIntent.putExtra(MediaView.SUBREDDIT, submission.getSubredditName()); myIntent.putExtra(MediaView.EXTRA_URL, submission.getUrl()); + myIntent.putExtra(EXTRA_SUBMISSION_TITLE, submission.getTitle()); contextActivity.startActivity(myIntent); } else { LinkUtil.openExternally(submission.getUrl()); @@ -153,10 +158,10 @@ public void onSingleClick(View v) { break; case EMBEDDED: if (SettingValues.video) { - String data = Html.fromHtml(submission.getDataNode() + String data = HtmlCompat.fromHtml(submission.getDataNode() .get("media_embed") .get("content") - .asText()).toString(); + .asText(), HtmlCompat.FROM_HTML_MODE_LEGACY).toString(); { Intent i = new Intent(contextActivity, FullscreenVideo.class); @@ -189,10 +194,12 @@ public void onSingleClick(View v) { i = new Intent(contextActivity, AlbumPager.class); i.putExtra(AlbumPager.SUBREDDIT, submission.getSubredditName()); + i.putExtra(EXTRA_SUBMISSION_TITLE, submission.getTitle()); } else { i = new Intent(contextActivity, Album.class); i.putExtra(Album.SUBREDDIT, submission.getSubredditName()); + i.putExtra(EXTRA_SUBMISSION_TITLE, submission.getTitle()); } i.putExtra(Album.EXTRA_URL, submission.getUrl()); @@ -276,9 +283,9 @@ public static void openImage(ContentType.Type type, Activity contextActivity, if (SettingValues.image) { Intent myIntent = new Intent(contextActivity, MediaView.class); myIntent.putExtra(MediaView.SUBREDDIT, submission.getSubredditName()); - String url; + myIntent.putExtra(EXTRA_SUBMISSION_TITLE, submission.getTitle()); String previewUrl; - url = submission.getUrl(); + String url = submission.getUrl(); if (baseView != null && baseView.lq @@ -338,6 +345,7 @@ public static void openGif(Activity contextActivity, Submission submission, Intent myIntent = new Intent(contextActivity, MediaView.class); myIntent.putExtra(MediaView.SUBREDDIT, submission.getSubredditName()); + myIntent.putExtra(EXTRA_SUBMISSION_TITLE, submission.getTitle()); GifUtils.AsyncLoadGif.VideoType t = GifUtils.AsyncLoadGif.getVideoType(submission.getUrl()); @@ -431,18 +439,18 @@ public void showBottomSheet(final Activity mContext, final Drawable sub = ResourcesCompat.getDrawable(mContext.getResources(), R.drawable.sub, null); Drawable saved = - ResourcesCompat.getDrawable(mContext.getResources(), R.drawable.iconstarfilled, + ResourcesCompat.getDrawable(mContext.getResources(), R.drawable.star, null); Drawable hide = ResourcesCompat.getDrawable(mContext.getResources(), R.drawable.hide, null); final Drawable report = ResourcesCompat.getDrawable(mContext.getResources(), R.drawable.report, null); Drawable copy = - ResourcesCompat.getDrawable(mContext.getResources(), R.drawable.ic_content_copy, + ResourcesCompat.getDrawable(mContext.getResources(), R.drawable.copy, null); final Drawable readLater = ResourcesCompat.getDrawable(mContext.getResources(), R.drawable.save, null); Drawable open = - ResourcesCompat.getDrawable(mContext.getResources(), R.drawable.openexternal, null); + ResourcesCompat.getDrawable(mContext.getResources(), R.drawable.open_external, null); Drawable link = ResourcesCompat.getDrawable(mContext.getResources(), R.drawable.link, null); Drawable reddit = ResourcesCompat.getDrawable(mContext.getResources(), R.drawable.commentchange, @@ -450,22 +458,22 @@ public void showBottomSheet(final Activity mContext, Drawable filter = ResourcesCompat.getDrawable(mContext.getResources(), R.drawable.filter, null); - profile.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - sub.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - saved.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - hide.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - report.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - copy.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - open.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - link.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - reddit.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - readLater.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - filter.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); + profile.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + sub.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + saved.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + hide.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + report.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + copy.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + open.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + link.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + reddit.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + readLater.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + filter.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); ta.recycle(); final BottomSheet.Builder b = - new BottomSheet.Builder(mContext).title(Html.fromHtml(submission.getTitle())); + new BottomSheet.Builder(mContext).title(HtmlCompat.fromHtml(submission.getTitle(), HtmlCompat.FROM_HTML_MODE_LEGACY)); final boolean isReadLater = mContext instanceof PostReadLater; @@ -785,7 +793,7 @@ public void onClick(View view) { } break; case 4: - Reddit.defaultShareText(Html.fromHtml(submission.getTitle()).toString(), + Reddit.defaultShareText(HtmlCompat.fromHtml(submission.getTitle(), HtmlCompat.FROM_HTML_MODE_LEGACY).toString(), StringEscapeUtils.escapeHtml4(submission.getUrl()), mContext); break; case 12: @@ -869,14 +877,16 @@ protected void onPostExecute(Ruleset rules) { reportDialog.show(); break; case 8: - Reddit.defaultShareText(Html.fromHtml(submission.getTitle()).toString(), + Reddit.defaultShareText(HtmlCompat.fromHtml(submission.getTitle(), HtmlCompat.FROM_HTML_MODE_LEGACY).toString(), "https://reddit.com" + submission.getPermalink(), mContext); break; case 6: { - ClipboardManager clipboard = (ClipboardManager) mContext.getSystemService( - Context.CLIPBOARD_SERVICE); + ClipboardManager clipboard = ContextCompat.getSystemService(mContext, + ClipboardManager.class); ClipData clip = ClipData.newPlainText("Link", submission.getUrl()); - clipboard.setPrimaryClip(clip); + if (clipboard != null) { + clipboard.setPrimaryClip(clip); + } Toast.makeText(mContext, R.string.submission_link_copied, Toast.LENGTH_SHORT).show(); } @@ -902,8 +912,8 @@ public void onClick(DialogInterface dialog, int which) { .substring(showText.getSelectionStart(), showText.getSelectionEnd()); ClipboardManager clipboard = - (ClipboardManager) mContext.getSystemService( - Context.CLIPBOARD_SERVICE); + ContextCompat.getSystemService(mContext, + ClipboardManager.class); ClipData clip; if (!selected.isEmpty()) { clip = ClipData.newPlainText("Selftext", @@ -911,13 +921,15 @@ public void onClick(DialogInterface dialog, int which) { } else { clip = ClipData.newPlainText("Selftext", - Html.fromHtml( + HtmlCompat.fromHtml( submission.getTitle() + "\n\n" - + submission.getSelftext())); + + submission.getSelftext(), HtmlCompat.FROM_HTML_MODE_LEGACY)); } - clipboard.setPrimaryClip(clip); + if (clipboard != null) { + clipboard.setPrimaryClip(clip); + } Toast.makeText(mContext, R.string.submission_comment_copied, Toast.LENGTH_SHORT).show(); @@ -930,16 +942,19 @@ public void onClick(DialogInterface dialog, int which) { @Override public void onClick(DialogInterface dialog, int which) { ClipboardManager clipboard = - (ClipboardManager) mContext.getSystemService( - Context.CLIPBOARD_SERVICE); + ContextCompat.getSystemService(mContext, + ClipboardManager.class); ClipData clip = ClipData.newPlainText("Selftext", - Html.fromHtml(submission.getTitle() - + "\n\n" - + submission.getSelftext())); - clipboard.setPrimaryClip(clip); + StringEscapeUtils.unescapeHtml4( + submission.getTitle() + + "\n\n" + + submission.getSelftext())); + if (clipboard != null) { + clipboard.setPrimaryClip(clip); + } Toast.makeText(mContext, - R.string.submission_comment_copied, + R.string.submission_text_copied, Toast.LENGTH_SHORT).show(); } }) @@ -1175,4 +1190,4 @@ protected void onPostExecute(Void aVoid) { s.show(); } } -} \ No newline at end of file +} diff --git a/app/src/main/java/me/ccrama/redditslide/SubmissionViews/PopulateShadowboxInfo.java b/app/src/main/java/me/ccrama/redditslide/SubmissionViews/PopulateShadowboxInfo.java index 6076d0fa1d..9c42a6fa3c 100644 --- a/app/src/main/java/me/ccrama/redditslide/SubmissionViews/PopulateShadowboxInfo.java +++ b/app/src/main/java/me/ccrama/redditslide/SubmissionViews/PopulateShadowboxInfo.java @@ -3,16 +3,15 @@ import android.app.Activity; import android.content.ClipData; import android.content.ClipboardManager; -import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.res.TypedArray; import android.graphics.Color; import android.graphics.PorterDuff; +import android.graphics.PorterDuffColorFilter; import android.graphics.Typeface; import android.graphics.drawable.Drawable; import android.os.AsyncTask; -import android.text.Html; import android.text.SpannableStringBuilder; import android.text.Spanned; import android.text.style.ForegroundColorSpan; @@ -28,6 +27,7 @@ import android.widget.Toast; import androidx.core.content.ContextCompat; +import androidx.core.text.HtmlCompat; import com.afollestad.materialdialogs.DialogAction; import com.afollestad.materialdialogs.MaterialDialog; @@ -77,7 +77,7 @@ public static void doActionbar(final Submission s, final View rootView, final Ac else if (s.getDistinguishedStatus() == DistinguishedStatus.ADMIN) distingush = "[A]"; - title.setText(Html.fromHtml(s.getTitle())); + title.setText(HtmlCompat.fromHtml(s.getTitle(), HtmlCompat.FROM_HTML_MODE_LEGACY)); String spacer = c.getString(R.string.submission_properties_seperator); SpannableStringBuilder titleString = new SpannableStringBuilder(); @@ -298,7 +298,7 @@ else if (s.getDistinguishedStatus() == DistinguishedStatus.ADMIN) Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); commentTitle.append(level); } - commentTitle.append(Html.fromHtml(s.getDataNode().get("body_html").asText().trim())); + commentTitle.append(HtmlCompat.fromHtml(s.getDataNode().get("body_html").asText().trim(), HtmlCompat.FROM_HTML_MODE_LEGACY)); title.setTextHtml(commentTitle); title.setMaxLines(3); @@ -495,23 +495,23 @@ public static void showBottomSheet(final Activity mContext, final Submission sub Drawable profile = mContext.getResources().getDrawable(R.drawable.profile); final Drawable sub = mContext.getResources().getDrawable(R.drawable.sub); final Drawable report = mContext.getResources().getDrawable(R.drawable.report); - Drawable copy = mContext.getResources().getDrawable(R.drawable.ic_content_copy); - Drawable open = mContext.getResources().getDrawable(R.drawable.openexternal); + Drawable copy = mContext.getResources().getDrawable(R.drawable.copy); + Drawable open = mContext.getResources().getDrawable(R.drawable.open_external); Drawable link = mContext.getResources().getDrawable(R.drawable.link); Drawable reddit = mContext.getResources().getDrawable(R.drawable.commentchange); - profile.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - sub.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - report.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - copy.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - open.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - link.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - reddit.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); + profile.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + sub.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + report.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + copy.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + open.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + link.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + reddit.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); ta.recycle(); BottomSheet.Builder b = new BottomSheet.Builder(mContext) - .title(Html.fromHtml(submission.getTitle())); + .title(HtmlCompat.fromHtml(submission.getTitle(), HtmlCompat.FROM_HTML_MODE_LEGACY)); if (Authentication.didOnline) { @@ -635,9 +635,12 @@ protected void onPostExecute(Ruleset rules) { } break; case 6: { - ClipboardManager clipboard = (ClipboardManager) mContext.getSystemService(Context.CLIPBOARD_SERVICE); + ClipboardManager clipboard = ContextCompat.getSystemService(mContext, + ClipboardManager.class); ClipData clip = ClipData.newPlainText("Link", submission.getUrl()); - clipboard.setPrimaryClip(clip); + if (clipboard != null) { + clipboard.setPrimaryClip(clip); + } Toast.makeText(mContext, R.string.submission_link_copied, Toast.LENGTH_SHORT).show(); } break; @@ -679,4 +682,4 @@ protected void onPostExecute(Void aVoid) { } } -} \ No newline at end of file +} diff --git a/app/src/main/java/me/ccrama/redditslide/SubmissionViews/PopulateSubmissionViewHolder.java b/app/src/main/java/me/ccrama/redditslide/SubmissionViews/PopulateSubmissionViewHolder.java index 40a8f83859..b775e3399e 100644 --- a/app/src/main/java/me/ccrama/redditslide/SubmissionViews/PopulateSubmissionViewHolder.java +++ b/app/src/main/java/me/ccrama/redditslide/SubmissionViews/PopulateSubmissionViewHolder.java @@ -13,10 +13,11 @@ import android.content.res.TypedArray; import android.graphics.Color; import android.graphics.PorterDuff; +import android.graphics.PorterDuffColorFilter; import android.graphics.Typeface; import android.graphics.drawable.Drawable; import android.os.AsyncTask; -import android.text.Html; +import android.os.Bundle; import android.text.InputType; import android.text.SpannableStringBuilder; import android.text.style.AbsoluteSizeSpan; @@ -37,6 +38,7 @@ import androidx.appcompat.app.AppCompatActivity; import androidx.core.content.ContextCompat; import androidx.core.content.res.ResourcesCompat; +import androidx.core.text.HtmlCompat; import androidx.recyclerview.widget.RecyclerView; import com.afollestad.materialdialogs.AlertDialogWrapper; @@ -44,6 +46,7 @@ import com.afollestad.materialdialogs.MaterialDialog; import com.cocosw.bottomsheet.BottomSheet; import com.devspark.robototextview.RobotoTypefaces; +import com.fasterxml.jackson.databind.JsonNode; import com.google.android.material.snackbar.Snackbar; import net.dean.jraw.ApiException; @@ -74,6 +77,7 @@ import me.ccrama.redditslide.Activities.Album; import me.ccrama.redditslide.Activities.AlbumPager; import me.ccrama.redditslide.Activities.FullscreenVideo; +import me.ccrama.redditslide.Activities.GalleryImage; import me.ccrama.redditslide.Activities.MainActivity; import me.ccrama.redditslide.Activities.MediaView; import me.ccrama.redditslide.Activities.ModQueue; @@ -81,6 +85,8 @@ import me.ccrama.redditslide.Activities.PostReadLater; import me.ccrama.redditslide.Activities.Profile; import me.ccrama.redditslide.Activities.Reauthenticate; +import me.ccrama.redditslide.Activities.RedditGallery; +import me.ccrama.redditslide.Activities.RedditGalleryPager; import me.ccrama.redditslide.Activities.Search; import me.ccrama.redditslide.Activities.SubredditView; import me.ccrama.redditslide.Activities.Tumblr; @@ -118,6 +124,8 @@ import me.ccrama.redditslide.util.OnSingleClickListener; import me.ccrama.redditslide.util.SubmissionParser; +import static me.ccrama.redditslide.Notifications.ImageDownloadNotificationService.EXTRA_SUBMISSION_TITLE; + /** * Created by ccrama on 9/19/2015. */ @@ -168,6 +176,7 @@ public void onSingleClick(View v) { myIntent.putExtra(MediaView.SUBREDDIT, submission.getSubredditName()); myIntent.putExtra(MediaView.EXTRA_URL, submission.getUrl()); + myIntent.putExtra(EXTRA_SUBMISSION_TITLE, submission.getTitle()); addAdaptorPosition(myIntent, submission, holder.getAdapterPosition()); contextActivity.startActivity(myIntent); @@ -184,10 +193,10 @@ public void onSingleClick(View v) { break; case EMBEDDED: if (SettingValues.video) { - String data = Html.fromHtml(submission.getDataNode() + String data = HtmlCompat.fromHtml(submission.getDataNode() .get("media_embed") .get("content") - .asText()).toString(); + .asText(), HtmlCompat.FROM_HTML_MODE_LEGACY).toString(); { Intent i = new Intent(contextActivity, FullscreenVideo.class); @@ -201,6 +210,63 @@ public void onSingleClick(View v) { case REDDIT: openRedditContent(submission.getUrl(), contextActivity); break; + case REDDIT_GALLERY: + if (SettingValues.album) { + Intent i; + if (SettingValues.albumSwipe) { + i = new Intent(contextActivity, RedditGalleryPager.class); + i.putExtra(AlbumPager.SUBREDDIT, + submission.getSubredditName()); + i.putExtra(EXTRA_SUBMISSION_TITLE, submission.getTitle()); + } else { + i = new Intent(contextActivity, RedditGallery.class); + i.putExtra(Album.SUBREDDIT, + submission.getSubredditName()); + i.putExtra(EXTRA_SUBMISSION_TITLE, submission.getTitle()); + } + + i.putExtra(RedditGallery.SUBREDDIT, + submission.getSubredditName()); + + ArrayList urls = new ArrayList<>(); + + JsonNode dataNode = submission.getDataNode(); + if (dataNode.has("gallery_data")) { + for (JsonNode identifier : dataNode.get("gallery_data").get("items")) { + if (dataNode.has("media_metadata") && dataNode.get( + "media_metadata") + .has(identifier.get("media_id").asText())) { + urls.add(new GalleryImage(dataNode.get("media_metadata") + .get(identifier.get("media_id").asText()) + .get("s"))); + } + } + } else if (dataNode.has("crosspost_parent_list")) { //Else, try getting crosspost gallery data + JsonNode crosspost_parent = dataNode.get("crosspost_parent_list").get(0); + for (JsonNode identifier : crosspost_parent.get("gallery_data").get("items")) { + if (crosspost_parent.has("media_metadata") && crosspost_parent.get( + "media_metadata") + .has(identifier.get("media_id").asText())) { + urls.add(new GalleryImage(crosspost_parent.get("media_metadata") + .get(identifier.get("media_id").asText()) + .get("s"))); + } + } + } + + Bundle urlsBundle = new Bundle(); + urlsBundle.putSerializable(RedditGallery.GALLERY_URLS, urls); + i.putExtras(urlsBundle); + + addAdaptorPosition(i, submission, + holder.getAdapterPosition()); + contextActivity.startActivity(i); + contextActivity.overridePendingTransition(R.anim.slideright, + R.anim.fade_out); + } else { + LinkUtil.openExternally(submission.getUrl()); + } + break; case LINK: LinkUtil.openUrl(submission.getUrl(), Palette.getColor(submission.getSubredditName()), @@ -220,10 +286,12 @@ public void onSingleClick(View v) { i = new Intent(contextActivity, AlbumPager.class); i.putExtra(AlbumPager.SUBREDDIT, submission.getSubredditName()); + i.putExtra(EXTRA_SUBMISSION_TITLE, submission.getTitle()); } else { i = new Intent(contextActivity, Album.class); i.putExtra(Album.SUBREDDIT, submission.getSubredditName()); + i.putExtra(EXTRA_SUBMISSION_TITLE, submission.getTitle()); } i.putExtra(Album.EXTRA_URL, submission.getUrl()); @@ -234,7 +302,6 @@ public void onSingleClick(View v) { R.anim.fade_out); } else { LinkUtil.openExternally(submission.getUrl()); - } break; case TUMBLR: @@ -309,9 +376,9 @@ public static void openImage(ContentType.Type type, Activity contextActivity, if (SettingValues.image) { Intent myIntent = new Intent(contextActivity, MediaView.class); myIntent.putExtra(MediaView.SUBREDDIT, submission.getSubredditName()); - String url; + myIntent.putExtra(EXTRA_SUBMISSION_TITLE, submission.getTitle()); String previewUrl; - url = submission.getUrl(); + String url = submission.getUrl(); if (baseView != null && baseView.lq @@ -371,6 +438,7 @@ public static void openGif(Activity contextActivity, Submission submission, Intent myIntent = new Intent(contextActivity, MediaView.class); myIntent.putExtra(MediaView.SUBREDDIT, submission.getSubredditName()); + myIntent.putExtra(EXTRA_SUBMISSION_TITLE, submission.getTitle()); GifUtils.AsyncLoadGif.VideoType t = GifUtils.AsyncLoadGif.getVideoType(submission.getUrl()); @@ -513,18 +581,18 @@ public void showBottomSheet(final Activity mContext, final Drawable sub = ResourcesCompat.getDrawable(mContext.getResources(), R.drawable.sub, null); Drawable saved = - ResourcesCompat.getDrawable(mContext.getResources(), R.drawable.iconstarfilled, + ResourcesCompat.getDrawable(mContext.getResources(), R.drawable.star, null); Drawable hide = ResourcesCompat.getDrawable(mContext.getResources(), R.drawable.hide, null); final Drawable report = ResourcesCompat.getDrawable(mContext.getResources(), R.drawable.report, null); Drawable copy = - ResourcesCompat.getDrawable(mContext.getResources(), R.drawable.ic_content_copy, + ResourcesCompat.getDrawable(mContext.getResources(), R.drawable.copy, null); final Drawable readLater = ResourcesCompat.getDrawable(mContext.getResources(), R.drawable.save, null); Drawable open = - ResourcesCompat.getDrawable(mContext.getResources(), R.drawable.openexternal, null); + ResourcesCompat.getDrawable(mContext.getResources(), R.drawable.open_external, null); Drawable link = ResourcesCompat.getDrawable(mContext.getResources(), R.drawable.link, null); Drawable reddit = ResourcesCompat.getDrawable(mContext.getResources(), R.drawable.commentchange, @@ -534,23 +602,23 @@ public void showBottomSheet(final Activity mContext, Drawable crosspost = ResourcesCompat.getDrawable(mContext.getResources(), R.drawable.forward, null); - profile.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - sub.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - saved.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - hide.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - report.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - copy.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - open.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - link.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - reddit.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - readLater.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - filter.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - crosspost.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); + profile.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + sub.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + saved.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + hide.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + report.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + copy.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + open.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + link.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + reddit.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + readLater.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + filter.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + crosspost.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); ta.recycle(); final BottomSheet.Builder b = - new BottomSheet.Builder(mContext).title(Html.fromHtml(submission.getTitle())); + new BottomSheet.Builder(mContext).title(HtmlCompat.fromHtml(submission.getTitle(), HtmlCompat.FROM_HTML_MODE_LEGACY)); final boolean isReadLater = mContext instanceof PostReadLater; @@ -877,7 +945,7 @@ public void onClick(View view) { } break; case 4: - Reddit.defaultShareText(Html.fromHtml(submission.getTitle()).toString(), + Reddit.defaultShareText(HtmlCompat.fromHtml(submission.getTitle(), HtmlCompat.FROM_HTML_MODE_LEGACY).toString(), StringEscapeUtils.escapeHtml4(submission.getUrl()), mContext); break; case 12: @@ -968,10 +1036,12 @@ protected void onPostExecute(Ruleset rules) { } break; case 6: { - ClipboardManager clipboard = (ClipboardManager) mContext.getSystemService( - Context.CLIPBOARD_SERVICE); + ClipboardManager clipboard = ContextCompat.getSystemService(mContext, + ClipboardManager.class); ClipData clip = ClipData.newPlainText("Link", submission.getUrl()); - clipboard.setPrimaryClip(clip); + if (clipboard != null) { + clipboard.setPrimaryClip(clip); + } Toast.makeText(mContext, R.string.submission_link_copied, Toast.LENGTH_SHORT).show(); } @@ -997,8 +1067,8 @@ public void onClick(DialogInterface dialog, int which) { .substring(showText.getSelectionStart(), showText.getSelectionEnd()); ClipboardManager clipboard = - (ClipboardManager) mContext.getSystemService( - Context.CLIPBOARD_SERVICE); + ContextCompat.getSystemService(mContext, + ClipboardManager.class); ClipData clip; if (!selected.isEmpty()) { clip = ClipData.newPlainText("Selftext", @@ -1006,13 +1076,15 @@ public void onClick(DialogInterface dialog, int which) { } else { clip = ClipData.newPlainText("Selftext", - Html.fromHtml( + HtmlCompat.fromHtml( submission.getTitle() + "\n\n" - + submission.getSelftext())); + + submission.getSelftext(), HtmlCompat.FROM_HTML_MODE_LEGACY)); } - clipboard.setPrimaryClip(clip); + if (clipboard != null) { + clipboard.setPrimaryClip(clip); + } Toast.makeText(mContext, R.string.submission_comment_copied, Toast.LENGTH_SHORT).show(); @@ -1025,16 +1097,19 @@ public void onClick(DialogInterface dialog, int which) { @Override public void onClick(DialogInterface dialog, int which) { ClipboardManager clipboard = - (ClipboardManager) mContext.getSystemService( - Context.CLIPBOARD_SERVICE); + ContextCompat.getSystemService(mContext, + ClipboardManager.class); ClipData clip = ClipData.newPlainText("Selftext", - Html.fromHtml(submission.getTitle() - + "\n\n" - + submission.getSelftext())); - clipboard.setPrimaryClip(clip); + StringEscapeUtils.unescapeHtml4( + submission.getTitle() + + "\n\n" + + submission.getSelftext())); + if (clipboard != null) { + clipboard.setPrimaryClip(clip); + } Toast.makeText(mContext, - R.string.submission_comment_copied, + R.string.submission_text_copied, Toast.LENGTH_SHORT).show(); } }) @@ -1076,7 +1151,7 @@ protected void onPostExecute(Void aVoid) { ((ImageView) holder.save).setColorFilter( ContextCompat.getColor(mContext, R.color.md_amber_500), PorterDuff.Mode.SRC_ATOP); - ((ImageView) holder.save).setContentDescription(mContext.getString(R.string.btn_unsave)); + holder.save.setContentDescription(mContext.getString(R.string.btn_unsave)); s = Snackbar.make(holder.itemView, R.string.submission_info_saved, Snackbar.LENGTH_LONG); if (Authentication.me.hasGold()) { @@ -1098,7 +1173,7 @@ public void onClick(View v) { && holder.itemView.getTag(holder.itemView.getId()) .equals("none"))) || full) ? getCurrentTintColor(mContext) : getWhiteTintColor(), PorterDuff.Mode.SRC_ATOP); - ((ImageView) holder.save).setContentDescription(mContext.getString(R.string.btn_save)); + holder.save.setContentDescription(mContext.getString(R.string.btn_save)); } View view = s.getView(); @@ -1374,41 +1449,41 @@ public void showModBottomSheet(final Activity mContext, final Drawable lock = ResourcesCompat.getDrawable(mContext.getResources(), R.drawable.lock, null); final Drawable flair = ResourcesCompat.getDrawable(mContext.getResources(), - R.drawable.ic_format_quote_white_48dp, null); + R.drawable.quote, null); final Drawable remove = ResourcesCompat.getDrawable(mContext.getResources(), R.drawable.close, null); final Drawable remove_reason = - ResourcesCompat.getDrawable(mContext.getResources(), R.drawable.reportreason, null); + ResourcesCompat.getDrawable(mContext.getResources(), R.drawable.report_reason, null); final Drawable ban = ResourcesCompat.getDrawable(mContext.getResources(), R.drawable.ban, null); final Drawable spam = ResourcesCompat.getDrawable(mContext.getResources(), R.drawable.spam, null); final Drawable distinguish = - ResourcesCompat.getDrawable(mContext.getResources(), R.drawable.iconstarfilled, + ResourcesCompat.getDrawable(mContext.getResources(), R.drawable.star, null); final Drawable note = ResourcesCompat.getDrawable(mContext.getResources(), R.drawable.note, null); - profile.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - report.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - approve.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - spam.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - nsfw.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - pin.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - flair.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - remove.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - spoiler.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - remove_reason.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - ban.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - spam.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - distinguish.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - lock.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - note.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); + profile.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + report.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + approve.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + spam.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + nsfw.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + pin.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + flair.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + remove.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + spoiler.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + remove_reason.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + ban.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + spam.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + distinguish.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + lock.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); + note.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); ta.recycle(); BottomSheet.Builder b = - new BottomSheet.Builder(mContext).title(Html.fromHtml(submission.getTitle())); + new BottomSheet.Builder(mContext).title(HtmlCompat.fromHtml(submission.getTitle(), HtmlCompat.FROM_HTML_MODE_LEGACY)); int reportCount = reports.size() + reports2.size(); @@ -2721,14 +2796,14 @@ public void onClick(View v) { ((ImageView) holder.save).setColorFilter( ContextCompat.getColor(mContext, R.color.md_amber_500), PorterDuff.Mode.SRC_ATOP); - ((ImageView) holder.save).setContentDescription(mContext.getString(R.string.btn_unsave)); + holder.save.setContentDescription(mContext.getString(R.string.btn_unsave)); } else { ((ImageView) holder.save).setColorFilter( (((holder.itemView.getTag(holder.itemView.getId())) != null && holder.itemView.getTag(holder.itemView.getId()).equals("none") || full)) ? getCurrentTintColor(mContext) : getWhiteTintColor(), PorterDuff.Mode.SRC_ATOP); - ((ImageView) holder.save).setContentDescription(mContext.getString(R.string.btn_save)); + holder.save.setContentDescription(mContext.getString(R.string.btn_save)); } holder.save.setOnClickListener(new View.OnClickListener() { @Override @@ -2831,8 +2906,8 @@ public boolean onLongClick(View v) { } holder.body.setTypeface(typeface); - holder.body.setTextHtml(Html.fromHtml( - text.substring(0, text.contains("\n") ? text.indexOf("\n") : text.length())) + holder.body.setTextHtml(HtmlCompat.fromHtml( + text.substring(0, text.contains("\n") ? text.indexOf("\n") : text.length()), HtmlCompat.FROM_HTML_MODE_LEGACY) .toString() .replace("", "") .replace("", ""), "none "); @@ -3057,17 +3132,17 @@ public void onPostExecute(final ArrayList data) { Drawable delete_drawable = mContext.getResources().getDrawable(R.drawable.delete); Drawable flair_drawable = - mContext.getResources().getDrawable(R.drawable.fontsizedarker); + mContext.getResources().getDrawable(R.drawable.fontsize); - edit_drawable.setColorFilter(color2, PorterDuff.Mode.SRC_ATOP); - nsfw_drawable.setColorFilter(color2, PorterDuff.Mode.SRC_ATOP); - delete_drawable.setColorFilter(color2, PorterDuff.Mode.SRC_ATOP); - flair_drawable.setColorFilter(color2, PorterDuff.Mode.SRC_ATOP); + edit_drawable.setColorFilter(new PorterDuffColorFilter(color2, PorterDuff.Mode.SRC_ATOP)); + nsfw_drawable.setColorFilter(new PorterDuffColorFilter(color2, PorterDuff.Mode.SRC_ATOP)); + delete_drawable.setColorFilter(new PorterDuffColorFilter(color2, PorterDuff.Mode.SRC_ATOP)); + flair_drawable.setColorFilter(new PorterDuffColorFilter(color2, PorterDuff.Mode.SRC_ATOP)); ta.recycle(); BottomSheet.Builder b = new BottomSheet.Builder(mContext).title( - Html.fromHtml(submission.getTitle())); + HtmlCompat.fromHtml(submission.getTitle(), HtmlCompat.FROM_HTML_MODE_LEGACY)); if (submission.isSelfPost()) { b.sheet(1, edit_drawable, diff --git a/app/src/main/java/me/ccrama/redditslide/SwipeLayout/SwipeBackLayout.java b/app/src/main/java/me/ccrama/redditslide/SwipeLayout/SwipeBackLayout.java index 1090f51318..06ddb582c5 100644 --- a/app/src/main/java/me/ccrama/redditslide/SwipeLayout/SwipeBackLayout.java +++ b/app/src/main/java/me/ccrama/redditslide/SwipeLayout/SwipeBackLayout.java @@ -176,15 +176,6 @@ public void setSensitivity(Context context, float sensitivity) { mDragHelper.setSensitivity(context, sensitivity); } - /** - * Set up contentView which will be moved by user gesture - * - * @param view - */ - private void setContentView(View view) { - mContentView = view; - } - public void setEnableGesture(boolean enable) { mEnable = enable; } @@ -504,7 +495,8 @@ public void attachToActivity(Activity activity) { decorChild.setBackgroundResource(background); decor.removeView(decorChild); addView(decorChild); - setContentView(decorChild); + // Set up contentView which will be moved by user gesture + mContentView = decorChild; decor.addView(this); } @@ -650,4 +642,4 @@ public void onViewDragStateChanged(int state) { } } } -} \ No newline at end of file +} diff --git a/app/src/main/java/me/ccrama/redditslide/SwipeLayout/Utils.java b/app/src/main/java/me/ccrama/redditslide/SwipeLayout/Utils.java index 4c0fa0d54f..ab970270aa 100644 --- a/app/src/main/java/me/ccrama/redditslide/SwipeLayout/Utils.java +++ b/app/src/main/java/me/ccrama/redditslide/SwipeLayout/Utils.java @@ -7,6 +7,8 @@ import java.lang.reflect.Method; +import me.ccrama.redditslide.util.LogUtil; + /** * Created by Chaojun Wang on 6/9/14. * diff --git a/app/src/main/java/me/ccrama/redditslide/SwipeLayout/app/SwipeBackActivityHelper.java b/app/src/main/java/me/ccrama/redditslide/SwipeLayout/app/SwipeBackActivityHelper.java index 33b31815e2..b04a73b0c5 100644 --- a/app/src/main/java/me/ccrama/redditslide/SwipeLayout/app/SwipeBackActivityHelper.java +++ b/app/src/main/java/me/ccrama/redditslide/SwipeLayout/app/SwipeBackActivityHelper.java @@ -23,10 +23,9 @@ public SwipeBackActivityHelper(Activity activity) { mActivity = activity; } - @SuppressWarnings("deprecation") public void onActivityCreate() { mActivity.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); - mActivity.getWindow().getDecorView().setBackgroundDrawable(null); + mActivity.getWindow().getDecorView().setBackground(null); mSwipeBackLayout = (SwipeBackLayout) LayoutInflater.from(mActivity).inflate( R.layout.swipeback_layout, null); mSwipeBackLayout.addSwipeListener(new SwipeBackLayout.SwipeListener() { diff --git a/app/src/main/java/me/ccrama/redditslide/Toolbox/RemovalReasons.java b/app/src/main/java/me/ccrama/redditslide/Toolbox/RemovalReasons.java index 2972bb679a..10e0c0b322 100644 --- a/app/src/main/java/me/ccrama/redditslide/Toolbox/RemovalReasons.java +++ b/app/src/main/java/me/ccrama/redditslide/Toolbox/RemovalReasons.java @@ -9,13 +9,13 @@ import java.util.List; public class RemovalReasons { - @SerializedName("pmsubject") private String pmSubject; - private String header; - private String footer; - @SerializedName("logsub") private String logSub; - @SerializedName("logtitle") private String logTitle; - @SerializedName("logreason") private String logReason; - @SerializedName("bantitle") private String banTitle; // Is this even used by Toolbox? For mod button bans maybe (not a removal reason thing...)? + @SerializedName("pmsubject") private String pmSubject = ""; + private String header = ""; + private String footer = ""; + @SerializedName("logsub") private String logSub = ""; + @SerializedName("logtitle") private String logTitle = ""; + @SerializedName("logreason") private String logReason = ""; + @SerializedName("bantitle") private String banTitle = ""; // Is this even used by Toolbox? For mod button bans maybe (not a removal reason thing...)? private List reasons; @@ -69,10 +69,10 @@ public List getReasons() { * Class defining an individual removal reason */ public static class RemovalReason { - private String title; - private String text; - private String flairText; - private String flairCSS; + private String title = ""; + private String text = ""; + private String flairText = ""; + private String flairCSS = ""; public RemovalReason() { diff --git a/app/src/main/java/me/ccrama/redditslide/Toolbox/ToolboxUI.java b/app/src/main/java/me/ccrama/redditslide/Toolbox/ToolboxUI.java index c5907e7c1f..6def348bcd 100644 --- a/app/src/main/java/me/ccrama/redditslide/Toolbox/ToolboxUI.java +++ b/app/src/main/java/me/ccrama/redditslide/Toolbox/ToolboxUI.java @@ -86,8 +86,7 @@ public static void showRemoval(final Context context, final PublicContribution t return; } - LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); - final View dialogContent = inflater.inflate(R.layout.toolbox_removal_dialog, null); + final View dialogContent = LayoutInflater.from(context).inflate(R.layout.toolbox_removal_dialog, null); final CheckBox headerToggle = dialogContent.findViewById(R.id.toolbox_header_toggle); final TextView headerText = dialogContent.findViewById(R.id.toolbox_header_text); @@ -312,10 +311,10 @@ public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) typeMap = Toolbox.DEFAULT_USERNOTE_TYPES; } - for (String type : typeMap.keySet()) { + for (Map stringStringMap : typeMap.values()) { SpannableStringBuilder typeString = - new SpannableStringBuilder(" [" + typeMap.get(type).get("text") + "] "); - typeString.setSpan(new BackgroundColorSpan(Color.parseColor(typeMap.get(type).get("color"))), + new SpannableStringBuilder(" [" + stringStringMap.get("text") + "] "); + typeString.setSpan(new BackgroundColorSpan(Color.parseColor(stringStringMap.get("color"))), 0, typeString.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); typeString.setSpan(new ForegroundColorSpan(Color.WHITE), 0, typeString.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); @@ -603,7 +602,7 @@ protected Boolean doInBackground(Object... objects) { try { new ModerationManager(Authentication.reddit).remove((PublicContribution) objects[0], false); if (lock && thing instanceof Submission) { - new ModerationManager(Authentication.reddit).setLocked((Submission) thing); + new ModerationManager(Authentication.reddit).setLocked(thing); } if ((flair[0].length() > 0 || flair[1].length() > 0) && thing instanceof Submission) { new ModerationManager(Authentication.reddit).setFlair(((Submission) thing).getSubredditName(), diff --git a/app/src/main/java/me/ccrama/redditslide/Toolbox/Usernotes.java b/app/src/main/java/me/ccrama/redditslide/Toolbox/Usernotes.java index 1cb04c7f7a..ede9adc947 100644 --- a/app/src/main/java/me/ccrama/redditslide/Toolbox/Usernotes.java +++ b/app/src/main/java/me/ccrama/redditslide/Toolbox/Usernotes.java @@ -113,7 +113,7 @@ public void createNote(String user, String noteText, String link, long time, Str public void removeNote(String user, Usernote note) { if (notes.get(user) != null) { notes.get(user).remove(note); - if (notes.get(user).size() == 0) { // if we just removed the last note, remove the user too + if (notes.get(user).isEmpty()) { // if we just removed the last note, remove the user too notes.remove(user); } } @@ -310,10 +310,10 @@ public static class BlobSerializer implements JsonSerializer> src, Type srcType, JsonSerializationContext context) { Map>> notes = new HashMap<>(); - for (String user : src.keySet()) { + for (Map.Entry> entry : src.entrySet()) { Map> newNotes = new HashMap<>(); - newNotes.put("ns", src.get(user)); - notes.put(user, newNotes); + newNotes.put("ns", entry.getValue()); + notes.put(entry.getKey(), newNotes); } String encodedBlob = jsonToBlob(context.serialize(notes).toString()); return context.serialize(encodedBlob); diff --git a/app/src/main/java/me/ccrama/redditslide/Tumblr/Post_.java b/app/src/main/java/me/ccrama/redditslide/Tumblr/Post_.java index 8798e623ec..c7668dbf82 100644 --- a/app/src/main/java/me/ccrama/redditslide/Tumblr/Post_.java +++ b/app/src/main/java/me/ccrama/redditslide/Tumblr/Post_.java @@ -13,9 +13,7 @@ @JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({ - "id" -}) +@JsonPropertyOrder("id") public class Post_ { @JsonProperty("id") @@ -24,7 +22,7 @@ public class Post_ { private Map additionalProperties = new HashMap(); /** - * + * * @return * The id */ @@ -34,7 +32,7 @@ public String getId() { } /** - * + * * @param id * The id */ diff --git a/app/src/main/java/me/ccrama/redditslide/UserSubscriptions.java b/app/src/main/java/me/ccrama/redditslide/UserSubscriptions.java index 03399381d2..afc2a08c4c 100644 --- a/app/src/main/java/me/ccrama/redditslide/UserSubscriptions.java +++ b/app/src/main/java/me/ccrama/redditslide/UserSubscriptions.java @@ -374,9 +374,7 @@ public static void syncMultiReddits(Context c) { concatenatedSubs.toString()); } } - } catch (ApiException e) { - e.printStackTrace(); - } catch (NetworkException e) { + } catch (ApiException | NetworkException e) { e.printStackTrace(); } } diff --git a/app/src/main/java/me/ccrama/redditslide/Views/AutoMarkupTextView.java b/app/src/main/java/me/ccrama/redditslide/Views/AutoMarkupTextView.java index 9356735c52..49415402d6 100644 --- a/app/src/main/java/me/ccrama/redditslide/Views/AutoMarkupTextView.java +++ b/app/src/main/java/me/ccrama/redditslide/Views/AutoMarkupTextView.java @@ -3,13 +3,14 @@ import android.content.Context; import android.text.util.Linkify; import android.util.AttributeSet; -import android.widget.TextView; + +import androidx.appcompat.widget.AppCompatTextView; /** * Created by ccrama on 5/5/2015. */ -public class AutoMarkupTextView extends TextView { +public class AutoMarkupTextView extends AppCompatTextView { public AutoMarkupTextView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); diff --git a/app/src/main/java/me/ccrama/redditslide/Views/CanvasView.java b/app/src/main/java/me/ccrama/redditslide/Views/CanvasView.java index d9d60f6894..123eb7fb69 100644 --- a/app/src/main/java/me/ccrama/redditslide/Views/CanvasView.java +++ b/app/src/main/java/me/ccrama/redditslide/Views/CanvasView.java @@ -17,6 +17,7 @@ import android.graphics.Matrix; import android.graphics.Paint; import android.graphics.Path; +import android.graphics.PathEffect; import android.graphics.PorterDuff; import android.graphics.PorterDuffXfermode; import android.graphics.RectF; @@ -52,13 +53,14 @@ public enum Drawer { QUBIC_BEZIER } - private Context context = null; private Canvas canvas = null; private Bitmap bitmap = null; private List pathLists = new ArrayList(); private List paintLists = new ArrayList(); + private final Paint emptyPaint = new Paint(); + // for Eraser private int baseColor = Color.parseColor("#303030"); @@ -78,6 +80,7 @@ public enum Drawer { private int opacity = 255; private float blur = 0F; private Paint.Cap lineCap = Paint.Cap.ROUND; + private PathEffect drawPathEffect = null; // for Text private String text = ""; @@ -103,7 +106,7 @@ public enum Drawer { */ public CanvasView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); - this.setup(context); + this.setup(); } /** @@ -114,7 +117,7 @@ public CanvasView(Context context, AttributeSet attrs, int defStyle) { */ public CanvasView(Context context, AttributeSet attrs) { super(context, attrs); - this.setup(context); + this.setup(); } /** @@ -124,16 +127,14 @@ public CanvasView(Context context, AttributeSet attrs) { */ public CanvasView(Context context) { super(context); - this.setup(context); + this.setup(); } /** * Common initialization. * - * @param context */ - private void setup(Context context) { - this.context = context; + private void setup() { this.pathLists.add(new Path()); this.paintLists.add(this.createPaint()); @@ -177,6 +178,7 @@ private Paint createPaint() { paint.setColor(this.paintStrokeColor); paint.setShadowLayer(this.blur, 0F, 0F, this.paintStrokeColor); paint.setAlpha(this.opacity); + paint.setPathEffect(this.drawPathEffect); } return paint; @@ -262,7 +264,7 @@ private void drawText(Canvas canvas) { float textLength = paintForMeasureText.measureText(this.text); float lengthOfChar = textLength / (float) this.text.length(); float restWidth = this.canvas.getWidth() - textX; // text-align : right - int numChars = (lengthOfChar <= 0) ? 1 : (int) Math.floor((double) (restWidth / lengthOfChar)); // The number of characters at 1 line + int numChars = (lengthOfChar <= 0) ? 1 : (int) Math.floor(restWidth / lengthOfChar); // The number of characters at 1 line int modNumChars = Math.max(numChars, 1); float y = textY; @@ -350,7 +352,12 @@ private void onActionMove(MotionEvent event) { break; case RECTANGLE: path.reset(); - path.addRect(this.startX, this.startY, x, y, Path.Direction.CCW); + float left = Math.min(this.startX, x); + float right = Math.max(this.startX, x); + float top = Math.min(this.startY, y); + float bottom = Math.max(this.startY, y); + + path.addRect(left, top, right, bottom, Path.Direction.CCW); break; case CIRCLE: double distanceX = Math.abs((double) (this.startX - x)); @@ -425,9 +432,9 @@ protected void onDraw(Canvas canvas) { Matrix m = new Matrix(); m.setRectToRect(new RectF(0, 0, bitmap.getWidth(), bitmap.getHeight()), new RectF(0, 0, canvas.getWidth(), canvas.getHeight()), Matrix.ScaleToFit.CENTER); bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), m, true); - height = (((canvas.getHeight()/2)-bitmap.getHeight()/2)); - width=((canvas.getWidth()/2)-bitmap.getWidth()/2); - canvas.drawBitmap(bitmap,width,height, new Paint()); + height = (((canvas.getHeight()/2.0f)-bitmap.getHeight()/2.0f)); + width=((canvas.getWidth()/2.0f)-bitmap.getWidth()/2.0f); + canvas.drawBitmap(bitmap,width,height, emptyPaint); right = canvas.getWidth(); bottom = height + ((bitmap.getHeight())); canvas.clipRect(0,height,right, bottom); @@ -509,13 +516,31 @@ public void setDrawer(Drawer drawer) { this.drawer = drawer; } + /** + * This method checks if Undo is available + * + * @return If Undo is available, this is returned as true. Otherwise, this is returned as false. + */ + public boolean canUndo() { + return this.historyPointer > 1; + } + + /** + * This method checks if Redo is available + * + * @return If Redo is available, this is returned as true. Otherwise, this is returned as false. + */ + public boolean canRedo() { + return this.historyPointer < this.pathLists.size(); + } + /** * This method draws canvas again for Undo. * * @return If Undo is enabled, this is returned as true. Otherwise, this is returned as false. */ public boolean undo() { - if (this.historyPointer > 1) { + if (canUndo()) { this.historyPointer--; this.invalidate(); @@ -531,7 +556,7 @@ public boolean undo() { * @return If Redo is enabled, this is returned as true. Otherwise, this is returned as false. */ public boolean redo() { - if (this.historyPointer < this.pathLists.size()) { + if (canRedo()) { this.historyPointer++; this.invalidate(); @@ -756,6 +781,24 @@ public void setLineCap(Paint.Cap cap) { this.lineCap = cap; } + /** + * This method is getter for path effect of drawing. + * + * @return drawPathEffect + */ + public PathEffect getDrawPathEffect() { + return drawPathEffect; + } + + /** + * This method is setter for path effect of drawing. + * + * @param drawPathEffect + */ + public void setDrawPathEffect(PathEffect drawPathEffect) { + this.drawPathEffect = drawPathEffect; + } + /** * This method is getter for font size, * @@ -880,4 +923,4 @@ public byte[] getBitmapAsByteArray() { return this.getBitmapAsByteArray(CompressFormat.PNG, 100); } -} \ No newline at end of file +} diff --git a/app/src/main/java/me/ccrama/redditslide/Views/CreateCardView.java b/app/src/main/java/me/ccrama/redditslide/Views/CreateCardView.java index cd2de8cac0..9d3a24d1c3 100644 --- a/app/src/main/java/me/ccrama/redditslide/Views/CreateCardView.java +++ b/app/src/main/java/me/ccrama/redditslide/Views/CreateCardView.java @@ -86,6 +86,12 @@ public static View CreateView(ViewGroup viewGroup) { } } + if (SettingValues.noThumbnails) { + final int SQUARE_THUMBNAIL_SIZE = 0; + thumbImage.getLayoutParams().height = Reddit.dpToPxVertical(SQUARE_THUMBNAIL_SIZE); + thumbImage.getLayoutParams().width = Reddit.dpToPxHorizontal(SQUARE_THUMBNAIL_SIZE); + } + doHideObjects(v); return v; } @@ -226,6 +232,9 @@ public static View setCardViewType(CardEnum cardEnum, ViewGroup parent) { } public static View setBigPicEnabled(Boolean b, ViewGroup parent) { + SettingValues.prefs.edit().putBoolean("noThumbnails", b).apply(); + SettingValues.noThumbnails = false; + SettingValues.prefs.edit().putBoolean("bigPicEnabled", b).apply(); SettingValues.bigPicEnabled = b; @@ -236,6 +245,9 @@ public static View setBigPicEnabled(Boolean b, ViewGroup parent) { } public static View setBigPicCropped(Boolean b, ViewGroup parent) { + SettingValues.prefs.edit().putBoolean("noThumbnails", b).apply(); + SettingValues.noThumbnails = false; + SettingValues.prefs.edit().putBoolean("bigPicCropped", b).apply(); SettingValues.bigPicCropped = b; @@ -245,6 +257,19 @@ public static View setBigPicCropped(Boolean b, ViewGroup parent) { return CreateView(parent); } + public static View setNoThumbnails(Boolean b, ViewGroup parent) { + SettingValues.prefs.edit().putBoolean("bigPicEnabled", b).apply(); + SettingValues.bigPicEnabled = false; + + SettingValues.prefs.edit().putBoolean("bigPicCropped", false).apply(); + SettingValues.bigPicCropped = false; + + SettingValues.prefs.edit().putBoolean("noThumbnails", b).apply(); + SettingValues.noThumbnails = b; + + return CreateView(parent); + } + public static View setMiddleCard(boolean b, ViewGroup parent) { SettingValues.prefs.edit().putString("defaultCardViewNew", CardEnum.LARGE.name()).apply(); SettingValues.defaultCardView = CardEnum.LARGE; diff --git a/app/src/main/java/me/ccrama/redditslide/Views/DoEditorActions.java b/app/src/main/java/me/ccrama/redditslide/Views/DoEditorActions.java index a1bf8a8388..533d8ce601 100644 --- a/app/src/main/java/me/ccrama/redditslide/Views/DoEditorActions.java +++ b/app/src/main/java/me/ccrama/redditslide/Views/DoEditorActions.java @@ -302,9 +302,10 @@ public void onImageSelected(List uri) { .create(); tedBottomPicker.show(fm); - InputMethodManager imm = (InputMethodManager) editText.getContext() - .getSystemService(Context.INPUT_METHOD_SERVICE); - imm.hideSoftInputFromWindow(editText.getWindowToken(), 0); + InputMethodManager imm = ContextCompat.getSystemService(editText.getContext(), InputMethodManager.class); + if (imm != null) { + imm.hideSoftInputFromWindow(editText.getWindowToken(), 0); + } } }); @@ -397,7 +398,7 @@ public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) String selected = showText.getText() .toString() .substring(showText.getSelectionStart(), showText.getSelectionEnd()); - if (selected.equals("")) { + if (selected.isEmpty()) { selected = StringEscapeUtils.unescapeHtml4(oldComment); } insertBefore("> " + selected.replaceAll("\n", "\n> ") + "\n\n", editText); @@ -405,9 +406,10 @@ public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) }) .negativeText(a.getString(R.string.btn_cancel)) .show(); - InputMethodManager imm = (InputMethodManager) editText.getContext() - .getSystemService(Context.INPUT_METHOD_SERVICE); - imm.hideSoftInputFromWindow(editText.getWindowToken(), 0); + InputMethodManager imm = ContextCompat.getSystemService(editText.getContext(), InputMethodManager.class); + if (imm != null) { + imm.hideSoftInputFromWindow(editText.getWindowToken(), 0); + } } else { insertBefore("> ", editText); } @@ -420,7 +422,7 @@ public void onClick(View v) { int start = editText.getSelectionStart(); int end = editText.getSelectionEnd(); String selected = editText.getText().toString().substring(Math.min(start, end), Math.max(start, end)); - if (!selected.equals("")) { + if (!selected.isEmpty()) { selected = selected.replaceFirst("^[^\n]", "* $0").replaceAll("\n", "\n* "); editText.getText().replace(Math.min(start, end), Math.max(start, end), selected); } else { @@ -435,7 +437,7 @@ public void onClick(View v) { int start = editText.getSelectionStart(); int end = editText.getSelectionEnd(); String selected = editText.getText().toString().substring(Math.min(start, end), Math.max(start, end)); - if (!selected.equals("")) { + if (!selected.isEmpty()) { selected = selected.replaceFirst("^[^\n]", "1. $0").replaceAll("\n", "\n1. "); editText.getText().replace(Math.min(start, end), Math.max(start, end), selected); } else { @@ -457,8 +459,8 @@ public void onClick(View v) { final View dialoglayout = inflater.inflate(R.layout.parent_comment_dialog, null); final AlertDialogWrapper.Builder builder = new AlertDialogWrapper.Builder(a); setViews(html, "NO sub", - (SpoilerRobotoTextView) dialoglayout.findViewById(R.id.firstTextView), - (CommentOverflow) dialoglayout.findViewById(R.id.commentOverflow)); + dialoglayout.findViewById(R.id.firstTextView), + dialoglayout.findViewById(R.id.commentOverflow)); builder.setView(dialoglayout); builder.show(); } @@ -507,10 +509,10 @@ public void onClick(@NonNull MaterialDialog dialog, (EditText) dialog.findViewById(R.id.text_box); dialog.dismiss(); - final String s = "[".concat(textBox.getText().toString()) - .concat("](") - .concat(urlBox.getText().toString()) - .concat(")"); + final String s = "[" + textBox.getText().toString() + + "](" + + urlBox.getText().toString() + + ")"; int start = Math.max(editText.getSelectionStart(), 0); int end = Math.max(editText.getSelectionEnd(), 0); @@ -566,9 +568,10 @@ public void onImageSelected(final Uri content, String mimeType) { public static void doDraw(final Activity a, final EditText editText, final FragmentManager fm) { final Intent intent = new Intent(a, Draw.class); - InputMethodManager imm = (InputMethodManager) editText.getContext() - .getSystemService(Context.INPUT_METHOD_SERVICE); - imm.hideSoftInputFromWindow(editText.getWindowToken(), 0); + InputMethodManager imm = ContextCompat.getSystemService(editText.getContext(), InputMethodManager.class); + if (imm != null) { + imm.hideSoftInputFromWindow(editText.getWindowToken(), 0); + } e = editText.getText(); TedBottomPicker tedBottomPicker = new TedBottomPicker.Builder(editText.getContext()).setOnImageSelectedListener( @@ -799,12 +802,7 @@ protected JSONObject doInBackground(Uri... sub) { .build(); ProgressRequestBody body = - new ProgressRequestBody(formBody, new ProgressRequestBody.Listener() { - @Override - public void onProgress(int progress) { - publishProgress(progress); - } - }); + new ProgressRequestBody(formBody, this::publishProgress); Request request = new Request.Builder().header("Authorization", @@ -849,10 +847,11 @@ protected void onPostExecute(final JSONObject result) { descriptionBox.setHint(R.string.editor_title); descriptionBox.setEnabled(true); descriptionBox.setTextColor(ta.getColor(0, Color.WHITE)); - final InputMethodManager imm = - (InputMethodManager) c.getSystemService(Context.INPUT_METHOD_SERVICE); - imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, - InputMethodManager.HIDE_IMPLICIT_ONLY); + final InputMethodManager imm = ContextCompat.getSystemService(c, InputMethodManager.class); + if (imm != null) { + imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, + InputMethodManager.HIDE_IMPLICIT_ONLY); + } if (DoEditorActions.e != null) { descriptionBox.setText(DoEditorActions.e.toString().substring(sStart, sEnd)); @@ -1053,12 +1052,7 @@ public void writeTo(BufferedSink sink) { MultipartBody formBody = formBodyBuilder.build(); ProgressRequestBody body = - new ProgressRequestBody(formBody, new ProgressRequestBody.Listener() { - @Override - public void onProgress(int progress) { - publishProgress(progress); - } - }); + new ProgressRequestBody(formBody, this::publishProgress); Request request = new Request.Builder().header("Authorization", diff --git a/app/src/main/java/me/ccrama/redditslide/Views/ExoVideoView.java b/app/src/main/java/me/ccrama/redditslide/Views/ExoVideoView.java index 48f5b4da24..d23875fc82 100644 --- a/app/src/main/java/me/ccrama/redditslide/Views/ExoVideoView.java +++ b/app/src/main/java/me/ccrama/redditslide/Views/ExoVideoView.java @@ -17,6 +17,9 @@ import android.widget.ImageView; import android.widget.RelativeLayout; +import androidx.core.content.ContextCompat; + +import com.google.android.exoplayer2.MediaItem; import com.google.android.exoplayer2.Player; import com.google.android.exoplayer2.SimpleExoPlayer; import com.google.android.exoplayer2.ext.okhttp.OkHttpDataSourceFactory; @@ -30,7 +33,7 @@ import com.google.android.exoplayer2.ui.AspectRatioFrameLayout; import com.google.android.exoplayer2.ui.PlayerControlView; import com.google.android.exoplayer2.upstream.DataSource; -import com.google.android.exoplayer2.upstream.cache.CacheDataSourceFactory; +import com.google.android.exoplayer2.upstream.cache.CacheDataSource; import com.google.android.exoplayer2.util.MimeTypes; import com.google.android.exoplayer2.video.VideoListener; @@ -108,7 +111,7 @@ private void setupPlayer() { player.setVolume(0f); // Create audio focus helper - audioFocusHelper = new AudioFocusHelper((AudioManager) context.getSystemService(Context.AUDIO_SERVICE)); + audioFocusHelper = new AudioFocusHelper(ContextCompat.getSystemService(context, AudioManager.class)); // Make the video use the correct aspect ratio player.addVideoListener(new VideoListener() { @@ -170,24 +173,36 @@ private void setupUI() { public void setVideoURI(Uri uri, VideoType type, Player.EventListener listener) { // Create the data sources used to retrieve and cache the video DataSource.Factory downloader = new OkHttpDataSourceFactory(Reddit.client, context.getString(R.string.app_name)); - DataSource.Factory cacheDataSourceFactory = new CacheDataSourceFactory(Reddit.videoCache, downloader); + DataSource.Factory cacheDataSourceFactory = + new CacheDataSource.Factory() + .setCache(Reddit.videoCache) + .setUpstreamDataSourceFactory(downloader); // Create an appropriate media source for the video type MediaSource videoSource; switch (type) { // DASH video, e.g. v.redd.it video case DASH: - videoSource = new DashMediaSource.Factory(cacheDataSourceFactory).createMediaSource(uri); + videoSource = new DashMediaSource.Factory(cacheDataSourceFactory) + .createMediaSource( + new MediaItem.Builder() + .setUri(uri) + .build()); break; // Standard video, e.g. MP4 file case STANDARD: default: - videoSource = new ProgressiveMediaSource.Factory(cacheDataSourceFactory).createMediaSource(uri); + videoSource = new ProgressiveMediaSource.Factory(cacheDataSourceFactory) + .createMediaSource( + new MediaItem.Builder() + .setUri(uri) + .build()); break; } - player.prepare(videoSource); + player.setMediaSource(videoSource); + player.prepare(); if (listener != null) { player.addListener(listener); } @@ -369,7 +384,7 @@ private class AudioFocusHelper implements AudioManager.OnAudioFocusChangeListene * Lose audio focus */ void loseFocus() { - if (Build.VERSION.SDK_INT >= 26) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { if (request != null) { manager.abandonAudioFocusRequest(request); } @@ -382,7 +397,7 @@ void loseFocus() { * Gain audio focus */ void gainFocus() { - if (Build.VERSION.SDK_INT >= 26) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { if (request == null) { request = new AudioFocusRequest.Builder(AudioManager.AUDIOFOCUS_GAIN_TRANSIENT) .setAcceptsDelayedFocusGain(false) diff --git a/app/src/main/java/me/ccrama/redditslide/Views/GeneralSwipeRefreshLayout.java b/app/src/main/java/me/ccrama/redditslide/Views/GeneralSwipeRefreshLayout.java deleted file mode 100644 index 1756610eb7..0000000000 --- a/app/src/main/java/me/ccrama/redditslide/Views/GeneralSwipeRefreshLayout.java +++ /dev/null @@ -1,25 +0,0 @@ -package me.ccrama.redditslide.Views; - -import android.content.Context; -import android.util.AttributeSet; - -import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; - -/** - * Created by carlo_000 on 10/8/2015. - */ -public class GeneralSwipeRefreshLayout extends SwipeRefreshLayout { - //TODO more to come - - public GeneralSwipeRefreshLayout(Context context) { - - super(context); - } - - public GeneralSwipeRefreshLayout(Context context, AttributeSet attrs) { - - super(context, attrs); - } - - -} \ No newline at end of file diff --git a/app/src/main/java/me/ccrama/redditslide/Views/ImageInsertEditText.java b/app/src/main/java/me/ccrama/redditslide/Views/ImageInsertEditText.java index c97879d05d..bac1bede71 100644 --- a/app/src/main/java/me/ccrama/redditslide/Views/ImageInsertEditText.java +++ b/app/src/main/java/me/ccrama/redditslide/Views/ImageInsertEditText.java @@ -7,8 +7,8 @@ import android.util.AttributeSet; import android.view.inputmethod.EditorInfo; import android.view.inputmethod.InputConnection; -import android.widget.EditText; +import androidx.appcompat.widget.AppCompatEditText; import androidx.core.view.inputmethod.EditorInfoCompat; import androidx.core.view.inputmethod.InputConnectionCompat; import androidx.core.view.inputmethod.InputContentInfoCompat; @@ -18,7 +18,7 @@ * Created by Carlos on 11/5/2016. */ -public class ImageInsertEditText extends EditText { +public class ImageInsertEditText extends AppCompatEditText { public interface ImageSelectedCallback { void onImageSelected(Uri content, String mimeType); @@ -37,10 +37,6 @@ public ImageInsertEditText(Context context, AttributeSet attrs, int defStyleAttr super(context, attrs, defStyleAttr); } - public ImageInsertEditText(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { - super(context, attrs, defStyleAttr, defStyleRes); - } - // endregion private ImageSelectedCallback callback; diff --git a/app/src/main/java/me/ccrama/redditslide/Views/MaxHeightImageView.java b/app/src/main/java/me/ccrama/redditslide/Views/MaxHeightImageView.java index 433c11b8ce..cee5ba0a11 100644 --- a/app/src/main/java/me/ccrama/redditslide/Views/MaxHeightImageView.java +++ b/app/src/main/java/me/ccrama/redditslide/Views/MaxHeightImageView.java @@ -2,12 +2,13 @@ import android.content.Context; import android.util.AttributeSet; -import android.widget.ImageView; + +import androidx.appcompat.widget.AppCompatImageView; /** * Created by Carlos on 6/2/2016. */ -public class MaxHeightImageView extends ImageView { +public class MaxHeightImageView extends AppCompatImageView { public MaxHeightImageView(Context context) { super(context); } @@ -20,10 +21,6 @@ public MaxHeightImageView(Context context, AttributeSet attrs, int defStyleAttr) super(context, attrs, defStyleAttr); } - public MaxHeightImageView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { - super(context, attrs, defStyleAttr, defStyleRes); - } - public static final int maxHeight = 3200; @Override diff --git a/app/src/main/java/me/ccrama/redditslide/Views/MediaVideoViewOld.java b/app/src/main/java/me/ccrama/redditslide/Views/MediaVideoViewOld.java index 3670ff6270..138f47ef8d 100644 --- a/app/src/main/java/me/ccrama/redditslide/Views/MediaVideoViewOld.java +++ b/app/src/main/java/me/ccrama/redditslide/Views/MediaVideoViewOld.java @@ -447,12 +447,7 @@ private void openVideo() { // target state that was there before. mCurrentState = STATE_PREPARING; attachMediaController(); - } catch (IOException ex) { - Log.w(TAG, "Unable to open content: " + mUri, ex); - mCurrentState = STATE_ERROR; - mTargetState = STATE_ERROR; - mErrorListener.onError(mMediaPlayer, MediaPlayer.MEDIA_ERROR_UNKNOWN, 0); - } catch (IllegalArgumentException ex) { + } catch (IOException | IllegalArgumentException ex) { Log.w(TAG, "Unable to open content: " + mUri, ex); mCurrentState = STATE_ERROR; mTargetState = STATE_ERROR; @@ -741,4 +736,4 @@ public void draw(Canvas canvas) { // canvas.restoreToCount(saveCount); // } } -} \ No newline at end of file +} diff --git a/app/src/main/java/me/ccrama/redditslide/Views/PeekMediaView.java b/app/src/main/java/me/ccrama/redditslide/Views/PeekMediaView.java index 4e284d1cd4..c5ff6e817a 100644 --- a/app/src/main/java/me/ccrama/redditslide/Views/PeekMediaView.java +++ b/app/src/main/java/me/ccrama/redditslide/Views/PeekMediaView.java @@ -103,7 +103,7 @@ public void doScroll(MotionEvent event) { } if (web && website.canScrollVertically((origY - event.getY()) > 0 ? 0 : 1) - && Math.abs(origY - event.getY()) > website.getHeight() / 4) { + && Math.abs(origY - event.getY()) > website.getHeight() / 4.0f) { website.scrollBy(0, (int) -(origY - event.getY()) / 5); } } @@ -125,6 +125,7 @@ public void setUrl(String url) { case LINK: case VIDEO: case SELF: + case REDDIT_GALLERY: case SPOILER: case NONE: doLoadLink(url); @@ -180,7 +181,7 @@ public void doWithData(final List jsonElements) { images = new ArrayList<>(jsonElements); displayImage(images.get(0).getImageUrl()); if (images.size() > 1) { - GridView grid = (GridView) findViewById(R.id.grid_area); + GridView grid = findViewById(R.id.grid_area); grid.setNumColumns(5); grid.setVisibility(VISIBLE); grid.setAdapter(new ImageGridAdapter(getContext(), images)); @@ -209,7 +210,7 @@ public void doWithData(final List jsonElements) { tumblrImages = new ArrayList<>(jsonElements); displayImage(tumblrImages.get(0).getOriginalSize().getUrl()); if (tumblrImages.size() > 1) { - GridView grid = (GridView) findViewById(R.id.grid_area); + GridView grid = findViewById(R.id.grid_area); grid.setNumColumns(5); grid.setVisibility(VISIBLE); grid.setAdapter(new ImageGridAdapter(getContext(), tumblrImages, true)); @@ -319,7 +320,7 @@ public void onDownloadStart(String url, String userAgent, String contentDisposit } private void doLoadReddit(String url) { - RedditItemView v = (RedditItemView) findViewById(R.id.reddit_item); + RedditItemView v = findViewById(R.id.reddit_item); v.loadUrl(this, url, progress); } @@ -356,10 +357,10 @@ public void doLoadImgur(String url) { url = url.substring(0, url.length() - 1); } final String finalUrl = url; - String hash = url.substring(url.lastIndexOf("/"), url.length()); + String hash = url.substring(url.lastIndexOf("/")); if (NetworkUtil.isConnected(getContext())) { - if (hash.startsWith("/")) hash = hash.substring(1, hash.length()); + if (hash.startsWith("/")) hash = hash.substring(1); final String apiUrl = "https://imgur-apiv3.p.mashape.com/3/image/" + hash + ".json"; LogUtil.v(apiUrl); @@ -525,7 +526,7 @@ public void displayImage(final String urlB) { if (!imageShown) { actuallyLoaded = url; final SubsamplingScaleImageView i = - (SubsamplingScaleImageView) findViewById(R.id.submission_image); + findViewById(R.id.submission_image); i.setMinimumDpi(70); i.setMinimumTileDpi(240); @@ -600,12 +601,10 @@ public void onPreviewReleased() { .imageScaleType(ImageScaleType.NONE) .cacheInMemory(false) .build(), new ImageLoadingListener() { - private View mView; @Override public void onLoadingStarted(String imageUri, View view) { imageShown = true; - mView = view; } @Override @@ -651,9 +650,9 @@ public void onProgressUpdate(String imageUri, View view, private void init() { inflate(getContext(), R.layout.peek_media_view, this); - this.image = (SubsamplingScaleImageView) findViewById(R.id.submission_image); + this.image = findViewById(R.id.submission_image); this.videoView = findViewById(R.id.gif); - this.website = (WebView) findViewById(R.id.website); - this.progress = ((ProgressBar) findViewById(R.id.progress)); + this.website = findViewById(R.id.website); + this.progress = findViewById(R.id.progress); } } \ No newline at end of file diff --git a/app/src/main/java/me/ccrama/redditslide/Views/PopMediaView.java b/app/src/main/java/me/ccrama/redditslide/Views/PopMediaView.java index 26606b307a..34f72ecf13 100644 --- a/app/src/main/java/me/ccrama/redditslide/Views/PopMediaView.java +++ b/app/src/main/java/me/ccrama/redditslide/Views/PopMediaView.java @@ -5,13 +5,14 @@ import android.graphics.Bitmap; import android.os.AsyncTask; import android.os.Handler; -import android.text.Html; import android.util.Log; import android.view.View; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.ProgressBar; +import androidx.core.text.HtmlCompat; + import com.google.gson.Gson; import com.google.gson.JsonObject; import com.nostra13.universalimageloader.core.DisplayImageOptions; @@ -67,7 +68,7 @@ public void doPop(View v, String contentUrl, Context c) { mashapeKey = SecretConstants.getImgurApiKey(c); if (contentUrl.contains("reddituploads.com")) { - contentUrl = Html.fromHtml(contentUrl).toString(); + contentUrl = HtmlCompat.fromHtml(contentUrl, HtmlCompat.FROM_HTML_MODE_LEGACY).toString(); } if (contentUrl != null && shouldTruncate(contentUrl)) { contentUrl = contentUrl.substring(0, contentUrl.lastIndexOf(".")); @@ -101,7 +102,7 @@ public void doLoadGif(final String dat, View v) { videoView.clearFocus(); v.findViewById(R.id.submission_image).setVisibility(View.GONE); - final ProgressBar loader = (ProgressBar) v.findViewById(R.id.gifprogress); + final ProgressBar loader = v.findViewById(R.id.gifprogress); v.findViewById(R.id.progress).setVisibility(View.GONE); GifUtils.AsyncLoadGif gif = new GifUtils.AsyncLoadGif(((Activity) v.getContext()), videoView, loader, null, null, false, true, ""); @@ -113,10 +114,10 @@ public void doLoadImgur(String url, final View v) { url = url.substring(0, url.length() - 1); } final String finalUrl = url; - String hash = url.substring(url.lastIndexOf("/"), url.length()); + String hash = url.substring(url.lastIndexOf("/")); if (NetworkUtil.isConnected(v.getContext())) { - if (hash.startsWith("/")) hash = hash.substring(1, hash.length()); + if (hash.startsWith("/")) hash = hash.substring(1); final String apiUrl = "https://imgur-apiv3.p.mashape.com/3/image/" + hash + ".json"; LogUtil.v(apiUrl); @@ -270,11 +271,11 @@ protected void onPostExecute(Void aVoid) { } public void displayImage(final String url, final View v) { - final SubsamplingScaleImageView i = (SubsamplingScaleImageView) v.findViewById(R.id.submission_image); + final SubsamplingScaleImageView i = v.findViewById(R.id.submission_image); i.setMinimumDpi(70); i.setMinimumTileDpi(240); - final ProgressBar bar = (ProgressBar) v.findViewById(R.id.progress); + final ProgressBar bar = v.findViewById(R.id.progress); bar.setIndeterminate(false); bar.setProgress(0); @@ -307,11 +308,9 @@ public void run() { .imageScaleType(ImageScaleType.NONE) .cacheInMemory(false) .build(), new ImageLoadingListener() { - private View mView; @Override public void onLoadingStarted(String imageUri, View view) { - mView = view; } @Override diff --git a/app/src/main/java/me/ccrama/redditslide/Views/RedditItemView.java b/app/src/main/java/me/ccrama/redditslide/Views/RedditItemView.java index db67bc04a5..5aa64d4561 100644 --- a/app/src/main/java/me/ccrama/redditslide/Views/RedditItemView.java +++ b/app/src/main/java/me/ccrama/redditslide/Views/RedditItemView.java @@ -7,7 +7,6 @@ import android.graphics.Typeface; import android.net.Uri; import android.os.AsyncTask; -import android.text.Html; import android.text.SpannableStringBuilder; import android.text.Spanned; import android.text.style.ForegroundColorSpan; @@ -24,6 +23,7 @@ import android.widget.TextView; import androidx.appcompat.widget.AppCompatCheckBox; +import androidx.core.text.HtmlCompat; import com.devspark.robototextview.RobotoTypefaces; @@ -184,7 +184,7 @@ protected void onPostExecute(Account account) { private void doUser(Account account, View content) { String name = account.getFullName(); - final TextView title = (TextView) content.findViewById(R.id.title); + final TextView title = content.findViewById(R.id.title); title.setText(name); final int currentColor = Palette.getColorUser(name); @@ -236,9 +236,8 @@ protected void onPostExecute(Subreddit subreddit) { } private void doSidebar(Subreddit subreddit, View content) { - if ((!Authentication.isLoggedIn && UserSubscriptions.getSubscriptions(getContext()) - .contains(subreddit.getDisplayName().toLowerCase(Locale.ENGLISH))) || (Authentication.isLoggedIn - && subreddit.isUserSubscriber())) { + if (Authentication.isLoggedIn ? subreddit.isUserSubscriber() : UserSubscriptions.getSubscriptions(getContext()) + .contains(subreddit.getDisplayName().toLowerCase(Locale.ENGLISH))) { ((AppCompatCheckBox) content.findViewById(R.id.subscribed)).setChecked(true); } content.findViewById(R.id.header_sub) @@ -248,8 +247,8 @@ private void doSidebar(Subreddit subreddit, View content) { content.findViewById(R.id.sub_title).setVisibility(View.VISIBLE); setViews(subreddit.getDataNode().get("public_description_html").asText(), subreddit.getDisplayName().toLowerCase(Locale.ENGLISH), - ((SpoilerRobotoTextView) content.findViewById(R.id.sub_title)), - (CommentOverflow) content.findViewById(R.id.sub_title_overflow)); + content.findViewById(R.id.sub_title), + content.findViewById(R.id.sub_title_overflow)); } else { content.findViewById(R.id.sub_title).setVisibility(View.GONE); } @@ -421,7 +420,7 @@ public void doComment(Comment comment, View content) { } holder.content.setTypeface(typeface); - if (comment.getTimesSilvered() > 0 || comment.getTimesGilded() > 0 || comment.getTimesPlatinized() > 0) { + if (!SettingValues.hideCommentAwards && (comment.getTimesSilvered() > 0 || comment.getTimesGilded() > 0 || comment.getTimesPlatinized() > 0)) { TypedArray a = getContext().obtainStyledAttributes( new FontPreferences(getContext()).getPostFontStyle().getResId(), R.styleable.FontStyle); @@ -480,9 +479,9 @@ public void doComment(Comment comment, View content) { } if (comment.getSubmissionTitle() != null) { - holder.title.setText(Html.fromHtml(comment.getSubmissionTitle())); + holder.title.setText(HtmlCompat.fromHtml(comment.getSubmissionTitle(), HtmlCompat.FROM_HTML_MODE_LEGACY)); } else { - holder.title.setText(Html.fromHtml(comment.getAuthor())); + holder.title.setText(HtmlCompat.fromHtml(comment.getAuthor(), HtmlCompat.FROM_HTML_MODE_LEGACY)); } } @@ -527,7 +526,7 @@ private void setViews(String rawHTML, String subreddit, SpoilerRobotoTextView fi } else { commentOverflow.setViews(blocks.subList(startIndex, blocks.size()), subreddit); } - SidebarLayout sidebar = (SidebarLayout) findViewById(R.id.drawer_layout); + SidebarLayout sidebar = findViewById(R.id.drawer_layout); for (int i = 0; i < commentOverflow.getChildCount(); i++) { View maybeScrollable = commentOverflow.getChildAt(i); if (maybeScrollable instanceof HorizontalScrollView) { @@ -569,4 +568,4 @@ private void setViews(String rawHTML, String subredditName, ProfileCommentViewHo } -} \ No newline at end of file +} diff --git a/app/src/main/java/me/ccrama/redditslide/Views/SubsamplingScaleImageView.java b/app/src/main/java/me/ccrama/redditslide/Views/SubsamplingScaleImageView.java index d07bd45b60..dddc49cf8d 100644 --- a/app/src/main/java/me/ccrama/redditslide/Views/SubsamplingScaleImageView.java +++ b/app/src/main/java/me/ccrama/redditslide/Views/SubsamplingScaleImageView.java @@ -35,6 +35,7 @@ import androidx.annotation.Nullable; import androidx.exifinterface.media.ExifInterface; import androidx.interpolator.view.animation.FastOutSlowInInterpolator; +import me.ccrama.redditslide.SettingValues; import com.davemorrissey.labs.subscaleview.ImageViewState; import com.davemorrissey.labs.subscaleview.R.styleable; @@ -267,8 +268,9 @@ public class SubsamplingScaleImageView extends View { // Tile and image decoding private ImageRegionDecoder decoder; private final ReadWriteLock decoderLock = new ReentrantReadWriteLock(true); - private DecoderFactory bitmapDecoderFactory = new CompatDecoderFactory(SkiaImageDecoder.class); - private DecoderFactory regionDecoderFactory = new CompatDecoderFactory(SkiaImageRegionDecoder.class); + private DecoderFactory bitmapDecoderFactory = new CompatDecoderFactory(SkiaImageDecoder.class, + SettingValues.highColorspaceImages ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565); + private DecoderFactory regionDecoderFactory = new CompatDecoderFactory(SkiaImageRegionDecoder.class, SettingValues.highColorspaceImages ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565); // Debug values private PointF vCenterStart; @@ -616,8 +618,8 @@ private void setGestureDetector(final Context context) { public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { if (panEnabled && readySent && vTranslate != null && e1 != null && e2 != null && (Math.abs(e1.getX() - e2.getX()) > 50 || Math.abs(e1.getY() - e2.getY()) > 50) && (Math.abs(velocityX) > 500 || Math.abs(velocityY) > 500) && !isZooming) { PointF vTranslateEnd = new PointF(vTranslate.x + (velocityX * 0.25f), vTranslate.y + (velocityY * 0.25f)); - float sCenterXEnd = ((getWidth() / 2) - vTranslateEnd.x) / scale; - float sCenterYEnd = ((getHeight() / 2) - vTranslateEnd.y) / scale; + float sCenterXEnd = ((getWidth() / 2.0f) - vTranslateEnd.x) / scale; + float sCenterYEnd = ((getHeight() / 2.0f) - vTranslateEnd.y) / scale; new AnimationBuilder(new PointF(sCenterXEnd, sCenterYEnd)).withEasing(EASE_OUT_QUAD).withPanLimited(false).withOrigin(ORIGIN_FLING).start(); return true; } @@ -840,12 +842,12 @@ private boolean onTouchEventInternal(@NonNull MotionEvent event) { } } else if (sRequestedCenter != null) { // With a center specified from code, zoom around that point. - vTranslate.x = (getWidth() / 2) - (scale * sRequestedCenter.x); - vTranslate.y = (getHeight() / 2) - (scale * sRequestedCenter.y); + vTranslate.x = (getWidth() / 2.0f) - (scale * sRequestedCenter.x); + vTranslate.y = (getHeight() / 2.0f) - (scale * sRequestedCenter.y); } else { // With no requested center, scale around the image center. - vTranslate.x = (getWidth() / 2) - (scale * (sWidth() / 2)); - vTranslate.y = (getHeight() / 2) - (scale * (sHeight() / 2)); + vTranslate.x = (getWidth() / 2.0f) - (scale * (sWidth() / 2.0f)); + vTranslate.y = (getHeight() / 2.0f) - (scale * (sHeight() / 2.0f)); } fitToBounds(true); @@ -891,12 +893,12 @@ private boolean onTouchEventInternal(@NonNull MotionEvent event) { } } else if (sRequestedCenter != null) { // With a center specified from code, zoom around that point. - vTranslate.x = (getWidth() / 2) - (scale * sRequestedCenter.x); - vTranslate.y = (getHeight() / 2) - (scale * sRequestedCenter.y); + vTranslate.x = (getWidth() / 2.0f) - (scale * sRequestedCenter.x); + vTranslate.y = (getHeight() / 2.0f) - (scale * sRequestedCenter.y); } else { // With no requested center, scale around the image center. - vTranslate.x = (getWidth() / 2) - (scale * (sWidth() / 2)); - vTranslate.y = (getHeight() / 2) - (scale * (sHeight() / 2)); + vTranslate.x = (getWidth() / 2.0f) - (scale * (sWidth() / 2.0f)); + vTranslate.y = (getHeight() / 2.0f) - (scale * (sHeight() / 2.0f)); } } @@ -1015,8 +1017,8 @@ private void doubleTapZoom(PointF sCenter, PointF vFocus) { sCenter.y = sRequestedCenter.y; } else { // With no requested center, scale around the image center. - sCenter.x = sWidth() / 2; - sCenter.y = sHeight() / 2; + sCenter.x = sWidth() / 2.0f; + sCenter.y = sHeight() / 2.0f; } } float doubleTapZoomScale = Math.min(maxScale, SubsamplingScaleImageView.this.doubleTapZoomScale); @@ -1155,7 +1157,7 @@ protected void onDraw(Canvas canvas) { } } - } else if (bitmap != null) { + } else if (bitmap != null && !bitmap.isRecycled()) { float xScale = scale, yScale = scale; if (bitmapIsPreview) { @@ -1210,7 +1212,7 @@ protected void onDraw(Canvas canvas) { //noinspection ConstantConditions canvas.drawCircle(vCenterEnd.x, vCenterEnd.y, px(25), debugLinePaint); debugLinePaint.setColor(Color.CYAN); - canvas.drawCircle(getWidth() / 2, getHeight() / 2, px(30), debugLinePaint); + canvas.drawCircle(getWidth() / 2.0f, getHeight() / 2.0f, px(30), debugLinePaint); } if (vCenterStart != null) { debugLinePaint.setColor(Color.RED); @@ -1434,8 +1436,8 @@ private void preDraw() { if (vTranslate == null) { vTranslate = new PointF(); } - vTranslate.x = (getWidth() / 2) - (scale * sPendingCenter.x); - vTranslate.y = (getHeight() / 2) - (scale * sPendingCenter.y); + vTranslate.x = (getWidth() / 2.0f) - (scale * sPendingCenter.x); + vTranslate.y = (getHeight() / 2.0f) - (scale * sPendingCenter.y); sPendingCenter = null; pendingScale = null; fitToBounds(true); @@ -1505,8 +1507,8 @@ private void fitToBounds(boolean center, ScaleAndTranslate sat) { float scaleHeight = scale * sHeight(); if (panLimit == PAN_LIMIT_CENTER && isReady()) { - vTranslate.x = Math.max(vTranslate.x, getWidth() / 2 - scaleWidth); - vTranslate.y = Math.max(vTranslate.y, getHeight() / 2 - scaleHeight); + vTranslate.x = Math.max(vTranslate.x, getWidth() / 2.0f - scaleWidth); + vTranslate.y = Math.max(vTranslate.y, getHeight() / 2.0f - scaleHeight); } else if (center) { vTranslate.x = Math.max(vTranslate.x, getWidth() - scaleWidth); vTranslate.y = Math.max(vTranslate.y, getHeight() - scaleHeight); @@ -1559,7 +1561,7 @@ private void fitToBounds(boolean center) { scale = satTemp.scale; vTranslate.set(satTemp.vTranslate); if (init && minimumScaleType != SCALE_TYPE_START) { - vTranslate.set(vTranslateForSCenter(sWidth() / 2, sHeight() / 2, scale)); + vTranslate.set(vTranslateForSCenter(sWidth() / 2.0f, sHeight() / 2.0f, scale)); } } @@ -2544,10 +2546,10 @@ public final void getPanRemaining(RectF vTarget) { float scaleHeight = scale * sHeight(); if (panLimit == PAN_LIMIT_CENTER) { - vTarget.top = Math.max(0, -(vTranslate.y - (getHeight() / 2))); - vTarget.left = Math.max(0, -(vTranslate.x - (getWidth() / 2))); - vTarget.bottom = Math.max(0, vTranslate.y - ((getHeight() / 2) - scaleHeight)); - vTarget.right = Math.max(0, vTranslate.x - ((getWidth() / 2) - scaleWidth)); + vTarget.top = Math.max(0, -(vTranslate.y - (getHeight() / 2.0f))); + vTarget.left = Math.max(0, -(vTranslate.x - (getWidth() / 2.0f))); + vTarget.bottom = Math.max(0, vTranslate.y - ((getHeight() / 2.0f) - scaleHeight)); + vTarget.right = Math.max(0, vTranslate.x - ((getWidth() / 2.0f) - scaleWidth)); } else if (panLimit == PAN_LIMIT_OUTSIDE) { vTarget.top = Math.max(0, -(vTranslate.y - getHeight())); vTarget.left = Math.max(0, -(vTranslate.x - getWidth())); @@ -2712,7 +2714,7 @@ public final void resetScaleAndCenter() { this.anim = null; this.pendingScale = limitedScale(0); if (isReady()) { - this.sPendingCenter = new PointF(sWidth() / 2, sHeight() / 2); + this.sPendingCenter = new PointF(sWidth() / 2.0f, sHeight() / 2.0f); } else { this.sPendingCenter = new PointF(0, 0); } @@ -2855,8 +2857,8 @@ public final boolean isPanEnabled() { public final void setPanEnabled(boolean panEnabled) { this.panEnabled = panEnabled; if (!panEnabled && vTranslate != null) { - vTranslate.x = (getWidth() / 2) - (scale * (sWidth() / 2)); - vTranslate.y = (getHeight() / 2) - (scale * (sHeight() / 2)); + vTranslate.x = (getWidth() / 2.0f) - (scale * (sWidth() / 2.0f)); + vTranslate.y = (getHeight() / 2.0f) - (scale * (sHeight() / 2.0f)); if (isReady()) { refreshRequiredTiles(true); invalidate(); diff --git a/app/src/main/java/me/ccrama/redditslide/Views/ToggleSwipeViewPager.java b/app/src/main/java/me/ccrama/redditslide/Views/ToggleSwipeViewPager.java index d6d0acd632..b82153636a 100644 --- a/app/src/main/java/me/ccrama/redditslide/Views/ToggleSwipeViewPager.java +++ b/app/src/main/java/me/ccrama/redditslide/Views/ToggleSwipeViewPager.java @@ -35,7 +35,7 @@ public boolean onTouchEvent(MotionEvent ev) { public boolean onInterceptTouchEvent(MotionEvent ev) { if (ev.getAction() == MotionEvent.ACTION_UP) { if (mSwipeDisabledUntilRelease) { - setSwipingEnabled(true); + mEnableSwiping = true; mSwipeDisabledUntilRelease = false; } } @@ -56,8 +56,8 @@ public void setSwipingEnabled(boolean enabled) { } public void disableSwipingUntilRelease() { - setSwipingEnabled(false); + mEnableSwiping = false; mSwipeDisabledUntilRelease = true; } -} \ No newline at end of file +} diff --git a/app/src/main/java/me/ccrama/redditslide/Views/TransparentTagTextView.java b/app/src/main/java/me/ccrama/redditslide/Views/TransparentTagTextView.java index 1386c936cf..419a1132f9 100644 --- a/app/src/main/java/me/ccrama/redditslide/Views/TransparentTagTextView.java +++ b/app/src/main/java/me/ccrama/redditslide/Views/TransparentTagTextView.java @@ -9,14 +9,15 @@ import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; import android.util.AttributeSet; -import android.widget.TextView; + +import androidx.appcompat.widget.AppCompatTextView; import me.ccrama.redditslide.R; /** * Created by carlos on 3/14/16. */ -public class TransparentTagTextView extends TextView { +public class TransparentTagTextView extends AppCompatTextView { Bitmap mMaskBitmap; Canvas mMaskCanvas; Paint mPaint; diff --git a/app/src/main/java/me/ccrama/redditslide/Vote.java b/app/src/main/java/me/ccrama/redditslide/Vote.java index aee1a67502..977c143860 100644 --- a/app/src/main/java/me/ccrama/redditslide/Vote.java +++ b/app/src/main/java/me/ccrama/redditslide/Vote.java @@ -53,7 +53,7 @@ public void run() { if (v != null && c != null && v.getContext() != null) { Snackbar s = Snackbar.make(v, R.string.vote_err, Snackbar.LENGTH_SHORT); View view = s.getView(); - TextView tv = (TextView) view.findViewById(com.google.android.material.R.id.snackbar_text); + TextView tv = view.findViewById(com.google.android.material.R.id.snackbar_text); tv.setTextColor(Color.WHITE); s.show(); } @@ -73,7 +73,7 @@ public void run() { if (v != null && c != null && v.getContext() != null) { Snackbar s = Snackbar.make(v, R.string.vote_err_login, Snackbar.LENGTH_SHORT); View view = s.getView(); - TextView tv = (TextView) view.findViewById(com.google.android.material.R.id.snackbar_text); + TextView tv = view.findViewById(com.google.android.material.R.id.snackbar_text); tv.setTextColor(Color.WHITE); s.show(); diff --git a/app/src/main/java/me/ccrama/redditslide/Widget/ListViewRemoteViewsFactory.java b/app/src/main/java/me/ccrama/redditslide/Widget/ListViewRemoteViewsFactory.java new file mode 100644 index 0000000000..d0333c2242 --- /dev/null +++ b/app/src/main/java/me/ccrama/redditslide/Widget/ListViewRemoteViewsFactory.java @@ -0,0 +1,302 @@ +package me.ccrama.redditslide.Widget; + +import android.appwidget.AppWidgetManager; +import android.content.Context; +import android.content.Intent; +import android.graphics.Color; +import android.os.AsyncTask; +import android.os.Bundle; +import android.view.View; +import android.widget.RemoteViews; +import android.widget.RemoteViewsService; + +import androidx.core.text.HtmlCompat; + +import net.dean.jraw.models.Submission; +import net.dean.jraw.models.Thumbnails; +import net.dean.jraw.paginators.DomainPaginator; +import net.dean.jraw.paginators.Paginator; +import net.dean.jraw.paginators.Sorting; +import net.dean.jraw.paginators.SubredditPaginator; +import net.dean.jraw.paginators.TimePeriod; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Set; + +import me.ccrama.redditslide.Activities.OpenContent; +import me.ccrama.redditslide.Authentication; +import me.ccrama.redditslide.Autocache.AutoCacheScheduler; +import me.ccrama.redditslide.Notifications.NotificationJobScheduler; +import me.ccrama.redditslide.PostMatch; +import me.ccrama.redditslide.R; +import me.ccrama.redditslide.Reddit; +import me.ccrama.redditslide.TimeUtils; +import me.ccrama.redditslide.Visuals.Palette; +import me.ccrama.redditslide.util.LogUtil; +import me.ccrama.redditslide.util.NetworkUtil; + +public class ListViewRemoteViewsFactory implements RemoteViewsService.RemoteViewsFactory { + String subreddit; + int id; + private Context mContext; + private ArrayList records; + + public ListViewRemoteViewsFactory(Context context, Intent intent, String subreddit, int id) { + mContext = context; + this.subreddit = subreddit; + this.id = id; + } + + // Initialize the data set. + public void onCreate() { + // In onCreate() you set up any connections / cursors to your data source. Heavy lifting, + // for example downloading or creating content etc, should be deferred to onDataSetChanged() + // or getViewAt(). Taking more than 20 seconds in this call will result in an ANR. + records = new ArrayList<>(); + if (NetworkUtil.isConnected(mContext)) { + new AsyncTask() { + @Override + protected Void doInBackground(Void... params) { + if (Authentication.reddit == null) { + new Authentication(mContext.getApplicationContext()); + Authentication.me = Authentication.reddit.me(); + Authentication.mod = Authentication.me.isMod(); + + Authentication.authentication.edit() + .putBoolean(Reddit.SHARED_PREF_IS_MOD, Authentication.mod) + .apply(); + + if (Reddit.notificationTime != -1) { + Reddit.notifications = new NotificationJobScheduler(mContext); + Reddit.notifications.start(mContext.getApplicationContext()); + } + + if (Reddit.cachedData.contains("toCache")) { + Reddit.autoCache = new AutoCacheScheduler(mContext); + Reddit.autoCache.start(mContext.getApplicationContext()); + } + + final String name = Authentication.me.getFullName(); + Authentication.name = name; + LogUtil.v("AUTHENTICATED"); + + if (Authentication.reddit.isAuthenticated()) { + final Set accounts = + Authentication.authentication.getStringSet("accounts", + new HashSet()); + if (accounts.contains(name)) { //convert to new system + accounts.remove(name); + accounts.add(name + ":" + Authentication.refresh); + Authentication.authentication.edit() + .putStringSet("accounts", accounts) + .apply(); //force commit + } + Authentication.isLoggedIn = true; + Reddit.notFirst = true; + } + } + String sub = SubredditWidgetProvider.getSubFromId(id, mContext); + Paginator p; + if (sub.equals("frontpage")) { + p = new SubredditPaginator(Authentication.reddit); + } else if (!sub.contains(".")) { + p = new SubredditPaginator(Authentication.reddit, sub); + } else { + p = new DomainPaginator(Authentication.reddit, sub); + } + p.setLimit(50); + switch (SubredditWidgetProvider.getSorting(id, mContext)) { + case 0: + p.setSorting(Sorting.HOT); + break; + case 1: + p.setSorting(Sorting.NEW); + break; + case 2: + p.setSorting(Sorting.RISING); + break; + case 3: + p.setSorting(Sorting.TOP); + break; + case 4: + p.setSorting(Sorting.CONTROVERSIAL); + break; + case 5: + p.setSorting(Sorting.BEST); + break; + } + switch (SubredditWidgetProvider.getSortingTime(id, mContext)) { + case 0: + p.setTimePeriod(TimePeriod.HOUR); + break; + case 1: + p.setTimePeriod(TimePeriod.DAY); + break; + case 2: + p.setTimePeriod(TimePeriod.WEEK); + break; + case 3: + p.setTimePeriod(TimePeriod.MONTH); + break; + case 4: + p.setTimePeriod(TimePeriod.YEAR); + break; + case 5: + p.setTimePeriod(TimePeriod.ALL); + break; + } + + try { + ArrayList s = new ArrayList<>(p.next()); + records = new ArrayList<>(); + for (Submission subm : s) { + if (!PostMatch.doesMatch(subm) && !subm.isStickied()) { + records.add(subm); + } + } + } catch (Exception e) { + + } + return null; + } + + @Override + protected void onPostExecute(Void aVoid) { + Intent widgetUpdateIntent = new Intent(mContext, SubredditWidgetProvider.class); + widgetUpdateIntent.setAction(SubredditWidgetProvider.UPDATE_MEETING_ACTION); + widgetUpdateIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, id); + mContext.sendBroadcast(widgetUpdateIntent); + } + }.execute(); + } else { + Intent widgetUpdateIntent = new Intent(mContext, SubredditWidgetProvider.class); + widgetUpdateIntent.setAction(SubredditWidgetProvider.UPDATE_MEETING_ACTION); + widgetUpdateIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, id); + mContext.sendBroadcast(widgetUpdateIntent); + } + } + + // Given the position (index) of a WidgetItem in the array, use the item's text value in + // combination with the app widget item XML file to construct a RemoteViews object. + public RemoteViews getViewAt(int position) { + // position will always range from 0 to getCount() - 1. + // Construct a RemoteViews item based on the app widget item XML file, and set the + // text based on the position. + int view = R.layout.submission_widget_light; + switch (SubredditWidgetProvider.getViewType(id, mContext)) { + case 1: + case 0: + if (SubredditWidgetProvider.getThemeFromId(id, mContext) == 2) { + view = R.layout.submission_widget_light; + } else { + view = R.layout.submission_widget; + } + + break; + case 2: + if (SubredditWidgetProvider.getThemeFromId(id, mContext) == 2) { + view = R.layout.submission_widget_compact_light; + } else { + view = R.layout.submission_widget_compact; + } + break; + } + final RemoteViews rv = new RemoteViews(mContext.getPackageName(), view); + try { + + // feed row + Submission data = records.get(position); + + rv.setTextViewText(R.id.title, HtmlCompat.fromHtml(data.getTitle(), HtmlCompat.FROM_HTML_MODE_LEGACY)); + rv.setTextViewText(R.id.score, data.getScore() + ""); + rv.setTextViewText(R.id.comments, data.getCommentCount() + ""); + rv.setTextViewText(R.id.information, + data.getAuthor() + " " + TimeUtils.getTimeAgo(data.getCreated().getTime(), + mContext)); + rv.setTextViewText(R.id.subreddit, data.getSubredditName()); + rv.setTextColor(R.id.subreddit, Palette.getColor(data.getSubredditName())); + if (SubredditWidgetProvider.getViewType(id, mContext) == 1) { + Thumbnails s = data.getThumbnails(); + rv.setViewVisibility(R.id.thumbimage2, View.GONE); + if (s != null && s.getVariations() != null && s.getSource() != null) { + rv.setImageViewBitmap(R.id.bigpic, + ((Reddit) mContext.getApplicationContext()).getImageLoader() + .loadImageSync( + HtmlCompat.fromHtml(data.getThumbnails().getSource().getUrl(), + HtmlCompat.FROM_HTML_MODE_LEGACY).toString())); + rv.setViewVisibility(R.id.bigpic, View.VISIBLE); + } else { + rv.setViewVisibility(R.id.bigpic, View.GONE); + } + } else { + if (SubredditWidgetProvider.getViewType(id, mContext) != 2) { + rv.setViewVisibility(R.id.bigpic, View.GONE); + } + if (data.getThumbnailType() == Submission.ThumbnailType.URL) { + rv.setImageViewBitmap(R.id.thumbimage2, + ((Reddit) mContext.getApplicationContext()).getImageLoader() + .loadImageSync(data.getThumbnail())); + rv.setViewVisibility(R.id.thumbimage2, View.VISIBLE); + } else { + rv.setViewVisibility(R.id.thumbimage2, View.GONE); + } + } + switch (SubredditWidgetProvider.getViewType(id, mContext)) { + case 1: + case 0: + case 2: + if (SubredditWidgetProvider.getThemeFromId(id, mContext) == 2) { + } else { + rv.setTextColor(R.id.title, Color.WHITE); + rv.setTextColor(R.id.score, Color.WHITE); + rv.setTextColor(R.id.comments, Color.WHITE); + rv.setTextColor(R.id.information, Color.WHITE); + } + + break; + } + + Bundle infos = new Bundle(); + infos.putString(OpenContent.EXTRA_URL, data.getPermalink()); + infos.putBoolean("popup", true); + final Intent activityIntent = new Intent(); + activityIntent.putExtras(infos); + activityIntent.setAction(data.getTitle()); + rv.setOnClickFillInIntent(R.id.card, activityIntent); + } catch (Exception e) { + + } + return rv; + } + + public int getCount() { + return records.size(); + } + + + public void onDataSetChanged() { + + // Fetching JSON data from server and add them to records arraylist + } + + public int getViewTypeCount() { + return 1; + } + + public long getItemId(int position) { + return position; + } + + public void onDestroy() { + records.clear(); + } + + public boolean hasStableIds() { + return true; + } + + public RemoteViews getLoadingView() { + return null; + } +} diff --git a/app/src/main/java/me/ccrama/redditslide/Widget/ListViewWidgetService.java b/app/src/main/java/me/ccrama/redditslide/Widget/ListViewWidgetService.java index 4e707e3b0d..d5d192bb8e 100644 --- a/app/src/main/java/me/ccrama/redditslide/Widget/ListViewWidgetService.java +++ b/app/src/main/java/me/ccrama/redditslide/Widget/ListViewWidgetService.java @@ -1,312 +1,15 @@ package me.ccrama.redditslide.Widget; import android.appwidget.AppWidgetManager; -import android.content.Context; import android.content.Intent; -import android.graphics.Color; -import android.os.AsyncTask; -import android.os.Bundle; -import android.text.Html; -import android.view.View; -import android.widget.RemoteViews; import android.widget.RemoteViewsService; -import net.dean.jraw.models.Submission; -import net.dean.jraw.models.Thumbnails; -import net.dean.jraw.paginators.DomainPaginator; -import net.dean.jraw.paginators.Paginator; -import net.dean.jraw.paginators.Sorting; -import net.dean.jraw.paginators.SubredditPaginator; -import net.dean.jraw.paginators.TimePeriod; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.Set; - -import me.ccrama.redditslide.Activities.OpenContent; -import me.ccrama.redditslide.Authentication; -import me.ccrama.redditslide.Autocache.AutoCacheScheduler; -import me.ccrama.redditslide.Notifications.NotificationJobScheduler; -import me.ccrama.redditslide.PostMatch; -import me.ccrama.redditslide.R; -import me.ccrama.redditslide.Reddit; -import me.ccrama.redditslide.TimeUtils; -import me.ccrama.redditslide.Visuals.Palette; -import me.ccrama.redditslide.util.LogUtil; -import me.ccrama.redditslide.util.NetworkUtil; - /** * Created by carlo_000 on 5/4/2016. */ public class ListViewWidgetService extends RemoteViewsService { - public RemoteViewsService.RemoteViewsFactory onGetViewFactory(Intent intent) { + public RemoteViewsFactory onGetViewFactory(Intent intent) { return new ListViewRemoteViewsFactory(this.getApplicationContext(), intent, "android", intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, 0)); } } - -class ListViewRemoteViewsFactory implements RemoteViewsService.RemoteViewsFactory { - private Context mContext; - private ArrayList records; - String subreddit; - int id; - - public ListViewRemoteViewsFactory(Context context, Intent intent, String subreddit, int id) { - mContext = context; - this.subreddit = subreddit; - this.id = id; - } - - // Initialize the data set. - public void onCreate() { - // In onCreate() you set up any connections / cursors to your data source. Heavy lifting, - // for example downloading or creating content etc, should be deferred to onDataSetChanged() - // or getViewAt(). Taking more than 20 seconds in this call will result in an ANR. - records = new ArrayList<>(); - if (NetworkUtil.isConnected(mContext)) { - new AsyncTask() { - @Override - protected Void doInBackground(Void... params) { - if (Authentication.reddit == null) { - new Authentication(mContext.getApplicationContext()); - Authentication.me = Authentication.reddit.me(); - Authentication.mod = Authentication.me.isMod(); - - Authentication.authentication.edit() - .putBoolean(Reddit.SHARED_PREF_IS_MOD, Authentication.mod) - .apply(); - - if (Reddit.notificationTime != -1) { - Reddit.notifications = new NotificationJobScheduler(mContext); - Reddit.notifications.start(mContext.getApplicationContext()); - } - - if (Reddit.cachedData.contains("toCache")) { - Reddit.autoCache = new AutoCacheScheduler(mContext); - Reddit.autoCache.start(mContext.getApplicationContext()); - } - - final String name = Authentication.me.getFullName(); - Authentication.name = name; - LogUtil.v("AUTHENTICATED"); - - if (Authentication.reddit.isAuthenticated()) { - final Set accounts = - Authentication.authentication.getStringSet("accounts", - new HashSet()); - if (accounts.contains(name)) { //convert to new system - accounts.remove(name); - accounts.add(name + ":" + Authentication.refresh); - Authentication.authentication.edit() - .putStringSet("accounts", accounts) - .apply(); //force commit - } - Authentication.isLoggedIn = true; - Reddit.notFirst = true; - } - } - String sub = SubredditWidgetProvider.getSubFromId(id, mContext); - Paginator p; - if (sub.equals("frontpage")) { - p = new SubredditPaginator(Authentication.reddit); - } else if (!sub.contains(".")) { - p = new SubredditPaginator(Authentication.reddit, sub); - } else { - p = new DomainPaginator(Authentication.reddit, sub); - } - p.setLimit(50); - switch (SubredditWidgetProvider.getSorting(id, mContext)) { - case 0: - p.setSorting(Sorting.HOT); - break; - case 1: - p.setSorting(Sorting.NEW); - break; - case 2: - p.setSorting(Sorting.RISING); - break; - case 3: - p.setSorting(Sorting.TOP); - break; - case 4: - p.setSorting(Sorting.CONTROVERSIAL); - break; - case 5: - p.setSorting(Sorting.BEST); - break; - } - switch (SubredditWidgetProvider.getSortingTime(id, mContext)) { - case 0: - p.setTimePeriod(TimePeriod.HOUR); - break; - case 1: - p.setTimePeriod(TimePeriod.DAY); - break; - case 2: - p.setTimePeriod(TimePeriod.WEEK); - break; - case 3: - p.setTimePeriod(TimePeriod.MONTH); - break; - case 4: - p.setTimePeriod(TimePeriod.YEAR); - break; - case 5: - p.setTimePeriod(TimePeriod.ALL); - break; - } - - try { - ArrayList s = new ArrayList<>(p.next()); - records = new ArrayList<>(); - for (Submission subm : s) { - if (!PostMatch.doesMatch(subm) && !subm.isStickied()) { - records.add(subm); - } - } - } catch (Exception e) { - - } - return null; - } - - @Override - protected void onPostExecute(Void aVoid) { - Intent widgetUpdateIntent = new Intent(mContext, SubredditWidgetProvider.class); - widgetUpdateIntent.setAction(SubredditWidgetProvider.UPDATE_MEETING_ACTION); - widgetUpdateIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, id); - mContext.sendBroadcast(widgetUpdateIntent); - } - }.execute(); - } else { - Intent widgetUpdateIntent = new Intent(mContext, SubredditWidgetProvider.class); - widgetUpdateIntent.setAction(SubredditWidgetProvider.UPDATE_MEETING_ACTION); - widgetUpdateIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, id); - mContext.sendBroadcast(widgetUpdateIntent); - } - } - - // Given the position (index) of a WidgetItem in the array, use the item's text value in - // combination with the app widget item XML file to construct a RemoteViews object. - public RemoteViews getViewAt(int position) { - // position will always range from 0 to getCount() - 1. - // Construct a RemoteViews item based on the app widget item XML file, and set the - // text based on the position. - int view = R.layout.submission_widget_light; - switch (SubredditWidgetProvider.getViewType(id, mContext)) { - case 1: - case 0: - if (SubredditWidgetProvider.getThemeFromId(id, mContext) == 2) { - view = R.layout.submission_widget_light; - } else { - view = R.layout.submission_widget; - } - - break; - case 2: - if (SubredditWidgetProvider.getThemeFromId(id, mContext) == 2) { - view = R.layout.submission_widget_compact_light; - } else { - view = R.layout.submission_widget_compact; - } - break; - } - final RemoteViews rv = new RemoteViews(mContext.getPackageName(), view); - try { - - // feed row - Submission data = records.get(position); - - rv.setTextViewText(R.id.title, Html.fromHtml(data.getTitle())); - rv.setTextViewText(R.id.score, data.getScore() + ""); - rv.setTextViewText(R.id.comments, data.getCommentCount() + ""); - rv.setTextViewText(R.id.information, - data.getAuthor() + " " + TimeUtils.getTimeAgo(data.getCreated().getTime(), - mContext)); - rv.setTextViewText(R.id.subreddit, data.getSubredditName()); - rv.setTextColor(R.id.subreddit, Palette.getColor(data.getSubredditName())); - if (SubredditWidgetProvider.getViewType(id, mContext) == 1) { - Thumbnails s = data.getThumbnails(); - rv.setViewVisibility(R.id.thumbimage2, View.GONE); - if (s != null && s.getVariations() != null && s.getSource() != null) { - rv.setImageViewBitmap(R.id.bigpic, - ((Reddit) mContext.getApplicationContext()).getImageLoader() - .loadImageSync( - Html.fromHtml(data.getThumbnails().getSource().getUrl()) - .toString())); - rv.setViewVisibility(R.id.bigpic, View.VISIBLE); - } else { - rv.setViewVisibility(R.id.bigpic, View.GONE); - } - } else { - if (SubredditWidgetProvider.getViewType(id, mContext) != 2) { - rv.setViewVisibility(R.id.bigpic, View.GONE); - } - if (data.getThumbnailType() == Submission.ThumbnailType.URL) { - rv.setImageViewBitmap(R.id.thumbimage2, - ((Reddit) mContext.getApplicationContext()).getImageLoader() - .loadImageSync(data.getThumbnail())); - rv.setViewVisibility(R.id.thumbimage2, View.VISIBLE); - } else { - rv.setViewVisibility(R.id.thumbimage2, View.GONE); - } - } - switch (SubredditWidgetProvider.getViewType(id, mContext)) { - case 1: - case 0: - case 2: - if (SubredditWidgetProvider.getThemeFromId(id, mContext) == 2) { - } else { - rv.setTextColor(R.id.title, Color.WHITE); - rv.setTextColor(R.id.score, Color.WHITE); - rv.setTextColor(R.id.comments, Color.WHITE); - rv.setTextColor(R.id.information, Color.WHITE); - } - - break; - } - - Bundle infos = new Bundle(); - infos.putString(OpenContent.EXTRA_URL, data.getPermalink()); - infos.putBoolean("popup", true); - final Intent activityIntent = new Intent(); - activityIntent.putExtras(infos); - activityIntent.setAction(data.getTitle()); - rv.setOnClickFillInIntent(R.id.card, activityIntent); - } catch (Exception e) { - - } - return rv; - } - - public int getCount() { - return records.size(); - } - - - public void onDataSetChanged() { - - // Fetching JSON data from server and add them to records arraylist - } - - public int getViewTypeCount() { - return 1; - } - - public long getItemId(int position) { - return position; - } - - public void onDestroy() { - records.clear(); - } - - public boolean hasStableIds() { - return true; - } - - public RemoteViews getLoadingView() { - return null; - } - -} diff --git a/app/src/main/java/me/ccrama/redditslide/util/GifDecoder.java b/app/src/main/java/me/ccrama/redditslide/util/GifDecoder.java index f9ea9f22b0..2a6ad191d5 100644 --- a/app/src/main/java/me/ccrama/redditslide/util/GifDecoder.java +++ b/app/src/main/java/me/ccrama/redditslide/util/GifDecoder.java @@ -155,7 +155,7 @@ private void setPixels() { } } } - image = Bitmap.createBitmap(dest, width, height, Bitmap.Config.ARGB_4444); + image = Bitmap.createBitmap(dest, width, height, Bitmap.Config.ARGB_8888); } private Bitmap getFrame(int n) { @@ -190,7 +190,7 @@ public int read(InputStream is) { private void decodeBitmapData() { int nullCode = -1; int npix = iw * ih; - int available, clear, code_mask, code_size, end_of_information, in_code, old_code, bits, code, count, i, datum, data_size, first, top, bi, pi; + int in_code, bits, code, count, i, datum, first, top, bi, pi; if ((pixels == null) || (pixels.length < npix)) { pixels = new byte[npix]; // allocate new pixel array } @@ -203,13 +203,13 @@ private void decodeBitmapData() { if (pixelStack == null) { pixelStack = new byte[MAX_STACK_SIZE + 1]; } - data_size = read(); - clear = 1 << data_size; - end_of_information = clear + 1; - available = clear + 2; - old_code = nullCode; - code_size = data_size + 1; - code_mask = (1 << code_size) - 1; + int data_size = read(); + int clear = 1 << data_size; + int end_of_information = clear + 1; + int available = clear + 2; + int old_code = nullCode; + int code_size = data_size + 1; + int code_mask = (1 << code_size) - 1; for (code = 0; code < clear; code++) { prefix[code] = 0; // XXX ArrayIndexOutOfBoundsException suffix[code] = (byte) code; @@ -465,7 +465,7 @@ private void readBitmap() { } frameCount++; // create new image to receive frame data - image = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_4444); + image = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); setPixels(); // transfer pixel data to image frames.addElement(new GifFrame(image, delay)); // add image to frame // list diff --git a/app/src/main/java/me/ccrama/redditslide/util/GifUtils.java b/app/src/main/java/me/ccrama/redditslide/util/GifUtils.java index c34b0ae01f..3a807958fd 100644 --- a/app/src/main/java/me/ccrama/redditslide/util/GifUtils.java +++ b/app/src/main/java/me/ccrama/redditslide/util/GifUtils.java @@ -12,6 +12,7 @@ import android.os.AsyncTask; import android.os.Environment; import android.os.Looper; +import android.util.Log; import android.view.View; import android.widget.ProgressBar; import android.widget.TextView; @@ -19,9 +20,9 @@ import androidx.annotation.Nullable; import androidx.core.app.NotificationCompat; +import androidx.core.content.ContextCompat; import com.afollestad.materialdialogs.AlertDialogWrapper; -import com.coremedia.iso.boxes.Container; import com.google.android.exoplayer2.Player; import com.google.android.exoplayer2.ext.okhttp.OkHttpDataSourceFactory; import com.google.android.exoplayer2.source.dash.manifest.AdaptationSet; @@ -31,18 +32,21 @@ import com.google.android.exoplayer2.upstream.DataSource; import com.google.android.exoplayer2.upstream.DataSourceInputStream; import com.google.android.exoplayer2.upstream.DataSpec; -import com.google.android.exoplayer2.upstream.cache.CacheDataSourceFactory; +import com.google.android.exoplayer2.upstream.cache.CacheDataSource; import com.google.android.exoplayer2.util.MimeTypes; import com.google.gson.Gson; import com.google.gson.JsonObject; -import com.googlecode.mp4parser.authoring.builder.DefaultMp4Builder; -import com.googlecode.mp4parser.authoring.container.mp4.MovieCreator; -import com.googlecode.mp4parser.authoring.tracks.CroppedTrack; import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; import org.apache.commons.io.output.NullOutputStream; import org.jetbrains.annotations.NotNull; +import org.mp4parser.Container; +import org.mp4parser.muxer.Movie; +import org.mp4parser.muxer.Track; +import org.mp4parser.muxer.builder.DefaultMp4Builder; +import org.mp4parser.muxer.container.mp4.MovieCreator; +import org.mp4parser.muxer.tracks.ClippedTrack; import java.io.File; import java.io.FileInputStream; @@ -93,13 +97,15 @@ public void onScanCompleted(String path, Uri uri) { Notification notif = new NotificationCompat.Builder(c, Reddit.CHANNEL_IMG).setContentTitle(c.getString(R.string.gif_saved)) - .setSmallIcon(R.drawable.save_png) + .setSmallIcon(R.drawable.save_content) .setContentIntent(contentIntent) .build(); NotificationManager mNotificationManager = - (NotificationManager) c.getSystemService(Activity.NOTIFICATION_SERVICE); - mNotificationManager.notify((int) System.currentTimeMillis(), notif); + ContextCompat.getSystemService(c, NotificationManager.class); + if (mNotificationManager != null) { + mNotificationManager.notify((int) System.currentTimeMillis(), notif); + } } } ); @@ -172,7 +178,7 @@ public static void cacheSaveGif(Uri uri, Activity a, String subreddit, boolean s } else { new AsyncTask() { File outFile; - NotificationManager notifMgr = (NotificationManager) a.getSystemService(Activity.NOTIFICATION_SERVICE); + NotificationManager notifMgr = ContextCompat.getSystemService(a, NotificationManager.class); @Override protected void onPreExecute() { @@ -181,7 +187,7 @@ protected void onPreExecute() { Notification notif = new NotificationCompat.Builder(a, Reddit.CHANNEL_IMG) .setContentTitle(a.getString(R.string.mediaview_saving, uri.toString().replace("/DASHPlaylist.mpd", ""))) - .setSmallIcon(R.drawable.download_png) + .setSmallIcon(R.drawable.save) .setProgress(0, 0, true) .setOngoing(true) .build(); @@ -209,7 +215,10 @@ protected Boolean doInBackground(Void... voids) { try { DataSource.Factory downloader = new OkHttpDataSourceFactory(Reddit.client, a.getString(R.string.app_name)); - DataSource.Factory cacheDataSourceFactory = new CacheDataSourceFactory(Reddit.videoCache, downloader); + DataSource.Factory cacheDataSourceFactory = + new CacheDataSource.Factory() + .setCache(Reddit.videoCache) + .setUpstreamDataSourceFactory(downloader); if (uri.getLastPathSegment().endsWith("DASHPlaylist.mpd")) { InputStream dashManifestStream = new DataSourceInputStream(cacheDataSourceFactory.createDataSource(), new DataSpec(uri)); @@ -270,7 +279,7 @@ protected Boolean doInBackground(Void... voids) { return true; } else if (audioUri != null && videoUri != null) { if (mux(new File(a.getCacheDir().getAbsolutePath(), "video.mp4").getAbsolutePath(), - new File(a.getCacheDir().getAbsolutePath(), "video.mp4").getAbsolutePath(), + new File(a.getCacheDir().getAbsolutePath(), "audio.mp4").getAbsolutePath(), new File(a.getCacheDir().getAbsolutePath(), "muxed.mp4").getAbsolutePath())) { in = new FileInputStream(new File(a.getCacheDir().getAbsolutePath(), "muxed.mp4")); } else { @@ -459,11 +468,39 @@ public static VideoType getVideoType(String url) { return VideoType.DIRECT; } if (realURL.contains("gfycat") && !realURL.contains("mp4")) return VideoType.GFYCAT; + if (realURL.contains("redgifs") && !realURL.contains("mp4")) return VideoType.GFYCAT; if (realURL.contains("imgur.com")) return VideoType.IMGUR; if (realURL.contains("streamable.com")) return VideoType.STREAMABLE; return VideoType.OTHER; } + /** + * Get an API response for a given host and gfy name + * + * @param host the host to send the req to + * @param name the name of the gfy + * @return the result + */ + JsonObject getApiResponse(String host, String name){ + String gfycatUrl = "https://api." + host + ".com/v1/gfycats" + name; + return HttpUtil.getJsonObject(client, gson, gfycatUrl); + } + + /** + * Get the correct mp4/mobile url from a given result JsonObject + * + * @param result the result to check + * @return the video url + */ + String getUrlFromApi(JsonObject result){ + if (result.getAsJsonObject("gfyItem").has("mobileUrl")) { + return result.getAsJsonObject("gfyItem").get("mobileUrl").getAsString(); + } else { + return result.getAsJsonObject("gfyItem").get("mp4Url").getAsString(); + } + } + + OkHttpClient client = Reddit.client; /** @@ -476,19 +513,21 @@ public static VideoType getVideoType(String url) { */ Uri loadGfycat(String name, String fullUrl, Gson gson) { showProgressBar(c, progressBar, true); + String host = "gfycat"; + if (fullUrl.contains("redgifs")) { + host = "redgifs"; + } if (!name.startsWith("/")) name = "/" + name; if (name.contains("-")) { name = name.split("-")[0]; } - String gfycatUrl = "https://api.gfycat.com/v1/gfycats" + name; - LogUtil.v(gfycatUrl); - final JsonObject result = HttpUtil.getJsonObject(client, gson, gfycatUrl); - String obj; + final JsonObject result = getApiResponse(host, name); if (result == null || result.get("gfyItem") == null || result.getAsJsonObject("gfyItem") .get("mp4Url") .isJsonNull()) { //If the result null, the gfycat link may be redirecting to gifdeliverynetwork which is powered by redgifs. - //Try getting the redirected url from gfycat and check if redirected url is gifdeliverynetwork and return the url + //Try getting the redirected url from gfycat and check if redirected url is gifdeliverynetwork and if it is, + // we fetch the actual .mp4/.webm url from the redgifs api if (result == null) { try { URL newUrl = new URL(fullUrl); @@ -496,7 +535,7 @@ Uri loadGfycat(String name, String fullUrl, Gson gson) { ucon.setInstanceFollowRedirects(false); String secondURL = new URL(ucon.getHeaderField("location")).toString(); if (secondURL.contains("gifdeliverynetwork")){ - return Uri.parse(secondURL); + return Uri.parse(getUrlFromApi(getApiResponse("redgifs", name))); } } catch (IOException e) { @@ -538,14 +577,9 @@ public void onClick(DialogInterface dialog, int which) { } return null; - } else { - if (result.getAsJsonObject("gfyItem").has("mobileUrl")) { - obj = result.getAsJsonObject("gfyItem").get("mobileUrl").getAsString(); - } else { - obj = result.getAsJsonObject("gfyItem").get("mp4Url").getAsString(); - } } - return Uri.parse(obj); + + return Uri.parse(getUrlFromApi(result)); } /*Loads a direct MP4, used for DASH mp4 or direct/imgur videos, currently unused @@ -818,7 +852,7 @@ public void run() { ? ExoVideoView.VideoType.DASH : ExoVideoView.VideoType.STANDARD; video.setVideoURI(uri, type, new Player.EventListener() { @Override - public void onPlayerStateChanged(boolean playWhenReady, int playbackState) { + public void onPlaybackStateChanged(int playbackState) { if (playbackState == Player.STATE_READY) { progressBar.setVisibility(View.GONE); if (size != null) { @@ -935,7 +969,10 @@ public void run() { } else { DataSource.Factory downloader = new OkHttpDataSourceFactory(Reddit.client, c.getString(R.string.app_name)); - DataSource.Factory cacheDataSourceFactory = new CacheDataSourceFactory(Reddit.videoCache, downloader); + DataSource.Factory cacheDataSourceFactory = + new CacheDataSource.Factory() + .setCache(Reddit.videoCache) + .setUpstreamDataSourceFactory(downloader); InputStream dashManifestStream = new DataSourceInputStream(cacheDataSourceFactory.createDataSource(), new DataSpec(Uri.parse(url))); try { @@ -943,7 +980,6 @@ public void run() { dashManifestStream.close(); long videoSize = 0; long audioSize = 0; - final long totalSize; for (int i = 0; i < dashManifest.getPeriodCount(); i++) { for (AdaptationSet as : dashManifest.getPeriod(i).adaptationSets) { @@ -976,7 +1012,7 @@ public void run() { } } } - totalSize = videoSize + audioSize; + final long totalSize = videoSize + audioSize; c.runOnUiThread(new Runnable() { @Override public void run() { @@ -1035,34 +1071,34 @@ public void run() { * @return Whether the muxing completed successfully */ private static boolean mux(String videoFile, String audioFile, String outputFile) { - com.googlecode.mp4parser.authoring.Movie video; + Movie rawVideo; + try { new MovieCreator(); - video = MovieCreator.build(videoFile); - } catch (RuntimeException e) { - e.printStackTrace(); - return false; - } catch (IOException e) { + rawVideo = MovieCreator.build(videoFile); + } catch (RuntimeException | IOException e) { e.printStackTrace(); return false; } - com.googlecode.mp4parser.authoring.Movie audio; + Movie audio; try { new MovieCreator(); audio = MovieCreator.build(audioFile); - } catch (IOException e) { - e.printStackTrace(); - return false; - } catch (NullPointerException e) { + } catch (IOException | NullPointerException e) { e.printStackTrace(); return false; } - com.googlecode.mp4parser.authoring.Track audioTrack = audio.getTracks().get(0); + Track audioTrack = audio.getTracks().get(0); + Track videoTrack = rawVideo.getTracks().get(0); + Movie video = new Movie(); + + ClippedTrack croppedTrackAudio = new ClippedTrack(audioTrack, 0, audioTrack.getSamples().size()); + video.addTrack(croppedTrackAudio); + ClippedTrack croppedTrackVideo = new ClippedTrack(videoTrack, 0, videoTrack.getSamples().size()); + video.addTrack(croppedTrackVideo); - CroppedTrack croppedTrack = new CroppedTrack(audioTrack, 0, audioTrack.getSamples().size()); - video.addTrack(croppedTrack); Container out = new DefaultMp4Builder().build(video); FileOutputStream fos; diff --git a/app/src/main/java/me/ccrama/redditslide/util/LinkUtil.java b/app/src/main/java/me/ccrama/redditslide/util/LinkUtil.java index de692b4f8f..136b1063d1 100644 --- a/app/src/main/java/me/ccrama/redditslide/util/LinkUtil.java +++ b/app/src/main/java/me/ccrama/redditslide/util/LinkUtil.java @@ -13,9 +13,7 @@ import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.net.Uri; -import android.os.Build; import android.os.Bundle; -import android.text.Html; import android.util.Log; import android.widget.Toast; @@ -27,6 +25,7 @@ import androidx.browser.customtabs.CustomTabsServiceConnection; import androidx.browser.customtabs.CustomTabsSession; import androidx.core.content.ContextCompat; +import androidx.core.text.HtmlCompat; import net.dean.jraw.models.Submission; @@ -101,7 +100,7 @@ public static void openCustomTab(@NonNull String url, int color, pendingIntent) .setCloseButtonIcon(drawableToBitmap( ContextCompat.getDrawable(contextActivity, - R.drawable.ic_arrow_back_white_24dp))); + R.drawable.left))); try { CustomTabsIntent customTabsIntent = builder.build(); @@ -168,11 +167,7 @@ public static Uri formatURL(String url) { } Uri uri = Uri.parse(url); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { - return uri.normalizeScheme(); - } else { - return uri; - } + return uri.normalizeScheme(); } public static boolean tryOpenWithVideoPlugin(@NonNull String url) { @@ -214,7 +209,7 @@ public static void openUrl(@NonNull String url, int color, @NonNull Activity con * @param url URL to open */ public static void openExternally(String url) { - url = StringEscapeUtils.unescapeHtml4(Html.fromHtml(url).toString()); + url = StringEscapeUtils.unescapeHtml4(HtmlCompat.fromHtml(url, HtmlCompat.FROM_HTML_MODE_LEGACY).toString()); Uri uri = formatURL(url); final Intent intent = new Intent(Intent.ACTION_VIEW, uri); @@ -238,11 +233,12 @@ public void onNavigationEvent(int navigationEvent, Bundle extras) { } public static void copyUrl(String url, Context context) { - url = StringEscapeUtils.unescapeHtml4(Html.fromHtml(url).toString()); - ClipboardManager clipboard = - (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE); + url = StringEscapeUtils.unescapeHtml4(HtmlCompat.fromHtml(url, HtmlCompat.FROM_HTML_MODE_LEGACY).toString()); + ClipboardManager clipboard = ContextCompat.getSystemService(context, ClipboardManager.class); ClipData clip = ClipData.newPlainText("Link", url); - clipboard.setPrimaryClip(clip); + if (clipboard != null) { + clipboard.setPrimaryClip(clip); + } Toast.makeText(context, R.string.submission_link_copied, Toast.LENGTH_SHORT).show(); } diff --git a/app/src/main/java/me/ccrama/redditslide/util/NetworkUtil.java b/app/src/main/java/me/ccrama/redditslide/util/NetworkUtil.java index e08ddfd877..9b82efb3be 100644 --- a/app/src/main/java/me/ccrama/redditslide/util/NetworkUtil.java +++ b/app/src/main/java/me/ccrama/redditslide/util/NetworkUtil.java @@ -3,7 +3,8 @@ import android.content.Context; import android.net.ConnectivityManager; import android.net.NetworkInfo; -import android.os.Build; + +import androidx.core.content.ContextCompat; import me.ccrama.redditslide.Reddit; @@ -27,15 +28,14 @@ private NetworkUtil() { * @return A non-null value defined in {@link Status} */ public static Status getConnectivityStatus(Context context) { - ConnectivityManager cm = (ConnectivityManager) context - .getSystemService(Context.CONNECTIVITY_SERVICE); + ConnectivityManager cm = ContextCompat.getSystemService(context, ConnectivityManager.class); + assert cm != null; NetworkInfo activeNetwork = cm.getActiveNetworkInfo(); switch (activeNetwork != null ? activeNetwork.getType() : CONST_NO_NETWORK) { case ConnectivityManager.TYPE_WIFI: case ConnectivityManager.TYPE_ETHERNET: - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) - if (cm.isActiveNetworkMetered()) - return Status.MOBILE; // respect metered wifi networks as mobile + if (cm.isActiveNetworkMetered()) + return Status.MOBILE; // respect metered wifi networks as mobile return Status.WIFI; case ConnectivityManager.TYPE_MOBILE: case ConnectivityManager.TYPE_BLUETOOTH: case ConnectivityManager.TYPE_WIMAX: return Status.MOBILE; diff --git a/app/src/main/java/me/ccrama/redditslide/util/Base64.java b/app/src/main/java/me/ccrama/redditslide/util/billing/Base64.java similarity index 99% rename from app/src/main/java/me/ccrama/redditslide/util/Base64.java rename to app/src/main/java/me/ccrama/redditslide/util/billing/Base64.java index 0e20f56420..a7448429a0 100644 --- a/app/src/main/java/me/ccrama/redditslide/util/Base64.java +++ b/app/src/main/java/me/ccrama/redditslide/util/billing/Base64.java @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package me.ccrama.redditslide.util; +package me.ccrama.redditslide.util.billing; // This code was converted from code at http://iharder.sourceforge.net/base64/ // Lots of extraneous features were removed. diff --git a/app/src/main/java/me/ccrama/redditslide/util/Base64DecoderException.java b/app/src/main/java/me/ccrama/redditslide/util/billing/Base64DecoderException.java similarity index 95% rename from app/src/main/java/me/ccrama/redditslide/util/Base64DecoderException.java rename to app/src/main/java/me/ccrama/redditslide/util/billing/Base64DecoderException.java index eb05fa1d79..e92b7fab43 100644 --- a/app/src/main/java/me/ccrama/redditslide/util/Base64DecoderException.java +++ b/app/src/main/java/me/ccrama/redditslide/util/billing/Base64DecoderException.java @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package me.ccrama.redditslide.util; +package me.ccrama.redditslide.util.billing; /** * Exception thrown when encountering an invalid Base64 input character. diff --git a/app/src/main/java/me/ccrama/redditslide/util/IabException.java b/app/src/main/java/me/ccrama/redditslide/util/billing/IabException.java similarity index 97% rename from app/src/main/java/me/ccrama/redditslide/util/IabException.java rename to app/src/main/java/me/ccrama/redditslide/util/billing/IabException.java index 63eafa497d..88946ad1cc 100644 --- a/app/src/main/java/me/ccrama/redditslide/util/IabException.java +++ b/app/src/main/java/me/ccrama/redditslide/util/billing/IabException.java @@ -13,7 +13,7 @@ * limitations under the License. */ -package me.ccrama.redditslide.util; +package me.ccrama.redditslide.util.billing; /** * Exception thrown when something went wrong with in-app billing. @@ -47,4 +47,4 @@ public IabException(int response, String message, Exception cause) { public IabResult getResult() { return mResult; } -} \ No newline at end of file +} diff --git a/app/src/main/java/me/ccrama/redditslide/util/IabHelper.java b/app/src/main/java/me/ccrama/redditslide/util/billing/IabHelper.java similarity index 99% rename from app/src/main/java/me/ccrama/redditslide/util/IabHelper.java rename to app/src/main/java/me/ccrama/redditslide/util/billing/IabHelper.java index 13138ade8f..62f0e107a4 100644 --- a/app/src/main/java/me/ccrama/redditslide/util/IabHelper.java +++ b/app/src/main/java/me/ccrama/redditslide/util/billing/IabHelper.java @@ -13,7 +13,7 @@ * limitations under the License. */ -package me.ccrama.redditslide.util; +package me.ccrama.redditslide.util.billing; import android.app.Activity; import android.app.PendingIntent; @@ -652,7 +652,7 @@ private void consume(Purchase itemInfo) throws IabException { try { String token = itemInfo.getToken(); String sku = itemInfo.getSku(); - if (token == null || token.equals("")) { + if (token == null || token.isEmpty()) { logError("Can't consume " + sku + ". No token."); throw new IabException(IABHELPER_MISSING_TOKEN, "PurchaseInfo is missing token for sku: " + sku + " " + itemInfo); diff --git a/app/src/main/java/me/ccrama/redditslide/util/IabResult.java b/app/src/main/java/me/ccrama/redditslide/util/billing/IabResult.java similarity index 92% rename from app/src/main/java/me/ccrama/redditslide/util/IabResult.java rename to app/src/main/java/me/ccrama/redditslide/util/billing/IabResult.java index 2c234499ba..f25979d2ba 100644 --- a/app/src/main/java/me/ccrama/redditslide/util/IabResult.java +++ b/app/src/main/java/me/ccrama/redditslide/util/billing/IabResult.java @@ -13,7 +13,7 @@ * limitations under the License. */ -package me.ccrama.redditslide.util; +package me.ccrama.redditslide.util.billing; /** * Represents the result of an in-app billing operation. @@ -29,7 +29,7 @@ public class IabResult { public IabResult(int response, String message) { mResponse = response; - if (message == null || message.trim().length() == 0) { + if (message == null || message.trim().isEmpty()) { mMessage = IabHelper.getResponseDesc(response); } else { mMessage = message + " (response: " + IabHelper.getResponseDesc(response) + ")"; @@ -53,7 +53,7 @@ public boolean isFailure() { } public String toString() { - return "IabResult: " + getMessage(); + return "IabResult: " + mMessage; } } diff --git a/app/src/main/java/me/ccrama/redditslide/util/Inventory.java b/app/src/main/java/me/ccrama/redditslide/util/billing/Inventory.java similarity index 98% rename from app/src/main/java/me/ccrama/redditslide/util/Inventory.java rename to app/src/main/java/me/ccrama/redditslide/util/billing/Inventory.java index c8aa4c560a..36c237afe1 100644 --- a/app/src/main/java/me/ccrama/redditslide/util/Inventory.java +++ b/app/src/main/java/me/ccrama/redditslide/util/billing/Inventory.java @@ -13,7 +13,7 @@ * limitations under the License. */ -package me.ccrama.redditslide.util; +package me.ccrama.redditslide.util.billing; import java.util.ArrayList; import java.util.HashMap; diff --git a/app/src/main/java/me/ccrama/redditslide/util/Purchase.java b/app/src/main/java/me/ccrama/redditslide/util/billing/Purchase.java similarity index 98% rename from app/src/main/java/me/ccrama/redditslide/util/Purchase.java rename to app/src/main/java/me/ccrama/redditslide/util/billing/Purchase.java index e76e16529c..083f3a5ce2 100644 --- a/app/src/main/java/me/ccrama/redditslide/util/Purchase.java +++ b/app/src/main/java/me/ccrama/redditslide/util/billing/Purchase.java @@ -13,7 +13,7 @@ * limitations under the License. */ -package me.ccrama.redditslide.util; +package me.ccrama.redditslide.util.billing; import org.json.JSONException; import org.json.JSONObject; diff --git a/app/src/main/java/me/ccrama/redditslide/util/Security.java b/app/src/main/java/me/ccrama/redditslide/util/billing/Security.java similarity index 99% rename from app/src/main/java/me/ccrama/redditslide/util/Security.java rename to app/src/main/java/me/ccrama/redditslide/util/billing/Security.java index 40e86a03b2..f031cea3d7 100644 --- a/app/src/main/java/me/ccrama/redditslide/util/Security.java +++ b/app/src/main/java/me/ccrama/redditslide/util/billing/Security.java @@ -13,7 +13,7 @@ * limitations under the License. */ -package me.ccrama.redditslide.util; +package me.ccrama.redditslide.util.billing; import android.text.TextUtils; import android.util.Log; diff --git a/app/src/main/java/me/ccrama/redditslide/util/SkuDetails.java b/app/src/main/java/me/ccrama/redditslide/util/billing/SkuDetails.java similarity index 97% rename from app/src/main/java/me/ccrama/redditslide/util/SkuDetails.java rename to app/src/main/java/me/ccrama/redditslide/util/billing/SkuDetails.java index 2a7f5b0b1b..e2a5ad2119 100644 --- a/app/src/main/java/me/ccrama/redditslide/util/SkuDetails.java +++ b/app/src/main/java/me/ccrama/redditslide/util/billing/SkuDetails.java @@ -13,7 +13,7 @@ * limitations under the License. */ -package me.ccrama.redditslide.util; +package me.ccrama.redditslide.util.billing; import org.json.JSONException; import org.json.JSONObject; diff --git a/app/src/main/java/uz/shift/colorpicker/LineColorPicker.java b/app/src/main/java/uz/shift/colorpicker/LineColorPicker.java new file mode 100644 index 0000000000..b41a368338 --- /dev/null +++ b/app/src/main/java/uz/shift/colorpicker/LineColorPicker.java @@ -0,0 +1,408 @@ +package uz.shift.colorpicker; + +import android.content.Context; +import android.content.res.TypedArray; +import android.graphics.Canvas; +import android.graphics.Paint; +import android.graphics.Paint.Style; +import android.graphics.Rect; +import android.os.Parcel; +import android.os.Parcelable; +import android.util.AttributeSet; +import android.view.MotionEvent; +import android.view.View; +import android.widget.LinearLayout; + +import me.ccrama.redditslide.R; + +public class LineColorPicker extends View { + + int[] colors; + // indicate if nothing selected + boolean isColorSelected = false; + private Paint paint; + private Rect rect = new Rect(); + private int selectedColor; + private OnColorChangedListener onColorChanged; + private int cellSize; + private int mOrientation; + private boolean isClick = false; + private int screenW; + private int screenH; + + { + if (isInEditMode()) { + colors = Palette.DEFAULT; + } else { + colors = new int[1]; + } + } + + public LineColorPicker(Context context, AttributeSet attrs) { + super(context, attrs); + + paint = new Paint(); + paint.setStyle(Style.FILL); + + final TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.LineColorPicker, 0, 0); + + try { + mOrientation = a.getInteger(R.styleable.LineColorPicker_android_orientation, LinearLayout.HORIZONTAL); + + if (!isInEditMode()) { + final int colorsArrayResId = a.getResourceId(R.styleable.LineColorPicker_colors, -1); + + if (colorsArrayResId > 0) { + final int[] colors = context.getResources().getIntArray(colorsArrayResId); + setColors(colors); + } + } + + final int selected = a.getInteger(R.styleable.LineColorPicker_selectedColorIndex, -1); + + if (selected != -1) { + final int[] currentColors = getColors(); + + final int currentColorsLength = currentColors != null ? currentColors.length : 0; + + if (selected < currentColorsLength) { + setSelectedColorPosition(selected); + } + } + } finally { + a.recycle(); + } + + selectedColor = colors[0]; + } + + @Override + protected void onDraw(Canvas canvas) { + super.onDraw(canvas); + + if (mOrientation == LinearLayout.HORIZONTAL) { + drawHorizontalPicker(canvas); + } else { + drawVerticalPicker(canvas); + } + + } + + private void drawVerticalPicker(Canvas canvas) { + rect.left = 0; + rect.top = 0; + rect.right = canvas.getWidth(); + rect.bottom = 0; + + // 8% + int margin = Math.round(canvas.getWidth() * 0.08f); + + for (int color : colors) { + + paint.setColor(color); + + rect.top = rect.bottom; + rect.bottom += cellSize; + + if (isColorSelected && color == selectedColor) { + rect.left = 0; + rect.right = canvas.getWidth(); + } else { + rect.left = margin; + rect.right = canvas.getWidth() - margin; + } + + canvas.drawRect(rect, paint); + } + + } + + private void drawHorizontalPicker(Canvas canvas) { + rect.left = 0; + rect.top = 0; + rect.right = 0; + rect.bottom = canvas.getHeight(); + + // 8% + int margin = Math.round(canvas.getHeight() * 0.08f); + + for (int color : colors) { + + paint.setColor(color); + + rect.left = rect.right; + rect.right += cellSize; + + if (isColorSelected && color == selectedColor) { + rect.top = 0; + rect.bottom = canvas.getHeight(); + } else { + rect.top = margin; + rect.bottom = canvas.getHeight() - margin; + } + + canvas.drawRect(rect, paint); + } + } + + private void onColorChanged(int color) { + if (onColorChanged != null) { + onColorChanged.onColorChanged(color); + } + } + + @Override + public boolean onTouchEvent(MotionEvent event) { + + int actionId = event.getAction(); + + int newColor; + + switch (actionId) { + case MotionEvent.ACTION_DOWN: + isClick = true; + break; + case MotionEvent.ACTION_UP: + newColor = getColorAtXY(event.getX(), event.getY()); + + setSelectedColor(newColor); + + if (isClick) { + performClick(); + } + + break; + + case MotionEvent.ACTION_MOVE: + newColor = getColorAtXY(event.getX(), event.getY()); + + setSelectedColor(newColor); + + break; + + case MotionEvent.ACTION_CANCEL: + case MotionEvent.ACTION_OUTSIDE: + isClick = false; + break; + + default: + break; + } + + return true; + } + + /** + * Return color at x,y coordinate of view. + */ + private int getColorAtXY(float x, float y) { + + // FIXME: colors.length == 0 -> division by ZERO.s + + if (mOrientation == LinearLayout.HORIZONTAL) { + int left = 0; + int right = 0; + + for (int color : colors) { + left = right; + right += cellSize; + + if (left <= x && right >= x) { + return color; + } + } + + } else { + int top = 0; + int bottom = 0; + + for (int color : colors) { + top = bottom; + bottom += cellSize; + + if (y >= top && y <= bottom) { + return color; + } + } + } + + return selectedColor; + } + + @Override + protected Parcelable onSaveInstanceState() { + // begin boilerplate code that allows parent classes to save state + Parcelable superState = super.onSaveInstanceState(); + + SavedState ss = new SavedState(superState); + // end + + ss.selectedColor = this.selectedColor; + ss.isColorSelected = this.isColorSelected; + + return ss; + } + + @Override + protected void onRestoreInstanceState(Parcelable state) { + // begin boilerplate code so parent classes can restore state + if (!(state instanceof SavedState)) { + super.onRestoreInstanceState(state); + return; + } + + SavedState ss = (SavedState) state; + super.onRestoreInstanceState(ss.getSuperState()); + // end + + this.selectedColor = ss.selectedColor; + this.isColorSelected = ss.isColorSelected; + } + + @Override + public boolean performClick() { + return super.performClick(); + } + + @Override + protected void onSizeChanged(int w, int h, int oldw, int oldh) { + + screenW = w; + screenH = h; + + recalcCellSize(); + + super.onSizeChanged(w, h, oldw, oldh); + } + + /** + * Return currently selected color. + */ + public int getColor() { + return selectedColor; + } + + // @Override + // protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + // int parentWidth = MeasureSpec.getSize(widthMeasureSpec); + // int parentHeight = MeasureSpec.getSize(heightMeasureSpec); + // this.setMeasuredDimension(parentWidth, parentHeight); + // super.onMeasure(widthMeasureSpec, heightMeasureSpec); + // } + + /** + * Set selected color as color value from palette. + */ + public void setSelectedColor(int color) { + + // not from current palette + if (!containsColor(colors, color)) { + return; + } + + // do we need to re-draw view? + if (!isColorSelected || selectedColor != color) { + this.selectedColor = color; + + isColorSelected = true; + + invalidate(); + + onColorChanged(color); + } + } + + /** + * Set selected color as index from palete + */ + public void setSelectedColorPosition(int position) { + setSelectedColor(colors[position]); + } + + private void recalcCellSize() { + + if (mOrientation == LinearLayout.HORIZONTAL) { + cellSize = Math.round(screenW / (colors.length * 1f)); + } else { + cellSize = Math.round(screenH / (colors.length * 1f)); + } + } + + /** + * Return current picker palete + */ + public int[] getColors() { + return colors; + } + + /** + * Set picker palette + */ + public void setColors(int[] colors) { + // TODO: selected color can be NOT in set of colors + // FIXME: colors can be null + this.colors = colors; + + if (!containsColor(colors, selectedColor)) { + selectedColor = colors[0]; + } + + recalcCellSize(); + + invalidate(); + } + + /** + * Return true if palette contains this color + */ + private boolean containsColor(int[] colors, int c) { + for (int color : colors) { + if (color == c) + return true; + + } + + return false; + } + + /** + * Set onColorChanged listener + * + * @param l + */ + public void setOnColorChangedListener(OnColorChangedListener l) { + this.onColorChanged = l; + } + + static class SavedState extends BaseSavedState { + // required field that makes Parcelables from a Parcel + public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { + public SavedState createFromParcel(Parcel in) { + return new SavedState(in); + } + + public SavedState[] newArray(int size) { + return new SavedState[size]; + } + }; + int selectedColor; + boolean isColorSelected; + + SavedState(Parcelable superState) { + super(superState); + } + + private SavedState(Parcel in) { + super(in); + this.selectedColor = in.readInt(); + this.isColorSelected = in.readInt() == 1; + } + + @Override + public void writeToParcel(Parcel out, int flags) { + super.writeToParcel(out, flags); + out.writeInt(this.selectedColor); + out.writeInt(this.isColorSelected ? 1 : 0); + } + } +} diff --git a/app/src/main/java/uz/shift/colorpicker/OnColorChangedListener.java b/app/src/main/java/uz/shift/colorpicker/OnColorChangedListener.java new file mode 100644 index 0000000000..a620775480 --- /dev/null +++ b/app/src/main/java/uz/shift/colorpicker/OnColorChangedListener.java @@ -0,0 +1,5 @@ +package uz.shift.colorpicker; + +public interface OnColorChangedListener { + void onColorChanged(int c); +} diff --git a/app/src/main/java/uz/shift/colorpicker/Palette.java b/app/src/main/java/uz/shift/colorpicker/Palette.java new file mode 100644 index 0000000000..57fc3451b5 --- /dev/null +++ b/app/src/main/java/uz/shift/colorpicker/Palette.java @@ -0,0 +1,21 @@ +package uz.shift.colorpicker; + +import android.graphics.Color; + +public class Palette { + + public static int[] DEFAULT; + + static { + DEFAULT = new int[]{Color.parseColor("#b8c847"), + Color.parseColor("#67bb43"), Color.parseColor("#41b691"), + Color.parseColor("#4182b6"), Color.parseColor("#4149b6"), + Color.parseColor("#7641b6"), Color.parseColor("#b741a7"), + Color.parseColor("#c54657"), Color.parseColor("#d1694a"), + Color.parseColor("#d1904a"), Color.parseColor("#d1c54a")}; + + } + + private Palette() { + } +} diff --git a/app/src/main/res/drawable-hdpi/chameleon.jpg b/app/src/main/res/drawable-hdpi/chameleon.jpg new file mode 100644 index 0000000000..940658ee1b Binary files /dev/null and b/app/src/main/res/drawable-hdpi/chameleon.jpg differ diff --git a/app/src/main/res/drawable-hdpi/chameleon.png b/app/src/main/res/drawable-hdpi/chameleon.png deleted file mode 100644 index 0e49ca1c5b..0000000000 Binary files a/app/src/main/res/drawable-hdpi/chameleon.png and /dev/null differ diff --git a/app/src/main/res/drawable-hdpi/crown.png b/app/src/main/res/drawable-hdpi/crown.png deleted file mode 100644 index 59712ebbe6..0000000000 Binary files a/app/src/main/res/drawable-hdpi/crown.png and /dev/null differ diff --git a/app/src/main/res/drawable-hdpi/ic_arrow_back_white_24dp.png b/app/src/main/res/drawable-hdpi/ic_arrow_back_white_24dp.png deleted file mode 100644 index 6d78fe137c..0000000000 Binary files a/app/src/main/res/drawable-hdpi/ic_arrow_back_white_24dp.png and /dev/null differ diff --git a/app/src/main/res/drawable-hdpi/ic_delete.png b/app/src/main/res/drawable-hdpi/ic_delete.png deleted file mode 100644 index 4a9f769475..0000000000 Binary files a/app/src/main/res/drawable-hdpi/ic_delete.png and /dev/null differ diff --git a/app/src/main/res/drawable-hdpi/ic_share.png b/app/src/main/res/drawable-hdpi/ic_share.png deleted file mode 100644 index b09a6926de..0000000000 Binary files a/app/src/main/res/drawable-hdpi/ic_share.png and /dev/null differ diff --git a/app/src/main/res/drawable-hdpi/slogo.png b/app/src/main/res/drawable-hdpi/slogo.png index 05f1d3f20e..3ae869a5e5 100644 Binary files a/app/src/main/res/drawable-hdpi/slogo.png and b/app/src/main/res/drawable-hdpi/slogo.png differ diff --git a/app/src/main/res/drawable-hdpi/upvoted.png b/app/src/main/res/drawable-hdpi/upvoted.png deleted file mode 100644 index df98526b04..0000000000 Binary files a/app/src/main/res/drawable-hdpi/upvoted.png and /dev/null differ diff --git a/app/src/main/res/drawable-mdpi/chameleon.jpg b/app/src/main/res/drawable-mdpi/chameleon.jpg new file mode 100644 index 0000000000..b047aec5a3 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/chameleon.jpg differ diff --git a/app/src/main/res/drawable-mdpi/chameleon.png b/app/src/main/res/drawable-mdpi/chameleon.png deleted file mode 100644 index c7edeaa38d..0000000000 Binary files a/app/src/main/res/drawable-mdpi/chameleon.png and /dev/null differ diff --git a/app/src/main/res/drawable-mdpi/crown.png b/app/src/main/res/drawable-mdpi/crown.png deleted file mode 100644 index dcc26d40e0..0000000000 Binary files a/app/src/main/res/drawable-mdpi/crown.png and /dev/null differ diff --git a/app/src/main/res/drawable-mdpi/ic_arrow_back_white_24dp.png b/app/src/main/res/drawable-mdpi/ic_arrow_back_white_24dp.png deleted file mode 100644 index 018f8acc90..0000000000 Binary files a/app/src/main/res/drawable-mdpi/ic_arrow_back_white_24dp.png and /dev/null differ diff --git a/app/src/main/res/drawable-mdpi/ic_delete.png b/app/src/main/res/drawable-mdpi/ic_delete.png deleted file mode 100644 index e2f5f35558..0000000000 Binary files a/app/src/main/res/drawable-mdpi/ic_delete.png and /dev/null differ diff --git a/app/src/main/res/drawable-mdpi/ic_share.png b/app/src/main/res/drawable-mdpi/ic_share.png deleted file mode 100644 index e944fd70c4..0000000000 Binary files a/app/src/main/res/drawable-mdpi/ic_share.png and /dev/null differ diff --git a/app/src/main/res/drawable-mdpi/upvoted.png b/app/src/main/res/drawable-mdpi/upvoted.png deleted file mode 100644 index 8c1c494826..0000000000 Binary files a/app/src/main/res/drawable-mdpi/upvoted.png and /dev/null differ diff --git a/app/src/main/res/drawable-xhdpi/chameleon.jpg b/app/src/main/res/drawable-xhdpi/chameleon.jpg new file mode 100644 index 0000000000..8a87d9e11b Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/chameleon.jpg differ diff --git a/app/src/main/res/drawable-xhdpi/chameleon.png b/app/src/main/res/drawable-xhdpi/chameleon.png deleted file mode 100644 index b479fa5e44..0000000000 Binary files a/app/src/main/res/drawable-xhdpi/chameleon.png and /dev/null differ diff --git a/app/src/main/res/drawable-xhdpi/crown.png b/app/src/main/res/drawable-xhdpi/crown.png deleted file mode 100644 index 9948292ccb..0000000000 Binary files a/app/src/main/res/drawable-xhdpi/crown.png and /dev/null differ diff --git a/app/src/main/res/drawable-xhdpi/ic_arrow_back_white_24dp.png b/app/src/main/res/drawable-xhdpi/ic_arrow_back_white_24dp.png deleted file mode 100644 index 409c4bf36c..0000000000 Binary files a/app/src/main/res/drawable-xhdpi/ic_arrow_back_white_24dp.png and /dev/null differ diff --git a/app/src/main/res/drawable-xhdpi/ic_delete.png b/app/src/main/res/drawable-xhdpi/ic_delete.png deleted file mode 100644 index 388b5b060a..0000000000 Binary files a/app/src/main/res/drawable-xhdpi/ic_delete.png and /dev/null differ diff --git a/app/src/main/res/drawable-xhdpi/ic_share.png b/app/src/main/res/drawable-xhdpi/ic_share.png deleted file mode 100644 index 22a8783e70..0000000000 Binary files a/app/src/main/res/drawable-xhdpi/ic_share.png and /dev/null differ diff --git a/app/src/main/res/drawable-xhdpi/slogo.png b/app/src/main/res/drawable-xhdpi/slogo.png index 090459d24e..b908fe4368 100644 Binary files a/app/src/main/res/drawable-xhdpi/slogo.png and b/app/src/main/res/drawable-xhdpi/slogo.png differ diff --git a/app/src/main/res/drawable-xhdpi/upvoted.png b/app/src/main/res/drawable-xhdpi/upvoted.png deleted file mode 100644 index dacb933176..0000000000 Binary files a/app/src/main/res/drawable-xhdpi/upvoted.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/chameleon.jpg b/app/src/main/res/drawable-xxhdpi/chameleon.jpg new file mode 100644 index 0000000000..cac69a61bd Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/chameleon.jpg differ diff --git a/app/src/main/res/drawable-xxhdpi/chameleon.png b/app/src/main/res/drawable-xxhdpi/chameleon.png deleted file mode 100644 index 8abe89afe5..0000000000 Binary files a/app/src/main/res/drawable-xxhdpi/chameleon.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/crown.png b/app/src/main/res/drawable-xxhdpi/crown.png deleted file mode 100644 index 8c20d64cc5..0000000000 Binary files a/app/src/main/res/drawable-xxhdpi/crown.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_arrow_back_white_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_arrow_back_white_24dp.png deleted file mode 100644 index 587fb8180c..0000000000 Binary files a/app/src/main/res/drawable-xxhdpi/ic_arrow_back_white_24dp.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_delete.png b/app/src/main/res/drawable-xxhdpi/ic_delete.png deleted file mode 100644 index 3fcdfdb55e..0000000000 Binary files a/app/src/main/res/drawable-xxhdpi/ic_delete.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_share.png b/app/src/main/res/drawable-xxhdpi/ic_share.png deleted file mode 100644 index a35b3cd14a..0000000000 Binary files a/app/src/main/res/drawable-xxhdpi/ic_share.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/slogo.png b/app/src/main/res/drawable-xxhdpi/slogo.png index 90ba17b32c..c8731cf3df 100644 Binary files a/app/src/main/res/drawable-xxhdpi/slogo.png and b/app/src/main/res/drawable-xxhdpi/slogo.png differ diff --git a/app/src/main/res/drawable-xxhdpi/upvoted.png b/app/src/main/res/drawable-xxhdpi/upvoted.png deleted file mode 100644 index 6c2a88e0c0..0000000000 Binary files a/app/src/main/res/drawable-xxhdpi/upvoted.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxxhdpi/chameleon.jpg b/app/src/main/res/drawable-xxxhdpi/chameleon.jpg new file mode 100644 index 0000000000..cac69a61bd Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/chameleon.jpg differ diff --git a/app/src/main/res/drawable-xxxhdpi/chameleon.png b/app/src/main/res/drawable-xxxhdpi/chameleon.png deleted file mode 100644 index 99d3590522..0000000000 Binary files a/app/src/main/res/drawable-xxxhdpi/chameleon.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxxhdpi/crown.png b/app/src/main/res/drawable-xxxhdpi/crown.png deleted file mode 100644 index a36cf583ec..0000000000 Binary files a/app/src/main/res/drawable-xxxhdpi/crown.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxxhdpi/ic_arrow_back_white_24dp.png b/app/src/main/res/drawable-xxxhdpi/ic_arrow_back_white_24dp.png deleted file mode 100644 index 90d29e5582..0000000000 Binary files a/app/src/main/res/drawable-xxxhdpi/ic_arrow_back_white_24dp.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxxhdpi/ic_delete.png b/app/src/main/res/drawable-xxxhdpi/ic_delete.png deleted file mode 100644 index 8d322aa9ba..0000000000 Binary files a/app/src/main/res/drawable-xxxhdpi/ic_delete.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxxhdpi/ic_share.png b/app/src/main/res/drawable-xxxhdpi/ic_share.png deleted file mode 100644 index e351c7beb0..0000000000 Binary files a/app/src/main/res/drawable-xxxhdpi/ic_share.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxxhdpi/slogo.png b/app/src/main/res/drawable-xxxhdpi/slogo.png index 90ba17b32c..c8731cf3df 100644 Binary files a/app/src/main/res/drawable-xxxhdpi/slogo.png and b/app/src/main/res/drawable-xxxhdpi/slogo.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/upvoted.png b/app/src/main/res/drawable-xxxhdpi/upvoted.png deleted file mode 100644 index 6c2a88e0c0..0000000000 Binary files a/app/src/main/res/drawable-xxxhdpi/upvoted.png and /dev/null differ diff --git a/app/src/main/res/drawable/accent.xml b/app/src/main/res/drawable/accent.xml index 1c8dd1ea85..2f3e4c1fc7 100644 --- a/app/src/main/res/drawable/accent.xml +++ b/app/src/main/res/drawable/accent.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + android:fillColor="@android:color/white" + android:pathData="M20.71,5.63l-2.34,-2.34c-0.39,-0.39 -1.02,-0.39 -1.41,0l-3.12,3.12 -1.93,-1.91 -1.41,1.41 1.42,1.42L3,16.25V21h4.75l8.92,-8.92 1.42,1.42 1.41,-1.41 -1.92,-1.92 3.12,-3.12c0.4,-0.4 0.4,-1.03 0.01,-1.42zM6.92,19L5,17.08l8.06,-8.06 1.92,1.92L6.92,19z" /> diff --git a/app/src/main/res/drawable/add.xml b/app/src/main/res/drawable/add.xml index b5b5ba4cc8..d3c2150c6e 100644 --- a/app/src/main/res/drawable/add.xml +++ b/app/src/main/res/drawable/add.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + android:fillColor="@android:color/white" + android:pathData="M19,13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z" /> diff --git a/app/src/main/res/drawable/album.xml b/app/src/main/res/drawable/album.xml index 13cd80e04e..cd2591f69d 100644 --- a/app/src/main/res/drawable/album.xml +++ b/app/src/main/res/drawable/album.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + android:fillColor="@android:color/white" + android:pathData="M22,16L22,4c0,-1.1 -0.9,-2 -2,-2L8,2c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2zM11,12l2.03,2.71L16,11l4,5L8,16l3,-4zM2,6v14c0,1.1 0.9,2 2,2h14v-2L4,20L4,6L2,6z" /> diff --git a/app/src/main/res/drawable/album_grid.xml b/app/src/main/res/drawable/album_grid.xml index 836c883f1d..4cf7346ea4 100644 --- a/app/src/main/res/drawable/album_grid.xml +++ b/app/src/main/res/drawable/album_grid.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + android:fillColor="@android:color/white" + android:pathData="M4,11h5L9,5L4,5v6zM4,18h5v-6L4,12v6zM10,18h5v-6h-5v6zM16,18h5v-6h-5v6zM10,11h5L15,5h-5v6zM16,5v6h5L21,5h-5z" /> diff --git a/app/src/main/res/drawable/album_list.xml b/app/src/main/res/drawable/album_list.xml index 3ec3033cf8..a9cc076199 100644 --- a/app/src/main/res/drawable/album_list.xml +++ b/app/src/main/res/drawable/album_list.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + android:fillColor="@android:color/white" + android:pathData="M2,21h19v-3H2v3zM20,8H3c-0.55,0 -1,0.45 -1,1v6c0,0.55 0.45,1 1,1h17c0.55,0 1,-0.45 1,-1V9c0,-0.55 -0.45,-1 -1,-1zM2,3v3h19V3H2z" /> diff --git a/app/src/main/res/drawable/album_pager.xml b/app/src/main/res/drawable/album_pager.xml index f828113ee0..e7de73e6f1 100644 --- a/app/src/main/res/drawable/album_pager.xml +++ b/app/src/main/res/drawable/album_pager.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + android:fillColor="@android:color/white" + android:pathData="M4,18h3V5H4v13zM18,5v13h3V5h-3zM8,18h9V5H8v13z" /> diff --git a/app/src/main/res/drawable/az.xml b/app/src/main/res/drawable/az.xml index c6fd09ce8f..200bdd423d 100644 --- a/app/src/main/res/drawable/az.xml +++ b/app/src/main/res/drawable/az.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> - \ No newline at end of file + android:fillColor="@android:color/white" + android:pathData="M14.94,4.66h-4.72l2.36,-2.36zM10.25,19.37h4.66l-2.33,2.33zM6.1,6.27L1.6,17.73h1.84l0.92,-2.45h5.11l0.92,2.45h1.84L7.74,6.27L6.1,6.27zM4.97,13.64l1.94,-5.18 1.94,5.18L4.97,13.64zM15.73,16.14h6.12v1.59h-8.53v-1.29l5.92,-8.56h-5.88v-1.6h8.3v1.26l-5.93,8.6z" /> + diff --git a/app/src/main/res/drawable/ic_backup.xml b/app/src/main/res/drawable/backup.xml similarity index 58% rename from app/src/main/res/drawable/ic_backup.xml rename to app/src/main/res/drawable/backup.xml index 3f9ff6541b..407a1ffb43 100644 --- a/app/src/main/res/drawable/ic_backup.xml +++ b/app/src/main/res/drawable/backup.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + android:fillColor="@android:color/white" + android:pathData="M19.35,10.04C18.67,6.59 15.64,4 12,4 9.11,4 6.6,5.64 5.35,8.04 2.34,8.36 0,10.91 0,14c0,3.31 2.69,6 6,6h13c2.76,0 5,-2.24 5,-5 0,-2.64 -2.05,-4.78 -4.65,-4.96zM14,13v4h-4v-4H7l5,-5 5,5h-3z" /> diff --git a/app/src/main/res/drawable/ban.xml b/app/src/main/res/drawable/ban.xml index 360e67fb52..8811480c7b 100644 --- a/app/src/main/res/drawable/ban.xml +++ b/app/src/main/res/drawable/ban.xml @@ -1,9 +1,18 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + android:fillColor="@android:color/white" + android:pathData="M5.2496,8.0688l2.83,-2.8268l14.134,14.15l-2.83,2.8268z" /> + + + diff --git a/app/src/main/res/drawable/blackandwhite.png b/app/src/main/res/drawable/blackandwhite.png index 6b10b8f9d2..e3d2425781 100644 Binary files a/app/src/main/res/drawable/blackandwhite.png and b/app/src/main/res/drawable/blackandwhite.png differ diff --git a/app/src/main/res/drawable/bold.xml b/app/src/main/res/drawable/bold.xml new file mode 100644 index 0000000000..5c865b7482 --- /dev/null +++ b/app/src/main/res/drawable/bold.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/card.xml b/app/src/main/res/drawable/card.xml index c884bf0e7e..9abccbac27 100644 --- a/app/src/main/res/drawable/card.xml +++ b/app/src/main/res/drawable/card.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + android:fillColor="@android:color/white" + android:pathData="M20,13L3,13c-0.55,0 -1,0.45 -1,1v6c0,0.55 0.45,1 1,1h17c0.55,0 1,-0.45 1,-1v-6c0,-0.55 -0.45,-1 -1,-1zM20,3L3,3c-0.55,0 -1,0.45 -1,1v6c0,0.55 0.45,1 1,1h17c0.55,0 1,-0.45 1,-1L21,4c0,-0.55 -0.45,-1 -1,-1z" /> diff --git a/app/src/main/res/drawable/check_all.xml b/app/src/main/res/drawable/check_all.xml new file mode 100644 index 0000000000..2e24134794 --- /dev/null +++ b/app/src/main/res/drawable/check_all.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/circle_shape.xml b/app/src/main/res/drawable/circle_shape.xml deleted file mode 100644 index 47cc8a60bd..0000000000 --- a/app/src/main/res/drawable/circle_shape.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/close.xml b/app/src/main/res/drawable/close.xml index c82041598d..6f6c8767dc 100644 --- a/app/src/main/res/drawable/close.xml +++ b/app/src/main/res/drawable/close.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + android:fillColor="@android:color/white" + android:pathData="M19,6.41L17.59,5 12,10.59 6.41,5 5,6.41 10.59,12 5,17.59 6.41,19 12,13.41 17.59,19 19,17.59 13.41,12z" /> diff --git a/app/src/main/res/drawable/collection.xml b/app/src/main/res/drawable/collection.xml index 4da1b4e6fa..ab42ef1ab3 100644 --- a/app/src/main/res/drawable/collection.xml +++ b/app/src/main/res/drawable/collection.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + android:fillColor="@android:color/white" + android:pathData="M10,4H4c-1.1,0 -1.99,0.9 -1.99,2L2,18c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2V8c0,-1.1 -0.9,-2 -2,-2h-8l-2,-2z" /> diff --git a/app/src/main/res/drawable/color.xml b/app/src/main/res/drawable/color.xml deleted file mode 100644 index 9ce649c0c3..0000000000 --- a/app/src/main/res/drawable/color.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/comment.xml b/app/src/main/res/drawable/comment.xml index b37fb7df13..6c91f8440f 100644 --- a/app/src/main/res/drawable/comment.xml +++ b/app/src/main/res/drawable/comment.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + android:fillColor="@android:color/white" + android:pathData="M21.99,4c0,-1.1 -0.89,-2 -1.99,-2H4c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h14l4,4 -0.01,-18z" /> diff --git a/app/src/main/res/drawable/commentchange.xml b/app/src/main/res/drawable/commentchange.xml index ff420745d2..bb33579686 100644 --- a/app/src/main/res/drawable/commentchange.xml +++ b/app/src/main/res/drawable/commentchange.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + android:fillColor="@android:color/white" + android:pathData="M21,6h-2v9L6,15v2c0,0.55 0.45,1 1,1h11l4,4L22,7c0,-0.55 -0.45,-1 -1,-1zM17,12L17,3c0,-0.55 -0.45,-1 -1,-1L3,2c-0.55,0 -1,0.45 -1,1v14l4,-4h10c0.55,0 1,-0.45 1,-1z" /> diff --git a/app/src/main/res/drawable/commentwidget.png b/app/src/main/res/drawable/commentwidget.png deleted file mode 100644 index 85d1e8e805..0000000000 Binary files a/app/src/main/res/drawable/commentwidget.png and /dev/null differ diff --git a/app/src/main/res/drawable/copy.xml b/app/src/main/res/drawable/copy.xml new file mode 100644 index 0000000000..df88b4d24d --- /dev/null +++ b/app/src/main/res/drawable/copy.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/crown.png b/app/src/main/res/drawable/crown.png deleted file mode 100644 index 8c20d64cc5..0000000000 Binary files a/app/src/main/res/drawable/crown.png and /dev/null differ diff --git a/app/src/main/res/drawable/crown.xml b/app/src/main/res/drawable/crown.xml new file mode 100644 index 0000000000..7643729c8b --- /dev/null +++ b/app/src/main/res/drawable/crown.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/delete.xml b/app/src/main/res/drawable/delete.xml index 55c8fa4fad..6c6f704afe 100644 --- a/app/src/main/res/drawable/delete.xml +++ b/app/src/main/res/drawable/delete.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + android:fillColor="@android:color/white" + android:pathData="M6,19c0,1.1 0.9,2 2,2h8c1.1,0 2,-0.9 2,-2V7H6v12zM19,4h-3.5l-1,-1h-5l-1,1H5v2h14V4z" /> diff --git a/app/src/main/res/drawable/donate.xml b/app/src/main/res/drawable/donate.xml index 6da21a7baf..3fe958998d 100644 --- a/app/src/main/res/drawable/donate.xml +++ b/app/src/main/res/drawable/donate.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + android:fillColor="@android:color/white" + android:pathData="M20,6h-2.18c0.11,-0.31 0.18,-0.65 0.18,-1 0,-1.66 -1.34,-3 -3,-3 -1.05,0 -1.96,0.54 -2.5,1.35l-0.5,0.67 -0.5,-0.68C10.96,2.54 10.05,2 9,2 7.34,2 6,3.34 6,5c0,0.35 0.07,0.69 0.18,1L4,6c-1.11,0 -1.99,0.89 -1.99,2L2,19c0,1.11 0.89,2 2,2h16c1.11,0 2,-0.89 2,-2L22,8c0,-1.11 -0.89,-2 -2,-2zM15,4c0.55,0 1,0.45 1,1s-0.45,1 -1,1 -1,-0.45 -1,-1 0.45,-1 1,-1zM9,4c0.55,0 1,0.45 1,1s-0.45,1 -1,1 -1,-0.45 -1,-1 0.45,-1 1,-1zM20,19L4,19v-2h16v2zM20,14L4,14L4,8h5.08L7,10.83 8.62,12 11,8.76l1,-1.36 1,1.36L15.38,12 17,10.83 14.92,8L20,8v6z" /> diff --git a/app/src/main/res/drawable/done.xml b/app/src/main/res/drawable/done.xml index 6848259cba..ddb4f0d840 100644 --- a/app/src/main/res/drawable/done.xml +++ b/app/src/main/res/drawable/done.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + android:fillColor="@android:color/white" + android:pathData="M9,16.17L4.83,12l-1.42,1.41L9,19 21,7l-1.41,-1.41z" /> diff --git a/app/src/main/res/drawable/down.xml b/app/src/main/res/drawable/down.xml index 7fe8a46925..7eb5aedc88 100644 --- a/app/src/main/res/drawable/down.xml +++ b/app/src/main/res/drawable/down.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + android:fillColor="@android:color/white" + android:pathData="M7.41,8.59L12,13.17l4.59,-4.58L18,10l-6,6 -6,-6 1.41,-1.41z" /> diff --git a/app/src/main/res/drawable/download_png.png b/app/src/main/res/drawable/download_png.png deleted file mode 100644 index 6602791545..0000000000 Binary files a/app/src/main/res/drawable/download_png.png and /dev/null differ diff --git a/app/src/main/res/drawable/downvote.png b/app/src/main/res/drawable/downvote.png deleted file mode 100644 index f98429e8df..0000000000 Binary files a/app/src/main/res/drawable/downvote.png and /dev/null differ diff --git a/app/src/main/res/drawable/downvote.xml b/app/src/main/res/drawable/downvote.xml new file mode 100644 index 0000000000..f0839e316b --- /dev/null +++ b/app/src/main/res/drawable/downvote.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/downvoteicon.xml b/app/src/main/res/drawable/downvoteicon.xml deleted file mode 100644 index 711a22382f..0000000000 --- a/app/src/main/res/drawable/downvoteicon.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/dragit.png b/app/src/main/res/drawable/dragit.png index 2d0bda453d..2ea18e421b 100644 Binary files a/app/src/main/res/drawable/dragit.png and b/app/src/main/res/drawable/dragit.png differ diff --git a/app/src/main/res/drawable/draw.xml b/app/src/main/res/drawable/draw.xml index 870f152693..ba099938b3 100644 --- a/app/src/main/res/drawable/draw.xml +++ b/app/src/main/res/drawable/draw.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + android:fillColor="@android:color/white" + android:pathData="M4.59,6.89c0.7,-0.71 1.4,-1.35 1.71,-1.22 0.5,0.2 0,1.03 -0.3,1.52 -0.25,0.42 -2.86,3.89 -2.86,6.31 0,1.28 0.48,2.34 1.34,2.98 0.75,0.56 1.74,0.73 2.64,0.46 1.07,-0.31 1.95,-1.4 3.06,-2.77 1.21,-1.49 2.83,-3.44 4.08,-3.44 1.63,0 1.65,1.01 1.76,1.79 -3.78,0.64 -5.38,3.67 -5.38,5.37 0,1.7 1.44,3.09 3.21,3.09 1.63,0 4.29,-1.33 4.69,-6.1L21,14.88v-2.5h-2.47c-0.15,-1.65 -1.09,-4.2 -4.03,-4.2 -2.25,0 -4.18,1.91 -4.94,2.84 -0.58,0.73 -2.06,2.48 -2.29,2.72 -0.25,0.3 -0.68,0.84 -1.11,0.84 -0.45,0 -0.72,-0.83 -0.36,-1.92 0.35,-1.09 1.4,-2.86 1.85,-3.52 0.78,-1.14 1.3,-1.92 1.3,-3.28C8.95,3.69 7.31,3 6.44,3 5.12,3 3.97,4 3.72,4.25c-0.36,0.36 -0.66,0.66 -0.88,0.93l1.75,1.71zM13.88,18.55c-0.31,0 -0.74,-0.26 -0.74,-0.72 0,-0.6 0.73,-2.2 2.87,-2.76 -0.3,2.69 -1.43,3.48 -2.13,3.48z" /> diff --git a/app/src/main/res/drawable/edit.xml b/app/src/main/res/drawable/edit.xml index a843267e5d..efc5ae47d2 100644 --- a/app/src/main/res/drawable/edit.xml +++ b/app/src/main/res/drawable/edit.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + android:fillColor="@android:color/white" + android:pathData="M3,17.25V21h3.75L17.81,9.94l-3.75,-3.75L3,17.25zM20.71,7.04c0.39,-0.39 0.39,-1.02 0,-1.41l-2.34,-2.34c-0.39,-0.39 -1.02,-0.39 -1.41,0l-1.83,1.83 3.75,3.75 1.83,-1.83z" /> diff --git a/app/src/main/res/drawable/filter.xml b/app/src/main/res/drawable/filter.xml index da6a93a76d..ced58887ec 100644 --- a/app/src/main/res/drawable/filter.xml +++ b/app/src/main/res/drawable/filter.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + android:fillColor="@android:color/white" + android:pathData="M10,18h4v-2h-4v2zM3,6v2h18L21,6L3,6zM6,13h12v-2L6,11v2z" /> diff --git a/app/src/main/res/drawable/flair.xml b/app/src/main/res/drawable/flair.xml index 9f29a8c95a..d909a19fc8 100644 --- a/app/src/main/res/drawable/flair.xml +++ b/app/src/main/res/drawable/flair.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + android:fillColor="@android:color/white" + android:pathData="M21.41,11.58l-9,-9C12.05,2.22 11.55,2 11,2H4c-1.1,0 -2,0.9 -2,2v7c0,0.55 0.22,1.05 0.59,1.42l9,9c0.36,0.36 0.86,0.58 1.41,0.58 0.55,0 1.05,-0.22 1.41,-0.59l7,-7c0.37,-0.36 0.59,-0.86 0.59,-1.41 0,-0.55 -0.23,-1.06 -0.59,-1.42zM5.5,7C4.67,7 4,6.33 4,5.5S4.67,4 5.5,4 7,4.67 7,5.5 6.33,7 5.5,7z" /> diff --git a/app/src/main/res/drawable/fontsize.xml b/app/src/main/res/drawable/fontsize.xml new file mode 100644 index 0000000000..68db65c772 --- /dev/null +++ b/app/src/main/res/drawable/fontsize.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/fontsizedarker.xml b/app/src/main/res/drawable/fontsizedarker.xml deleted file mode 100644 index e06e6c55c6..0000000000 --- a/app/src/main/res/drawable/fontsizedarker.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/forward.xml b/app/src/main/res/drawable/forward.xml index 20d1227a9e..5503a9ced8 100644 --- a/app/src/main/res/drawable/forward.xml +++ b/app/src/main/res/drawable/forward.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + android:fillColor="@android:color/white" + android:pathData="M12,8V4l8,8 -8,8v-4H4V8z" /> diff --git a/app/src/main/res/drawable/gild.xml b/app/src/main/res/drawable/gild.xml index 803af6f060..f011c1fc58 100644 --- a/app/src/main/res/drawable/gild.xml +++ b/app/src/main/res/drawable/gild.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + android:fillColor="@android:color/white" + android:pathData="M11.99,2C6.47,2 2,6.48 2,12s4.47,10 9.99,10C17.52,22 22,17.52 22,12S17.52,2 11.99,2zM16.23,18L12,15.45 7.77,18l1.12,-4.81 -3.73,-3.23 4.92,-0.42L12,5l1.92,4.53 4.92,0.42 -3.73,3.23L16.23,18z" /> diff --git a/app/src/main/res/drawable/gold.png b/app/src/main/res/drawable/gold.png index 4c730cad9d..fa850569d4 100644 Binary files a/app/src/main/res/drawable/gold.png and b/app/src/main/res/drawable/gold.png differ diff --git a/app/src/main/res/drawable/grid.xml b/app/src/main/res/drawable/grid.xml deleted file mode 100644 index 257273b1a1..0000000000 --- a/app/src/main/res/drawable/grid.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/hd.xml b/app/src/main/res/drawable/hd.xml index e3283c4d86..eb311839b7 100644 --- a/app/src/main/res/drawable/hd.xml +++ b/app/src/main/res/drawable/hd.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + android:fillColor="@android:color/white" + android:pathData="M19,4L5,4c-1.11,0 -2,0.9 -2,2v12c0,1.1 0.89,2 2,2h14c1.1,0 2,-0.9 2,-2L21,6c0,-1.1 -0.9,-2 -2,-2zM11,15L9.5,15v-2h-2v2L6,15L6,9h1.5v2.5h2L9.5,9L11,9v6zM18,14c0,0.55 -0.45,1 -1,1h-0.75v1.5h-1.5L14.75,15L14,15c-0.55,0 -1,-0.45 -1,-1v-4c0,-0.55 0.45,-1 1,-1h3c0.55,0 1,0.45 1,1v4zM14.5,13.5h2v-3h-2v3z" /> diff --git a/app/src/main/res/drawable/hide.xml b/app/src/main/res/drawable/hide.xml index c123b45046..f5b53c4071 100644 --- a/app/src/main/res/drawable/hide.xml +++ b/app/src/main/res/drawable/hide.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + android:fillColor="@android:color/white" + android:pathData="M12,7c2.76,0 5,2.24 5,5 0,0.65 -0.13,1.26 -0.36,1.83l2.92,2.92c1.51,-1.26 2.7,-2.89 3.43,-4.75 -1.73,-4.39 -6,-7.5 -11,-7.5 -1.4,0 -2.74,0.25 -3.98,0.7l2.16,2.16C10.74,7.13 11.35,7 12,7zM2,4.27l2.28,2.28 0.46,0.46C3.08,8.3 1.78,10.02 1,12c1.73,4.39 6,7.5 11,7.5 1.55,0 3.03,-0.3 4.38,-0.84l0.42,0.42L19.73,22 21,20.73 3.27,3 2,4.27zM7.53,9.8l1.55,1.55c-0.05,0.21 -0.08,0.43 -0.08,0.65 0,1.66 1.34,3 3,3 0.22,0 0.44,-0.03 0.65,-0.08l1.55,1.55c-0.67,0.33 -1.41,0.53 -2.2,0.53 -2.76,0 -5,-2.24 -5,-5 0,-0.79 0.2,-1.53 0.53,-2.2zM11.84,9.02l3.15,3.15 0.02,-0.16c0,-1.66 -1.34,-3 -3,-3l-0.17,0.01z" /> diff --git a/app/src/main/res/drawable/history.xml b/app/src/main/res/drawable/history.xml index 0a32f08824..0f599ccc65 100644 --- a/app/src/main/res/drawable/history.xml +++ b/app/src/main/res/drawable/history.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + android:fillColor="@android:color/white" + android:pathData="M13,3c-4.97,0 -9,4.03 -9,9L1,12l3.89,3.89 0.07,0.14L9,12L6,12c0,-3.87 3.13,-7 7,-7s7,3.13 7,7 -3.13,7 -7,7c-1.93,0 -3.68,-0.79 -4.94,-2.06l-1.42,1.42C8.27,19.99 10.51,21 13,21c4.97,0 9,-4.03 9,-9s-4.03,-9 -9,-9zM12,8v5l4.28,2.54 0.72,-1.21 -3.5,-2.08L13.5,8L12,8z" /> diff --git a/app/src/main/res/drawable/ic_check_all_black.xml b/app/src/main/res/drawable/ic_check_all_black.xml deleted file mode 100644 index 07de582560..0000000000 --- a/app/src/main/res/drawable/ic_check_all_black.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/ic_content_copy.xml b/app/src/main/res/drawable/ic_content_copy.xml deleted file mode 100644 index 7e48c6160f..0000000000 --- a/app/src/main/res/drawable/ic_content_copy.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/ic_format_bold_white_48dp.xml b/app/src/main/res/drawable/ic_format_bold_white_48dp.xml deleted file mode 100644 index eb96375251..0000000000 --- a/app/src/main/res/drawable/ic_format_bold_white_48dp.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/ic_format_italic_white_48dp.xml b/app/src/main/res/drawable/ic_format_italic_white_48dp.xml deleted file mode 100644 index 8882ceea2f..0000000000 --- a/app/src/main/res/drawable/ic_format_italic_white_48dp.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/ic_format_list_bulleted_white_48dp.xml b/app/src/main/res/drawable/ic_format_list_bulleted_white_48dp.xml deleted file mode 100644 index 4c912c9dc6..0000000000 --- a/app/src/main/res/drawable/ic_format_list_bulleted_white_48dp.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/ic_format_list_numbered_white_48dp.xml b/app/src/main/res/drawable/ic_format_list_numbered_white_48dp.xml deleted file mode 100644 index 6488fd9fbc..0000000000 --- a/app/src/main/res/drawable/ic_format_list_numbered_white_48dp.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/ic_format_quote_white_48dp.xml b/app/src/main/res/drawable/ic_format_quote_white_48dp.xml deleted file mode 100644 index 62525e7488..0000000000 --- a/app/src/main/res/drawable/ic_format_quote_white_48dp.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/ic_format_size_white_48dp.xml b/app/src/main/res/drawable/ic_format_size_white_48dp.xml deleted file mode 100644 index e06e6c55c6..0000000000 --- a/app/src/main/res/drawable/ic_format_size_white_48dp.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/ic_launcher.png b/app/src/main/res/drawable/ic_launcher.png index ecd22ec4d8..84120de115 100644 Binary files a/app/src/main/res/drawable/ic_launcher.png and b/app/src/main/res/drawable/ic_launcher.png differ diff --git a/app/src/main/res/drawable/ic_refresh.xml b/app/src/main/res/drawable/ic_refresh.xml deleted file mode 100644 index 9f9c14aef0..0000000000 --- a/app/src/main/res/drawable/ic_refresh.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/ic_share.xml b/app/src/main/res/drawable/ic_share.xml deleted file mode 100644 index 034ea67d5b..0000000000 --- a/app/src/main/res/drawable/ic_share.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/ic_share_link.xml b/app/src/main/res/drawable/ic_share_link.xml deleted file mode 100644 index 678bc0ea9c..0000000000 --- a/app/src/main/res/drawable/ic_share_link.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/iconstarfilled.xml b/app/src/main/res/drawable/iconstarfilled.xml deleted file mode 100644 index 8b6e2bb81e..0000000000 --- a/app/src/main/res/drawable/iconstarfilled.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/ignore.xml b/app/src/main/res/drawable/ignore.xml index b4c00c9a8a..1bbc3df287 100644 --- a/app/src/main/res/drawable/ignore.xml +++ b/app/src/main/res/drawable/ignore.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + android:fillColor="@android:color/white" + android:pathData="M20,18.69L7.84,6.14 5.27,3.49 4,4.76l2.8,2.8v0.01c-0.52,0.99 -0.8,2.16 -0.8,3.42v5l-2,2v1h13.73l2,2L21,19.72l-1,-1.03zM12,22c1.11,0 2,-0.89 2,-2h-4c0,1.11 0.89,2 2,2zM18,14.68L18,11c0,-3.08 -1.64,-5.64 -4.5,-6.32L13.5,4c0,-0.83 -0.67,-1.5 -1.5,-1.5s-1.5,0.67 -1.5,1.5v0.68c-0.15,0.03 -0.29,0.08 -0.42,0.12 -0.1,0.03 -0.2,0.07 -0.3,0.11h-0.01c-0.01,0 -0.01,0 -0.02,0.01 -0.23,0.09 -0.46,0.2 -0.68,0.31 0,0 -0.01,0 -0.01,0.01L18,14.68z" /> diff --git a/app/src/main/res/drawable/image.xml b/app/src/main/res/drawable/image.xml index 9cdf5037a0..ffe59a7b06 100644 --- a/app/src/main/res/drawable/image.xml +++ b/app/src/main/res/drawable/image.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + android:fillColor="@android:color/white" + android:pathData="M19,5v14L5,19L5,5h14m0,-2L5,3c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h14c1.1,0 2,-0.9 2,-2L21,5c0,-1.1 -0.9,-2 -2,-2zM14.14,11.86l-3,3.87L9,13.14 6,17h12l-3.86,-5.14z" /> diff --git a/app/src/main/res/drawable/info.xml b/app/src/main/res/drawable/info.xml new file mode 100644 index 0000000000..8c43b636e3 --- /dev/null +++ b/app/src/main/res/drawable/info.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/infonew.xml b/app/src/main/res/drawable/infonew.xml deleted file mode 100644 index 087871c570..0000000000 --- a/app/src/main/res/drawable/infonew.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/ic_insert_photo_white_48dp.xml b/app/src/main/res/drawable/insert_photo.xml similarity index 50% rename from app/src/main/res/drawable/ic_insert_photo_white_48dp.xml rename to app/src/main/res/drawable/insert_photo.xml index 524606a5ca..cffc7970d4 100644 --- a/app/src/main/res/drawable/ic_insert_photo_white_48dp.xml +++ b/app/src/main/res/drawable/insert_photo.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + android:fillColor="@android:color/white" + android:pathData="M21,19V5c0,-1.1 -0.9,-2 -2,-2H5c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h14c1.1,0 2,-0.9 2,-2zM8.5,13.5l2.5,3.01L14.5,12l4.5,6H5l3.5,-4.5z" /> diff --git a/app/src/main/res/drawable/internet.xml b/app/src/main/res/drawable/internet.xml deleted file mode 100644 index 8e18841347..0000000000 --- a/app/src/main/res/drawable/internet.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/italic.xml b/app/src/main/res/drawable/italic.xml new file mode 100644 index 0000000000..aa5bb44ce3 --- /dev/null +++ b/app/src/main/res/drawable/italic.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/left.xml b/app/src/main/res/drawable/left.xml index c339eccc72..805a9e6a85 100644 --- a/app/src/main/res/drawable/left.xml +++ b/app/src/main/res/drawable/left.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + android:fillColor="@android:color/white" + android:pathData="M20,11H7.83l5.59,-5.59L12,4l-8,8 8,8 1.41,-1.41L7.83,13H20v-2z" /> diff --git a/app/src/main/res/drawable/link.xml b/app/src/main/res/drawable/link.xml index 678bc0ea9c..c6dc3cd905 100644 --- a/app/src/main/res/drawable/link.xml +++ b/app/src/main/res/drawable/link.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + android:fillColor="@android:color/white" + android:pathData="M3.9,12c0,-1.71 1.39,-3.1 3.1,-3.1h4L11,7L7,7c-2.76,0 -5,2.24 -5,5s2.24,5 5,5h4v-1.9L7,15.1c-1.71,0 -3.1,-1.39 -3.1,-3.1zM8,13h8v-2L8,11v2zM17,7h-4v1.9h4c1.71,0 3.1,1.39 3.1,3.1s-1.39,3.1 -3.1,3.1h-4L13,17h4c2.76,0 5,-2.24 5,-5s-2.24,-5 -5,-5z" /> diff --git a/app/src/main/res/drawable/list_bulleted.xml b/app/src/main/res/drawable/list_bulleted.xml new file mode 100644 index 0000000000..574da11560 --- /dev/null +++ b/app/src/main/res/drawable/list_bulleted.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/list_numbered.xml b/app/src/main/res/drawable/list_numbered.xml new file mode 100644 index 0000000000..7434bc71a3 --- /dev/null +++ b/app/src/main/res/drawable/list_numbered.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/lock.xml b/app/src/main/res/drawable/lock.xml index 21597abb5b..2a9869ca20 100644 --- a/app/src/main/res/drawable/lock.xml +++ b/app/src/main/res/drawable/lock.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + android:fillColor="@android:color/white" + 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" /> diff --git a/app/src/main/res/drawable/matiasduarte.png b/app/src/main/res/drawable/matiasduarte.png index aef7cc9894..58b343a4bd 100644 Binary files a/app/src/main/res/drawable/matiasduarte.png and b/app/src/main/res/drawable/matiasduarte.png differ diff --git a/app/src/main/res/drawable/mention.xml b/app/src/main/res/drawable/mention.xml index c0b943c1f9..3b84ddd59e 100644 --- a/app/src/main/res/drawable/mention.xml +++ b/app/src/main/res/drawable/mention.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + android:fillColor="@android:color/white" + android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10h5v-2h-5c-4.34,0 -8,-3.66 -8,-8s3.66,-8 8,-8 8,3.66 8,8v1.43c0,0.79 -0.71,1.57 -1.5,1.57s-1.5,-0.78 -1.5,-1.57L17,12c0,-2.76 -2.24,-5 -5,-5s-5,2.24 -5,5 2.24,5 5,5c1.38,0 2.64,-0.56 3.54,-1.47 0.65,0.89 1.77,1.47 2.96,1.47 1.97,0 3.5,-1.6 3.5,-3.57L22,12c0,-5.52 -4.48,-10 -10,-10zM12,15c-1.66,0 -3,-1.34 -3,-3s1.34,-3 3,-3 3,1.34 3,3 -1.34,3 -3,3z" /> diff --git a/app/src/main/res/drawable/mod.xml b/app/src/main/res/drawable/mod.xml index 9d0d21e46c..926cea9bef 100644 --- a/app/src/main/res/drawable/mod.xml +++ b/app/src/main/res/drawable/mod.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + android:fillColor="@android:color/white" + android:pathData="M12,1L3,5v6c0,5.55 3.84,10.74 9,12 5.16,-1.26 9,-6.45 9,-12L21,5l-9,-4zM10,17l-4,-4 1.41,-1.41L10,14.17l6.59,-6.59L18,9l-8,8z" /> diff --git a/app/src/main/res/drawable/mod_png.png b/app/src/main/res/drawable/mod_png.png deleted file mode 100644 index c3de1b6879..0000000000 Binary files a/app/src/main/res/drawable/mod_png.png and /dev/null differ diff --git a/app/src/main/res/drawable/more.xml b/app/src/main/res/drawable/more.xml index 8d301de6e8..b29b2aef55 100644 --- a/app/src/main/res/drawable/more.xml +++ b/app/src/main/res/drawable/more.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + android:fillColor="@android:color/white" + android:pathData="M12,8c1.1,0 2,-0.9 2,-2s-0.9,-2 -2,-2 -2,0.9 -2,2 0.9,2 2,2zM12,10c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2zM12,16c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2z" /> diff --git a/app/src/main/res/drawable/multicolumn.xml b/app/src/main/res/drawable/multicolumn.xml index e00647263b..3a073830cd 100644 --- a/app/src/main/res/drawable/multicolumn.xml +++ b/app/src/main/res/drawable/multicolumn.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + android:fillColor="@android:color/white" + android:pathData="M3,13h8L11,3L3,3v10zM3,21h8v-6L3,15v6zM13,21h8L21,11h-8v10zM13,3v6h8L21,3h-8z" /> diff --git a/app/src/main/res/drawable/mute.xml b/app/src/main/res/drawable/mute.xml index 80473aff78..75370a190d 100644 --- a/app/src/main/res/drawable/mute.xml +++ b/app/src/main/res/drawable/mute.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + android:fillColor="@android:color/white" + android:pathData="M16.5,12c0,-1.77 -1.02,-3.29 -2.5,-4.03v2.21l2.45,2.45c0.03,-0.2 0.05,-0.41 0.05,-0.63zM19,12c0,0.94 -0.2,1.82 -0.54,2.64l1.51,1.51C20.63,14.91 21,13.5 21,12c0,-4.28 -2.99,-7.86 -7,-8.77v2.06c2.89,0.86 5,3.54 5,6.71zM4.27,3L3,4.27 7.73,9L3,9v6h4l5,5v-6.73l4.25,4.25c-0.67,0.52 -1.42,0.93 -2.25,1.18v2.06c1.38,-0.31 2.63,-0.95 3.69,-1.81L19.73,21 21,19.73l-9,-9L4.27,3zM12,4L9.91,6.09 12,8.18L12,4z" /> diff --git a/app/src/main/res/drawable/nav.xml b/app/src/main/res/drawable/navigation.xml similarity index 55% rename from app/src/main/res/drawable/nav.xml rename to app/src/main/res/drawable/navigation.xml index 379f31034e..6d38066c54 100644 --- a/app/src/main/res/drawable/nav.xml +++ b/app/src/main/res/drawable/navigation.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + android:fillColor="@android:color/white" + android:pathData="M12,10.9c-0.61,0 -1.1,0.49 -1.1,1.1s0.49,1.1 1.1,1.1c0.61,0 1.1,-0.49 1.1,-1.1s-0.49,-1.1 -1.1,-1.1zM12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM14.19,14.19L6,18l3.81,-8.19L18,6l-3.81,8.19z" /> diff --git a/app/src/main/res/drawable/nighttheme.xml b/app/src/main/res/drawable/nighttheme.xml index 6a05417b8e..96987936e0 100644 --- a/app/src/main/res/drawable/nighttheme.xml +++ b/app/src/main/res/drawable/nighttheme.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + android:fillColor="@android:color/white" + android:pathData="M10,2c-1.82,0 -3.53,0.5 -5,1.35C7.99,5.08 10,8.3 10,12s-2.01,6.92 -5,8.65C6.47,21.5 8.18,22 10,22c5.52,0 10,-4.48 10,-10S15.52,2 10,2z" /> diff --git a/app/src/main/res/drawable/note.xml b/app/src/main/res/drawable/note.xml index 0b5b5eb01e..e14ec2fa72 100644 --- a/app/src/main/res/drawable/note.xml +++ b/app/src/main/res/drawable/note.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + android:fillColor="@android:color/white" + android:pathData="M22,10l-6,-6L4,4c-1.1,0 -2,0.9 -2,2v12.01c0,1.1 0.9,1.99 2,1.99l16,-0.01c1.1,0 2,-0.89 2,-1.99v-8zM15,5.5l5.5,5.5L15,11L15,5.5z" /> diff --git a/app/src/main/res/drawable/notif.png b/app/src/main/res/drawable/notif.png index 260a35abb6..bc2c868d62 100644 Binary files a/app/src/main/res/drawable/notif.png and b/app/src/main/res/drawable/notif.png differ diff --git a/app/src/main/res/drawable/notifs.xml b/app/src/main/res/drawable/notifs.xml index 82048137c9..c6181c07bf 100644 --- a/app/src/main/res/drawable/notifs.xml +++ b/app/src/main/res/drawable/notifs.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + android:fillColor="@android:color/white" + android:pathData="M12,22c1.1,0 2,-0.9 2,-2h-4c0,1.1 0.9,2 2,2zM18,16v-5c0,-3.07 -1.63,-5.64 -4.5,-6.32L13.5,4c0,-0.83 -0.67,-1.5 -1.5,-1.5s-1.5,0.67 -1.5,1.5v0.68C7.64,5.36 6,7.92 6,11v5l-2,2v1h16v-1l-2,-2zM16,17L8,17v-6c0,-2.48 1.51,-4.5 4,-4.5s4,2.02 4,4.5v6z" /> diff --git a/app/src/main/res/drawable/nsfw.png b/app/src/main/res/drawable/nsfw.png index 6575cc5d81..3762550410 100644 Binary files a/app/src/main/res/drawable/nsfw.png and b/app/src/main/res/drawable/nsfw.png differ diff --git a/app/src/main/res/drawable/offline.xml b/app/src/main/res/drawable/offline.xml index e40579708f..3d605e450f 100644 --- a/app/src/main/res/drawable/offline.xml +++ b/app/src/main/res/drawable/offline.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + android:fillColor="@android:color/white" + android:pathData="M19.35,10.04C18.67,6.59 15.64,4 12,4c-1.48,0 -2.85,0.43 -4.01,1.17l1.46,1.46C10.21,6.23 11.08,6 12,6c3.04,0 5.5,2.46 5.5,5.5v0.5H19c1.66,0 3,1.34 3,3 0,1.13 -0.64,2.11 -1.56,2.62l1.45,1.45C23.16,18.16 24,16.68 24,15c0,-2.64 -2.05,-4.78 -4.65,-4.96zM3,5.27l2.75,2.74C2.56,8.15 0,10.77 0,14c0,3.31 2.69,6 6,6h11.73l2,2L21,20.73 4.27,4 3,5.27zM7.73,10l8,8H6c-2.21,0 -4,-1.79 -4,-4s1.79,-4 4,-4h1.73z" /> diff --git a/app/src/main/res/drawable/online.xml b/app/src/main/res/drawable/online.xml index 8e18841347..ead68a7271 100644 --- a/app/src/main/res/drawable/online.xml +++ b/app/src/main/res/drawable/online.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + android:fillColor="@android:color/white" + android:pathData="M12,6c2.62,0 4.88,1.86 5.39,4.43l0.3,1.5 1.53,0.11c1.56,0.1 2.78,1.41 2.78,2.96 0,1.65 -1.35,3 -3,3H6c-2.21,0 -4,-1.79 -4,-4 0,-2.05 1.53,-3.76 3.56,-3.97l1.07,-0.11 0.5,-0.95C8.08,7.14 9.94,6 12,6m0,-2C9.11,4 6.6,5.64 5.35,8.04 2.34,8.36 0,10.91 0,14c0,3.31 2.69,6 6,6h13c2.76,0 5,-2.24 5,-5 0,-2.64 -2.05,-4.78 -4.65,-4.96C18.67,6.59 15.64,4 12,4z" /> diff --git a/app/src/main/res/drawable/open_external.xml b/app/src/main/res/drawable/open_external.xml new file mode 100644 index 0000000000..43cc81aa3f --- /dev/null +++ b/app/src/main/res/drawable/open_external.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_open_in_browser.xml b/app/src/main/res/drawable/open_in_browser.xml similarity index 50% rename from app/src/main/res/drawable/ic_open_in_browser.xml rename to app/src/main/res/drawable/open_in_browser.xml index 3505d7ddf7..10f351a70a 100644 --- a/app/src/main/res/drawable/ic_open_in_browser.xml +++ b/app/src/main/res/drawable/open_in_browser.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + android:fillColor="@android:color/white" + android:pathData="M19,19H5V5h7V3H5c-1.11,0 -2,0.9 -2,2v14c0,1.1 0.89,2 2,2h14c1.1,0 2,-0.9 2,-2v-7h-2v7zM14,3v2h3.59l-9.83,9.83 1.41,1.41L19,6.41V10h2V3h-7z" /> diff --git a/app/src/main/res/drawable/openexternal.xml b/app/src/main/res/drawable/openexternal.xml deleted file mode 100644 index 3f059d765f..0000000000 --- a/app/src/main/res/drawable/openexternal.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/palette.xml b/app/src/main/res/drawable/palette.xml new file mode 100644 index 0000000000..31bd991d49 --- /dev/null +++ b/app/src/main/res/drawable/palette.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/person.xml b/app/src/main/res/drawable/person.xml index 1a48d85df2..5587f05301 100644 --- a/app/src/main/res/drawable/person.xml +++ b/app/src/main/res/drawable/person.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + android:fillColor="@android:color/white" + android:pathData="M12,12c2.21,0 4,-1.79 4,-4s-1.79,-4 -4,-4 -4,1.79 -4,4 1.79,4 4,4zM12,14c-2.67,0 -8,1.34 -8,4v2h16v-2c0,-2.66 -5.33,-4 -8,-4z" /> diff --git a/app/src/main/res/drawable/pin.xml b/app/src/main/res/drawable/pin.xml index 23c6a1bb41..12d0b1e066 100644 --- a/app/src/main/res/drawable/pin.xml +++ b/app/src/main/res/drawable/pin.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + android:fillColor="@android:color/white" + android:pathData="M16,12V4H17V2H7V4H8V12L6,14V16H11.2V22H12.8V16H18V14L16,12Z" /> diff --git a/app/src/main/res/drawable/platinum.png b/app/src/main/res/drawable/platinum.png index 97a3982e8d..d2a9346f78 100644 Binary files a/app/src/main/res/drawable/platinum.png and b/app/src/main/res/drawable/platinum.png differ diff --git a/app/src/main/res/drawable/play.xml b/app/src/main/res/drawable/play.xml index 1f75805f18..88f629175b 100644 --- a/app/src/main/res/drawable/play.xml +++ b/app/src/main/res/drawable/play.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + android:fillColor="@android:color/white" + android:pathData="M8,5v14l11,-7z" /> diff --git a/app/src/main/res/drawable/profile.xml b/app/src/main/res/drawable/profile.xml index f501c95d84..568656a1cd 100644 --- a/app/src/main/res/drawable/profile.xml +++ b/app/src/main/res/drawable/profile.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + android:fillColor="@android:color/white" + android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,5c1.66,0 3,1.34 3,3s-1.34,3 -3,3 -3,-1.34 -3,-3 1.34,-3 3,-3zM12,19.2c-2.5,0 -4.71,-1.28 -6,-3.22 0.03,-1.99 4,-3.08 6,-3.08 1.99,0 5.97,1.09 6,3.08 -1.29,1.94 -3.5,3.22 -6,3.22z" /> diff --git a/app/src/main/res/drawable/quote.xml b/app/src/main/res/drawable/quote.xml new file mode 100644 index 0000000000..617c2659e4 --- /dev/null +++ b/app/src/main/res/drawable/quote.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/reddit.png b/app/src/main/res/drawable/reddit.png index 63c3981249..8c8174526c 100644 Binary files a/app/src/main/res/drawable/reddit.png and b/app/src/main/res/drawable/reddit.png differ diff --git a/app/src/main/res/drawable/refresh.xml b/app/src/main/res/drawable/refresh.xml index 5ae83ba3bf..311594eaa6 100644 --- a/app/src/main/res/drawable/refresh.xml +++ b/app/src/main/res/drawable/refresh.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + android:fillColor="@android:color/white" + android:pathData="M17.65,6.35C16.2,4.9 14.21,4 12,4c-4.42,0 -7.99,3.58 -7.99,8s3.57,8 7.99,8c3.73,0 6.84,-2.55 7.73,-6h-2.08c-0.82,2.33 -3.04,4 -5.65,4 -3.31,0 -6,-2.69 -6,-6s2.69,-6 6,-6c1.66,0 3.14,0.69 4.22,1.78L13,11h7V4l-2.35,2.35z" /> diff --git a/app/src/main/res/drawable/reply.xml b/app/src/main/res/drawable/reply.xml index f86f11c02b..d7e0cb1e70 100644 --- a/app/src/main/res/drawable/reply.xml +++ b/app/src/main/res/drawable/reply.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + android:fillColor="@android:color/white" + android:pathData="M10,9V5l-7,7 7,7v-4.1c5,0 8.5,1.6 11,5.1 -1,-5 -4,-10 -11,-11z" /> diff --git a/app/src/main/res/drawable/report.xml b/app/src/main/res/drawable/report.xml index b33377a2c6..26d48d7a7c 100644 --- a/app/src/main/res/drawable/report.xml +++ b/app/src/main/res/drawable/report.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + android:fillColor="@android:color/white" + android:pathData="M15.73,3L8.27,3L3,8.27v7.46L8.27,21h7.46L21,15.73L21,8.27L15.73,3zM12,17.3c-0.72,0 -1.3,-0.58 -1.3,-1.3 0,-0.72 0.58,-1.3 1.3,-1.3 0.72,0 1.3,0.58 1.3,1.3 0,0.72 -0.58,1.3 -1.3,1.3zM13,13h-2L11,7h2v6z" /> diff --git a/app/src/main/res/drawable/report_reason.xml b/app/src/main/res/drawable/report_reason.xml new file mode 100644 index 0000000000..4af36ce4b0 --- /dev/null +++ b/app/src/main/res/drawable/report_reason.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/reportreason.xml b/app/src/main/res/drawable/reportreason.xml deleted file mode 100644 index 7b95fd9d9f..0000000000 --- a/app/src/main/res/drawable/reportreason.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/restorecloud.xml b/app/src/main/res/drawable/restore_cloud.xml similarity index 58% rename from app/src/main/res/drawable/restorecloud.xml rename to app/src/main/res/drawable/restore_cloud.xml index 0f56a12d08..fb8c51f072 100644 --- a/app/src/main/res/drawable/restorecloud.xml +++ b/app/src/main/res/drawable/restore_cloud.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + android:fillColor="@android:color/white" + android:pathData="M19.35,10.04C18.67,6.59 15.64,4 12,4 9.11,4 6.6,5.64 5.35,8.04 2.34,8.36 0,10.91 0,14c0,3.31 2.69,6 6,6h13c2.76,0 5,-2.24 5,-5 0,-2.64 -2.05,-4.78 -4.65,-4.96zM17,13l-5,5 -5,-5h3V9h4v4h3z" /> diff --git a/app/src/main/res/drawable/restore_file.xml b/app/src/main/res/drawable/restore_file.xml new file mode 100644 index 0000000000..6b1a6f2649 --- /dev/null +++ b/app/src/main/res/drawable/restore_file.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/restorefile.xml b/app/src/main/res/drawable/restorefile.xml deleted file mode 100644 index 195aea8c9d..0000000000 --- a/app/src/main/res/drawable/restorefile.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/roundedbackmod.xml b/app/src/main/res/drawable/roundedbackmod.xml deleted file mode 100644 index b406c65ea6..0000000000 --- a/app/src/main/res/drawable/roundedbackmod.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/sad.png b/app/src/main/res/drawable/sad.png deleted file mode 100644 index 4243f99360..0000000000 Binary files a/app/src/main/res/drawable/sad.png and /dev/null differ diff --git a/app/src/main/res/drawable/save.xml b/app/src/main/res/drawable/save.xml index 807347667b..5cfc347c06 100644 --- a/app/src/main/res/drawable/save.xml +++ b/app/src/main/res/drawable/save.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + android:fillColor="@android:color/white" + android:pathData="M19,9h-4V3H9v6H5l7,7 7,-7zM5,18v2h14v-2H5z" /> diff --git a/app/src/main/res/drawable/savecontent.xml b/app/src/main/res/drawable/save_content.xml similarity index 61% rename from app/src/main/res/drawable/savecontent.xml rename to app/src/main/res/drawable/save_content.xml index 6b251ff2c9..56aad040e8 100644 --- a/app/src/main/res/drawable/savecontent.xml +++ b/app/src/main/res/drawable/save_content.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + android:fillColor="@android:color/white" + android:pathData="M17,3L5,3c-1.11,0 -2,0.9 -2,2v14c0,1.1 0.89,2 2,2h14c1.1,0 2,-0.9 2,-2L21,7l-4,-4zM12,19c-1.66,0 -3,-1.34 -3,-3s1.34,-3 3,-3 3,1.34 3,3 -1.34,3 -3,3zM15,9L5,9L5,5h10v4z" /> diff --git a/app/src/main/res/drawable/save_png.png b/app/src/main/res/drawable/save_png.png deleted file mode 100644 index 3b9de2bf0b..0000000000 Binary files a/app/src/main/res/drawable/save_png.png and /dev/null differ diff --git a/app/src/main/res/drawable/search.xml b/app/src/main/res/drawable/search.xml index c2d216051c..aefdcef5ca 100644 --- a/app/src/main/res/drawable/search.xml +++ b/app/src/main/res/drawable/search.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + android:fillColor="@android:color/white" + android:pathData="M15.5,14h-0.79l-0.28,-0.27C15.41,12.59 16,11.11 16,9.5 16,5.91 13.09,3 9.5,3S3,5.91 3,9.5 5.91,16 9.5,16c1.61,0 3.09,-0.59 4.23,-1.57l0.27,0.28v0.79l5,4.99L20.49,19l-4.99,-5zM9.5,14C7.01,14 5,11.99 5,9.5S7.01,5 9.5,5 14,7.01 14,9.5 11.99,14 9.5,14z" /> diff --git a/app/src/main/res/drawable/send.xml b/app/src/main/res/drawable/send.xml index c178e5e93b..e72d4860c7 100644 --- a/app/src/main/res/drawable/send.xml +++ b/app/src/main/res/drawable/send.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + android:fillColor="@android:color/white" + android:pathData="M2.01,21L23,12 2.01,3 2,10l15,2 -15,2z" /> diff --git a/app/src/main/res/drawable/settings.xml b/app/src/main/res/drawable/settings.xml index c11919c669..ea7e236d17 100644 --- a/app/src/main/res/drawable/settings.xml +++ b/app/src/main/res/drawable/settings.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + android:fillColor="@android:color/white" + android:pathData="M19.14,12.94c0.04,-0.3 0.06,-0.61 0.06,-0.94c0,-0.32 -0.02,-0.64 -0.07,-0.94l2.03,-1.58c0.18,-0.14 0.23,-0.41 0.12,-0.61l-1.92,-3.32c-0.12,-0.22 -0.37,-0.29 -0.59,-0.22l-2.39,0.96c-0.5,-0.38 -1.03,-0.7 -1.62,-0.94L14.4,2.81c-0.04,-0.24 -0.24,-0.41 -0.48,-0.41h-3.84c-0.24,0 -0.43,0.17 -0.47,0.41L9.25,5.35C8.66,5.59 8.12,5.92 7.63,6.29L5.24,5.33c-0.22,-0.08 -0.47,0 -0.59,0.22L2.74,8.87C2.62,9.08 2.66,9.34 2.86,9.48l2.03,1.58C4.84,11.36 4.8,11.69 4.8,12s0.02,0.64 0.07,0.94l-2.03,1.58c-0.18,0.14 -0.23,0.41 -0.12,0.61l1.92,3.32c0.12,0.22 0.37,0.29 0.59,0.22l2.39,-0.96c0.5,0.38 1.03,0.7 1.62,0.94l0.36,2.54c0.05,0.24 0.24,0.41 0.48,0.41h3.84c0.24,0 0.44,-0.17 0.47,-0.41l0.36,-2.54c0.59,-0.24 1.13,-0.56 1.62,-0.94l2.39,0.96c0.22,0.08 0.47,0 0.59,-0.22l1.92,-3.32c0.12,-0.22 0.07,-0.47 -0.12,-0.61L19.14,12.94zM12,15.6c-1.98,0 -3.6,-1.62 -3.6,-3.6s1.62,-3.6 3.6,-3.6s3.6,1.62 3.6,3.6S13.98,15.6 12,15.6z" /> diff --git a/app/src/main/res/drawable/shadow_bottom.png b/app/src/main/res/drawable/shadow_bottom.png index 4569174a10..34b84a72aa 100644 Binary files a/app/src/main/res/drawable/shadow_bottom.png and b/app/src/main/res/drawable/shadow_bottom.png differ diff --git a/app/src/main/res/drawable/shadow_left.png b/app/src/main/res/drawable/shadow_left.png index 82c71c2f28..5ef74c5807 100644 Binary files a/app/src/main/res/drawable/shadow_left.png and b/app/src/main/res/drawable/shadow_left.png differ diff --git a/app/src/main/res/drawable/shadow_right.png b/app/src/main/res/drawable/shadow_right.png index 0b7a17b13f..9415ec5f9d 100644 Binary files a/app/src/main/res/drawable/shadow_right.png and b/app/src/main/res/drawable/shadow_right.png differ diff --git a/app/src/main/res/drawable/shadow_top.png b/app/src/main/res/drawable/shadow_top.png index ba8a96b32a..174d644c50 100644 Binary files a/app/src/main/res/drawable/shadow_top.png and b/app/src/main/res/drawable/shadow_top.png differ diff --git a/app/src/main/res/drawable/shadowbox.xml b/app/src/main/res/drawable/shadowbox.xml index ccdae94ab2..223a0b39de 100644 --- a/app/src/main/res/drawable/shadowbox.xml +++ b/app/src/main/res/drawable/shadowbox.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + android:fillColor="@android:color/white" + android:pathData="M7,19h10L17,4L7,4v15zM2,17h4L6,6L2,6v11zM18,6v11h4L22,6h-4z" /> diff --git a/app/src/main/res/drawable/share.xml b/app/src/main/res/drawable/share.xml index 034ea67d5b..ce75f383ab 100644 --- a/app/src/main/res/drawable/share.xml +++ b/app/src/main/res/drawable/share.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + android:fillColor="@android:color/white" + android:pathData="M18,16.08c-0.76,0 -1.44,0.3 -1.96,0.77L8.91,12.7c0.05,-0.23 0.09,-0.46 0.09,-0.7s-0.04,-0.47 -0.09,-0.7l7.05,-4.11c0.54,0.5 1.25,0.81 2.04,0.81 1.66,0 3,-1.34 3,-3s-1.34,-3 -3,-3 -3,1.34 -3,3c0,0.24 0.04,0.47 0.09,0.7L8.04,9.81C7.5,9.31 6.79,9 6,9c-1.66,0 -3,1.34 -3,3s1.34,3 3,3c0.79,0 1.5,-0.31 2.04,-0.81l7.12,4.16c-0.05,0.21 -0.08,0.43 -0.08,0.65 0,1.61 1.31,2.92 2.92,2.92 1.61,0 2.92,-1.31 2.92,-2.92s-1.31,-2.92 -2.92,-2.92z" /> diff --git a/app/src/main/res/drawable/sidebar_inbox.xml b/app/src/main/res/drawable/sidebar_inbox.xml index 673ecba1a2..4d54e4d832 100644 --- a/app/src/main/res/drawable/sidebar_inbox.xml +++ b/app/src/main/res/drawable/sidebar_inbox.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + android:fillColor="@android:color/white" + android:pathData="M20,4L4,4c-1.1,0 -1.99,0.9 -1.99,2L2,18c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2L22,6c0,-1.1 -0.9,-2 -2,-2zM20,8l-8,5 -8,-5L4,6l8,5 8,-5v2z" /> diff --git a/app/src/main/res/drawable/silver.png b/app/src/main/res/drawable/silver.png index 463b9c5276..2f67f88337 100644 Binary files a/app/src/main/res/drawable/silver.png and b/app/src/main/res/drawable/silver.png differ diff --git a/app/src/main/res/drawable/sort.xml b/app/src/main/res/drawable/sort.xml index bc08009fad..51843d136b 100644 --- a/app/src/main/res/drawable/sort.xml +++ b/app/src/main/res/drawable/sort.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + android:fillColor="@android:color/white" + android:pathData="M3,18h6v-2L3,16v2zM3,6v2h18L21,6L3,6zM3,13h12v-2L3,11v2z" /> diff --git a/app/src/main/res/drawable/spam.xml b/app/src/main/res/drawable/spam.xml index a3a87a908c..1be2144302 100644 --- a/app/src/main/res/drawable/spam.xml +++ b/app/src/main/res/drawable/spam.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + android:fillColor="@android:color/white" + android:pathData="M14.4,6L14,4H5v17h2v-7h5.6l0.4,2h7V6z" /> diff --git a/app/src/main/res/drawable/spoil.xml b/app/src/main/res/drawable/spoil.xml index 0406e52d8c..bc60bf103b 100644 --- a/app/src/main/res/drawable/spoil.xml +++ b/app/src/main/res/drawable/spoil.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + android:fillColor="@android:color/white" + android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM17,13L7,13v-2h10v2z" /> diff --git a/app/src/main/res/drawable/spoiler.png b/app/src/main/res/drawable/spoiler.png index ed341faba8..ee23bf20a0 100644 Binary files a/app/src/main/res/drawable/spoiler.png and b/app/src/main/res/drawable/spoiler.png differ diff --git a/app/src/main/res/drawable/star.xml b/app/src/main/res/drawable/star.xml new file mode 100644 index 0000000000..8bb6680974 --- /dev/null +++ b/app/src/main/res/drawable/star.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/strike.xml b/app/src/main/res/drawable/strike.xml index a87aac5faf..cb25154fc5 100644 --- a/app/src/main/res/drawable/strike.xml +++ b/app/src/main/res/drawable/strike.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + android:fillColor="@android:color/white" + android:pathData="M10,19h4v-3h-4v3zM5,4v3h5v3h4V7h5V4H5zM3,14h18v-2H3v2z" /> diff --git a/app/src/main/res/drawable/sub.xml b/app/src/main/res/drawable/sub.xml index 7cad8ef50d..7d0e1cf35a 100644 --- a/app/src/main/res/drawable/sub.xml +++ b/app/src/main/res/drawable/sub.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + android:fillColor="@android:color/white" + android:pathData="M17,3L7,3c-1.1,0 -1.99,0.9 -1.99,2L5,21l7,-3 7,3L19,5c0,-1.1 -0.9,-2 -2,-2zM17,18l-5,-2.18L7,18L7,5h10v13z" /> diff --git a/app/src/main/res/drawable/subscribed.xml b/app/src/main/res/drawable/subscribed.xml index 3910aadb1a..aecaf234a8 100644 --- a/app/src/main/res/drawable/subscribed.xml +++ b/app/src/main/res/drawable/subscribed.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + android:fillColor="@android:color/white" + android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM10,17l-5,-5 1.41,-1.41L10,14.17l7.59,-7.59L19,8l-9,9z" /> diff --git a/app/src/main/res/drawable/support.xml b/app/src/main/res/drawable/support.xml index 1abe32bba5..d76a72c542 100644 --- a/app/src/main/res/drawable/support.xml +++ b/app/src/main/res/drawable/support.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + android:fillColor="@android:color/white" + android:pathData="M1,21h4L5,9L1,9v12zM23,10c0,-1.1 -0.9,-2 -2,-2h-6.31l0.95,-4.57 0.03,-0.32c0,-0.41 -0.17,-0.79 -0.44,-1.06L14.17,1 7.59,7.59C7.22,7.95 7,8.45 7,9v10c0,1.1 0.9,2 2,2h9c0.83,0 1.54,-0.5 1.84,-1.22l3.02,-7.05c0.09,-0.23 0.14,-0.47 0.14,-0.73v-2z" /> diff --git a/app/src/main/res/drawable/sync.xml b/app/src/main/res/drawable/sync.xml new file mode 100644 index 0000000000..0b74032b5b --- /dev/null +++ b/app/src/main/res/drawable/sync.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/synccit.png b/app/src/main/res/drawable/synccit.png index 925d4bcf2c..b289a50f46 100644 Binary files a/app/src/main/res/drawable/synccit.png and b/app/src/main/res/drawable/synccit.png differ diff --git a/app/src/main/res/drawable/theme.xml b/app/src/main/res/drawable/theme.xml index aec89191fa..0faaa62397 100644 --- a/app/src/main/res/drawable/theme.xml +++ b/app/src/main/res/drawable/theme.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + android:fillColor="@android:color/white" + android:pathData="M17.66,7.93L12,2.27 6.34,7.93c-3.12,3.12 -3.12,8.19 0,11.31C7.9,20.8 9.95,21.58 12,21.58c2.05,0 4.1,-0.78 5.66,-2.34 3.12,-3.12 3.12,-8.19 0,-11.31zM12,19.59c-1.6,0 -3.11,-0.62 -4.24,-1.76C6.62,16.69 6,15.19 6,13.59s0.62,-3.11 1.76,-4.24L12,5.1v14.49z" /> diff --git a/app/src/main/res/drawable/time.xml b/app/src/main/res/drawable/time.xml deleted file mode 100644 index 52eab53931..0000000000 --- a/app/src/main/res/drawable/time.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/undo.xml b/app/src/main/res/drawable/undo.xml index 85f213ab5e..fc6e2e6dca 100644 --- a/app/src/main/res/drawable/undo.xml +++ b/app/src/main/res/drawable/undo.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + android:fillColor="@android:color/white" + android:pathData="M12.5,8c-2.65,0 -5.05,0.99 -6.9,2.6L2,7v9h9l-3.62,-3.62c1.39,-1.16 3.16,-1.88 5.12,-1.88 3.54,0 6.55,2.31 7.6,5.5l2.37,-0.78C21.08,11.03 17.15,8 12.5,8z" /> diff --git a/app/src/main/res/drawable/unignore.xml b/app/src/main/res/drawable/unignore.xml index 38ff9bd5d5..2757b5c9e0 100644 --- a/app/src/main/res/drawable/unignore.xml +++ b/app/src/main/res/drawable/unignore.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + android:fillColor="@android:color/white" + android:pathData="M7.58,4.08L6.15,2.65C3.75,4.48 2.17,7.3 2.03,10.5h2c0.15,-2.65 1.51,-4.97 3.55,-6.42zM19.97,10.5h2c-0.15,-3.2 -1.73,-6.02 -4.12,-7.85l-1.42,1.43c2.02,1.45 3.39,3.77 3.54,6.42zM18,11c0,-3.07 -1.64,-5.64 -4.5,-6.32L13.5,4c0,-0.83 -0.67,-1.5 -1.5,-1.5s-1.5,0.67 -1.5,1.5v0.68C7.63,5.36 6,7.92 6,11v5l-2,2v1h16v-1l-2,-2v-5zM12,22c0.14,0 0.27,-0.01 0.4,-0.04 0.65,-0.14 1.18,-0.58 1.44,-1.18 0.1,-0.24 0.15,-0.5 0.15,-0.78h-4c0.01,1.1 0.9,2 2.01,2z" /> diff --git a/app/src/main/res/drawable/up.xml b/app/src/main/res/drawable/up.xml index 712b2977b9..deb25f07c1 100644 --- a/app/src/main/res/drawable/up.xml +++ b/app/src/main/res/drawable/up.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + android:fillColor="@android:color/white" + android:pathData="M7.41,15.41L12,10.83l4.59,4.58L18,14l-6,-6 -6,6z" /> diff --git a/app/src/main/res/drawable/upload.xml b/app/src/main/res/drawable/upload.xml index 3f9ff6541b..407a1ffb43 100644 --- a/app/src/main/res/drawable/upload.xml +++ b/app/src/main/res/drawable/upload.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + android:fillColor="@android:color/white" + android:pathData="M19.35,10.04C18.67,6.59 15.64,4 12,4 9.11,4 6.6,5.64 5.35,8.04 2.34,8.36 0,10.91 0,14c0,3.31 2.69,6 6,6h13c2.76,0 5,-2.24 5,-5 0,-2.64 -2.05,-4.78 -4.65,-4.96zM14,13v4h-4v-4H7l5,-5 5,5h-3z" /> diff --git a/app/src/main/res/drawable/upvoted.xml b/app/src/main/res/drawable/upvoted.xml new file mode 100644 index 0000000000..4ad44218e9 --- /dev/null +++ b/app/src/main/res/drawable/upvoted.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/upvoteicon.xml b/app/src/main/res/drawable/upvoteicon.xml deleted file mode 100644 index a0227a11f5..0000000000 --- a/app/src/main/res/drawable/upvoteicon.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_visibility.xml b/app/src/main/res/drawable/visibility.xml similarity index 65% rename from app/src/main/res/drawable/ic_visibility.xml rename to app/src/main/res/drawable/visibility.xml index 0254ed3492..ef50789007 100644 --- a/app/src/main/res/drawable/ic_visibility.xml +++ b/app/src/main/res/drawable/visibility.xml @@ -1,9 +1,9 @@ + android:viewportWidth="24" + android:viewportHeight="24"> + android:fillColor="@android:color/white" + android:pathData="M12,4.5C7,4.5 2.73,7.61 1,12c1.73,4.39 6,7.5 11,7.5s9.27,-3.11 11,-7.5c-1.73,-4.39 -6,-7.5 -11,-7.5zM12,17c-2.76,0 -5,-2.24 -5,-5s2.24,-5 5,-5 5,2.24 5,5 -2.24,5 -5,5zM12,9c-1.66,0 -3,1.34 -3,3s1.34,3 3,3 3,-1.34 3,-3 -1.34,-3 -3,-3z" /> diff --git a/app/src/main/res/drawable/web.png b/app/src/main/res/drawable/web.png index 06591fc3b9..b48997fec3 100644 Binary files a/app/src/main/res/drawable/web.png and b/app/src/main/res/drawable/web.png differ diff --git a/app/src/main/res/drawable/wiki.xml b/app/src/main/res/drawable/wiki.xml index 4afa7d8baa..ffbcd3cd3c 100644 --- a/app/src/main/res/drawable/wiki.xml +++ b/app/src/main/res/drawable/wiki.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + android:fillColor="@android:color/white" + android:pathData="M18,2H6c-1.1,0 -2,0.9 -2,2v16c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2V4c0,-1.1 -0.9,-2 -2,-2zM6,4h5v8l-2.5,-1.5L6,12V4z" /> diff --git a/app/src/main/res/drawable/world.xml b/app/src/main/res/drawable/world.xml index 8ceb5eafe2..7a1ab40046 100644 --- a/app/src/main/res/drawable/world.xml +++ b/app/src/main/res/drawable/world.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + android:fillColor="@android:color/white" + android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM11,19.93c-3.95,-0.49 -7,-3.85 -7,-7.93 0,-0.62 0.08,-1.21 0.21,-1.79L9,15v1c0,1.1 0.9,2 2,2v1.93zM17.9,17.39c-0.26,-0.81 -1,-1.39 -1.9,-1.39h-1v-3c0,-0.55 -0.45,-1 -1,-1L8,12v-2h2c0.55,0 1,-0.45 1,-1L11,7h2c1.1,0 2,-0.9 2,-2v-0.41c2.93,1.19 5,4.06 5,7.41 0,2.08 -0.8,3.97 -2.1,5.39z" /> diff --git a/app/src/main/res/layout/activity_gif.xml b/app/src/main/res/layout/activity_gif.xml deleted file mode 100644 index 8df898b890..0000000000 --- a/app/src/main/res/layout/activity_gif.xml +++ /dev/null @@ -1,87 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/activity_image.xml b/app/src/main/res/layout/activity_image.xml deleted file mode 100644 index c04ee687e4..0000000000 --- a/app/src/main/res/layout/activity_image.xml +++ /dev/null @@ -1,72 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/activity_imgur.xml b/app/src/main/res/layout/activity_imgur.xml deleted file mode 100644 index a9e340df06..0000000000 --- a/app/src/main/res/layout/activity_imgur.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/activity_internet.xml b/app/src/main/res/layout/activity_internet.xml deleted file mode 100644 index 221b8c8d0d..0000000000 --- a/app/src/main/res/layout/activity_internet.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - - - diff --git a/app/src/main/res/layout/activity_overview.xml b/app/src/main/res/layout/activity_overview.xml index d8f7534ce4..9b19293c66 100644 --- a/app/src/main/res/layout/activity_overview.xml +++ b/app/src/main/res/layout/activity_overview.xml @@ -64,9 +64,9 @@ android:layout_marginBottom="8dp" android:background="?attr/selectableItemBackgroundBorderless" android:clickable="true" - android:tint="@color/white" android:visibility="gone" - app:srcCompat="@drawable/close" /> + app:srcCompat="@drawable/close" + android:tint="@color/white" /> diff --git a/app/src/main/res/layout/activity_search.xml b/app/src/main/res/layout/activity_search.xml index 1658578e5d..5b91a4c984 100644 --- a/app/src/main/res/layout/activity_search.xml +++ b/app/src/main/res/layout/activity_search.xml @@ -5,7 +5,7 @@ android:background="?attr/activity_background" android:orientation="vertical"> - @@ -21,7 +21,7 @@ android:listSelector="@android:color/transparent" android:orientation="vertical"> - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/activity_settings_comments_child.xml b/app/src/main/res/layout/activity_settings_comments_child.xml index cbfcb13ad0..6d8a66e170 100644 --- a/app/src/main/res/layout/activity_settings_comments_child.xml +++ b/app/src/main/res/layout/activity_settings_comments_child.xml @@ -361,6 +361,49 @@ android:textColorHint="?attr/fontColor"/> + + + + + + + + + + + + + - \ No newline at end of file + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/activity_settings_filters.xml b/app/src/main/res/layout/activity_settings_filters.xml index ded63e1949..de40004cf3 100644 --- a/app/src/main/res/layout/activity_settings_filters.xml +++ b/app/src/main/res/layout/activity_settings_filters.xml @@ -94,7 +94,7 @@ android:layout_height="match_parent" android:layout_marginEnd="16dp" android:padding="16dp" - app:srcCompat="@drawable/fontsizedarker" + app:srcCompat="@drawable/fontsize" android:tint="?attr/tintColor" /> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/activity_settings_general_child.xml b/app/src/main/res/layout/activity_settings_general_child.xml index 0ae7dac24a..a5a466dc9e 100644 --- a/app/src/main/res/layout/activity_settings_general_child.xml +++ b/app/src/main/res/layout/activity_settings_general_child.xml @@ -585,56 +585,108 @@ + android:layout_width="match_parent" + android:layout_height="0.25dp" + android:alpha=".25" + android:background="?attr/tintColor" /> + android:layout_width="match_parent" + android:layout_height="56dp" + android:background="?android:selectableItemBackground" + android:gravity="center_vertical" + android:orientation="horizontal" + android:paddingStart="16dp" + android:paddingLeft="16dp"> + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_centerVertical="true" + android:layout_marginEnd="64dp" + android:orientation="vertical" + android:layout_marginRight="64dp"> + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/high_colorspace_images" + android:textColor="?attr/fontColor" + android:textSize="14sp" /> + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:alpha=".86" + android:text="@string/description_high_colorspace" + android:textColor="?attr/fontColor" + android:textSize="13sp" /> + + + android:layout_height="0.25dp" + android:alpha=".25" + android:background="?attr/tintColor" /> + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/res/layout/activity_settings_subreddit.xml b/app/src/main/res/layout/activity_settings_subreddit.xml index ffd47d4f7b..7d3ac88a4d 100644 --- a/app/src/main/res/layout/activity_settings_subreddit.xml +++ b/app/src/main/res/layout/activity_settings_subreddit.xml @@ -40,7 +40,7 @@ android:paddingTop="8dp" android:scaleType="fitCenter" android:tint="@color/white" - app:srcCompat="@drawable/color" /> + app:srcCompat="@drawable/palette" /> + + + + + + + + + + + + - \ No newline at end of file + diff --git a/app/src/main/res/layout/activity_settings_theme_child.xml b/app/src/main/res/layout/activity_settings_theme_child.xml index 7a895fbf86..10d588f4b1 100644 --- a/app/src/main/res/layout/activity_settings_theme_child.xml +++ b/app/src/main/res/layout/activity_settings_theme_child.xml @@ -1,305 +1,305 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/album_image_pager.xml b/app/src/main/res/layout/album_image_pager.xml index aef6399b98..948c46ffd1 100644 --- a/app/src/main/res/layout/album_image_pager.xml +++ b/app/src/main/res/layout/album_image_pager.xml @@ -46,7 +46,7 @@ android:theme="@style/Ripple.List" android:layout_toLeftOf="@+id/save" android:padding="15dp" - app:srcCompat="@drawable/hd" + sothree:srcCompat="@drawable/hd" android:tint="#e1e1e1" /> diff --git a/app/src/main/res/layout/capatcha.xml b/app/src/main/res/layout/capatcha.xml deleted file mode 100644 index 75fde5315e..0000000000 --- a/app/src/main/res/layout/capatcha.xml +++ /dev/null @@ -1,79 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/res/layout/chooseaccent.xml b/app/src/main/res/layout/chooseaccent.xml index 17e4e5d764..e552a92917 100644 --- a/app/src/main/res/layout/chooseaccent.xml +++ b/app/src/main/res/layout/chooseaccent.xml @@ -1,70 +1,70 @@ - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/choosemain.xml b/app/src/main/res/layout/choosemain.xml index bd5e902804..b3c56a7d63 100644 --- a/app/src/main/res/layout/choosemain.xml +++ b/app/src/main/res/layout/choosemain.xml @@ -1,80 +1,80 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/colorprofile.xml b/app/src/main/res/layout/colorprofile.xml index 7810ef22cf..8ccfea2823 100644 --- a/app/src/main/res/layout/colorprofile.xml +++ b/app/src/main/res/layout/colorprofile.xml @@ -1,346 +1,372 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/colorsub.xml b/app/src/main/res/layout/colorsub.xml index dfb27fe860..f95f86d740 100644 --- a/app/src/main/res/layout/colorsub.xml +++ b/app/src/main/res/layout/colorsub.xml @@ -1,111 +1,111 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/comment_mediacard.xml b/app/src/main/res/layout/comment_mediacard.xml deleted file mode 100644 index 583be45d57..0000000000 --- a/app/src/main/res/layout/comment_mediacard.xml +++ /dev/null @@ -1,190 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/res/layout/commentnumber.xml b/app/src/main/res/layout/commentnumber.xml deleted file mode 100644 index 91b88faed6..0000000000 --- a/app/src/main/res/layout/commentnumber.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/drawer_offline.xml b/app/src/main/res/layout/drawer_offline.xml index 717c2f7978..dac0070ac1 100644 --- a/app/src/main/res/layout/drawer_offline.xml +++ b/app/src/main/res/layout/drawer_offline.xml @@ -60,7 +60,7 @@ android:layout_height="match_parent" android:layout_marginStart="16dp" android:layout_marginEnd="26dp" - app:srcCompat="@drawable/internet" + app:srcCompat="@drawable/online" android:tint="?attr/tintColor" /> + app:srcCompat="@drawable/save_content" /> + app:srcCompat="@drawable/restore_file" /> + app:srcCompat="@drawable/bold"/> + app:srcCompat="@drawable/italic"/> + app:srcCompat="@drawable/quote"/> + app:srcCompat="@drawable/list_bulleted"/> + app:srcCompat="@drawable/list_numbered"/> + app:srcCompat="@drawable/fontsize"/> - - + - \ No newline at end of file + diff --git a/app/src/main/res/layout/fragment_verticalcontenttoolbar.xml b/app/src/main/res/layout/fragment_verticalcontenttoolbar.xml index 631021ab5e..f21212baa6 100644 --- a/app/src/main/res/layout/fragment_verticalcontenttoolbar.xml +++ b/app/src/main/res/layout/fragment_verticalcontenttoolbar.xml @@ -5,7 +5,7 @@ android:layout_height="match_parent" android:background="?attr/activity_background"> - @@ -17,7 +17,7 @@ android:fadeScrollbars="true" android:orientation="vertical" android:scrollbars="vertical"/> - + - - \ No newline at end of file + diff --git a/app/src/main/res/layout/mod_action.xml b/app/src/main/res/layout/mod_action.xml index 8c14faed37..1c59bb37b4 100644 --- a/app/src/main/res/layout/mod_action.xml +++ b/app/src/main/res/layout/mod_action.xml @@ -24,11 +24,11 @@ android:id="@+id/action" android:layout_width="28dp" android:layout_marginLeft="4dp" - android:tint="?attr/tintColor" - android:layout_height="48dp" + android:layout_height="48dp" android:layout_alignParentRight="true" android:padding="4dp" - cardview:srcCompat="@drawable/support"/> + cardview:srcCompat="@drawable/support" + android:tint="?attr/tintColor" /> - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/peek_media.xml b/app/src/main/res/layout/peek_media.xml deleted file mode 100644 index 7569b828d2..0000000000 --- a/app/src/main/res/layout/peek_media.xml +++ /dev/null @@ -1,99 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/peek_view.xml b/app/src/main/res/layout/peek_view.xml index 66f8f688c3..5b0893d8d9 100644 --- a/app/src/main/res/layout/peek_view.xml +++ b/app/src/main/res/layout/peek_view.xml @@ -46,7 +46,7 @@ android:paddingTop="16dp" android:paddingBottom="16dp" - app:srcCompat="@drawable/openexternal" + app:srcCompat="@drawable/open_external" android:clickable="true" android:layout_height="match_parent"/> @@ -54,7 +54,7 @@ android:layout_width="0dp" android:layout_weight="1" android:id="@+id/copy" - app:srcCompat="@drawable/ic_content_copy" + app:srcCompat="@drawable/copy" android:paddingTop="16dp" android:paddingBottom="16dp" diff --git a/app/src/main/res/layout/peek_view_submission.xml b/app/src/main/res/layout/peek_view_submission.xml index 263c1c3e7f..8f15aa92bb 100644 --- a/app/src/main/res/layout/peek_view_submission.xml +++ b/app/src/main/res/layout/peek_view_submission.xml @@ -65,7 +65,7 @@ android:paddingTop="16dp" android:paddingBottom="16dp" android:id="@+id/upvoteb" - android:src="@drawable/upvoted" + app:srcCompat="@drawable/upvoted" android:clickable="true" android:layout_height="match_parent"/> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/res/layout/postmenu.xml b/app/src/main/res/layout/postmenu.xml index 8ed9c21ea2..08722fd9b6 100644 --- a/app/src/main/res/layout/postmenu.xml +++ b/app/src/main/res/layout/postmenu.xml @@ -134,7 +134,7 @@ android:layout_height="match_parent" android:alpha=".86" android:padding="12dp" - app:srcCompat="@drawable/iconstarfilled" + app:srcCompat="@drawable/star" android:tint="?attr/tintColor" /> @@ -170,7 +170,7 @@ android:alpha=".86" android:padding="12dp" - app:srcCompat="@drawable/openexternal" + app:srcCompat="@drawable/open_external" android:tint="?attr/tintColor" /> - - - - - - - diff --git a/app/src/main/res/layout/sharemenu.xml b/app/src/main/res/layout/sharemenu.xml deleted file mode 100644 index 68930264c8..0000000000 --- a/app/src/main/res/layout/sharemenu.xml +++ /dev/null @@ -1,119 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/res/layout/subinfo.xml b/app/src/main/res/layout/subinfo.xml index 3336d88abb..cbddf56c0d 100644 --- a/app/src/main/res/layout/subinfo.xml +++ b/app/src/main/res/layout/subinfo.xml @@ -1,418 +1,418 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/submission_albumcard.xml b/app/src/main/res/layout/submission_albumcard.xml index 9e8c84ebad..50bf23ab44 100644 --- a/app/src/main/res/layout/submission_albumcard.xml +++ b/app/src/main/res/layout/submission_albumcard.xml @@ -77,7 +77,7 @@ android:tag="tintactionbar" android:tint="?attr/tintColor" android:contentDescription="@string/img_score" - app:srcCompat="@drawable/upvoted" /> + sothree:srcCompat="@drawable/upvoted" /> + sothree:srcCompat="@drawable/commentchange" /> + sothree:srcCompat="@drawable/star" /> + sothree:srcCompat="@drawable/upvoted" /> + sothree:srcCompat="@drawable/downvote" /> + sothree:srcCompat="@drawable/more" /> diff --git a/app/src/main/res/layout/submission_fullscreen.xml b/app/src/main/res/layout/submission_fullscreen.xml index 6c33dcd503..c2a46028dc 100644 --- a/app/src/main/res/layout/submission_fullscreen.xml +++ b/app/src/main/res/layout/submission_fullscreen.xml @@ -1,423 +1,423 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/submission_gifcard.xml b/app/src/main/res/layout/submission_gifcard.xml deleted file mode 100644 index 03ddbf4699..0000000000 --- a/app/src/main/res/layout/submission_gifcard.xml +++ /dev/null @@ -1,135 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/res/layout/submission_largecard.xml b/app/src/main/res/layout/submission_largecard.xml index 37f0dfaad3..c3bdc4ef87 100644 --- a/app/src/main/res/layout/submission_largecard.xml +++ b/app/src/main/res/layout/submission_largecard.xml @@ -182,7 +182,7 @@ android:tag="tintactionbar" android:tint="?attr/tintColor" android:contentDescription="@string/btn_save" - app:srcCompat="@drawable/iconstarfilled" /> + app:srcCompat="@drawable/star" /> - \ No newline at end of file + diff --git a/app/src/main/res/layout/submission_largecard_middle.xml b/app/src/main/res/layout/submission_largecard_middle.xml index f0f3f7e26c..8f05029af9 100644 --- a/app/src/main/res/layout/submission_largecard_middle.xml +++ b/app/src/main/res/layout/submission_largecard_middle.xml @@ -186,7 +186,7 @@ android:tag="tintactionbar" android:tint="?attr/tintColor" android:contentDescription="@string/btn_save" - app:srcCompat="@drawable/iconstarfilled" /> + app:srcCompat="@drawable/star" /> - \ No newline at end of file + diff --git a/app/src/main/res/layout/submission_list.xml b/app/src/main/res/layout/submission_list.xml index 824188ff58..f53c212df0 100644 --- a/app/src/main/res/layout/submission_list.xml +++ b/app/src/main/res/layout/submission_list.xml @@ -181,7 +181,7 @@ android:padding="8dp" android:tag="tintactionbar" android:tint="?attr/tintColor" - app:srcCompat="@drawable/iconstarfilled" /> + app:srcCompat="@drawable/star" /> - \ No newline at end of file + diff --git a/app/src/main/res/layout/submission_list_desktop.xml b/app/src/main/res/layout/submission_list_desktop.xml index 26f0ecfeeb..0817250674 100644 --- a/app/src/main/res/layout/submission_list_desktop.xml +++ b/app/src/main/res/layout/submission_list_desktop.xml @@ -193,7 +193,7 @@ android:tag="tintactionbar" android:tint="?attr/tintColor" android:contentDescription="@string/btn_save" - app:srcCompat="@drawable/iconstarfilled" /> + app:srcCompat="@drawable/star" /> - \ No newline at end of file + diff --git a/app/src/main/res/layout/submission_mediacard.xml b/app/src/main/res/layout/submission_mediacard.xml index 8e878d7714..815dd0c224 100644 --- a/app/src/main/res/layout/submission_mediacard.xml +++ b/app/src/main/res/layout/submission_mediacard.xml @@ -136,7 +136,7 @@ android:tag="tintactionbar" android:tint="?attr/tintColor" android:contentDescription="@string/img_score" - app:srcCompat="@drawable/upvoted" /> + sothree:srcCompat="@drawable/upvoted" /> + sothree:srcCompat="@drawable/commentchange" /> + sothree:srcCompat="@drawable/star" /> + sothree:srcCompat="@drawable/upvoted" /> + sothree:srcCompat="@drawable/downvote" /> + sothree:srcCompat="@drawable/more" /> diff --git a/app/src/main/res/layout/submission_textcard.xml b/app/src/main/res/layout/submission_textcard.xml index 3d445e8747..8cecffd1f3 100644 --- a/app/src/main/res/layout/submission_textcard.xml +++ b/app/src/main/res/layout/submission_textcard.xml @@ -162,7 +162,7 @@ android:tag="tintactionbar" android:tint="?attr/tintColor" android:contentDescription="@string/btn_save" - app:srcCompat="@drawable/iconstarfilled" /> + app:srcCompat="@drawable/star" /> + app:srcCompat="@drawable/star" /> + app:srcCompat="@drawable/upvoted" /> + app:srcCompat="@drawable/commentchange" /> + app:srcCompat="@drawable/upvoted" /> + app:srcCompat="@drawable/commentchange" /> - - - - diff --git a/app/src/main/res/layout/widget.xml b/app/src/main/res/layout/widget.xml index f7c6df834a..bb581db8de 100644 --- a/app/src/main/res/layout/widget.xml +++ b/app/src/main/res/layout/widget.xml @@ -33,7 +33,7 @@ android:layout_height="36dp" android:visibility="gone" android:padding="8dp" - app:srcCompat="@drawable/refresh" + app:srcCompat="@drawable/sync" android:id="@+id/refresh" android:layout_toLeftOf="@+id/open" android:layout_margin="2dp" diff --git a/app/src/main/res/layout/widget_dark.xml b/app/src/main/res/layout/widget_dark.xml index 95c47b6223..1973dd29d8 100644 --- a/app/src/main/res/layout/widget_dark.xml +++ b/app/src/main/res/layout/widget_dark.xml @@ -33,7 +33,7 @@ android:visibility="gone" android:layout_height="36dp" android:padding="8dp" - app:srcCompat="@drawable/refresh" + app:srcCompat="@drawable/sync" android:id="@+id/refresh" android:layout_toLeftOf="@+id/open" android:layout_margin="2dp" diff --git a/app/src/main/res/layout/widget_light.xml b/app/src/main/res/layout/widget_light.xml index ffabcf8e02..f31ddf46c3 100644 --- a/app/src/main/res/layout/widget_light.xml +++ b/app/src/main/res/layout/widget_light.xml @@ -35,7 +35,7 @@ android:layout_height="36dp" android:tint="#424242" android:padding="8dp" - app:srcCompat="@drawable/refresh" + app:srcCompat="@drawable/sync" android:id="@+id/refresh" android:layout_toLeftOf="@+id/open" android:layout_margin="2dp" diff --git a/app/src/main/res/layout/widget_submission_list.xml b/app/src/main/res/layout/widget_submission_list.xml deleted file mode 100644 index 649e8d441b..0000000000 --- a/app/src/main/res/layout/widget_submission_list.xml +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - - - diff --git a/app/src/main/res/menu/link_menu.xml b/app/src/main/res/menu/link_menu.xml index 115340cc25..ff9e6c2752 100644 --- a/app/src/main/res/menu/link_menu.xml +++ b/app/src/main/res/menu/link_menu.xml @@ -5,13 +5,13 @@ + android:icon="@drawable/open_in_browser" /> + android:icon="@drawable/share" /> - \ No newline at end of file + android:icon="@drawable/copy" /> + diff --git a/app/src/main/res/menu/menu_comment_items.xml b/app/src/main/res/menu/menu_comment_items.xml index 751ec30c29..c95a85aef6 100644 --- a/app/src/main/res/menu/menu_comment_items.xml +++ b/app/src/main/res/menu/menu_comment_items.xml @@ -17,7 +17,7 @@ @@ -35,7 +35,7 @@ - \ No newline at end of file + diff --git a/app/src/main/res/menu/menu_inbox.xml b/app/src/main/res/menu/menu_inbox.xml index d7e35a9f82..8fdeba151c 100644 --- a/app/src/main/res/menu/menu_inbox.xml +++ b/app/src/main/res/menu/menu_inbox.xml @@ -11,7 +11,7 @@ diff --git a/app/src/main/res/menu/menu_multireddits.xml b/app/src/main/res/menu/menu_multireddits.xml index 8ada22e596..e1069be850 100644 --- a/app/src/main/res/menu/menu_multireddits.xml +++ b/app/src/main/res/menu/menu_multireddits.xml @@ -6,6 +6,7 @@ diff --git a/app/src/main/res/menu/menu_profile.xml b/app/src/main/res/menu/menu_profile.xml index 0e4b501f9e..7a81cea2af 100644 --- a/app/src/main/res/menu/menu_profile.xml +++ b/app/src/main/res/menu/menu_profile.xml @@ -17,7 +17,7 @@ - \ No newline at end of file + diff --git a/app/src/main/res/menu/menu_reader.xml b/app/src/main/res/menu/menu_reader.xml index 35f0e43beb..dd56c3ee80 100644 --- a/app/src/main/res/menu/menu_reader.xml +++ b/app/src/main/res/menu/menu_reader.xml @@ -13,7 +13,7 @@ diff --git a/app/src/main/res/menu/menu_search.xml b/app/src/main/res/menu/menu_search.xml index 8dedd21e1d..56c90e5a96 100644 --- a/app/src/main/res/menu/menu_search.xml +++ b/app/src/main/res/menu/menu_search.xml @@ -5,7 +5,7 @@ diff --git a/app/src/main/res/menu/menu_single_subreddit.xml b/app/src/main/res/menu/menu_single_subreddit.xml index 1db5e8dc51..d12ea2db32 100644 --- a/app/src/main/res/menu/menu_single_subreddit.xml +++ b/app/src/main/res/menu/menu_single_subreddit.xml @@ -23,7 +23,7 @@ @@ -35,7 +35,7 @@ diff --git a/app/src/main/res/menu/menu_single_subreddit_expanded.xml b/app/src/main/res/menu/menu_single_subreddit_expanded.xml index 3d25d65657..2d5d15cb8c 100644 --- a/app/src/main/res/menu/menu_single_subreddit_expanded.xml +++ b/app/src/main/res/menu/menu_single_subreddit_expanded.xml @@ -23,7 +23,7 @@ @@ -35,7 +35,7 @@ diff --git a/app/src/main/res/menu/menu_subreddit_overview.xml b/app/src/main/res/menu/menu_subreddit_overview.xml index b8e549a7f0..9dbdd7f023 100644 --- a/app/src/main/res/menu/menu_subreddit_overview.xml +++ b/app/src/main/res/menu/menu_subreddit_overview.xml @@ -23,7 +23,7 @@ @@ -35,7 +35,7 @@ diff --git a/app/src/main/res/menu/menu_subreddit_overview_expanded.xml b/app/src/main/res/menu/menu_subreddit_overview_expanded.xml index 2eeed0299e..0bdf71fed5 100644 --- a/app/src/main/res/menu/menu_subreddit_overview_expanded.xml +++ b/app/src/main/res/menu/menu_subreddit_overview_expanded.xml @@ -23,7 +23,7 @@ @@ -35,7 +35,7 @@ diff --git a/app/src/main/res/menu/menu_website.xml b/app/src/main/res/menu/menu_website.xml index 7fb4b59c5e..32ba99297f 100644 --- a/app/src/main/res/menu/menu_website.xml +++ b/app/src/main/res/menu/menu_website.xml @@ -5,19 +5,19 @@ - \ No newline at end of file + android:id="@+id/thumbnail" + android:title="@string/mode_thumbnail"/> + + + diff --git a/app/src/main/res/menu/reorder_subs.xml b/app/src/main/res/menu/reorder_subs.xml index 9063a038ed..892a8ef401 100644 --- a/app/src/main/res/menu/reorder_subs.xml +++ b/app/src/main/res/menu/reorder_subs.xml @@ -12,16 +12,16 @@ android:id="@+id/refresh" android:title="@string/sync_subscriptions" app:showAsAction="always" - android:icon="@drawable/refresh" /> + android:icon="@drawable/sync" /> + android:icon="@drawable/info" /> - \ No newline at end of file + diff --git a/app/src/main/res/menu/settings_info.xml b/app/src/main/res/menu/settings_info.xml index 9abc24e0c3..7dc81b5e5e 100644 --- a/app/src/main/res/menu/settings_info.xml +++ b/app/src/main/res/menu/settings_info.xml @@ -7,5 +7,5 @@ android:id="@+id/info" android:title="Info" app:showAsAction="always" - android:icon="@drawable/infonew" /> - \ No newline at end of file + android:icon="@drawable/info" /> + diff --git a/app/src/main/res/menu/share_menu.xml b/app/src/main/res/menu/share_menu.xml index 26103d1ce7..1490e2fcf2 100644 --- a/app/src/main/res/menu/share_menu.xml +++ b/app/src/main/res/menu/share_menu.xml @@ -7,5 +7,5 @@ + android:icon="@drawable/link" /> \ No newline at end of file diff --git a/app/src/main/res/menu/thumb_type_settings.xml b/app/src/main/res/menu/thumb_type_settings.xml deleted file mode 100644 index ee2dd8ba1b..0000000000 --- a/app/src/main/res/menu/thumb_type_settings.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png index 080fce88a2..a04a475ad4 100644 Binary files a/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png and b/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png differ diff --git a/app/src/main/res/mipmap-hdpi/icon_amber.png b/app/src/main/res/mipmap-hdpi/icon_amber.png index 9e4c75bf1f..0affbecc47 100644 Binary files a/app/src/main/res/mipmap-hdpi/icon_amber.png and b/app/src/main/res/mipmap-hdpi/icon_amber.png differ diff --git a/app/src/main/res/mipmap-hdpi/icon_blue.png b/app/src/main/res/mipmap-hdpi/icon_blue.png index 80a7cc4cdf..a86e1bc3b9 100644 Binary files a/app/src/main/res/mipmap-hdpi/icon_blue.png and b/app/src/main/res/mipmap-hdpi/icon_blue.png differ diff --git a/app/src/main/res/mipmap-hdpi/icon_blue_grey.png b/app/src/main/res/mipmap-hdpi/icon_blue_grey.png index 27520ec891..802bbdface 100644 Binary files a/app/src/main/res/mipmap-hdpi/icon_blue_grey.png and b/app/src/main/res/mipmap-hdpi/icon_blue_grey.png differ diff --git a/app/src/main/res/mipmap-hdpi/icon_brown.png b/app/src/main/res/mipmap-hdpi/icon_brown.png index c8674378b9..dac36603e2 100644 Binary files a/app/src/main/res/mipmap-hdpi/icon_brown.png and b/app/src/main/res/mipmap-hdpi/icon_brown.png differ diff --git a/app/src/main/res/mipmap-hdpi/icon_cyan.png b/app/src/main/res/mipmap-hdpi/icon_cyan.png index 4141151b03..6762544777 100644 Binary files a/app/src/main/res/mipmap-hdpi/icon_cyan.png and b/app/src/main/res/mipmap-hdpi/icon_cyan.png differ diff --git a/app/src/main/res/mipmap-hdpi/icon_deep_orange.png b/app/src/main/res/mipmap-hdpi/icon_deep_orange.png index f06dd6d96e..32b0af90e4 100644 Binary files a/app/src/main/res/mipmap-hdpi/icon_deep_orange.png and b/app/src/main/res/mipmap-hdpi/icon_deep_orange.png differ diff --git a/app/src/main/res/mipmap-hdpi/icon_deep_purple.png b/app/src/main/res/mipmap-hdpi/icon_deep_purple.png index 253c02342c..c342f87ec4 100644 Binary files a/app/src/main/res/mipmap-hdpi/icon_deep_purple.png and b/app/src/main/res/mipmap-hdpi/icon_deep_purple.png differ diff --git a/app/src/main/res/mipmap-hdpi/icon_green.png b/app/src/main/res/mipmap-hdpi/icon_green.png index e670018e3e..eb3b856055 100644 Binary files a/app/src/main/res/mipmap-hdpi/icon_green.png and b/app/src/main/res/mipmap-hdpi/icon_green.png differ diff --git a/app/src/main/res/mipmap-hdpi/icon_grey.png b/app/src/main/res/mipmap-hdpi/icon_grey.png index 494928fd1a..fc0959493a 100644 Binary files a/app/src/main/res/mipmap-hdpi/icon_grey.png and b/app/src/main/res/mipmap-hdpi/icon_grey.png differ diff --git a/app/src/main/res/mipmap-hdpi/icon_indigo.png b/app/src/main/res/mipmap-hdpi/icon_indigo.png index 83c1f01505..1f4b44554a 100644 Binary files a/app/src/main/res/mipmap-hdpi/icon_indigo.png and b/app/src/main/res/mipmap-hdpi/icon_indigo.png differ diff --git a/app/src/main/res/mipmap-hdpi/icon_light_blue.png b/app/src/main/res/mipmap-hdpi/icon_light_blue.png index 5571816026..cad9313c3a 100644 Binary files a/app/src/main/res/mipmap-hdpi/icon_light_blue.png and b/app/src/main/res/mipmap-hdpi/icon_light_blue.png differ diff --git a/app/src/main/res/mipmap-hdpi/icon_light_green.png b/app/src/main/res/mipmap-hdpi/icon_light_green.png index c1262b9caa..2d816b20af 100644 Binary files a/app/src/main/res/mipmap-hdpi/icon_light_green.png and b/app/src/main/res/mipmap-hdpi/icon_light_green.png differ diff --git a/app/src/main/res/mipmap-hdpi/icon_lime.png b/app/src/main/res/mipmap-hdpi/icon_lime.png index 2a20337c14..e3235b6239 100644 Binary files a/app/src/main/res/mipmap-hdpi/icon_lime.png and b/app/src/main/res/mipmap-hdpi/icon_lime.png differ diff --git a/app/src/main/res/mipmap-hdpi/icon_orange.png b/app/src/main/res/mipmap-hdpi/icon_orange.png index da5f75aa80..91a8d23aba 100644 Binary files a/app/src/main/res/mipmap-hdpi/icon_orange.png and b/app/src/main/res/mipmap-hdpi/icon_orange.png differ diff --git a/app/src/main/res/mipmap-hdpi/icon_pink.png b/app/src/main/res/mipmap-hdpi/icon_pink.png index 2552abb943..fd1fa6dbbb 100644 Binary files a/app/src/main/res/mipmap-hdpi/icon_pink.png and b/app/src/main/res/mipmap-hdpi/icon_pink.png differ diff --git a/app/src/main/res/mipmap-hdpi/icon_purple.png b/app/src/main/res/mipmap-hdpi/icon_purple.png index faa0a80901..fcf4cdb970 100644 Binary files a/app/src/main/res/mipmap-hdpi/icon_purple.png and b/app/src/main/res/mipmap-hdpi/icon_purple.png differ diff --git a/app/src/main/res/mipmap-hdpi/icon_red.png b/app/src/main/res/mipmap-hdpi/icon_red.png index f27ff6ba88..342f6968e7 100644 Binary files a/app/src/main/res/mipmap-hdpi/icon_red.png and b/app/src/main/res/mipmap-hdpi/icon_red.png differ diff --git a/app/src/main/res/mipmap-hdpi/icon_round.png b/app/src/main/res/mipmap-hdpi/icon_round.png deleted file mode 100644 index d710ff25ec..0000000000 Binary files a/app/src/main/res/mipmap-hdpi/icon_round.png and /dev/null differ diff --git a/app/src/main/res/mipmap-hdpi/icon_teal.png b/app/src/main/res/mipmap-hdpi/icon_teal.png index e02eb515e0..4999931f0f 100644 Binary files a/app/src/main/res/mipmap-hdpi/icon_teal.png and b/app/src/main/res/mipmap-hdpi/icon_teal.png differ diff --git a/app/src/main/res/mipmap-hdpi/icon_yellow.png b/app/src/main/res/mipmap-hdpi/icon_yellow.png index 8a5958a7d5..a3d0119519 100644 Binary files a/app/src/main/res/mipmap-hdpi/icon_yellow.png and b/app/src/main/res/mipmap-hdpi/icon_yellow.png differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png index ca52a7551b..2bb305af68 100644 Binary files a/app/src/main/res/mipmap-mdpi/ic_launcher.png and b/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png index 9ccf756885..cb9a39a4d1 100644 Binary files a/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png and b/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png index cff066d717..98b8cb5cbd 100644 Binary files a/app/src/main/res/mipmap-mdpi/ic_launcher_round.png and b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-mdpi/icon_amber.png b/app/src/main/res/mipmap-mdpi/icon_amber.png index db803ce7ed..47b95506d4 100644 Binary files a/app/src/main/res/mipmap-mdpi/icon_amber.png and b/app/src/main/res/mipmap-mdpi/icon_amber.png differ diff --git a/app/src/main/res/mipmap-mdpi/icon_blue.png b/app/src/main/res/mipmap-mdpi/icon_blue.png index 0efd9f3cfb..71de83d3f6 100644 Binary files a/app/src/main/res/mipmap-mdpi/icon_blue.png and b/app/src/main/res/mipmap-mdpi/icon_blue.png differ diff --git a/app/src/main/res/mipmap-mdpi/icon_blue_grey.png b/app/src/main/res/mipmap-mdpi/icon_blue_grey.png index a54ca49def..31822026b5 100644 Binary files a/app/src/main/res/mipmap-mdpi/icon_blue_grey.png and b/app/src/main/res/mipmap-mdpi/icon_blue_grey.png differ diff --git a/app/src/main/res/mipmap-mdpi/icon_brown.png b/app/src/main/res/mipmap-mdpi/icon_brown.png index 6fc198930d..0209e54df4 100644 Binary files a/app/src/main/res/mipmap-mdpi/icon_brown.png and b/app/src/main/res/mipmap-mdpi/icon_brown.png differ diff --git a/app/src/main/res/mipmap-mdpi/icon_cyan.png b/app/src/main/res/mipmap-mdpi/icon_cyan.png index deefd49935..116e0692ac 100644 Binary files a/app/src/main/res/mipmap-mdpi/icon_cyan.png and b/app/src/main/res/mipmap-mdpi/icon_cyan.png differ diff --git a/app/src/main/res/mipmap-mdpi/icon_deep_orange.png b/app/src/main/res/mipmap-mdpi/icon_deep_orange.png index 7ac75eab2e..6f15fb6aa2 100644 Binary files a/app/src/main/res/mipmap-mdpi/icon_deep_orange.png and b/app/src/main/res/mipmap-mdpi/icon_deep_orange.png differ diff --git a/app/src/main/res/mipmap-mdpi/icon_deep_purple.png b/app/src/main/res/mipmap-mdpi/icon_deep_purple.png index 6066d1d8b2..6ba6f4a904 100644 Binary files a/app/src/main/res/mipmap-mdpi/icon_deep_purple.png and b/app/src/main/res/mipmap-mdpi/icon_deep_purple.png differ diff --git a/app/src/main/res/mipmap-mdpi/icon_green.png b/app/src/main/res/mipmap-mdpi/icon_green.png index aebfd3217b..5ee393cfbd 100644 Binary files a/app/src/main/res/mipmap-mdpi/icon_green.png and b/app/src/main/res/mipmap-mdpi/icon_green.png differ diff --git a/app/src/main/res/mipmap-mdpi/icon_grey.png b/app/src/main/res/mipmap-mdpi/icon_grey.png index b32c8fff35..de87bc1b08 100644 Binary files a/app/src/main/res/mipmap-mdpi/icon_grey.png and b/app/src/main/res/mipmap-mdpi/icon_grey.png differ diff --git a/app/src/main/res/mipmap-mdpi/icon_indigo.png b/app/src/main/res/mipmap-mdpi/icon_indigo.png index 3a1b645a28..d3dd52a063 100644 Binary files a/app/src/main/res/mipmap-mdpi/icon_indigo.png and b/app/src/main/res/mipmap-mdpi/icon_indigo.png differ diff --git a/app/src/main/res/mipmap-mdpi/icon_light_blue.png b/app/src/main/res/mipmap-mdpi/icon_light_blue.png index 2b728fabc9..fff59389bd 100644 Binary files a/app/src/main/res/mipmap-mdpi/icon_light_blue.png and b/app/src/main/res/mipmap-mdpi/icon_light_blue.png differ diff --git a/app/src/main/res/mipmap-mdpi/icon_light_green.png b/app/src/main/res/mipmap-mdpi/icon_light_green.png index 41c2013f87..94c79cc4ef 100644 Binary files a/app/src/main/res/mipmap-mdpi/icon_light_green.png and b/app/src/main/res/mipmap-mdpi/icon_light_green.png differ diff --git a/app/src/main/res/mipmap-mdpi/icon_lime.png b/app/src/main/res/mipmap-mdpi/icon_lime.png index 74e06b5ce0..529f55fa50 100644 Binary files a/app/src/main/res/mipmap-mdpi/icon_lime.png and b/app/src/main/res/mipmap-mdpi/icon_lime.png differ diff --git a/app/src/main/res/mipmap-mdpi/icon_orange.png b/app/src/main/res/mipmap-mdpi/icon_orange.png index 046bd3d393..39718ccf6b 100644 Binary files a/app/src/main/res/mipmap-mdpi/icon_orange.png and b/app/src/main/res/mipmap-mdpi/icon_orange.png differ diff --git a/app/src/main/res/mipmap-mdpi/icon_pink.png b/app/src/main/res/mipmap-mdpi/icon_pink.png index 1dbef60617..7cf0d11e25 100644 Binary files a/app/src/main/res/mipmap-mdpi/icon_pink.png and b/app/src/main/res/mipmap-mdpi/icon_pink.png differ diff --git a/app/src/main/res/mipmap-mdpi/icon_purple.png b/app/src/main/res/mipmap-mdpi/icon_purple.png index 6fb2a14927..9a7775436a 100644 Binary files a/app/src/main/res/mipmap-mdpi/icon_purple.png and b/app/src/main/res/mipmap-mdpi/icon_purple.png differ diff --git a/app/src/main/res/mipmap-mdpi/icon_red.png b/app/src/main/res/mipmap-mdpi/icon_red.png index 1184da1363..2bcdeb0878 100644 Binary files a/app/src/main/res/mipmap-mdpi/icon_red.png and b/app/src/main/res/mipmap-mdpi/icon_red.png differ diff --git a/app/src/main/res/mipmap-mdpi/icon_round.png b/app/src/main/res/mipmap-mdpi/icon_round.png deleted file mode 100644 index e17a7b2724..0000000000 Binary files a/app/src/main/res/mipmap-mdpi/icon_round.png and /dev/null differ diff --git a/app/src/main/res/mipmap-mdpi/icon_teal.png b/app/src/main/res/mipmap-mdpi/icon_teal.png index 28ae92c2e6..1045165d7d 100644 Binary files a/app/src/main/res/mipmap-mdpi/icon_teal.png and b/app/src/main/res/mipmap-mdpi/icon_teal.png differ diff --git a/app/src/main/res/mipmap-mdpi/icon_yellow.png b/app/src/main/res/mipmap-mdpi/icon_yellow.png index 9580ba76f9..d429eb8048 100644 Binary files a/app/src/main/res/mipmap-mdpi/icon_yellow.png and b/app/src/main/res/mipmap-mdpi/icon_yellow.png differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png index 63fd68db7b..9eb0cac394 100644 Binary files a/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png and b/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png differ diff --git a/app/src/main/res/mipmap-xhdpi/icon_amber.png b/app/src/main/res/mipmap-xhdpi/icon_amber.png index c0cc84de22..2efbfb3150 100644 Binary files a/app/src/main/res/mipmap-xhdpi/icon_amber.png and b/app/src/main/res/mipmap-xhdpi/icon_amber.png differ diff --git a/app/src/main/res/mipmap-xhdpi/icon_blue.png b/app/src/main/res/mipmap-xhdpi/icon_blue.png index cf1ca17f4d..2898b4afc7 100644 Binary files a/app/src/main/res/mipmap-xhdpi/icon_blue.png and b/app/src/main/res/mipmap-xhdpi/icon_blue.png differ diff --git a/app/src/main/res/mipmap-xhdpi/icon_blue_grey.png b/app/src/main/res/mipmap-xhdpi/icon_blue_grey.png index 45fb88201b..4e413b3e6d 100644 Binary files a/app/src/main/res/mipmap-xhdpi/icon_blue_grey.png and b/app/src/main/res/mipmap-xhdpi/icon_blue_grey.png differ diff --git a/app/src/main/res/mipmap-xhdpi/icon_brown.png b/app/src/main/res/mipmap-xhdpi/icon_brown.png index a85b1406cd..533184feb2 100644 Binary files a/app/src/main/res/mipmap-xhdpi/icon_brown.png and b/app/src/main/res/mipmap-xhdpi/icon_brown.png differ diff --git a/app/src/main/res/mipmap-xhdpi/icon_cyan.png b/app/src/main/res/mipmap-xhdpi/icon_cyan.png index 06eccaed06..2aea29ba5f 100644 Binary files a/app/src/main/res/mipmap-xhdpi/icon_cyan.png and b/app/src/main/res/mipmap-xhdpi/icon_cyan.png differ diff --git a/app/src/main/res/mipmap-xhdpi/icon_deep_orange.png b/app/src/main/res/mipmap-xhdpi/icon_deep_orange.png index 0a8851e5c4..e787cd13f5 100644 Binary files a/app/src/main/res/mipmap-xhdpi/icon_deep_orange.png and b/app/src/main/res/mipmap-xhdpi/icon_deep_orange.png differ diff --git a/app/src/main/res/mipmap-xhdpi/icon_deep_purple.png b/app/src/main/res/mipmap-xhdpi/icon_deep_purple.png index 6c6d0026ea..9238503407 100644 Binary files a/app/src/main/res/mipmap-xhdpi/icon_deep_purple.png and b/app/src/main/res/mipmap-xhdpi/icon_deep_purple.png differ diff --git a/app/src/main/res/mipmap-xhdpi/icon_green.png b/app/src/main/res/mipmap-xhdpi/icon_green.png index 05105eae86..32814100d9 100644 Binary files a/app/src/main/res/mipmap-xhdpi/icon_green.png and b/app/src/main/res/mipmap-xhdpi/icon_green.png differ diff --git a/app/src/main/res/mipmap-xhdpi/icon_grey.png b/app/src/main/res/mipmap-xhdpi/icon_grey.png index e17279b0d4..eb85ba1e8d 100644 Binary files a/app/src/main/res/mipmap-xhdpi/icon_grey.png and b/app/src/main/res/mipmap-xhdpi/icon_grey.png differ diff --git a/app/src/main/res/mipmap-xhdpi/icon_indigo.png b/app/src/main/res/mipmap-xhdpi/icon_indigo.png index 361bf6c24d..a06eb3e367 100644 Binary files a/app/src/main/res/mipmap-xhdpi/icon_indigo.png and b/app/src/main/res/mipmap-xhdpi/icon_indigo.png differ diff --git a/app/src/main/res/mipmap-xhdpi/icon_light_blue.png b/app/src/main/res/mipmap-xhdpi/icon_light_blue.png index b2388d179c..7e04cda8e0 100644 Binary files a/app/src/main/res/mipmap-xhdpi/icon_light_blue.png and b/app/src/main/res/mipmap-xhdpi/icon_light_blue.png differ diff --git a/app/src/main/res/mipmap-xhdpi/icon_light_green.png b/app/src/main/res/mipmap-xhdpi/icon_light_green.png index c4c6d7b9c7..3b508b44ea 100644 Binary files a/app/src/main/res/mipmap-xhdpi/icon_light_green.png and b/app/src/main/res/mipmap-xhdpi/icon_light_green.png differ diff --git a/app/src/main/res/mipmap-xhdpi/icon_lime.png b/app/src/main/res/mipmap-xhdpi/icon_lime.png index fc43890d7c..f8da852d4c 100644 Binary files a/app/src/main/res/mipmap-xhdpi/icon_lime.png and b/app/src/main/res/mipmap-xhdpi/icon_lime.png differ diff --git a/app/src/main/res/mipmap-xhdpi/icon_orange.png b/app/src/main/res/mipmap-xhdpi/icon_orange.png index 15c6bc4af6..88278a9bef 100644 Binary files a/app/src/main/res/mipmap-xhdpi/icon_orange.png and b/app/src/main/res/mipmap-xhdpi/icon_orange.png differ diff --git a/app/src/main/res/mipmap-xhdpi/icon_pink.png b/app/src/main/res/mipmap-xhdpi/icon_pink.png index 55603b3283..e5f2476238 100644 Binary files a/app/src/main/res/mipmap-xhdpi/icon_pink.png and b/app/src/main/res/mipmap-xhdpi/icon_pink.png differ diff --git a/app/src/main/res/mipmap-xhdpi/icon_purple.png b/app/src/main/res/mipmap-xhdpi/icon_purple.png index 4434734cb9..3f895bac59 100644 Binary files a/app/src/main/res/mipmap-xhdpi/icon_purple.png and b/app/src/main/res/mipmap-xhdpi/icon_purple.png differ diff --git a/app/src/main/res/mipmap-xhdpi/icon_red.png b/app/src/main/res/mipmap-xhdpi/icon_red.png index ae7aa9ea19..8398ba1b07 100644 Binary files a/app/src/main/res/mipmap-xhdpi/icon_red.png and b/app/src/main/res/mipmap-xhdpi/icon_red.png differ diff --git a/app/src/main/res/mipmap-xhdpi/icon_round.png b/app/src/main/res/mipmap-xhdpi/icon_round.png deleted file mode 100644 index c368458ae8..0000000000 Binary files a/app/src/main/res/mipmap-xhdpi/icon_round.png and /dev/null differ diff --git a/app/src/main/res/mipmap-xhdpi/icon_teal.png b/app/src/main/res/mipmap-xhdpi/icon_teal.png index 5c6ac8b7a0..55da761fd5 100644 Binary files a/app/src/main/res/mipmap-xhdpi/icon_teal.png and b/app/src/main/res/mipmap-xhdpi/icon_teal.png differ diff --git a/app/src/main/res/mipmap-xhdpi/icon_yellow.png b/app/src/main/res/mipmap-xhdpi/icon_yellow.png index 9be7316b1c..ad2086e7ec 100644 Binary files a/app/src/main/res/mipmap-xhdpi/icon_yellow.png and b/app/src/main/res/mipmap-xhdpi/icon_yellow.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png index 25db774150..96d5fe0951 100644 Binary files a/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png and b/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/icon_amber.png b/app/src/main/res/mipmap-xxhdpi/icon_amber.png index 401494d08f..c701da0d13 100644 Binary files a/app/src/main/res/mipmap-xxhdpi/icon_amber.png and b/app/src/main/res/mipmap-xxhdpi/icon_amber.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/icon_blue.png b/app/src/main/res/mipmap-xxhdpi/icon_blue.png index db63eb5234..855e0e5d19 100644 Binary files a/app/src/main/res/mipmap-xxhdpi/icon_blue.png and b/app/src/main/res/mipmap-xxhdpi/icon_blue.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/icon_blue_grey.png b/app/src/main/res/mipmap-xxhdpi/icon_blue_grey.png index 41b05852a3..d840c63bfe 100644 Binary files a/app/src/main/res/mipmap-xxhdpi/icon_blue_grey.png and b/app/src/main/res/mipmap-xxhdpi/icon_blue_grey.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/icon_brown.png b/app/src/main/res/mipmap-xxhdpi/icon_brown.png index 7f3c6e072d..180e812f89 100644 Binary files a/app/src/main/res/mipmap-xxhdpi/icon_brown.png and b/app/src/main/res/mipmap-xxhdpi/icon_brown.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/icon_cyan.png b/app/src/main/res/mipmap-xxhdpi/icon_cyan.png index 9cd54c9a07..466e7b72a9 100644 Binary files a/app/src/main/res/mipmap-xxhdpi/icon_cyan.png and b/app/src/main/res/mipmap-xxhdpi/icon_cyan.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/icon_deep_orange.png b/app/src/main/res/mipmap-xxhdpi/icon_deep_orange.png index 97c416b1dd..eafdda3697 100644 Binary files a/app/src/main/res/mipmap-xxhdpi/icon_deep_orange.png and b/app/src/main/res/mipmap-xxhdpi/icon_deep_orange.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/icon_deep_purple.png b/app/src/main/res/mipmap-xxhdpi/icon_deep_purple.png index 1f535efd5b..206a307398 100644 Binary files a/app/src/main/res/mipmap-xxhdpi/icon_deep_purple.png and b/app/src/main/res/mipmap-xxhdpi/icon_deep_purple.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/icon_green.png b/app/src/main/res/mipmap-xxhdpi/icon_green.png index 90577e760f..a1a5722b6d 100644 Binary files a/app/src/main/res/mipmap-xxhdpi/icon_green.png and b/app/src/main/res/mipmap-xxhdpi/icon_green.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/icon_grey.png b/app/src/main/res/mipmap-xxhdpi/icon_grey.png index 0958cbe1c2..83ab71c377 100644 Binary files a/app/src/main/res/mipmap-xxhdpi/icon_grey.png and b/app/src/main/res/mipmap-xxhdpi/icon_grey.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/icon_indigo.png b/app/src/main/res/mipmap-xxhdpi/icon_indigo.png index 92cca61311..5826e66a3d 100644 Binary files a/app/src/main/res/mipmap-xxhdpi/icon_indigo.png and b/app/src/main/res/mipmap-xxhdpi/icon_indigo.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/icon_light_blue.png b/app/src/main/res/mipmap-xxhdpi/icon_light_blue.png index d0e91077a5..defe4f18aa 100644 Binary files a/app/src/main/res/mipmap-xxhdpi/icon_light_blue.png and b/app/src/main/res/mipmap-xxhdpi/icon_light_blue.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/icon_light_green.png b/app/src/main/res/mipmap-xxhdpi/icon_light_green.png index 655c5bb2ce..37b2dd55e3 100644 Binary files a/app/src/main/res/mipmap-xxhdpi/icon_light_green.png and b/app/src/main/res/mipmap-xxhdpi/icon_light_green.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/icon_lime.png b/app/src/main/res/mipmap-xxhdpi/icon_lime.png index cc8e718404..3aeaa864da 100644 Binary files a/app/src/main/res/mipmap-xxhdpi/icon_lime.png and b/app/src/main/res/mipmap-xxhdpi/icon_lime.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/icon_orange.png b/app/src/main/res/mipmap-xxhdpi/icon_orange.png index 9f09d2e417..783c139e6b 100644 Binary files a/app/src/main/res/mipmap-xxhdpi/icon_orange.png and b/app/src/main/res/mipmap-xxhdpi/icon_orange.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/icon_pink.png b/app/src/main/res/mipmap-xxhdpi/icon_pink.png index b840b865c1..824b9b81e6 100644 Binary files a/app/src/main/res/mipmap-xxhdpi/icon_pink.png and b/app/src/main/res/mipmap-xxhdpi/icon_pink.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/icon_purple.png b/app/src/main/res/mipmap-xxhdpi/icon_purple.png index 7701d79226..12959bf157 100644 Binary files a/app/src/main/res/mipmap-xxhdpi/icon_purple.png and b/app/src/main/res/mipmap-xxhdpi/icon_purple.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/icon_red.png b/app/src/main/res/mipmap-xxhdpi/icon_red.png index 98bfd38e5e..0425e537c7 100644 Binary files a/app/src/main/res/mipmap-xxhdpi/icon_red.png and b/app/src/main/res/mipmap-xxhdpi/icon_red.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/icon_round.png b/app/src/main/res/mipmap-xxhdpi/icon_round.png deleted file mode 100644 index 17d42ab6de..0000000000 Binary files a/app/src/main/res/mipmap-xxhdpi/icon_round.png and /dev/null differ diff --git a/app/src/main/res/mipmap-xxhdpi/icon_teal.png b/app/src/main/res/mipmap-xxhdpi/icon_teal.png index eb8bdc487a..3a74280eb5 100644 Binary files a/app/src/main/res/mipmap-xxhdpi/icon_teal.png and b/app/src/main/res/mipmap-xxhdpi/icon_teal.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/icon_yellow.png b/app/src/main/res/mipmap-xxhdpi/icon_yellow.png index dc49ab1651..8382ec0e31 100644 Binary files a/app/src/main/res/mipmap-xxhdpi/icon_yellow.png and b/app/src/main/res/mipmap-xxhdpi/icon_yellow.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png index d6660dc909..9d62b80ad4 100644 Binary files a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/icon_round.png b/app/src/main/res/mipmap-xxxhdpi/icon_round.png deleted file mode 100644 index 750069cab5..0000000000 Binary files a/app/src/main/res/mipmap-xxxhdpi/icon_round.png and /dev/null differ diff --git a/app/src/main/res/values/attrs.xml b/app/src/main/res/values/attrs.xml index 181bb7beff..780f529e98 100644 --- a/app/src/main/res/values/attrs.xml +++ b/app/src/main/res/values/attrs.xml @@ -42,4 +42,10 @@ - \ 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 e2b13711ba..ba9483d8c1 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -45,9 +45,9 @@ Comment un-saved Share link Comment text copied + Submission text copied Submission has no content Link copied - Selftext copied Submission removed @@ -130,6 +130,7 @@ + Total karma Post karma Comment karma Private message @@ -315,6 +316,8 @@ Which sub would you like to submit to? Saved successfully Do you really want to delete /m/%1$s? + Would you like to save this multireddit? + @@ -328,6 +331,8 @@ Album XKCD NSFW album + NSFW Gallery + Gallery Image Video Videos @@ -664,6 +669,7 @@ Comment font Crop lead image in comment view Mark posts as seen when scrolled past + Hide posts when scrolled past Custom Tabs Select image/GIF save location Not yet set @@ -720,6 +726,7 @@ Collapse child comments by default Enable Data Saving settings Prefer low-quality videos when Data Saving enabled + Collapse deleted comments by default Backup will occur at %1$s No subreddits will back up \u0020will back up @@ -1156,6 +1163,7 @@ Card with centered image Card Thumbnail + No Thumbnail Wide thumbnails Cropped big picture Big picture @@ -1320,4 +1328,8 @@ Page not found The page you requested does not exist Go to first subreddit + Hide awards + Hide awards + High-Colorspace Images + Loads full colorspace on images, potentially leading to higher memory usage diff --git a/app/src/noGPlay/java/me/ccrama/redditslide/Activities/SettingsBackup.java b/app/src/noGPlay/java/me/ccrama/redditslide/Activities/SettingsBackup.java index 5a256d720a..e01f2f50c1 100644 --- a/app/src/noGPlay/java/me/ccrama/redditslide/Activities/SettingsBackup.java +++ b/app/src/noGPlay/java/me/ccrama/redditslide/Activities/SettingsBackup.java @@ -92,8 +92,8 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) { for (int i = 1; i < files.length; i++) { String innerFile = files[i]; String t = innerFile.substring(6, innerFile.indexOf(">")); - innerFile = innerFile.substring(innerFile.indexOf(">") + 1, - innerFile.length()); + innerFile = innerFile.substring(innerFile.indexOf(">") + 1 + ); File newF = new File(getApplicationInfo().dataDir + File.separator diff --git a/app/src/noGPlay/res/layout/activity_settings_sync.xml b/app/src/noGPlay/res/layout/activity_settings_sync.xml index 8423a2b51e..a100c204b2 100644 --- a/app/src/noGPlay/res/layout/activity_settings_sync.xml +++ b/app/src/noGPlay/res/layout/activity_settings_sync.xml @@ -55,7 +55,7 @@ android:layout_marginEnd="16dp" android:padding="16dp" android:tint="?attr/tintColor" - app:srcCompat="@drawable/restorefile"/> + app:srcCompat="@drawable/restore_file"/> - \ No newline at end of file + diff --git a/app/src/test/java/me/ccrama/redditslide/test/SpoilerTextTest.java b/app/src/test/java/me/ccrama/redditslide/test/SpoilerTextTest.java index 4c61f854ef..0582a417aa 100644 --- a/app/src/test/java/me/ccrama/redditslide/test/SpoilerTextTest.java +++ b/app/src/test/java/me/ccrama/redditslide/test/SpoilerTextTest.java @@ -12,10 +12,10 @@ import me.ccrama.redditslide.SpoilerRobotoTextView; -import static junit.framework.Assert.fail; +import static org.junit.Assert.fail; @RunWith(PowerMockRunner.class) -@PrepareForTest({SpoilerRobotoTextView.class}) +@PrepareForTest(SpoilerRobotoTextView.class) public class SpoilerTextTest { private final Pattern htmlSpoilerPattern = Whitebox.getInternalState(SpoilerRobotoTextView.class, "htmlSpoilerPattern"); private final Pattern nativeSpoilerPattern = Whitebox.getInternalState(SpoilerRobotoTextView.class, "nativeSpoilerPattern"); @@ -46,9 +46,9 @@ public void nativeSpoilerTest() { private void spoilerTest(List tests, Pattern pattern, String name) { for (Object[] test : tests) { if (pattern.matcher((String) test[0]).matches() == (Boolean) test[1]) { - System.out.println(name.concat(": ").concat((String) test[0]).concat(" PASSED")); + System.out.println(name + ": " + (String) test[0] + " PASSED"); } else { - System.out.println(name.concat(": ").concat((String) test[0]).concat(" FAILED")); + System.out.println(name + ": " + (String) test[0] + " FAILED"); fail(); } } diff --git a/app/src/withGPlay/java/me/ccrama/redditslide/Activities/SettingsBackup.java b/app/src/withGPlay/java/me/ccrama/redditslide/Activities/SettingsBackup.java index c030721b45..a29fd7682d 100644 --- a/app/src/withGPlay/java/me/ccrama/redditslide/Activities/SettingsBackup.java +++ b/app/src/withGPlay/java/me/ccrama/redditslide/Activities/SettingsBackup.java @@ -284,8 +284,8 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) { for (int i = 1; i < files.length; i++) { String innerFile = files[i]; String t = innerFile.substring(6, innerFile.indexOf(">")); - innerFile = innerFile.substring(innerFile.indexOf(">") + 1, - innerFile.length()); + innerFile = innerFile.substring(innerFile.indexOf(">") + 1 + ); File newF = new File(getApplicationInfo().dataDir + File.separator @@ -678,7 +678,7 @@ public void onClick(DialogInterface dialog, int which) { + file.getAbsolutePath(), Snackbar.LENGTH_INDEFINITE); View view = s.getView(); - TextView tv = (TextView) view.findViewById( + TextView tv = view.findViewById( com.google.android.material.R.id.snackbar_text); tv.setTextColor(Color.WHITE); s.show(); diff --git a/app/src/withGPlay/res/layout/activity_settings_sync.xml b/app/src/withGPlay/res/layout/activity_settings_sync.xml index 726bf923f1..922b6adb5a 100644 --- a/app/src/withGPlay/res/layout/activity_settings_sync.xml +++ b/app/src/withGPlay/res/layout/activity_settings_sync.xml @@ -62,7 +62,7 @@ android:layout_marginEnd="16dp" android:padding="16dp" android:tint="?attr/tintColor" - app:srcCompat="@drawable/restorecloud" /> + app:srcCompat="@drawable/restore_cloud" /> + app:srcCompat="@drawable/restore_file" /> - \ No newline at end of file + diff --git a/build.gradle b/build.gradle index fe1cc48b4e..5b9d1c6b15 100644 --- a/build.gradle +++ b/build.gradle @@ -8,7 +8,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:4.0.1' + classpath 'com.android.tools.build:gradle:4.1.0' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 62d4c05355..e708b1c023 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ac33e9944a..3cd2be350c 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,6 @@ +#Mon Mar 23 16:50:37 CET 2020 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index fbd7c51583..4f906e0c81 100755 --- a/gradlew +++ b/gradlew @@ -130,7 +130,7 @@ fi if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - + JAVACMD=`cygpath --unix "$JAVACMD"` # We build the pattern for arguments to be converted via cygpath diff --git a/gradlew.bat b/gradlew.bat index 5093609d51..107acd32c4 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -40,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init +if "%ERRORLEVEL%" == "0" goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -54,7 +54,7 @@ goto fail set JAVA_HOME=%JAVA_HOME:"=% set JAVA_EXE=%JAVA_HOME%/bin/java.exe -if exist "%JAVA_EXE%" goto init +if exist "%JAVA_EXE%" goto execute echo. echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% @@ -64,21 +64,6 @@ echo location of your Java installation. goto fail -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - :execute @rem Setup the command line @@ -86,7 +71,7 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* :end @rem End local scope for the variables with windows NT shell