Remove unused code

This commit is contained in:
NekoInverter committed 2020-03-25 18:46:42 +08:00
1 parent 952d621f37
commit f7b37551fd
37 files changed
+49 -1845

No files matched your search

+4 -7
View File
@@ -48,7 +48,8 @@ android {
buildTypes {
release {
minifyEnabled false
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
buildConfigField 'String', 'FILE_PROVIDER_AUTHORITY', '"com.hippo.ehviewer.fileprovider"'
signingConfig signingConfigs.release
@@ -67,12 +68,8 @@ android {
}
}
task copyNotice(type: Copy) {
finalizedBy ":daogenerator:executeDaoGenerator"
}
tasks.withType(JavaCompile) {
task -> task.dependsOn copyNotice
task -> task.dependsOn ":daogenerator:executeDaoGenerator"
}
dependencies {
@@ -81,7 +78,7 @@ dependencies {
implementation 'androidx.biometric:biometric:1.0.1'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'com.google.android.gms:play-services-oss-licenses:17.0.0'
implementation 'com.google.android.material:material:1.1.0'
implementation 'com.google.android.material:material:1.2.0-alpha05'
implementation 'com.getkeepsafe.relinker:relinker:1.4.1'
implementation 'com.github.amlcurran.showcaseview:library:5.4.3'
implementation 'com.github.seven332.a7zip:extract-lite:d4ddec5793'
+3
View File
@@ -15,3 +15,6 @@
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
-keepattributes SourceFile,LineNumberTable
-keep class com.hippo.** { *; }
-4
View File
@@ -44,10 +44,6 @@
android:name="org.apache.http.legacy"
android:required="false" />
<meta-data
android:name="android.max_aspect"
android:value="2.1" />
<activity
android:name="com.hippo.ehviewer.ui.MainActivity"
android:configChanges="screenSize|uiMode"
@@ -1,568 +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.app;
import android.annotation.SuppressLint;
import android.content.Intent;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.Build;
import android.os.Bundle;
import android.preference.PreferenceActivity;
import android.util.DisplayMetrics;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import androidx.annotation.CallSuper;
import androidx.annotation.IdRes;
import androidx.annotation.LayoutRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.StyleRes;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.ActionBarDrawerToggle;
import androidx.appcompat.app.AppCompatCallback;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.appcompat.view.ActionMode;
import androidx.appcompat.widget.Toolbar;
import androidx.appcompat.widget.VectorEnabledTintResources;
import androidx.core.app.ActivityCompat;
import androidx.core.app.NavUtils;
import androidx.core.app.TaskStackBuilder;
public abstract class AppCompatPreferenceActivity extends PreferenceActivity implements AppCompatCallback,
TaskStackBuilder.SupportParentable, ActionBarDrawerToggle.DelegateProvider {
private AppCompatDelegate mDelegate;
private int mThemeId = 0;
private Resources mResources;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
final AppCompatDelegate delegate = getDelegate();
delegate.installViewFactory();
delegate.onCreate(savedInstanceState);
if (delegate.applyDayNight() && mThemeId != 0) {
// If DayNight has been applied, we need to re-apply the theme for
// the changes to take effect. On API 23+, we should bypass
// setTheme(), which will no-op if the theme ID is identical to the
// current theme ID.
if (Build.VERSION.SDK_INT >= 23) {
onApplyThemeResource(getTheme(), mThemeId, false);
} else {
setTheme(mThemeId);
}
}
super.onCreate(savedInstanceState);
}
@Override
public void setTheme(@StyleRes final int resid) {
super.setTheme(resid);
// Keep hold of the theme id so that we can re-set it later if needed
mThemeId = resid;
}
@Override
protected void onPostCreate(@Nullable Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
getDelegate().onPostCreate(savedInstanceState);
}
/**
* Support library version of {@link android.app.Activity#getActionBar}.
*
* <p>Retrieve a reference to this activity's ActionBar.
*
* @return The Activity's ActionBar, or null if it does not have one.
*/
@Nullable
public ActionBar getSupportActionBar() {
return getDelegate().getSupportActionBar();
}
/**
* Set a {@link android.widget.Toolbar Toolbar} to act as the
* {@link androidx.appcompat.app.ActionBar} for this Activity window.
*
* <p>When set to a non-null value the {@link #getActionBar()} method will return
* an {@link androidx.appcompat.app.ActionBar} object that can be used to control the given
* toolbar as if it were a traditional window decor action bar. The toolbar's menu will be
* populated with the Activity's options menu and the navigation button will be wired through
* the standard {@link android.R.id#home home} menu select action.</p>
*
* <p>In order to use a Toolbar within the Activity's window content the application
* must not request the window feature
* {@link android.view.Window#FEATURE_ACTION_BAR FEATURE_SUPPORT_ACTION_BAR}.</p>
*
* @param toolbar Toolbar to set as the Activity's action bar, or {@code null} to clear it
*/
public void setSupportActionBar(@Nullable Toolbar toolbar) {
getDelegate().setSupportActionBar(toolbar);
}
@Override
public MenuInflater getMenuInflater() {
return getDelegate().getMenuInflater();
}
@Override
public void setContentView(@LayoutRes int layoutResID) {
getDelegate().setContentView(layoutResID);
}
@Override
public void setContentView(View view) {
getDelegate().setContentView(view);
}
@Override
public void setContentView(View view, ViewGroup.LayoutParams params) {
getDelegate().setContentView(view, params);
}
@Override
public void addContentView(View view, ViewGroup.LayoutParams params) {
getDelegate().addContentView(view, params);
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
getDelegate().onConfigurationChanged(newConfig);
if (mResources != null) {
// The real (and thus managed) resources object was already updated
// by ResourcesManager, so pull the current metrics from there.
final DisplayMetrics newMetrics = super.getResources().getDisplayMetrics();
mResources.updateConfiguration(newConfig, newMetrics);
}
}
@Override
protected void onPostResume() {
super.onPostResume();
getDelegate().onPostResume();
}
@Override
protected void onStart() {
super.onStart();
getDelegate().onStart();
}
@Override
protected void onStop() {
super.onStop();
getDelegate().onStop();
}
@SuppressWarnings("TypeParameterUnusedInFormals")
@Override
public <T extends View> T findViewById(@IdRes int id) {
return getDelegate().findViewById(id);
}
@Override
public final boolean onMenuItemSelected(int featureId, android.view.MenuItem item) {
if (super.onMenuItemSelected(featureId, item)) {
return true;
}
final ActionBar ab = getSupportActionBar();
if (item.getItemId() == android.R.id.home && ab != null &&
(ab.getDisplayOptions() & ActionBar.DISPLAY_HOME_AS_UP) != 0) {
return onSupportNavigateUp();
}
return false;
}
@Override
protected void onDestroy() {
super.onDestroy();
getDelegate().onDestroy();
}
@Override
protected void onTitleChanged(CharSequence title, int color) {
super.onTitleChanged(title, color);
getDelegate().setTitle(title);
}
/**
* Enable extended support library window features.
* <p>
* This is a convenience for calling
* {@link android.view.Window#requestFeature getWindow().requestFeature()}.
* </p>
*
* @param featureId The desired feature as defined in
* {@link android.view.Window} or {@link androidx.core.view.WindowCompat}.
* @return Returns true if the requested feature is supported and now enabled.
* @see android.app.Activity#requestWindowFeature
* @see android.view.Window#requestFeature
*/
public boolean supportRequestWindowFeature(int featureId) {
return getDelegate().requestWindowFeature(featureId);
}
public void supportInvalidateOptionsMenu() {
getDelegate().invalidateOptionsMenu();
}
@Override
public void invalidateOptionsMenu() {
getDelegate().invalidateOptionsMenu();
}
/**
* Notifies the Activity that a support action mode has been started.
* Activity subclasses overriding this method should call the superclass implementation.
*
* @param mode The new action mode.
*/
@Override
@CallSuper
public void onSupportActionModeStarted(@NonNull ActionMode mode) {
}
/**
* Notifies the activity that a support action mode has finished.
* Activity subclasses overriding this method should call the superclass implementation.
*
* @param mode The action mode that just finished.
*/
@Override
@CallSuper
public void onSupportActionModeFinished(@NonNull ActionMode mode) {
}
/**
* Called when a support action mode is being started for this window. Gives the
* callback an opportunity to handle the action mode in its own unique and
* beautiful way. If this method returns null the system can choose a way
* to present the mode or choose not to start the mode at all.
*
* @param callback Callback to control the lifecycle of this action mode
* @return The ActionMode that was started, or null if the system should present it
*/
@Nullable
@Override
public ActionMode onWindowStartingSupportActionMode(@NonNull ActionMode.Callback callback) {
return null;
}
/**
* Start an action mode.
*
* @param callback Callback that will manage lifecycle events for this context mode
* @return The ContextMode that was started, or null if it was canceled
*/
@Nullable
public ActionMode startSupportActionMode(@NonNull ActionMode.Callback callback) {
return getDelegate().startSupportActionMode(callback);
}
/**
* @deprecated Progress bars are no longer provided in AppCompat.
*/
@Deprecated
public void setSupportProgressBarVisibility(boolean visible) {
}
/**
* @deprecated Progress bars are no longer provided in AppCompat.
*/
@Deprecated
public void setSupportProgressBarIndeterminateVisibility(boolean visible) {
}
/**
* @deprecated Progress bars are no longer provided in AppCompat.
*/
@Deprecated
public void setSupportProgressBarIndeterminate(boolean indeterminate) {
}
/**
* @deprecated Progress bars are no longer provided in AppCompat.
*/
@Deprecated
public void setSupportProgress(int progress) {
}
/**
* Support version of {@link #onCreateNavigateUpTaskStack(android.app.TaskStackBuilder)}.
* This method will be called on all platform versions.
* <p>
* Define the synthetic task stack that will be generated during Up navigation from
* a different task.
*
* <p>The default implementation of this method adds the parent chain of this activity
* as specified in the manifest to the supplied {@link androidx.core.app.TaskStackBuilder}. Applications
* may choose to override this method to construct the desired task stack in a different
* way.</p>
*
* <p>This method will be invoked by the default implementation of {@link #onNavigateUp()}
* if {@link #shouldUpRecreateTask(android.content.Intent)} returns true when supplied with the intent
* returned by {@link #getParentActivityIntent()}.</p>
*
* <p>Applications that wish to supply extra Intent parameters to the parent stack defined
* by the manifest should override
* {@link #onPrepareSupportNavigateUpTaskStack(androidx.core.app.TaskStackBuilder)}.</p>
*
* @param builder An empty TaskStackBuilder - the application should add intents representing
* the desired task stack
*/
public void onCreateSupportNavigateUpTaskStack(@NonNull TaskStackBuilder builder) {
builder.addParentStack(this);
}
/**
* Support version of {@link #onPrepareNavigateUpTaskStack(android.app.TaskStackBuilder)}.
* This method will be called on all platform versions.
* <p>
* Prepare the synthetic task stack that will be generated during Up navigation
* from a different task.
*
* <p>This method receives the {@link androidx.core.app.TaskStackBuilder} with the constructed series of
* Intents as generated by {@link #onCreateSupportNavigateUpTaskStack(androidx.core.app.TaskStackBuilder)}.
* If any extra data should be added to these intents before launching the new task,
* the application should override this method and add that data here.</p>
*
* @param builder A TaskStackBuilder that has been populated with Intents by
* onCreateNavigateUpTaskStack.
*/
public void onPrepareSupportNavigateUpTaskStack(@NonNull TaskStackBuilder builder) {
}
/**
* This method is called whenever the user chooses to navigate Up within your application's
* activity hierarchy from the action bar.
*
* <p>If a parent was specified in the manifest for this activity or an activity-alias to it,
* default Up navigation will be handled automatically. See
* {@link #getSupportParentActivityIntent()} for how to specify the parent. If any activity
* along the parent chain requires extra Intent arguments, the Activity subclass
* should override the method {@link #onPrepareSupportNavigateUpTaskStack(androidx.core.app.TaskStackBuilder)}
* to supply those arguments.</p>
*
* <p>See <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and
* Back Stack</a> from the developer guide and
* <a href="{@docRoot}design/patterns/navigation.html">Navigation</a> from the design guide
* for more information about navigating within your app.</p>
*
* <p>See the {@link androidx.core.app.TaskStackBuilder} class and the Activity methods
* {@link #getSupportParentActivityIntent()}, {@link #supportShouldUpRecreateTask(android.content.Intent)}, and
* {@link #supportNavigateUpTo(android.content.Intent)} for help implementing custom Up navigation.</p>
*
* @return true if Up navigation completed successfully and this Activity was finished,
* false otherwise.
*/
public boolean onSupportNavigateUp() {
Intent upIntent = getSupportParentActivityIntent();
if (upIntent != null) {
if (supportShouldUpRecreateTask(upIntent)) {
TaskStackBuilder b = TaskStackBuilder.create(this);
onCreateSupportNavigateUpTaskStack(b);
onPrepareSupportNavigateUpTaskStack(b);
b.startActivities();
try {
ActivityCompat.finishAffinity(this);
} catch (IllegalStateException e) {
// This can only happen on 4.1+, when we don't have a parent or a result set.
// In that case we should just finish().
finish();
}
} else {
// This activity is part of the application's task, so simply
// navigate up to the hierarchical parent activity.
supportNavigateUpTo(upIntent);
}
return true;
}
return false;
}
/**
* Obtain an {@link android.content.Intent} that will launch an explicit target activity
* specified by sourceActivity's {@link androidx.core.app.NavUtils#PARENT_ACTIVITY} &lt;meta-data&gt;
* element in the application's manifest. If the device is running
* Jellybean or newer, the android:parentActivityName attribute will be preferred
* if it is present.
*
* @return a new Intent targeting the defined parent activity of sourceActivity
*/
@Nullable
@Override
public Intent getSupportParentActivityIntent() {
return NavUtils.getParentActivityIntent(this);
}
/**
* Returns true if sourceActivity should recreate the task when navigating 'up'
* by using targetIntent.
*
* <p>If this method returns false the app can trivially call
* {@link #supportNavigateUpTo(android.content.Intent)} using the same parameters to correctly perform
* up navigation. If this method returns false, the app should synthesize a new task stack
* by using {@link androidx.core.app.TaskStackBuilder} or another similar mechanism to perform up navigation.</p>
*
* @param targetIntent An intent representing the target destination for up navigation
* @return true if navigating up should recreate a new task stack, false if the same task
* should be used for the destination
*/
public boolean supportShouldUpRecreateTask(@NonNull Intent targetIntent) {
return NavUtils.shouldUpRecreateTask(this, targetIntent);
}
/**
* Navigate from sourceActivity to the activity specified by upIntent, finishing sourceActivity
* in the process. upIntent will have the flag {@link android.content.Intent#FLAG_ACTIVITY_CLEAR_TOP} set
* by this method, along with any others required for proper up navigation as outlined
* in the Android Design Guide.
*
* <p>This method should be used when performing up navigation from within the same task
* as the destination. If up navigation should cross tasks in some cases, see
* {@link #supportShouldUpRecreateTask(android.content.Intent)}.</p>
*
* @param upIntent An intent representing the target destination for up navigation
*/
public void supportNavigateUpTo(@NonNull Intent upIntent) {
NavUtils.navigateUpTo(this, upIntent);
}
@Nullable
@Override
public ActionBarDrawerToggle.Delegate getDrawerToggleDelegate() {
return getDelegate().getDrawerToggleDelegate();
}
/**
* {@inheritDoc}
*
* <p>Please note: AppCompat uses its own feature id for the action bar:
* {@link AppCompatDelegate#FEATURE_SUPPORT_ACTION_BAR FEATURE_SUPPORT_ACTION_BAR}.</p>
*/
@Override
public boolean onMenuOpened(int featureId, Menu menu) {
return super.onMenuOpened(featureId, menu);
}
/**
* {@inheritDoc}
*
* <p>Please note: AppCompat uses its own feature id for the action bar:
* {@link AppCompatDelegate#FEATURE_SUPPORT_ACTION_BAR FEATURE_SUPPORT_ACTION_BAR}.</p>
*/
@Override
public void onPanelClosed(int featureId, Menu menu) {
super.onPanelClosed(featureId, menu);
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
getDelegate().onSaveInstanceState(outState);
}
/**
* @return The {@link AppCompatDelegate} being used by this Activity.
*/
@NonNull
public AppCompatDelegate getDelegate() {
if (mDelegate == null) {
mDelegate = AppCompatDelegate.create(this, this);
}
return mDelegate;
}
@SuppressLint("RestrictedApi")
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
// Let support action bars open menus in response to the menu key prioritized over
// the window handling it
final int keyCode = event.getKeyCode();
final ActionBar actionBar = getSupportActionBar();
if (keyCode == KeyEvent.KEYCODE_MENU
&& actionBar != null && actionBar.onMenuKeyEvent(event)) {
return true;
}
return super.dispatchKeyEvent(event);
}
@SuppressLint("RestrictedApi")
@Override
public Resources getResources() {
if (mResources == null && VectorEnabledTintResources.shouldBeUsed()) {
mResources = new VectorEnabledTintResources(this, super.getResources());
}
return mResources == null ? super.getResources() : mResources;
}
/**
* KeyEvents with non-default modifiers are not dispatched to menu's performShortcut in API 25
* or lower. Here, we check if the keypress corresponds to a menuitem's shortcut combination
* and perform the corresponding action.
*/
private boolean performMenuItemShortcut(int keycode, KeyEvent event) {
if (!(Build.VERSION.SDK_INT >= 26) && !event.isCtrlPressed()
&& !KeyEvent.metaStateHasNoModifiers(event.getMetaState())
&& event.getRepeatCount() == 0
&& !KeyEvent.isModifierKey(event.getKeyCode())) {
final Window currentWindow = getWindow();
if (currentWindow != null && currentWindow.getDecorView() != null) {
final View decorView = currentWindow.getDecorView();
return decorView.dispatchKeyShortcutEvent(event);
}
}
return false;
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (performMenuItemShortcut(keyCode, event)) {
return true;
}
return super.onKeyDown(keyCode, event);
}
@SuppressLint("RestrictedApi")
@Override
public void openOptionsMenu() {
ActionBar actionBar = getSupportActionBar();
if (getWindow().hasFeature(Window.FEATURE_OPTIONS_PANEL)
&& (actionBar == null || !actionBar.openOptionsMenu())) {
super.openOptionsMenu();
}
}
@SuppressLint("RestrictedApi")
@Override
public void closeOptionsMenu() {
ActionBar actionBar = getSupportActionBar();
if (getWindow().hasFeature(Window.FEATURE_OPTIONS_PANEL)
&& (actionBar == null || !actionBar.closeOptionsMenu())) {
super.closeOptionsMenu();
}
}
}
@@ -1,357 +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.app;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.style.StyleSpan;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ProgressBar;
import android.widget.TextView;
import androidx.appcompat.app.AlertDialog;
import com.hippo.ehviewer.R;
import java.text.NumberFormat;
/**
* <p>A dialog showing a progress indicator and an optional text message or view.
* Only a text message or a view can be used at the same time.</p>
* <p>The dialog can be made cancelable on back key press.</p>
* <p>The progress range is 0..10000.</p>
*/
public class ProgressDialog extends AlertDialog {
/**
* Creates a ProgressDialog with a circular, spinning progress
* bar. This is the default.
*/
public static final int STYLE_SPINNER = 0;
/**
* Creates a ProgressDialog with a horizontal progress bar.
*/
public static final int STYLE_HORIZONTAL = 1;
private ProgressBar mProgress;
private TextView mMessageView;
private int mProgressStyle = STYLE_SPINNER;
private TextView mProgressNumber;
private String mProgressNumberFormat;
private TextView mProgressPercent;
private NumberFormat mProgressPercentFormat;
private int mMax;
private int mProgressVal;
private int mSecondaryProgressVal;
private int mIncrementBy;
private int mIncrementSecondaryBy;
private Drawable mProgressDrawable;
private Drawable mIndeterminateDrawable;
private CharSequence mMessage;
private boolean mIndeterminate;
private boolean mHasStarted;
private Handler mViewUpdateHandler;
public ProgressDialog(Context context) {
super(context);
initFormats();
}
public ProgressDialog(Context context, int theme) {
super(context, theme);
initFormats();
}
public static ProgressDialog show(Context context, CharSequence title,
CharSequence message) {
return show(context, title, message, false);
}
public static ProgressDialog show(Context context, CharSequence title,
CharSequence message, boolean indeterminate) {
return show(context, title, message, indeterminate, false, null);
}
public static ProgressDialog show(Context context, CharSequence title,
CharSequence message, boolean indeterminate, boolean cancelable) {
return show(context, title, message, indeterminate, cancelable, null);
}
public static ProgressDialog show(Context context, CharSequence title,
CharSequence message, boolean indeterminate,
boolean cancelable, OnCancelListener cancelListener) {
ProgressDialog dialog = new ProgressDialog(context);
dialog.setTitle(title);
dialog.setMessage(message);
dialog.setIndeterminate(indeterminate);
dialog.setCancelable(cancelable);
dialog.setOnCancelListener(cancelListener);
dialog.show();
return dialog;
}
private void initFormats() {
mProgressNumberFormat = "%1d/%2d";
mProgressPercentFormat = NumberFormat.getPercentInstance();
mProgressPercentFormat.setMaximumFractionDigits(0);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
LayoutInflater inflater = LayoutInflater.from(getContext());
if (mProgressStyle == STYLE_HORIZONTAL) {
/* Use a separate handler to update the text views as they
* must be updated on the same thread that created them.
*/
mViewUpdateHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
/* Update the number and percent */
int progress = mProgress.getProgress();
int max = mProgress.getMax();
if (mProgressNumberFormat != null) {
String format = mProgressNumberFormat;
mProgressNumber.setText(String.format(format, progress, max));
} else {
mProgressNumber.setText("");
}
if (mProgressPercentFormat != null) {
double percent = (double) progress / (double) max;
SpannableString tmp = new SpannableString(mProgressPercentFormat.format(percent));
tmp.setSpan(new StyleSpan(android.graphics.Typeface.BOLD),
0, tmp.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
mProgressPercent.setText(tmp);
} else {
mProgressPercent.setText("");
}
}
};
View view = inflater.inflate(R.layout.alert_dialog_progress_material, null);
mProgress = view.findViewById(R.id.progress);
mProgressNumber = view.findViewById(R.id.progress_number);
mProgressPercent = view.findViewById(R.id.progress_percent);
setView(view);
} else {
View view = inflater.inflate(R.layout.progress_dialog_material, null);
mProgress = view.findViewById(R.id.progress);
mMessageView = view.findViewById(R.id.message);
setView(view);
}
if (mMax > 0) {
setMax(mMax);
}
if (mProgressVal > 0) {
setProgress(mProgressVal);
}
if (mSecondaryProgressVal > 0) {
setSecondaryProgress(mSecondaryProgressVal);
}
if (mIncrementBy > 0) {
incrementProgressBy(mIncrementBy);
}
if (mIncrementSecondaryBy > 0) {
incrementSecondaryProgressBy(mIncrementSecondaryBy);
}
if (mProgressDrawable != null) {
setProgressDrawable(mProgressDrawable);
}
if (mIndeterminateDrawable != null) {
setIndeterminateDrawable(mIndeterminateDrawable);
}
if (mMessage != null) {
setMessage(mMessage);
}
setIndeterminate(mIndeterminate);
onProgressChanged();
super.onCreate(savedInstanceState);
}
@Override
public void onStart() {
super.onStart();
mHasStarted = true;
}
@Override
protected void onStop() {
super.onStop();
mHasStarted = false;
}
public int getProgress() {
if (mProgress != null) {
return mProgress.getProgress();
}
return mProgressVal;
}
public void setProgress(int value) {
if (mHasStarted) {
mProgress.setProgress(value);
onProgressChanged();
} else {
mProgressVal = value;
}
}
public int getSecondaryProgress() {
if (mProgress != null) {
return mProgress.getSecondaryProgress();
}
return mSecondaryProgressVal;
}
public void setSecondaryProgress(int secondaryProgress) {
if (mProgress != null) {
mProgress.setSecondaryProgress(secondaryProgress);
onProgressChanged();
} else {
mSecondaryProgressVal = secondaryProgress;
}
}
public int getMax() {
if (mProgress != null) {
return mProgress.getMax();
}
return mMax;
}
public void setMax(int max) {
if (mProgress != null) {
mProgress.setMax(max);
onProgressChanged();
} else {
mMax = max;
}
}
public void incrementProgressBy(int diff) {
if (mProgress != null) {
mProgress.incrementProgressBy(diff);
onProgressChanged();
} else {
mIncrementBy += diff;
}
}
public void incrementSecondaryProgressBy(int diff) {
if (mProgress != null) {
mProgress.incrementSecondaryProgressBy(diff);
onProgressChanged();
} else {
mIncrementSecondaryBy += diff;
}
}
public void setProgressDrawable(Drawable d) {
if (mProgress != null) {
mProgress.setProgressDrawable(d);
} else {
mProgressDrawable = d;
}
}
public void setIndeterminateDrawable(Drawable d) {
if (mProgress != null) {
mProgress.setIndeterminateDrawable(d);
} else {
mIndeterminateDrawable = d;
}
}
public boolean isIndeterminate() {
if (mProgress != null) {
return mProgress.isIndeterminate();
}
return mIndeterminate;
}
public void setIndeterminate(boolean indeterminate) {
if (mProgress != null) {
mProgress.setIndeterminate(indeterminate);
} else {
mIndeterminate = indeterminate;
}
}
@Override
public void setMessage(CharSequence message) {
if (mProgress != null) {
if (mProgressStyle == STYLE_HORIZONTAL) {
super.setMessage(message);
} else {
mMessageView.setText(message);
}
} else {
mMessage = message;
}
}
public void setProgressStyle(int style) {
mProgressStyle = style;
}
/**
* Change the format of the small text showing current and maximum units
* of progress. The default is "%1d/%2d".
* Should not be called during the number is progressing.
*
* @param format A string passed to {@link String#format String.format()};
* use "%1d" for the current number and "%2d" for the maximum. If null,
* nothing will be shown.
*/
public void setProgressNumberFormat(String format) {
mProgressNumberFormat = format;
onProgressChanged();
}
/**
* Change the format of the small text showing the percentage of progress.
* The default is
* {@link NumberFormat#getPercentInstance() NumberFormat.getPercentageInstnace().}
* Should not be called during the number is progressing.
*
* @param format An instance of a {@link NumberFormat} to generate the
* percentage text. If null, nothing will be shown.
*/
public void setProgressPercentFormat(NumberFormat format) {
mProgressPercentFormat = format;
onProgressChanged();
}
private void onProgressChanged() {
if (mProgressStyle == STYLE_HORIZONTAL) {
if (mViewUpdateHandler != null && !mViewUpdateHandler.hasMessages(0)) {
mViewUpdateHandler.sendEmptyMessage(0);
}
}
}
}
@@ -48,13 +48,10 @@ public class ContextLocalWrapper extends ContextWrapper {
context = context.createConfigurationContext(configuration);
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
} else {
configuration.setLocale(newLocale);
context = context.createConfigurationContext(configuration);
} else {
configuration.locale = newLocale;
res.updateConfiguration(configuration, res.getDisplayMetrics());
}
return new ContextLocalWrapper(context);
@@ -1,68 +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.drawable;
import android.graphics.Bitmap;
import android.util.Log;
import androidx.annotation.Nullable;
import java.lang.ref.WeakReference;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Set;
class BitmapPool {
private static final String TAG = BitmapPool.class.getSimpleName();
private final Set<WeakReference<Bitmap>> mReusableBitmapSet = new LinkedHashSet<>();
public synchronized void put(@Nullable Bitmap bitmap) {
if (bitmap != null) {
mReusableBitmapSet.add(new WeakReference<>(bitmap));
}
}
@Nullable
public synchronized Bitmap get(int width, int height) {
final Iterator<WeakReference<Bitmap>> iterator = mReusableBitmapSet.iterator();
Bitmap item;
while (iterator.hasNext()) {
item = iterator.next().get();
if (item != null) {
if (item.getWidth() == width && item.getHeight() == height) {
// Remove from reusable set so it can't be used again.
iterator.remove();
return item;
}
} else {
// Remove from the set if the reference has been cleared or
// it can't be used.
iterator.remove();
}
}
// Can not find reusable bitmap
try {
return Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
} catch (OutOfMemoryError e) {
Log.e(TAG, "Out of memory");
return null;
}
}
}
@@ -1,68 +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.drawable;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.Paint;
import android.graphics.PixelFormat;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.drawable.Drawable;
public class RoundDrawable extends Drawable {
private final Paint mPaint;
private final RectF mRectF;
public RoundDrawable(int color) {
mPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG);
mPaint.setColor(color);
mRectF = new RectF();
}
public void setColor(int color) {
mPaint.setColor(color);
invalidateSelf();
}
@Override
protected void onBoundsChange(Rect bounds) {
super.onBoundsChange(bounds);
mRectF.set(bounds);
}
@Override
public void draw(Canvas canvas) {
canvas.drawOval(mRectF, mPaint);
}
@Override
public void setAlpha(int alpha) {
mPaint.setAlpha(alpha);
}
@Override
public void setColorFilter(ColorFilter colorFilter) {
mPaint.setColorFilter(colorFilter);
}
@Override
public int getOpacity() {
return PixelFormat.OPAQUE;
}
}
@@ -1,76 +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.preference;
import android.content.Context;
import android.util.AttributeSet;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import com.hippo.ehviewer.R;
import com.hippo.ehviewer.Settings;
import com.hippo.ehviewer.widget.CategoryTable;
import com.hippo.preference.DialogPreference;
import com.hippo.yorozuya.ViewUtils;
public class DefaultCategoryPreference extends DialogPreference {
@Nullable
private CategoryTable mCategoryTable;
public DefaultCategoryPreference(Context context) {
super(context);
init();
}
public DefaultCategoryPreference(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
public DefaultCategoryPreference(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init();
}
private void init() {
setDialogLayoutResource(R.layout.preference_dialog_default_categories);
}
@Override
protected void onPrepareDialogBuilder(AlertDialog.Builder builder) {
super.onPrepareDialogBuilder(builder);
builder.setPositiveButton(android.R.string.ok, this);
}
@Override
protected void onDialogCreated(AlertDialog dialog) {
super.onDialogCreated(dialog);
mCategoryTable = (CategoryTable) ViewUtils.$$(dialog, R.id.category_table);
mCategoryTable.setCategory(Settings.getDefaultCategories());
}
@Override
protected void onDialogClosed(boolean positiveResult) {
super.onDialogClosed(positiveResult);
if (null != mCategoryTable && positiveResult) {
Settings.putDefaultCategories(mCategoryTable.getCategory());
}
mCategoryTable = null;
}
}
@@ -1,114 +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.preference;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.CheckBox;
import androidx.appcompat.app.AlertDialog;
import com.hippo.ehviewer.R;
import com.hippo.ehviewer.Settings;
import com.hippo.preference.DialogPreference;
import com.hippo.yorozuya.NumberUtils;
import com.hippo.yorozuya.ViewUtils;
public class ExcludedTagNamespacesPreference extends DialogPreference {
private static final int[] EXCLUDED_TAG_GROUP_RES_ID = {
R.id.tag_group_reclass,
R.id.tag_group_language,
R.id.tag_group_parody,
R.id.tag_group_character,
R.id.tag_group_group,
R.id.tag_group_artist,
R.id.tag_group_male,
R.id.tag_group_female,
};
private static final int[] EXCLUDED_TAG_GROUP_ID = {
0x1,
0x2,
0x4,
0x8,
0x10,
0x20,
0x40,
0x80
};
private View mTableLayout;
public ExcludedTagNamespacesPreference(Context context) {
super(context);
init();
}
public ExcludedTagNamespacesPreference(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
public ExcludedTagNamespacesPreference(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init();
}
private void init() {
setDialogLayoutResource(R.layout.preference_dialog_excluded_tag_namespaces);
}
@Override
protected void onPrepareDialogBuilder(AlertDialog.Builder builder) {
super.onPrepareDialogBuilder(builder);
builder.setPositiveButton(android.R.string.ok, this);
}
@Override
protected void onDialogCreated(AlertDialog dialog) {
super.onDialogCreated(dialog);
mTableLayout = ViewUtils.$$(dialog, R.id.table_layout);
setExcludedTagNamespaces(mTableLayout, Settings.getExcludedTagNamespaces());
}
@Override
protected void onDialogClosed(boolean positiveResult) {
super.onDialogClosed(positiveResult);
if (null != mTableLayout && positiveResult) {
Settings.putExcludedTagNamespaces(getExcludedTagNamespaces(mTableLayout));
}
mTableLayout = null;
}
private void setExcludedTagNamespaces(View view, int value) {
for (int i = 0; i < EXCLUDED_TAG_GROUP_RES_ID.length; i++) {
CheckBox cb = view.findViewById(EXCLUDED_TAG_GROUP_RES_ID[i]);
cb.setChecked(NumberUtils.int2boolean(value & EXCLUDED_TAG_GROUP_ID[i]));
}
}
private int getExcludedTagNamespaces(View view) {
int newValue = 0;
for (int i = 0; i < EXCLUDED_TAG_GROUP_RES_ID.length; i++) {
CheckBox cb = view.findViewById(EXCLUDED_TAG_GROUP_RES_ID[i]);
if (cb.isChecked()) {
newValue |= EXCLUDED_TAG_GROUP_ID[i];
}
}
return newValue;
}
}
@@ -85,13 +85,8 @@ public abstract class EhActivity extends AppCompatActivity {
}
}
@StyleRes
protected abstract int getThemeResId(int theme);
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
setTheme(getThemeResId(Settings.getTheme()));
super.onCreate(savedInstanceState);
((EhApplication) getApplication()).registerActivity(this);
@@ -179,11 +179,6 @@ public class GalleryActivity extends EhActivity implements SeekBar.OnSeekBarChan
private int mSize;
private int mCurrentIndex;
@Override
protected int getThemeResId(int theme) {
return R.style.AppTheme_Gallery;
}
private void buildProvider() {
if (mGalleryProvider != null) {
return;
@@ -21,6 +21,7 @@ import android.content.ClipboardManager;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.net.ConnectivityManager;
import android.net.Uri;
@@ -138,11 +139,6 @@ public final class MainActivity extends StageActivity
private TextView mDisplayName;
private int mNavCheckedItem = 0;
@Override
protected int getThemeResId(int theme) {
return R.style.AppTheme_Main;
}
@Override
public int getContainerViewId() {
return R.id.fragment_container;
@@ -321,7 +317,7 @@ public final class MainActivity extends StageActivity
mAvatar = (LoadImageView) ViewUtils.$$(headerLayout, R.id.avatar);
mDisplayName = (TextView) ViewUtils.$$(headerLayout, R.id.display_name);
ViewUtils.$$(headerLayout, R.id.night_mode).setOnClickListener(v -> {
int theme = isNightMode(getResources().getConfiguration()) ? AppCompatDelegate.MODE_NIGHT_NO : AppCompatDelegate.MODE_NIGHT_YES;
int theme = (getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_YES) > 0 ? AppCompatDelegate.MODE_NIGHT_NO : AppCompatDelegate.MODE_NIGHT_YES;
AppCompatDelegate.setDefaultNightMode(theme);
((EhApplication) getApplication()).recreate();
Settings.putTheme(theme);
@@ -39,7 +39,6 @@ import okhttp3.HttpUrl;
public class MyTagsActivity extends ToolbarActivity {
private WebView webView;
private ProgressView progress;
private String url;
@@ -64,7 +63,7 @@ public class MyTagsActivity extends ToolbarActivity {
setContentView(R.layout.activity_my_tags);
setNavigationIcon(R.drawable.v_arrow_left_dark_x24);
webView = findViewById(R.id.webview);
WebView webView = findViewById(R.id.webview);
webView.getSettings().setJavaScriptEnabled(true);
webView.setWebViewClient(new MyTagsWebViewClient());
webView.setWebChromeClient(new DialogWebChromeClient(this));
@@ -16,39 +16,16 @@
package com.hippo.ehviewer.ui;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.MenuItem;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.ActionBarDrawerToggle;
import com.hippo.ehviewer.R;
import com.hippo.ehviewer.ui.fragment.SettingsFragment;
import com.hippo.util.DrawableManager;
public final class SettingsActivity extends EhActivity {
private static final int REQUEST_CODE_FRAGMENT = 0;
@Override
protected int getThemeResId(int theme) {
return R.style.AppTheme_Settings;
}
private void setActionBarUpIndicator(Drawable drawable) {
ActionBarDrawerToggle.Delegate delegate = getDrawerToggleDelegate();
if (delegate != null) {
delegate.setActionBarUpIndicator(drawable, 0);
}
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setHomeButtonEnabled(true);
}
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -63,7 +40,6 @@ public final class SettingsActivity extends EhActivity {
if (bar != null) {
bar.setDisplayHomeAsUpEnabled(true);
}
setActionBarUpIndicator(DrawableManager.getVectorDrawable(this, R.drawable.v_arrow_left_dark_x24));
}
@Override
@@ -76,15 +52,4 @@ public final class SettingsActivity extends EhActivity {
return super.onOptionsItemSelected(item);
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == REQUEST_CODE_FRAGMENT) {
if (resultCode == RESULT_OK) {
setResult(RESULT_OK);
}
} else {
super.onActivityResult(requestCode, resultCode, data);
}
}
}
@@ -29,11 +29,6 @@ import com.hippo.ehviewer.R;
public abstract class ToolbarActivity extends EhActivity {
@Override
protected int getThemeResId(int theme) {
return R.style.AppTheme_Toolbar;
}
@Override
public void setContentView(@LayoutRes int layoutResID) {
super.setContentView(R.layout.activity_toolbar);
@@ -72,7 +72,7 @@ public class AboutFragment extends PreferenceFragmentCompat
public boolean onPreferenceClick(Preference preference) {
String key = preference.getKey();
if (KEY_AUTHOR.equals(key)) {
AppHelper.sendEmail(getActivity(), EhApplication.getDeveloperEmail(),
AppHelper.sendEmail(requireActivity(), EhApplication.getDeveloperEmail(),
"About EhViewer", null);
} else if (KEY_DONATE.equals(key)) {
showDonationDialog();
@@ -22,6 +22,7 @@ import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.Resources;
import android.graphics.Color;
import android.graphics.Point;
import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
@@ -59,6 +60,7 @@ import com.hippo.android.resource.AttrResources;
import com.hippo.app.CheckBoxDialogBuilder;
import com.hippo.conaco.DataContainer;
import com.hippo.conaco.ProgressNotifier;
import com.hippo.drawable.DrawerArrowDrawable;
import com.hippo.easyrecyclerview.EasyRecyclerView;
import com.hippo.easyrecyclerview.FastScroller;
import com.hippo.easyrecyclerview.HandlerDrawable;
@@ -457,7 +459,7 @@ public class DownloadsScene extends ToolbarScene
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
updateTitle();
setNavigationIcon(R.drawable.v_arrow_left_dark_x24);
setNavigationIcon(new DrawerArrowDrawable(getContext2(), Color.WHITE));
}
@Override
@@ -485,7 +487,7 @@ public class DownloadsScene extends ToolbarScene
@Override
public void onNavigationClick() {
onBackPressed();
toggleDrawer(Gravity.LEFT);
}
@Override
@@ -20,8 +20,10 @@ import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.Resources;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
@@ -46,6 +48,7 @@ import com.h6ah4i.android.widget.advrecyclerview.swipeable.action.SwipeResultAct
import com.h6ah4i.android.widget.advrecyclerview.touchguard.RecyclerViewTouchActionGuardManager;
import com.h6ah4i.android.widget.advrecyclerview.utils.AbstractSwipeableItemViewHolder;
import com.hippo.android.resource.AttrResources;
import com.hippo.drawable.DrawerArrowDrawable;
import com.hippo.easyrecyclerview.EasyRecyclerView;
import com.hippo.easyrecyclerview.FastScroller;
import com.hippo.easyrecyclerview.HandlerDrawable;
@@ -240,7 +243,7 @@ public class HistoryScene extends ToolbarScene {
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
setTitle(R.string.history);
setNavigationIcon(R.drawable.v_arrow_left_dark_x24);
setNavigationIcon(new DrawerArrowDrawable(getContext2(), Color.WHITE));
}
@Override
@@ -286,7 +289,7 @@ public class HistoryScene extends ToolbarScene {
@Override
public void onNavigationClick() {
onBackPressed();
toggleDrawer(Gravity.LEFT);
}
@Override
@@ -21,9 +21,9 @@ import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.core.view.ViewCompat;
import androidx.drawerlayout.widget.DrawerLayout;
import com.google.android.material.snackbar.Snackbar;
@@ -33,8 +33,7 @@ import com.hippo.yorozuya.AnimationUtils;
import java.util.ArrayList;
import java.util.List;
@CoordinatorLayout.DefaultBehavior(EhDrawerLayout.Behavior.class)
public class EhDrawerLayout extends DrawerLayout {
public class EhDrawerLayout extends DrawerLayout implements CoordinatorLayout.AttachedBehavior {
private List<View> mAboveSnackViewList;
@@ -73,9 +72,13 @@ public class EhDrawerLayout extends DrawerLayout {
}
}
@NonNull
@Override
public CoordinatorLayout.Behavior getBehavior() {
return new Behavior();
}
public static class Behavior extends CoordinatorLayout.Behavior<EhDrawerLayout> {
// We only support the FAB <> Snackbar shift movement on Honeycomb and above. This is
// because we can use view translation properties which greatly simplifies the code.
@Override
public boolean layoutDependsOn(CoordinatorLayout parent,
@@ -90,7 +93,9 @@ public class EhDrawerLayout extends DrawerLayout {
if (dependency instanceof Snackbar.SnackbarLayout) {
for (int i = 0, n = child.getAboveSnackViewCount(); i < n; i++) {
View view = child.getAboveSnackViewAt(i);
updateChildTranslationForSnackbar(parent, child, view);
if (view != null) {
updateChildTranslationForSnackbar(parent, child, view);
}
}
}
return false;
@@ -119,7 +124,7 @@ public class EhDrawerLayout extends DrawerLayout {
fabTranslationYAnimator.cancel();
}
final float currentTransY = ViewCompat.getTranslationY(child);
final float currentTransY = child.getTranslationY();
if (child.isShown()
&& Math.abs(currentTransY - targetTransY) > (child.getHeight() * 0.667f)) {
@@ -132,7 +137,7 @@ public class EhDrawerLayout extends DrawerLayout {
new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
ViewCompat.setTranslationY(child, (Float) animation.getAnimatedValue());
child.setTranslationY((Float) animation.getAnimatedValue());
}
});
child.setTag(R.id.fab_translation_y_animator, fabTranslationYAnimator);
@@ -141,7 +146,7 @@ public class EhDrawerLayout extends DrawerLayout {
fabTranslationYAnimator.start();
} else {
// Now update the translation Y
ViewCompat.setTranslationY(child, targetTransY);
child.setTranslationY(targetTransY);
}
child.setTag(R.id.fab_translation_y, targetTransY);
@@ -155,7 +160,7 @@ public class EhDrawerLayout extends DrawerLayout {
final View view = dependencies.get(i);
if (view instanceof Snackbar.SnackbarLayout && parent.doViewsOverlap(child, view)) {
minOffset = Math.min(minOffset,
ViewCompat.getTranslationY(view) - view.getHeight());
view.getTranslationY() - view.getHeight());
}
}
@@ -1,40 +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.widget;
import android.content.Context;
import android.util.AttributeSet;
import com.hippo.widget.DrawerView;
public class EhDrawerView extends DrawerView {
private int mWindowPaddingTop;
private int mWindowPaddingBottom;
public EhDrawerView(Context context) {
super(context);
}
public EhDrawerView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public EhDrawerView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
}
@@ -1,41 +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.widget;
import android.content.Context;
import android.util.AttributeSet;
import com.hippo.scene.StageLayout;
public class EhStageLayout extends StageLayout {
private int mWindowPaddingTop;
private int mWindowPaddingBottom;
public EhStageLayout(Context context) {
super(context);
}
public EhStageLayout(Context context, AttributeSet attrs) {
super(context, attrs);
}
public EhStageLayout(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
}
@@ -22,7 +22,7 @@ public class ChromeRequestBuilder extends Request.Builder {
private static final String CHROME_USER_AGENT =
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) " +
"AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36";
"AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36";
private static final String CHROME_ACCEPT =
"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
@@ -1,182 +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.preference;
import android.content.Context;
import android.content.res.TypedArray;
import android.preference.TwoStatePreference;
import android.util.AttributeSet;
import android.view.View;
import android.widget.Checkable;
import android.widget.CompoundButton;
import androidx.annotation.StringRes;
import androidx.appcompat.widget.SwitchCompat;
import com.hippo.ehviewer.R;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
public class SwitchPreference extends TwoStatePreference {
private static Method sSyncSummaryViewMethod;
static {
try {
sSyncSummaryViewMethod = TwoStatePreference.class.getDeclaredMethod("syncSummaryView", View.class);
sSyncSummaryViewMethod.setAccessible(true);
} catch (NoSuchMethodException e) {
e.printStackTrace();
sSyncSummaryViewMethod = null;
}
}
private final Listener mListener = new Listener();
// Switch text for on and off states
private CharSequence mSwitchOn;
private CharSequence mSwitchOff;
public SwitchPreference(Context context) {
super(context);
init(context, null, 0, 0);
}
public SwitchPreference(Context context, AttributeSet attrs) {
super(context, attrs, android.R.attr.preferenceStyle);
init(context, attrs, 0, 0);
}
public SwitchPreference(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init(context, attrs, defStyleAttr, 0);
}
public void init(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
setWidgetLayoutResource(R.layout.preference_widget_fixed_switch);
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SwitchPreference, defStyleAttr, defStyleRes);
setSummaryOn(a.getString(R.styleable.SwitchPreference_summaryOn));
setSummaryOff(a.getString(R.styleable.SwitchPreference_summaryOff));
setSwitchTextOn(a.getString(R.styleable.SwitchPreference_switchTextOn));
setSwitchTextOff(a.getString(R.styleable.SwitchPreference_switchTextOff));
setDisableDependentsState(a.getBoolean(R.styleable.SwitchPreference_disableDependentsState, false));
a.recycle();
}
@SuppressWarnings("TryWithIdenticalCatches")
@Override
protected void onBindView(View view) {
super.onBindView(view);
View checkableView = view.findViewById(R.id.switchWidget);
if (checkableView != null && checkableView instanceof Checkable) {
if (checkableView instanceof SwitchCompat) {
final SwitchCompat switchView = (SwitchCompat) checkableView;
switchView.setOnCheckedChangeListener(null);
}
((Checkable) checkableView).setChecked(isChecked());
if (checkableView instanceof SwitchCompat) {
final SwitchCompat switchView = (SwitchCompat) checkableView;
switchView.setTextOn(mSwitchOn);
switchView.setTextOff(mSwitchOff);
switchView.setOnCheckedChangeListener(mListener);
}
}
if (sSyncSummaryViewMethod != null) {
try {
sSyncSummaryViewMethod.invoke(this, view);
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}
/**
* @return The text that will be displayed on the switch widget in the on state
*/
public CharSequence getSwitchTextOn() {
return mSwitchOn;
}
/**
* Set the text displayed on the switch widget in the on state.
* This should be a very short string; one word if possible.
*
* @param onText Text to display in the on state
*/
public void setSwitchTextOn(CharSequence onText) {
mSwitchOn = onText;
notifyChanged();
}
/**
* Set the text displayed on the switch widget in the on state.
* This should be a very short string; one word if possible.
*
* @param resId The text as a string resource ID
*/
public void setSwitchTextOn(@StringRes int resId) {
setSwitchTextOn(getContext().getString(resId));
}
/**
* @return The text that will be displayed on the switch widget in the off state
*/
public CharSequence getSwitchTextOff() {
return mSwitchOff;
}
/**
* Set the text displayed on the switch widget in the off state.
* This should be a very short string; one word if possible.
*
* @param offText Text to display in the off state
*/
public void setSwitchTextOff(CharSequence offText) {
mSwitchOff = offText;
notifyChanged();
}
/**
* Set the text displayed on the switch widget in the off state.
* This should be a very short string; one word if possible.
*
* @param resId The text as a string resource ID
*/
public void setSwitchTextOff(@StringRes int resId) {
setSwitchTextOff(getContext().getString(resId));
}
private class Listener implements CompoundButton.OnCheckedChangeListener {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (!callChangeListener(isChecked)) {
// Listener didn't like it, change it back.
// CompoundButton will make sure we don't recurse.
buttonView.setChecked(!isChecked);
return;
}
SwitchPreference.this.setChecked(isChecked);
}
}
}
@@ -1,24 +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.reveal;
public interface Reveal {
void setRevealEnable(boolean enable);
void setReveal(int centerX, int centerY, float radius);
}
@@ -1,78 +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.reveal;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Path;
import android.util.AttributeSet;
import android.widget.LinearLayout;
public class RevealLinearLayout extends LinearLayout implements Reveal {
private final Path mRevealPath = new Path();
private boolean mReveal;
private int mCenterX;
private int mCenterY;
private float mRadius;
public RevealLinearLayout(Context context) {
super(context);
}
public RevealLinearLayout(Context context, AttributeSet attrs) {
super(context, attrs);
}
public RevealLinearLayout(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
public void setRevealEnable(boolean enable) {
mReveal = enable;
invalidate();
}
@Override
public void setReveal(int centerX, int centerY, float radius) {
mCenterX = centerX;
mCenterY = centerY;
mRadius = radius;
invalidate();
}
@Override
public void draw(Canvas canvas) {
boolean reveal = mReveal;
int saveCount = 0;
if (reveal) {
saveCount = canvas.save();
Path path = mRevealPath;
path.reset();
path.addCircle(mCenterX, mCenterY, mRadius, Path.Direction.CW);
canvas.clipPath(path);
}
super.draw(canvas);
if (reveal) {
canvas.restoreToCount(saveCount);
}
}
}
@@ -1,78 +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.reveal;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Path;
import android.util.AttributeSet;
import android.view.View;
public class RevealView extends View implements Reveal {
private final Path mRevealPath = new Path();
private boolean mReveal;
private int mCenterX;
private int mCenterY;
private float mRadius;
public RevealView(Context context) {
super(context);
}
public RevealView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public RevealView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
public void setRevealEnable(boolean enable) {
mReveal = enable;
invalidate();
}
@Override
public void setReveal(int centerX, int centerY, float radius) {
mCenterX = centerX;
mCenterY = centerY;
mRadius = radius;
invalidate();
}
@Override
public void draw(Canvas canvas) {
boolean reveal = mReveal;
int saveCount = 0;
if (reveal) {
saveCount = canvas.save();
Path path = mRevealPath;
path.reset();
path.addCircle(mCenterX, mCenterY, mRadius, Path.Direction.CW);
canvas.clipPath(path);
}
super.draw(canvas);
if (reveal) {
canvas.restoreToCount(saveCount);
}
}
}
@@ -20,8 +20,6 @@ import android.animation.Animator;
import android.view.View;
public final class ViewAnimationUtils {
// http://developer.android.com/guide/topics/graphics/hardware-accel.html#unsupported
public static Animator createCircularReveal(View view,
int centerX, int centerY, float startRadius, float endRadius) {
return android.view.ViewAnimationUtils.createCircularReveal(
@@ -23,7 +23,6 @@ import android.content.Intent;
import android.content.IntentFilter;
import android.database.ContentObserver;
import android.net.Uri;
import android.os.Build;
import android.os.Handler;
import android.os.SystemClock;
import android.provider.Settings;
@@ -42,10 +41,7 @@ public class TextClock extends AppCompatTextView {
public static final CharSequence DEFAULT_FORMAT_24_HOUR;
static {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2)
DEFAULT_FORMAT_24_HOUR = "kk:mm";
else
DEFAULT_FORMAT_24_HOUR = "HH:mm";
DEFAULT_FORMAT_24_HOUR = "HH:mm";
}
private CharSequence mFormat12;
@@ -21,7 +21,7 @@
android:viewportHeight="24">
<path
android:fillColor="@color/secondary_drawable_dark"
android:fillColor="@color/primary_drawable_black"
android:pathData="@string/pd_dots_vertical" />
</vector>
+2 -2
View File
@@ -25,7 +25,7 @@
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<com.hippo.ehviewer.widget.EhStageLayout
<com.hippo.scene.StageLayout
android:id="@+id/fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
@@ -39,7 +39,7 @@
app:menu="@menu/nav_drawer_main" />
<com.hippo.ehviewer.widget.EhDrawerView
<com.hippo.widget.DrawerView
android:id="@+id/right_drawer"
android:layout_width="wrap_content"
android:layout_height="match_parent"
@@ -24,7 +24,7 @@
android:layout_height="match_parent"
android:orientation="vertical">
<com.hippo.reveal.RevealView
<View
android:id="@+id/color_bg"
android:layout_width="match_parent"
android:layout_height="0dp"
@@ -1,25 +0,0 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ 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.
-->
<!-- Layout used by SwitchPreference for the switch widget style. This is inflated
inside android.R.layout.preference. -->
<androidx.appcompat.widget.SwitchCompat xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/switchWidget"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:focusable="false"
android:padding="16dp" />
@@ -36,11 +36,12 @@
android:gravity="center_horizontal"
android:text="@string/no_one_comments_gallery" />
<com.hippo.reveal.RevealLinearLayout
<LinearLayout
android:id="@+id/edit_panel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="@android:color/transparent"
android:orientation="vertical"
android:visibility="invisible">
@@ -72,7 +73,7 @@
android:padding="16dp" />
</LinearLayout>
</com.hippo.reveal.RevealLinearLayout>
</LinearLayout>
<com.hippo.widget.FabLayout
android:id="@+id/fab_layout"
-20
View File
@@ -131,26 +131,6 @@
<attr name="dark" format="boolean" />
</declare-styleable>
<declare-styleable name="SwitchPreference">
<!-- The summary for the Preference in a PreferenceActivity screen when the
SwitchPreference is checked. If separate on/off summaries are not
needed, the summary attribute can be used instead. -->
<attr name="summaryOn" format="string" />
<!-- The summary for the Preference in a PreferenceActivity screen when the
SwitchPreference is unchecked. If separate on/off summaries are not
needed, the summary attribute can be used instead. -->
<attr name="summaryOff" format="string" />
<!-- The text used on the switch itself when in the "on" state.
This should be a very SHORT string, as it appears in a small space. -->
<attr name="switchTextOn" format="string" />
<!-- The text used on the switch itself when in the "off" state.
This should be a very SHORT string, as it appears in a small space. -->
<attr name="switchTextOff" format="string" />
<!-- The state (true for on, or false for off) that causes dependents to be disabled. By default,
dependents will be disabled when this is unchecked, so the value of this preference is false. -->
<attr name="disableDependentsState" format="boolean" />
</declare-styleable>
<declare-styleable name="BatteryView">
<attr name="color" />
<attr name="warningColor" format="color" />
+1 -1
View File
@@ -16,7 +16,7 @@
<resources>
<style name="ActionBarStyle" parent="@style/Widget.AppCompat.ActionBar.Solid">
<style name="ActionBarStyle" parent="@style/Widget.MaterialComponents.ActionBar.Solid">
<item name="background">?attr/toolbarColor</item>
</style>
+3 -3
View File
@@ -122,7 +122,7 @@
</item>
<item name="preferenceHeaderBackground">@drawable/preference_header_background_black</item>
<item name="toolbarPopupTheme">@style/ThemeOverlay.AppCompat.Dark</item>
<item name="toolbarPopupTheme">@style/ThemeOverlay.MaterialComponents.Dark</item>
<item name="galleryDetailDivider">@drawable/divider_gallery_detail_dark</item>
<item name="android:navigationBarColor">@android:color/black</item>
<item name="android:windowLightNavigationBar" tools:targetApi="o_mr1">false</item>
@@ -144,13 +144,13 @@
<!-- ============ -->
<!-- Widget Theme -->
<!-- ============ -->
<style name="CommentEditText" parent="ThemeOverlay.AppCompat">
<style name="CommentEditText" parent="ThemeOverlay.MaterialComponents">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@android:color/white</item>
</style>
<style name="RatingBarTheme" parent="ThemeOverlay.AppCompat">
<style name="RatingBarTheme" parent="ThemeOverlay.MaterialComponents">
<item name="colorControlNormal">@color/yellow_800</item>
<item name="colorControlActivated">@color/yellow_800</item>
</style>