diff --git a/app/src/main/java/com/hippo/ehviewer/ui/ContentActivity.java b/app/src/main/java/com/hippo/ehviewer/ui/ContentActivity.java
index 69f05e52e..77b1b2302 100644
--- a/app/src/main/java/com/hippo/ehviewer/ui/ContentActivity.java
+++ b/app/src/main/java/com/hippo/ehviewer/ui/ContentActivity.java
@@ -16,6 +16,7 @@
package com.hippo.ehviewer.ui;
import android.os.Bundle;
+import android.support.v4.widget.DrawerLayout;
import android.widget.FrameLayout;
import com.hippo.ehviewer.R;
@@ -24,6 +25,7 @@ import com.hippo.scene.StageActivity;
public class ContentActivity extends StageActivity {
+ private DrawerLayout mDrawerLayout;
private FrameLayout mStage;
@Override
@@ -31,7 +33,9 @@ public class ContentActivity extends StageActivity {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_content);
- mStage = (FrameLayout) findViewById(R.id.stage);
+ mDrawerLayout = (DrawerLayout) findViewById(R.id.drawerLayout);
+ mStage = (FrameLayout) mDrawerLayout.findViewById(R.id.stage);
+
startFirstScene(GalleryListScene.class);
}
diff --git a/app/src/main/java/com/hippo/scene/Scene.java b/app/src/main/java/com/hippo/scene/Scene.java
index 98ed2914a..75feefd46 100644
--- a/app/src/main/java/com/hippo/scene/Scene.java
+++ b/app/src/main/java/com/hippo/scene/Scene.java
@@ -106,4 +106,8 @@ public abstract class Scene {
mStageActivity.stopSceneRetain(this);
}
+ public void onBackPressed() {
+ finish();
+ }
+
}
diff --git a/app/src/main/java/com/hippo/scene/StageActivity.java b/app/src/main/java/com/hippo/scene/StageActivity.java
index 633bd902b..b9b2b91c5 100644
--- a/app/src/main/java/com/hippo/scene/StageActivity.java
+++ b/app/src/main/java/com/hippo/scene/StageActivity.java
@@ -133,9 +133,11 @@ public abstract class StageActivity extends AbsActionBarActivity {
void finishScene(Scene scene) {
if (scene != mRetainedScene && scene != mCurrentScene) {
- // Remove with out animation
- getStageView().removeView(scene.getRootView());
- mSceneStack.remove(scene);
+ if (mSceneStack.contains(scene)) {
+ // Remove without animation
+ getStageView().removeView(scene.getRootView());
+ mSceneStack.remove(scene);
+ }
} else {
if (mRetainedScene == null) {
// Because scene can't be null, so scene == mCurrentScene
@@ -149,10 +151,8 @@ public abstract class StageActivity extends AbsActionBarActivity {
@Override
public void onBackPressed() {
- if (mRetainedScene == null) {
- // No retained scene, no animation
- // If not, just miss it.
- popScense();
+ if (mCurrentScene != null) {
+ mCurrentScene.onBackPressed();
}
}
diff --git a/app/src/main/java/com/hippo/widget/FixedAspectImageView.java b/app/src/main/java/com/hippo/widget/FixedAspectImageView.java
index 2d78f6190..82947d332 100644
--- a/app/src/main/java/com/hippo/widget/FixedAspectImageView.java
+++ b/app/src/main/java/com/hippo/widget/FixedAspectImageView.java
@@ -26,11 +26,7 @@ import com.hippo.util.ViewUtils;
/**
* aspect is width / height
- *
- * @author Hippo
- *
*/
-
public class FixedAspectImageView extends ImageView {
private static final String TAG = FixedAspectImageView.class.getSimpleName();
@@ -69,7 +65,7 @@ public class FixedAspectImageView extends ImageView {
a = context.obtainStyledAttributes(
attrs, R.styleable.FixedAspectImageView, defStyle, 0);
- setAspect(a.getFloat(R.styleable.FixedAspectImageView_aspect, -1f));
+ setAspect(a.getFloat(R.styleable.FixedAspectImageView_faiAspect, -1f));
a.recycle();
}
diff --git a/app/src/main/java/com/hippo/widget/FixedAspectLayout.java b/app/src/main/java/com/hippo/widget/FixedAspectLayout.java
new file mode 100644
index 000000000..1ab319184
--- /dev/null
+++ b/app/src/main/java/com/hippo/widget/FixedAspectLayout.java
@@ -0,0 +1,101 @@
+/*
+ * Copyright (C) 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
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.hippo.widget;
+
+import android.annotation.TargetApi;
+import android.content.Context;
+import android.content.res.TypedArray;
+import android.os.Build;
+import android.util.AttributeSet;
+import android.widget.FrameLayout;
+
+import com.hippo.ehviewer.R;
+
+/**
+ * aspect is width / height
+ */
+public class FixedAspectLayout extends FrameLayout {
+
+ private float mAspect = -1f;
+
+ public FixedAspectLayout(Context context) {
+ super(context);
+ }
+
+ public FixedAspectLayout(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ init(context, attrs, 0, 0);
+ }
+
+ public FixedAspectLayout(Context context, AttributeSet attrs, int defStyleAttr) {
+ super(context, attrs, defStyleAttr);
+ init(context, attrs, defStyleAttr, 0);
+ }
+
+ @TargetApi(Build.VERSION_CODES.LOLLIPOP)
+ public FixedAspectLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
+ super(context, attrs, defStyleAttr, defStyleRes);
+ init(context, attrs, defStyleAttr, defStyleRes);
+ }
+
+ private void init(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
+ TypedArray a = context.obtainStyledAttributes(
+ attrs, R.styleable.FixedAspectLayout, defStyleAttr, defStyleRes);
+ setAspect(a.getFloat(R.styleable.FixedAspectLayout_falAspect, -1f));
+ a.recycle();
+ }
+
+ public void setAspect(float ratio) {
+ if (ratio > 0) {
+ mAspect = ratio;
+ } else {
+ mAspect = -1f;
+ }
+ requestLayout();
+ }
+
+ @Override
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ if (mAspect > 0.0f) {
+ final int widthSpecMode = MeasureSpec.getMode(widthMeasureSpec);
+ final int heightSpecMode = MeasureSpec.getMode(heightMeasureSpec);
+ int width;
+ int height;
+ if (widthSpecMode == MeasureSpec.EXACTLY && heightSpecMode != MeasureSpec.EXACTLY) {
+ width = MeasureSpec.getSize(widthMeasureSpec);
+ int maxheight;
+ if (heightSpecMode == MeasureSpec.AT_MOST) {
+ maxheight = MeasureSpec.getSize(heightMeasureSpec);
+ } else {
+ maxheight = Integer.MAX_VALUE;
+ }
+ height = Math.min((int) (width / mAspect), maxheight);
+ heightMeasureSpec = MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY);
+ } else if (heightSpecMode == MeasureSpec.EXACTLY && widthSpecMode != MeasureSpec.EXACTLY) {
+ height = MeasureSpec.getSize(heightMeasureSpec);
+ int maxWidth;
+ if (widthSpecMode == MeasureSpec.AT_MOST) {
+ maxWidth = MeasureSpec.getSize(widthSpecMode);
+ } else {
+ maxWidth = Integer.MAX_VALUE;
+ }
+ width = Math.min((int) (height * mAspect), maxWidth);
+ widthMeasureSpec = MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY);
+ }
+ }
+ super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+ }
+}
diff --git a/app/src/main/res/layout/activity_content.xml b/app/src/main/res/layout/activity_content.xml
index bfb436d6c..8bff0d6c0 100644
--- a/app/src/main/res/layout/activity_content.xml
+++ b/app/src/main/res/layout/activity_content.xml
@@ -14,6 +14,7 @@
~ limitations under the License.
-->
@@ -22,4 +23,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"/>
+
+
diff --git a/app/src/main/res/layout/draw_left.xml b/app/src/main/res/layout/draw_left.xml
new file mode 100644
index 000000000..7ac9218d7
--- /dev/null
+++ b/app/src/main/res/layout/draw_left.xml
@@ -0,0 +1,24 @@
+
+
+
+
+
+
diff --git a/app/src/main/res/values/attrs.xml b/app/src/main/res/values/attrs.xml
index 19a49b657..4bfd46471 100644
--- a/app/src/main/res/values/attrs.xml
+++ b/app/src/main/res/values/attrs.xml
@@ -16,7 +16,11 @@
-
+
+
+
+
+
diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
index 93805d3a2..1be936175 100644
--- a/app/src/main/res/values/colors.xml
+++ b/app/src/main/res/values/colors.xml
@@ -29,6 +29,9 @@
#deffffff
#61ffffff
+ #ff303030
+ #ffeeeeee
+
@color/material_teal_500
@color/material_teal_700
#ffff6977