Skip to content

Commit 322ad88

Browse files
[#581] 修复问题反馈、使用说明、常见问题和开发文档,点击后只会弹出一个toast提示,无法进入页面的问题 (#582)
1 parent 733bf8a commit 322ad88

File tree

10 files changed

+286
-21
lines changed

10 files changed

+286
-21
lines changed

debug/shell/android/app-impl/src/main/AndroidManifest.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22

33
<!--
4-
Copyright (c) 2021-2022, the hapjs-platform Project Contributors
4+
Copyright (c) 2021-present, the hapjs-platform Project Contributors
55
SPDX-License-Identifier: Apache-2.0
66
-->
77

@@ -87,6 +87,10 @@
8787
android:label="@string/choose_app_label"
8888
android:theme="@style/AppTheme.InstalledApp" />
8989

90+
<activity
91+
android:name="org.hapjs.debugger.WebActivity"
92+
android:theme="@style/AppTheme.InstalledApp"/>
93+
9094
<provider
9195
android:name="androidx.core.content.FileProvider"
9296
android:authorities="org.hapjs.debugger.file"

debug/shell/android/app-impl/src/main/java/org/hapjs/debugger/SettingsActivity.java

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
/*
2-
* Copyright (c) 2021-2022, the hapjs-platform Project Contributors
2+
* Copyright (c) 2021-present, the hapjs-platform Project Contributors
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

66
package org.hapjs.debugger;
77

88
import android.app.Fragment;
9+
import android.content.Intent;
910
import android.graphics.Color;
1011
import android.net.Uri;
1112
import android.os.Bundle;
@@ -170,17 +171,23 @@ public void onDisplayPreferenceDialog(Preference preference) {
170171

171172
@Override
172173
public boolean onPreferenceTreeClick(Preference preference) {
173-
if (preference.getKey().equals(getString(R.string.setting_item_feedback_key))) {
174-
Toast.makeText(getActivity(), R.string.setting_item_feedback, Toast.LENGTH_SHORT).show();
175-
return true;
176-
} else if (preference.getKey().equals(getString(R.string.setting_item_instruction_key))) {
177-
Toast.makeText(getActivity(), R.string.setting_item_instruction, Toast.LENGTH_SHORT).show();
174+
if (preference.getKey().equals(getString(R.string.setting_item_instruction_key))) {
175+
Intent intent = new Intent(getActivity(), WebActivity.class);
176+
intent.putExtra(WebActivity.KEY_URL, "https://doc.quickapp.cn/ide/machine-debug.html");
177+
intent.putExtra(WebActivity.KEY_TITLE, preference.getTitle());
178+
getActivity().startActivity(intent);
178179
return true;
179180
} else if (preference.getKey().equals(getString(R.string.setting_item_faq_key))) {
180-
Toast.makeText(getActivity(), R.string.setting_item_faq, Toast.LENGTH_SHORT).show();
181+
Intent intent = new Intent(getActivity(), WebActivity.class);
182+
intent.putExtra(WebActivity.KEY_URL, "https://faq.quickapp.cn/");
183+
intent.putExtra(WebActivity.KEY_TITLE, preference.getTitle());
184+
getActivity().startActivity(intent);
181185
return true;
182186
} else if (preference.getKey().equals(getString(R.string.setting_item_doc_key))) {
183-
Toast.makeText(getActivity(), R.string.setting_item_doc, Toast.LENGTH_SHORT).show();
187+
Intent intent = new Intent(getActivity(), WebActivity.class);
188+
intent.putExtra(WebActivity.KEY_URL, "https://doc.quickapp.cn/");
189+
intent.putExtra(WebActivity.KEY_TITLE, preference.getTitle());
190+
getActivity().startActivity(intent);
184191
return true;
185192
}
186193
return super.onPreferenceTreeClick(preference);
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
/*
2+
* Copyright (c) 2023, the hapjs-platform Project Contributors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package org.hapjs.debugger;
7+
8+
import android.app.Activity;
9+
import android.content.Context;
10+
import android.content.res.Resources;
11+
import android.util.AttributeSet;
12+
import android.view.View;
13+
import android.widget.ImageView;
14+
import android.widget.RelativeLayout;
15+
import android.widget.TextView;
16+
17+
import org.hapjs.debugger.app.impl.R;
18+
19+
public class TitleBar extends RelativeLayout implements View.OnClickListener {
20+
public static final int STYLE_TITLE_BACK = 0;
21+
22+
private Context mContext;
23+
private Resources mRes;
24+
25+
private ImageView mBackIcon;
26+
private TextView mTitle;
27+
private int mStyle;
28+
29+
public TitleBar(Context context) {
30+
this(context, null);
31+
}
32+
33+
public TitleBar(Context context, AttributeSet attrs) {
34+
super(context, attrs);
35+
36+
mContext = context;
37+
mRes = getResources();
38+
mStyle = STYLE_TITLE_BACK;
39+
}
40+
41+
@Override
42+
protected void onFinishInflate() {
43+
super.onFinishInflate();
44+
initViews();
45+
}
46+
47+
private void initViews() {
48+
mBackIcon = findViewById(R.id.back_icon);
49+
mTitle = findViewById(R.id.title);
50+
mBackIcon.setOnClickListener(this);
51+
}
52+
53+
@Override
54+
public void onClick(View v) {
55+
if (!(mContext instanceof Activity)) {
56+
return;
57+
}
58+
if (v.getId() == R.id.back_icon) {
59+
((Activity) mContext).onBackPressed();
60+
}
61+
}
62+
63+
public void setStyleOnly(int style) {
64+
setStyleAndTitle(style, "");
65+
}
66+
67+
public void setStyleAndTitle(int style, int resId) {
68+
setStyleAndTitle(style, mRes.getString(resId));
69+
}
70+
71+
public void setStyleAndTitle(int style, String title) {
72+
mStyle = style;
73+
74+
switch (style) {
75+
case STYLE_TITLE_BACK:
76+
mBackIcon.setVisibility(VISIBLE);
77+
mTitle.setText(title);
78+
mTitle.setVisibility(VISIBLE);
79+
break;
80+
default:
81+
break;
82+
}
83+
}
84+
85+
public void setBackListener(OnClickListener backListener) {
86+
if (mBackIcon != null) {
87+
mBackIcon.setOnClickListener(backListener);
88+
}
89+
}
90+
}
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
/*
2+
* Copyright (c) 2023, the hapjs-platform Project Contributors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package org.hapjs.debugger;
7+
8+
import android.annotation.SuppressLint;
9+
import android.graphics.Color;
10+
import android.os.Build;
11+
import android.os.Bundle;
12+
import android.view.View;
13+
import android.view.WindowManager;
14+
import android.webkit.WebSettings;
15+
import android.webkit.WebView;
16+
import android.webkit.WebViewClient;
17+
import android.widget.FrameLayout;
18+
19+
import androidx.annotation.Nullable;
20+
import androidx.appcompat.app.AppCompatActivity;
21+
22+
import org.hapjs.debugger.app.impl.R;
23+
24+
25+
public class WebActivity extends AppCompatActivity {
26+
private TitleBar mTitleBar;
27+
private FrameLayout mFlContainer;
28+
private WebView mWebView;
29+
public static final String KEY_URL = "url";
30+
public static final String KEY_TITLE = "title";
31+
32+
@Override
33+
public void onCreate(@Nullable Bundle savedInstanceState) {
34+
super.onCreate(savedInstanceState);
35+
setStatusBar();
36+
setContentView(R.layout.activity_web);
37+
init();
38+
}
39+
40+
private void setStatusBar() {
41+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
42+
View decorView = getWindow().getDecorView();
43+
int option = 0;
44+
option = View.SYSTEM_UI_FLAG_VISIBLE
45+
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE
46+
| View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
47+
decorView.setSystemUiVisibility(option);
48+
getWindow().setStatusBarColor(Color.TRANSPARENT);
49+
} else {
50+
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
51+
}
52+
}
53+
54+
@SuppressLint("SetJavaScriptEnabled")
55+
private void init() {
56+
mTitleBar = findViewById(R.id.title_bar);
57+
mTitleBar.setStyleAndTitle(TitleBar.STYLE_TITLE_BACK, getIntent().getStringExtra(KEY_TITLE));
58+
mTitleBar.setBackListener(v -> finish());
59+
mFlContainer = findViewById(R.id.fl_container);
60+
mWebView = new WebView(this);
61+
mWebView.getSettings().setJavaScriptEnabled(true);
62+
mWebView.getSettings().setAllowFileAccessFromFileURLs(false);
63+
mWebView.getSettings().setAllowUniversalAccessFromFileURLs(false);
64+
mWebView.getSettings().setDomStorageEnabled(true);
65+
mWebView.getSettings().setUseWideViewPort(true);
66+
mWebView.getSettings().setSupportZoom(true);
67+
mWebView.getSettings().setBuiltInZoomControls(true);
68+
mWebView.getSettings().setDisplayZoomControls(false);
69+
mWebView.getSettings().setLoadWithOverviewMode(true);
70+
mWebView.getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.TEXT_AUTOSIZING);
71+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
72+
mWebView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
73+
}
74+
mWebView.getSettings().setTextZoom(100);
75+
mWebView.setWebViewClient(new WebViewClient());
76+
mFlContainer.addView(mWebView);
77+
String url = getIntent().getStringExtra(KEY_URL);
78+
mWebView.loadUrl(url);
79+
}
80+
81+
@Override
82+
public void onBackPressed() {
83+
if(mWebView.canGoBack()) {
84+
mWebView.goBack();
85+
} else {
86+
super.onBackPressed();
87+
}
88+
}
89+
90+
@Override
91+
protected void onDestroy() {
92+
if(mFlContainer != null) {
93+
mFlContainer.removeAllViews();
94+
}
95+
if(mWebView != null) {
96+
mWebView.destroy();
97+
mWebView = null;
98+
}
99+
super.onDestroy();
100+
}
101+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
Copyright (c) 2023, the hapjs-platform Project Contributors
4+
SPDX-License-Identifier: Apache-2.0
5+
-->
6+
<LinearLayout
7+
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
8+
android:layout_height="match_parent"
9+
android:orientation="vertical">
10+
11+
<include
12+
android:id="@+id/title_bar"
13+
layout="@layout/common_title_bar" />
14+
15+
<FrameLayout
16+
android:id="@+id/fl_container"
17+
android:layout_width="match_parent"
18+
android:layout_height="match_parent"/>
19+
</LinearLayout>
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
Copyright (c) 2023, the hapjs-platform Project Contributors
4+
SPDX-License-Identifier: Apache-2.0
5+
-->
6+
<org.hapjs.debugger.TitleBar xmlns:android="http://schemas.android.com/apk/res/android"
7+
android:id="@+id/title_bar"
8+
android:layout_width="match_parent"
9+
android:layout_height="52dp"
10+
android:layout_marginBottom="0.5dp"
11+
android:background="@android:color/white">
12+
13+
<RelativeLayout
14+
android:id="@+id/title_back_panel"
15+
android:layout_width="wrap_content"
16+
android:layout_height="match_parent"
17+
android:gravity="center_vertical">
18+
19+
<ImageView
20+
android:id="@+id/back_icon"
21+
android:layout_width="wrap_content"
22+
android:layout_height="match_parent"
23+
android:layout_centerVertical="true"
24+
android:layout_marginStart="21dp"
25+
android:src="@drawable/back"
26+
android:visibility="visible" />
27+
28+
<TextView
29+
android:id="@+id/title"
30+
style="@style/common_title_text_style"
31+
android:layout_width="wrap_content"
32+
android:layout_height="match_parent"
33+
android:layout_gravity="center_vertical"
34+
android:layout_marginStart="21dp"
35+
android:layout_toEndOf="@+id/back_icon"
36+
android:ellipsize="end"
37+
android:gravity="start|center_vertical"
38+
android:singleLine="true"
39+
android:text="@string/feedback_title"
40+
android:textDirection="locale"
41+
android:textSize="16sp"
42+
android:visibility="visible" />
43+
</RelativeLayout>
44+
</org.hapjs.debugger.TitleBar>

debug/shell/android/app-impl/src/main/res/values-zh-rCN/strings.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22

33
<!--
4-
Copyright (c) 2021-2022, the hapjs-platform Project Contributors
4+
Copyright (c) 2021-present, the hapjs-platform Project Contributors
55
SPDX-License-Identifier: Apache-2.0
66
-->
77

@@ -106,7 +106,6 @@
106106
<string name="setting_item_set_params_hint">如: /pageName?key=value 或 key=value</string>
107107
<string name="toast_params_illegal">参数不能包含\"__DEBUG_PARAMS__\"</string>
108108
<string name="setting_category_help">帮助</string>
109-
<string name="setting_item_feedback">问题反馈</string>
110109
<string name="setting_item_instruction">使用说明</string>
111110
<string name="setting_item_faq">常见问题</string>
112111
<string name="setting_item_doc">开发文档</string>
@@ -158,4 +157,5 @@
158157
<string name="toast_app_not_install">应用未安装</string>
159158
<string name="toast_invalid_pem">文件格式错误</string>
160159
<string name="str_save">保存</string>
160+
<string name="feedback_title">问题反馈</string>
161161
</resources>

debug/shell/android/app-impl/src/main/res/values/strings.xml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22

33
<!--
4-
Copyright (c) 2021-2022, the hapjs-platform Project Contributors
4+
Copyright (c) 2021-present, the hapjs-platform Project Contributors
55
SPDX-License-Identifier: Apache-2.0
66
-->
77

@@ -109,7 +109,6 @@
109109
<string name="setting_item_set_params_hint">Example: /pageName?key=value or key=value</string>
110110
<string name="toast_params_illegal">Params cannot contain \"__DEBUG_PARAMS__\"</string>
111111
<string name="setting_category_help">Help</string>
112-
<string name="setting_item_feedback">Feedback</string>
113112
<string name="setting_item_instruction">Instructions</string>
114113
<string name="setting_item_faq">FAQ</string>
115114
<string name="setting_item_doc">Document</string>
@@ -119,7 +118,6 @@
119118
<string name="setting_item_wait_connect_key" translatable="false">setting_item_wait_connect</string>
120119
<string name="setting_item_web_debug_key" translatable="false">setting_item_web_debug</string>
121120
<string name="setting_item_reload_key" translatable="false">setting_item_reload</string>
122-
<string name="setting_item_feedback_key" translatable="false">setting_item_feedback</string>
123121
<string name="setting_item_instruction_key" translatable="false">setting_item_instruction</string>
124122
<string name="setting_item_faq_key" translatable="false">setting_item_faq</string>
125123
<string name="setting_item_doc_key" translatable="false">setting_item_doc</string>
@@ -171,4 +169,5 @@
171169
<string name="toast_app_not_install">The App is not installed</string>
172170
<string name="toast_invalid_pem">Invalid PEM file</string>
173171
<string name="str_save">Save</string>
172+
<string name="feedback_title">Question Feedback </string>
174173
</resources>

debug/shell/android/app-impl/src/main/res/values/styles.xml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22

33
<!--
4-
Copyright (c) 2021-2022, the hapjs-platform Project Contributors
4+
Copyright (c) 2021-present, the hapjs-platform Project Contributors
55
SPDX-License-Identifier: Apache-2.0
66
-->
77

@@ -108,4 +108,10 @@
108108
<item name="corner_radius">16dp</item>
109109
<item name="android:background">@drawable/hint_popup_color_bg</item>
110110
</style>
111+
112+
<style name="common_title_text_style">
113+
<item name="android:textSize">16sp</item>
114+
<item name="android:textColor">@android:color/black</item>
115+
<item name="android:textStyle">bold</item>
116+
</style>
111117
</resources>

0 commit comments

Comments
 (0)