diff --git a/app/src/main/java/com/hippo/ehviewer/EhApplication.java b/app/src/main/java/com/hippo/ehviewer/EhApplication.java
index 7ff7a771b..507d8a8dc 100644
--- a/app/src/main/java/com/hippo/ehviewer/EhApplication.java
+++ b/app/src/main/java/com/hippo/ehviewer/EhApplication.java
@@ -21,6 +21,7 @@ import android.content.Context;
import android.os.Build;
import android.webkit.CookieSyncManager;
+import com.hippo.beerbelly.SimpleDiskCache;
import com.hippo.conaco.Conaco;
import com.hippo.ehviewer.network.EhOkHttpClient;
import com.hippo.ehviewer.util.Config;
@@ -29,10 +30,12 @@ import com.hippo.util.Log;
import com.hippo.vectorold.content.VectorContext;
import java.io.File;
+import java.io.IOException;
public class EhApplication extends SceneApplication {
private Conaco mConaco;
+ private SimpleDiskCache mReadcache;
@Override
public void onCreate() {
@@ -52,6 +55,12 @@ public class EhApplication extends SceneApplication {
conacoBuilder.diskCacheMaxSize = 50 * 1024 * 1024;
conacoBuilder.httpClient = EhOkHttpClient.getInstance();
mConaco = conacoBuilder.build();
+
+ try {
+ mReadcache = new SimpleDiskCache(new File(getCacheDir(), "readCache"), 200 * 1024 * 1024);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
}
private int getMemoryCacheMaxSize() {
@@ -79,4 +88,9 @@ public class EhApplication extends SceneApplication {
EhApplication application = (EhApplication) context.getApplicationContext();
return application.mConaco;
}
+
+ public static SimpleDiskCache getReadCache(Context context) {
+ EhApplication application = (EhApplication) context.getApplicationContext();
+ return application.mReadcache;
+ }
}
diff --git a/app/src/main/java/com/hippo/ehviewer/ui/GalleryActivity.java b/app/src/main/java/com/hippo/ehviewer/ui/GalleryActivity.java
new file mode 100644
index 000000000..5cf3a3321
--- /dev/null
+++ b/app/src/main/java/com/hippo/ehviewer/ui/GalleryActivity.java
@@ -0,0 +1,22 @@
+/*
+ * 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.ehviewer.ui;
+
+import android.support.v7.app.AppCompatActivity;
+
+public class GalleryActivity extends AppCompatActivity {
+}
diff --git a/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryDetailScene.java b/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryDetailScene.java
index 50bd221af..ace86be9a 100644
--- a/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryDetailScene.java
+++ b/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryDetailScene.java
@@ -421,8 +421,6 @@ public class GalleryDetailScene extends Scene implements View.OnClickListener,
}
}
- public static boolean AAA = false;
-
private class EhDetailListener extends EhClient.OnGetGalleryDetailListener {
@Override
diff --git a/app/src/main/java/com/hippo/ehviewer/ui/scene/MainSettingsScene.java b/app/src/main/java/com/hippo/ehviewer/ui/scene/MainSettingsScene.java
index 431d6f32d..80f275d3f 100644
--- a/app/src/main/java/com/hippo/ehviewer/ui/scene/MainSettingsScene.java
+++ b/app/src/main/java/com/hippo/ehviewer/ui/scene/MainSettingsScene.java
@@ -17,6 +17,7 @@
package com.hippo.ehviewer.ui.scene;
import android.content.res.Resources;
+import android.support.v4.content.ContextCompat;
import com.hippo.ehviewer.R;
import com.hippo.ehviewer.ui.ContentActivity;
@@ -67,7 +68,7 @@ public final class MainSettingsScene extends PreferenceHeaderScene {
private PreferenceHeader newPreferenceHeader(int drawableId, int titleId, Class clazz) {
Resources resources = getStageActivity().getResources();
return new PreferenceHeader(
- resources.getDrawable(drawableId),
+ ContextCompat.getDrawable(getStageActivity(), drawableId),
resources.getString(titleId),
clazz
);
diff --git a/app/src/main/java/com/hippo/ehviewer/widget/SearchBar.java b/app/src/main/java/com/hippo/ehviewer/widget/SearchBar.java
index 1ebc4ac22..9c0f4c445 100644
--- a/app/src/main/java/com/hippo/ehviewer/widget/SearchBar.java
+++ b/app/src/main/java/com/hippo/ehviewer/widget/SearchBar.java
@@ -162,7 +162,6 @@ public class SearchBar extends CardView implements View.OnClickListener,
}
});
- // TODO get source from config
setSource(Config.getEhSource());
}
diff --git a/app/src/main/java/com/hippo/scene/RippleCurtain.java b/app/src/main/java/com/hippo/scene/RippleCurtain.java
index 7dd4cbecf..1d51a9c05 100644
--- a/app/src/main/java/com/hippo/scene/RippleCurtain.java
+++ b/app/src/main/java/com/hippo/scene/RippleCurtain.java
@@ -4,7 +4,6 @@ import android.animation.Animator;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.animation.PropertyValuesHolder;
-import android.os.Build;
import android.support.annotation.NonNull;
import android.view.View;
import android.view.ViewTreeObserver;
@@ -17,6 +16,7 @@ import com.hippo.util.ViewUtils;
import java.util.HashSet;
import java.util.Set;
+// Do not ues it when Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2
public class RippleCurtain extends Curtain {
private static final String TAG = RippleCurtain.class.getSimpleName();
@@ -47,11 +47,6 @@ public class RippleCurtain extends Curtain {
enterView.setStartPoint(mStartX, mStartY);
ViewUtils.setVisibility(enterView, View.INVISIBLE);
- // Canvas.clipPath() not work for pre-JELLY_BEAN_MR2 when hardware accelerated
- if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) {
- ViewUtils.removeHardwareAccelerationSupport(enterView);
- }
-
enterView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
@@ -92,11 +87,6 @@ public class RippleCurtain extends Curtain {
dispatchOpenFinished(enter, exit);
hideSceneOnOpen(exit);
mAnimatorSet = null;
-
- // Canvas.clipPath() not work for pre-JELLY_BEAN_MR2 when hardware accelerated
- if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) {
- ViewUtils.addHardwareAccelerationSupport(enterView);
- }
}
});
mAnimatorSet.start();
@@ -113,11 +103,6 @@ public class RippleCurtain extends Curtain {
final SceneView exitView = exit.getSceneView();
exitView.setStartPoint(mStartX, mStartY);
- // Canvas.clipPath() not work for pre-JELLY_BEAN_MR2 when hardware accelerated
- if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) {
- ViewUtils.removeHardwareAccelerationSupport(exitView);
- }
-
PropertyValuesHolder circlePercentPvh = PropertyValuesHolder.ofFloat("circlePercent", 1f, 0f);
ObjectAnimator animFrame = ObjectAnimator.ofPropertyValuesHolder(exitView, circlePercentPvh);
animFrame.setDuration(ANIMATE_TIME);
@@ -130,11 +115,6 @@ public class RippleCurtain extends Curtain {
public void onAnimationEnd(Animator animation) {
dispatchCloseFinished(enter, exit);
mAnimatorSet = null;
-
- // Canvas.clipPath() not work for pre-JELLY_BEAN_MR2 when hardware accelerated
- if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) {
- ViewUtils.addHardwareAccelerationSupport(exitView);
- }
}
});
mAnimatorSet.start();
diff --git a/app/src/main/java/com/hippo/scene/Scene.java b/app/src/main/java/com/hippo/scene/Scene.java
index f943aea94..9bec380a7 100644
--- a/app/src/main/java/com/hippo/scene/Scene.java
+++ b/app/src/main/java/com/hippo/scene/Scene.java
@@ -60,7 +60,6 @@ public abstract class Scene {
private @Nullable Announcer mAnnouncer;
- @SuppressWarnings("deprecation")
private SceneView mSceneView;
private int mBackgroundColor = 0xffeeeeee; // TODO Need a better to set background color
@@ -184,9 +183,14 @@ public abstract class Scene {
if (mSceneView == null) {
// Not call setContentView in onCreate, create scene view by ourself
mSceneView = createSceneView(getStageActivity());
- initBackground(mSceneView);
}
+ mSceneView.setBackgroundColor(mBackgroundColor);
+
+ mSceneView.setFocusable(true);
+ mSceneView.setFocusableInTouchMode(true);
+ mSceneView.requestFocus();
+
// Make sure scene view is attach from stage
attachToStage();
@@ -212,16 +216,16 @@ public abstract class Scene {
}
void destroy(boolean die) {
- // Make sure soft key broad is hidden
- InputMethodManager imm = (InputMethodManager) getStageActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
- imm.hideSoftInputFromWindow(getSceneView().getWindowToken(), 0);
-
onDestroy(die);
}
void die(boolean keepView) {
onDie();
+ // Make sure soft key broad is hidden
+ InputMethodManager imm = (InputMethodManager) getStageActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
+ imm.hideSoftInputFromWindow(getSceneView().getWindowToken(), 0);
+
if (!keepView) {
detachFromeStage();
}
@@ -238,6 +242,8 @@ public abstract class Scene {
void resume() {
getSceneView().setEnableTouch(true);
+ mSceneView.requestFocus();
+
onResume();
}
@@ -332,7 +338,6 @@ public abstract class Scene {
protected void setContentView(int resId) {
StageActivity sa = getStageActivity();
mSceneView = createSceneView(sa);
- initBackground(mSceneView);
mSceneView.setBackgroundColor(mBackgroundColor);
sa.getLayoutInflater().inflate(resId, mSceneView);
}
@@ -340,18 +345,10 @@ public abstract class Scene {
protected void setContentView(View view) {
StageActivity sa = getStageActivity();
mSceneView = createSceneView(sa);
- initBackground(mSceneView);
mSceneView.addView(view, new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
}
- private void initBackground(@NonNull View bg) {
- bg.setBackgroundColor(mBackgroundColor);
- bg.setFocusable(true);
- bg.setFocusableInTouchMode(true);
- bg.requestFocus();
- }
-
protected void onNewAnnouncer(Announcer announcer) {
}
diff --git a/app/src/main/java/com/hippo/widget/CardButton.java b/app/src/main/java/com/hippo/widget/CardButton.java
index f81c3a0ac..f07c7cd81 100644
--- a/app/src/main/java/com/hippo/widget/CardButton.java
+++ b/app/src/main/java/com/hippo/widget/CardButton.java
@@ -44,17 +44,12 @@ public class CardButton extends Button implements CardViewDelegate {
}
@Override
- public void setPadding(int left, int top, int right, int bottom) {
+ public void setCardPadding(int left, int top, int right, int bottom) {
if (mCardHelper != null) {
mCardHelper.setPadding(left, top, right, bottom);
}
}
- @Override
- public void setRawPadding(int left, int top, int right, int bottom) {
- super.setPadding(left, top, right, bottom);
- }
-
@SuppressWarnings("deprecation")
@Override
public void setRawBackgroundDrawable(Drawable drawable) {
diff --git a/app/src/main/java/com/hippo/widget/CardLinearLayout.java b/app/src/main/java/com/hippo/widget/CardLinearLayout.java
index 78eb1342b..a3d17aa51 100644
--- a/app/src/main/java/com/hippo/widget/CardLinearLayout.java
+++ b/app/src/main/java/com/hippo/widget/CardLinearLayout.java
@@ -44,17 +44,12 @@ public class CardLinearLayout extends LinearLayout implements CardViewDelegate {
}
@Override
- public void setPadding(int left, int top, int right, int bottom) {
+ public void setCardPadding(int left, int top, int right, int bottom) {
if (mCardHelper != null) {
mCardHelper.setPadding(left, top, right, bottom);
}
}
- @Override
- public void setRawPadding(int left, int top, int right, int bottom) {
- super.setPadding(left, top, right, bottom);
- }
-
@SuppressWarnings("deprecation")
@Override
public void setRawBackgroundDrawable(Drawable drawable) {
diff --git a/app/src/main/res/layout-v21/gallery_detail_header.xml b/app/src/main/res/layout-v21/gallery_detail_header.xml
new file mode 100644
index 000000000..9370ca2ba
--- /dev/null
+++ b/app/src/main/res/layout-v21/gallery_detail_header.xml
@@ -0,0 +1,69 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/layout-v21/scene_gallery_detail.xml b/app/src/main/res/layout-v21/scene_gallery_detail.xml
deleted file mode 100644
index 94200be0b..000000000
--- a/app/src/main/res/layout-v21/scene_gallery_detail.xml
+++ /dev/null
@@ -1,195 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/app/src/main/res/layout/gallery_detail_header.xml b/app/src/main/res/layout/gallery_detail_header.xml
new file mode 100644
index 000000000..ca2132b03
--- /dev/null
+++ b/app/src/main/res/layout/gallery_detail_header.xml
@@ -0,0 +1,80 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/scene_gallery_detail.xml b/app/src/main/res/layout/scene_gallery_detail.xml
index 18eba37a4..eceae815d 100644
--- a/app/src/main/res/layout/scene_gallery_detail.xml
+++ b/app/src/main/res/layout/scene_gallery_detail.xml
@@ -17,7 +17,6 @@
@@ -85,62 +84,8 @@
-
-
-
-
-
-
-
-
-
-
-
+