From f7b37551fde449181a01b894b2c7f672872c1838 Mon Sep 17 00:00:00 2001 From: NekoInverter <42698724+NekoInverter@users.noreply.github.com> Date: Wed, 25 Mar 2020 18:41:23 +0800 Subject: [PATCH] Remove unused code --- app/build.gradle | 11 +- app/proguard-rules.pro | 3 + app/src/main/AndroidManifest.xml | 4 - .../app/AppCompatPreferenceActivity.java | 568 ------------------ .../java/com/hippo/app/ProgressDialog.java | 357 ----------- .../hippo/content/ContextLocalWrapper.java | 5 +- .../java/com/hippo/drawable/BitmapPool.java | 68 --- .../com/hippo/drawable/RoundDrawable.java | 68 --- .../preference/DefaultCategoryPreference.java | 76 --- .../ExcludedTagNamespacesPreference.java | 114 ---- .../com/hippo/ehviewer/ui/EhActivity.java | 5 - .../hippo/ehviewer/ui/GalleryActivity.java | 5 - .../com/hippo/ehviewer/ui/MainActivity.java | 8 +- .../com/hippo/ehviewer/ui/MyTagsActivity.java | 3 +- .../hippo/ehviewer/ui/SettingsActivity.java | 35 -- .../hippo/ehviewer/ui/ToolbarActivity.java | 5 - .../ehviewer/ui/fragment/AboutFragment.java | 2 +- .../ehviewer/ui/scene/DownloadsScene.java | 6 +- .../hippo/ehviewer/ui/scene/HistoryScene.java | 7 +- .../hippo/ehviewer/widget/EhDrawerLayout.java | 25 +- .../hippo/ehviewer/widget/EhDrawerView.java | 40 -- .../hippo/ehviewer/widget/EhStageLayout.java | 41 -- .../hippo/okhttp/ChromeRequestBuilder.java | 2 +- .../hippo/preference/SwitchPreference.java | 182 ------ .../main/java/com/hippo/reveal/Reveal.java | 24 - .../com/hippo/reveal/RevealLinearLayout.java | 78 --- .../java/com/hippo/reveal/RevealView.java | 78 --- .../com/hippo/reveal/ViewAnimationUtils.java | 2 - .../main/java/com/hippo/widget/TextClock.java | 6 +- .../v_dots_vertical_secondary_dark_x24.xml | 2 +- app/src/main/res/layout/activity_main.xml | 4 +- .../main/res/layout/gallery_detail_header.xml | 2 +- .../layout/preference_widget_fixed_switch.xml | 25 - .../res/layout/scene_gallery_comments.xml | 5 +- app/src/main/res/values/attrs.xml | 20 - app/src/main/res/values/styles.xml | 2 +- app/src/main/res/values/themes.xml | 6 +- 37 files changed, 49 insertions(+), 1845 deletions(-) delete mode 100644 app/src/main/java/com/hippo/app/AppCompatPreferenceActivity.java delete mode 100644 app/src/main/java/com/hippo/app/ProgressDialog.java delete mode 100644 app/src/main/java/com/hippo/drawable/BitmapPool.java delete mode 100644 app/src/main/java/com/hippo/drawable/RoundDrawable.java delete mode 100644 app/src/main/java/com/hippo/ehviewer/preference/DefaultCategoryPreference.java delete mode 100644 app/src/main/java/com/hippo/ehviewer/preference/ExcludedTagNamespacesPreference.java delete mode 100644 app/src/main/java/com/hippo/ehviewer/widget/EhDrawerView.java delete mode 100644 app/src/main/java/com/hippo/ehviewer/widget/EhStageLayout.java delete mode 100644 app/src/main/java/com/hippo/preference/SwitchPreference.java delete mode 100644 app/src/main/java/com/hippo/reveal/Reveal.java delete mode 100644 app/src/main/java/com/hippo/reveal/RevealLinearLayout.java delete mode 100644 app/src/main/java/com/hippo/reveal/RevealView.java delete mode 100644 app/src/main/res/layout/preference_widget_fixed_switch.xml diff --git a/app/build.gradle b/app/build.gradle index 7edccb123..1ab53512e 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -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' diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index 468280303..1d7f668ed 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -15,3 +15,6 @@ #-keepclassmembers class fqcn.of.javascript.interface.for.webview { # public *; #} + +-keepattributes SourceFile,LineNumberTable +-keep class com.hippo.** { *; } \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index f0ed84683..d1b767bc1 100755 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -44,10 +44,6 @@ android:name="org.apache.http.legacy" android:required="false" /> - - = 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}. - * - *

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. - * - *

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.

