Add cellular network warning
This commit is contained in:
1 parent
981598dc70
commit
d07dc49dc7
8 files changed
+66
No files matched your search
@@ -412,6 +412,13 @@ public class Settings {
|
||||
putString(KEY_HATH_PASSKEY, value);
|
||||
}
|
||||
|
||||
private static final String KEY_CELLULAR_NETWORK_WARNING = "cellular_network_warning";
|
||||
private static final boolean DEFAULT_CELLULAR_NETWORK_WARNING = false;
|
||||
|
||||
public static boolean getCellularNetworkWarning() {
|
||||
return getBoolean(KEY_CELLULAR_NETWORK_WARNING, DEFAULT_CELLULAR_NETWORK_WARNING);
|
||||
}
|
||||
|
||||
/********************
|
||||
****** Read
|
||||
********************/
|
||||
|
||||
@@ -20,6 +20,7 @@ import android.Manifest;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Bitmap;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
@@ -70,6 +71,7 @@ import com.hippo.ehviewer.ui.scene.WarningScene;
|
||||
import com.hippo.ehviewer.ui.scene.WebViewSignInScene;
|
||||
import com.hippo.ehviewer.widget.EhDrawerLayout;
|
||||
import com.hippo.io.UniFileInputStreamPipe;
|
||||
import com.hippo.network.Network;
|
||||
import com.hippo.scene.Announcer;
|
||||
import com.hippo.scene.SceneFragment;
|
||||
import com.hippo.scene.StageActivity;
|
||||
@@ -392,6 +394,9 @@ public final class MainActivity extends StageActivity
|
||||
onInit();
|
||||
CommonOperations.checkUpdate(this, false);
|
||||
checkDownloadLocation();
|
||||
if (Settings.getCellularNetworkWarning()) {
|
||||
checkCellularNetwork();
|
||||
}
|
||||
} else {
|
||||
onRestore(savedInstanceState);
|
||||
}
|
||||
@@ -410,6 +415,12 @@ public final class MainActivity extends StageActivity
|
||||
.show();
|
||||
}
|
||||
|
||||
private void checkCellularNetwork() {
|
||||
if (Network.getActiveNetworkType(this) == ConnectivityManager.TYPE_MOBILE) {
|
||||
showTip(R.string.cellular_network_warning, BaseScene.LENGTH_SHORT);
|
||||
}
|
||||
}
|
||||
|
||||
private void onInit() {
|
||||
// Check permission
|
||||
PermissionRequester.request(this, Manifest.permission.WRITE_EXTERNAL_STORAGE,
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (C) 2014 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.network;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
|
||||
public final class Network {
|
||||
private Network() {}
|
||||
|
||||
public static int getActiveNetworkType(Context context) {
|
||||
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
|
||||
if (activeNetwork != null) {
|
||||
return activeNetwork.getType();
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -50,6 +50,8 @@
|
||||
|
||||
<string name="invalid_download_location">似乎下载路径不可用。请到重新设置下载路径。</string>
|
||||
|
||||
<string name="cellular_network_warning">正在使用移动网络</string>
|
||||
|
||||
<string name="error_bad_status_code">错误的状态码:%d</string>
|
||||
<string name="error_timeout">超时</string>
|
||||
<string name="error_unknown_host">未知主机</string>
|
||||
@@ -385,6 +387,7 @@
|
||||
<string name="settings_eh_show_jpn_title_summary_off">显示默认标题。一般是英文标题</string>
|
||||
<string name="settings_eh_filter">过滤</string>
|
||||
<string name="settings_eh_filter_summary">过滤标题,上传者,标签和标签组</string>
|
||||
<string name="settings_eh_cellular_network_warning">移动网络警告</string>
|
||||
|
||||
<string name="settings_read">阅读</string>
|
||||
<string name="settings_read_screen_rotation">屏幕方向</string>
|
||||
|
||||
@@ -385,6 +385,7 @@
|
||||
<string name="settings_eh_show_jpn_title_summary_off">顯示默認標題。一般是英文標題</string>
|
||||
<string name="settings_eh_filter">過濾</string>
|
||||
<string name="settings_eh_filter_summary">過濾標題,上傳者,標籤和標籤組</string>
|
||||
<string name="settings_eh_cellular_network_warning">移動網絡警告</string>
|
||||
|
||||
<string name="settings_read">閲讀</string>
|
||||
<string name="settings_read_screen_rotation">屏幕方向</string>
|
||||
|
||||
@@ -385,6 +385,7 @@
|
||||
<string name="settings_eh_show_jpn_title_summary_off">顯示預設標題。一般是英文標題</string>
|
||||
<string name="settings_eh_filter">過濾</string>
|
||||
<string name="settings_eh_filter_summary">過濾標題,上傳者,標籤和標籤組</string>
|
||||
<string name="settings_eh_cellular_network_warning">行動網路警告</string>
|
||||
|
||||
<string name="settings_read">閱讀</string>
|
||||
<string name="settings_read_screen_rotation">螢幕方向</string>
|
||||
|
||||
@@ -66,6 +66,8 @@
|
||||
|
||||
<string name="invalid_download_location">It seems download location is not available. Please set it in Settings.</string>
|
||||
|
||||
<string name="cellular_network_warning">Connected to cellular networks</string>
|
||||
|
||||
<string name="error_status_code_400" translatable="false">Bad Request</string>
|
||||
<string name="error_status_code_401" translatable="false">Unauthorized</string>
|
||||
<string name="error_status_code_402" translatable="false">Payment Required</string>
|
||||
@@ -427,6 +429,7 @@
|
||||
<string name="settings_eh_show_jpn_title_summary_off">Show default title. It is usually English title</string>
|
||||
<string name="settings_eh_filter">Filter</string>
|
||||
<string name="settings_eh_filter_summary">Filter by title, uploader, tag and tag namespace</string>
|
||||
<string name="settings_eh_cellular_network_warning">Cellular network warning</string>
|
||||
|
||||
<string name="settings_read">Read</string>
|
||||
<string name="settings_read_screen_rotation">Screen orientation</string>
|
||||
|
||||
@@ -97,4 +97,9 @@
|
||||
android:summary="@string/settings_eh_filter_summary"
|
||||
app:activity="com.hippo.ehviewer.ui.FilterActivity"/>
|
||||
|
||||
<com.hippo.preference.SwitchPreference
|
||||
android:key="cellular_network_warning"
|
||||
android:title="@string/settings_eh_cellular_network_warning"
|
||||
android:defaultValue="false"/>
|
||||
|
||||
</PreferenceScreen>
|
||||
Reference in new issue
Block a user