├── .idea
├── .name
├── copyright
│ └── profiles_settings.xml
├── encodings.xml
├── vcs.xml
├── modules.xml
├── runConfigurations.xml
├── gradle.xml
├── compiler.xml
└── misc.xml
├── app
├── .gitignore
├── src
│ └── main
│ │ ├── logo-web.png
│ │ ├── res
│ │ ├── app_icon.png
│ │ ├── travel_1.png
│ │ ├── travel_4.png
│ │ ├── drawable
│ │ │ ├── app_icon.png
│ │ │ ├── build_1.png
│ │ │ ├── build_4.png
│ │ │ ├── make_1.png
│ │ │ ├── make_4.png
│ │ │ ├── repair_1.png
│ │ │ ├── repair_4.png
│ │ │ ├── travel_1.png
│ │ │ └── travel_4.png
│ │ ├── drawable-hdpi
│ │ │ └── logo.png
│ │ ├── drawable-mdpi
│ │ │ └── logo.png
│ │ ├── drawable-xhdpi
│ │ │ └── logo.png
│ │ ├── drawable-xxhdpi
│ │ │ └── logo.png
│ │ ├── xml
│ │ │ ├── pref_shared_empty.xml
│ │ │ ├── pref_shared_top.xml
│ │ │ ├── widget__main_info.xml
│ │ │ ├── widget__make_info.xml
│ │ │ ├── widget__build_info.xml
│ │ │ ├── widget__repair_info.xml
│ │ │ ├── widget__travel_info.xml
│ │ │ ├── pref_part_main_other.xml
│ │ │ ├── pref_part_sync.xml
│ │ │ ├── pref_shared_bot.xml
│ │ │ ├── pref_part_customize.xml
│ │ │ ├── pref_part_black.xml
│ │ │ ├── pref_part_general.xml
│ │ │ ├── pref_part_main_settings.xml
│ │ │ └── pref_part_notification.xml
│ │ ├── values
│ │ │ ├── styles.xml
│ │ │ ├── colors.xml
│ │ │ ├── dimens.xml
│ │ │ ├── strings_activity_settings.xml
│ │ │ ├── strings.xml
│ │ │ └── strings_pref_values.xml
│ │ ├── values-v14
│ │ │ └── dimens.xml
│ │ ├── values-w820dp
│ │ │ └── dimens.xml
│ │ ├── menu
│ │ │ └── menu_settings_info.xml
│ │ └── layout
│ │ │ ├── pref_shared_toolbar.xml
│ │ │ ├── double_time_preference.xml
│ │ │ ├── widget__main.xml
│ │ │ ├── widget__make.xml
│ │ │ ├── widget__build.xml
│ │ │ ├── widget__repair.xml
│ │ │ └── widget__travel.xml
│ │ ├── java
│ │ └── me
│ │ │ └── crafter
│ │ │ └── android
│ │ │ └── zjsnviewer
│ │ │ ├── State.java
│ │ │ ├── ScreenReceiver.java
│ │ │ ├── Widget_Make.java
│ │ │ ├── Widget_Repair.java
│ │ │ ├── Widget_Travel.java
│ │ │ ├── Widget_Build.java
│ │ │ ├── NotificationSender.java
│ │ │ ├── Widget_Main.java
│ │ │ ├── SettingsNotification.java
│ │ │ ├── SettingsSync.java
│ │ │ ├── SettingsGeneral.java
│ │ │ ├── SettingsCustomize.java
│ │ │ ├── ZjsnViewer.java
│ │ │ ├── SettingsActivity.java
│ │ │ ├── TimerService.java
│ │ │ ├── DoubleTimePreference.java
│ │ │ ├── Storage.java
│ │ │ ├── SettingsBlack.java
│ │ │ ├── Worker.java
│ │ │ ├── DockInfo.java
│ │ │ └── NetworkManager.java
│ │ └── AndroidManifest.xml
├── proguard-rules.pro
├── build.gradle
├── manifest-merger-release-report.txt
└── app.iml
├── settings.gradle
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .gitignore
├── README.md
├── gradle.properties
├── ZjsnViewer.iml
├── gradlew.bat
└── gradlew
/.idea/.name:
--------------------------------------------------------------------------------
1 | ZjsnViewer
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/app/src/main/logo-web.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/connection-lost/ZjsnViewer/HEAD/app/src/main/logo-web.png
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/app/src/main/res/app_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/connection-lost/ZjsnViewer/HEAD/app/src/main/res/app_icon.png
--------------------------------------------------------------------------------
/app/src/main/res/travel_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/connection-lost/ZjsnViewer/HEAD/app/src/main/res/travel_1.png
--------------------------------------------------------------------------------
/app/src/main/res/travel_4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/connection-lost/ZjsnViewer/HEAD/app/src/main/res/travel_4.png
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/connection-lost/ZjsnViewer/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/app/src/main/res/drawable/app_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/connection-lost/ZjsnViewer/HEAD/app/src/main/res/drawable/app_icon.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/build_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/connection-lost/ZjsnViewer/HEAD/app/src/main/res/drawable/build_1.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/build_4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/connection-lost/ZjsnViewer/HEAD/app/src/main/res/drawable/build_4.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/make_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/connection-lost/ZjsnViewer/HEAD/app/src/main/res/drawable/make_1.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/make_4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/connection-lost/ZjsnViewer/HEAD/app/src/main/res/drawable/make_4.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/repair_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/connection-lost/ZjsnViewer/HEAD/app/src/main/res/drawable/repair_1.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/repair_4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/connection-lost/ZjsnViewer/HEAD/app/src/main/res/drawable/repair_4.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/travel_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/connection-lost/ZjsnViewer/HEAD/app/src/main/res/drawable/travel_1.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/travel_4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/connection-lost/ZjsnViewer/HEAD/app/src/main/res/drawable/travel_4.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/connection-lost/ZjsnViewer/HEAD/app/src/main/res/drawable-hdpi/logo.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/connection-lost/ZjsnViewer/HEAD/app/src/main/res/drawable-mdpi/logo.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/connection-lost/ZjsnViewer/HEAD/app/src/main/res/drawable-xhdpi/logo.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/connection-lost/ZjsnViewer/HEAD/app/src/main/res/drawable-xxhdpi/logo.png
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .gradle
2 | /local.properties
3 | /.idea/workspace.xml
4 | /.idea/libraries
5 | .DS_Store
6 | /build
7 | WeatherGuard.*
8 | Encrypt.java
9 | .dropbpx.attr
10 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/pref_shared_empty.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/java/me/crafter/android/zjsnviewer/State.java:
--------------------------------------------------------------------------------
1 | package me.crafter.android.zjsnviewer;
2 |
3 | public enum State {
4 | DEFAULT, UNKNOWN, INTERRUPT, CONNECTION_FAIL, NO_INTERNET, CONNECTION_RESET, PARSE_ERROR, NO_UPDATE_FOUND, UPDATE_FOUND;
5 | }
6 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Apr 10 15:27:10 PDT 2013
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values-v14/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
8 | 0dp
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | #fafafa
5 | #070707
6 |
7 | #070707
8 | #fafafa
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/pref_shared_top.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_settings_info.xml:
--------------------------------------------------------------------------------
1 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
8 | 8dp
9 | 12dp
10 | 12dp
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/widget__main_info.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/widget__make_info.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/widget__build_info.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/widget__repair_info.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/widget__travel_info.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # ZjsnViewer
2 | by Tidu no JB
3 |
4 | ### 写在前面
5 | 本github repo为战舰少女Viewer最初起源。目前战舰少女Viewer已经不再更新,但是有其他非本人的后期更新修改版可以使用。
6 |
7 | ZjsnViewer, or Warship Girls Viewer, is a helper app designed for Warship Girls.
8 | http://zj.p7game.com/
9 |
10 | For more information please visit release page.
11 | http://www.crafter.me/zjsnviewer/
12 |
13 | Inspired by KancolleViewer
14 | http://grabacr.net/kancolleviewer
15 |
16 | Special thanks to:
17 |
18 | 萨拉托加
19 |
20 | 玄学统计局
21 |
22 | 黑喵
23 |
24 | 神秘大神 (https://github.com/warshipgirl)
25 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/pref_part_main_other.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
9 |
10 |
11 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/pref_shared_toolbar.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/pref_part_sync.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
6 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in D:\Users\Frank\AppData\Local\Android\sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 23
5 | buildToolsVersion "21.1.2"
6 |
7 | defaultConfig {
8 | applicationId "me.crafter.android.zjsnviewer"
9 | minSdkVersion 16
10 | targetSdkVersion 23
11 | versionCode 26
12 | versionName "2.6 - G"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(dir: 'libs', include: ['*.jar'])
24 | compile 'com.android.support:appcompat-v7:23.1.1'
25 | compile 'com.android.support:support-v4:23.1.1'
26 | }
27 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/app/src/main/java/me/crafter/android/zjsnviewer/ScreenReceiver.java:
--------------------------------------------------------------------------------
1 | package me.crafter.android.zjsnviewer;
2 |
3 | import android.content.BroadcastReceiver;
4 | import android.content.Context;
5 | import android.content.Intent;
6 | import android.util.Log;
7 |
8 | public class ScreenReceiver extends BroadcastReceiver {
9 | public ScreenReceiver() {
10 | }
11 |
12 | @Override
13 | public void onReceive(Context context, Intent intent) {
14 | if (intent.getAction().equals(Intent.ACTION_SCREEN_ON)){
15 | Widget_Main.updateWidget(context);
16 | Widget_Travel.updateWidget(context);
17 | Widget_Repair.updateWidget(context);
18 | Widget_Build.updateWidget(context);
19 | Widget_Make.updateWidget(context);
20 | }
21 | }
22 |
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
--------------------------------------------------------------------------------
/app/src/main/res/xml/pref_shared_bot.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
10 |
13 |
16 |
17 |
18 |
21 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/ZjsnViewer.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/pref_part_customize.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
11 |
12 |
20 |
21 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings_activity_settings.xml:
--------------------------------------------------------------------------------
1 |
2 | ZjsnViewer Settings
3 | 战舰少女Viewer设置
4 |
5 | 各种设定
6 | 账户设置
7 | 更新设定
8 | 通知设定
9 | 自定义
10 | 其他
11 | 黑科技
12 |
13 | 用户名/密码/服务器
14 | 远征/入渠/建造结束通知
15 | 挂件刷新时间
16 | 字体大小/显示方式
17 | 其他
18 |
19 | 关于
20 | 战舰少女Viewer 2.6 by 提督の機霸\n©2014–2015 crafter.me
21 | 2.6
22 | 26
23 | Master Switch
24 | silent
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/pref_part_black.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
9 |
14 |
15 |
24 |
25 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/pref_part_general.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
11 |
12 |
18 |
19 |
21 |
22 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/pref_part_main_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
12 |
14 |
15 |
16 |
20 |
22 |
23 |
24 |
28 |
30 |
31 |
32 |
36 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/double_time_preference.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
13 |
20 |
21 |
26 |
27 |
34 |
35 |
40 |
41 |
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/widget__main.xml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
23 |
24 |
36 |
37 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/pref_part_notification.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
9 |
14 |
15 |
16 |
21 |
22 |
23 |
28 |
29 |
30 |
35 |
36 |
42 |
43 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/app/src/main/java/me/crafter/android/zjsnviewer/Widget_Make.java:
--------------------------------------------------------------------------------
1 | package me.crafter.android.zjsnviewer;
2 |
3 | import android.appwidget.AppWidgetManager;
4 | import android.appwidget.AppWidgetProvider;
5 | import android.content.ComponentName;
6 | import android.content.Context;
7 | import android.content.Intent;
8 | import android.os.Bundle;
9 | import android.util.Log;
10 | import android.util.TypedValue;
11 | import android.widget.RemoteViews;
12 |
13 |
14 | /**
15 | * Implementation of App Widget functionality.
16 | */
17 | public class Widget_Make extends AppWidgetProvider {
18 |
19 | @Override
20 | public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
21 | context.startService(new Intent(context, TimerService.class));
22 | updateWidget(context, appWidgetManager);
23 | }
24 |
25 |
26 | @Override
27 | public void onEnabled(Context context) {
28 | context.startService(new Intent(context, TimerService.class));
29 | }
30 |
31 | @Override
32 | public void onDisabled(Context context) {
33 |
34 | }
35 |
36 | @Override
37 | public void onAppWidgetOptionsChanged(Context context, AppWidgetManager appWidgetManager, int appWidgetId, Bundle newOptions) {
38 | context.startService(new Intent(context, TimerService.class));
39 | }
40 |
41 | public static void updateWidget(Context context){
42 | updateWidget(context, AppWidgetManager.getInstance(context));
43 | }
44 |
45 | public static void updateWidget(Context context, AppWidgetManager appWidgetManager) {
46 | //Log.i("Widget_Make", "updateWidget()");
47 | RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget__make);
48 | String[] info = DockInfo.getMakeBoard();
49 | views.setTextViewText(R.id.textView1, info[0]);
50 | views.setTextViewText(R.id.textView2, info[1]);
51 | views.setTextViewText(R.id.textView3, info[2]);
52 | views.setTextViewText(R.id.textView4, info[3]);
53 | Worker.widgetSetTextSize(context, views);
54 | appWidgetManager.updateAppWidget(new ComponentName(context, Widget_Make.class), views);
55 | }
56 | }
57 |
58 |
59 |
--------------------------------------------------------------------------------
/app/src/main/java/me/crafter/android/zjsnviewer/Widget_Repair.java:
--------------------------------------------------------------------------------
1 | package me.crafter.android.zjsnviewer;
2 |
3 | import android.appwidget.AppWidgetManager;
4 | import android.appwidget.AppWidgetProvider;
5 | import android.content.ComponentName;
6 | import android.content.Context;
7 | import android.content.Intent;
8 | import android.os.Bundle;
9 | import android.util.Log;
10 | import android.util.TypedValue;
11 | import android.widget.RemoteViews;
12 |
13 |
14 | /**
15 | * Implementation of App Widget functionality.
16 | */
17 | public class Widget_Repair extends AppWidgetProvider {
18 |
19 | @Override
20 | public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
21 | context.startService(new Intent(context, TimerService.class));
22 | updateWidget(context, appWidgetManager);
23 | }
24 |
25 |
26 | @Override
27 | public void onEnabled(Context context) {
28 | context.startService(new Intent(context, TimerService.class));
29 | }
30 |
31 | @Override
32 | public void onDisabled(Context context) {
33 |
34 | }
35 |
36 | @Override
37 | public void onAppWidgetOptionsChanged(Context context, AppWidgetManager appWidgetManager, int appWidgetId, Bundle newOptions) {
38 | context.startService(new Intent(context, TimerService.class));
39 | }
40 |
41 | public static void updateWidget(Context context){
42 | updateWidget(context, AppWidgetManager.getInstance(context));
43 | }
44 |
45 | public static void updateWidget(Context context, AppWidgetManager appWidgetManager) {
46 | //Log.i("Widget_Repair", "updateWidget()");
47 | RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget__repair);
48 | String[] info = DockInfo.getRepairBoard();
49 | views.setTextViewText(R.id.textView1, info[0]);
50 | views.setTextViewText(R.id.textView2, info[1]);
51 | views.setTextViewText(R.id.textView3, info[2]);
52 | views.setTextViewText(R.id.textView4, info[3]);
53 | Worker.widgetSetTextSize(context, views);
54 | appWidgetManager.updateAppWidget(new ComponentName(context, Widget_Repair.class), views);
55 | }
56 | }
57 |
58 |
59 |
--------------------------------------------------------------------------------
/app/src/main/java/me/crafter/android/zjsnviewer/Widget_Travel.java:
--------------------------------------------------------------------------------
1 | package me.crafter.android.zjsnviewer;
2 |
3 | import android.appwidget.AppWidgetManager;
4 | import android.appwidget.AppWidgetProvider;
5 | import android.content.ComponentName;
6 | import android.content.Context;
7 | import android.content.Intent;
8 | import android.os.Bundle;
9 | import android.util.Log;
10 | import android.util.TypedValue;
11 | import android.widget.RemoteViews;
12 |
13 |
14 | /**
15 | * Implementation of App Widget functionality.
16 | */
17 | public class Widget_Travel extends AppWidgetProvider {
18 |
19 | @Override
20 | public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
21 | context.startService(new Intent(context, TimerService.class));
22 | updateWidget(context, appWidgetManager);
23 | }
24 |
25 |
26 | @Override
27 | public void onEnabled(Context context) {
28 | context.startService(new Intent(context, TimerService.class));
29 | }
30 |
31 | @Override
32 | public void onDisabled(Context context) {
33 |
34 | }
35 |
36 | @Override
37 | public void onAppWidgetOptionsChanged(Context context, AppWidgetManager appWidgetManager, int appWidgetId, Bundle newOptions) {
38 | context.startService(new Intent(context, TimerService.class));
39 | }
40 |
41 | public static void updateWidget(Context context){
42 | updateWidget(context, AppWidgetManager.getInstance(context));
43 | }
44 |
45 | public static void updateWidget(Context context, AppWidgetManager appWidgetManager) {
46 | //Log.i("Widget_Travel", "updateWidget()");
47 | RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget__travel);
48 | String[] info = DockInfo.getTravelBoard();
49 | views.setTextViewText(R.id.textView1, info[0]);
50 | views.setTextViewText(R.id.textView2, info[1]);
51 | views.setTextViewText(R.id.textView3, info[2]);
52 | views.setTextViewText(R.id.textView4, info[3]);
53 | Worker.widgetSetTextSize(context, views);
54 | appWidgetManager.updateAppWidget(new ComponentName(context, Widget_Travel.class), views);
55 | }
56 | }
57 |
58 |
59 |
--------------------------------------------------------------------------------
/app/src/main/java/me/crafter/android/zjsnviewer/Widget_Build.java:
--------------------------------------------------------------------------------
1 | package me.crafter.android.zjsnviewer;
2 |
3 | import android.app.PendingIntent;
4 | import android.appwidget.AppWidgetManager;
5 | import android.appwidget.AppWidgetProvider;
6 | import android.content.ComponentName;
7 | import android.content.Context;
8 | import android.content.Intent;
9 | import android.os.Bundle;
10 | import android.util.TypedValue;
11 | import android.widget.RemoteViews;
12 |
13 |
14 | /**
15 | * Implementation of App Widget functionality.
16 | */
17 | public class Widget_Build extends AppWidgetProvider {
18 |
19 | @Override
20 | public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
21 | context.startService(new Intent(context, TimerService.class));
22 | updateWidget(context, appWidgetManager);
23 | }
24 |
25 |
26 | @Override
27 | public void onEnabled(Context context) {
28 | context.startService(new Intent(context, TimerService.class));
29 | }
30 |
31 | @Override
32 | public void onDisabled(Context context) {
33 |
34 | }
35 |
36 | @Override
37 | public void onAppWidgetOptionsChanged(Context context, AppWidgetManager appWidgetManager, int appWidgetId, Bundle newOptions) {
38 | context.startService(new Intent(context, TimerService.class));
39 | }
40 |
41 | public static void updateWidget(Context context){
42 | updateWidget(context, AppWidgetManager.getInstance(context));
43 | }
44 |
45 | public static void updateWidget(Context context, AppWidgetManager appWidgetManager) {
46 | //Log.i("Widget_Build", "updateWidget()");
47 | RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget__build);
48 | String[] info = DockInfo.getBuildBoard();
49 | views.setTextViewText(R.id.textView1, info[0]);
50 | views.setTextViewText(R.id.textView2, info[1]);
51 | views.setTextViewText(R.id.textView3, info[2]);
52 | views.setTextViewText(R.id.textView4, info[3]);
53 | Worker.widgetSetTextSize(context, views);
54 |
55 | appWidgetManager.updateAppWidget(new ComponentName(context, Widget_Build.class), views);
56 | }
57 | }
58 |
59 |
60 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 战舰少女Viewer
5 |
6 | ZjsnViewer
7 | EXAMPLE
8 | Add widget
9 | ZjsnViewer - 修理
10 | ZjsnViewer - 远征
11 | ZjsnViewer - 建造
12 | ZjsnViewer - 开发
13 | 加载未完成
14 | 加载未完成
15 | Loading...
16 |
17 | SettingsInfo
18 | Hello world!
19 | Settings
20 | ZjsnViewer
21 |
22 |
23 |
24 | 检查更新中
25 | 网络不给力,检查失败 QwQ
26 | 无法检测更新,可能当前版本过旧
27 | 当前版本已经是最新的了
28 | 发现新版本
29 |
30 | 版本更新
31 | 战舰少女Viewer
32 | 下载中
33 | \n程序有较大的变动,建议更新
34 | 当前版本: @curr@\n最新版本: @new@\n新版本功能: \n@feature@
35 |
36 | 现在下载
37 | 下次再说
38 |
39 | 暂未开放 QwQ
40 |
41 | 黑科技有风险,使用请谨慎
42 | 请给我root权限喵~ 0w0
43 | root成功 ~\(≧▽≦)/~
44 | root失败 QwQ
45 |
46 | 确定
47 | 取消
48 |
49 |
50 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/app/src/main/java/me/crafter/android/zjsnviewer/NotificationSender.java:
--------------------------------------------------------------------------------
1 | package me.crafter.android.zjsnviewer;
2 |
3 | import android.annotation.TargetApi;
4 | import android.app.Notification;
5 | import android.app.NotificationManager;
6 | import android.app.PendingIntent;
7 | import android.content.Context;
8 | import android.content.Intent;
9 | import android.content.res.Resources;
10 | import android.graphics.Bitmap;
11 | import android.graphics.BitmapFactory;
12 | import android.net.Uri;
13 | import android.os.Build;
14 | import android.os.PowerManager;
15 | import android.support.v4.app.NotificationCompat;
16 |
17 | public class NotificationSender {
18 |
19 | private static final String NOTIFICATION_TAG = "ZjsnViewer";
20 | private static final int notificationId = 0;
21 |
22 | public static void notify(final Context context, final String title, final String text) {
23 | final Resources res = context.getResources();
24 |
25 | final Notification.Builder builder = new Notification.Builder(context)
26 | .setDefaults(Notification.DEFAULT_ALL)
27 | .setSmallIcon(R.drawable.logo)
28 | .setContentTitle(title)
29 | .setContentText(text)
30 | .setStyle(new Notification.BigTextStyle().bigText(text))
31 | .setPriority(NotificationCompat.PRIORITY_DEFAULT)
32 | .setContentIntent(Storage.getStartPendingIntent(context))
33 | .setAutoCancel(true);
34 |
35 | PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
36 | PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "ZJSN");
37 | wl.acquire(10000);
38 | notify(context, builder.build());
39 | }
40 |
41 | @TargetApi(Build.VERSION_CODES.ECLAIR)
42 | private static void notify(final Context context, final Notification notification) {
43 | final NotificationManager nm = (NotificationManager) context
44 | .getSystemService(Context.NOTIFICATION_SERVICE);
45 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ECLAIR) {
46 | nm.notify(NOTIFICATION_TAG, 0, notification);
47 | } else {
48 | nm.notify(NOTIFICATION_TAG.hashCode(), notification);
49 | }
50 | }
51 |
52 | @TargetApi(Build.VERSION_CODES.ECLAIR)
53 | public static void cancel(final Context context) {
54 | final NotificationManager nm = (NotificationManager) context
55 | .getSystemService(Context.NOTIFICATION_SERVICE);
56 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ECLAIR) {
57 | nm.cancel(NOTIFICATION_TAG, 0);
58 | } else {
59 | nm.cancel(NOTIFICATION_TAG.hashCode());
60 | }
61 | }
62 | }
--------------------------------------------------------------------------------
/app/src/main/java/me/crafter/android/zjsnviewer/Widget_Main.java:
--------------------------------------------------------------------------------
1 | package me.crafter.android.zjsnviewer;
2 |
3 | import android.app.PendingIntent;
4 | import android.appwidget.AppWidgetManager;
5 | import android.appwidget.AppWidgetProvider;
6 | import android.content.ComponentName;
7 | import android.content.Context;
8 | import android.content.Intent;
9 | import android.os.Bundle;
10 | import android.widget.RemoteViews;
11 |
12 |
13 | public class Widget_Main extends AppWidgetProvider {
14 |
15 | @Override
16 | public void onEnabled(Context context) {
17 | context.startService(new Intent(context, TimerService.class));
18 | super.onEnabled(context);
19 | //Toast.makeText(context, "启动了吔", Toast.LENGTH_SHORT).show();
20 | }
21 |
22 | @Override
23 | public void onDisabled(Context context) {
24 | super.onDisabled(context);
25 | //Toast.makeText(context, "关闭了哇", Toast.LENGTH_SHORT).show();
26 | }
27 |
28 | @Override
29 | public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds){
30 | context.startService(new Intent(context, TimerService.class));
31 | super.onUpdate(context, appWidgetManager, appWidgetIds);
32 | updateWidget(context);
33 | }
34 |
35 | @Override
36 | public void onAppWidgetOptionsChanged(Context context, AppWidgetManager appWidgetManager, int appWidgetId, Bundle newOptions){
37 | context.startService(new Intent(context, TimerService.class));
38 | //Toast.makeText(context, "啦啦啦", Toast.LENGTH_SHORT).show();
39 | updateWidget(context);
40 | }
41 |
42 |
43 | public static void updateWidget(Context context){
44 | updateWidget(context, AppWidgetManager.getInstance(context));
45 | }
46 |
47 | public static void updateWidget(Context context, AppWidgetManager appWidgetManager){
48 | //Log.i("Widget_Main", "updateWidget()");
49 | PendingIntent pending = Storage.getStartPendingIntent(context);
50 | RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget__main);
51 |
52 | views.setOnClickPendingIntent(R.id.imageButton, pending);
53 |
54 | //SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
55 | //views.setTextViewText(R.id.textView, "Last Update: " + sdf.format(new Date()));
56 | views.setTextViewText(R.id.textView2, Storage.str_tiduName);
57 | views.setTextViewText(R.id.textView, "Level: " + DockInfo.level + " (" + DockInfo.exp + "/" + DockInfo.nextExp + ")");
58 | if (DockInfo.level.equals("150")){
59 | views.setTextViewText(R.id.textView, "Level: 150 (MAX)");
60 | }
61 | Worker.mainSetTextSize(context, views);
62 | appWidgetManager.updateAppWidget(new ComponentName(context, Widget_Main.class), views);
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/app/src/main/java/me/crafter/android/zjsnviewer/SettingsNotification.java:
--------------------------------------------------------------------------------
1 | package me.crafter.android.zjsnviewer;
2 |
3 | import android.media.Ringtone;
4 | import android.media.RingtoneManager;
5 | import android.net.Uri;
6 | import android.os.Bundle;
7 | import android.preference.ListPreference;
8 | import android.preference.Preference;
9 | import android.preference.PreferenceActivity;
10 | import android.preference.PreferenceCategory;
11 | import android.preference.PreferenceManager;
12 | import android.preference.RingtonePreference;
13 | import android.support.v7.widget.Toolbar;
14 | import android.text.TextUtils;
15 | import android.view.LayoutInflater;
16 | import android.view.View;
17 | import android.widget.LinearLayout;
18 |
19 | @SuppressWarnings("deprecation")
20 | public class SettingsNotification extends PreferenceActivity {
21 |
22 | @Override
23 | protected void onPostCreate(Bundle savedInstanceState) {
24 | super.onPostCreate(savedInstanceState);
25 | setupToolBar();
26 | setupSimplePreferencesScreen();
27 | }
28 |
29 | private void setupSimplePreferencesScreen() {
30 | addPreferencesFromResource(R.xml.pref_shared_empty);
31 | // Add 'notification' preferences.
32 | PreferenceCategory fakeHeader = new PreferenceCategory(this);
33 | fakeHeader.setTitle(R.string.pref_header_notification);
34 | getPreferenceScreen().addPreference(fakeHeader);
35 | addPreferencesFromResource(R.xml.pref_part_notification);
36 | }
37 |
38 | private void setupToolBar(){
39 | LinearLayout root = (LinearLayout)findViewById(android.R.id.list).getParent().getParent().getParent();
40 | Toolbar bar = (Toolbar) LayoutInflater.from(this).inflate(R.layout.pref_shared_toolbar, root, false);
41 | root.addView(bar, 0); // insert at top
42 | bar.setNavigationOnClickListener(new View.OnClickListener() {
43 | @Override
44 | public void onClick(View v) {
45 | finish();
46 | }
47 | });
48 | }
49 | /**
50 | * A preference value change listener that updates the preference's summary
51 | * to reflect its new value.
52 | */
53 | private static Preference.OnPreferenceChangeListener sBindPreferenceSummaryToValueListener = new Preference.OnPreferenceChangeListener() {
54 | @Override
55 | public boolean onPreferenceChange(Preference preference, Object value) {
56 | String stringValue = value.toString();
57 |
58 | if (preference instanceof ListPreference) {
59 | ListPreference listPreference = (ListPreference) preference;
60 | int index = listPreference.findIndexOfValue(stringValue);
61 |
62 | preference.setSummary(index >= 0 ? listPreference.getEntries()[index] : null);
63 | }
64 | else if (preference instanceof RingtonePreference) {
65 | if (TextUtils.isEmpty(stringValue)) {
66 | preference.setSummary(R.string.pref_ringtone_silent);
67 |
68 | } else {
69 | Ringtone ringtone = RingtoneManager.getRingtone(
70 | preference.getContext(), Uri.parse(stringValue));
71 |
72 | if (ringtone == null) {
73 | preference.setSummary(null);
74 | } else {
75 | String name = ringtone.getTitle(preference.getContext());
76 | preference.setSummary(name);
77 | }
78 | }
79 | }
80 | else {
81 | preference.setSummary(stringValue);
82 | }
83 | return true;
84 | }
85 | };
86 |
87 | private static void bindPreferenceSummaryToValue(Preference preference) {
88 | preference.setOnPreferenceChangeListener(sBindPreferenceSummaryToValueListener);
89 | sBindPreferenceSummaryToValueListener.onPreferenceChange(preference,
90 | PreferenceManager
91 | .getDefaultSharedPreferences(preference.getContext())
92 | .getString(preference.getKey(), ""));
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/app/src/main/java/me/crafter/android/zjsnviewer/SettingsSync.java:
--------------------------------------------------------------------------------
1 | package me.crafter.android.zjsnviewer;
2 |
3 | import android.media.Ringtone;
4 | import android.media.RingtoneManager;
5 | import android.net.Uri;
6 | import android.os.Bundle;
7 | import android.preference.ListPreference;
8 | import android.preference.Preference;
9 | import android.preference.PreferenceActivity;
10 | import android.preference.PreferenceCategory;
11 | import android.preference.PreferenceManager;
12 | import android.preference.RingtonePreference;
13 | import android.support.v7.widget.Toolbar;
14 | import android.text.TextUtils;
15 | import android.view.LayoutInflater;
16 | import android.view.View;
17 | import android.widget.LinearLayout;
18 |
19 | @SuppressWarnings("deprecation")
20 | public class SettingsSync extends PreferenceActivity {
21 |
22 | @Override
23 | protected void onPostCreate(Bundle savedInstanceState) {
24 | super.onPostCreate(savedInstanceState);
25 | setupToolBar();
26 | setupSimplePreferencesScreen();
27 | }
28 |
29 | private void setupSimplePreferencesScreen() {
30 | addPreferencesFromResource(R.xml.pref_shared_empty);
31 | // Add 'general' preferences.
32 | PreferenceCategory fakeHeader = new PreferenceCategory(this);
33 | fakeHeader.setTitle(R.string.pref_header_data_sync);
34 | getPreferenceScreen().addPreference(fakeHeader);
35 | addPreferencesFromResource(R.xml.pref_part_sync);
36 | bindPreferenceSummaryToValue(findPreference("refresh"));
37 | }
38 |
39 | private void setupToolBar(){
40 | LinearLayout root = (LinearLayout)findViewById(android.R.id.list).getParent().getParent().getParent();
41 | Toolbar bar = (Toolbar) LayoutInflater.from(this).inflate(R.layout.pref_shared_toolbar, root, false);
42 | root.addView(bar, 0); // insert at top
43 | bar.setNavigationOnClickListener(new View.OnClickListener() {
44 | @Override
45 | public void onClick(View v) {
46 | finish();
47 | }
48 | });
49 | }
50 | /**
51 | * A preference value change listener that updates the preference's summary
52 | * to reflect its new value.
53 | */
54 | private static Preference.OnPreferenceChangeListener sBindPreferenceSummaryToValueListener = new Preference.OnPreferenceChangeListener() {
55 | @Override
56 | public boolean onPreferenceChange(Preference preference, Object value) {
57 | String stringValue = value.toString();
58 |
59 | if (preference instanceof ListPreference) {
60 | ListPreference listPreference = (ListPreference) preference;
61 | int index = listPreference.findIndexOfValue(stringValue);
62 |
63 | preference.setSummary(index >= 0 ? listPreference.getEntries()[index] : null);
64 | }
65 | else if (preference instanceof RingtonePreference) {
66 | if (TextUtils.isEmpty(stringValue)) {
67 | preference.setSummary(R.string.pref_ringtone_silent);
68 |
69 | } else {
70 | Ringtone ringtone = RingtoneManager.getRingtone(
71 | preference.getContext(), Uri.parse(stringValue));
72 |
73 | if (ringtone == null) {
74 | preference.setSummary(null);
75 | } else {
76 | String name = ringtone.getTitle(preference.getContext());
77 | preference.setSummary(name);
78 | }
79 | }
80 | }
81 | else {
82 | preference.setSummary(stringValue);
83 | }
84 | return true;
85 | }
86 | };
87 |
88 | private static void bindPreferenceSummaryToValue(Preference preference) {
89 | preference.setOnPreferenceChangeListener(sBindPreferenceSummaryToValueListener);
90 | sBindPreferenceSummaryToValueListener.onPreferenceChange(preference,
91 | PreferenceManager
92 | .getDefaultSharedPreferences(preference.getContext())
93 | .getString(preference.getKey(), ""));
94 | }
95 | }
96 |
--------------------------------------------------------------------------------
/app/src/main/java/me/crafter/android/zjsnviewer/SettingsGeneral.java:
--------------------------------------------------------------------------------
1 | package me.crafter.android.zjsnviewer;
2 |
3 | import android.media.Ringtone;
4 | import android.media.RingtoneManager;
5 | import android.net.Uri;
6 | import android.os.Bundle;
7 | import android.preference.ListPreference;
8 | import android.preference.Preference;
9 | import android.preference.PreferenceActivity;
10 | import android.preference.PreferenceCategory;
11 | import android.preference.PreferenceManager;
12 | import android.preference.RingtonePreference;
13 | import android.support.v7.widget.Toolbar;
14 | import android.text.TextUtils;
15 | import android.view.LayoutInflater;
16 | import android.view.View;
17 | import android.widget.LinearLayout;
18 |
19 | @SuppressWarnings("deprecation")
20 | public class SettingsGeneral extends PreferenceActivity {
21 |
22 | @Override
23 | protected void onPostCreate(Bundle savedInstanceState) {
24 | super.onPostCreate(savedInstanceState);
25 | setupToolBar();
26 | setupSimplePreferencesScreen();
27 | }
28 |
29 | private void setupSimplePreferencesScreen() {
30 | addPreferencesFromResource(R.xml.pref_shared_empty);
31 | // Add 'general' preferences.
32 | PreferenceCategory fakeHeader = new PreferenceCategory(this);
33 | fakeHeader.setTitle(R.string.pref_header_account);
34 | getPreferenceScreen().addPreference(fakeHeader);
35 | addPreferencesFromResource(R.xml.pref_part_general);
36 |
37 | bindPreferenceSummaryToValue(findPreference("username"));
38 | bindPreferenceSummaryToValue(findPreference("server"));
39 | }
40 |
41 | private void setupToolBar(){
42 | LinearLayout root = (LinearLayout)findViewById(android.R.id.list).getParent().getParent().getParent();
43 | Toolbar bar = (Toolbar) LayoutInflater.from(this).inflate(R.layout.pref_shared_toolbar, root, false);
44 | root.addView(bar, 0); // insert at top
45 | bar.setNavigationOnClickListener(new View.OnClickListener() {
46 | @Override
47 | public void onClick(View v) {
48 | finish();
49 | }
50 | });
51 | }
52 | /**
53 | * A preference value change listener that updates the preference's summary
54 | * to reflect its new value.
55 | */
56 | private static Preference.OnPreferenceChangeListener sBindPreferenceSummaryToValueListener = new Preference.OnPreferenceChangeListener() {
57 | @Override
58 | public boolean onPreferenceChange(Preference preference, Object value) {
59 | String stringValue = value.toString();
60 |
61 | if (preference instanceof ListPreference) {
62 | ListPreference listPreference = (ListPreference) preference;
63 | int index = listPreference.findIndexOfValue(stringValue);
64 |
65 | preference.setSummary(index >= 0 ? listPreference.getEntries()[index] : null);
66 | }
67 | else if (preference instanceof RingtonePreference) {
68 | if (TextUtils.isEmpty(stringValue)) {
69 | preference.setSummary(R.string.pref_ringtone_silent);
70 |
71 | } else {
72 | Ringtone ringtone = RingtoneManager.getRingtone(
73 | preference.getContext(), Uri.parse(stringValue));
74 |
75 | if (ringtone == null) {
76 | preference.setSummary(null);
77 | } else {
78 | String name = ringtone.getTitle(preference.getContext());
79 | preference.setSummary(name);
80 | }
81 | }
82 | }
83 | else {
84 | preference.setSummary(stringValue);
85 | }
86 | return true;
87 | }
88 | };
89 |
90 | private static void bindPreferenceSummaryToValue(Preference preference) {
91 | preference.setOnPreferenceChangeListener(sBindPreferenceSummaryToValueListener);
92 | sBindPreferenceSummaryToValueListener.onPreferenceChange(preference,
93 | PreferenceManager
94 | .getDefaultSharedPreferences(preference.getContext())
95 | .getString(preference.getKey(), ""));
96 | }
97 | }
98 |
--------------------------------------------------------------------------------
/app/src/main/java/me/crafter/android/zjsnviewer/SettingsCustomize.java:
--------------------------------------------------------------------------------
1 | package me.crafter.android.zjsnviewer;
2 |
3 | import android.media.Ringtone;
4 | import android.media.RingtoneManager;
5 | import android.net.Uri;
6 | import android.os.Bundle;
7 | import android.preference.ListPreference;
8 | import android.preference.Preference;
9 | import android.preference.PreferenceActivity;
10 | import android.preference.PreferenceCategory;
11 | import android.preference.PreferenceManager;
12 | import android.preference.RingtonePreference;
13 | import android.support.v7.widget.Toolbar;
14 | import android.text.TextUtils;
15 | import android.view.LayoutInflater;
16 | import android.view.View;
17 | import android.widget.LinearLayout;
18 |
19 | @SuppressWarnings("deprecation")
20 | public class SettingsCustomize extends PreferenceActivity {
21 |
22 | @Override
23 | protected void onPostCreate(Bundle savedInstanceState) {
24 | super.onPostCreate(savedInstanceState);
25 | setupToolBar();
26 | setupSimplePreferencesScreen();
27 | }
28 |
29 | private void setupSimplePreferencesScreen() {
30 | addPreferencesFromResource(R.xml.pref_shared_empty);
31 | // Add 'customize' preferences.
32 | PreferenceCategory fakeHeader = new PreferenceCategory(this);
33 | fakeHeader.setTitle(R.string.pref_header_customize);
34 | getPreferenceScreen().addPreference(fakeHeader);
35 | addPreferencesFromResource(R.xml.pref_part_customize);
36 | bindPreferenceSummaryToValue(findPreference("textsize_major"));
37 | bindPreferenceSummaryToValue(findPreference("textsize_minor"));
38 | bindPreferenceSummaryToValue(findPreference("language"));
39 | }
40 |
41 | private void setupToolBar(){
42 | LinearLayout root = (LinearLayout)findViewById(android.R.id.list).getParent().getParent().getParent();
43 | Toolbar bar = (Toolbar) LayoutInflater.from(this).inflate(R.layout.pref_shared_toolbar, root, false);
44 | root.addView(bar, 0); // insert at top
45 | bar.setNavigationOnClickListener(new View.OnClickListener() {
46 | @Override
47 | public void onClick(View v) {
48 | finish();
49 | }
50 | });
51 | }
52 | /**
53 | * A preference value change listener that updates the preference's summary
54 | * to reflect its new value.
55 | */
56 | private static Preference.OnPreferenceChangeListener sBindPreferenceSummaryToValueListener = new Preference.OnPreferenceChangeListener() {
57 | @Override
58 | public boolean onPreferenceChange(Preference preference, Object value) {
59 | String stringValue = value.toString();
60 |
61 | if (preference instanceof ListPreference) {
62 | ListPreference listPreference = (ListPreference) preference;
63 | int index = listPreference.findIndexOfValue(stringValue);
64 |
65 | preference.setSummary(index >= 0 ? listPreference.getEntries()[index] : null);
66 | }
67 | else if (preference instanceof RingtonePreference) {
68 | if (TextUtils.isEmpty(stringValue)) {
69 | preference.setSummary(R.string.pref_ringtone_silent);
70 |
71 | } else {
72 | Ringtone ringtone = RingtoneManager.getRingtone(
73 | preference.getContext(), Uri.parse(stringValue));
74 |
75 | if (ringtone == null) {
76 | preference.setSummary(null);
77 | } else {
78 | String name = ringtone.getTitle(preference.getContext());
79 | preference.setSummary(name);
80 | }
81 | }
82 | }
83 | else {
84 | preference.setSummary(stringValue);
85 | }
86 | return true;
87 | }
88 | };
89 |
90 | private static void bindPreferenceSummaryToValue(Preference preference) {
91 | preference.setOnPreferenceChangeListener(sBindPreferenceSummaryToValueListener);
92 | sBindPreferenceSummaryToValueListener.onPreferenceChange(preference,
93 | PreferenceManager
94 | .getDefaultSharedPreferences(preference.getContext())
95 | .getString(preference.getKey(), ""));
96 | }
97 | }
98 |
--------------------------------------------------------------------------------
/app/src/main/java/me/crafter/android/zjsnviewer/ZjsnViewer.java:
--------------------------------------------------------------------------------
1 | package me.crafter.android.zjsnviewer;
2 |
3 | import android.content.Context;
4 | import android.media.Ringtone;
5 | import android.media.RingtoneManager;
6 | import android.net.Uri;
7 | import android.os.Bundle;
8 | import android.preference.ListPreference;
9 | import android.preference.Preference;
10 | import android.preference.PreferenceActivity;
11 | import android.preference.PreferenceCategory;
12 | import android.preference.PreferenceManager;
13 | import android.preference.RingtonePreference;
14 | import android.text.TextUtils;
15 | import android.util.Log;
16 | import android.view.View;
17 | import android.widget.Toast;
18 |
19 | @SuppressWarnings("deprecation")
20 | public class ZjsnViewer extends PreferenceActivity {
21 |
22 | @Override
23 | protected void onPostCreate(Bundle savedInstanceState) {
24 | super.onPostCreate(savedInstanceState);
25 | setupSimplePreferencesScreen();
26 | registerListener(getApplicationContext());
27 | }
28 |
29 | private void setupSimplePreferencesScreen() {
30 | addPreferencesFromResource(R.xml.pref_shared_top);
31 |
32 | // Add 'main' preferences.
33 | PreferenceCategory fakeHeader = new PreferenceCategory(this);
34 | fakeHeader.setTitle(R.string.pref_header_main);
35 | getPreferenceScreen().addPreference(fakeHeader);
36 | addPreferencesFromResource(R.xml.pref_part_main_settings);
37 |
38 | // Add 'other' preferences.
39 | fakeHeader = new PreferenceCategory(this);
40 | fakeHeader.setTitle(R.string.pref_header_other);
41 | getPreferenceScreen().addPreference(fakeHeader);
42 | addPreferencesFromResource(R.xml.pref_part_main_other);
43 |
44 | // Add bottom
45 | fakeHeader = new PreferenceCategory(this);
46 | fakeHeader.setTitle(R.string.pref_header_about);
47 | getPreferenceScreen().addPreference(fakeHeader);
48 | addPreferencesFromResource(R.xml.pref_shared_bot);
49 |
50 | }
51 |
52 | // Listener
53 | private void registerListener(final Context context){
54 | findPreference("go_pref_check_update").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
55 | public boolean onPreferenceClick(Preference preference) {
56 | Worker.checkUpdate(ZjsnViewer.this, context);
57 | return true;
58 | }
59 | });
60 | }
61 |
62 | private static Preference.OnPreferenceChangeListener sBindPreferenceSummaryToValueListener = new Preference.OnPreferenceChangeListener() {
63 | @Override
64 | public boolean onPreferenceChange(Preference preference, Object value) {
65 | String stringValue = value.toString();
66 |
67 | if (preference instanceof ListPreference) {
68 | ListPreference listPreference = (ListPreference) preference;
69 | int index = listPreference.findIndexOfValue(stringValue);
70 |
71 | preference.setSummary(index >= 0 ? listPreference.getEntries()[index] : null);
72 | }
73 | else if (preference instanceof RingtonePreference) {
74 | if (TextUtils.isEmpty(stringValue)) {
75 | preference.setSummary(R.string.pref_ringtone_silent);
76 |
77 | } else {
78 | Ringtone ringtone = RingtoneManager.getRingtone(
79 | preference.getContext(), Uri.parse(stringValue));
80 |
81 | if (ringtone == null) {
82 | preference.setSummary(null);
83 | } else {
84 | String name = ringtone.getTitle(preference.getContext());
85 | preference.setSummary(name);
86 | }
87 | }
88 | }
89 | else {
90 | preference.setSummary(stringValue);
91 | }
92 | return true;
93 | }
94 | };
95 |
96 | private static void bindPreferenceSummaryToValue(Preference preference) {
97 | preference.setOnPreferenceChangeListener(sBindPreferenceSummaryToValueListener);
98 | sBindPreferenceSummaryToValueListener.onPreferenceChange(preference,
99 | PreferenceManager
100 | .getDefaultSharedPreferences(preference.getContext())
101 | .getString(preference.getKey(), ""));
102 | }
103 | }
104 |
--------------------------------------------------------------------------------
/app/src/main/java/me/crafter/android/zjsnviewer/SettingsActivity.java:
--------------------------------------------------------------------------------
1 | package me.crafter.android.zjsnviewer;
2 |
3 | import android.media.Ringtone;
4 | import android.media.RingtoneManager;
5 | import android.net.Uri;
6 | import android.os.Bundle;
7 | import android.preference.ListPreference;
8 | import android.preference.Preference;
9 | import android.preference.PreferenceActivity;
10 | import android.preference.PreferenceCategory;
11 | import android.preference.PreferenceManager;
12 | import android.preference.RingtonePreference;
13 | import android.text.TextUtils;
14 |
15 | @SuppressWarnings("deprecation")
16 | public class SettingsActivity extends PreferenceActivity {
17 |
18 | @Override
19 | protected void onPostCreate(Bundle savedInstanceState) {
20 | super.onPostCreate(savedInstanceState);
21 | setupSimplePreferencesScreen();
22 | }
23 |
24 | private void setupSimplePreferencesScreen() {
25 | addPreferencesFromResource(R.xml.pref_shared_top);
26 |
27 | // Add 'general' preferences.
28 | PreferenceCategory fakeHeader = new PreferenceCategory(this);
29 | fakeHeader.setTitle(R.string.pref_header_account);
30 | getPreferenceScreen().addPreference(fakeHeader);
31 | addPreferencesFromResource(R.xml.pref_part_general);
32 |
33 | fakeHeader = new PreferenceCategory(this);
34 | fakeHeader.setTitle(R.string.pref_header_notification);
35 | getPreferenceScreen().addPreference(fakeHeader);
36 | addPreferencesFromResource(R.xml.pref_part_notification);
37 |
38 | fakeHeader = new PreferenceCategory(this);
39 | fakeHeader.setTitle(R.string.pref_header_data_sync);
40 | getPreferenceScreen().addPreference(fakeHeader);
41 | addPreferencesFromResource(R.xml.pref_part_sync);
42 |
43 | fakeHeader = new PreferenceCategory(this);
44 | fakeHeader.setTitle(R.string.pref_header_about);
45 | getPreferenceScreen().addPreference(fakeHeader);
46 | addPreferencesFromResource(R.xml.pref_shared_bot);
47 |
48 | bindPreferenceSummaryToValue(findPreference("username"));
49 | bindPreferenceSummaryToValue(findPreference("server"));
50 |
51 | bindPreferenceSummaryToValue(findPreference("language"));
52 | bindPreferenceSummaryToValue(findPreference("platform"));
53 |
54 | bindPreferenceSummaryToValue(findPreference("refresh"));
55 | }
56 |
57 | /**
58 | * A preference value change listener that updates the preference's summary
59 | * to reflect its new value.
60 | */
61 | private static Preference.OnPreferenceChangeListener sBindPreferenceSummaryToValueListener = new Preference.OnPreferenceChangeListener() {
62 | @Override
63 | public boolean onPreferenceChange(Preference preference, Object value) {
64 | String stringValue = value.toString();
65 |
66 | if (preference instanceof ListPreference) {
67 | ListPreference listPreference = (ListPreference) preference;
68 | int index = listPreference.findIndexOfValue(stringValue);
69 |
70 | preference.setSummary(index >= 0 ? listPreference.getEntries()[index] : null);
71 | }
72 | else if (preference instanceof RingtonePreference) {
73 | if (TextUtils.isEmpty(stringValue)) {
74 | preference.setSummary(R.string.pref_ringtone_silent);
75 |
76 | } else {
77 | Ringtone ringtone = RingtoneManager.getRingtone(
78 | preference.getContext(), Uri.parse(stringValue));
79 |
80 | if (ringtone == null) {
81 | preference.setSummary(null);
82 | } else {
83 | String name = ringtone.getTitle(preference.getContext());
84 | preference.setSummary(name);
85 | }
86 | }
87 | }
88 | else {
89 | preference.setSummary(stringValue);
90 | }
91 | return true;
92 | }
93 | };
94 |
95 | private static void bindPreferenceSummaryToValue(Preference preference) {
96 | preference.setOnPreferenceChangeListener(sBindPreferenceSummaryToValueListener);
97 | sBindPreferenceSummaryToValueListener.onPreferenceChange(preference,
98 | PreferenceManager
99 | .getDefaultSharedPreferences(preference.getContext())
100 | .getString(preference.getKey(), ""));
101 | }
102 | }
103 |
--------------------------------------------------------------------------------
/app/src/main/java/me/crafter/android/zjsnviewer/TimerService.java:
--------------------------------------------------------------------------------
1 | package me.crafter.android.zjsnviewer;
2 |
3 | import android.app.AlarmManager;
4 | import android.app.PendingIntent;
5 | import android.app.Service;
6 | import android.content.BroadcastReceiver;
7 | import android.content.Context;
8 | import android.content.Intent;
9 | import android.content.IntentFilter;
10 | import android.content.SharedPreferences;
11 | import android.os.AsyncTask;
12 | import android.os.Handler;
13 | import android.os.IBinder;
14 | import android.os.PowerManager;
15 | import android.os.SystemClock;
16 | import android.preference.PreferenceManager;
17 | import android.util.Log;
18 |
19 | import java.util.Timer;
20 | import java.util.TimerTask;
21 |
22 | public class TimerService extends Service {
23 | // constant
24 | public static final long NOTIFY_INTERVAL = 5 * 1000; // 10 seconds
25 | public static TimerService instance;
26 |
27 | public static BroadcastReceiver mReceiver;
28 |
29 | public static int lastWidgetUpdate = 0;
30 |
31 | // run on another Thread to avoid crash
32 | private Handler mHandler = new Handler();
33 | // timer handling
34 | private Timer mTimer = null;
35 |
36 | @Override
37 | public IBinder onBind(Intent intent) {
38 | return null;
39 | }
40 |
41 | @Override
42 | public void onCreate() {
43 | Log.i("TimerService", "onCreate()");
44 | if (mTimer != null) {
45 | mTimer.cancel();
46 | } else {
47 | mTimer = new Timer();
48 | instance = this;
49 | }
50 | if (mReceiver == null){
51 | IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_ON);
52 | filter.addAction(Intent.ACTION_SCREEN_OFF);
53 | mReceiver = new ScreenReceiver();
54 | registerReceiver(mReceiver, filter);
55 | }
56 | mTimer.scheduleAtFixedRate(new TimeDisplayTimerTask(), 0, NOTIFY_INTERVAL);
57 | }
58 |
59 | @Override
60 | public void onTaskRemoved(Intent rootIntent){
61 | // test
62 | Log.d("TimerService", "onTaskRemoved is called");
63 | Intent restartServiceIntent = new Intent(getApplicationContext(), this.getClass());
64 | restartServiceIntent.setPackage(getPackageName());
65 | PendingIntent restartServicePendingIntent = PendingIntent.getService(getApplicationContext(), 1, restartServiceIntent, PendingIntent.FLAG_ONE_SHOT);
66 | AlarmManager alarmService = (AlarmManager) getApplicationContext().getSystemService(Context.ALARM_SERVICE);
67 | alarmService.set(
68 | AlarmManager.ELAPSED_REALTIME,
69 | SystemClock.elapsedRealtime() + 1000,
70 | restartServicePendingIntent);
71 | super.onTaskRemoved(rootIntent);
72 | }
73 |
74 | class TimeDisplayTimerTask extends TimerTask {
75 | @Override
76 | public void run() {
77 | mHandler.post(new Runnable() {
78 | @Override
79 | public void run() {
80 | // Log.i("TimerService", "run() - TimerService Receive Call");
81 | new Proceed().execute();
82 | }
83 | });
84 | }
85 | }
86 |
87 | private class Proceed extends AsyncTask {
88 | @Override
89 | protected Object doInBackground(Object... arg0){
90 | Context context = instance;
91 | SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
92 | Storage.language = Integer.parseInt(prefs.getString("language", "0"));
93 |
94 | DockInfo.requestUpdate(context);
95 | //notification checker
96 | if (DockInfo.shouldNotify(context)){
97 | NotificationSender.notify(context, Storage.str_reportTitle[Storage.language], DockInfo.getStatusReportAllFull());
98 | }
99 | //check if screen is on
100 | //if screen not on, widget should not update
101 | PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
102 | if (!pm.isScreenOn()){
103 | //Log.i("TimerService", "run() - Screen is off, ignores update.");
104 | } else {
105 | int currentUnix = DockInfo.currentUnix();
106 | if (currentUnix - lastWidgetUpdate >= Integer.parseInt(prefs.getString("refresh", "60"))){
107 | lastWidgetUpdate = currentUnix;
108 | Widget_Main.updateWidget(context);
109 | Widget_Travel.updateWidget(context);
110 | Widget_Repair.updateWidget(context);
111 | Widget_Build.updateWidget(context);
112 | Widget_Make.updateWidget(context);
113 | } else {
114 | //not time yet, ignore widget update
115 | }
116 | }
117 | return null;
118 | }
119 | }
120 |
121 | }
--------------------------------------------------------------------------------
/app/src/main/java/me/crafter/android/zjsnviewer/DoubleTimePreference.java:
--------------------------------------------------------------------------------
1 | package me.crafter.android.zjsnviewer;
2 |
3 | import android.content.Context;
4 | import android.content.res.TypedArray;
5 | import android.preference.DialogPreference;
6 | import android.support.annotation.NonNull;
7 | import android.text.format.DateFormat;
8 | import android.util.AttributeSet;
9 | import android.view.LayoutInflater;
10 | import android.view.View;
11 | import android.widget.TimePicker;
12 |
13 | import java.util.Calendar;
14 | import java.util.Date;
15 | import java.util.GregorianCalendar;
16 |
17 | public class DoubleTimePreference extends DialogPreference {
18 | private Calendar calendar;
19 | private Calendar calendar2;
20 | private View picker = null;
21 |
22 | TimePicker startPicker = null;
23 | TimePicker endPicker = null;
24 |
25 | public DoubleTimePreference(Context context) {
26 | this(context, null);
27 | }
28 |
29 | public DoubleTimePreference(Context context, AttributeSet attrs) {
30 | this(context, attrs, android.R.attr.dialogPreferenceStyle);
31 | }
32 |
33 | public DoubleTimePreference(Context context, AttributeSet attrs, int defStyle) {
34 | super(context, attrs, defStyle);
35 |
36 | setPositiveButtonText(R.string.settings_yes);
37 | setNegativeButtonText(R.string.settings_no);
38 | calendar = new GregorianCalendar();
39 | calendar2 = new GregorianCalendar();
40 | }
41 |
42 | @Override
43 | protected View onCreateDialogView() {
44 | picker = LayoutInflater.from(getContext()).inflate(R.layout.double_time_preference, null);
45 | return (picker);
46 | }
47 |
48 | @Override
49 | protected void onBindDialogView(@NonNull View view) {
50 | super.onBindDialogView(view);
51 | startPicker = (TimePicker)picker.findViewById(R.id.timePicker);
52 | endPicker = (TimePicker)picker.findViewById(R.id.timePicker2);
53 | startPicker.setCurrentHour(calendar.get(Calendar.HOUR_OF_DAY));
54 | startPicker.setCurrentMinute(calendar.get(Calendar.MINUTE));
55 | //startPicker.setIs24HourView(true);
56 | endPicker.setCurrentHour(calendar2.get(Calendar.HOUR_OF_DAY));
57 | endPicker.setCurrentMinute(calendar2.get(Calendar.MINUTE));
58 | //endPicker.setIs24HourView(true);
59 | }
60 |
61 | @Override
62 | protected void onDialogClosed(boolean positiveResult) {
63 | super.onDialogClosed(positiveResult);
64 |
65 | if (positiveResult) {
66 | calendar.set(Calendar.HOUR_OF_DAY, startPicker.getCurrentHour());
67 | calendar.set(Calendar.MINUTE, startPicker.getCurrentMinute());
68 | long startTime = (calendar.getTimeInMillis() % 86400000);
69 | calendar2.set(Calendar.HOUR_OF_DAY, endPicker.getCurrentHour());
70 | calendar2.set(Calendar.MINUTE, endPicker.getCurrentMinute());
71 | long endTime = (calendar2.getTimeInMillis() % 86400000);
72 | setSummary(getSummary());
73 | if (callChangeListener(toOneString(startTime, endTime))) {
74 | persistString(toOneString(startTime, endTime));
75 | notifyChanged();
76 | }
77 | }
78 | }
79 |
80 | @Override
81 | protected Object onGetDefaultValue(TypedArray a, int index) {
82 | return (a.getString(index));
83 | }
84 |
85 | @Override
86 | protected void onSetInitialValue(boolean restoreValue, Object defaultValue) {
87 | String value;
88 | if (restoreValue) {
89 | if (defaultValue == null){
90 | value = getPersistedString("0:0");
91 | } else {
92 | value = getPersistedString(defaultValue.toString());
93 | }
94 | } else {
95 | if (defaultValue == null){
96 | value = getPersistedString("0:0");
97 | } else {
98 | value = defaultValue.toString();
99 | }
100 | }
101 | long[] times = toTwoLongs(value);
102 | calendar.setTimeInMillis(times[0]);
103 | calendar2.setTimeInMillis(times[1]);
104 | setSummary(getSummary());
105 | }
106 |
107 | @Override
108 | public CharSequence getSummary() {
109 | if (calendar == null || calendar2 == null) {
110 | return null;
111 | }
112 | String summary = "";
113 | summary += DateFormat.getTimeFormat(getContext()).format(new Date(calendar.getTimeInMillis()));
114 | summary += " - ";
115 | summary += DateFormat.getTimeFormat(getContext()).format(new Date(calendar2.getTimeInMillis()));
116 | return summary;
117 | }
118 |
119 | public static long[] toTwoLongs(String in){
120 | try {
121 | String[] splitted = in.split(":");
122 | return new long[]{Long.parseLong(splitted[0]), Long.parseLong(splitted[1])};
123 | } catch (Exception ex) {
124 | return new long[]{0L, 0L};
125 | }
126 | }
127 |
128 | public static String toOneString(long first, long second){
129 | return first + ":" + second;
130 | }
131 |
132 | }
--------------------------------------------------------------------------------
/app/src/main/res/values/strings_pref_values.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 用户名
4 | 此处输入用户名
5 | 密码
6 | 服务器
7 |
8 | 语言/显示形式
9 |
10 | - 简体中文
11 | - 简体中文短
12 | - 正體中文
13 | - English
14 | - 日本語
15 | - 精简 Lite スリム化
16 | - ???
17 |
18 |
19 | - 0
20 | - 1
21 | - 2
22 | - 3
23 | - 4
24 | - 5
25 | - 6
26 |
27 |
28 |
29 | - [国] ZERO
30 | - [国] 胡德
31 | - [国] 萨拉托加
32 | - [国] 俾斯麦
33 | - [国] 声望
34 | - [国] 纳尔逊
35 | - [国] 空想
36 | - [国] 海伦娜
37 | - [国] 突击者
38 | - [国] 黎塞留
39 | - [国] 贝尔法斯特
40 | - [国] 追赶者
41 | - [台] 胡德
42 | - [台] 萨拉托加
43 | - [台] 俾斯麦
44 | - [台] 声望
45 | - [台] 纳尔逊
46 | - [台] 空想
47 | - [台] 海伦娜
48 | - [台] 突击者
49 | - [台] 黎赛留
50 | - [台] 贝尔法斯特
51 |
52 |
53 | - 0
54 | - 1
55 | - 2
56 | - 3
57 | - 4
58 | - 5
59 | - 6
60 | - 7
61 | - 8
62 | - 9
63 | - 10
64 | - 11
65 | - 101
66 | - 102
67 | - 103
68 | - 104
69 | - 105
70 | - 106
71 | - 107
72 | - 108
73 | - 109
74 | - 110
75 |
76 |
77 | 挂件刷新时间
78 |
79 | - 5秒
80 | - 10秒
81 | - 20秒
82 | - 30秒
83 | - 1分钟
84 | - 2分钟
85 | - 5分钟
86 |
87 |
88 | - 5
89 | - 10
90 | - 20
91 | - 30
92 | - 60
93 | - 120
94 | - 300
95 |
96 |
97 | 总开关
98 | 开启推送通知
99 | 远征结束通知
100 | 维修结束通知
101 | 建造结束通知
102 | 开发结束通知
103 |
104 | Turn On Notifications
105 | Expedition Notifications
106 | Repair Notifications
107 | Constriction Notifications (Fleet)
108 | Constriction Notifications (Equipment)
109 |
110 | 信息挂件字体大小
111 | 48
112 |
113 | 主挂件字体大小
114 | 48
115 |
116 | 黑科技开关
117 | 比较新奇的玩意,请谨慎使用
118 | 真·黑科技 (未完成)
119 | 无视平台与服务器,甚至不需要设置用户名密码,需要root权限支持
120 | 手动输入服务器
121 | 高级选项,强制使用输入的服务器地址,使用方法请参见网站。
122 |
123 | 登陆服务器
124 | http://login.alpha.p7game.com/index/passportLogin/
125 | 游戏服务器
126 | http://s2.zj.p7game.com/
127 |
128 | 免打扰模式
129 | 在设定的时间段内,你将不会收到任何通知,该时间可以跨天。
130 | 免打扰时间段
131 |
132 | 开始时间
133 | 结束时间
134 | 你将不会在以上时间段内收到推送通知。
135 |
136 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # For Cygwin, ensure paths are in UNIX format before anything is touched.
46 | if $cygwin ; then
47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
48 | fi
49 |
50 | # Attempt to set APP_HOME
51 | # Resolve links: $0 may be a link
52 | PRG="$0"
53 | # Need this for relative symlinks.
54 | while [ -h "$PRG" ] ; do
55 | ls=`ls -ld "$PRG"`
56 | link=`expr "$ls" : '.*-> \(.*\)$'`
57 | if expr "$link" : '/.*' > /dev/null; then
58 | PRG="$link"
59 | else
60 | PRG=`dirname "$PRG"`"/$link"
61 | fi
62 | done
63 | SAVED="`pwd`"
64 | cd "`dirname \"$PRG\"`/" >&-
65 | APP_HOME="`pwd -P`"
66 | cd "$SAVED" >&-
67 |
68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
69 |
70 | # Determine the Java command to use to start the JVM.
71 | if [ -n "$JAVA_HOME" ] ; then
72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
73 | # IBM's JDK on AIX uses strange locations for the executables
74 | JAVACMD="$JAVA_HOME/jre/sh/java"
75 | else
76 | JAVACMD="$JAVA_HOME/bin/java"
77 | fi
78 | if [ ! -x "$JAVACMD" ] ; then
79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
80 |
81 | Please set the JAVA_HOME variable in your environment to match the
82 | location of your Java installation."
83 | fi
84 | else
85 | JAVACMD="java"
86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
87 |
88 | Please set the JAVA_HOME variable in your environment to match the
89 | location of your Java installation."
90 | fi
91 |
92 | # Increase the maximum file descriptors if we can.
93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
94 | MAX_FD_LIMIT=`ulimit -H -n`
95 | if [ $? -eq 0 ] ; then
96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
97 | MAX_FD="$MAX_FD_LIMIT"
98 | fi
99 | ulimit -n $MAX_FD
100 | if [ $? -ne 0 ] ; then
101 | warn "Could not set maximum file descriptor limit: $MAX_FD"
102 | fi
103 | else
104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
105 | fi
106 | fi
107 |
108 | # For Darwin, add options to specify how the application appears in the dock
109 | if $darwin; then
110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
111 | fi
112 |
113 | # For Cygwin, switch paths to Windows format before running java
114 | if $cygwin ; then
115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
158 | function splitJvmOpts() {
159 | JVM_OPTS=("$@")
160 | }
161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
163 |
164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
165 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/widget__make.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
10 |
16 |
17 |
23 |
29 |
30 |
43 |
44 |
45 |
46 |
52 |
58 |
59 |
72 |
73 |
74 |
75 |
81 |
87 |
88 |
101 |
102 |
103 |
104 |
110 |
116 |
117 |
130 |
131 |
132 |
133 |
134 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/widget__build.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
10 |
16 |
17 |
23 |
29 |
30 |
43 |
44 |
45 |
46 |
52 |
58 |
59 |
72 |
73 |
74 |
75 |
81 |
87 |
88 |
101 |
102 |
103 |
104 |
110 |
116 |
117 |
130 |
131 |
132 |
133 |
134 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/widget__repair.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
10 |
16 |
17 |
23 |
29 |
30 |
43 |
44 |
45 |
46 |
52 |
58 |
59 |
72 |
73 |
74 |
75 |
81 |
87 |
88 |
101 |
102 |
103 |
104 |
110 |
116 |
117 |
130 |
131 |
132 |
133 |
134 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/widget__travel.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
10 |
16 |
17 |
23 |
29 |
30 |
43 |
44 |
45 |
46 |
52 |
58 |
59 |
72 |
73 |
74 |
75 |
81 |
87 |
88 |
101 |
102 |
103 |
104 |
110 |
116 |
117 |
130 |
131 |
132 |
133 |
134 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
14 |
17 |
18 |
19 |
20 |
21 |
24 |
25 |
28 |
29 |
30 |
31 |
32 |
35 |
36 |
39 |
40 |
41 |
42 |
43 |
46 |
47 |
50 |
51 |
52 |
53 |
54 |
57 |
58 |
61 |
62 |
63 |
64 |
65 |
68 |
69 |
70 |
71 |
72 |
73 |
77 |
78 |
79 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
102 |
105 | >
106 |
107 |
108 |
109 |
113 |
116 | >
117 |
118 |
119 |
120 |
124 |
127 | >
128 |
129 |
130 |
131 |
135 |
138 | >
139 |
140 |
141 |
145 |
148 | >
149 |
150 |
151 |
152 |
153 |
154 |
155 |
--------------------------------------------------------------------------------
/app/manifest-merger-release-report.txt:
--------------------------------------------------------------------------------
1 | -- Merging decision tree log ---
2 | manifest
3 | ADDED from AndroidManifest.xml:2:1
4 | xmlns:android
5 | ADDED from AndroidManifest.xml:2:11
6 | package
7 | ADDED from AndroidManifest.xml:3:5
8 | INJECTED from AndroidManifest.xml:0:0
9 | INJECTED from AndroidManifest.xml:0:0
10 | android:versionName
11 | INJECTED from AndroidManifest.xml:0:0
12 | INJECTED from AndroidManifest.xml:0:0
13 | android:versionCode
14 | INJECTED from AndroidManifest.xml:0:0
15 | INJECTED from AndroidManifest.xml:0:0
16 | uses-permission#android.permission.WAKE_LOCK
17 | ADDED from AndroidManifest.xml:5:5
18 | android:name
19 | ADDED from AndroidManifest.xml:5:22
20 | uses-permission#android.permission.VIBRATE
21 | ADDED from AndroidManifest.xml:6:5
22 | android:name
23 | ADDED from AndroidManifest.xml:6:22
24 | uses-permission#android.permission.INTERNET
25 | ADDED from AndroidManifest.xml:7:5
26 | android:name
27 | ADDED from AndroidManifest.xml:7:22
28 | application
29 | ADDED from AndroidManifest.xml:9:5
30 | MERGED from com.android.support:appcompat-v7:21.0.3:16:5
31 | MERGED from com.android.support:support-v4:21.0.3:16:5
32 | MERGED from com.android.support:support-v4:21.0.3:16:5
33 | android:label
34 | ADDED from AndroidManifest.xml:12:9
35 | android:allowBackup
36 | ADDED from AndroidManifest.xml:10:9
37 | android:icon
38 | ADDED from AndroidManifest.xml:11:9
39 | android:theme
40 | ADDED from AndroidManifest.xml:13:9
41 | receiver#me.crafter.android.zjsnviewer.Widget_Repair
42 | ADDED from AndroidManifest.xml:14:9
43 | android:label
44 | ADDED from AndroidManifest.xml:16:13
45 | android:name
46 | ADDED from AndroidManifest.xml:15:13
47 | intent-filter#android.appwidget.action.APPWIDGET_UPDATE
48 | ADDED from AndroidManifest.xml:17:13
49 | action#android.appwidget.action.APPWIDGET_UPDATE
50 | ADDED from AndroidManifest.xml:18:17
51 | android:name
52 | ADDED from AndroidManifest.xml:18:25
53 | meta-data#android.appwidget.provider
54 | ADDED from AndroidManifest.xml:21:13
55 | android:resource
56 | ADDED from AndroidManifest.xml:23:17
57 | android:name
58 | ADDED from AndroidManifest.xml:22:17
59 | receiver#me.crafter.android.zjsnviewer.Widget_Build
60 | ADDED from AndroidManifest.xml:25:9
61 | android:label
62 | ADDED from AndroidManifest.xml:27:13
63 | android:name
64 | ADDED from AndroidManifest.xml:26:13
65 | receiver#me.crafter.android.zjsnviewer.Widget_Make
66 | ADDED from AndroidManifest.xml:36:9
67 | android:label
68 | ADDED from AndroidManifest.xml:38:13
69 | android:name
70 | ADDED from AndroidManifest.xml:37:13
71 | receiver#me.crafter.android.zjsnviewer.Widget_Travel
72 | ADDED from AndroidManifest.xml:47:9
73 | android:label
74 | ADDED from AndroidManifest.xml:49:13
75 | android:name
76 | ADDED from AndroidManifest.xml:48:13
77 | receiver#me.crafter.android.zjsnviewer.Widget_Main
78 | ADDED from AndroidManifest.xml:58:9
79 | android:label
80 | ADDED from AndroidManifest.xml:60:13
81 | android:name
82 | ADDED from AndroidManifest.xml:59:13
83 | service#me.crafter.android.zjsnviewer.TimerService
84 | ADDED from AndroidManifest.xml:70:9
85 | android:name
86 | ADDED from AndroidManifest.xml:70:18
87 | receiver#me.crafter.android.zjsnviewer.ScreenReceiver
88 | ADDED from AndroidManifest.xml:73:9
89 | android:exported
90 | ADDED from AndroidManifest.xml:76:13
91 | android:enabled
92 | ADDED from AndroidManifest.xml:75:13
93 | android:name
94 | ADDED from AndroidManifest.xml:74:13
95 | activity#me.crafter.android.zjsnviewer.SettingsActivity
96 | ADDED from AndroidManifest.xml:79:9
97 | android:label
98 | ADDED from AndroidManifest.xml:81:13
99 | android:name
100 | ADDED from AndroidManifest.xml:80:13
101 | intent-filter#android.intent.category.LAUNCHER
102 | ADDED from AndroidManifest.xml:82:13
103 | category#android.intent.category.LAUNCHER
104 | ADDED from AndroidManifest.xml:83:17
105 | android:name
106 | ADDED from AndroidManifest.xml:83:27
107 | activity#me.crafter.android.zjsnviewer.ZjsnViewer
108 | ADDED from AndroidManifest.xml:88:9
109 | android:label
110 | ADDED from AndroidManifest.xml:90:13
111 | android:name
112 | ADDED from AndroidManifest.xml:89:13
113 | intent-filter#android.intent.action.MAIN+android.intent.category.LAUNCHER
114 | ADDED from AndroidManifest.xml:91:13
115 | action#android.intent.action.MAIN
116 | ADDED from AndroidManifest.xml:92:17
117 | android:name
118 | ADDED from AndroidManifest.xml:92:25
119 | activity#me.crafter.android.zjsnviewer.SettingsGeneral
120 | ADDED from AndroidManifest.xml:98:9
121 | android:label
122 | ADDED from AndroidManifest.xml:100:13
123 | android:parentActivityName
124 | ADDED from AndroidManifest.xml:101:13
125 | android:name
126 | ADDED from AndroidManifest.xml:99:13
127 | meta-data#android.support.PARENT_ACTIVITY
128 | ADDED from AndroidManifest.xml:102:13
129 | android:name
130 | ADDED from AndroidManifest.xml:103:17
131 | android:value
132 | ADDED from AndroidManifest.xml:104:17
133 | activity#me.crafter.android.zjsnviewer.SettingsNotification
134 | ADDED from AndroidManifest.xml:109:9
135 | android:label
136 | ADDED from AndroidManifest.xml:111:13
137 | android:parentActivityName
138 | ADDED from AndroidManifest.xml:112:13
139 | android:name
140 | ADDED from AndroidManifest.xml:110:13
141 | activity#me.crafter.android.zjsnviewer.SettingsSync
142 | ADDED from AndroidManifest.xml:120:9
143 | android:label
144 | ADDED from AndroidManifest.xml:122:13
145 | android:parentActivityName
146 | ADDED from AndroidManifest.xml:123:13
147 | android:name
148 | ADDED from AndroidManifest.xml:121:13
149 | activity#me.crafter.android.zjsnviewer.SettingsCustomize
150 | ADDED from AndroidManifest.xml:131:9
151 | android:label
152 | ADDED from AndroidManifest.xml:133:13
153 | android:parentActivityName
154 | ADDED from AndroidManifest.xml:134:13
155 | android:name
156 | ADDED from AndroidManifest.xml:132:13
157 | activity#me.crafter.android.zjsnviewer.SettingsBlack
158 | ADDED from AndroidManifest.xml:141:9
159 | android:label
160 | ADDED from AndroidManifest.xml:143:13
161 | android:parentActivityName
162 | ADDED from AndroidManifest.xml:144:13
163 | android:name
164 | ADDED from AndroidManifest.xml:142:13
165 | uses-sdk
166 | INJECTED from AndroidManifest.xml:0:0 reason: use-sdk injection requested
167 | MERGED from com.android.support:appcompat-v7:21.0.3:15:5
168 | MERGED from com.android.support:support-v4:21.0.3:15:5
169 | MERGED from com.android.support:support-v4:21.0.3:15:5
170 | android:targetSdkVersion
171 | INJECTED from AndroidManifest.xml:0:0
172 | INJECTED from AndroidManifest.xml:0:0
173 | android:minSdkVersion
174 | INJECTED from AndroidManifest.xml:0:0
175 | INJECTED from AndroidManifest.xml:0:0
176 |
--------------------------------------------------------------------------------
/app/src/main/java/me/crafter/android/zjsnviewer/Storage.java:
--------------------------------------------------------------------------------
1 | package me.crafter.android.zjsnviewer;
2 |
3 | import android.app.PendingIntent;
4 | import android.content.Context;
5 | import android.content.Intent;
6 | import android.content.SharedPreferences;
7 | import android.net.Uri;
8 | import android.preference.PreferenceManager;
9 | import android.text.format.DateFormat;
10 | import android.util.Log;
11 | import android.widget.RemoteViews;
12 |
13 | import java.util.Calendar;
14 | import java.util.Date;
15 |
16 | public class Storage {
17 |
18 | public static int language = 0;
19 |
20 | public static String str_tiduName = "提督の名前";
21 | public static String[] str_reportTitle = {"战舰少女码头报告","战舰少女码头报告","戰艦少女碼頭通知","Warship Girls Dock Report","提督注意書","战舰少女码头报告","喂!看这里!"};
22 | public static String[] str_locked = {"该槽位已被锁定","槽位锁定","該槽位已被鎖定","Slot Locked","???","x","还不课金么?"};
23 | public static String[] str_idle = {"空闲中","空闲中","閒置中","Idle","未使用","-","闲着呢"};
24 | public static String[] str_hour = {"小时","时","小時","hr","时",":","时"};
25 | public static String[] str_minute = {"分钟","分","分鐘","min.","分","","分"};
26 | public static String[] str_travel = {"远征中 - ","远征中 - ","遠征中 - ","Exp.ing - ","遠征中 - ","","不在家"};
27 | public static String[] str_repair = {"修理中 - ","修理中 - ","修理中 - ","Reparing - ","入渠中 - ","","大破中"};
28 | public static String[] str_build = {"建造中 - ","建造中 - ","建造中 - ","Cons.ing - ","建造中 - ","","换装中"};
29 | public static String[] str_make = {"开发中 - ","开发中 - ","開發中 - ","Cons.ing - ","開発中 - ","","开发中"};
30 | public static String[] str_travel2 = {"远征完成","远征完成","遠征完成","Expedition Complete","遠征完了","00:00","欧尼酱我回来啦"};
31 | public static String[] str_repair2 = {"修理完成","修理完成","修理完成","Repair Done","入渠完了","00:00","衣服穿好了"};
32 | public static String[] str_build2 = {"建造完成","建造完成","建造完成","Construction Complete","建造完了","00:00","快抱抱"};
33 | public static String[] str_make2 = {"开发完成","开发完成","開發完成","Construction Complete","開壳完了","00:00","工具在这里"};
34 | public static String[] str_thereIs = {"有","有","有","There is(are) ","","","有"};
35 | public static String[] str_teamsTravelling = {"个队伍正在远征,","个队伍正在远征,","個隊伍正在遠征,"," teams expedicting,","艦隊遠征中,","个队伍远征中,","个队伍出去玩了,"};
36 | public static String[] str_travelDone = {"远征结束,","远征结束,","遠征結束"," completed. ","遠征完了,","远征结束,","回家了,"};
37 | public static String[] str_team = {"队、","队、","隊、"," team,","隊,","队、","队"};
38 | public static String[] str_allFleetFixed = {"全部舰船维修完成,","全部舰船维修完成,","全部艦船維修完成","All fleet repaired. ","全艦隊入渠完了","维修全部结束,","所有的妹妹都穿好了衣服,"};
39 | public static String[] str_isRepairing = {"艘船正在维修,","艘船正在维修,","艘船正在維修,"," fleet(s) are currently repairing. ","艦娘入渠中,","艘船维修中,","个妹妹爆衣中,"};
40 | public static String[] str_allFleetBuilt = {"全部舰船建造完成,","全部舰船建造完成,","全部艦船建造完成","All fleets construction complete. ","全艦隊建造完了。","建造全部结束,","所有的妹妹全都准备好啦,"};
41 | public static String[] str_fleetIsBuilding = {"艘船正在建造,","艘船正在建造,","艘船正在建造,"," fleet(s) are under construction. ","艦娘建造中","艘船建造中","个妹妹还没准备好,"};
42 | public static String[] str_allEquipmentMade = {"全部装备开发完成。","全部装备开发完成。","全部裝備開發完成。","All equipments construction conplete. ","全裝備開壳完了。","开发全部结束。","所有衣服都做好啦,"};
43 | public static String[] str_equipmentIsMaking = {"个装备正在开发。","个装备正在开发。","個裝備正在開發。"," equipment(s) are under construction.","裝備開壳中。","个装备开发中。","个衣服正在做。"};
44 | public static String[] str_badLogin = {"用户名密码错误","用户名密码错误","用戶名密碼錯誤","Bad username or password","ユーザー名またはパスワードが正しくありません","用户名密码错误","吔屎啦 这都输不对"};
45 | public static String[] str_noUserData = {"数据错误,你选错服务器了?","数据错误,你选错服务器了?","數據錯誤,你選錯伺服器了?","No user data, check your server selection.","データエラー,サーバーの選択は間違っています?","数据错误,你选错服务器了?","然后并没有什么卵用"};
46 | public static String[] str_badConnection = {"网络错误","网炸了","網絡錯誤","Bad internet.","ネットワーク接続エラー","网络错误","移动联通你家炸了"};
47 | public static String[] str_notOn = {"未开启","未开启","未啟動","Disabled","起動しない","x","我在睡觉"};
48 | public static String[] str_gameRunning = {"游戏运行中","游戏运行中","遊戲運行中","Game is running","起動しない","-","游戏在运行"};
49 |
50 |
51 | public static String getZjsnPackageName(Context context){
52 | SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
53 | int serverId = Integer.parseInt(prefs.getString("server", "-1"));
54 | if (serverId == 0){
55 | return "com.muka.shipwarzero";
56 | } else if (serverId < 100){
57 | return "com.muka.shipwar";
58 | } else {
59 | return "org.huanmeng.Zhanjian2_alipay";
60 | }
61 | }
62 |
63 | public static PendingIntent getStartPendingIntent(Context context){
64 | Intent intent = context.getPackageManager().getLaunchIntentForPackage(Storage.getZjsnPackageName(context));
65 | if (intent == null){
66 | intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.crafter.me/zjsnviewer/"));
67 | }
68 | return PendingIntent.getActivity(context, 0, intent, 0);
69 | }
70 |
71 | public static float getTextSizeMajor(Context context){
72 | SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
73 | String size = prefs.getString("textsize_major", "48");
74 | float ret = 48;
75 | try {
76 | ret = Float.parseFloat(size);
77 | } catch (Exception ex) {}
78 | ret = Math.max(0.001F, ret);
79 | return ret;
80 | }
81 |
82 | public static float getTextSizeMinor(Context context){
83 | SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
84 | String size = prefs.getString("textsize_minor", "48");
85 | float ret = 48;
86 | try {
87 | ret = Float.parseFloat(size);
88 | } catch (Exception ex) {}
89 | ret = Math.max(0.001F, ret);
90 | return ret;
91 | }
92 |
93 | public static boolean isNoDisturbNow(Context context){
94 | SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
95 | boolean on = prefs.getBoolean("notification_do_not_disturb_on", false);
96 | if (on){
97 | int now = Integer.parseInt(DateFormat.format("HHmm", new Date(System.currentTimeMillis() % 86400000)).toString());
98 | long[] interval = DoubleTimePreference.toTwoLongs(prefs.getString("notification_do_not_disturb_time", "14400000:45000000"));
99 | int start = Integer.parseInt(DateFormat.format("HHmm", new Date(interval[0])).toString());
100 | int finish = Integer.parseInt(DateFormat.format("HHmm", new Date(interval[1])).toString());
101 | Log.i("Storage", now + " " + start + " " + finish);
102 | if (start < finish){ // Not cross day
103 | return (now > start && now < finish);
104 | } else if (start > finish){ // Cross day
105 | return (now > start || now < finish);
106 | } else {
107 | return false;
108 | }
109 | } else {
110 | return false;
111 | }
112 | }
113 |
114 | public static int getVersion(Context context){
115 | return context.getResources().getInteger(R.integer.version);
116 | }
117 |
118 | public static boolean black(Context context){
119 | return PreferenceManager.getDefaultSharedPreferences(context).getBoolean("black", false);
120 | }
121 |
122 | public static boolean root(Context context){
123 | return PreferenceManager.getDefaultSharedPreferences(context).getBoolean("root", false);
124 | }
125 |
126 | }
127 |
--------------------------------------------------------------------------------
/app/app.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | generateDebugAndroidTestSources
19 | generateDebugSources
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
--------------------------------------------------------------------------------
/app/src/main/java/me/crafter/android/zjsnviewer/SettingsBlack.java:
--------------------------------------------------------------------------------
1 | package me.crafter.android.zjsnviewer;
2 |
3 | import android.content.Context;
4 | import android.content.SharedPreferences;
5 | import android.media.Ringtone;
6 | import android.media.RingtoneManager;
7 | import android.net.Uri;
8 | import android.os.Bundle;
9 | import android.preference.ListPreference;
10 | import android.preference.Preference;
11 | import android.preference.PreferenceActivity;
12 | import android.preference.PreferenceCategory;
13 | import android.preference.PreferenceManager;
14 | import android.preference.RingtonePreference;
15 | import android.preference.SwitchPreference;
16 | import android.support.v7.widget.Toolbar;
17 | import android.text.TextUtils;
18 | import android.util.Log;
19 | import android.view.LayoutInflater;
20 | import android.view.View;
21 | import android.widget.LinearLayout;
22 | import android.widget.Toast;
23 |
24 | @SuppressWarnings("deprecation")
25 | public class SettingsBlack extends PreferenceActivity {
26 |
27 | @Override
28 | protected void onPostCreate(Bundle savedInstanceState) {
29 | super.onPostCreate(savedInstanceState);
30 | setupToolBar();
31 | setupSimplePreferencesScreen();
32 | registerListener(getApplicationContext());
33 | }
34 |
35 | private void setupSimplePreferencesScreen() {
36 | addPreferencesFromResource(R.xml.pref_shared_empty);
37 | // Add 'black' preferences.
38 | PreferenceCategory fakeHeader = new PreferenceCategory(this);
39 | fakeHeader.setTitle(R.string.pref_header_black);
40 | getPreferenceScreen().addPreference(fakeHeader);
41 | addPreferencesFromResource(R.xml.pref_part_black);
42 | bindPreferenceSummaryToValue(findPreference("alt_url_login"));
43 | bindPreferenceSummaryToValue(findPreference("alt_url_server"));
44 | }
45 |
46 | // Listener
47 | private void registerListener(final Context context){
48 | // TODO change
49 | // Ref: http://stackoverflow.com/questions/2542938/sharedpreferences-onsharedpreferencechangelistener-not-being-called-consistently
50 | // findPreference("black").setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
51 | // @Override
52 | // public boolean onPreferenceChange(Preference preference,Object newValue) {
53 | // if ((Boolean)newValue){
54 | // Toast.makeText(context, context.getResources().getString(R.string.black_warning), Toast.LENGTH_SHORT).show();
55 | // } else {
56 | // //PreferenceManager.getDefaultSharedPreferences(context).edit().putBoolean("root", false).commit();
57 | // ((SwitchPreference)findPreference("root")).setChecked(false);
58 | // }
59 | // return true;
60 | // }
61 | // });
62 | findPreference("root").setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
63 | @Override
64 | public boolean onPreferenceChange(Preference preference,Object newValue) {
65 | if ((Boolean)newValue){
66 | Toast.makeText(context, context.getResources().getString(R.string.root_please), Toast.LENGTH_SHORT).show();
67 | if (Worker.testSuperUser(context)){
68 | Toast.makeText(context, context.getResources().getString(R.string.root_success), Toast.LENGTH_SHORT).show();
69 | } else {
70 | Toast.makeText(context, context.getResources().getString(R.string.root_fail), Toast.LENGTH_SHORT).show();
71 | // TODO not working
72 | ((SwitchPreference)preference).setChecked(false);
73 | }
74 | }
75 | return true;
76 | }
77 | });
78 | // findPreference("black").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
79 | // public boolean onPreferenceClick(Preference preference) {
80 | // if (Storage.black(context)) {
81 | // Toast.makeText(context, context.getResources().getString(R.string.black_warning), Toast.LENGTH_SHORT).show();
82 | // } else {
83 | // //PreferenceManager.getDefaultSharedPreferences(context).edit().putBoolean("root", false).commit();
84 | // ((SwitchPreference)findPreference("root")).setChecked(false);
85 | // }
86 | // return true;
87 | // }
88 | // });
89 | // findPreference("root").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
90 | // public boolean onPreferenceClick(Preference preference) {
91 | // if (Storage.root(context)){
92 | // Toast.makeText(context, context.getResources().getString(R.string.root_please), Toast.LENGTH_SHORT).show();
93 | // if (Worker.testSuperUser(context)){
94 | // Toast.makeText(context, context.getResources().getString(R.string.root_success), Toast.LENGTH_SHORT).show();
95 | // } else {
96 | // Toast.makeText(context, context.getResources().getString(R.string.root_fail), Toast.LENGTH_SHORT).show();
97 | // ((SwitchPreference)findPreference("root")).setChecked(false);
98 | // }
99 | // }
100 | // return true;
101 | // }
102 | // });
103 | }
104 |
105 | private void setupToolBar(){
106 | LinearLayout root = (LinearLayout)findViewById(android.R.id.list).getParent().getParent().getParent();
107 | Toolbar bar = (Toolbar) LayoutInflater.from(this).inflate(R.layout.pref_shared_toolbar, root, false);
108 | root.addView(bar, 0); // insert at top
109 | bar.setNavigationOnClickListener(new View.OnClickListener() {
110 | @Override
111 | public void onClick(View v) {
112 | finish();
113 | }
114 | });
115 | }
116 | /**
117 | * A preference value change listener that updates the preference's summary
118 | * to reflect its new value.
119 | */
120 | private static Preference.OnPreferenceChangeListener sBindPreferenceSummaryToValueListener = new Preference.OnPreferenceChangeListener() {
121 | @Override
122 | public boolean onPreferenceChange(Preference preference, Object value) {
123 | String stringValue = value.toString();
124 |
125 | if (preference instanceof ListPreference) {
126 | ListPreference listPreference = (ListPreference) preference;
127 | int index = listPreference.findIndexOfValue(stringValue);
128 |
129 | preference.setSummary(index >= 0 ? listPreference.getEntries()[index] : null);
130 | }
131 | else if (preference instanceof RingtonePreference) {
132 | if (TextUtils.isEmpty(stringValue)) {
133 | preference.setSummary(R.string.pref_ringtone_silent);
134 |
135 | } else {
136 | Ringtone ringtone = RingtoneManager.getRingtone(
137 | preference.getContext(), Uri.parse(stringValue));
138 |
139 | if (ringtone == null) {
140 | preference.setSummary(null);
141 | } else {
142 | String name = ringtone.getTitle(preference.getContext());
143 | preference.setSummary(name);
144 | }
145 | }
146 | }
147 | else {
148 | preference.setSummary(stringValue);
149 | }
150 | return true;
151 | }
152 | };
153 |
154 | private static void bindPreferenceSummaryToValue(Preference preference) {
155 | preference.setOnPreferenceChangeListener(sBindPreferenceSummaryToValueListener);
156 | sBindPreferenceSummaryToValueListener.onPreferenceChange(preference,
157 | PreferenceManager
158 | .getDefaultSharedPreferences(preference.getContext())
159 | .getString(preference.getKey(), ""));
160 | }
161 | }
162 |
--------------------------------------------------------------------------------
/app/src/main/java/me/crafter/android/zjsnviewer/Worker.java:
--------------------------------------------------------------------------------
1 | package me.crafter.android.zjsnviewer;
2 |
3 | import android.app.Activity;
4 | import android.app.AlertDialog;
5 | import android.app.DownloadManager;
6 | import android.content.Context;
7 | import android.content.DialogInterface;
8 | import android.content.Intent;
9 | import android.net.Uri;
10 | import android.os.AsyncTask;
11 | import android.os.Bundle;
12 | import android.os.Environment;
13 | import android.util.Log;
14 | import android.util.TypedValue;
15 | import android.widget.RemoteViews;
16 | import android.widget.Toast;
17 |
18 | import org.json.JSONObject;
19 |
20 | import java.io.BufferedReader;
21 | import java.io.DataOutputStream;
22 | import java.io.IOException;
23 | import java.io.InputStreamReader;
24 | import java.net.URL;
25 | import java.net.URLConnection;
26 |
27 | public class Worker {
28 |
29 | public static void widgetSetTextSize(Context context, RemoteViews views){
30 | float textsize = Storage.getTextSizeMinor(context);
31 | views.setTextViewTextSize(R.id.textView1, TypedValue.COMPLEX_UNIT_PX, textsize);
32 | views.setTextViewTextSize(R.id.textView2, TypedValue.COMPLEX_UNIT_PX, textsize);
33 | views.setTextViewTextSize(R.id.textView3, TypedValue.COMPLEX_UNIT_PX, textsize);
34 | views.setTextViewTextSize(R.id.textView4, TypedValue.COMPLEX_UNIT_PX, textsize);
35 | }
36 |
37 | public static void mainSetTextSize(Context context, RemoteViews views){
38 | float textsize = Storage.getTextSizeMajor(context);
39 | views.setTextViewTextSize(R.id.textView2, TypedValue.COMPLEX_UNIT_PX, textsize);
40 | views.setTextViewTextSize(R.id.textView, TypedValue.COMPLEX_UNIT_PX, textsize);
41 | }
42 |
43 | public static void checkUpdate(final Activity activity, final Context context){
44 | Toast.makeText(context, context.getString(R.string.checking_update), Toast.LENGTH_SHORT).show();
45 | new AsyncTask() {
46 | State state = State.INTERRUPT;
47 | String newVersionString = "";
48 | String newVersionFeature = "";
49 | boolean important = false;
50 | String downloadLink = "";
51 | @Override
52 | protected Void doInBackground( final Void ... params ) {
53 | String response = visit("http://zjsn.acg.land/version.json");
54 | if (response.equals("ERR1")){
55 | state = State.CONNECTION_FAIL;
56 | return null;
57 | }
58 | try {
59 | JSONObject obj = new JSONObject(response);
60 | int currVersion = Storage.getVersion(context);
61 | int newVersion = obj.getInt("currentVersion");
62 | if (newVersion > currVersion){
63 | state = State.UPDATE_FOUND;
64 | } else {
65 | state = State.NO_UPDATE_FOUND;
66 | return null;
67 | }
68 | int importantSince = obj.getInt("importantSince");
69 | if (importantSince <= currVersion){
70 | important = true;
71 | }
72 | newVersionString = obj.getString("versionString");
73 | newVersionFeature = obj.getString("whatsNew");
74 | downloadLink = obj.getString("downloadLink");
75 | } catch (Exception ex){
76 | state = State.PARSE_ERROR;
77 | return null;
78 | }
79 | return null;
80 | }
81 | @Override
82 | protected void onPostExecute( final Void result ) {
83 | switch (state){
84 | case CONNECTION_FAIL:
85 | case CONNECTION_RESET:
86 | case INTERRUPT:
87 | Toast.makeText(context, context.getString(R.string.check_update_fail_connection), Toast.LENGTH_SHORT).show();
88 | break;
89 | case PARSE_ERROR:
90 | Toast.makeText(context, context.getString(R.string.check_update_fail_parse), Toast.LENGTH_SHORT).show();
91 | break;
92 | case UPDATE_FOUND:
93 | Toast.makeText(context, context.getString(R.string.check_update_success_update_available) + " " + newVersionString, Toast.LENGTH_SHORT).show();
94 | String ready = context.getResources().getString(R.string.check_update_body);
95 | ready = ready.replace("@curr@", context.getResources().getString(R.string.versions));
96 | ready = ready.replace("@new@", newVersionString);
97 | ready = ready.replace("@feature@", newVersionFeature);
98 | if (important){
99 | ready += context.getResources().getString(R.string.check_update_important);
100 | }
101 | askUpdate(activity, context, ready, downloadLink);
102 | break;
103 | case NO_UPDATE_FOUND:
104 | Toast.makeText(context, context.getString(R.string.check_update_success_no_update), Toast.LENGTH_SHORT).show();
105 | break;
106 | default:
107 | Toast.makeText(context, context.getString(R.string.check_update_fail_parse), Toast.LENGTH_SHORT).show();
108 | break;
109 | }
110 | }
111 | }.execute();
112 | }
113 |
114 | public static String visit(String urls){
115 | String ret = "";
116 | try {
117 | URL url = new URL(urls);
118 | URLConnection connection = url.openConnection();
119 | connection.setConnectTimeout(15000);
120 | connection.setReadTimeout(15000);
121 | BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
122 | String inputLine;
123 | StringBuffer response = new StringBuffer();
124 | while ((inputLine = in.readLine()) != null) {
125 | response.append(inputLine);
126 | }
127 | ret = response.toString();
128 | } catch (Exception ex){
129 | ret = "ERR1";
130 | }
131 | return ret;
132 | }
133 |
134 | public static void askUpdate(final Activity activity, final Context context, String message, final String url){
135 | new AlertDialog.Builder(activity)
136 | .setTitle(R.string.check_update_title)
137 | .setMessage(message)
138 | .setPositiveButton(R.string.check_update_yes, new DialogInterface.OnClickListener() {
139 | public void onClick(DialogInterface dialog, int which) {
140 | Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
141 | activity.startActivity(intent);
142 | }
143 | })
144 | .setNegativeButton(R.string.check_update_no, new DialogInterface.OnClickListener() {
145 | public void onClick(DialogInterface dialog, int which) {
146 | }
147 | })
148 | .setIcon(android.R.drawable.ic_dialog_info)
149 | .show();
150 | }
151 |
152 | public static boolean testSuperUser(final Context context){
153 | Process p;
154 | try {
155 | p = Runtime.getRuntime().exec("su");
156 | DataOutputStream os = new DataOutputStream(p.getOutputStream());
157 | os.writeBytes("echo \"Do I have root?\" >/system/sd/temporary.txt\n");
158 | os.writeBytes("exit\n");
159 | os.flush();
160 | try {
161 | p.waitFor();
162 | if (p.exitValue() != 255) {
163 | return true;
164 | }
165 | else {
166 | return false;
167 | }
168 | } catch (InterruptedException e) {
169 | return false;
170 | }
171 | } catch (IOException e) {
172 | return false;
173 | }
174 | }
175 |
176 | }
177 |
--------------------------------------------------------------------------------
/app/src/main/java/me/crafter/android/zjsnviewer/DockInfo.java:
--------------------------------------------------------------------------------
1 | package me.crafter.android.zjsnviewer;
2 |
3 | import android.app.ActivityManager;
4 | import android.content.Context;
5 | import android.content.SharedPreferences;
6 | import android.preference.PreferenceManager;
7 | import android.util.Log;
8 |
9 | import java.util.List;
10 |
11 | public class DockInfo {
12 |
13 | public static int lastUpdate = -1;
14 |
15 | public static int[] dockTravelTime = {0, 0, 0, 0};
16 | public static int[] dockRepairTime = {0, 0, 0, 0};
17 | public static int[] dockBuildTime = {0, 0, 0, 0};
18 | public static int[] dockMakeTime = {0, 0, 0, 0};
19 |
20 | public static int updateInterval = 15;
21 |
22 | public static String exp = "0";
23 | public static String nextExp = "0";
24 | public static String level = "0";
25 |
26 |
27 | public static int[][] lastStatus;
28 |
29 | public static int currentUnix(){
30 | return ((int)(System.currentTimeMillis() / 1000L));
31 | }
32 |
33 | public static int countTravelIng(){
34 | int ing = 0;
35 | for (int i : dockTravelTime){
36 | if (i > currentUnix()) ing ++;
37 | }
38 | return ing;
39 | }
40 |
41 | public static int countRepairIng(){
42 | int ing = 0;
43 | for (int i : dockRepairTime){
44 | if (i > currentUnix()) ing ++;
45 | }
46 | return ing;
47 | }
48 |
49 | public static int countBuildIng(){
50 | int ing = 0;
51 | for (int i : dockBuildTime){
52 | if (i > currentUnix()) ing ++;
53 | }
54 | return ing;
55 | }
56 |
57 | public static int countMakeIng(){
58 | int ing = 0;
59 | for (int i : dockMakeTime){
60 | if (i > currentUnix()) ing ++;
61 | }
62 | return ing;
63 | }
64 |
65 | public static String getStatusReportAllFull(){
66 | String report = "";
67 | if (countTravelIng() != 0){
68 | report += Storage.str_thereIs[Storage.language] + countTravelIng() + Storage.str_teamsTravelling[Storage.language];
69 | }
70 | String travelDone = "";
71 | for (int i = 0; i < 4; i++){
72 | if (dockTravelTime[i] != -1 && dockTravelTime[i] != 0 && dockTravelTime[i] < currentUnix()){
73 | travelDone += (i+1) + Storage.str_team[Storage.language];
74 | }
75 | }
76 | if (!travelDone.equals("")){
77 | travelDone = travelDone.substring(0, travelDone.length()-1);
78 | report += travelDone + Storage.str_travelDone[Storage.language];
79 | }
80 |
81 | if (countRepairIng() == 0){
82 | report += Storage.str_allFleetFixed[Storage.language];
83 | } else {
84 | report += Storage.str_thereIs[Storage.language] + countRepairIng() + Storage.str_isRepairing[Storage.language];
85 | }
86 | //report += "空槽位" + (dockSlotMax[0]-countRepairIng()) + "个;";
87 |
88 | if (countBuildIng() == 0){
89 | report += Storage.str_allFleetBuilt[Storage.language];
90 | } else {
91 | report += Storage.str_thereIs[Storage.language] + countBuildIng() + Storage.str_fleetIsBuilding[Storage.language];
92 | }
93 | //report += "空槽位" + (dockSlotMax[0]-countBuildIng()) + "个;";
94 |
95 | if (countMakeIng() == 0){
96 | report += Storage.str_allEquipmentMade[Storage.language];
97 | } else {
98 | report += Storage.str_thereIs[Storage.language] + countMakeIng() + Storage.str_equipmentIsMaking[Storage.language];
99 | }
100 | //report += "空槽位" + (dockSlotMax[0]-countBuildIng()) + "个。";
101 | return report;
102 | }
103 |
104 | public static int[][] getStatusInt(){
105 | //-1 = locked, 0 = done, 1 = in progress, 2 = nothing
106 | int [][] ret = {{2, 2, 2, 2}, {2, 2, 2, 2}, {2, 2, 2, 2}, {2, 2, 2, 2}};
107 | for (int i = 0; i < 4; i++){
108 | if (dockTravelTime[i] == -1) ret[0][i] = 2;
109 | else if (dockTravelTime[i] > currentUnix()) ret[0][i] = 1;
110 | else if (dockTravelTime[i] <= currentUnix()) ret[0][i] = 0;
111 | if (dockRepairTime[i] == -1) ret[1][i] = 2;
112 | else if (dockRepairTime[i] > currentUnix()) ret[1][i] = 1;
113 | else if (dockRepairTime[i] <= currentUnix()) ret[1][i] = 0;
114 | if (dockBuildTime[i] == -1) ret[2][i] = 2;
115 | else if (dockBuildTime[i] > currentUnix()) ret[2][i] = 1;
116 | else if (dockBuildTime[i] <= currentUnix()) ret[2][i] = 0;
117 | if (dockMakeTime[i] == -1) ret[3][i] = 2;
118 | else if (dockMakeTime[i] > currentUnix()) ret[3][i] = 1;
119 | else if (dockMakeTime[i] <= currentUnix()) ret[3][i] = 0;
120 | }
121 | // String debug = "";
122 | // for (int x = 0; x < 4; x++){
123 | // for (int y = 0; y < 4; y++){
124 | // debug += ret[x][y] + " ";
125 | // }
126 | // debug += "| ";
127 | // }
128 | // Log.i("DockInfo", "getStatusInt() returned " + debug);
129 | return ret;
130 | }
131 |
132 | public static boolean shouldNotify(Context context){
133 | // First check no disturb
134 | if (Storage.isNoDisturbNow(context)) return false;
135 |
136 | SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
137 |
138 | if (!prefs.getBoolean("notification_general", true)) return false;
139 | boolean[] shouldMap = {prefs.getBoolean("notification_travel", true), prefs.getBoolean("notification_repair", true), prefs.getBoolean("notification_build", true), prefs.getBoolean("notification_make", true)};
140 |
141 |
142 | int[][] thisStatus = getStatusInt();
143 | boolean should = false;
144 | if (lastStatus == null){
145 |
146 | // for (int x = 0; x < 4; x++){
147 | // for (int y = 0; y < 4; y++){
148 | // if (thisStatus[x][y] == 0) should = true;
149 | // }
150 | // }
151 | //TODO NOTICE! TEMP BYPASS
152 | //TEMP FORCE NO NOTIFY ON START!!!
153 | should = false;
154 | //TEMP FORCE NO NOTIFY ON START!!!
155 | } else {
156 | for (int x = 0; x < 4; x++){
157 | for (int y = 0; y < 4; y++){
158 | if (shouldMap[x] && (thisStatus[x][y] == 0 && lastStatus[x][y] != 0)) should = true;
159 | }
160 | }
161 | }
162 | lastStatus = thisStatus;
163 | return should;
164 | }
165 |
166 | public static String timeBetween(int future){
167 | String ret = "";
168 | int second = future-currentUnix();
169 | if (Storage.language == 5){ //Lite display is different
170 | if (second >= 3600){
171 | if ((second/3600) < 10){
172 | ret += "0";
173 | }
174 | ret += second/3600 + Storage.str_hour[Storage.language];
175 | } else {
176 | ret += "00:";
177 | }
178 | if ((second/60)%60 < 10){
179 | ret += "0";
180 | }
181 | ret += (second/60)%60 + Storage.str_minute[Storage.language];
182 | if (second < 60){
183 | ret = "< 00:01" + Storage.str_minute[Storage.language];
184 | }
185 | } else { //non-Lite display
186 | if (second >= 3600){
187 | ret += second/3600 + Storage.str_hour[Storage.language];
188 | }
189 | if ((second/60)%60 < 10){
190 | ret += "0";
191 | }
192 | ret += (second/60)%60 + Storage.str_minute[Storage.language];
193 | if (second < 60){
194 | ret = "<1" + Storage.str_minute[Storage.language];
195 | }
196 | }
197 | return ret;
198 | }
199 |
200 | public static String[] getTravelBoard(){
201 | String[] ret = {"","","",""};
202 | for (int i = 0; i < 4; i++){
203 | if (dockTravelTime[i] == 0){
204 | ret[i] = Storage.str_idle[Storage.language];
205 | } else if (dockTravelTime[i] == -1){
206 | ret[i] = Storage.str_idle[Storage.language];
207 | } else if (dockTravelTime[i] < currentUnix()){
208 | ret[i] = Storage.str_travel2[Storage.language];
209 | } else {
210 | ret[i] = Storage.str_travel[Storage.language] + timeBetween(dockTravelTime[i]);
211 | }
212 | }
213 | return ret;
214 | }
215 |
216 | public static String[] getRepairBoard(){
217 | String[] ret = {"","","",""};
218 | for (int i = 0; i < 4; i++){
219 | if (dockRepairTime[i] == 0){
220 | ret[i] = Storage.str_idle[Storage.language];
221 | } else if (dockRepairTime[i] == -1){
222 | ret[i] = Storage.str_locked[Storage.language];
223 | } else if (dockRepairTime[i] < currentUnix()){
224 | ret[i] = Storage.str_repair2[Storage.language];
225 | } else {
226 | ret[i] = Storage.str_repair[Storage.language] + timeBetween(dockRepairTime[i]);
227 | }
228 | }
229 | return ret;
230 | }
231 |
232 | public static String[] getBuildBoard(){
233 | String[] ret = {"","","",""};
234 | for (int i = 0; i < 4; i++){
235 | if (dockBuildTime[i] == 0){
236 | ret[i] = Storage.str_idle[Storage.language];
237 | } else if (dockBuildTime[i] == -1){
238 | ret[i] = Storage.str_locked[Storage.language];
239 | } else if (dockBuildTime[i] < currentUnix()){
240 | ret[i] = Storage.str_build2[Storage.language];
241 | } else {
242 | ret[i] = Storage.str_build[Storage.language] + timeBetween(dockBuildTime[i]);
243 | }
244 | }
245 | return ret;
246 | }
247 |
248 | public static String[] getMakeBoard(){
249 | String[] ret = {"","","",""};
250 | for (int i = 0; i < 4; i++){
251 | if (dockMakeTime[i] == 0){
252 | ret[i] = Storage.str_idle[Storage.language];
253 | } else if (dockMakeTime[i] == -1){
254 | ret[i] = Storage.str_locked[Storage.language];
255 | } else if (dockMakeTime[i] < currentUnix()){
256 | ret[i] = Storage.str_make2[Storage.language];
257 | } else {
258 | ret[i] = Storage.str_make[Storage.language] + timeBetween(dockMakeTime[i]);
259 | }
260 | }
261 | return ret;
262 | }
263 |
264 |
265 | //request an update, with a interval of 15 seconds checked
266 | public static boolean requestUpdate(Context context){
267 | boolean ret = true;
268 | Log.i("DockInfo", "Current Interval is " + updateInterval + " (" + (currentUnix() - lastUpdate) + ")");
269 | if (currentUnix() - lastUpdate > updateInterval){
270 | //lastUpdate is put before updateDockInfo
271 | //to prevent multi request caused by delay
272 | lastUpdate = currentUnix();
273 | NetworkManager.updateDockInfo(context);
274 | } else {
275 | ret = false;
276 | }
277 |
278 | ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
279 | List procInfos = activityManager.getRunningAppProcesses();
280 | for (int i = 0; i < procInfos.size(); i++){
281 | if (procInfos.get(i).processName.startsWith("com.muka.shipwar")){
282 | DockInfo.updateInterval = 15;
283 | Storage.str_tiduName = Storage.str_gameRunning[Storage.language];
284 | break;
285 | }
286 | }
287 |
288 | SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
289 | Boolean on = prefs.getBoolean("on", false);
290 | if (!on){
291 | DockInfo.updateInterval = 15;
292 | }
293 |
294 | return ret;
295 | }
296 |
297 |
298 | }
299 |
--------------------------------------------------------------------------------
/app/src/main/java/me/crafter/android/zjsnviewer/NetworkManager.java:
--------------------------------------------------------------------------------
1 | package me.crafter.android.zjsnviewer;
2 |
3 | import java.io.BufferedReader;
4 | import java.io.InputStreamReader;
5 | import java.net.URL;
6 | import java.net.URLConnection;
7 | import java.util.HashMap;
8 | import java.util.List;
9 | import java.util.Map;
10 |
11 | import org.json.JSONArray;
12 | import org.json.JSONObject;
13 |
14 | import android.app.ActivityManager;
15 | import android.content.Context;
16 | import android.content.SharedPreferences;
17 | import android.preference.PreferenceManager;
18 | import android.util.Log;
19 |
20 | public class NetworkManager {
21 |
22 | // TODO this class needs cleanup
23 |
24 | public static String url_init_p7 = "api/initGame&t=233&e=5f3cd4e0d30c4376f8c9685d263f5184";
25 | public static String url_init_zero = "api/initGame&t=233&e=5f3cd4e0d30c4376f8c9685d263f5184";
26 | public static String url_init_hm = "api/initGame&t=233&e=3deb25e23f5fdd11d792d63bd66ced7c";
27 | public static String url_passport_p7 = "http://login.alpha.p7game.com/index/passportLogin/";// +username/password
28 | //hm change the login in url as http://login.jianniang.com/index/passportLogin/
29 | public static String url_passport_hm = "http://login.jianniang.com/index/passportLogin/";// +username/password
30 | public static String url_login = "index/login/";//+uid
31 | public static String[] url_server_p7 = {
32 | "http://zj.alpha.p7game.com/",
33 | "http://s2.zj.p7game.com/",
34 | "http://s3.zj.p7game.com/",
35 | "http://s4.zj.p7game.com/",
36 | "http://s5.zj.p7game.com/",
37 | "http://s6.zj.p7game.com/",
38 | "http://s7.zj.p7game.com/",
39 | "http://s8.zj.p7game.com/",
40 | "http://s9.zj.p7game.com/",
41 | "http://s10.zj.p7game.com/",
42 | "http://s11.zj.p7game.com/",
43 | };
44 |
45 | public static String[] url_server_hm = {
46 | "http://zj.alpha.jianniang.com/",
47 | "http://s2.jianniang.com/",
48 | "http://s3.jianniang.com/",
49 | "http://s4.jianniang.com/",
50 | "http://s5.jianniang.com/",
51 | "http://s6.jianniang.com/",
52 | "http://s7.jianniang.com/",
53 | "http://s8.jianniang.com/",
54 | "http://s9.jianniang.com/",
55 | "http://s10.jianniang.com/",
56 | "http://s11.jianniang.com/"
57 | };
58 |
59 | public static String getCurrentUnixTime() {
60 | long unixTime = System.currentTimeMillis() / 10L;
61 | return String.valueOf(unixTime);
62 | }
63 |
64 | public static void updateDockInfo(Context context){
65 | Log.i("NetworkManager", "updateDockInfo()");
66 | Log.i("NetworkManager", "Unix: " + getCurrentUnixTime());
67 | final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
68 | String username = prefs.getString("username", "none");
69 | String password = prefs.getString("password", "none");
70 | String server = prefs.getString("server", "-1");
71 | if (server.equals("-1")) return;
72 | int serverId = Integer.parseInt(server);
73 | if (serverId < 100){
74 | server = url_server_p7[serverId];
75 | } else {
76 | server = url_server_hm[serverId-100];
77 | }
78 |
79 | // Black: Alt Server
80 | boolean altserver = prefs.getBoolean("altserver", false);
81 | if (altserver){
82 | server = prefs.getString("alt_url_server", "");
83 | }
84 | // the login alt server is changed in step 1
85 |
86 | Boolean on = prefs.getBoolean("on", false);
87 | if (!on){
88 | Storage.str_tiduName = Storage.str_notOn[Storage.language];
89 | DockInfo.updateInterval = 15;
90 | return;
91 | }
92 |
93 | ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
94 | List procInfos = activityManager.getRunningAppProcesses();
95 | for (int i = 0; i < procInfos.size(); i++){
96 | String processName = procInfos.get(i).processName;
97 | if (processName.startsWith("com.muka.shipwar") || processName.startsWith("org.huanmeng.Zhanjian2")){
98 | DockInfo.updateInterval = 15;
99 | Storage.str_tiduName = Storage.str_gameRunning[Storage.language];
100 | return;
101 | }
102 | }
103 | String error = "";
104 |
105 | try {
106 | // STEP 1 PASSPORT LOGIN
107 | URL url;
108 | if (serverId < 100){
109 | url = new URL(url_passport_p7 +username+"/"+password);
110 | } else {
111 | url = new URL(url_passport_hm +username+"/"+password);
112 | }
113 | if (altserver){
114 | url = new URL(prefs.getString("alt_url_login", "") +username+"/"+password);
115 | }
116 | Log.i("NetWorkManager > 1", url.toString());
117 | URLConnection connection = url.openConnection();
118 | connection.setConnectTimeout(15000);
119 | connection.setReadTimeout(15000);
120 |
121 | BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
122 | String inputLine;
123 | StringBuffer response = new StringBuffer();
124 |
125 | while ((inputLine = in.readLine()) != null) {
126 | response.append(inputLine);
127 | }
128 |
129 | if (response.toString().contains("\"eid\"")){
130 | error = Storage.str_badLogin[Storage.language];
131 | }
132 |
133 | List cookies = connection.getHeaderFields().get("Set-Cookie");
134 | Map cookieMap = new HashMap<>();
135 | String loginCookie = parseCookie(cookies, cookieMap);
136 |
137 | in.close();
138 |
139 | JSONObject obj = new JSONObject(response.toString());
140 | int uid = obj.getInt("userId");
141 |
142 | // STEP 2 UID SERVER LOGIN
143 | url = new URL(server + url_login + uid);
144 | Log.i("NetWorkManager > 2", url.toString());
145 | connection = url.openConnection();
146 | connection.setConnectTimeout(15000);
147 | connection.setReadTimeout(15000);
148 | connection.setRequestProperty("cookie", loginCookie);
149 | cookies = connection.getHeaderFields().get("Set-Cookie");
150 | loginCookie = parseCookie(cookies, cookieMap);
151 |
152 | in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
153 | //String inputLine;
154 | response = new StringBuffer();
155 | while ((inputLine = in.readLine()) != null) {
156 | response.append(inputLine);
157 | }
158 | in.close();
159 |
160 | // STEP 3 GET USER DATA
161 | String urString;
162 | if (serverId == 0){
163 | urString = server + url_init_zero;
164 | } else if (serverId < 100){
165 | urString = server + url_init_p7;
166 | } else {
167 | urString = server + url_init_hm;
168 | }
169 |
170 | url = new URL(urString);
171 | Log.i("NetWorkManager > 3", url.toString());
172 | connection = url.openConnection();
173 | connection.setConnectTimeout(15000);
174 | connection.setReadTimeout(15000);
175 | connection.setRequestProperty("cookie", loginCookie);
176 |
177 | in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
178 | // String inputLine;
179 | response = new StringBuffer();
180 | while ((inputLine = in.readLine()) != null) {
181 | response.append(inputLine);
182 | }
183 | in.close();
184 | // Log.i("NetworkManager", response.toString());
185 | JSONObject data = new JSONObject(response.toString());
186 |
187 | if (!data.has("userVo")){
188 | error = Storage.str_noUserData[Storage.language];
189 | }
190 |
191 | Storage.str_tiduName = data.getJSONObject("userVo").getString("username");
192 | DockInfo.exp = data.getJSONObject("userVo").getString("exp");
193 | DockInfo.nextExp = data.getJSONObject("userVo").getString("nextExp");
194 | DockInfo.level = data.getJSONObject("userVo").getString("level");
195 |
196 | JSONObject pveExploreVo = data.getJSONObject("pveExploreVo");
197 | JSONArray levels = pveExploreVo.getJSONArray("levels");
198 | for (int i = 0; i < levels.length(); i++){
199 | JSONObject level = levels.getJSONObject(i);
200 | DockInfo.dockTravelTime[level.getInt("fleetId")-1] = level.getInt("endTime");
201 | }
202 |
203 | JSONArray dockVo = data.getJSONArray("dockVo");
204 | JSONArray repairDockVo = data.getJSONArray("repairDockVo");
205 | JSONArray equipmentDockVo = data.getJSONArray("equipmentDockVo");
206 | for (int i = 0; i < 4; i++){
207 | JSONObject o = dockVo.getJSONObject(i);
208 | if (o.getInt("locked") == 1){
209 | DockInfo.dockBuildTime[i] = -1;
210 | } else if (o.has("endTime")){
211 | DockInfo.dockBuildTime[i] = o.getInt("endTime");
212 | } else {
213 | DockInfo.dockBuildTime[i] = 0;
214 | }
215 | o = repairDockVo.getJSONObject(i);
216 | if (o.getInt("locked") == 1){
217 | DockInfo.dockRepairTime[i] = -1;
218 | } else if (o.has("endTime")){
219 | DockInfo.dockRepairTime[i] = o.getInt("endTime");
220 | } else {
221 | DockInfo.dockRepairTime[i] = 0;
222 | }
223 | o = equipmentDockVo.getJSONObject(i);
224 | if (o.getInt("locked") == 1){
225 | DockInfo.dockMakeTime[i] = -1;
226 | } else if (o.has("endTime")){
227 | DockInfo.dockMakeTime[i] = o.getInt("endTime");
228 | } else {
229 | DockInfo.dockMakeTime[i] = 0;
230 | }
231 | }
232 | Log.i("NetworkManager", "Update successful");
233 | DockInfo.updateInterval += 75;
234 | DockInfo.updateInterval = Math.min(DockInfo.updateInterval, 1210);
235 |
236 | // if (WeatherGuard.yes){
237 | // DockInfo.updateInterval = Math.min(DockInfo.updateInterval, 305);
238 | // WeatherGuard.dash(data, server, loginCookie);
239 | // }
240 |
241 | } catch (Exception ex) {
242 | Log.e("UpdateDockInfo()", "ERR1");
243 | ex.printStackTrace();
244 | if (error.equals("")){
245 | Storage.str_tiduName = Storage.str_badConnection[Storage.language];
246 | } else {
247 | Storage.str_tiduName = error;
248 | }
249 | if (DockInfo.updateInterval > 90){
250 | DockInfo.updateInterval = 90;
251 | } else {
252 | DockInfo.updateInterval += 15;
253 | }
254 | }
255 |
256 |
257 | }
258 |
259 | private static String parseCookie(List cookies, Map cookieMap) {
260 | for (String cookie : cookies) {
261 | String[] token = cookie.split("=");
262 | cookieMap.put(token[0], cookie);
263 | }
264 | StringBuffer sb = new StringBuffer();
265 | int size = cookieMap.size();
266 | int count = 0;
267 | for (String cookie : cookieMap.values()) {
268 | sb.append(cookie);
269 | if (++count != size) {
270 | sb.append(";");
271 | }
272 | }
273 | return sb.toString();
274 | }
275 | }
276 |
--------------------------------------------------------------------------------