Remove codes for pre-21

This commit is contained in:
NekoInverter committed 2020-03-23 22:58:37 +08:00
1 parent 910c05b5a6
commit d75e2e78bf
30 files changed
+84 -805

No files matched your search

-6
View File
@@ -149,12 +149,6 @@
android:label="@string/settings"
android:theme="@style/AppTheme.Settings" />
<activity
android:name="com.hippo.ehviewer.ui.ExcludedLanguagesActivity"
android:configChanges="screenSize|uiMode"
android:label="@string/excluded_languages"
android:theme="@style/AppTheme.Toolbar" />
<activity
android:name="com.hippo.ehviewer.ui.FilterActivity"
android:configChanges="screenSize|uiMode"
@@ -1,398 +0,0 @@
/*
* Copyright 2016 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.ehviewer.ui;
import android.os.Bundle;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.hippo.android.resource.AttrResources;
import com.hippo.easyrecyclerview.EasyRecyclerView;
import com.hippo.ehviewer.R;
import com.hippo.ehviewer.Settings;
import com.hippo.ehviewer.client.EhConfig;
import com.hippo.ripple.Ripple;
import com.hippo.widget.SensitiveCheckBox;
import com.hippo.yorozuya.ViewUtils;
public class ExcludedLanguagesActivity extends ToolbarActivity
implements View.OnClickListener {
private static final String KEY_SELECTIONS = "selections";
private static final int ROW_COUNT = 17;
private static final int[] LANGUAGE_STR_IDS = {
R.string.language_japanese,
R.string.language_english,
R.string.language_chinese,
R.string.language_dutch,
R.string.language_french,
R.string.language_german,
R.string.language_hungarian,
R.string.language_italian,
R.string.language_korean,
R.string.language_polish,
R.string.language_portuguese,
R.string.language_russian,
R.string.language_spanish,
R.string.language_thai,
R.string.language_vietnamese,
R.string.language_na,
R.string.language_other
};
private static final String[] LANGUAGES = {
EhConfig.JAPANESE_ORIGINAL,
EhConfig.JAPANESE_TRANSLATED,
EhConfig.JAPANESE_REWRITE,
EhConfig.ENGLISH_ORIGINAL,
EhConfig.ENGLISH_TRANSLATED,
EhConfig.ENGLISH_REWRITE,
EhConfig.CHINESE_ORIGINAL,
EhConfig.CHINESE_TRANSLATED,
EhConfig.CHINESE_REWRITE,
EhConfig.DUTCH_ORIGINAL,
EhConfig.DUTCH_TRANSLATED,
EhConfig.DUTCH_REWRITE,
EhConfig.FRENCH_ORIGINAL,
EhConfig.FRENCH_TRANSLATED,
EhConfig.FRENCH_REWRITE,
EhConfig.GERMAN_ORIGINAL,
EhConfig.GERMAN_TRANSLATED,
EhConfig.GERMAN_REWRITE,
EhConfig.HUNGARIAN_ORIGINAL,
EhConfig.HUNGARIAN_TRANSLATED,
EhConfig.HUNGARIAN_REWRITE,
EhConfig.ITALIAN_ORIGINAL,
EhConfig.ITALIAN_TRANSLATED,
EhConfig.ITALIAN_REWRITE,
EhConfig.KOREAN_ORIGINAL,
EhConfig.KOREAN_TRANSLATED,
EhConfig.KOREAN_REWRITE,
EhConfig.POLISH_ORIGINAL,
EhConfig.POLISH_TRANSLATED,
EhConfig.POLISH_REWRITE,
EhConfig.PORTUGUESE_ORIGINAL,
EhConfig.PORTUGUESE_TRANSLATED,
EhConfig.PORTUGUESE_REWRITE,
EhConfig.RUSSIAN_ORIGINAL,
EhConfig.RUSSIAN_TRANSLATED,
EhConfig.RUSSIAN_REWRITE,
EhConfig.SPANISH_ORIGINAL,
EhConfig.SPANISH_TRANSLATED,
EhConfig.SPANISH_REWRITE,
EhConfig.THAI_ORIGINAL,
EhConfig.THAI_TRANSLATED,
EhConfig.THAI_REWRITE,
EhConfig.VIETNAMESE_ORIGINAL,
EhConfig.VIETNAMESE_TRANSLATED,
EhConfig.VIETNAMESE_REWRITE,
EhConfig.NA_ORIGINAL,
EhConfig.NA_TRANSLATED,
EhConfig.NA_REWRITE,
EhConfig.OTHER_ORIGINAL,
EhConfig.OTHER_TRANSLATED,
EhConfig.OTHER_REWRITE};
private final boolean[][] mSelections = new boolean[ROW_COUNT][3];
/*---------------
Whole life cycle
---------------*/
@Nullable
private View mCancel;
@Nullable
private View mOk;
@Nullable
private View mSelectAll;
@Nullable
private View mDeselectAll;
@Nullable
private View mInvertSelection;
@Nullable
private EasyRecyclerView mRecyclerView;
@Nullable
private LanguageAdapter mAdapter;
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.scene_excluded_languages);
setNavigationIcon(R.drawable.v_arrow_left_dark_x24);
if (null == savedInstanceState) {
onInit();
} else {
onRestore(savedInstanceState);
}
mCancel = ViewUtils.$$(this, R.id.cancel);
mOk = ViewUtils.$$(this, R.id.ok);
mSelectAll = ViewUtils.$$(this, R.id.select_all);
mDeselectAll = ViewUtils.$$(this, R.id.deselect_all);
mInvertSelection = ViewUtils.$$(this, R.id.invert_selection);
mRecyclerView = (EasyRecyclerView) ViewUtils.$$(this, R.id.recycler_view);
mRecyclerView.setHasFixedSize(true);
mRecyclerView.setClipToPadding(false);
mAdapter = new LanguageAdapter();
mRecyclerView.setAdapter(mAdapter);
mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
mCancel.setOnClickListener(this);
mOk.setOnClickListener(this);
mSelectAll.setOnClickListener(this);
mDeselectAll.setOnClickListener(this);
mInvertSelection.setOnClickListener(this);
boolean isDarkTheme = !AttrResources.getAttrBoolean(this, R.attr.isLightTheme);
Ripple.addRipple(mCancel, isDarkTheme);
Ripple.addRipple(mOk, isDarkTheme);
Ripple.addRipple(mSelectAll, isDarkTheme);
Ripple.addRipple(mDeselectAll, isDarkTheme);
Ripple.addRipple(mInvertSelection, isDarkTheme);
}
private boolean isDecimal(String str) {
int length = str.length();
// "" is not decimal
if (length <= 0) {
return false;
}
for (int i = 0; i < length; i++) {
char ch = str.charAt(i);
if (ch < '0' || ch > '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<LanguageHolder> {
@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;
}
}
}
@@ -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);
@@ -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();
@@ -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();
@@ -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();
}
}
@@ -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
@@ -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);
@@ -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
@@ -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);
@@ -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));
@@ -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
@@ -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);
}
}
}
@@ -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);
}
}
@@ -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
@@ -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<File> 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<File> {
@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<DirHolder> {
@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();
}
}
}
@@ -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);
}
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 258 B

