diff --git a/app/src/main/java/com/hippo/ehviewer/Settings.java b/app/src/main/java/com/hippo/ehviewer/Settings.java index 4ec3eed7a..129abfb0a 100644 --- a/app/src/main/java/com/hippo/ehviewer/Settings.java +++ b/app/src/main/java/com/hippo/ehviewer/Settings.java @@ -209,6 +209,17 @@ public class Settings { putBoolean(KEY_NEED_SIGN_IN, value); } + private static final String KEY_SELECT_SITE = "select_site"; + private static final boolean DEFAULT_SELECT_SITE = true; + + public static boolean getSelectSite() { + return getBoolean(KEY_SELECT_SITE, DEFAULT_SELECT_SITE); + } + + public static void putSelectSite(boolean value) { + putBoolean(KEY_SELECT_SITE, value); + } + /******************** ****** Eh ********************/ diff --git a/app/src/main/java/com/hippo/ehviewer/ui/MainActivity.java b/app/src/main/java/com/hippo/ehviewer/ui/MainActivity.java index 6beb1ae7f..8eb2e44bf 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/MainActivity.java +++ b/app/src/main/java/com/hippo/ehviewer/ui/MainActivity.java @@ -58,6 +58,7 @@ import com.hippo.ehviewer.ui.scene.GalleryPreviewsScene; import com.hippo.ehviewer.ui.scene.HistoryScene; import com.hippo.ehviewer.ui.scene.ProgressScene; import com.hippo.ehviewer.ui.scene.QuickSearchScene; +import com.hippo.ehviewer.ui.scene.SelectSiteScene; import com.hippo.ehviewer.ui.scene.SignInScene; import com.hippo.ehviewer.ui.scene.WarningScene; import com.hippo.ehviewer.ui.scene.WebViewSignInScene; @@ -83,6 +84,7 @@ public final class MainActivity extends StageActivity public static final int CHECK_STEP_ANALYTICS = 1; public static final int CHECK_STEP_CRASH = 2; public static final int CHECK_STEP_SIGN_IN = 3; + public static final int CHECK_STEP_SELECT_SITE = 4; public static final String KEY_TARGET_SCENE = "target_scene"; public static final String KEY_TARGET_ARGS = "target_args"; @@ -110,6 +112,7 @@ public final class MainActivity extends StageActivity registerLaunchMode(SignInScene.class, SceneFragment.LAUNCH_MODE_SINGLE_TASK); registerLaunchMode(WebViewSignInScene.class, SceneFragment.LAUNCH_MODE_SINGLE_TASK); registerLaunchMode(CookieSignInScene.class, SceneFragment.LAUNCH_MODE_SINGLE_TASK); + registerLaunchMode(SelectSiteScene.class, SceneFragment.LAUNCH_MODE_SINGLE_TASK); registerLaunchMode(GalleryListScene.class, SceneFragment.LAUNCH_MODE_SINGLE_TOP); registerLaunchMode(QuickSearchScene.class, SceneFragment.LAUNCH_MODE_SINGLE_TASK); registerLaunchMode(GalleryDetailScene.class, SceneFragment.LAUNCH_MODE_STANDARD); @@ -141,6 +144,11 @@ public final class MainActivity extends StageActivity break; } case CHECK_STEP_SIGN_IN: + if (Settings.getSelectSite()) { + startScene(new Announcer(SelectSiteScene.class).setArgs(args)); + break; + } + case CHECK_STEP_SELECT_SITE: String targetScene = null; Bundle targetArgs = null; if (null != args) { @@ -184,6 +192,8 @@ public final class MainActivity extends StageActivity return new Announcer(CrashScene.class); } else if (EhUtils.needSignedIn(this)) { return new Announcer(SignInScene.class); + } else if (Settings.getSelectSite()) { + return new Announcer(SelectSiteScene.class); } else { Bundle args = new Bundle(); args.putString(GalleryListScene.KEY_ACTION, GalleryListScene.ACTION_HOMEPAGE); @@ -214,6 +224,11 @@ public final class MainActivity extends StageActivity newArgs.putString(KEY_TARGET_SCENE, announcer.getClazz().getName()); newArgs.putBundle(KEY_TARGET_ARGS, announcer.getArgs()); return new Announcer(SignInScene.class).setArgs(newArgs); + } else if (Settings.getSelectSite()) { + Bundle newArgs = new Bundle(); + newArgs.putString(KEY_TARGET_SCENE, announcer.getClazz().getName()); + newArgs.putBundle(KEY_TARGET_ARGS, announcer.getArgs()); + return new Announcer(SelectSiteScene.class).setArgs(newArgs); } } return announcer; diff --git a/app/src/main/java/com/hippo/ehviewer/ui/scene/SelectSiteScene.java b/app/src/main/java/com/hippo/ehviewer/ui/scene/SelectSiteScene.java new file mode 100644 index 000000000..9f209e700 --- /dev/null +++ b/app/src/main/java/com/hippo/ehviewer/ui/scene/SelectSiteScene.java @@ -0,0 +1,93 @@ +/* + * 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.ui.scene; + +import android.os.Bundle; +import android.support.annotation.Nullable; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.RadioGroup; +import android.widget.Toast; + +import com.hippo.ehviewer.R; +import com.hippo.ehviewer.Settings; +import com.hippo.ehviewer.client.EhUrl; +import com.hippo.ehviewer.ui.MainActivity; +import com.hippo.yorozuya.ViewUtils; + +public class SelectSiteScene extends BaseScene implements View.OnClickListener { + + private RadioGroup mRadioGroup; + private View mOk; + + @Override + public boolean needShowLeftDrawer() { + return false; + } + + @Nullable + @Override + public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, + @Nullable Bundle savedInstanceState) { + View view = inflater.inflate(R.layout.scene_select_site, container, false); + + mRadioGroup = (RadioGroup) ViewUtils.$$(view, R.id.radio_group); + mOk = ViewUtils.$$(view, R.id.ok); + + mOk.setOnClickListener(this); + + return view; + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + + mRadioGroup = null; + mOk = null; + } + + @Override + public void onClick(View v) { + MainActivity activity = getActivity2(); + if (null == activity || null == mRadioGroup) { + return; + } + + if (v == mOk) { + int id = mRadioGroup.getCheckedRadioButtonId(); + switch (id) { + case R.id.site_e: + Settings.putSelectSite(false); + Settings.putGallerySite(EhUrl.SITE_G); + activity.startSceneForCheckStep(MainActivity.CHECK_STEP_SELECT_SITE, getArguments()); + finish(); + break; + case R.id.site_ex: + Settings.putSelectSite(false); + Settings.putGallerySite(EhUrl.SITE_EX); + activity.startSceneForCheckStep(MainActivity.CHECK_STEP_SELECT_SITE, getArguments()); + finish(); + break; + default: + Toast.makeText(activity, R.string.no_select, Toast.LENGTH_SHORT).show(); + break; + } + } + } +} diff --git a/app/src/main/res/layout/scene_select_site.xml b/app/src/main/res/layout/scene_select_site.xml new file mode 100644 index 000000000..45da49e3e --- /dev/null +++ b/app/src/main/res/layout/scene_select_site.xml @@ -0,0 +1,93 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/scene_warning.xml b/app/src/main/res/layout/scene_warning.xml index 5473e2deb..6150faa7d 100644 --- a/app/src/main/res/layout/scene_warning.xml +++ b/app/src/main/res/layout/scene_warning.xml @@ -31,7 +31,6 @@ app:srcCompat="@drawable/v_alert_red_x48"/> diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index 4cf93ff7a..82bf1e3d6 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -88,6 +88,11 @@ 发送 上次应用崩溃了。你愿意把错误日志发送给开发者以便以后得到更好的用户体验?(以电子邮件的形式发送) + + 你想选择哪个画廊站点? + e-hentai:对任何人开放\nexhentai:仅对登陆用户开放 + 请选择一个站点 + 更新 版本:%1$s\n大小:%2$s\n\n%3$s diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index 69e4e2fb6..da0dce821 100644 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -88,6 +88,11 @@ 發送 上次應用崩潰了。你願意把錯誤日誌發送給開發者以便以後得到更好的用户體驗?(以電子郵件的形式發送) + + 你想選擇哪個畫廊站點? + e-hentai:對任何人開放\nexhentai:僅對登陸用户開放 + 請選擇一個站點 + 更新 版本:%1$s\n大小:%2$s\n\n%3$s diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index 49098f9f4..33b448cd7 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -88,6 +88,11 @@ 傳送 上次應用崩潰了。你願意把錯誤日誌傳送給開發者以便以後得到更好的使用者體驗?(以電子郵件的形式傳送) + + 你想選擇哪個畫廊站點? + e-hentai:對任何人開放\nexhentai:僅對登陸使用者開放 + 請選擇一個站點 + 更新 版本:%1$s\n大小:%2$s\n\n%3$s diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index 1e4fc64f7..95d7a1c49 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -28,8 +28,8 @@ - e-hentai - exhentai + @string/site_e + @string/site_ex diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 68380f8a3..28f1b6afc 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -19,6 +19,9 @@ EhViewer + e-hentai + exhentai + DOUJINSHI MANGA @@ -127,6 +130,11 @@ Send This application crashed last time. Would you mind to send logcat to the developer for a better user experience in future ? (via e-mail) + + Which gallery site do you want to select? + e-hentai: available for anyone\nexhentai: available for who signed in + Please select one site + Update Version: %1$s\nSize: %2$s\n\n%3$s