소스 검색

主界面和事件界面隐藏虚拟导航栏,主界面恢复时检查是否有未处理事件,有则显示

weizhengliang 2 년 전
부모
커밋
6a33decb4c

+ 5 - 1
app/src/main/AndroidManifest.xml

@@ -48,7 +48,11 @@
 <!--            >-->
 <!--        <activity android:name="com.wdkl.ncs.android.component.home.activity.WatchRegisterActivity">-->
 <!--        <activity android:name="com.starrtc.demo.demo.SplashActivity">-->
-        <activity android:name="com.wdkl.ncs.android.component.home.activity.WatchHome2Activity" android:screenOrientation="portrait">
+        <activity android:name="com.wdkl.ncs.android.component.home.activity.WatchHome2Activity"
+            android:showOnLockScreen="true"
+            android:showWhenLocked="true"
+            android:launchMode="singleInstance"
+            android:screenOrientation="portrait">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN"/>
 

+ 4 - 0
home/src/main/AndroidManifest.xml

@@ -42,8 +42,12 @@
         <activity android:screenOrientation="portrait" android:name=".activity.TakeoverActivity" />
         <activity android:screenOrientation="portrait" android:name=".activity.AppUpdateActivity" />
         <activity android:screenOrientation="portrait" android:name=".activity.NewEventListActivity"
+            android:showOnLockScreen="true"
+            android:showWhenLocked="true"
             android:launchMode="singleTask"/>
         <activity android:screenOrientation="portrait" android:name=".activity.NewCallListActivity"
+            android:showOnLockScreen="true"
+            android:showWhenLocked="true"
             android:launchMode="singleTask"/>
         <activity android:name=".activity.VoiceMsgActivity" android:screenOrientation="portrait"/>
         <activity android:name=".activity.ChannelImActivity" android:screenOrientation="portrait"/>

+ 9 - 0
home/src/main/code/com/wdkl/ncs/android/component/home/activity/BaseActivity.kt

@@ -10,6 +10,7 @@ import android.os.Looper
 import android.os.Message
 import android.view.KeyEvent
 import android.view.View
+import android.view.WindowManager
 import android.view.inputmethod.InputMethodManager
 import com.enation.javashop.android.jrouter.JRouter
 import com.enation.javashop.utils.base.tool.BaseToolActivity
@@ -71,6 +72,11 @@ abstract class BaseActivity<PresenterType : BaseContract.BasePresenter, DataBind
      */
     protected val disposableManager by lazy { DisposableManager() }
 
+    protected val screen_flags = (
+            View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
+                    or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
+                    or View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY)
+
     /**
      * @author  LDD
      * @From   com.wdkl.ncs.android.component.home.activity.BaseActivity
@@ -85,6 +91,9 @@ abstract class BaseActivity<PresenterType : BaseContract.BasePresenter, DataBind
         }
         /**父类初始化*/
         super.onCreate(savedInstanceState)
+
+        window.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED or WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON)
+
         /**执行生命周期监听*/
         lifeCycleDo(LIFE_CYCLE_CREATE)
         /**创建根视图*/

+ 11 - 0
home/src/main/code/com/wdkl/ncs/android/component/home/activity/NewCallListActivity.kt

@@ -53,6 +53,11 @@ class NewCallListActivity : BaseToolActivity(), NewCallItemAdapter.CallClickList
 
     private var transSeconds = 15
 
+    private val screen_flags = (
+            View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
+                    or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
+                    or View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY)
+
     override fun onCreate(savedInstanceState: Bundle?) {
         super.onCreate(savedInstanceState)
 
@@ -213,8 +218,14 @@ class NewCallListActivity : BaseToolActivity(), NewCallItemAdapter.CallClickList
         }.start()
     }
 
+    override fun onWindowFocusChanged(hasFocus: Boolean) {
+        super.onWindowFocusChanged(hasFocus)
+        window.decorView.systemUiVisibility = screen_flags
+    }
+
     override fun onResume() {
         super.onResume()
+        window.decorView.systemUiVisibility = screen_flags
         updateCallList()
     }
 

+ 11 - 1
home/src/main/code/com/wdkl/ncs/android/component/home/activity/NewEventListActivity.kt

@@ -79,6 +79,13 @@ class NewEventListActivity : BaseActivity<NewEventListPresenter, ActivityEventLi
         rv_event_list.adapter = delegateAdapter
     }
 
