From d75e2e78bfdd9d7832379037ea7b5b323f321c3b Mon Sep 17 00:00:00 2001 From: NekoInverter <42698724+NekoInverter@users.noreply.github.com> Date: Mon, 23 Mar 2020 22:58:37 +0800 Subject: [PATCH] Remove codes for pre-21 --- app/src/main/AndroidManifest.xml | 6 - .../ui/ExcludedLanguagesActivity.java | 398 ------------------ .../hippo/ehviewer/ui/GalleryActivity.java | 2 +- .../com/hippo/ehviewer/ui/MyTagsActivity.java | 15 +- .../hippo/ehviewer/ui/UConfigActivity.java | 15 +- .../ui/fragment/DownloadFragment.java | 14 +- .../ehviewer/ui/scene/DownloadsScene.java | 8 +- .../ehviewer/ui/scene/GalleryDetailScene.java | 12 - .../hippo/ehviewer/ui/scene/HistoryScene.java | 6 +- .../ehviewer/ui/scene/WebViewSignInScene.java | 14 +- .../hippo/ehviewer/widget/SearchLayout.java | 1 - .../com/hippo/reveal/RevealLinearLayout.java | 9 - .../com/hippo/reveal/ViewAnimationUtils.java | 65 --- .../java/com/hippo/util/DrawableManager.java | 7 +- .../java/com/hippo/widget/CheckTextView.java | 3 - .../java/com/hippo/widget/DirExplorer.java | 190 --------- .../com/hippo/widget/ShadowLinearLayout.java | 46 +- .../main/res/drawable-xxhdpi/shadow_2dp.9.png | Bin 258 -> 0 bytes .../main/res/layout/activity_set_security.xml | 1 + .../res/layout/gallery_detail_actions.xml | 20 +- .../res/layout/gallery_detail_comments.xml | 3 + .../main/res/layout/gallery_detail_header.xml | 20 +- .../main/res/layout/gallery_detail_info.xml | 3 + .../res/layout/gallery_detail_previews.xml | 3 + app/src/main/res/layout/item_download.xml | 6 + app/src/main/res/layout/item_gallery_grid.xml | 4 +- app/src/main/res/layout/item_gallery_list.xml | 4 +- .../res/layout/scene_gallery_comments.xml | 6 +- app/src/main/res/layout/widget_search_bar.xml | 6 + settings.gradle | 2 +- 30 files changed, 84 insertions(+), 805 deletions(-) delete mode 100644 app/src/main/java/com/hippo/ehviewer/ui/ExcludedLanguagesActivity.java delete mode 100644 app/src/main/java/com/hippo/widget/DirExplorer.java delete mode 100644 app/src/main/res/drawable-xxhdpi/shadow_2dp.9.png diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index aa044030b..22ac6e9b2 100755 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -149,12 +149,6 @@ android:label="@string/settings" android:theme="@style/AppTheme.Settings" /> - - '9') { - return false; - } - } - return true; - } - - private void onInit() { - String excludedLanguages = Settings.getExcludedLanguages(); - if (null == excludedLanguages) { - return; - } - - String[] languages = excludedLanguages.split("x"); - - int iLength = languages.length; - int jLength = LANGUAGES.length; - for (int i = 0, j = 0; i < iLength; i++) { - String language = languages[i]; - if (!isDecimal(language)) { - continue; - } - - for (; j < jLength; j++) { - String pattern = LANGUAGES[j]; - if (pattern.equals(language)) { - // Get it - int row = j / 3; - int column = j % 3; - mSelections[row][column] = true; - break; - } - } - } - } - - private long saveSelectionsToLong() { - boolean[][] selections = mSelections; - long value = 0; - for (int i = 0; i < ROW_COUNT; i++) { - for (int j = 0; j < 3; j++) { - if (selections[i][j]) { - value |= 1 << (i * 3 + j); - } - } - } - return value; - } - - private void restoreSelectionsFromLong(long value) { - boolean[][] selections = mSelections; - for (int i = 0; i < ROW_COUNT; i++) { - for (int j = 0; j < 3; j++) { - selections[i][j] = 0 != ((value >>> (i * 3 + j)) & 1); - } - } - } - - private void onRestore(@NonNull Bundle savedInstanceState) { - restoreSelectionsFromLong(savedInstanceState.getLong(KEY_SELECTIONS)); - } - - @Override - protected void onSaveInstanceState(Bundle outState) { - super.onSaveInstanceState(outState); - outState.putLong(KEY_SELECTIONS, saveSelectionsToLong()); - } - - @Override - protected void onDestroy() { - super.onDestroy(); - - mCancel = null; - mOk = null; - mSelectAll = null; - mDeselectAll = null; - mInvertSelection = null; - mRecyclerView = null; - mAdapter = null; - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case android.R.id.home: - finish(); - return true; - default: - return super.onOptionsItemSelected(item); - } - } - - @Override - public void onClick(View v) { - if (null == mAdapter) { - return; - } - - if (v == mCancel) { - finish(); - } else if (v == mOk) { - StringBuilder sb = new StringBuilder(); - int i = 0; - boolean first = true; - for (boolean[] selections : mSelections) { - for (boolean b : selections) { - if (b) { - if (!first) { - sb.append("x"); - } else { - first = false; - } - sb.append(LANGUAGES[i]); - } - i++; - } - } - - String excludedLanguages = sb.toString(); - Settings.putExcludedLanguages(excludedLanguages); - finish(); - } else if (v == mSelectAll) { - for (boolean[] selections : mSelections) { - int length = selections.length; - for (int i = 0; i < length; i++) { - selections[i] = true; - } - } - mAdapter.notifyDataSetChanged(); - } else if (v == mDeselectAll) { - for (boolean[] selections : mSelections) { - int length = selections.length; - for (int i = 0; i < length; i++) { - selections[i] = false; - } - } - mAdapter.notifyDataSetChanged(); - } else if (v == mInvertSelection) { - for (boolean[] selections : mSelections) { - int length = selections.length; - for (int i = 0; i < length; i++) { - selections[i] = !selections[i]; - } - } - mAdapter.notifyDataSetChanged(); - } - } - - private class LanguageHolder extends RecyclerView.ViewHolder - implements SensitiveCheckBox.OnCheckedChangeListener { - - public TextView language; - public SensitiveCheckBox original; - public SensitiveCheckBox translated; - public SensitiveCheckBox rewrite; - - public LanguageHolder(View itemView) { - super(itemView); - - ViewGroup viewGroup = (ViewGroup) itemView; - language = (TextView) viewGroup.getChildAt(0); - original = (SensitiveCheckBox) viewGroup.getChildAt(1); - translated = (SensitiveCheckBox) viewGroup.getChildAt(2); - rewrite = (SensitiveCheckBox) viewGroup.getChildAt(3); - - original.setOnCheckedChangeListener(this); - translated.setOnCheckedChangeListener(this); - rewrite.setOnCheckedChangeListener(this); - } - - @Override - public void onCheckedChanged(SensitiveCheckBox view, boolean isChecked, boolean fromUser) { - if (fromUser) { - int row = getAdapterPosition(); - if (row < 0) { - return; - } - int column; - if (view == original) { - column = 0; - } else if (view == translated) { - column = 1; - } else { - column = 2; - } - mSelections[row][column] = !mSelections[row][column]; - } - } - } - - private class LanguageAdapter extends RecyclerView.Adapter { - - @Override - public LanguageHolder onCreateViewHolder(ViewGroup parent, int viewType) { - return new LanguageHolder(getLayoutInflater().inflate(R.layout.item_excluded_languages, parent, false)); - } - - @Override - public void onBindViewHolder(LanguageHolder holder, int position) { - holder.language.setText(LANGUAGE_STR_IDS[position]); - boolean[] selections = mSelections[position]; - holder.original.setChecked(selections[0]); - holder.translated.setChecked(selections[1]); - holder.rewrite.setChecked(selections[2]); - } - - @Override - public int getItemCount() { - return ROW_COUNT; - } - } -} diff --git a/app/src/main/java/com/hippo/ehviewer/ui/GalleryActivity.java b/app/src/main/java/com/hippo/ehviewer/ui/GalleryActivity.java index ead4d5fec..8156d8fc2 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/GalleryActivity.java +++ b/app/src/main/java/com/hippo/ehviewer/ui/GalleryActivity.java @@ -243,7 +243,7 @@ public class GalleryActivity extends EhActivity implements SeekBar.OnSeekBarChan @SuppressWarnings({"WrongConstant"}) protected void onCreate(@Nullable Bundle savedInstanceState) { getDelegate().setLocalNightMode(AppCompatDelegate.MODE_NIGHT_YES); - if (Settings.getReadingFullscreen() && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + if (Settings.getReadingFullscreen()) { Window w = getWindow(); w.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION, WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); diff --git a/app/src/main/java/com/hippo/ehviewer/ui/MyTagsActivity.java b/app/src/main/java/com/hippo/ehviewer/ui/MyTagsActivity.java index 5f3d7484a..7052b1306 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/MyTagsActivity.java +++ b/app/src/main/java/com/hippo/ehviewer/ui/MyTagsActivity.java @@ -52,17 +52,10 @@ public class MyTagsActivity extends ToolbarActivity { // http://stackoverflow.com/questions/32284642/how-to-handle-an-uncatched-exception CookieManager cookieManager = CookieManager.getInstance(); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - cookieManager.flush(); - cookieManager.removeAllCookies(null); - cookieManager.removeSessionCookies(null); - } else { - CookieSyncManager cookieSyncManager = CookieSyncManager.createInstance(this); - cookieSyncManager.startSync(); - cookieManager.removeAllCookie(); - cookieManager.removeSessionCookie(); - cookieSyncManager.stopSync(); - } + cookieManager.flush(); + cookieManager.removeAllCookies(null); + cookieManager.removeSessionCookies(null); + // Copy cookies from okhttp cookie store to CookieManager url = EhUrl.getMyTagsUrl(); diff --git a/app/src/main/java/com/hippo/ehviewer/ui/UConfigActivity.java b/app/src/main/java/com/hippo/ehviewer/ui/UConfigActivity.java index f8eeac4d0..36382c5cd 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/UConfigActivity.java +++ b/app/src/main/java/com/hippo/ehviewer/ui/UConfigActivity.java @@ -59,17 +59,10 @@ public class UConfigActivity extends ToolbarActivity { // http://stackoverflow.com/questions/32284642/how-to-handle-an-uncatched-exception CookieManager cookieManager = CookieManager.getInstance(); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - cookieManager.flush(); - cookieManager.removeAllCookies(null); - cookieManager.removeSessionCookies(null); - } else { - CookieSyncManager cookieSyncManager = CookieSyncManager.createInstance(this); - cookieSyncManager.startSync(); - cookieManager.removeAllCookie(); - cookieManager.removeSessionCookie(); - cookieSyncManager.stopSync(); - } + cookieManager.flush(); + cookieManager.removeAllCookies(null); + cookieManager.removeSessionCookies(null); + // Copy cookies from okhttp cookie store to CookieManager url = EhUrl.getUConfigUrl(); diff --git a/app/src/main/java/com/hippo/ehviewer/ui/fragment/DownloadFragment.java b/app/src/main/java/com/hippo/ehviewer/ui/fragment/DownloadFragment.java index e2a7f9fb8..103a5f81c 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/fragment/DownloadFragment.java +++ b/app/src/main/java/com/hippo/ehviewer/ui/fragment/DownloadFragment.java @@ -91,14 +91,12 @@ public class DownloadFragment extends PreferenceFragmentCompat implements } private void openDirPickerL() { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE); - try { - startActivityForResult(intent, REQUEST_CODE_PICK_IMAGE_DIR_L); - } catch (Throwable e) { - ExceptionUtils.throwIfFatal(e); - Toast.makeText(getActivity(), R.string.error_cant_find_activity, Toast.LENGTH_SHORT).show(); - } + Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE); + try { + startActivityForResult(intent, REQUEST_CODE_PICK_IMAGE_DIR_L); + } catch (Throwable e) { + ExceptionUtils.throwIfFatal(e); + Toast.makeText(getActivity(), R.string.error_cant_find_activity, Toast.LENGTH_SHORT).show(); } } diff --git a/app/src/main/java/com/hippo/ehviewer/ui/scene/DownloadsScene.java b/app/src/main/java/com/hippo/ehviewer/ui/scene/DownloadsScene.java index 6a48547bf..9d5bdbbee 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/scene/DownloadsScene.java +++ b/app/src/main/java/com/hippo/ehviewer/ui/scene/DownloadsScene.java @@ -1086,10 +1086,6 @@ public class DownloadsScene extends ToolbarScene thumb.setOnClickListener(this); start.setOnClickListener(this); stop.setOnClickListener(this); - - boolean isDarkTheme = !AttrResources.getAttrBoolean(getContext2(), R.attr.isLightTheme); - Ripple.addRipple(start, isDarkTheme); - Ripple.addRipple(stop, isDarkTheme); } @Override @@ -1186,9 +1182,7 @@ public class DownloadsScene extends ToolbarScene bindForState(holder, info); // Update transition name - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - ViewCompat.setTransitionName(holder.thumb, TransitionNameFactory.getThumbTransitionName(info.gid)); - } + ViewCompat.setTransitionName(holder.thumb, TransitionNameFactory.getThumbTransitionName(info.gid)); } @Override diff --git a/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryDetailScene.java b/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryDetailScene.java index 11cc78760..ea70894fe 100755 --- a/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryDetailScene.java +++ b/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryDetailScene.java @@ -516,8 +516,6 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene mActionGroup = (ViewGroup) ViewUtils.$$(mHeader, R.id.action_card); mDownload = (TextView) ViewUtils.$$(mActionGroup, R.id.download); mRead = ViewUtils.$$(mActionGroup, R.id.read); - Ripple.addRipple(mDownload, isDarkTheme); - Ripple.addRipple(mRead, isDarkTheme); mUploader.setOnClickListener(this); mCategory.setOnClickListener(this); mOtherActions.setOnClickListener(this); @@ -536,7 +534,6 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene mSize = (TextView) ViewUtils.$$(mInfo, R.id.size); mPosted = (TextView) ViewUtils.$$(mInfo, R.id.posted); mFavoredTimes = (TextView) ViewUtils.$$(mInfo, R.id.favoredTimes); - Ripple.addRipple(mInfo, isDarkTheme); mInfo.setOnClickListener(this); mActions = ViewUtils.$$(belowHeader, R.id.actions); @@ -551,13 +548,6 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene mRate = (TextView) ViewUtils.$$(mActions, R.id.rate); mSimilar = (TextView) ViewUtils.$$(mActions, R.id.similar); mSearchCover = (TextView) ViewUtils.$$(mActions, R.id.search_cover); - Ripple.addRipple(mHeartGroup, isDarkTheme); - Ripple.addRipple(mTorrent, isDarkTheme); - Ripple.addRipple(mArchive, isDarkTheme); - Ripple.addRipple(mShare, isDarkTheme); - Ripple.addRipple(mRate, isDarkTheme); - Ripple.addRipple(mSimilar, isDarkTheme); - Ripple.addRipple(mSearchCover, isDarkTheme); mHeartGroup.setOnClickListener(this); mTorrent.setOnClickListener(this); mArchive.setOnClickListener(this); @@ -572,13 +562,11 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene mComments = (LinearLayout) ViewUtils.$$(belowHeader, R.id.comments); mCommentsText = (TextView) ViewUtils.$$(mComments, R.id.comments_text); - Ripple.addRipple(mComments, isDarkTheme); mComments.setOnClickListener(this); mPreviews = ViewUtils.$$(belowHeader, R.id.previews); mGridLayout = (SimpleGridAutoSpanLayout) ViewUtils.$$(mPreviews, R.id.grid_layout); mPreviewText = (TextView) ViewUtils.$$(mPreviews, R.id.preview_text); - Ripple.addRipple(mPreviews, isDarkTheme); mPreviews.setOnClickListener(this); mProgress = ViewUtils.$$(mainView, R.id.progress); diff --git a/app/src/main/java/com/hippo/ehviewer/ui/scene/HistoryScene.java b/app/src/main/java/com/hippo/ehviewer/ui/scene/HistoryScene.java index ae235dba5..aa93abff1 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/scene/HistoryScene.java +++ b/app/src/main/java/com/hippo/ehviewer/ui/scene/HistoryScene.java @@ -407,10 +407,8 @@ public class HistoryScene extends ToolbarScene holder.simpleLanguage.setText(gi.simpleLanguage); // Update transition name - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - long gid = gi.gid; - ViewCompat.setTransitionName(holder.thumb, TransitionNameFactory.getThumbTransitionName(gid)); - } + long gid = gi.gid; + ViewCompat.setTransitionName(holder.thumb, TransitionNameFactory.getThumbTransitionName(gid)); } @Override diff --git a/app/src/main/java/com/hippo/ehviewer/ui/scene/WebViewSignInScene.java b/app/src/main/java/com/hippo/ehviewer/ui/scene/WebViewSignInScene.java index 435ccee9d..c1e63a028 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/scene/WebViewSignInScene.java +++ b/app/src/main/java/com/hippo/ehviewer/ui/scene/WebViewSignInScene.java @@ -69,17 +69,9 @@ public class WebViewSignInScene extends SolidScene { // http://stackoverflow.com/questions/32284642/how-to-handle-an-uncatched-exception CookieManager cookieManager = CookieManager.getInstance(); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - cookieManager.flush(); - cookieManager.removeAllCookies(null); - cookieManager.removeSessionCookies(null); - } else { - CookieSyncManager cookieSyncManager = CookieSyncManager.createInstance(context); - cookieSyncManager.startSync(); - cookieManager.removeAllCookie(); - cookieManager.removeSessionCookie(); - cookieSyncManager.stopSync(); - } + cookieManager.flush(); + cookieManager.removeAllCookies(null); + cookieManager.removeSessionCookies(null); mWebView = new WebView(context); mWebView.getSettings().setJavaScriptEnabled(true); diff --git a/app/src/main/java/com/hippo/ehviewer/widget/SearchLayout.java b/app/src/main/java/com/hippo/ehviewer/widget/SearchLayout.java index c00e0be4c..b41ed7891 100644 --- a/app/src/main/java/com/hippo/ehviewer/widget/SearchLayout.java +++ b/app/src/main/java/com/hippo/ehviewer/widget/SearchLayout.java @@ -126,7 +126,6 @@ public class SearchLayout extends EasyRecyclerView implements CompoundButton.OnC mNormalSearchModeHelp = (ImageView) normalView.findViewById(R.id.normal_search_mode_help); mEnableAdvanceSwitch = (SwitchCompat) normalView.findViewById(R.id.search_enable_advance); mNormalSearchModeHelp.setOnClickListener(this); - Ripple.addRipple(mNormalSearchModeHelp, !AttrResources.getAttrBoolean(context, R.attr.isLightTheme)); mEnableAdvanceSwitch.setOnCheckedChangeListener(SearchLayout.this); mEnableAdvanceSwitch.setSwitchPadding(resources.getDimensionPixelSize(R.dimen.switch_padding)); diff --git a/app/src/main/java/com/hippo/reveal/RevealLinearLayout.java b/app/src/main/java/com/hippo/reveal/RevealLinearLayout.java index f7c938419..157d72c02 100644 --- a/app/src/main/java/com/hippo/reveal/RevealLinearLayout.java +++ b/app/src/main/java/com/hippo/reveal/RevealLinearLayout.java @@ -32,23 +32,14 @@ public class RevealLinearLayout extends LinearLayout implements Reveal { public RevealLinearLayout(Context context) { super(context); - init(); } public RevealLinearLayout(Context context, AttributeSet attrs) { super(context, attrs); - init(); } public RevealLinearLayout(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); - init(); - } - - private void init() { - if (!ViewAnimationUtils.API_SUPPORT_CIRCULAR_REVEAL) { - setWillNotDraw(false); - } } @Override diff --git a/app/src/main/java/com/hippo/reveal/ViewAnimationUtils.java b/app/src/main/java/com/hippo/reveal/ViewAnimationUtils.java index d3428d737..a8e8a13b5 100644 --- a/app/src/main/java/com/hippo/reveal/ViewAnimationUtils.java +++ b/app/src/main/java/com/hippo/reveal/ViewAnimationUtils.java @@ -25,76 +25,11 @@ import android.view.View; import com.hippo.yorozuya.SimpleAnimatorListener; public final class ViewAnimationUtils { - public static final boolean API_SUPPORT_CIRCULAR_REVEAL = - Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP; // http://developer.android.com/guide/topics/graphics/hardware-accel.html#unsupported - private ViewAnimationUtils() { - } - - @TargetApi(Build.VERSION_CODES.LOLLIPOP) public static Animator createCircularReveal(View view, int centerX, int centerY, float startRadius, float endRadius) { - if (API_SUPPORT_CIRCULAR_REVEAL) { return android.view.ViewAnimationUtils.createCircularReveal( view, centerX, centerY, startRadius, endRadius); - } else if (view instanceof Reveal) { - return createRevealAnimator((Reveal) view, centerX, centerY, - startRadius, endRadius); - } else { - throw new IllegalStateException("Only View implements CircularReveal or" + - " api >= 21 can create circular reveal"); - } - } - - private static Animator createRevealAnimator(Reveal reveal, int centerX, int centerY, - float startRadius, float endRadius) { - ValueAnimator animator = ValueAnimator.ofFloat(startRadius, endRadius); - animator.addUpdateListener(new RevealAnimatorUpdateListener(reveal, centerX, centerY)); - animator.addListener(new RevealAnimatorListener(reveal)); - return animator; - } - - private static class RevealAnimatorUpdateListener - implements ValueAnimator.AnimatorUpdateListener { - - private final Reveal mReveal; - private final int mCenterX; - private final int mCenterY; - - public RevealAnimatorUpdateListener(Reveal reveal, int centerX, int centerY) { - mReveal = reveal; - mCenterX = centerX; - mCenterY = centerY; - } - - @Override - public void onAnimationUpdate(ValueAnimator animation) { - Object value = animation.getAnimatedValue(); - if (value instanceof Float) { - mReveal.setReveal(mCenterX, mCenterY, (Float) value); - } - } - } - - private static class RevealAnimatorListener extends SimpleAnimatorListener { - - private final Reveal mReveal; - private final View mView; - - public RevealAnimatorListener(Reveal reveal) { - mReveal = reveal; - mView = (View) reveal; - } - - @Override - public void onAnimationStart(Animator animation) { - mReveal.setRevealEnable(true); - } - - @Override - public void onAnimationEnd(Animator animation) { - mReveal.setRevealEnable(false); - } } } diff --git a/app/src/main/java/com/hippo/util/DrawableManager.java b/app/src/main/java/com/hippo/util/DrawableManager.java index b9efc9e99..2f84a3d10 100644 --- a/app/src/main/java/com/hippo/util/DrawableManager.java +++ b/app/src/main/java/com/hippo/util/DrawableManager.java @@ -24,7 +24,6 @@ import android.os.Build; import androidx.annotation.DrawableRes; import androidx.annotation.NonNull; import androidx.annotation.Nullable; -import androidx.vectordrawable.graphics.drawable.VectorDrawableCompat; public final class DrawableManager { @@ -34,10 +33,6 @@ public final class DrawableManager { public static Drawable getVectorDrawable(@NonNull Resources res, @DrawableRes int resId, @Nullable Resources.Theme theme) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - return res.getDrawable(resId, theme); - } else { - return VectorDrawableCompat.create(res, resId, theme); - } + return res.getDrawable(resId, theme); } } diff --git a/app/src/main/java/com/hippo/widget/CheckTextView.java b/app/src/main/java/com/hippo/widget/CheckTextView.java index 2f345e9d4..13ce140d9 100644 --- a/app/src/main/java/com/hippo/widget/CheckTextView.java +++ b/app/src/main/java/com/hippo/widget/CheckTextView.java @@ -82,9 +82,6 @@ public class CheckTextView extends AppCompatTextView implements OnClickListener, mPaint.setColor(mMaskColor); setOnClickListener(this); - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { - Hotspot.addHotspotable(this, this); - } } @Override diff --git a/app/src/main/java/com/hippo/widget/DirExplorer.java b/app/src/main/java/com/hippo/widget/DirExplorer.java deleted file mode 100644 index 8a605c1c7..000000000 --- a/app/src/main/java/com/hippo/widget/DirExplorer.java +++ /dev/null @@ -1,190 +0,0 @@ -/* - * Copyright 2015 Hippo Seven - * - * 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. - */ - -package com.hippo.widget; - -import android.content.Context; -import android.graphics.Color; -import android.graphics.drawable.ColorDrawable; -import android.os.Environment; -import android.util.AttributeSet; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.TextView; - -import androidx.recyclerview.widget.LinearLayoutManager; - -import com.hippo.android.resource.AttrResources; -import com.hippo.easyrecyclerview.EasyRecyclerView; -import com.hippo.easyrecyclerview.LinearDividerItemDecoration; -import com.hippo.ehviewer.R; -import com.hippo.ripple.Ripple; -import com.hippo.yorozuya.LayoutUtils; - -import java.io.File; -import java.io.FileFilter; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; - -public class DirExplorer extends EasyRecyclerView implements EasyRecyclerView.OnItemClickListener { - - private static final DirFilter DIR_FILTER = new DirFilter(); - private static final FileSort FILE_SORT = new FileSort(); - - private static final File PARENT_DIR = null; - private static final String PARENT_DIR_NAME = ".."; - private final List mFiles = new ArrayList<>(); - private File mCurrentFile; - private DirAdapter mAdapter; - - private OnChangeDirListener mOnChangeDirListener; - - public DirExplorer(Context context) { - super(context); - init(context); - } - - public DirExplorer(Context context, AttributeSet attrs) { - super(context, attrs); - init(context); - } - - public DirExplorer(Context context, AttributeSet attrs, int defStyle) { - super(context, attrs, defStyle); - init(context); - } - - private void init(Context context) { - mAdapter = new DirAdapter(); - setAdapter(mAdapter); - setLayoutManager(new LinearLayoutManager(context)); - LinearDividerItemDecoration decoration = new LinearDividerItemDecoration( - LinearDividerItemDecoration.VERTICAL, AttrResources.getAttrColor(context, R.attr.dividerColor), - LayoutUtils.dp2pix(context, 1)); - decoration.setShowLastDivider(true); - addItemDecoration(decoration); - setSelector(Ripple.generateRippleDrawable(context, !AttrResources.getAttrBoolean(context, R.attr.isLightTheme), new ColorDrawable(Color.TRANSPARENT))); - setOnItemClickListener(this); - - mCurrentFile = Environment.getExternalStorageDirectory(); - if (!Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState()) - || mCurrentFile == null) { - mCurrentFile = new File("/"); - } - updateFileList(); - } - - public void setOnChangeDirListener(OnChangeDirListener listener) { - mOnChangeDirListener = listener; - } - - public void updateFileList() { - File[] files = mCurrentFile.listFiles(DIR_FILTER); - - mFiles.clear(); - if (mCurrentFile.getParent() != null) { - mFiles.add(PARENT_DIR); - } - if (files != null) { - Collections.addAll(mFiles, files); - } - // sort - Collections.sort(mFiles, FILE_SORT); - } - - public File getCurrentFile() { - return mCurrentFile; - } - - public void setCurrentFile(File file) { - if (file != null && file.isDirectory()) { - mCurrentFile = file; - updateFileList(); - mAdapter.notifyDataSetChanged(); - - if (mOnChangeDirListener != null) { - mOnChangeDirListener.onChangeDir(mCurrentFile); - } - } - } - - @Override - public boolean onItemClick(EasyRecyclerView parent, View view, int position, long id) { - File file = mFiles.get(position); - if (file == PARENT_DIR) { - file = mCurrentFile.getParentFile(); - } - setCurrentFile(file); - return true; - } - - public interface OnChangeDirListener { - - void onChangeDir(File dir); - } - - static class DirFilter implements FileFilter { - @Override - public boolean accept(File pathname) { - return pathname.isDirectory(); - } - } - - static class FileSort implements Comparator { - @Override - public int compare(File lhs, File rhs) { - if (lhs == null) { - return Integer.MIN_VALUE; - } else if (rhs == null) { - return Integer.MAX_VALUE; - } else { - return lhs.getName().compareToIgnoreCase(rhs.getName()); - } - } - } - - private class DirHolder extends ViewHolder { - - public TextView textView; - - public DirHolder(View itemView) { - super(itemView); - textView = (TextView) itemView; - } - } - - private class DirAdapter extends Adapter { - - @Override - public DirHolder onCreateViewHolder(ViewGroup parent, int viewType) { - return new DirHolder(LayoutInflater.from(getContext()).inflate(R.layout.item_dir_explorer, parent, false)); - } - - @Override - public void onBindViewHolder(DirHolder holder, int position) { - File file = mFiles.get(position); - holder.textView.setText(file == PARENT_DIR ? PARENT_DIR_NAME : file.getName()); - } - - @Override - public int getItemCount() { - return mFiles.size(); - } - } -} diff --git a/app/src/main/java/com/hippo/widget/ShadowLinearLayout.java b/app/src/main/java/com/hippo/widget/ShadowLinearLayout.java index fce4069de..eee7c2783 100644 --- a/app/src/main/java/com/hippo/widget/ShadowLinearLayout.java +++ b/app/src/main/java/com/hippo/widget/ShadowLinearLayout.java @@ -32,9 +32,6 @@ import com.hippo.yorozuya.LayoutUtils; public class ShadowLinearLayout extends LinearLayout { - private final Rect mShadowPaddings = new Rect(); - private NinePatchDrawable mShadow; - public ShadowLinearLayout(Context context) { super(context); init(context); @@ -51,47 +48,8 @@ public class ShadowLinearLayout extends LinearLayout { } private void init(Context context) { - // TODO not only 2dp - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - setOutlineProvider(ViewOutlineProvider.BOUNDS); - setElevation(LayoutUtils.dp2pix(context, 2)); - } else { - setShadow((NinePatchDrawable) context.getResources().getDrawable(R.drawable.shadow_2dp)); // TODO draktheme - } + setOutlineProvider(ViewOutlineProvider.BOUNDS); + setElevation(LayoutUtils.dp2pix(context, 2)); } - private void setShadow(NinePatchDrawable shadow) { - mShadow = shadow; - mShadow.getPadding(mShadowPaddings); - updateShadowBounds(); - setWillNotDraw(false); - } - - private void updateShadowBounds() { - NinePatchDrawable shadow = mShadow; - if (shadow == null) { - return; - } - - int width = getWidth(); - int height = getHeight(); - Rect paddings = mShadowPaddings; - if (width != 0 && height != 0) { - shadow.setBounds(-paddings.left, -paddings.top, width + paddings.right, height + paddings.bottom); - } - } - - @Override - protected void onLayout(boolean changed, int left, int top, int right, int bottom) { - super.onLayout(changed, left, top, right, bottom); - updateShadowBounds(); - } - - @Override - public void draw(@NonNull Canvas canvas) { - if (mShadow != null) { - mShadow.draw(canvas); - } - super.draw(canvas); - } } diff --git a/app/src/main/res/drawable-xxhdpi/shadow_2dp.9.png b/app/src/main/res/drawable-xxhdpi/shadow_2dp.9.png deleted file mode 100644 index 0592d8ee6e01f1e11ea4e8425f09b3fbc317690d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 258 zcmV+d0sa1oP)x?7#z{Zx1S})fEr13CyCnstU=xwoAP1=}n_gz%5RvyRUA1zxg{*Px%TS-~~S94W8f*PL?d}X;+-48QP7(Ej5Q_uCm~?9XaO`n1G$f7Oa>+`?BK4 zf@RG+D48JRk~r&W`WSOfyU-LB*VB0z3IC`9q!eZ74gbP9U#>zKGdOVHxBvhE07*qo IM6N<$f@5fDzW@LL diff --git a/app/src/main/res/layout/activity_set_security.xml b/app/src/main/res/layout/activity_set_security.xml index f8c2673e3..deb842287 100755 --- a/app/src/main/res/layout/activity_set_security.xml +++ b/app/src/main/res/layout/activity_set_security.xml @@ -76,6 +76,7 @@ android:layout_height="wrap_content" android:layout_weight="1" android:text="@string/set" /> +