- * - *

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}.

- * - * @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 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. - *

- * This is a convenience for calling - * {@link android.view.Window#requestFeature getWindow().requestFeature()}. - *

- * - * @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. - *

- * Define the synthetic task stack that will be generated during Up navigation from - * a different task. - * - *

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.

- * - *

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()}.

- * - *

Applications that wish to supply extra Intent parameters to the parent stack defined - * by the manifest should override - * {@link #onPrepareSupportNavigateUpTaskStack(androidx.core.app.TaskStackBuilder)}.

- * - * @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. - *

- * Prepare the synthetic task stack that will be generated during Up navigation - * from a different task. - * - *

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.

- * - * @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. - * - *

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.

- * - *

See Tasks and - * Back Stack from the developer guide and - * Navigation from the design guide - * for more information about navigating within your app.

- * - *

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.

- * - * @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} <meta-data> - * 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. - * - *

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.

- * - * @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. - * - *

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)}.

- * - * @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} - * - *

Please note: AppCompat uses its own feature id for the action bar: - * {@link AppCompatDelegate#FEATURE_SUPPORT_ACTION_BAR FEATURE_SUPPORT_ACTION_BAR}.

- */ - @Override - public boolean onMenuOpened(int featureId, Menu menu) { - return super.onMenuOpened(featureId, menu); - } - - /** - * {@inheritDoc} - * - *

Please note: AppCompat uses its own feature id for the action bar: - * {@link AppCompatDelegate#FEATURE_SUPPORT_ACTION_BAR FEATURE_SUPPORT_ACTION_BAR}.

- */ - @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(); - } - } -} diff --git a/app/src/main/java/com/hippo/app/ProgressDialog.java b/app/src/main/java/com/hippo/app/ProgressDialog.java deleted file mode 100644 index f808b8180..000000000 --- a/app/src/main/java/com/hippo/app/ProgressDialog.java +++ /dev/null @@ -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; - -/** - *

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.

- *

The dialog can be made cancelable on back key press.

- *

The progress range is 0..10000.

- */ -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); - } - } - } -} diff --git a/app/src/main/java/com/hippo/content/ContextLocalWrapper.java b/app/src/main/java/com/hippo/content/ContextLocalWrapper.java index 698caed61..70180dab4 100644 --- a/app/src/main/java/com/hippo/content/ContextLocalWrapper.java +++ b/app/src/main/java/com/hippo/content/ContextLocalWrapper.java @@ -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); diff --git a/app/src/main/java/com/hippo/drawable/BitmapPool.java b/app/src/main/java/com/hippo/drawable/BitmapPool.java deleted file mode 100644 index 81b3730d6..000000000 --- a/app/src/main/java/com/hippo/drawable/BitmapPool.java +++ /dev/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.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> 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> 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; - } - } -} diff --git a/app/src/main/java/com/hippo/drawable/RoundDrawable.java b/app/src/main/java/com/hippo/drawable/RoundDrawable.java deleted file mode 100644 index 62cf3fab4..000000000 --- a/app/src/main/java/com/hippo/drawable/RoundDrawable.java +++ /dev/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; - } -} diff --git a/app/src/main/java/com/hippo/ehviewer/preference/DefaultCategoryPreference.java b/app/src/main/java/com/hippo/ehviewer/preference/DefaultCategoryPreference.java deleted file mode 100644 index ed2cd3a27..000000000 --- a/app/src/main/java/com/hippo/ehviewer/preference/DefaultCategoryPreference.java +++ /dev/null @@ -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; - } -} diff --git a/app/src/main/java/com/hippo/ehviewer/preference/ExcludedTagNamespacesPreference.java b/app/src/main/java/com/hippo/ehviewer/preference/ExcludedTagNamespacesPreference.java deleted file mode 100644 index d5a5a2241..000000000 --- a/app/src/main/java/com/hippo/ehviewer/preference/ExcludedTagNamespacesPreference.java +++ /dev/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; - } -} diff --git a/app/src/main/java/com/hippo/ehviewer/ui/EhActivity.java b/app/src/main/java/com/hippo/ehviewer/ui/EhActivity.java index d9a6f8e1f..61697cebb 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/EhActivity.java +++ b/app/src/main/java/com/hippo/ehviewer/ui/EhActivity.java @@ -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); diff --git a/app/src/main/java/com/hippo/ehviewer/ui/GalleryActivity.java b/app/src/main/java/com/hippo/ehviewer/ui/GalleryActivity.java index 744689ea9..52c996cfb 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/GalleryActivity.java +++ b/app/src/main/java/com/hippo/ehviewer/ui/GalleryActivity.java @@ -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; diff --git a/app/src/main/java/com/hippo/ehviewer/ui/MainActivity.java b/app/src/main/java/com/hippo/ehviewer/ui/MainActivity.java index a58259b13..943943746 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/MainActivity.java +++ b/app/src/main/java/com/hippo/ehviewer/ui/MainActivity.java @@ -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); diff --git a/app/src/main/java/com/hippo/ehviewer/ui/MyTagsActivity.java b/app/src/main/java/com/hippo/ehviewer/ui/MyTagsActivity.java index 62f7abad0..a825f72d1 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/MyTagsActivity.java +++ b/app/src/main/java/com/hippo/ehviewer/ui/MyTagsActivity.java @@ -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)); diff --git a/app/src/main/java/com/hippo/ehviewer/ui/SettingsActivity.java b/app/src/main/java/com/hippo/ehviewer/ui/SettingsActivity.java index 91969b0aa..95d7b3819 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/SettingsActivity.java +++ b/app/src/main/java/com/hippo/ehviewer/ui/SettingsActivity.java @@ -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); - } - } } diff --git a/app/src/main/java/com/hippo/ehviewer/ui/ToolbarActivity.java b/app/src/main/java/com/hippo/ehviewer/ui/ToolbarActivity.java index 80d12763e..593bc4988 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/ToolbarActivity.java +++ b/app/src/main/java/com/hippo/ehviewer/ui/ToolbarActivity.java @@ -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); diff --git a/app/src/main/java/com/hippo/ehviewer/ui/fragment/AboutFragment.java b/app/src/main/java/com/hippo/ehviewer/ui/fragment/AboutFragment.java index bca499093..ae519e02a 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/fragment/AboutFragment.java +++ b/app/src/main/java/com/hippo/ehviewer/ui/fragment/AboutFragment.java @@ -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(); diff --git a/app/src/main/java/com/hippo/ehviewer/ui/scene/DownloadsScene.java b/app/src/main/java/com/hippo/ehviewer/ui/scene/DownloadsScene.java index 1e055d14e..5ec255640 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/scene/DownloadsScene.java +++ b/app/src/main/java/com/hippo/ehviewer/ui/scene/DownloadsScene.java @@ -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 diff --git a/app/src/main/java/com/hippo/ehviewer/ui/scene/HistoryScene.java b/app/src/main/java/com/hippo/ehviewer/ui/scene/HistoryScene.java index 6c3ee1ebf..7006f5093 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/scene/HistoryScene.java +++ b/app/src/main/java/com/hippo/ehviewer/ui/scene/HistoryScene.java @@ -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 diff --git a/app/src/main/java/com/hippo/ehviewer/widget/EhDrawerLayout.java b/app/src/main/java/com/hippo/ehviewer/widget/EhDrawerLayout.java index 4237a734d..42f88f3e1 100644 --- a/app/src/main/java/com/hippo/ehviewer/widget/EhDrawerLayout.java +++ b/app/src/main/java/com/hippo/ehviewer/widget/EhDrawerLayout.java @@ -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 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 { - // 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()); } } diff --git a/app/src/main/java/com/hippo/ehviewer/widget/EhDrawerView.java b/app/src/main/java/com/hippo/ehviewer/widget/EhDrawerView.java deleted file mode 100644 index 1d2d7dfbc..000000000 --- a/app/src/main/java/com/hippo/ehviewer/widget/EhDrawerView.java +++ /dev/null @@ -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); - } -} diff --git a/app/src/main/java/com/hippo/ehviewer/widget/EhStageLayout.java b/app/src/main/java/com/hippo/ehviewer/widget/EhStageLayout.java deleted file mode 100644 index fa638a828..000000000 --- a/app/src/main/java/com/hippo/ehviewer/widget/EhStageLayout.java +++ /dev/null @@ -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); - } - -} diff --git a/app/src/main/java/com/hippo/okhttp/ChromeRequestBuilder.java b/app/src/main/java/com/hippo/okhttp/ChromeRequestBuilder.java index f391c1c23..c668c4ec6 100644 --- a/app/src/main/java/com/hippo/okhttp/ChromeRequestBuilder.java +++ b/app/src/main/java/com/hippo/okhttp/ChromeRequestBuilder.java @@ -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"; diff --git a/app/src/main/java/com/hippo/preference/SwitchPreference.java b/app/src/main/java/com/hippo/preference/SwitchPreference.java deleted file mode 100644 index f29244aed..000000000 --- a/app/src/main/java/com/hippo/preference/SwitchPreference.java +++ /dev/null @@ -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); - } - } -} diff --git a/app/src/main/java/com/hippo/reveal/Reveal.java b/app/src/main/java/com/hippo/reveal/Reveal.java deleted file mode 100644 index 91124cda7..000000000 --- a/app/src/main/java/com/hippo/reveal/Reveal.java +++ /dev/null @@ -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); -} diff --git a/app/src/main/java/com/hippo/reveal/RevealLinearLayout.java b/app/src/main/java/com/hippo/reveal/RevealLinearLayout.java deleted file mode 100644 index 157d72c02..000000000 --- a/app/src/main/java/com/hippo/reveal/RevealLinearLayout.java +++ /dev/null @@ -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); - } - } -} diff --git a/app/src/main/java/com/hippo/reveal/RevealView.java b/app/src/main/java/com/hippo/reveal/RevealView.java deleted file mode 100644 index f145cde65..000000000 --- a/app/src/main/java/com/hippo/reveal/RevealView.java +++ /dev/null @@ -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); - } - } -} diff --git a/app/src/main/java/com/hippo/reveal/ViewAnimationUtils.java b/app/src/main/java/com/hippo/reveal/ViewAnimationUtils.java index 563684daa..13d39d4f0 100644 --- a/app/src/main/java/com/hippo/reveal/ViewAnimationUtils.java +++ b/app/src/main/java/com/hippo/reveal/ViewAnimationUtils.java @@ -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( diff --git a/app/src/main/java/com/hippo/widget/TextClock.java b/app/src/main/java/com/hippo/widget/TextClock.java index c9388217f..e9ae121d4 100644 --- a/app/src/main/java/com/hippo/widget/TextClock.java +++ b/app/src/main/java/com/hippo/widget/TextClock.java @@ -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; diff --git a/app/src/main/res/drawable/v_dots_vertical_secondary_dark_x24.xml b/app/src/main/res/drawable/v_dots_vertical_secondary_dark_x24.xml index e8ff044e4..7efbe1a17 100644 --- a/app/src/main/res/drawable/v_dots_vertical_secondary_dark_x24.xml +++ b/app/src/main/res/drawable/v_dots_vertical_secondary_dark_x24.xml @@ -21,7 +21,7 @@ android:viewportHeight="24"> diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 69186dd7f..b8543ddf7 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -25,7 +25,7 @@ android:layout_height="match_parent" android:fitsSystemWindows="true"> - @@ -39,7 +39,7 @@ app:menu="@menu/nav_drawer_main" /> - - - - - diff --git a/app/src/main/res/layout/scene_gallery_comments.xml b/app/src/main/res/layout/scene_gallery_comments.xml index fba37dbfe..68008d6d1 100644 --- a/app/src/main/res/layout/scene_gallery_comments.xml +++ b/app/src/main/res/layout/scene_gallery_comments.xml @@ -36,11 +36,12 @@ android:gravity="center_horizontal" android:text="@string/no_one_comments_gallery" /> - @@ -72,7 +73,7 @@ android:padding="16dp" /> - + - - - - - - - - - - - - - diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index cda3c8e63..81f0d6094 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -16,7 +16,7 @@ - diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml index 3959cea7e..28c0da409 100644 --- a/app/src/main/res/values/themes.xml +++ b/app/src/main/res/values/themes.xml @@ -122,7 +122,7 @@ @drawable/preference_header_background_black - @style/ThemeOverlay.AppCompat.Dark + @style/ThemeOverlay.MaterialComponents.Dark @drawable/divider_gallery_detail_dark @android:color/black false @@ -144,13 +144,13 @@ - -