+    override fun onWindowFocusChanged(hasFocus: Boolean) {
+        super.onWindowFocusChanged(hasFocus)
+        if (!Constants.oldEvent) {
+            window.decorView.systemUiVisibility = screen_flags
+        }
+    }
+
     override fun bindEvent() {
         adapter.setOnItemClickListener { data, position ->
             if (Constants.assignRole) {
@@ -100,6 +107,9 @@ class NewEventListActivity : BaseActivity<NewEventListPresenter, ActivityEventLi
 
     override fun onResume() {
         super.onResume()
+        if (!Constants.oldEvent) {
+            window.decorView.systemUiVisibility = screen_flags
+        }
         WdKeepAliveService.mNewEventListActive = true
         renderData(Constants.eventList)
         if (!MediaPlayHelper.getInstance().isMediaPlaying) {
@@ -126,7 +136,7 @@ class NewEventListActivity : BaseActivity<NewEventListPresenter, ActivityEventLi
     override fun renderData(data: ArrayList<InteractionVO>) {
         Log.e(TAG,"返回的数据 "+data.size)
         //data.sortByDescending { it.id }
-        srl_event_list.finishRefresh()
+        //srl_event_list.finishRefresh()
         if (data.size > 0) {
             adapter.data.clear()
             adapter.data.addAll(data)

+ 24 - 0
home/src/main/code/com/wdkl/ncs/android/component/home/activity/WatchHome2Activity.kt

@@ -57,6 +57,7 @@ import com.wdkl.rtc.util.JanusConstant
 import io.reactivex.Observable
 import kotlinx.android.synthetic.main.watch_activity_home2.*
 import kotlinx.android.synthetic.main.watch_activity_register.*
+import org.greenrobot.eventbus.EventBus
 import org.greenrobot.eventbus.Subscribe
 import org.greenrobot.eventbus.ThreadMode
 
@@ -98,6 +99,11 @@ class WatchHome2Activity : BaseActivity<WatchHomeActivityPresenter, WatchActivit
         HomeLaunch.component.inject(this)
     }
 
+    override fun onWindowFocusChanged(hasFocus: Boolean) {
+        super.onWindowFocusChanged(hasFocus)
+        window.decorView.systemUiVisibility = screen_flags
+    }
+
     //初始化
     override fun init() {
 //        DaemonEnv.sendStopWorkBroadcast(this)
@@ -634,6 +640,8 @@ class WatchHome2Activity : BaseActivity<WatchHomeActivityPresenter, WatchActivit
 
     override fun onResume() {
         super.onResume()
+        window.decorView.systemUiVisibility = screen_flags
+
         //主界面恢复时检查tcp连接状态
         Log.d(TAG, "Watch home activity resumed...")
         if (TcpClientHandler.getConnected()) {
@@ -649,6 +657,22 @@ class WatchHome2Activity : BaseActivity<WatchHomeActivityPresenter, WatchActivit
         /*if (!Constants.showFloatWindow) {
             DeviceChannel.calling = false
         }*/
+
+        //未处理的来电
+        if (Constants.newCallList.size > 0) {
+            val intent = Intent()
+            intent.setClass(this, NewCallListActivity::class.java)
+            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
+            startActivity(intent)
+        }
+
+        //检查当前是否还有未处理事件,有则显示
+        if (Constants.eventList.size > 0) {
+            val intent = Intent()
+            intent.setClass(this, NewEventListActivity::class.java)
+            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
+            startActivity(intent)
+        }
     }
 
     override fun onError(message: String, type: Int) {

+ 4 - 3
home/src/main/res/layout/activity_call_list.xml

@@ -4,7 +4,8 @@
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:orientation="vertical"
-    android:background="#FFBDC3">
+    android:background="#FFBDC3"
+    android:fitsSystemWindows="true">
 
     <com.scwang.smartrefresh.layout.SmartRefreshLayout
         android:id="@+id/srl_call_list"
@@ -12,8 +13,8 @@
         android:layout_height="match_parent"
         android:layout_marginLeft="3sp"
         android:layout_marginRight="3sp"
-        bind:srlEnableLoadMore="true"
-        bind:srlEnableRefresh="true">
+        bind:srlEnableLoadMore="false"
+        bind:srlEnableRefresh="false">
         <android.support.v7.widget.RecyclerView
             android:id="@+id/rv_call_list"
             android:layout_width="match_parent"

+ 3 - 2
home/src/main/res/layout/activity_event_list.xml

@@ -3,6 +3,7 @@
     <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
+        android:fitsSystemWindows="true"
         android:background="#FFBDC3">
         <TextView
             android:id="@+id/tv_empty_event"
@@ -20,8 +21,8 @@
             android:layout_height="match_parent"
             android:layout_marginLeft="3sp"
             android:layout_marginRight="3sp"
-            bind:srlEnableLoadMore="true"
-            bind:srlEnableRefresh="true">
+            bind:srlEnableLoadMore="false"
+            bind:srlEnableRefresh="false">
             <android.support.v7.widget.RecyclerView
                 android:id="@+id/rv_event_list"
                 android:layout_width="match_parent"

+ 2 - 1
home/src/main/res/layout/watch_activity_home2.xml

@@ -3,7 +3,8 @@
 
     <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
         android:layout_width="match_parent"
-        android:layout_height="match_parent">
+        android:layout_height="match_parent"
+        android:fitsSystemWindows="true">
 
         <include
             android:id="@+id/watch_activity_register_layout"