This commit is contained in:
seven332 committed 2015-04-18 04:06:49 +08:00
1 parent 525ce72ec1
commit 4133bb4e7b
19 files changed
+368 -57

No files matched your search

Binary file not shown.
@@ -26,7 +26,6 @@ import android.view.View;
import com.hippo.ehviewer.R;
import com.hippo.widget.HotspotTouchHelper;
public final class RippleSalon {
private static final Drawable MASK = new ColorDrawable(Color.BLACK);
@@ -15,11 +15,13 @@
package com.hippo.ehviewer.ui;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.Resources;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.widget.DrawerLayout;
import android.view.Gravity;
import com.hippo.content.VectorContext;
import com.hippo.ehviewer.R;
@@ -62,4 +64,13 @@ public class ContentActivity extends StageActivity {
protected void attachBaseContext(Context newBase) {
super.attachBaseContext(VectorContext.wrapContext(newBase));
}
@SuppressLint("RtlHardcoded")
public void toggleDrawer() {
if (mDrawerLayout.isDrawerOpen(Gravity.LEFT) || mDrawerLayout.isDrawerOpen(Gravity.RIGHT)) {
mDrawerLayout.closeDrawers();
} else {
mDrawerLayout.openDrawer(Gravity.LEFT);
}
}
}
@@ -16,7 +16,6 @@
package com.hippo.ehviewer.ui;
import android.content.Intent;
import android.graphics.Typeface;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.TextView;
@@ -37,7 +36,6 @@ public class StartActivity extends AbsActionBarActivity {
setContentView(R.layout.activity_start);
TextView text = (TextView) findViewById(R.id.text_welcome);
text.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/GloriaHallelujah.ttf"));
try {
SVG svg = new SVGBuilder().readFromResource(getResources(), R.raw.sad_pandroid).build();
@@ -23,10 +23,11 @@ import android.view.View;
import com.hippo.ehviewer.R;
import com.hippo.ehviewer.ui.ContentActivity;
import com.hippo.ehviewer.widget.ContentLayout;
import com.hippo.ehviewer.widget.SearchBar;
import com.hippo.scene.Scene;
import com.hippo.scene.TransitionCurtain;
public class GalleryListScene extends Scene {
public class GalleryListScene extends Scene implements SearchBar.Helper{
private final static int PAGE_INDEX_SEARCH = 0;
private final static int PAGE_INDEX_LIST = 1;
@@ -35,6 +36,7 @@ public class GalleryListScene extends Scene {
private ContentActivity mActivity;
private Resources mResources;
private SearchBar mSearchBar;
private ContentLayout mContentLayout;
@Override
@@ -45,8 +47,10 @@ public class GalleryListScene extends Scene {
mActivity = (ContentActivity) getStageActivity();
mResources = mActivity.getResources();
mSearchBar = (SearchBar) findViewById(R.id.search_bar);
mContentLayout = (ContentLayout) findViewById(R.id.content_layout);
mSearchBar.setHelper(this);
mContentLayout.showText("无法连接网络");
View view = getSceneView();
@@ -70,4 +74,9 @@ public class GalleryListScene extends Scene {
protected void onGetFitPaddingBottom(int b) {
// TODO
}
@Override
public void onClickMenu() {
mActivity.toggleDrawer();
}
}
@@ -0,0 +1,80 @@
/*
* 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.ehviewer.widget;
import android.content.Context;
import android.graphics.Typeface;
import android.support.v7.widget.CardView;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import com.hippo.ehviewer.R;
import com.hippo.util.UiUtils;
public class SearchBar extends CardView implements View.OnClickListener {
private View mMenuButton;
private TextView mLogoTextView;
private Helper mHelper;
public SearchBar(Context context) {
super(context);
init(context);
}
public SearchBar(Context context, AttributeSet attrs) {
super(context, attrs);
init(context);
}
public SearchBar(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init(context);
}
private void init(Context context) {
setRadius(UiUtils.dp2pix(context, 2));
setCardElevation(UiUtils.dp2pix(context, 2));
LayoutInflater.from(context).inflate(R.layout.widget_search_bar, this);
mMenuButton = getChildAt(0);
mLogoTextView = (TextView) getChildAt(1);
mMenuButton.setOnClickListener(this);
mLogoTextView.setTypeface(Typeface.createFromAsset(context.getAssets(),
"fonts/Slabo.ttf"));
}
public void setHelper(Helper helper) {
mHelper = helper;
}
@Override
public void onClick(View v) {
if (v == mMenuButton) {
if (mHelper != null) {
mHelper.onClickMenu();
}
}
}
public interface Helper {
void onClickMenu();
}
}
@@ -20,7 +20,6 @@ import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.animation.PropertyValuesHolder;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.drawable.BitmapDrawable;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
@@ -63,8 +62,8 @@ public class TransitionCurtain extends Curtain {
// Handle background
int bgColor = enter.getBackgroundColor();
enter.setBackgroundColor(Color.TRANSPARENT);
int startBgColor = bgColor & 0xffffff;
enter.setBackgroundColor(startBgColor);
ObjectAnimator colorAnim = ObjectAnimator.ofInt(enter, "backgroundColor", bgColor);
colorAnim.setEvaluator(ArgbEvaluator.getInstance());
colorAnim.setDuration(ANIMATE_TIME);
@@ -235,7 +234,9 @@ public class TransitionCurtain extends Curtain {
final Set<Animator> animatorCollection = new HashSet<>();
// Handle background
ObjectAnimator colorAnim = ObjectAnimator.ofInt(exit, "backgroundColor", Color.TRANSPARENT);
int bgColor = enter.getBackgroundColor();
int endBgColor = bgColor & 0xffffff;
ObjectAnimator colorAnim = ObjectAnimator.ofInt(exit, "backgroundColor", endBgColor);
colorAnim.setEvaluator(ArgbEvaluator.getInstance());
colorAnim.setDuration(ANIMATE_TIME);
animatorCollection.add(colorAnim);
@@ -0,0 +1,76 @@
/*
* 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.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.View;
public class SimpleImageView extends View {
private Drawable mDrawable;
private static final int[] LAYOUT_ATTRS = new int[] {
android.R.attr.src
};
public SimpleImageView(Context context, AttributeSet attrs) {
super(context, attrs);
init(context, attrs);
}
public SimpleImageView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init(context, attrs);
}
private void init(Context context, AttributeSet attrs) {
final TypedArray a = context.obtainStyledAttributes(attrs, LAYOUT_ATTRS);
mDrawable = a.getDrawable(0);
a.recycle();
}
@Override
protected int getSuggestedMinimumWidth() {
int superMinWidth = super.getSuggestedMinimumWidth();
return (mDrawable == null) ? superMinWidth :
Math.max(superMinWidth, mDrawable.getMinimumWidth() + getPaddingLeft() + getPaddingRight());
}
@Override
protected int getSuggestedMinimumHeight() {
int superMinHeight = super.getSuggestedMinimumHeight();
return (mDrawable == null) ? superMinHeight :
Math.max(superMinHeight, mDrawable.getMinimumHeight() + getPaddingTop() + getPaddingBottom());
}
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
int width = right - left;
int height = bottom - top;
mDrawable.setBounds(getPaddingLeft(), getPaddingTop(),
width - getPaddingRight(), height - getPaddingBottom());
}
@Override
protected void onDraw(Canvas canvas) {
mDrawable.draw(canvas);
}
}
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ 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.
-->
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:auto="http://schemas.android.com/apk/res-auto"
tools:targetApi="21"
auto:width="24dp"
auto:height="24dp"
auto:viewportWidth="24"
auto:viewportHeight="24"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
auto:pathData="@string/pd_android_debug_bridge"
auto:fillColor="#8A000000"
android:pathData="@string/pd_android_debug_bridge"
android:fillColor="#8A000000"/>
</vector>
+8 -8
View File
@@ -19,15 +19,15 @@
xmlns:auto="http://schemas.android.com/apk/res-auto"
tools:targetApi="21"
auto:width="24.0dp"
auto:height="24.0dp"
auto:viewportWidth="24.0"
auto:viewportHeight="24.0"
auto:width="24dp"
auto:height="24dp"
auto:viewportWidth="24"
auto:viewportHeight="24"
android:width="24.0dp"
android:height="24.0dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
auto:pathData="@string/pd_search"
+8 -8
View File
@@ -19,15 +19,15 @@
xmlns:auto="http://schemas.android.com/apk/res-auto"
tools:targetApi="21"
auto:width="24.0dp"
auto:height="24.0dp"
auto:viewportWidth="24.0"
auto:viewportHeight="24.0"
auto:width="24dp"
auto:height="24dp"
auto:viewportWidth="24"
auto:viewportHeight="24"
android:width="24.0dp"
android:height="24.0dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
auto:pathData="@string/pd_happy"
+40
View File
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ 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.
-->
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:auto="http://schemas.android.com/apk/res-auto"
tools:targetApi="21"
auto:width="24dp"
auto:height="24dp"
auto:viewportWidth="24"
auto:viewportHeight="24"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
auto:pathData="@string/pd_menu"
auto:fillColor="#8A000000"
android:pathData="@string/pd_menu"
android:fillColor="#8A000000"/>
</vector>
+8 -8
View File
@@ -19,15 +19,15 @@
xmlns:auto="http://schemas.android.com/apk/res-auto"
tools:targetApi="21"
auto:width="24.0dp"
auto:height="24.0dp"
auto:viewportWidth="24.0"
auto:viewportHeight="24.0"
auto:width="24dp"
auto:height="24dp"
auto:viewportWidth="24"
auto:viewportHeight="24"
android:width="24.0dp"
android:height="24.0dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
auto:pathData="@string/pd_sad"
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ 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.
-->
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners
android:radius="2dp" />
<solid
android:color="@android:color/white" />
</shape>
+4 -2
View File
@@ -15,6 +15,7 @@
-->
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawerLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
@@ -30,11 +31,12 @@
<com.hippo.widget.DrawerFrameLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:layout_gravity="left"
android:maxWidth="320dp"
android:background="?attr/colorAccent"
android:fitsSystemWindows="true"
android:clickable="true">
android:clickable="true"
tools:ignore="RtlHardcoded">
<include
layout="@layout/draw_left"/>
+17 -4
View File
@@ -13,9 +13,22 @@
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<com.hippo.ehviewer.widget.ContentLayout
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/content_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"/>
android:layout_height="match_parent">
<com.hippo.ehviewer.widget.SearchBar
android:id="@+id/search_bar"
android:layout_width="match_parent"
android:layout_height="56dp"
android:layout_margin="8dp"/>
<com.hippo.ehviewer.widget.ContentLayout
android:id="@+id/content_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"/>
</FrameLayout>
+24 -17
View File
@@ -13,26 +13,33 @@
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<LinearLayout
<merge
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="@dimen/stage_bar_height">
xmlns:tools="http://schemas.android.com/tools">
<ImageView
<com.hippo.widget.SimpleImageView
android:layout_width="56dp"
android:layout_height="56dp"
android:layout_gravity="left|center_vertical"
android:padding="14dp"
android:src="@drawable/ic_menu"
tools:ignore="RtlHardcoded"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/vector_search"
android:contentDescription="@string/search"/>
android:layout_gravity="left|center_vertical"
android:paddingLeft="56dp"
android:text="@string/app_name"
android:textSize="@dimen/text_large"
tools:ignore="RtlHardcoded,RtlSymmetry"/>
<Space
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<com.hippo.widget.SimpleImageView
android:layout_width="56dp"
android:layout_height="56dp"
android:layout_gravity="right|center_vertical"
android:padding="14dp"
android:src="@drawable/ic_android_debug_bridge"
tools:ignore="RtlHardcoded"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/vector_search"
android:contentDescription="@string/search"/>
</LinearLayout>
</merge>
+9 -2
View File
@@ -15,8 +15,6 @@
-->
<resources>
<!-- Stage Bar -->
<dimen name="stage_bar_height">56dp</dimen>
@@ -74,4 +72,13 @@
<dimen name="fab_size">60dp</dimen>
<dimen name="fab_size_small">44dp</dimen>
<!-- Text size -->
<dimen name="text_super_large">24sp</dimen>
<dimen name="text_large">22sp</dimen>
<dimen name="text_little_large">20sp</dimen>
<dimen name="text_medium">18sp</dimen>
<dimen name="text_little_small">16sp</dimen>
<dimen name="text_small">14sp</dimen>
<dimen name="text_super_small">12sp</dimen>
</resources>
+2
View File
@@ -18,5 +18,7 @@
<string name="pd_happy" translatable="false">M20,12A8,8 0 0,0 12,4A8,8 0 0,0 4,12A8,8 0 0,0 12,20A8,8 0 0,0 20,12M22,12A10,10 0 0,1 12,22A10,10 0 0,1 2,12A10,10 0 0,1 12,2A10,10 0 0,1 22,12M10,9.5C10,10.3 9.3,11 8.5,11C7.7,11 7,10.3 7,9.5C7,8.7 7.7,8 8.5,8C9.3,8 10,8.7 10,9.5M17,9.5C17,10.3 16.3,11 15.5,11C14.7,11 14,10.3 14,9.5C14,8.7 14.7,8 15.5,8C16.3,8 17,8.7 17,9.5M12,17.23C10.25,17.23 8.71,16.5 7.81,15.42L9.23,14C9.68,14.72 10.75,15.23 12,15.23C13.25,15.23 14.32,14.72 14.77,14L16.19,15.42C15.29,16.5 13.75,17.23 12,17.23Z</string>
<string name="pd_sad" translatable="false">M20,12A8,8 0 0,0 12,4A8,8 0 0,0 4,12A8,8 0 0,0 12,20A8,8 0 0,0 20,12M22,12A10,10 0 0,1 12,22A10,10 0 0,1 2,12A10,10 0 0,1 12,2A10,10 0 0,1 22,12M15.5,8C16.3,8 17,8.7 17,9.5C17,10.3 16.3,11 15.5,11C14.7,11 14,10.3 14,9.5C14,8.7 14.7,8 15.5,8M10,9.5C10,10.3 9.3,11 8.5,11C7.7,11 7,10.3 7,9.5C7,8.7 7.7,8 8.5,8C9.3,8 10,8.7 10,9.5M12,14C13.75,14 15.29,14.72 16.19,15.81L14.77,17.23C14.32,16.5 13.25,16 12,16C10.75,16 9.68,16.5 9.23,17.23L7.81,15.81C8.71,14.72 10.25,14 12,14Z</string>
<string name="pd_search" translatable="false">M9.5,3A6.5,6.5 0 0,1 16,9.5C16,11.11 15.41,12.59 14.44,13.73L14.71,14H15.5L20.5,19L19,20.5L14,15.5V14.71L13.73,14.44C12.59,15.41 11.11,16 9.5,16A6.5,6.5 0 0,1 3,9.5A6.5,6.5 0 0,1 9.5,3M9.5,5C7,5 5,7 5,9.5C5,12 7,14 9.5,14C12,14 14,12 14,9.5C14,7 12,5 9.5,5Z</string>
<string name="pd_menu" translatable="false">M3,6H21V8H3V6M3,11H21V13H3V11M3,16H21V18H3V16Z</string>
<string name="pd_android_debug_bridge" translatable="false">M15,9A1,1 0 0,1 14,8A1,1 0 0,1 15,7A1,1 0 0,1 16,8A1,1 0 0,1 15,9M9,9A1,1 0 0,1 8,8A1,1 0 0,1 9,7A1,1 0 0,1 10,8A1,1 0 0,1 9,9M16.12,4.37L18.22,2.27L17.4,1.44L15.09,3.75C14.16,3.28 13.11,3 12,3C10.88,3 9.84,3.28 8.91,3.75L6.6,1.44L5.78,2.27L7.88,4.37C6.14,5.64 5,7.68 5,10V11H19V10C19,7.68 17.86,5.64 16.12,4.37M5,16C5,19.86 8.13,23 12,23A7,7 0 0,0 19,16V12H5V16Z</string>
</resources>