diff --git a/app/build.gradle b/app/build.gradle index 7f319e320..6cd4723fe 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -58,7 +58,6 @@ clean { dependencies { compile project(':anani') compile project(':beerbelly') - compile project(':cardsalon') compile project(':conaco') compile project(':easyrecyclerview') compile project(':hotspot') @@ -72,7 +71,6 @@ dependencies { compile 'com.android.support:appcompat-v7:23.1.1' compile 'com.android.support:customtabs:23.1.1' compile 'com.android.support:design:23.1.1' - compile 'com.h6ah4i.android.materialshadowninepatch:materialshadowninepatch:0.6.5' compile 'de.greenrobot:greendao:2.0.0' compile 'org.ccil.cowan.tagsoup:tagsoup:1.2.1' } diff --git a/app/src/androidTest/java/com/hippo/ehviewer/DumpTest.java b/app/src/androidTest/java/com/hippo/ehviewer/DumpTest.java index 3aff6166e..3b311ef8e 100644 --- a/app/src/androidTest/java/com/hippo/ehviewer/DumpTest.java +++ b/app/src/androidTest/java/com/hippo/ehviewer/DumpTest.java @@ -18,6 +18,9 @@ package com.hippo.ehviewer; import junit.framework.TestCase; +import java.net.MalformedURLException; +import java.net.URL; + public class DumpTest extends TestCase { @@ -26,4 +29,22 @@ public class DumpTest extends TestCase { System.out.println(str.replaceAll("\\d+(\\.\\d+)?", "12")); } + public void testDumpURL() { + String str1 = "http://exhentai.org/?f_doujinshi=1&f_manga=0&f_artistcg=0&f_gamecg=1&f_western=1&f_non-h=1&f_imageset=0&f_cosplay=0&f_asianporn=1&f_misc=1&f_search=&f_apply=Apply+Filter"; + String str2 = "http://exhentai.org/3?f_search=hentai&f_apply=Apply+Filter"; + try { + URL url = new URL(str2); + + + System.out.println(url.getHost()); + System.out.println(url.getPath()); + System.out.println(url.getQuery()); + + + } catch (MalformedURLException e) { + e.printStackTrace(); + } + + } + } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 2ac6ea616..18ad186a0 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -33,7 +33,7 @@ android:name="com.hippo.ehviewer.ui.MainActivity" android:configChanges="screenSize|uiMode" android:theme="@style/AppTheme.Main" - android:launchMode="singleTask"> + android:launchMode="singleTop"> diff --git a/app/src/main/java/com/hippo/ehviewer/EhApplication.java b/app/src/main/java/com/hippo/ehviewer/EhApplication.java index 6666dbe7c..acec839ae 100644 --- a/app/src/main/java/com/hippo/ehviewer/EhApplication.java +++ b/app/src/main/java/com/hippo/ehviewer/EhApplication.java @@ -31,7 +31,7 @@ import com.hippo.network.StatusCodeException; import com.hippo.okhttp.CookieDB; import com.hippo.scene.SceneApplication; import com.hippo.text.Html; -import com.hippo.utils.ReadableTime; +import com.hippo.util.ReadableTime; import com.hippo.yorozuya.IntIdGenerator; import java.io.File; diff --git a/app/src/main/java/com/hippo/ehviewer/OpenUrlHelper.java b/app/src/main/java/com/hippo/ehviewer/OpenUrlHelper.java new file mode 100644 index 000000000..4c8631529 --- /dev/null +++ b/app/src/main/java/com/hippo/ehviewer/OpenUrlHelper.java @@ -0,0 +1,120 @@ +/* + * 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.app.Activity; +import android.content.Intent; +import android.content.pm.PackageManager; +import android.content.pm.ResolveInfo; +import android.net.Uri; +import android.os.Bundle; +import android.support.customtabs.CustomTabsIntent; +import android.text.TextUtils; +import android.widget.Toast; + +import com.hippo.ehviewer.client.data.ListUrlBuilder; +import com.hippo.ehviewer.client.parser.GalleryDetailUrlParser; +import com.hippo.ehviewer.client.parser.GalleryListUrlParser; +import com.hippo.ehviewer.ui.MainActivity; +import com.hippo.ehviewer.ui.scene.GalleryDetailScene; +import com.hippo.ehviewer.ui.scene.GalleryListScene; +import com.hippo.scene.StageActivity; +import com.hippo.util.CustomTabsHelper; + +public final class OpenUrlHelper { + + private OpenUrlHelper() { + } + + public static void openUrl(Activity activity, String url, boolean inApp, boolean customTabs) { + if (TextUtils.isEmpty(url)) { + return; + } + + Intent intent; + Uri uri = Uri.parse(url); + + if (inApp) { + ListUrlBuilder listUrlBuilder = GalleryListUrlParser.parse(url); + if (listUrlBuilder != null) { + Bundle args = new Bundle(); + args.putString(GalleryListScene.KEY_ACTION, GalleryListScene.ACTION_LIST_URL_BUILDER); + args.putParcelable(GalleryListScene.KEY_LIST_URL_BUILDER, listUrlBuilder); + intent = new Intent(activity, MainActivity.class); + intent.putExtra(StageActivity.KEY_SCENE_NAME, GalleryListScene.class.getName()); + intent.putExtra(StageActivity.KEY_SCENE_ARGS, args); + activity.startActivity(intent); + return; + } + + int gid = -1; + String token = null; + int page = -1; + GalleryDetailUrlParser.Result result1 = GalleryDetailUrlParser.parse(url); + if (result1 != null) { + gid = result1.gid; + token = result1.token; + } else { + /* TODO + GalleryUrlParser.Result result2 = GalleryUrlParser.parse(url); + if (result2 != null) { + gid = result2.gid; + token = result2.token; + page = result2.index; + } + */ + } + if (gid != -1 && token != null) { + Bundle args = new Bundle(); + args.putString(GalleryDetailScene.KEY_ACTION, GalleryDetailScene.ACTION_GID_TOKEN); + args.putInt(GalleryDetailScene.KEY_GID, gid); + args.putString(GalleryDetailScene.KEY_TOKEN, token); + args.putInt(GalleryDetailScene.KEY_PAGE, page); + intent = new Intent(activity, MainActivity.class); + intent.putExtra(StageActivity.KEY_SCENE_NAME, GalleryDetailScene.class.getName()); + intent.putExtra(StageActivity.KEY_SCENE_ARGS, args); + activity.startActivity(intent); + return; + } + } + + // CustomTabs + if (customTabs) { + String packageName = CustomTabsHelper.getPackageNameToUseFixed(activity); + if (packageName != null) { + new CustomTabsIntent.Builder() + .setToolbarColor(activity.getResources().getColor(R.color.colorPrimary)) + .setShowTitle(true) + .build() + .launchUrl(activity, uri); + return; + } + } + + // Intent.ACTION_VIEW + intent = new Intent(Intent.ACTION_VIEW); + intent.setData(uri); + PackageManager pm = activity.getPackageManager(); + ResolveInfo ri = pm.resolveActivity(intent, 0); + if (ri != null) { + activity.startActivity(intent); + return; + } + + Toast.makeText(activity, R.string.error_cant_find_activity, Toast.LENGTH_SHORT).show(); + } +} diff --git a/app/src/main/java/com/hippo/ehviewer/client/EhUrl.java b/app/src/main/java/com/hippo/ehviewer/client/EhUrl.java index eb43fffa2..1de9b8409 100644 --- a/app/src/main/java/com/hippo/ehviewer/client/EhUrl.java +++ b/app/src/main/java/com/hippo/ehviewer/client/EhUrl.java @@ -20,12 +20,23 @@ public class EhUrl { public static final String DOMAIN_EX = "exhentai.org"; public static final String DOMAIN_E = "e-hentai.org"; + public static final String DOMAIN_G = "g.e-hentai.org"; + public static final String DOMAIN_LOFI = "lofi.e-hentai.org"; public static final String HOST_EX = "http://" + DOMAIN_EX + "/"; public static final String API_SIGN_IN = "http://forums.e-hentai.org/index.php?act=Login&CODE=01"; public static String getGalleryDetailUrl(int gid, String token) { - return HOST_EX + "g/" + gid + '/' + token; + return getGalleryDetailUrl(gid, token, 0); + } + + public static String getGalleryDetailUrl(int gid, String token, int index) { + StringBuilder sb = new StringBuilder(HOST_EX); + sb.append("g/").append(gid).append('/').append(token); + if (index != 0) { + sb.append("/?p=").append(index); + } + return sb.toString(); } } diff --git a/app/src/main/java/com/hippo/ehviewer/client/data/ListUrlBuilder.java b/app/src/main/java/com/hippo/ehviewer/client/data/ListUrlBuilder.java index 6fcf18494..cbeb8c860 100644 --- a/app/src/main/java/com/hippo/ehviewer/client/data/ListUrlBuilder.java +++ b/app/src/main/java/com/hippo/ehviewer/client/data/ListUrlBuilder.java @@ -19,16 +19,19 @@ package com.hippo.ehviewer.client.data; import android.os.Parcel; import android.os.Parcelable; import android.support.annotation.IntDef; +import android.text.TextUtils; import com.hippo.ehviewer.client.EhConfig; import com.hippo.ehviewer.client.EhUrl; import com.hippo.ehviewer.client.EhUtils; import com.hippo.ehviewer.widget.AdvanceSearchTable; import com.hippo.network.UrlBuilder; +import com.hippo.yorozuya.StringUtils; import java.io.UnsupportedEncodingException; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; +import java.net.URLDecoder; import java.net.URLEncoder; public class ListUrlBuilder implements Cloneable, Parcelable { @@ -144,16 +147,149 @@ public class ListUrlBuilder implements Cloneable, Parcelable { mMinRating = lub.mMinRating; } - /* - public void set(QuickSearch quickSearch) { - mMode = quickSearch.mode; - mPageIndex = 0; - mCategory = quickSearch.category; - mKeyword = quickSearch.keyword; - mAdvanceSearch = quickSearch.advancedSearch; - mMinRating = quickSearch.minRating; + /** + * @param query xxx=yyy&mmm=nnn + */ + // TODO page + public void setQuery(String query) { + reset(); + + if (TextUtils.isEmpty(query)) { + return; + } + + String[] querys = StringUtils.split(query, '&'); + boolean apply = false; + int category = 0; + String keyword = null; + boolean enableAdvanceSearch = false; + int advanceSearch = 0; + boolean enableMinRating = false; + int minRating = 0; + for (int i = 0, size = querys.length; i < size; i++) { + String str = querys[i]; + int index = str.indexOf('='); + if (index < 0) { + continue; + } + String key = str.substring(0, index); + String value = str.substring(index + 1); + if ("f_doujinshi".equals(key)) { + if ("1".equals(value)) { + category |= EhConfig.DOUJINSHI; + } + } else if ("f_manga".equals(key)) { + if ("1".equals(value)) { + category |= EhConfig.MANGA; + } + } else if ("f_artistcg".equals(key)) { + if ("1".equals(value)) { + category |= EhConfig.ARTIST_CG; + } + } else if ("f_gamecg".equals(key)) { + if ("1".equals(value)) { + category |= EhConfig.GAME_CG; + } + } else if ("f_western".equals(key)) { + if ("1".equals(value)) { + category |= EhConfig.WESTERN; + } + } else if ("f_non-h".equals(key)) { + if ("1".equals(value)) { + category |= EhConfig.NON_H; + } + } else if ("f_imageset".equals(key)) { + if ("1".equals(value)) { + category |= EhConfig.IMAGE_SET; + } + } else if ("f_cosplay".equals(key)) { + if ("1".equals(value)) { + category |= EhConfig.COSPLAY; + } + } else if ("f_asianporn".equals(key)) { + if ("1".equals(value)) { + category |= EhConfig.ASIAN_PORN; + } + } else if ("f_misc".equals(key)) { + if ("1".equals(value)) { + category |= EhConfig.MISC; + } + } else if ("f_search".equals(key)) { + try { + keyword = URLDecoder.decode(value, "utf-8"); + } catch (UnsupportedEncodingException e) { + // Ignore + } + } else if ("advsearch".equals(key)) { + if ("1".equals(value)) { + enableAdvanceSearch = true; + } + } else if ("f_sname".equals(key)) { + if ("on".equals(value)) { + advanceSearch |= AdvanceSearchTable.SNAME; + } + } else if ("f_stags".equals(key)) { + if ("on".equals(value)) { + advanceSearch |= AdvanceSearchTable.STAGS; + } + } else if ("f_sdesc".equals(key)) { + if ("on".equals(value)) { + advanceSearch |= AdvanceSearchTable.SDESC; + } + } else if ("f_storr".equals(key)) { + if ("on".equals(value)) { + advanceSearch |= AdvanceSearchTable.STORR; + } + } else if ("f_sto".equals(key)) { + if ("on".equals(value)) { + advanceSearch |= AdvanceSearchTable.STO; + } + } else if ("f_sdt1".equals(key)) { + if ("on".equals(value)) { + advanceSearch |= AdvanceSearchTable.SDT1; + } + } else if ("f_sdt2".equals(key)) { + if ("on".equals(value)) { + advanceSearch |= AdvanceSearchTable.SDT2; + } + } else if ("f_sh".equals(key)) { + if ("on".equals(value)) { + advanceSearch |= AdvanceSearchTable.SH; + } + } else if ("f_sr".equals(key)) { + if ("on".equals(value)) { + enableMinRating = true; + } + } else if ("f_srdd".equals(key)) { + try { + minRating = Integer.parseInt(value); + } catch (NumberFormatException e) { + // Ignore + } + } else if ("f_apply".equals(key)) { + if ("Apply+Filter".equals(value)) { + apply = true; + } + } + } + + if (!apply) { + return; + } + + mCategory = category; + mKeyword = keyword; + if (enableAdvanceSearch) { + mAdvanceSearch = advanceSearch; + if (enableMinRating) { + mMinRating = minRating; + } else { + mMinRating = -1; + } + } else { + mAdvanceSearch = -1; + } } - */ public String build() { switch (mMode) { @@ -220,6 +356,7 @@ public class ListUrlBuilder implements Cloneable, Parcelable { } catch (UnsupportedEncodingException e) { // Empty } + sb.append('/').append(mPageIndex); return sb.toString(); } } diff --git a/app/src/main/java/com/hippo/ehviewer/client/parser/GalleryDetailParser.java b/app/src/main/java/com/hippo/ehviewer/client/parser/GalleryDetailParser.java index 8ef97576b..ff033a2d7 100644 --- a/app/src/main/java/com/hippo/ehviewer/client/parser/GalleryDetailParser.java +++ b/app/src/main/java/com/hippo/ehviewer/client/parser/GalleryDetailParser.java @@ -257,7 +257,7 @@ public class GalleryDetailParser { LargePreviewSet largePreviewSet = new LargePreviewSet(); while (m.find()) { - largePreviewSet.addItem(ParserUtils.parseInt(m.group(2)), + largePreviewSet.addItem(ParserUtils.parseInt(m.group(2)) - 1, ParserUtils.trim(m.group(3)), ParserUtils.trim(m.group(1))); } return largePreviewSet; diff --git a/app/src/main/java/com/hippo/ehviewer/client/parser/GalleryDetailUrlParser.java b/app/src/main/java/com/hippo/ehviewer/client/parser/GalleryDetailUrlParser.java index bb9d48777..51c631166 100644 --- a/app/src/main/java/com/hippo/ehviewer/client/parser/GalleryDetailUrlParser.java +++ b/app/src/main/java/com/hippo/ehviewer/client/parser/GalleryDetailUrlParser.java @@ -16,14 +16,21 @@ package com.hippo.ehviewer.client.parser; +import com.hippo.ehviewer.client.EhUrl; + import java.util.regex.Matcher; import java.util.regex.Pattern; -public class GalleryDetailUrlParser { +/** + * Like http://exhentai.org/g/1234567/a1b2c3d4e5
+ * + */ +public final class GalleryDetailUrlParser { - public static final Pattern URL_PATTERN = Pattern.compile("/(\\d+)/(\\w+)"); + public static final Pattern URL_PATTERN = Pattern.compile("http://(?:" + + EhUrl.DOMAIN_EX + "|" + EhUrl.DOMAIN_G + "|" + EhUrl.DOMAIN_LOFI + ")/g/(\\d+)/(\\w+)"); - public static Result parser(String url) { + public static Result parse(String url) { if (url == null) { return null; } diff --git a/app/src/main/java/com/hippo/ehviewer/client/parser/GalleryListUrlParser.java b/app/src/main/java/com/hippo/ehviewer/client/parser/GalleryListUrlParser.java new file mode 100644 index 000000000..2bae677cd --- /dev/null +++ b/app/src/main/java/com/hippo/ehviewer/client/parser/GalleryListUrlParser.java @@ -0,0 +1,135 @@ +/* + * 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.client.parser; + +import android.text.TextUtils; + +import com.hippo.ehviewer.client.EhUrl; +import com.hippo.ehviewer.client.EhUtils; +import com.hippo.ehviewer.client.data.ListUrlBuilder; +import com.hippo.yorozuya.Utilities; + +import java.io.UnsupportedEncodingException; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLDecoder; + +public final class GalleryListUrlParser { + + private static final String[] INVALID_HOSTS = {EhUrl.DOMAIN_EX, EhUrl.DOMAIN_G, EhUrl.DOMAIN_LOFI}; + + private static final String PATH_NORMAL = "/"; + private static final String PATH_UPLOADER = "/uploader/"; + private static final String PATH_TAG = "/tag/"; + + public static ListUrlBuilder parse(String urlStr) { + URL url; + try { + url = new URL(urlStr); + } catch (MalformedURLException e) { + return null; + } + + if (!Utilities.contain(INVALID_HOSTS, url.getHost())) { + return null; + } + + String path = url.getPath(); + if (path == null) { + return null; + } + if (PATH_NORMAL.equals(path) || path.length() == 0) { + ListUrlBuilder builder = new ListUrlBuilder(); + builder.setQuery(url.getQuery()); + return builder; + } else if (path.startsWith(PATH_UPLOADER)) { + return parseUploader(path); + } else if (path.startsWith(PATH_TAG)) { + return parseTag(path); + } else if (path.startsWith("/")) { + int category; + try { + category = Integer.parseInt(path.substring(1)); + } catch (NumberFormatException e) { + return null; + } + ListUrlBuilder builder = new ListUrlBuilder(); + builder.setQuery(url.getQuery()); + builder.setCategory(category); + return builder; + } else { + return null; + } + } + + // TODO get page + private static ListUrlBuilder parseUploader(String path) { + String uploader; + int prefixLength = PATH_UPLOADER.length(); + int index = path.indexOf('/', prefixLength); + + if (index < 0) { + uploader = path.substring(prefixLength); + } else { + uploader = path.substring(prefixLength, index); + } + + try { + uploader = URLDecoder.decode(uploader, "utf-8"); + } catch (UnsupportedEncodingException e) { + return null; + } + + if (TextUtils.isEmpty(uploader)) { + return null; + } + + ListUrlBuilder builder = new ListUrlBuilder(); + builder.setMode(ListUrlBuilder.MODE_UPLOADER); + builder.setKeyword(EhUtils.getSpecifyUploaderKeyword(uploader)); + return builder; + } + + // TODO get page + private static ListUrlBuilder parseTag(String path) { + String tag; + int prefixLength = PATH_TAG.length(); + int index = path.indexOf('/', prefixLength); + + + if (index < 0) { + tag = path.substring(prefixLength); + } else { + tag = path.substring(prefixLength, index); + } + + try { + tag = URLDecoder.decode(tag, "utf-8"); + } catch (UnsupportedEncodingException e) { + return null; + } + + if (TextUtils.isEmpty(tag)) { + return null; + } + + ListUrlBuilder builder = new ListUrlBuilder(); + builder.setMode(ListUrlBuilder.MODE_TAG); + builder.setKeyword(tag); + return builder; + } +} diff --git a/app/src/main/java/com/hippo/ehviewer/client/parser/GalleryUrlParser.java b/app/src/main/java/com/hippo/ehviewer/client/parser/GalleryUrlParser.java new file mode 100644 index 000000000..074cf8133 --- /dev/null +++ b/app/src/main/java/com/hippo/ehviewer/client/parser/GalleryUrlParser.java @@ -0,0 +1,54 @@ +/* + * 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.client.parser; + +import com.hippo.ehviewer.client.EhUrl; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * Like http://exhentai.org/s/91ea4b6d89/901103-12 + */ +public final class GalleryUrlParser { + + public static final Pattern URL_PATTERN = Pattern.compile("http://(?:" + + EhUrl.DOMAIN_EX + "|" + EhUrl.DOMAIN_G + "|" + EhUrl.DOMAIN_LOFI + ")/s/(\\w+)/(\\d+)-(\\d+)"); + + public static Result parse(String url) { + if (url == null) { + return null; + } + + Matcher m = URL_PATTERN.matcher(url); + if (m.find()) { + Result result = new Result(); + result.gid = Integer.parseInt(m.group(2)); + result.token = m.group(1); + result.index = Integer.parseInt(m.group(3)) - 1; + return result; + } else { + return null; + } + } + + public static class Result { + public int gid; + public String token; + public int index; + } +} diff --git a/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryCommentsScene.java b/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryCommentsScene.java index a107fc919..7e799ab47 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryCommentsScene.java +++ b/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryCommentsScene.java @@ -38,9 +38,9 @@ import com.hippo.ehviewer.client.data.GalleryComment; import com.hippo.rippleold.RippleSalon; import com.hippo.text.Html; import com.hippo.text.URLImageGetter; -import com.hippo.utils.OpenUrlHelper; -import com.hippo.utils.ReadableTime; -import com.hippo.utils.TextUrl; +import com.hippo.ehviewer.OpenUrlHelper; +import com.hippo.util.ReadableTime; +import com.hippo.util.TextUrl; import com.hippo.vector.VectorDrawable; import com.hippo.widget.LinkifyTextView; import com.hippo.yorozuya.LayoutUtils; @@ -141,7 +141,7 @@ public final class GalleryCommentsScene extends ToolbarScene commentHolder.comment.clearCurrentSpan(); if (span instanceof URLSpan) { - OpenUrlHelper.openUrl(getContext(), ((URLSpan) span).getURL(), true); + OpenUrlHelper.openUrl(getActivity(), ((URLSpan) span).getURL(), true, true); return true; } } 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 bf3663576..e6764efcd 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 @@ -35,6 +35,7 @@ import android.widget.ScrollView; import android.widget.TextView; import com.hippo.ehviewer.EhApplication; +import com.hippo.ehviewer.OpenUrlHelper; import com.hippo.ehviewer.R; import com.hippo.ehviewer.client.EhCacheKeyFactory; import com.hippo.ehviewer.client.EhClient; @@ -52,9 +53,9 @@ import com.hippo.scene.SceneFragment; import com.hippo.scene.StageActivity; import com.hippo.text.Html; import com.hippo.text.URLImageGetter; -import com.hippo.utils.ApiHelper; -import com.hippo.utils.ExceptionUtils; -import com.hippo.utils.ReadableTime; +import com.hippo.util.ApiHelper; +import com.hippo.util.ExceptionUtils; +import com.hippo.util.ReadableTime; import com.hippo.vector.AnimatedVectorDrawable; import com.hippo.vector.VectorDrawable; import com.hippo.widget.AutoWrapLayout; @@ -74,6 +75,7 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene public static final String KEY_GALLERY_INFO = "gallery_info"; public static final String KEY_GID = "gid"; public static final String KEY_TOKEN = "token"; + public static final String KEY_PAGE = "page"; private static final String KEY_GALLERY_DETAIL = "gallery_detail"; private static final String KEY_REQUEST_ID = "request_id"; @@ -638,7 +640,7 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene LoadImageView image = (LoadImageView) view.findViewById(R.id.image); image.load(EhCacheKeyFactory.getLargePreviewKey(gd.gid, index), imageUrl, true); TextView text = (TextView) view.findViewById(R.id.text); - text.setText(String.format(Locale.US, "%d", index)); + text.setText(String.format(Locale.US, "%d", index + 1)); } } @@ -711,7 +713,10 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene public boolean onMenuItemClick(MenuItem item) { switch (item.getItemId()) { case R.id.action_open_in_other_app: - // TODO + String url = getGalleryDetailUrl(); + if (url != null) { + OpenUrlHelper.openUrl(getActivity(), url, false, false); + } break; } return true; diff --git a/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryListScene.java b/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryListScene.java index 2ea5401d3..9f2a78bb9 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryListScene.java +++ b/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryListScene.java @@ -69,7 +69,7 @@ import com.hippo.scene.SceneApplication; import com.hippo.scene.SceneFragment; import com.hippo.scene.StageActivity; import com.hippo.scene.TransitionHelper; -import com.hippo.utils.ApiHelper; +import com.hippo.util.ApiHelper; import com.hippo.vector.VectorDrawable; import com.hippo.view.ViewTransition; import com.hippo.widget.ContentLayout; @@ -171,6 +171,7 @@ public final class GalleryListScene extends BaseScene onUpdateUrlBuilder(); mHelper.refresh(); setState(STATE_NORMAL); + mSearchBarMoveHelper.showSearchBar(); } @Override diff --git a/app/src/main/java/com/hippo/ehviewer/ui/scene/LoginScene.java b/app/src/main/java/com/hippo/ehviewer/ui/scene/LoginScene.java index f5542ab36..011bb311f 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/scene/LoginScene.java +++ b/app/src/main/java/com/hippo/ehviewer/ui/scene/LoginScene.java @@ -41,8 +41,7 @@ import com.hippo.ehviewer.client.EhClient; import com.hippo.ehviewer.client.EhCookieStore; import com.hippo.ehviewer.client.EhRequest; import com.hippo.rippleold.RippleSalon; -import com.hippo.utils.ExceptionUtils; -import com.hippo.widget.CardButton; +import com.hippo.util.ExceptionUtils; public final class LoginScene extends BaseScene implements EditText.OnEditorActionListener, View.OnClickListener { @@ -52,8 +51,8 @@ public final class LoginScene extends BaseScene implements EditText.OnEditorActi private TextInputLayout mPasswordLayout; private EditText mUsername; private EditText mPassword; - private CardButton mRegister; - private CardButton mSignIn; + private View mRegister; + private View mSignIn; private TextView mSignInViaWebview; private TextView mSignInViaCookies; private TextView mSkipSigningIn; @@ -88,8 +87,8 @@ public final class LoginScene extends BaseScene implements EditText.OnEditorActi mUsername = mUsernameLayout.getEditText(); mPasswordLayout = (TextInputLayout) loginForm.findViewById(R.id.password_layout); mPassword = mPasswordLayout.getEditText(); - mRegister = (CardButton) loginForm.findViewById(R.id.register); - mSignIn = (CardButton) loginForm.findViewById(R.id.sign_in); + mRegister = loginForm.findViewById(R.id.register); + mSignIn = loginForm.findViewById(R.id.sign_in); mSignInViaWebview = (TextView) loginForm.findViewById(R.id.sign_in_via_webview); mSignInViaCookies = (TextView) loginForm.findViewById(R.id.sign_in_via_cookies); mSkipSigningIn = (TextView) loginForm.findViewById(R.id.skip_signing_in); @@ -106,10 +105,8 @@ public final class LoginScene extends BaseScene implements EditText.OnEditorActi mSignInViaCookies.setOnClickListener(this); mSkipSigningIn.setOnClickListener(this); - mRegister.setRawBackgroundDrawable( - RippleSalon.generateRippleDrawable(true, mRegister.getBackground())); - mSignIn.setRawBackgroundDrawable( - RippleSalon.generateRippleDrawable(true, mSignIn.getBackground())); + RippleSalon.addRipple(mRegister, true); + RippleSalon.addRipple(mSignIn, true); return view; } diff --git a/app/src/main/java/com/hippo/ehviewer/ui/scene/WarningScene.java b/app/src/main/java/com/hippo/ehviewer/ui/scene/WarningScene.java index eb6fcd1a2..35871ec8c 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/scene/WarningScene.java +++ b/app/src/main/java/com/hippo/ehviewer/ui/scene/WarningScene.java @@ -28,13 +28,12 @@ import com.hippo.ehviewer.Settings; import com.hippo.ehviewer.client.EhUtils; import com.hippo.rippleold.RippleSalon; import com.hippo.vector.VectorDrawable; -import com.hippo.widget.CardButton; import com.hippo.widget.SimpleImageView; public final class WarningScene extends BaseScene implements View.OnClickListener { - private CardButton mCancel; - private CardButton mOk; + private View mCancel; + private View mOk; @Nullable @Override @@ -43,8 +42,8 @@ public final class WarningScene extends BaseScene implements View.OnClickListene View view = inflater.inflate(R.layout.scene_warning, container, false); SimpleImageView alert = (SimpleImageView) view.findViewById(R.id.icon_alert); - mCancel = (CardButton) view.findViewById(R.id.cancel); - mOk = (CardButton) view.findViewById(R.id.ok); + mCancel = view.findViewById(R.id.cancel); + mOk = view.findViewById(R.id.ok); Drawable drawable = VectorDrawable.create(getContext(), R.drawable.ic_alert); alert.setDrawable(drawable); @@ -52,10 +51,8 @@ public final class WarningScene extends BaseScene implements View.OnClickListene mCancel.setOnClickListener(this); mOk.setOnClickListener(this); - mCancel.setRawBackgroundDrawable( - RippleSalon.generateRippleDrawable(true, mCancel.getBackground())); - mOk.setRawBackgroundDrawable( - RippleSalon.generateRippleDrawable(true, mOk.getBackground())); + RippleSalon.addRipple(mCancel, true); + RippleSalon.addRipple(mOk, true); return view; } 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 538f29bc7..d7547e84e 100644 --- a/app/src/main/java/com/hippo/ehviewer/widget/SearchBar.java +++ b/app/src/main/java/com/hippo/ehviewer/widget/SearchBar.java @@ -37,11 +37,11 @@ import android.view.inputmethod.EditorInfo; import android.view.inputmethod.InputMethodManager; import android.widget.AdapterView; import android.widget.ArrayAdapter; +import android.widget.FrameLayout; import android.widget.ListView; import android.widget.TextView; import com.hippo.anani.SimpleAnimatorListener; -import com.hippo.cardsalon.CardView; import com.hippo.ehviewer.R; import com.hippo.view.ViewTransition; import com.hippo.widget.SimpleImageView; @@ -52,7 +52,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; -public class SearchBar extends CardView implements View.OnClickListener, +public class SearchBar extends FrameLayout implements View.OnClickListener, TextView.OnEditorActionListener, TextWatcher, SearchEditText.SearchEditTextListener { @@ -108,6 +108,8 @@ public class SearchBar extends CardView implements View.OnClickListener, } private void init(Context context) { + setBackgroundResource(R.drawable.card_white_2dp); + mSearchDatabase = SearchDatabase.getInstance(getContext()); LayoutInflater inflater = LayoutInflater.from(context); diff --git a/app/src/main/java/com/hippo/utils/ActivityHelper.java b/app/src/main/java/com/hippo/util/ActivityHelper.java similarity index 98% rename from app/src/main/java/com/hippo/utils/ActivityHelper.java rename to app/src/main/java/com/hippo/util/ActivityHelper.java index 2763cdcda..b5ba70bab 100644 --- a/app/src/main/java/com/hippo/utils/ActivityHelper.java +++ b/app/src/main/java/com/hippo/util/ActivityHelper.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.hippo.utils; +package com.hippo.util; import android.app.Activity; import android.content.ActivityNotFoundException; diff --git a/app/src/main/java/com/hippo/utils/ApiHelper.java b/app/src/main/java/com/hippo/util/ApiHelper.java similarity index 96% rename from app/src/main/java/com/hippo/utils/ApiHelper.java rename to app/src/main/java/com/hippo/util/ApiHelper.java index 990e86d2d..4d9d42eae 100644 --- a/app/src/main/java/com/hippo/utils/ApiHelper.java +++ b/app/src/main/java/com/hippo/util/ApiHelper.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.hippo.utils; +package com.hippo.util; import android.os.Build; diff --git a/app/src/main/java/com/hippo/utils/CustomTabsHelper.java b/app/src/main/java/com/hippo/util/CustomTabsHelper.java similarity index 99% rename from app/src/main/java/com/hippo/utils/CustomTabsHelper.java rename to app/src/main/java/com/hippo/util/CustomTabsHelper.java index 4186ebf6a..5378004b1 100644 --- a/app/src/main/java/com/hippo/utils/CustomTabsHelper.java +++ b/app/src/main/java/com/hippo/util/CustomTabsHelper.java @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package com.hippo.utils; +package com.hippo.util; import android.content.Context; import android.content.Intent; diff --git a/app/src/main/java/com/hippo/utils/ExceptionUtils.java b/app/src/main/java/com/hippo/util/ExceptionUtils.java similarity index 98% rename from app/src/main/java/com/hippo/utils/ExceptionUtils.java rename to app/src/main/java/com/hippo/util/ExceptionUtils.java index fac3215e1..72f5b7c36 100644 --- a/app/src/main/java/com/hippo/utils/ExceptionUtils.java +++ b/app/src/main/java/com/hippo/util/ExceptionUtils.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.hippo.utils; +package com.hippo.util; import android.content.Context; diff --git a/app/src/main/java/com/hippo/utils/ReadableTime.java b/app/src/main/java/com/hippo/util/ReadableTime.java similarity index 99% rename from app/src/main/java/com/hippo/utils/ReadableTime.java rename to app/src/main/java/com/hippo/util/ReadableTime.java index 469a08142..7c63a698a 100644 --- a/app/src/main/java/com/hippo/utils/ReadableTime.java +++ b/app/src/main/java/com/hippo/util/ReadableTime.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.hippo.utils; +package com.hippo.util; import android.content.Context; import android.content.res.Resources; diff --git a/app/src/main/java/com/hippo/utils/TextUrl.java b/app/src/main/java/com/hippo/util/TextUrl.java similarity index 98% rename from app/src/main/java/com/hippo/utils/TextUrl.java rename to app/src/main/java/com/hippo/util/TextUrl.java index 20bd9c854..f9461dae9 100644 --- a/app/src/main/java/com/hippo/utils/TextUrl.java +++ b/app/src/main/java/com/hippo/util/TextUrl.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.hippo.utils; +package com.hippo.util; import android.text.Spannable; import android.text.SpannableString; diff --git a/app/src/main/java/com/hippo/utils/OpenUrlHelper.java b/app/src/main/java/com/hippo/utils/OpenUrlHelper.java deleted file mode 100644 index 653dde214..000000000 --- a/app/src/main/java/com/hippo/utils/OpenUrlHelper.java +++ /dev/null @@ -1,97 +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.utils; - -import android.app.Activity; -import android.content.Context; -import android.content.Intent; -import android.content.pm.PackageManager; -import android.content.pm.ResolveInfo; -import android.net.Uri; -import android.support.customtabs.CustomTabsIntent; -import android.text.TextUtils; - -import com.hippo.ehviewer.R; - -public final class OpenUrlHelper { - - private OpenUrlHelper() { - } - - public static void openUrl(Context context, String url, boolean checkNMB) { - if (TextUtils.isEmpty(url)) { - return; - } - - Intent intent; - Uri uri = Uri.parse(url); - - /* - // Is nmb url - if (checkNMB) { - NMBUriParser.PostResult result = NMBUriParser.parsePostUri(uri); - if (result.site != null && result.id != null) { - intent = new Intent(context, PostActivity.class); - intent.setAction(PostActivity.ACTION_SITE_ID); - intent.putExtra(PostActivity.KEY_SITE, result.site.getId()); - intent.putExtra(PostActivity.KEY_ID, result.id); - if (!(context instanceof Activity)) { - intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - } - context.startActivity(intent); - return; - } - } - */ - - // CustomTabs - if (context instanceof Activity) { - String packageName = CustomTabsHelper.getPackageNameToUseFixed(context); - if (packageName != null) { - new CustomTabsIntent.Builder() - .setToolbarColor(context.getResources().getColor(R.color.colorPrimary)) - .setShowTitle(true) - .build() - .launchUrl((Activity) context, uri); - return; - } - } - - // Intent.ACTION_VIEW - intent = new Intent(Intent.ACTION_VIEW); - intent.setData(uri); - PackageManager pm = context.getPackageManager(); - ResolveInfo ri = pm.resolveActivity(intent, 0); - if (ri != null) { - if (!(context instanceof Activity)) { - intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - } - context.startActivity(intent); - return; - } - - /* - // Use WebViewActivity - intent = new Intent(context, WebViewActivity.class); - intent.putExtra(WebViewActivity.KEY_URL, url); - if (!(context instanceof Activity)) { - intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - } - context.startActivity(intent); - */ - } -} diff --git a/app/src/main/java/com/hippo/widget/CardButton.java b/app/src/main/java/com/hippo/widget/CardButton.java deleted file mode 100644 index 4572cc298..000000000 --- a/app/src/main/java/com/hippo/widget/CardButton.java +++ /dev/null @@ -1,109 +0,0 @@ -package com.hippo.widget; - -import android.content.Context; -import android.content.res.ColorStateList; -import android.graphics.drawable.Drawable; -import android.util.AttributeSet; -import android.widget.Button; - -import com.hippo.cardsalon.CardHelper; -import com.hippo.cardsalon.CardViewDelegate; - -public class CardButton extends Button implements CardViewDelegate { - - private CardHelper mCardHelper; - - public CardButton(Context context) { - super(context); - init(context, null); - } - - public CardButton(Context context, AttributeSet attrs) { - super(context, attrs); - init(context, attrs); - } - - public CardButton(Context context, AttributeSet attrs, int defStyleAttr) { - super(context, attrs, defStyleAttr); - init(context, attrs); - } - - private void init(Context context, AttributeSet attrs) { - mCardHelper = new CardHelper(this); - mCardHelper.initialize(context, attrs); - } - - @Override - public void setBackgroundResource(int resid) { - // Empty - } - - @SuppressWarnings("deprecation") - @Override - public void setBackgroundDrawable(Drawable drawable) { - // Empty - } - - @Override - public void setCardPadding(int left, int top, int right, int bottom) { - if (mCardHelper != null) { - mCardHelper.setPadding(left, top, right, bottom); - } - } - - @SuppressWarnings("deprecation") - @Override - public void setRawBackgroundDrawable(Drawable drawable) { - super.setBackgroundDrawable(drawable); - } - - @Override - public void setCardRadius(float radius) { - mCardHelper.setCardRadius(radius); - } - - @Override - public float getCardRadius() { - return mCardHelper.getCardRadius(); - } - - @Override - public void setCardBackgroundColor(ColorStateList color) { - mCardHelper.setCardBackgroundColor(color); - } - - @Override - public ColorStateList getCardBackgroundColor() { - return mCardHelper.getCardBackgroundColor(); - } - - @Override - public void setCardBoundSize(float size) { - mCardHelper.setCardBoundSize(size); - } - - @Override - public float getCardBoundSize() { - return mCardHelper.getCardBoundSize(); - } - - @Override - public void setCardBoundColor(ColorStateList color) { - mCardHelper.setCardBoundColor(color); - } - - @Override - public ColorStateList getCardBoundColor() { - return mCardHelper.getCardBoundColor(); - } - - @Override - public void setCardElevation(float elevation) { - mCardHelper.setCardElevation(elevation); - } - - @Override - public float getCardElevation() { - return mCardHelper.getCardElevation(); - } -} diff --git a/app/src/main/java/com/hippo/widget/CardLinearLayout.java b/app/src/main/java/com/hippo/widget/CardLinearLayout.java deleted file mode 100644 index 3059d829c..000000000 --- a/app/src/main/java/com/hippo/widget/CardLinearLayout.java +++ /dev/null @@ -1,109 +0,0 @@ -package com.hippo.widget; - -import android.content.Context; -import android.content.res.ColorStateList; -import android.graphics.drawable.Drawable; -import android.util.AttributeSet; -import android.widget.LinearLayout; - -import com.hippo.cardsalon.CardHelper; -import com.hippo.cardsalon.CardViewDelegate; - -public class CardLinearLayout extends LinearLayout implements CardViewDelegate { - - private CardHelper mCardHelper; - - public CardLinearLayout(Context context) { - super(context); - init(context, null); - } - - public CardLinearLayout(Context context, AttributeSet attrs) { - super(context, attrs); - init(context, attrs); - } - - public CardLinearLayout(Context context, AttributeSet attrs, int defStyleAttr) { - super(context, attrs, defStyleAttr); - init(context, attrs); - } - - private void init(Context context, AttributeSet attrs) { - mCardHelper = new CardHelper(this); - mCardHelper.initialize(context, attrs); - } - - @Override - public void setBackgroundResource(int resid) { - // Empty - } - - @SuppressWarnings("deprecation") - @Override - public void setBackgroundDrawable(Drawable drawable) { - // Empty - } - - @Override - public void setCardPadding(int left, int top, int right, int bottom) { - if (mCardHelper != null) { - mCardHelper.setPadding(left, top, right, bottom); - } - } - - @SuppressWarnings("deprecation") - @Override - public void setRawBackgroundDrawable(Drawable drawable) { - super.setBackgroundDrawable(drawable); - } - - @Override - public void setCardRadius(float radius) { - mCardHelper.setCardRadius(radius); - } - - @Override - public float getCardRadius() { - return mCardHelper.getCardRadius(); - } - - @Override - public void setCardBackgroundColor(ColorStateList color) { - mCardHelper.setCardBackgroundColor(color); - } - - @Override - public ColorStateList getCardBackgroundColor() { - return mCardHelper.getCardBackgroundColor(); - } - - @Override - public void setCardBoundSize(float size) { - mCardHelper.setCardBoundSize(size); - } - - @Override - public float getCardBoundSize() { - return mCardHelper.getCardBoundSize(); - } - - @Override - public void setCardBoundColor(ColorStateList color) { - mCardHelper.setCardBoundColor(color); - } - - @Override - public ColorStateList getCardBoundColor() { - return mCardHelper.getCardBoundColor(); - } - - @Override - public void setCardElevation(float elevation) { - mCardHelper.setCardElevation(elevation); - } - - @Override - public float getCardElevation() { - return mCardHelper.getCardElevation(); - } -} diff --git a/app/src/main/java/com/hippo/widget/CardRelativeLayout.java b/app/src/main/java/com/hippo/widget/CardRelativeLayout.java deleted file mode 100644 index 2490647d7..000000000 --- a/app/src/main/java/com/hippo/widget/CardRelativeLayout.java +++ /dev/null @@ -1,125 +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.widget; - -import android.content.Context; -import android.content.res.ColorStateList; -import android.graphics.drawable.Drawable; -import android.util.AttributeSet; -import android.widget.RelativeLayout; - -import com.hippo.cardsalon.CardHelper; -import com.hippo.cardsalon.CardViewDelegate; - -public class CardRelativeLayout extends RelativeLayout implements CardViewDelegate { - - private CardHelper mCardHelper; - - public CardRelativeLayout(Context context) { - super(context); - init(context, null); - } - - public CardRelativeLayout(Context context, AttributeSet attrs) { - super(context, attrs); - init(context, attrs); - } - - public CardRelativeLayout(Context context, AttributeSet attrs, int defStyleAttr) { - super(context, attrs, defStyleAttr); - init(context, attrs); - } - - private void init(Context context, AttributeSet attrs) { - mCardHelper = new CardHelper(this); - mCardHelper.initialize(context, attrs); - } - - @Override - public void setBackgroundResource(int resid) { - // Empty - } - - @SuppressWarnings("deprecation") - @Override - public void setBackgroundDrawable(Drawable drawable) { - // Empty - } - - @Override - public void setCardPadding(int left, int top, int right, int bottom) { - if (mCardHelper != null) { - mCardHelper.setPadding(left, top, right, bottom); - } - } - - @SuppressWarnings("deprecation") - @Override - public void setRawBackgroundDrawable(Drawable drawable) { - super.setBackgroundDrawable(drawable); - } - - @Override - public void setCardRadius(float radius) { - mCardHelper.setCardRadius(radius); - } - - @Override - public float getCardRadius() { - return mCardHelper.getCardRadius(); - } - - @Override - public void setCardBackgroundColor(ColorStateList color) { - mCardHelper.setCardBackgroundColor(color); - } - - @Override - public ColorStateList getCardBackgroundColor() { - return mCardHelper.getCardBackgroundColor(); - } - - @Override - public void setCardBoundSize(float size) { - mCardHelper.setCardBoundSize(size); - } - - @Override - public float getCardBoundSize() { - return mCardHelper.getCardBoundSize(); - } - - @Override - public void setCardBoundColor(ColorStateList color) { - mCardHelper.setCardBoundColor(color); - } - - @Override - public ColorStateList getCardBoundColor() { - return mCardHelper.getCardBoundColor(); - } - - @Override - public void setCardElevation(float elevation) { - mCardHelper.setCardElevation(elevation); - } - - @Override - public float getCardElevation() { - return mCardHelper.getCardElevation(); - } -} diff --git a/app/src/main/java/com/hippo/widget/ContentLayout.java b/app/src/main/java/com/hippo/widget/ContentLayout.java index 7f3185887..5e829fa21 100644 --- a/app/src/main/java/com/hippo/widget/ContentLayout.java +++ b/app/src/main/java/com/hippo/widget/ContentLayout.java @@ -34,7 +34,7 @@ import com.hippo.easyrecyclerview.FastScroller; import com.hippo.easyrecyclerview.HandlerDrawable; import com.hippo.easyrecyclerview.LayoutManagerUtils; import com.hippo.ehviewer.R; -import com.hippo.utils.ExceptionUtils; +import com.hippo.util.ExceptionUtils; import com.hippo.vector.VectorDrawable; import com.hippo.view.ViewTransition; import com.hippo.widget.refreshlayout.RefreshLayout; diff --git a/app/src/main/res/layout/gallery_detail_header.xml b/app/src/main/res/layout/gallery_detail_header.xml index 2768409c3..17c8c987a 100644 --- a/app/src/main/res/layout/gallery_detail_header.xml +++ b/app/src/main/res/layout/gallery_detail_header.xml @@ -119,16 +119,14 @@ - + android:background="@drawable/card_white_2dp"> - + diff --git a/app/src/main/res/layout/item_gallery_list.xml b/app/src/main/res/layout/item_gallery_list.xml index 6c8ccfc97..d7223473a 100644 --- a/app/src/main/res/layout/item_gallery_list.xml +++ b/app/src/main/res/layout/item_gallery_list.xml @@ -14,88 +14,79 @@ ~ limitations under the License. --> - + android:background="@drawable/card_white_2dp"> - + + + android:layout_alignParentTop="true" + android:layout_marginLeft="8dp" + android:layout_marginRight="8dp" + android:layout_marginTop="4dp" + android:layout_toRightOf="@id/thumb"/> - + - + - + - + - + - - - - - - + diff --git a/app/src/main/res/layout/scene_gallery_list.xml b/app/src/main/res/layout/scene_gallery_list.xml index ace2af9f5..5096f17a6 100644 --- a/app/src/main/res/layout/scene_gallery_list.xml +++ b/app/src/main/res/layout/scene_gallery_list.xml @@ -46,8 +46,7 @@ android:layout_height="wrap_content" android:layout_marginLeft="@dimen/list_search_bar_margin" android:layout_marginRight="@dimen/list_search_bar_margin" - android:layout_marginTop="8dp" - app:forceNoElevation="true"/> + android:layout_marginTop="8dp"/> - + android:background="@drawable/card_purple_2dp"/> - + android:background="@drawable/card_teal_2dp"/> diff --git a/app/src/main/res/layout/scene_warning.xml b/app/src/main/res/layout/scene_warning.xml index 051c7e8ec..ec181b557 100644 --- a/app/src/main/res/layout/scene_warning.xml +++ b/app/src/main/res/layout/scene_warning.xml @@ -56,15 +56,13 @@ - - - + android:background="@drawable/card_purple_2dp"/> - + android:background="@drawable/card_teal_2dp"/> diff --git a/app/src/main/res/layout/search_category.xml b/app/src/main/res/layout/search_category.xml index 6e7bd2e04..247102693 100644 --- a/app/src/main/res/layout/search_category.xml +++ b/app/src/main/res/layout/search_category.xml @@ -14,13 +14,11 @@ ~ limitations under the License. --> - + android:background="@drawable/card_white_2dp"> + android:paddingBottom="@dimen/search_category_padding_v"> - - + diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 6eab96eb4..fceb9c17b 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -43,7 +43,8 @@