update 功能开启引导
This commit is contained in:
@@ -66,6 +66,12 @@
|
||||
android:launchMode="singleInstance"
|
||||
android:theme="@style/AppTheme">
|
||||
</activity>
|
||||
<activity
|
||||
android:name="org.yameida.worktool.activity.AccessibilityGuideActivity"
|
||||
android:windowSoftInputMode="adjustUnspecified|stateHidden"
|
||||
android:launchMode="singleInstance"
|
||||
android:theme="@style/AppTheme">
|
||||
</activity>
|
||||
<service
|
||||
android:name="org.yameida.worktool.service.WeworkService"
|
||||
android:enabled="true"
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
package org.yameida.worktool.activity
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.provider.Settings
|
||||
import android.view.View
|
||||
import android.view.animation.AlphaAnimation
|
||||
import android.view.animation.Animation
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.blankj.utilcode.util.LogUtils
|
||||
import com.blankj.utilcode.util.SPUtils
|
||||
import kotlinx.android.synthetic.main.activity_accessibility_guide.*
|
||||
import org.yameida.worktool.R
|
||||
import org.yameida.worktool.utils.PermissionHelper
|
||||
|
||||
/**
|
||||
* Created by gallon on 2019/7/20.
|
||||
* 提示开启无障碍服务权限
|
||||
*/
|
||||
class AccessibilityGuideActivity: AppCompatActivity() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_accessibility_guide)
|
||||
window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LOW_PROFILE or
|
||||
View.SYSTEM_UI_FLAG_FULLSCREEN or
|
||||
View.SYSTEM_UI_FLAG_LAYOUT_STABLE or
|
||||
View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY or
|
||||
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or
|
||||
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
|
||||
|
||||
tv_float_allow.setOnClickListener {
|
||||
try {
|
||||
if (!PermissionHelper.isAccessibilitySettingOn()) {
|
||||
val intent = Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS)
|
||||
startActivity(intent)
|
||||
}
|
||||
} catch (t: Throwable) {}
|
||||
}
|
||||
tv_float_reject.setOnClickListener {
|
||||
finish()
|
||||
}
|
||||
cb_guide_not.isChecked = SPUtils.getInstance().getBoolean("not_show_accessibility_guide", false)
|
||||
cb_guide_not.setOnCheckedChangeListener { buttonView, isChecked ->
|
||||
SPUtils.getInstance().put("not_show_accessibility_guide", isChecked)
|
||||
}
|
||||
|
||||
val alphaAnimation = AlphaAnimation(0.2F, 1F).apply {
|
||||
duration = 800
|
||||
repeatCount = Animation.INFINITE
|
||||
repeatMode = Animation.REVERSE
|
||||
}
|
||||
iv_over_finger.startAnimation(alphaAnimation)
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
val accessibilitySettingOn = PermissionHelper.isAccessibilitySettingOn()
|
||||
LogUtils.d("PermissionHelper.isAccessibilitySettingOn: $accessibilitySettingOn")
|
||||
if (accessibilitySettingOn) {
|
||||
finish()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,9 +10,13 @@ import android.view.animation.Animation
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.blankj.utilcode.util.LogUtils
|
||||
import com.blankj.utilcode.util.SPUtils
|
||||
import com.blankj.utilcode.util.ToastUtils
|
||||
import com.blankj.utilcode.util.Utils
|
||||
import kotlinx.android.synthetic.main.activity_float_guide.*
|
||||
import org.yameida.worktool.R
|
||||
import org.yameida.worktool.utils.FloatWindowHelper
|
||||
import org.yameida.worktool.utils.FlowPermissionHelper
|
||||
import org.yameida.worktool.utils.PermissionPageManagement
|
||||
|
||||
/**
|
||||
* Created by gallon on 2019/7/20.
|
||||
@@ -20,6 +24,8 @@ import org.yameida.worktool.R
|
||||
*/
|
||||
class FloatViewGuideActivity: AppCompatActivity() {
|
||||
|
||||
private var goToSetting = false
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_float_guide)
|
||||
@@ -61,7 +67,21 @@ class FloatViewGuideActivity: AppCompatActivity() {
|
||||
val canDrawOverlays = Settings.canDrawOverlays(Utils.getApp())
|
||||
LogUtils.d("Settings.canDrawOverlays: $canDrawOverlays")
|
||||
if (canDrawOverlays) {
|
||||
finish()
|
||||
if (goToSetting) {
|
||||
if (FlowPermissionHelper.canBackgroundStart(Utils.getApp())) {
|
||||
FloatWindowHelper.showWindow()
|
||||
}
|
||||
finish()
|
||||
} else if (!FlowPermissionHelper.canBackgroundStart(Utils.getApp())) {
|
||||
ToastUtils.showLong("请同时打开后台弹出界面权限~")
|
||||
PermissionPageManagement.goToSetting(this)
|
||||
goToSetting = true
|
||||
} else {
|
||||
if (FlowPermissionHelper.canBackgroundStart(Utils.getApp())) {
|
||||
FloatWindowHelper.showWindow()
|
||||
}
|
||||
finish()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -55,8 +55,8 @@ class ListenActivity : AppCompatActivity() {
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
sw_overlay.isChecked = PermissionUtils.isGrantedDrawOverlays()
|
||||
freshOpenServiceSwitch()
|
||||
sw_overlay.isChecked = Settings.canDrawOverlays(Utils.getApp()) && FlowPermissionHelper.canBackgroundStart(Utils.getApp())
|
||||
sw_accessibility.isChecked = PermissionHelper.isAccessibilitySettingOn()
|
||||
if (needToWork) {
|
||||
needToWork = false
|
||||
goToWork()
|
||||
@@ -126,7 +126,7 @@ class ListenActivity : AppCompatActivity() {
|
||||
sw_accessibility.isChecked = false
|
||||
ToastUtils.showLong("请先填写并保存链接号~")
|
||||
} else if (!PermissionHelper.isAccessibilitySettingOn()) {
|
||||
openAccessibility()
|
||||
startActivity(Intent(this, AccessibilityGuideActivity::class.java))
|
||||
}
|
||||
} else {
|
||||
if (PermissionHelper.isAccessibilitySettingOn()) {
|
||||
@@ -142,58 +142,19 @@ class ListenActivity : AppCompatActivity() {
|
||||
sw_overlay.setOnCheckedChangeListener(CompoundButton.OnCheckedChangeListener { buttonView, isChecked ->
|
||||
LogUtils.i("sw_overlay onCheckedChanged: $isChecked")
|
||||
if (isChecked) {
|
||||
if (!PermissionUtils.isGrantedDrawOverlays()) {
|
||||
PermissionUtils.requestDrawOverlays(object : PermissionUtils.SimpleCallback {
|
||||
override fun onGranted() {
|
||||
ToastUtils.showLong("请同时打开后台弹出界面权限~")
|
||||
PermissionPageManagement.goToSetting(this@ListenActivity)
|
||||
FloatWindowHelper.showWindow()
|
||||
}
|
||||
|
||||
override fun onDenied() { sw_accessibility.isChecked = false }
|
||||
})
|
||||
}
|
||||
startActivity(Intent(this, FloatViewGuideActivity::class.java))
|
||||
} else {
|
||||
if (PermissionUtils.isGrantedDrawOverlays()) {
|
||||
if (Settings.canDrawOverlays(Utils.getApp()) && FlowPermissionHelper.canBackgroundStart(Utils.getApp())) {
|
||||
sw_overlay.isChecked = true
|
||||
PermissionPageManagement.goToSetting(this)
|
||||
}
|
||||
}
|
||||
})
|
||||
if (PermissionUtils.isGrantedDrawOverlays()) {
|
||||
if (Settings.canDrawOverlays(Utils.getApp()) && FlowPermissionHelper.canBackgroundStart(Utils.getApp())) {
|
||||
FloatWindowHelper.showWindow()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开辅助
|
||||
*/
|
||||
private fun openAccessibility() {
|
||||
val clickListener =
|
||||
DialogInterface.OnClickListener { dialog, which ->
|
||||
freshOpenServiceSwitch()
|
||||
val intent = Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS)
|
||||
startActivity(intent)
|
||||
}
|
||||
val cancel = DialogInterface.OnCancelListener {
|
||||
freshOpenServiceSwitch()
|
||||
}
|
||||
val cancelListener = DialogInterface.OnClickListener { dialog, which ->
|
||||
freshOpenServiceSwitch()
|
||||
}
|
||||
val dialog: AlertDialog = AlertDialog.Builder(this)
|
||||
.setMessage(R.string.tips)
|
||||
.setOnCancelListener(cancel)
|
||||
.setNegativeButton("取消", cancelListener)
|
||||
.setPositiveButton("确定", clickListener)
|
||||
.create()
|
||||
dialog.show()
|
||||
}
|
||||
|
||||
private fun freshOpenServiceSwitch() {
|
||||
sw_accessibility.isChecked = PermissionHelper.isAccessibilitySettingOn()
|
||||
}
|
||||
|
||||
private fun showSelectHostDialog() {
|
||||
val hostList = SPUtils.getInstance().getStringSet("host_list", mutableSetOf(Constant.host))
|
||||
if (hostList.isNotEmpty()) {
|
||||
|
||||
@@ -78,10 +78,11 @@ class SettingsActivity : AppCompatActivity() {
|
||||
if (!FlowPermissionHelper.canBackgroundStart(Utils.getApp())) {
|
||||
ToastUtils.showLong("请同时打开后台弹出界面权限~")
|
||||
PermissionPageManagement.goToSetting(this)
|
||||
} else {
|
||||
FloatWindowHelper.showWindow()
|
||||
}
|
||||
FloatWindowHelper.showWindow()
|
||||
} else {
|
||||
startActivityForResult(Intent(this, FloatViewGuideActivity::class.java), 0)
|
||||
startActivity(Intent(this, FloatViewGuideActivity::class.java))
|
||||
}
|
||||
}
|
||||
freshOpenMain()
|
||||
@@ -94,24 +95,12 @@ class SettingsActivity : AppCompatActivity() {
|
||||
if (Constant.robotId.isBlank()) {
|
||||
ToastUtils.showLong("请先填写并保存链接号~")
|
||||
} else if (!PermissionHelper.isAccessibilitySettingOn()) {
|
||||
openAccessibility()
|
||||
startActivity(Intent(this, AccessibilityGuideActivity::class.java))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
freshOpenFlow()
|
||||
if (Settings.canDrawOverlays(Utils.getApp())) {
|
||||
if (!FlowPermissionHelper.canBackgroundStart(Utils.getApp())) {
|
||||
ToastUtils.showLong("请同时打开后台弹出界面权限~")
|
||||
PermissionPageManagement.goToSetting(this)
|
||||
}
|
||||
FloatWindowHelper.showWindow()
|
||||
}
|
||||
}
|
||||
|
||||
private fun showReplyStrategyDialog() {
|
||||
val strategyArray = arrayOf("只读消息不回调", "仅私聊和群聊@机器人回调", "私聊群聊全部回调")
|
||||
QMUIDialog.CheckableDialogBuilder(this)
|
||||
@@ -189,31 +178,6 @@ class SettingsActivity : AppCompatActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开辅助
|
||||
*/
|
||||
private fun openAccessibility() {
|
||||
val clickListener =
|
||||
DialogInterface.OnClickListener { dialog, which ->
|
||||
freshOpenMain()
|
||||
val intent = Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS)
|
||||
startActivity(intent)
|
||||
}
|
||||
val cancel = DialogInterface.OnCancelListener {
|
||||
freshOpenMain()
|
||||
}
|
||||
val cancelListener = DialogInterface.OnClickListener { dialog, which ->
|
||||
freshOpenMain()
|
||||
}
|
||||
val dialog: AlertDialog = AlertDialog.Builder(this)
|
||||
.setMessage(R.string.tips)
|
||||
.setOnCancelListener(cancel)
|
||||
.setNegativeButton("取消", cancelListener)
|
||||
.setPositiveButton("确定", clickListener)
|
||||
.create()
|
||||
dialog.show()
|
||||
}
|
||||
|
||||
private fun updateRobotQaUrl(callbackUrl: String) {
|
||||
try {
|
||||
val json = hashMapOf<String, Any>()
|
||||
|
||||
@@ -146,7 +146,7 @@ object WeworkController {
|
||||
|
||||
/**
|
||||
* 进入群聊并修改群配置
|
||||
* 群名称、群公告、拉人、踢人
|
||||
* 群名称、群公告、拉人、踢人、群备注、群模板
|
||||
* @see WeworkMessageBean.INTO_GROUP_AND_CONFIG
|
||||
* @param message#groupName 待修改的群
|
||||
* @param message#newGroupName 修改群名 选填
|
||||
|
||||
@@ -257,7 +257,7 @@ object WeworkOperationImpl {
|
||||
|
||||
/**
|
||||
* 进入群聊并修改群配置
|
||||
* 群名称、群公告、拉人、踢人
|
||||
* 群名称、群公告、拉人、踢人、群备注、群模板
|
||||
* @param groupName 待修改的群
|
||||
* @param newGroupName 修改群名 选填
|
||||
* @param newGroupAnnouncement 修改群公告 选填
|
||||
|
||||
234
app/src/main/res/layout/activity_accessibility_guide.xml
Normal file
234
app/src/main/res/layout/activity_accessibility_guide.xml
Normal file
@@ -0,0 +1,234 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center_horizontal"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="32dp"
|
||||
android:layout_marginStart="32dp"
|
||||
android:layout_marginEnd="32dp"
|
||||
android:text="允许开启无障碍服务"
|
||||
android:textColor="@color/color_333333"
|
||||
android:textSize="22sp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="18dp"
|
||||
android:layout_marginStart="18dp"
|
||||
android:layout_marginEnd="18dp"
|
||||
android:text="请开启无障碍服务,以使用WorkTool主功能"
|
||||
android:textColor="@color/color_333333"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:background="@drawable/bg_float_guide">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/rl_guide_title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_guide_icon"
|
||||
android:layout_width="75dp"
|
||||
android:layout_height="75dp"
|
||||
android:layout_marginBottom="15dp"
|
||||
android:layout_marginStart="20dp"
|
||||
android:layout_marginTop="18dp"
|
||||
android:src="@mipmap/ic_launcher" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_guide_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginStart="18dp"
|
||||
android:layout_toEndOf="@id/iv_guide_icon"
|
||||
android:text="@string/app_name"
|
||||
android:textColor="#000"
|
||||
android:textSize="22sp" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/ll_guide_permit"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/rl_guide_title"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginStart="30dp"
|
||||
android:layout_marginEnd="30dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/bar_gray">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="30dp"
|
||||
android:layout_margin="10dp"
|
||||
android:scaleX="0.9"
|
||||
android:scaleY="0.9"
|
||||
android:src="@drawable/ic_arrow_back"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="65dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:textSize="21sp"
|
||||
android:textColor="@color/white"
|
||||
android:text="无障碍"
|
||||
/>
|
||||
|
||||
<ImageView
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="30dp"
|
||||
android:layout_margin="10dp"
|
||||
android:layout_gravity="end"
|
||||
android:src="@drawable/abc_ic_menu_moreoverflow_mtrl_alpha"
|
||||
/>
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0.5dp"
|
||||
android:background="@color/color_b2000000"
|
||||
/>
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/bar_gray">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="30dp"
|
||||
android:layout_margin="10dp"
|
||||
android:src="@mipmap/ic_launcher"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="65dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:textSize="21sp"
|
||||
android:textColor="@color/white"
|
||||
android:text="@string/app_name"
|
||||
/>
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp"
|
||||
android:background="@color/while_bg">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="5dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:textSize="17sp"
|
||||
android:textColor="@color/qmui_config_color_black"
|
||||
android:text="使用WorkTool"
|
||||
/>
|
||||
|
||||
<ImageView
|
||||
android:layout_width="50dp"
|
||||
android:layout_height="50dp"
|
||||
android:layout_gravity="end"
|
||||
android:src="@drawable/widget_tip_button"
|
||||
/>
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_over_finger"
|
||||
android:layout_width="55dp"
|
||||
android:layout_height="55dp"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_below="@id/ll_guide_permit"
|
||||
android:layout_marginEnd="23dp"
|
||||
android:layout_marginTop="-15dp"
|
||||
android:src="@drawable/widget_guide_finger"
|
||||
/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_float_allow"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="30dp"
|
||||
android:layout_marginStart="30dp"
|
||||
android:layout_marginTop="30dp"
|
||||
android:background="@drawable/comment_red_btn"
|
||||
android:gravity="center"
|
||||
android:paddingBottom="7dp"
|
||||
android:paddingTop="7dp"
|
||||
android:text="允许"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="16sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_float_reject"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="30dp"
|
||||
android:layout_marginStart="30dp"
|
||||
android:layout_marginTop="15dp"
|
||||
android:background="@drawable/comment_gray_btn"
|
||||
android:gravity="center"
|
||||
android:paddingBottom="7dp"
|
||||
android:paddingTop="7dp"
|
||||
android:text="暂不使用"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="16sp" />
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="15dp">
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/cb_guide_not"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="2dp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_toEndOf="@id/cb_guide_not"
|
||||
android:text="不再询问"
|
||||
android:textColor="@color/color_333333"
|
||||
android:textSize="14sp" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</LinearLayout>
|
||||
Reference in New Issue
Block a user