Skip to content

Commit

Permalink
增加英文翻译、底部测评修改为添加设备、控制面板增加免开发面板
Browse files Browse the repository at this point in the history
  • Loading branch information
neilyhe committed Sep 24, 2024
1 parent b45d991 commit 69b2436
Show file tree
Hide file tree
Showing 14 changed files with 1,080 additions and 817 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,18 @@ import com.tencent.iot.explorer.link.kitlink.webview.WebCallBack
import kotlinx.android.synthetic.main.activity_device_panel.*
import kotlinx.android.synthetic.main.menu_back_layout.*

class DevicePanelActivity: BaseActivity(), View.OnClickListener, MyCallback, AppLifeCircleListener {
class DevicePanelActivity : BaseActivity(), View.OnClickListener, MyCallback,
AppLifeCircleListener {

private val H5_PANEL_BASE_URL = "https://iot.cloud.tencent.com/scf/h5panel/"
private var callback: WebCallBack? = null
private var deviceEntity: DeviceEntity? = null
private var editPopupWindow: EditPopupWindow? = null
private var onEventCallback: OnEventCallback? = null
private val type: String by lazy { intent.getStringExtra("type") ?: PANEL_TYPE_H5 }

override fun getContentView(): Int {
return R.layout.activity_device_panel
return R.layout.activity_device_panel
}

override fun initView() {
Expand Down Expand Up @@ -69,21 +71,7 @@ class DevicePanelActivity: BaseActivity(), View.OnClickListener, MyCallback, App
if (response.isSuccess()) {
JSBridgeKt.register("help_center_bridge", BridgeImpl::class.java)
val ticketResponse = JSON.parse(response.data.toString()) as JSONObject
var url = H5_PANEL_BASE_URL +
"?deviceId=${deviceEntity?.DeviceId}" +
"&familyId=${deviceEntity?.FamilyId}" +
"&uin=${App.uuid}" +
"&roomId=${deviceEntity?.RoomId}" +
"&familyType=${App.data.getCurrentFamily().FamilyType}" +
"&lid=${App.data.appLifeCircleId}" +
"&quid=${App.uuid}" +
"&ticket=${ticketResponse[CommonField.TOKEN_TICKET]}" +
"&appID=${T.getContext().applicationInfo.packageName}" +
"&platform=android" +
"&regionId=${App.data.regionId}"
if (deviceEntity?.shareDevice != null && deviceEntity?.shareDevice!!) {
url += "&isShareDevice=true"
}
val url = buildUrl(type, ticketResponse[CommonField.TOKEN_TICKET].toString())
showUrl(url)
} else {
T.show(response.msg)
Expand All @@ -92,6 +80,36 @@ class DevicePanelActivity: BaseActivity(), View.OnClickListener, MyCallback, App
}
}

private fun buildUrl(type: String, ticket: String): String {
return if (type == PANEL_TYPE_FREE) {
H5_PANEL_BASE_URL +
"?deviceId=${deviceEntity?.DeviceId}" +
"&familyId=${deviceEntity?.FamilyId}" +
"&roomId=${deviceEntity?.RoomId}" +
"&isShareDevice=${deviceEntity?.shareDevice != null && deviceEntity?.shareDevice!!}" +
"&ticket=${ticket}" +
"&isFreePanel=true" +
"&lang=${Utils.getLang()}"
} else {
var url = H5_PANEL_BASE_URL +
"?deviceId=${deviceEntity?.DeviceId}" +
"&familyId=${deviceEntity?.FamilyId}" +
"&uin=${App.uuid}" +
"&roomId=${deviceEntity?.RoomId}" +
"&familyType=${App.data.getCurrentFamily().FamilyType}" +
"&lid=${App.data.appLifeCircleId}" +
"&quid=${App.uuid}" +
"&ticket=${ticket}" +
"&appID=${T.getContext().applicationInfo.packageName}" +
"&platform=android" +
"&regionId=${App.data.regionId}"
if (deviceEntity?.shareDevice != null && deviceEntity?.shareDevice!!) {
url += "&isShareDevice=true"
}
url
}
}

override fun onDestroy() {
super.onDestroy()
device_panel_webview.clearHistory()
Expand Down Expand Up @@ -131,7 +149,8 @@ class DevicePanelActivity: BaseActivity(), View.OnClickListener, MyCallback, App
device_panel_webview.settings.allowContentAccess = true

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
device_panel_webview.settings.mixedContentMode = WebSettings.MIXED_CONTENT_COMPATIBILITY_MODE;
device_panel_webview.settings.mixedContentMode =
WebSettings.MIXED_CONTENT_COMPATIBILITY_MODE;
}
device_panel_webview.settings.blockNetworkImage = false
device_panel_webview.loadUrl(url)
Expand All @@ -141,11 +160,12 @@ class DevicePanelActivity: BaseActivity(), View.OnClickListener, MyCallback, App
callback = WebCallBack(device_panel_webview)
}

private val webChromeClient = object: WebChromeClient() {
override fun onShowFileChooser (
private val webChromeClient = object : WebChromeClient() {
override fun onShowFileChooser(
webView: WebView,
filePathCallback: ValueCallback<Array<Uri>>,
fileChooserParams: FileChooserParams?): Boolean {
fileChooserParams: FileChooserParams?
): Boolean {
return true
}

Expand All @@ -154,9 +174,15 @@ class DevicePanelActivity: BaseActivity(), View.OnClickListener, MyCallback, App
tv_title.text = title
}

override fun onReceivedTouchIconUrl(view: WebView?, url: String?, precomposed: Boolean) { }
override fun onReceivedTouchIconUrl(view: WebView?, url: String?, precomposed: Boolean) {}

override fun onJsPrompt(view: WebView, url: String, message: String, defaultValue: String, result: JsPromptResult): Boolean {
override fun onJsPrompt(
view: WebView,
url: String,
message: String,
defaultValue: String,
result: JsPromptResult
): Boolean {
result.confirm(JSBridgeKt.callNative(view, message))
return true
}
Expand All @@ -169,52 +195,63 @@ class DevicePanelActivity: BaseActivity(), View.OnClickListener, MyCallback, App
}
}

private val webViewClient = object: WebViewClient() {
private val webViewClient = object : WebViewClient() {
override fun shouldOverrideUrlLoading(view: WebView, url: String): Boolean {
L.e("shouldOverrideUrlLoading: " + url)
when {
url.contains("goDeviceDetailPage") -> {
jumpActivity(DeviceDetailsActivity::class.java)
callBackToH5(getCallbackId(url))
}

url.contains("goFeedBackPage") -> {
jumpActivity(FeedbackForH5Activity::class.java)
callBackToH5(getCallbackId(url))
}

url.contains("goDeviceInfoPage") -> {
jumpActivity(DeviceInfoActivity::class.java)
callBackToH5(getCallbackId(url))
}

url.contains("goEditDeviceNamePage") -> {
showEditPopup()
callBackToH5(getCallbackId(url))
}

url.contains("goRoomSettingPage") -> {
jumpActivity(SelectRoomActivity::class.java)
callBackToH5(getCallbackId(url))
}

url.contains("goShareDevicePage") -> {
jumpActivity(ShareUserListActivity::class.java)
callBackToH5(getCallbackId(url))
}

url.contains("navBack") -> {
App.data.setRefreshLevel(2) // 2: 刷新设备列表
backToMain()
callBackToH5(getCallbackId(url))
}

url.contains("reloadAfterUnmount") -> {
callBackToH5(getCallbackId(url))
}

url.contains("setShareConfig") -> {
callBackToH5(getCallbackId(url))
}

url.contains("goFirmwareUpgradePage") -> {
callBackToH5(getCallbackId(url))
}

url.contains("openBluetoothAdapter") -> {
JSBridgeKt.callNative(view, url)
onEventCallback = JSBridgeKt.onEventCallback
}

else -> {
JSBridgeKt.callNative(view, url)
}
Expand Down Expand Up @@ -291,4 +328,9 @@ class DevicePanelActivity: BaseActivity(), View.OnClickListener, MyCallback, App
jsonObject1["data"] = jsonObject2
return jsonObject1
}

companion object {
const val PANEL_TYPE_H5 = "h5"
const val PANEL_TYPE_FREE = "free"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import com.tencent.iot.explorer.link.kitlink.entity.GatewaySubDevsResp
import com.tencent.iot.explorer.link.kitlink.entity.ProdConfigDetailEntity
import com.tencent.iot.explorer.link.kitlink.entity.ProductGlobal
import com.tencent.iot.explorer.link.kitlink.fragment.CommentFragment
import com.tencent.iot.explorer.link.kitlink.fragment.DeviceCategoryFragment
import com.tencent.iot.explorer.link.kitlink.fragment.HomeFragment
import com.tencent.iot.explorer.link.kitlink.fragment.MeFragment
import com.tencent.iot.explorer.link.kitlink.fragment.SmartFragment
Expand Down Expand Up @@ -162,7 +163,7 @@ class MainActivity : PActivity(), MyCallback {
)
.addMenu(
BottomItemEntity(
getString(R.string.main_tab_4),
getString(R.string.add_device),
resources.getColor(R.color.main_tab_normal), resources.getColor(R.color.main_tab_hover),
R.mipmap.commet_unpressed, R.mipmap.commet_pressed
)
Expand All @@ -178,7 +179,11 @@ class MainActivity : PActivity(), MyCallback {
fragments.clear()
fragments.add(HomeFragment())
fragments.add(SmartFragment())
fragments.add(CommentFragment())
fragments.add(DeviceCategoryFragment().apply {
setToMainListener {
home_bottom_view.performClickAtItem(0)
}
})
fragments.add(MeFragment())
this.supportFragmentManager.beginTransaction()
.add(R.id.main_container, fragments[0])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ private void goPicture() {

private void initView() {
mToolBar = (Toolbar) findViewById(com.example.qrcode.R.id.tool_bar);
mToolBar.setTitle("二维码/条形码");
mToolBar.setTitle(getString(R.string.code_text));
mToolBar.setTitleTextColor(Color.WHITE);
mToolBar.setBackgroundColor(Color.DKGRAY);
setSupportActionBar(mToolBar);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import com.tencent.iot.explorer.link.kitlink.util.HttpRequest
import com.tencent.iot.explorer.link.core.auth.callback.MyCallback
import com.tencent.iot.explorer.link.customview.verticaltab.TabView
import com.tencent.iot.explorer.link.customview.verticaltab.VerticalTabLayout
import com.tencent.iot.explorer.link.kitlink.fragment.DeviceCategoryFragment
import com.tencent.iot.explorer.link.kitlink.util.RequestCode
import kotlinx.android.synthetic.main.activity_smart_sel_dev.vtab_device_category
import kotlinx.android.synthetic.main.menu_back_layout.*
Expand Down Expand Up @@ -107,7 +108,7 @@ class SmartSelectDevActivity : BaseActivity(), MyCallback, VerticalTabLayout.OnT
if (!roomListEnd) {
loadRoomList()
} else { // 没有数据了,开始加载所有房间的列表数据
val adapter = DeviceCategoryActivity.MyTabAdapter(this@SmartSelectDevActivity)
val adapter = DeviceCategoryFragment.MyTabAdapter(this@SmartSelectDevActivity)
for (item in roomList) {
if (TextUtils.isEmpty(item.RoomId)) {
adapter.titleList.add(getString(R.string.all_devices))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ class SmartLogAdapter(context: Context, list: MutableList<LogMessage>) : Recycle
holder.taskName.setText(list.get(position).automationName)
}

holder.taskDesc.setText(list.get(position).time + " " + list.get(position).result)
val result = if (list.get(position).resultCode == 0) context?.getString(R.string.execute_success_text) else context?.getString(R.string.execute_failed_text)
holder.taskDesc.setText(list.get(position).time + " " + result)
holder.failedDetail.adapter = ActionResultAdapter(context, list.get(position).actionResults)

holder.allLayout.setOnClickListener{
Expand Down
Loading

0 comments on commit 69b2436

Please sign in to comment.