Commit ce671a44 authored by liusheng's avatar liusheng

修改bug

parent f17ec01e
......@@ -6,6 +6,7 @@ data class News(
val aNickname: String?,
val aUserId: Int?,
val abbrContent: String?,
val content:String?,
val avatar: String?,
val createdDate: String?,
var greatNum: Int,
......
......@@ -102,7 +102,7 @@ class MainActivity() : XPageActivity(), TencentLocationListener {
Tencent.setIsPermissionGranted(true)
//隐私协议
if (!SettingSPUtils.isAgreePrivacy) {
PrivacyDialog(this, HttpConfig.privacy_url) {
PrivacyDialog(this, HttpConfig.HTML_HOST_PRIVACY+"index.html") {
if (it) {
SettingSPUtils.isAgreePrivacy = true
} else {
......
......@@ -5,6 +5,8 @@ import android.view.ViewGroup
import android.widget.FrameLayout
import android.widget.TextView
import com.ccwangluo.accelerator.R
import com.ccwangluo.accelerator.ui.web.AndroidActivityInterface
import com.ccwangluo.accelerator.ui.web.AndroidInterface
import com.just.agentweb.core.AgentWeb
import com.just.agentweb.core.client.DefaultWebClient
import com.xuexiang.xpage.base.XPageActivity
......@@ -42,6 +44,7 @@ class PrivacyDialog(
val container = findViewById<FrameLayout>(R.id.privacy_webview)
val agentWeb =
createAgentWeb(xPageActivity, container, privacy_url)
agentWeb.jsInterfaceHolder.addJavaObject("android", AndroidActivityInterface(xPageActivity, agentWeb!!))
mDialog.setCancelable(false)
}
......
......@@ -81,12 +81,24 @@ class NewsObjectFragment : XPageFragment() {
itemView.findViewById<TextView>(R.id.title).setText(it)
} ?: let { itemView.findViewById<TextView>(R.id.title).visibility = View.GONE }
if (itemData.type == 5){
itemData.content?.let {
itemView.findViewById<TextView>(R.id.abbrContent).visibility = View.VISIBLE
itemView.findViewById<TextView>(R.id.abbrContent).setText(it)
} ?: let {
itemView.findViewById<TextView>(R.id.abbrContent).visibility = View.GONE
}
}else{
itemData.abbrContent?.let {
itemView.findViewById<TextView>(R.id.abbrContent).visibility = View.VISIBLE
itemView.findViewById<TextView>(R.id.abbrContent).setText(it)
} ?: let {
itemView.findViewById<TextView>(R.id.abbrContent).visibility = View.GONE
}
}
// 资讯类型:0攻略 1视频
val imgs = itemView.findViewById<ImageView>(R.id.imgs)
val vedio = itemView.findViewById<JCVideoPlayerStandard>(R.id.video_view)
......
package com.ccwangluo.accelerator.ui.web
import android.os.Bundle
import android.webkit.JavascriptInterface
import com.ccwangluo.accelerator.utils.LoginUtils
import com.github.shadowsocks.http.HttpConfig
import com.ccwangluo.cc_quickly.utils.SettingSPUtils
import com.ccwangluo.cc_quickly.utils.XToastUtils
import com.just.agentweb.core.AgentWeb
import com.xuexiang.xutil.app.AppUtils
import com.xuexiang.xutil.system.PermissionUtils
import android.content.Intent
import android.net.Uri
import android.provider.Settings
import com.ccwangluo.accelerator.utils.SysUtils
import com.xuexiang.xpage.base.XPageActivity
/**
* js注入的方法
*/
class AndroidActivityInterface(val xPageActivity: XPageActivity, val agentWeb: AgentWeb) {
@JavascriptInterface
fun callAndroid(msg: String) {
XToastUtils.toast("这是Js调用Android的方法,内容:$msg")
}
@JavascriptInterface
fun close() {
xPageActivity.popPage()
}
@JavascriptInterface
fun openNative(pageName: String) {
xPageActivity.openPage(pageName)
}
@JavascriptInterface
fun openWebview(url: String) {
LoginUtils.token?.let {
val intent = Intent(xPageActivity,BlankActivity::class.java)
intent.putExtra(CommonWebViewFragment.WEBVIEW_URL_KEY, HttpConfig.UI_MAIN_URL + url)
xPageActivity?.startActivity(intent)
} ?: let {
xPageActivity?.let { it1 ->
LoginUtils.login(it1) {
LoginUtils.token?.let {
agentWeb.getJsAccessEntrace()
.quickCallJs("userToken", it)
}
}
}
}
}
/**
* 跳转协议
*/
@JavascriptInterface
fun openWebviewByWholeUrl(url: String) {
val intent = Intent(xPageActivity,BlankActivity::class.java)
if(url.startsWith("http:")||url.startsWith("https:")){
intent.putExtra(CommonWebViewFragment.WEBVIEW_URL_KEY, url)
}else{
intent.putExtra(CommonWebViewFragment.WEBVIEW_URL_KEY, HttpConfig.HTML_HOST_PRIVACY+url)
}
xPageActivity?.startActivity(intent)
}
//打开系统设置
@JavascriptInterface
fun openSysSetting() {
xPageActivity.startActivity( Intent(Settings.ACTION_SETTINGS));
}
@JavascriptInterface
fun openAsideWebview(url: String) {
val intent = Intent(xPageActivity,BlankActivity::class.java)
intent.putExtra(CommonWebViewFragment.WEBVIEW_URL_KEY, url)
xPageActivity?.startActivity(intent)
}
@JavascriptInterface
fun login(callback: String) {
xPageActivity?.let {
LoginUtils.login(it, {
if (it) {
agentWeb.getJsAccessEntrace()
.quickCallJs(callback, LoginUtils.token)
}
})
}
}
/**
* 打开外部系统浏览器
*/
@JavascriptInterface
fun goSysBrowser(url: String?) {
val uri = Uri.parse(url)
val intent = Intent(Intent.ACTION_VIEW, uri)
xPageActivity.startActivity(intent)
}
/**
* 智能极限加速
*/
@JavascriptInterface
fun setSmartAccOpen(isopen: Boolean) {
SettingSPUtils.isSmartAccOpen = isopen
}
/**
* 智能极限加速
*/
@JavascriptInterface
fun getSmartAccStatus(callback: String) {
agentWeb.getJsAccessEntrace()
.quickCallJs(callback, SettingSPUtils.isSmartAccOpen.toString())
}
/**
* 清除token
*/
@JavascriptInterface
fun clearToken() {
LoginUtils.clearToken()
}
/**
* 检查权限
*/
@JavascriptInterface
fun getPermissionState(key: String, callback: String) {
xPageActivity?.let {
val hasPermission: Boolean = PermissionUtils.isGranted(key)
agentWeb.getJsAccessEntrace()
.quickCallJs(callback, key, hasPermission.toString())
}
}
/**
* 申请权限
*/
@JavascriptInterface
fun requirePermissionState(key: String, callback: String) {
xPageActivity?.let {
PermissionUtils.permission(key).rationale({
PermissionUtils.openAppSettings()
}).callback(object : PermissionUtils.FullCallback {
override fun onGranted(permissionsGranted: MutableList<String>?) {
permissionsGranted?.forEach {
if (it.equals(key)) {
agentWeb.getJsAccessEntrace()
.quickCallJs(callback, key, "true")
}
}
}
override fun onDenied(
permissionsDeniedForever: MutableList<String>?,
permissionsDenied: MutableList<String>?
) {
permissionsDenied?.forEach {
if (it.equals(key)) {
agentWeb.getJsAccessEntrace()
.quickCallJs(callback, key, "false")
}
}
permissionsDeniedForever?.forEach {
if (it.equals(key)) {
PermissionUtils.openAppSettings()
}
}
}
}).request()
}
}
/**
* 检查安装包
*/
@JavascriptInterface
fun getPackageState(packageName: String, callback: String) {
xPageActivity?.let {
val packageInstall = SysUtils.isPackageInstall(it, packageName)
agentWeb.getJsAccessEntrace()
.quickCallJs(callback, packageName, packageInstall.toString())
}
}
/**
* 卸载程序
*/
@JavascriptInterface
fun uninstallPackge(pageName: String) {
AppUtils.uninstallApp(pageName)
}
/**
* 安装
*/
@JavascriptInterface
fun installPackge(pageName: String) {
// AppUtils.installApp(pageName)
}
/**
* 版本号
*/
@JavascriptInterface
fun getVersion(callback: String) {
agentWeb.getJsAccessEntrace()
.quickCallJs(
callback,
AppUtils.getAppVersionName(),
AppUtils.getAppVersionCode().toString()
)
}
/****************
*
* 发起添加群流程。
* 调用 joinQQGroup(09Gg-vMtnaIfgr-slk1pOkjVIFmjI79U)
*/
@JavascriptInterface
fun joinQQGroup() {
xPageActivity?.let {
SysUtils.joinQQGroup(it)
}
}
@JavascriptInterface
fun getSystemVersion(callback: String) {
agentWeb.getJsAccessEntrace()
.quickCallJs(
callback,
android.os.Build.VERSION.RELEASE,
SysUtils.getDpi(xPageActivity).toString(),android.os.Build.VERSION.SDK_INT.toString()
)
}
/**
* 获取android dpi
*/
@JavascriptInterface
fun getDpi(callback: String) {
agentWeb.getJsAccessEntrace()
.quickCallJs(callback, SysUtils.getDpi(xPageActivity).toString())
}
@JavascriptInterface
fun closeApp() {
LoginUtils.clearToken()
System.exit(0)
}
}
\ No newline at end of file
......@@ -23,7 +23,10 @@ import com.hjq.toast.ToastUtils
import java.lang.Exception
import android.util.DisplayMetrics
import com.ccwangluo.accelerator.utils.SysUtils
import com.tencent.bugly.beta.Beta
import com.tencent.bugly.beta.UpgradeInfo
import com.xuexiang.xutil.net.NetworkUtils
import org.json.JSONObject
import java.util.*
......@@ -63,7 +66,31 @@ class AndroidInterface(val xPageFragment: XPageFragment, val agentWeb: AgentWeb)
}
}
}
}
/**
* 打开外部系统浏览器
*/
@JavascriptInterface
fun goSysBrowser(url: String?) {
val uri = Uri.parse(url)
val intent = Intent(Intent.ACTION_VIEW, uri)
xPageFragment.context?.startActivity(intent)
}
/**
* 跳转协议
*/
@JavascriptInterface
fun openWebviewByWholeUrl(url: String) {
val params = Bundle()
if(url.startsWith("http:")||url.startsWith("https:")){
params.putString(CommonWebViewFragment.WEBVIEW_URL_KEY,url)
}else{
params.putString(CommonWebViewFragment.WEBVIEW_URL_KEY, HttpConfig.HTML_HOST_PRIVACY+url)
}
xPageFragment.openPage(CommonWebViewFragment::class.java, params)
}
//打开系统设置
......@@ -91,6 +118,42 @@ class AndroidInterface(val xPageFragment: XPageFragment, val agentWeb: AgentWeb)
}
}
/**
* 检查是否有更新
*/
@JavascriptInterface
fun getUpdateInfo(callback: String) {
val updateInfo: UpgradeInfo =Beta.getUpgradeInfo()
//当前版本号
jsonObject.put("current_version_name",)
val is_update:Int =0;
updateInfo?.let {
//是否有更新:1有 0没有
is_update=1;
jsonObject.put("is_update",1)
//最新安装包的版本名称
jsonObject.put("last_version_name",updateInfo.versionName)
agentWeb.jsAccessEntrace
.quickCallJs(callback, 1, AppUtils.getAppVersionName(),updateInfo.versionName)
} ?: let{
jsonObject.put("is_update",0)
jsonObject.put("last_version_name",AppUtils.getAppVersionName())
}
agentWeb.jsAccessEntrace
.quickCallJs(callback, AppUtils.getAppVersionName()jsonObject.toString())
}
/**
* 点击更新
*/
@JavascriptInterface
fun doAppUpdate() {
Beta.checkUpgrade(true,false)
}
/**
* 智能极限加速
*/
......
......@@ -138,10 +138,11 @@ object PhoneUtils {
.setLogBtnImgPath(context.resources.getDrawable(R.mipmap.login_btn_onekey))
.addCustomView(
mOtherTv, true, false
) { context, view -> context.startActivity(
Intent(context,
PhoneLoginActivity::class.java)
) }
) { context, view ->
val intent = Intent(context,PhoneLoginActivity::class.java)
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
context.startActivity(intent)
}
.setPrivacyState(false)
.setCheckedImgPath(mCheckedImg)
.setUncheckedImgPath(mCunheckedImg)
......
......@@ -17,6 +17,7 @@ import android.app.DownloadManager
import android.content.Intent
import android.net.*
import com.hjq.toast.ToastUtils
import com.xuexiang.xpage.base.XPageActivity
import java.lang.Exception
......@@ -100,6 +101,15 @@ object SysUtils {
return (dm.density * 160)
}
/**
* 获取dpi
*/
fun getDpi(xPageActivity: XPageActivity): Float {
val dm = DisplayMetrics()
xPageActivity?.windowManager?.getDefaultDisplay()?.getMetrics(dm)
return (dm.density * 160)
}
fun downloadFile(context: Context, url: String) {
val request = DownloadManager.Request(Uri.parse(url))
request.setDestinationInExternalPublicDir("", url.substring(url.lastIndexOf("/") + 1))
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="302dp"
android:orientation="vertical"
android:layout_height="418.5dp">
android:layout_height="wrap_content"
android:orientation="vertical">
<FrameLayout
android:id="@+id/privacy_webview"
android:layout_width="match_parent"
android:layout_height="364.5dp"/>
android:layout_height="364.5dp" />
<View
android:layout_width="match_parent"
android:layout_height="1px"
android:background="#F0F0F0" />
<LinearLayout
android:layout_width="match_parent"
android:orientation="horizontal"
android:layout_height="53.5dp">
android:layout_height="53.5dp"
android:orientation="horizontal">
<TextView
android:id="@+id/privacy_disagree"
android:layout_width="match_parent"
android:layout_width="0dp"
android:layout_height="match_parent"
android:text="不同意"
android:textColor="#FFA8A8A8"
android:textSize="15sp"
android:layout_weight="1"
android:gravity="center"
/>
android:text="不同意"
android:textColor="#FFA8A8A8"
android:textSize="15sp" />
<View
android:layout_width="1px"
android:layout_height="match_parent"
android:background="#F0F0F0" />
<TextView
android:id="@+id/privacy_agree"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="同意"
android:textColor="#FF3CA4FD"
android:textSize="15sp"
android:gravity="center"
/>
android:textSize="15sp" />
</LinearLayout>
......
......@@ -88,6 +88,8 @@ object AuthManager {
getLineConfig()?.let {
if (it.code != 200) {
return@withContext
}else if(it.code==1001){//vip过期
}
profile.host = it.data.host
profile.token = it.data.token
......
......@@ -11,12 +11,13 @@ object HttpConfig {
/**
* 主页h5
*/
val UI_MAIN_URL = "https://test-cc-tt-front.orangenet.org.cn/#" //测试
// val UI_MAIN_URL = "http://10.3.0.217:8080/#"
//val UI_MAIN_URL = "https://test-cc-tt-front.orangenet.org.cn/#" //测试
val UI_MAIN_URL = "http://10.3.0.217:8080/#"
// val UI_MAIN_URL = "https://cc-tt-front.srccwl.com/#" //生产
//隐私协议地址
val privacy_url = "https://sdk-static.srccwl.com/tt_html/index.html"
val HTML_HOST_PRIVACY="https://sdk-static.srccwl.com/tt_html/"
//用户协议
val url_user_agreement="https://sdk-static.srccwl.com/tt_html/service.html"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment