diff --git a/app/src/androidTest/java/com/hippo/ehviewer/CardBgTest.java b/app/src/androidTest/java/com/hippo/ehviewer/CardBgTest.java new file mode 100644 index 000000000..f48cf5b35 --- /dev/null +++ b/app/src/androidTest/java/com/hippo/ehviewer/CardBgTest.java @@ -0,0 +1,164 @@ +/* + * 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; + +import android.graphics.Bitmap; +import android.graphics.Canvas; +import android.graphics.Color; +import android.graphics.Paint; +import android.graphics.Path; +import android.graphics.RectF; +import android.os.Environment; + +import junit.framework.TestCase; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.OutputStream; + +public class CardBgTest extends TestCase { + + private static final float[] TOP_ALPHA = { + 0f, // Dump + 0.12f, + 0.16f, + 0.19f, + 0.25f, + 0.30f, + }; + + private static final float[] TOP_OFFSET = { + 0f, // Dump + 1f, + 3f, + 10f, + 14f, + 19f, + }; + + private static final float[] TOP_BLUR = { + 0f, // Dump + 1.5f, + 3f, + 10f, + 14f, + 19f, + }; + + private static final float[] BOTTOM_ALPHA = { + 0f, // Dump + 0.24f, + 0.23f, + 0.23f, + 0.22f, + 0.22f, + }; + + private static final float[] BOTTOM_OFFSET = { + 0f, // Dump + 1f, + 3f, + 6f, + 10f, + 15f, + }; + + private static final float[] BOTTOM_BLUR = { + 0f, // Dump + 1f, + 3f, + 3f, + 5f, + 6f, + }; + + private static final int MAX_SIZE = 200; + + + public void testGen() throws FileNotFoundException { + genCardBg(Color.WHITE, 2, 2); + } + + private Path getPath(float radius, float base) { + RectF rectF = new RectF(); + Path path = new Path(); + path.moveTo(base / 2, -base / 2 - radius); + rectF.set(base / 2 - radius, -base / 2 - radius, base / 2 + radius, -base / 2 + radius); + path.arcTo(rectF, -90, 90); + path.lineTo(base / 2 + radius, base / 2); + rectF.set(base / 2 - radius, base / 2 - radius, base / 2 + radius, base / 2 + radius); + path.arcTo(rectF, 0, 90); + path.lineTo(-base / 2, base / 2 + radius); + rectF.set(-base / 2 - radius, base / 2 - radius, -base / 2 + radius, base / 2 + radius); + path.arcTo(rectF, 90, 90); + path.lineTo(-base / 2 - radius, -base / 2); + rectF.set(-base / 2 - radius, -base / 2 - radius, -base / 2 + radius, -base / 2 + radius); + path.arcTo(rectF, 180, 90); + path.close(); + return path; + } + + private void genCardBg(int color, float radius, int elevation) throws FileNotFoundException { + + float base = 4; + float topAlpha = TOP_ALPHA[elevation]; + float topOffset = TOP_OFFSET[elevation]; + float topBlur = TOP_BLUR[elevation]; + float bottomAlpha = BOTTOM_ALPHA[elevation]; + float bottomOffset = BOTTOM_OFFSET[elevation]; + float bottomBlur = BOTTOM_BLUR[elevation]; + + + float ratio = 3; + + + doGenCardBg(new FileOutputStream(new File(Environment.getExternalStorageDirectory(), "test.png")), + color, radius * ratio, base * ratio, + topAlpha, topOffset * ratio, topBlur * ratio, + bottomAlpha, bottomOffset * ratio, bottomBlur * ratio); + + + } + + private int getColor(float alpha) { + return Color.argb((int) (alpha * 0xff), 0, 0, 0); + } + + private void doGenCardBg(OutputStream os, int color, float radius, float base, + float topAlpha, float topOffset, float topBlur, + float bottomAlpha, float bottomOffset, float bottomBlur) throws FileNotFoundException { + + Path path = getPath(radius, base); + path.offset(MAX_SIZE / 2, MAX_SIZE / 2); + + Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG); + paint.setColor(color); + Bitmap bitmap = Bitmap.createBitmap(MAX_SIZE, MAX_SIZE, Bitmap.Config.ARGB_8888); + Canvas canvas = new Canvas(bitmap); + + // Draw bottom + paint.setShadowLayer(bottomBlur, 0, bottomOffset, getColor(bottomAlpha)); + canvas.drawPath(path, paint); + + // Draw top + paint.setShadowLayer(topBlur, 0, topOffset, getColor(topAlpha)); + canvas.drawPath(path, paint); + + bitmap.compress(Bitmap.CompressFormat.PNG, 100, os); + } +} diff --git a/app/src/main/res/drawable-hdpi/card_grey_2dp.9.png b/app/src/main/res/drawable-hdpi/card_grey_2dp.9.png new file mode 100644 index 000000000..dbb819aa3 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/card_grey_2dp.9.png differ diff --git a/app/src/main/res/drawable-mdpi/card_grey_2dp.9.png b/app/src/main/res/drawable-mdpi/card_grey_2dp.9.png new file mode 100644 index 000000000..14dbd13b1 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/card_grey_2dp.9.png differ diff --git a/app/src/main/res/drawable-xhdpi/card_grey_2dp.9.png b/app/src/main/res/drawable-xhdpi/card_grey_2dp.9.png new file mode 100644 index 000000000..48fcc7426 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/card_grey_2dp.9.png differ diff --git a/app/src/main/res/drawable-xxhdpi/card_grey_2dp.9.png b/app/src/main/res/drawable-xxhdpi/card_grey_2dp.9.png new file mode 100644 index 000000000..71173615c Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/card_grey_2dp.9.png differ diff --git a/app/src/main/res/drawable/card_background.xml b/app/src/main/res/drawable/card_background.xml index 3bf952060..5537b2d90 100644 --- a/app/src/main/res/drawable/card_background.xml +++ b/app/src/main/res/drawable/card_background.xml @@ -18,7 +18,7 @@ - + diff --git a/app/src/main/res/layout/scene_download.xml b/app/src/main/res/layout/scene_download.xml index 52cb7822c..e154ee98f 100644 --- a/app/src/main/res/layout/scene_download.xml +++ b/app/src/main/res/layout/scene_download.xml @@ -54,6 +54,7 @@ + android:src="@drawable/ic_check_all_dark_x24" + app:backgroundTint="?attr/colorPrimary"/> + android:src="@drawable/ic_play_dark_x24" + app:backgroundTint="?attr/colorPrimary"/> + android:src="@drawable/ic_pause_dark_x24" + app:backgroundTint="?attr/colorPrimary"/> + android:src="@drawable/ic_close_dark_x24" + app:backgroundTint="?attr/colorPrimary"/> + android:src="@drawable/ic_folder_move_dark_x24" + app:backgroundTint="?attr/colorPrimary"/> %1$d 项下载成功,%2$d 项下载失败 下载成功:%s 下载失败:%s - 移除画廊 + 移除下载项 从下载列表移除 %s ? 删除图片文件 全部停止 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 119ebbd87..c23681aa6 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -230,7 +230,7 @@ %1$d succeeded, %2$d failed Succeeded: %s Failed: %s - Remove Gallery + Remove Download Item Remove %s from download list ? Delete image files Stop All