@@ -76,6 +76,7 @@
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/set" />
<Button
android:id="@+id/cancel"
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
@@ -42,7 +42,10 @@
<FrameLayout
android:id="@+id/heart_group"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:background="?selectableItemBackgroundBorderless"
android:clickable="true"
android:focusable="true">
<TextView
android:id="@+id/heart"
@@ -68,7 +71,10 @@
android:id="@+id/rate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?selectableItemBackgroundBorderless"
android:clickable="true"
android:drawablePadding="8dp"
android:focusable="true"
android:gravity="center_horizontal"
android:text="@string/rate"
android:textColor="?android:attr/textColorPrimary" />
@@ -77,7 +83,10 @@
android:id="@+id/share"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?selectableItemBackgroundBorderless"
android:clickable="true"
android:drawablePadding="8dp"
android:focusable="true"
android:gravity="center_horizontal"
android:text="@string/share"
android:textColor="?android:attr/textColorPrimary" />
@@ -94,7 +103,10 @@
android:id="@+id/archive"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?selectableItemBackgroundBorderless"
android:clickable="true"
android:drawablePadding="8dp"
android:focusable="true"
android:gravity="center_horizontal"
android:text="@string/archive"
android:textColor="?android:attr/textColorPrimary" />
@@ -103,7 +115,10 @@
android:id="@+id/similar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?selectableItemBackgroundBorderless"
android:clickable="true"
android:drawablePadding="8dp"
android:focusable="true"
android:gravity="center_horizontal"
android:text="@string/similar_gallery"
android:textColor="?android:attr/textColorPrimary" />
@@ -112,7 +127,10 @@
android:id="@+id/search_cover"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?selectableItemBackgroundBorderless"
android:clickable="true"
android:drawablePadding="8dp"
android:focusable="true"
android:gravity="center_horizontal"
android:text="@string/search_cover"
android:textColor="?android:attr/textColorPrimary" />
@@ -17,7 +17,10 @@
android:id="@+id/comments"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?selectableItemBackground"
android:clickable="true"
android:divider="@drawable/spacer_keyline"
android:focusable="true"
android:orientation="vertical"
android:padding="@dimen/keyline_margin"
android:showDividers="middle">
@@ -29,12 +29,8 @@
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="?attr/galleryDetailHeaderBackgroundColor" />
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="@drawable/shadow_bottom" />
android:background="?attr/galleryDetailHeaderBackgroundColor"
android:elevation="4dp" />
<Space
android:layout_width="match_parent"
@@ -49,7 +45,8 @@
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:background="@android:color/transparent">
<com.hippo.widget.LoadImageView
android:id="@+id/thumb"
@@ -109,6 +106,9 @@
android:layout_height="56dp"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:background="?selectableItemBackgroundBorderless"
android:clickable="true"
android:focusable="true"
android:paddingLeft="12dp"
android:paddingTop="16dp"
android:paddingRight="12dp"
@@ -137,6 +137,9 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="?selectableItemBackgroundBorderless"
android:clickable="true"
android:focusable="true"
android:textColor="?attr/textColorThemePrimary" />
<View
@@ -152,6 +155,9 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="?selectableItemBackgroundBorderless"
android:clickable="true"
android:focusable="true"
android:text="@string/read"
android:textColor="?attr/textColorThemeAccent" />
@@ -18,6 +18,9 @@
android:id="@+id/info"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?selectableItemBackground"
android:clickable="true"
android:focusable="true"
android:orientation="vertical"
android:padding="@dimen/keyline_margin">
@@ -18,7 +18,10 @@
android:id="@+id/previews"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?selectableItemBackground"
android:clickable="true"
android:divider="@drawable/spacer_keyline"
android:focusable="true"
android:orientation="vertical"
android:padding="@dimen/keyline_margin"
android:showDividers="middle">
@@ -88,6 +88,9 @@
android:id="@+id/start"
android:layout_width="40dp"
android:layout_height="40dp"
android:background="?selectableItemBackgroundBorderless"
android:clickable="true"
android:focusable="true"
android:padding="8dp"
app:srcCompat="@drawable/v_play_x24" />
@@ -95,6 +98,9 @@
android:id="@+id/stop"
android:layout_width="40dp"
android:layout_height="40dp"
android:background="?selectableItemBackgroundBorderless"
android:clickable="true"
android:focusable="true"
android:padding="8dp"
app:srcCompat="@drawable/v_pause_x24" />
@@ -14,7 +14,7 @@
~ limitations under the License.
-->
<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
style="@style/CardView.Normal"
android:layout_width="match_parent"
@@ -46,4 +46,4 @@
android:textStyle="bold"
tools:ignore="SpUsage" />
</com.google.android.material.card.MaterialCardView>
</androidx.cardview.widget.CardView>
@@ -13,7 +13,7 @@
~ limitations under the License.
-->
<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
style="@style/CardView.Reactive"
android:layout_width="match_parent"
@@ -124,4 +124,4 @@
</LinearLayout>
</RelativeLayout>
</com.google.android.material.card.MaterialCardView>
</androidx.cardview.widget.CardView>
@@ -44,15 +44,11 @@
android:orientation="vertical"
android:visibility="invisible">
<View
android:layout_width="match_parent"
android:layout_height="4dp"
android:background="@drawable/shadow_top" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/contentColorThemePrimary"
android:elevation="4dp"
android:orientation="horizontal">
<EditText
@@ -29,6 +29,9 @@
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_gravity="left|center_vertical"
android:background="?selectableItemBackgroundBorderless"
android:clickable="true"
android:focusable="true"
android:padding="12dp" />
<TextView
@@ -48,6 +51,9 @@
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_gravity="right|center_vertical"
android:background="?selectableItemBackgroundBorderless"
android:clickable="true"
android:focusable="true"
android:padding="12dp" />
<com.hippo.ehviewer.widget.SearchEditText
+1 -1
View File
@@ -1 +1 @@
include ':app', ':daogenerator'
include ':app', ':daogenerator'