Forráskód Böngészése

完成主控模块

zhaofuxin 4 éve
szülő
commit
e8bfd28cf3
55 módosított fájl, 2520 hozzáadás és 100 törlés
  1. 5 2
      app/build.gradle
  2. 8 4
      app/src/main/AndroidManifest.xml
  3. 87 6
      app/src/main/java/com/jld/vod/base/BaseActivity.kt
  4. 36 1
      app/src/main/java/com/jld/vod/base/MyApplication.kt
  5. 15 2
      app/src/main/java/com/jld/vod/config/Config.kt
  6. 11 0
      app/src/main/java/com/jld/vod/interfaces/OnConnectionStateListener.java
  7. 9 0
      app/src/main/java/com/jld/vod/interfaces/OnMessageReceiveListener.java
  8. 28 0
      app/src/main/java/com/jld/vod/interfaces/remote/Apis.kt
  9. 24 0
      app/src/main/java/com/jld/vod/model/bean/ContextBean.java
  10. 22 0
      app/src/main/java/com/jld/vod/model/bean/GEOAdvertBean.kt
  11. 15 0
      app/src/main/java/com/jld/vod/model/bean/PositionAdvertBean.kt
  12. 9 0
      app/src/main/java/com/jld/vod/model/event/ReceiveEvent.java
  13. 57 16
      app/src/main/java/com/jld/vod/service/LatLongService.kt
  14. 5 1
      app/src/main/java/com/jld/vod/service/MyAccessibilityService.kt
  15. 53 0
      app/src/main/java/com/jld/vod/service/PositionAdvertService.kt
  16. 174 0
      app/src/main/java/com/jld/vod/service/SocketService.kt
  17. 58 0
      app/src/main/java/com/jld/vod/socket/ReceiveSocketManager.java
  18. 168 0
      app/src/main/java/com/jld/vod/socket/ReceiveUDPSocket.java
  19. 64 0
      app/src/main/java/com/jld/vod/socket/SendSocketManager.java
  20. 133 0
      app/src/main/java/com/jld/vod/socket/SendUDPSocket.java
  21. 4 3
      app/src/main/java/com/jld/vod/ui/XBasicLibInit.kt
  22. 36 3
      app/src/main/java/com/jld/vod/utils/SilentInstall.java
  23. 127 0
      app/src/main/java/com/jld/vod/utils/WifiUtil.java
  24. 142 0
      app/src/main/java/com/jld/vod/utils/WinCallback.java
  25. 33 0
      app/src/main/java/com/jld/vod/utils/http/RetrofitUtils.kt
  26. 4 0
      app/src/main/java/com/jld/vod/view/HomeActivity.kt
  27. 71 14
      app/src/main/java/com/jld/vod/view/MainActivity.kt
  28. 6 5
      app/src/main/java/com/jld/vod/view/MusicPlayActivity.kt
  29. 10 0
      app/src/main/java/com/jld/vod/view/OrderActivity.kt
  30. 1 0
      app/src/main/java/com/jld/vod/view/PostFileActivity.kt
  31. 43 0
      app/src/main/java/com/jld/vod/view/SettingsActivity.kt
  32. 96 32
      app/src/main/java/com/jld/vod/view/SplashActivity.kt
  33. 64 6
      app/src/main/java/com/jld/vod/view/VideoPlayActivity.kt
  34. 53 0
      app/src/main/java/com/jld/vod/view/fragment/OrderFragment.kt
  35. 151 0
      app/src/main/java/com/jld/vod/view/widget/CustomAdDialog.java
  36. 110 0
      app/src/main/java/com/jld/vod/view/widget/CustomBlackBgDialog.java
  37. 166 0
      app/src/main/java/com/jld/vod/view/widget/CustomGEOAdDialog.java
  38. 2 2
      app/src/main/java/com/jld/vod/view/widget/CustomProgressDialog.kt
  39. 163 0
      app/src/main/java/com/jld/vod/view/widget/CustomScreenAdDialog.java
  40. 23 1
      app/src/main/java/com/jld/vod/viewmodel/MainViewModel.kt
  41. 20 0
      app/src/main/java/com/jld/vod/viewmodel/SplashViewModel.kt
  42. 5 0
      app/src/main/res/anim/dialog_scale_action.xml
  43. 32 0
      app/src/main/res/layout/activity_order.xml
  44. 32 2
      app/src/main/res/layout/activity_play_video.xml
  45. 36 0
      app/src/main/res/layout/custom_ad_dialog.xml
  46. 28 0
      app/src/main/res/layout/custom_geo_ad_dialog.xml
  47. 7 0
      app/src/main/res/layout/custom_geo_black_dialog.xml
  48. 11 0
      app/src/main/res/layout/custom_screen_ad_dialog.xml
  49. 32 0
      app/src/main/res/layout/fragment_order.xml
  50. BIN
      app/src/main/res/mipmap-hdpi/close_ads_icon.png
  51. BIN
      app/src/main/res/mipmap-hdpi/order_icon.png
  52. 4 0
      app/src/main/res/values-zh-rCN/strings.xml
  53. 4 0
      app/src/main/res/values/strings.xml
  54. 15 0
      app/src/main/res/values/styles.xml
  55. 8 0
      app/src/main/res/xml/root_preferences.xml

+ 5 - 2
app/build.gradle

@@ -70,8 +70,11 @@ dependencies {
     //xui
     implementation 'com.github.xuexiangjys:XUI:1.1.4'
     //XPage
-    implementation 'com.github.xuexiangjys.XPage:xpage-lib:2.2.8'
-    kapt 'com.github.xuexiangjys.XPage:xpage-compiler:2.2.8'
+//    implementation 'com.github.xuexiangjys.XPage:xpage-lib:2.2.8'
+//    kapt 'com.github.xuexiangjys.XPage:xpage-compiler:2.2.8'
+    // XPage
+    implementation 'com.github.xuexiangjys.XPage:xpage-lib:3.1.1'
+    kapt 'com.github.xuexiangjys.XPage:xpage-compiler:3.1.1'
     //XRouter
 //    implementation 'com.github.xuexiangjys.XRouter:xrouter-runtime:1.0.1'
 //    annotationProcessor 'com.github.xuexiangjys.XRouter:xrouter-compiler:1.0.1'

+ 8 - 4
app/src/main/AndroidManifest.xml

@@ -11,15 +11,16 @@
     <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
     <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
     <uses-permission android:name="android.permission.INTERNET" />
-    <uses-permission android:name="android.permission.WRITE_SETTINGS"
-        tools:ignore="ProtectedPermissions" />
+    <uses-permission android:name="android.permission.WRITE_SETTINGS" />
     <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
-    <uses-permission android:name="android.permission.BIND_ACCESSIBILITY_SERVICE"
-        tools:ignore="ProtectedPermissions" />
+    <uses-permission android:name="android.permission.BIND_ACCESSIBILITY_SERVICE" />
     <uses-permission android:name="permission.CHANGE_CONFIGURATION"/>
     <uses-permission android:name="android.permission.DELETE_PACKAGES" />
     <uses-permission android:name="android.permission.WRITE_SETTINGS" />
     <uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />
+    <uses-permission android:name="android.permission.INSTALL_PACKAGES"/>
+    <uses-permission android:name="android.permission.CLEAR_APP_USER_DATA"/>
+    <uses-permission android:name="android.permission.CLEAR_APP_CACHE"/>
 
     <application
         android:name=".base.MyApplication"
@@ -79,6 +80,7 @@
         <activity android:name=".view.AboutActivity"/>
         <activity android:name=".view.LinkageSeatSettingsActivity"/>
         <activity android:name=".view.SettingActivity"/>
+        <activity android:name=".view.OrderActivity"/>
 
         <receiver
             android:name="com.jld.face.receiver.BootBroadcastReceiver"
@@ -110,6 +112,8 @@
 
         <service android:name=".service.MusicPlayerService" />
         <service android:name=".service.LatLongService"/>
+        <service android:name=".service.PositionAdvertService"/>
+        <service android:name=".service.SocketService"/>
         <service
             android:name=".service.MyAccessibilityService"
             android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE">

+ 87 - 6
app/src/main/java/com/jld/vod/base/BaseActivity.kt

@@ -5,15 +5,24 @@ import android.app.ProgressDialog
 import android.content.Context
 import android.content.Intent
 import android.os.Bundle
+import android.os.Handler
 import android.util.Log
+import android.view.MotionEvent
 import android.widget.Toast
+import androidx.lifecycle.ViewModelProvider
+import androidx.lifecycle.observe
 import com.jld.vod.R
-import com.jld.vod.utils.CommonUtil
+import com.jld.vod.model.bean.BaseBean
+import com.jld.vod.model.bean.ContextBean
+import com.jld.vod.utils.LogUtils
+import com.jld.vod.utils.WinCallback
 import com.jld.vod.view.widget.CustomProgressDialog
+import com.jld.vod.viewmodel.MainViewModel
 import com.kaopiz.kprogresshud.KProgressHUD
 import com.xuexiang.xpage.base.XPageActivity
 import com.xuexiang.xpage.base.XPageFragment
 import com.xuexiang.xpage.core.CoreSwitchBean
+import org.greenrobot.eventbus.EventBus
 
 /**
  * Create by Panda on 2019/3/14
@@ -24,6 +33,17 @@ abstract class BaseActivity : XPageActivity() {
     private var dialog: ProgressDialog? = null
     private var mToast: Toast? = null
     private var dialogs: KProgressHUD? = null
+    private lateinit var viewModel: MainViewModel
+    private val handlerBaseActivity: Handler =  Handler()
+
+
+    //用户没操作了
+    private val runnableBaseActivity = Runnable {
+        LogUtils.logD("用户没操作了")
+        //获取固定广告
+        viewModel.findPositionAdvert()
+    }
+
     //页面是否处于前台
     var isFront = false
     override fun onCreate(savedInstanceState: Bundle?) {
@@ -31,23 +51,82 @@ abstract class BaseActivity : XPageActivity() {
         setContentView(layoutId)
         mContext = this
 
+        viewModel = ViewModelProvider.AndroidViewModelFactory(application).create(MainViewModel::class.java)
+
         initView()
         initData()
         initEvent()
+        initAdVert()
+
+        val activity = ContextBean.getInstance().getActivity();
+        if (activity == null) { return; }
+        LogUtils.logE("activity"+activity)
+        val win = activity.getWindow();
+
+        win.setCallback(object :WinCallback(win.callback){
+            override fun dispatchTouchEvent(event: MotionEvent?): Boolean {
+                when (event!!.getAction()) {
+                    MotionEvent.ACTION_DOWN->{
+                        LogUtils.logD( "dispatchTouchEvent:ACTION_DOWN");
+                        handlerBaseActivity.removeCallbacks(runnableBaseActivity);
+                    }
+                    MotionEvent.ACTION_MOVE->{
+                       // LogUtils.logD("dispatchTouchEvent:activity窗口被触摸");
+                        //handlerBaseActivity.removeCallbacks(runnableBaseActivity)
+                         }
+                    MotionEvent.ACTION_UP->
+                        {
+                            handlerBaseActivity.removeCallbacks(runnableBaseActivity)
+                            handlerBaseActivity.postDelayed(runnableBaseActivity, 1800 * 1000)
+                            LogUtils.logD( "dispatchTouchEvent:ACTION_UP");
+                        }
+                }
+                return super.dispatchTouchEvent(event)
+            }
+        })
     }
 
 
-    open protected fun initView() {
-
+    /**
+     * 初始化广告模块
+     */
+    private fun initAdVert() {
+        viewModel.findPositionAdvertLiveData.observe(this) {res->
+            when (res?.code) {
+                BaseBean.SUCCESS -> {
+                    if (res.data!!.size != 0)
+                    {
+                        EventBus.getDefault().post(res.data)
+                    }
+                    finishLoading()
+                }
+                BaseBean.ERROR -> {
+                    finishLoading()
+                    Toast.makeText(this, res.message, Toast.LENGTH_SHORT).show()
+                }
+                BaseBean.LOADING -> showLoading()
+            }
+        }
     }
 
-    open protected fun initData() {
+    override fun onWindowFocusChanged(hasFocus: Boolean) {
+        if(hasFocus)
+        {
+            handlerBaseActivity.removeCallbacks(runnableBaseActivity)
+            handlerBaseActivity.postDelayed(runnableBaseActivity, 1800 * 1000)
+        }else{
+            handlerBaseActivity.removeCallbacks(runnableBaseActivity)
+        }
 
+        //Log.e("zhaofuxin", "onWindowFocusChanged: activity焦点变化=="+hasFocus );
+        super.onWindowFocusChanged(hasFocus )
     }
 
-    open protected fun initEvent() {
+    open protected fun initView() {}
 
-    }
+    open protected fun initData() {}
+
+    open protected fun initEvent() {}
 
     fun showLoading() {
         if (dialog == null) {
@@ -65,10 +144,12 @@ abstract class BaseActivity : XPageActivity() {
 
     override fun onResume() {
         super.onResume()
+        handlerBaseActivity.postDelayed(runnableBaseActivity, 1800 * 1000)
         isFront = true
     }
 
     override fun onPause() {
+        handlerBaseActivity.removeCallbacks(runnableBaseActivity)
         super.onPause()
         isFront = false
     }

+ 36 - 1
app/src/main/java/com/jld/vod/base/MyApplication.kt

@@ -1,9 +1,13 @@
 package com.jld.vod.base
 
+import android.app.Activity
 import android.app.Application
+import android.content.Context
+import android.os.Bundle
 import android.preference.PreferenceManager
 import android.util.Log
 import com.facebook.drawee.backends.pipeline.Fresco
+import com.jld.vod.model.bean.ContextBean
 import com.jld.vod.ui.XBasicLibInit
 import com.jld.vod.utils.http.RetrofitUtils
 import com.xuexiang.xui.XUI
@@ -31,13 +35,14 @@ class MyApplication : Application(){
     val SETTING_TILECACHE_PERSISTENCE = "tilecache_persistence"
     val SETTING_WAYFILTERING = "wayfiltering"
     val SETTING_WAYFILTERING_DISTANCE = "wayfiltering_distance"
+    private var callbacks:ActivityLifecycleCallbacks? = null
 
     /**
      * 内存检测
      */
     companion object{
         fun isDebug(): Boolean {
-            return true
+            return false
         }
         lateinit var app: Application
     }
@@ -68,8 +73,38 @@ class MyApplication : Application(){
         //html
         RichText.initCacheDir(this)
         RichText.debugMode = true
+
+        initActivityLifecycle()
     }
 
+    private fun initActivityLifecycle() {
+        app.registerActivityLifecycleCallbacks(object : ActivityLifecycleCallbacks{
+            override fun onActivityPaused(activity: Activity) {
+            }
+            override fun onActivityStarted(activity: Activity) {
+            }
+
+            override fun onActivityDestroyed(activity: Activity) {
+                if (activity == ContextBean.getInstance().getActivity()) {
+                    ContextBean.getInstance().setActivity(null)
+                }
+            }
+
+            override fun onActivitySaveInstanceState(activity: Activity, outState: Bundle) {
+            }
+
+            override fun onActivityStopped(activity: Activity) {
+            }
+
+            override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) {
+                ContextBean.getInstance().setActivity(activity);
+            }
+
+            override fun onActivityResumed(activity: Activity) {
+            }
+        })
+
+    }
     /**
      * 初始化XUI 框架
      */

+ 15 - 2
app/src/main/java/com/jld/vod/config/Config.kt

@@ -9,10 +9,23 @@ package com.jld.vod.config
 object Config {
 //    const val ApiBaseUrl : String = "http://192.168.16.110:8088"
 //    const val ApiBaseUrlDebug : String = "http://192.168.16.110:8088"
-    const val ApiBaseUrl : String = "http://192.168.0.16:8088"
-    const val ApiBaseUrlDebug : String = "http://192.168.0.16:8088"
+    const val ApiBaseUrl : String = "http://192.168.0.18:8088"
+    const val ApiBaseUrlDebug : String = "http://192.168.0.18:8088"
 //    true--有线VOD false ---无线VOD
     const val Breed:Boolean = false
 //   进入设置的密码
     const val pwd:String = "123456"
+
+    const val TYPE = "type"
+    const val MSG = "msg"
+    const val HEARTBREAK = "turn"
+    const val SCREEN = "screen"
+    const val ADS = "ads"
+    const val PING = "ping"
+
+    const val TCP_IP = "ip"
+    const val TCP_PORT = "port"
+
+    // 单个CPU线程池大小
+    const val POOL_SIZE = 5
 }

+ 11 - 0
app/src/main/java/com/jld/vod/interfaces/OnConnectionStateListener.java

@@ -0,0 +1,11 @@
+package com.jld.vod.interfaces;
+
+/**
+ * Created by melo on 2017/11/29.
+ */
+
+public interface OnConnectionStateListener {
+    void onSuccess();
+
+    void onFailed(int errorCode);
+}

+ 9 - 0
app/src/main/java/com/jld/vod/interfaces/OnMessageReceiveListener.java

@@ -0,0 +1,9 @@
+package com.jld.vod.interfaces;
+
+/**
+ * Created by melo on 2017/11/27.
+ */
+
+public interface OnMessageReceiveListener {
+    void onMessageReceived(String message);
+}

+ 28 - 0
app/src/main/java/com/jld/vod/interfaces/remote/Apis.kt

@@ -308,4 +308,32 @@ interface Apis {
      */
     @GET("/modular/delInstallPath")
     fun delInstallPath(@Query("tiId") tiId :String): Observable<BaseBean<List<NuInstallGameBean>>>
+
+
+    /**
+     * 获取固定位置广告
+     */
+    @GET("/advert/findPositionAdvert")
+    fun findPositionAdvert(): Observable<BaseBean<List<PositionAdvertBean>>>
+
+    /**
+     * 获取GEO广告
+     */
+    @GET("/advert/findGEOAdvert")
+    fun findGEOAdvert(): Observable<BaseBean<List<String>>>
+
+
+    /**
+     * 获取电影广告
+     */
+    @GET("/advert/findMovieAdvert")
+    fun findMovieAdvert(): Observable<BaseBean<List<String>>>
+
+
+    /**
+     * 绑定用户
+     */
+    @GET("/user/updateUser")
+    fun updateUser(@Query("userId") userId :String): Observable<BaseBean<String>>
+
 }

+ 24 - 0
app/src/main/java/com/jld/vod/model/bean/ContextBean.java

@@ -0,0 +1,24 @@
+package com.jld.vod.model.bean;
+
+import android.app.Activity;
+
+public class ContextBean {
+    private static ContextBean contextBean;
+    //我们保持跟目前存活的Activity一致的话,可以无视内存泄漏
+    private Activity activity;
+
+    public static ContextBean getInstance() {
+        if(contextBean == null) {
+            contextBean = new ContextBean();
+        }
+        return contextBean;
+    }
+
+    public Activity getActivity() {
+        return activity;
+    }
+
+    public void setActivity(Activity activity) {
+        this.activity = activity;
+    }
+}

+ 22 - 0
app/src/main/java/com/jld/vod/model/bean/GEOAdvertBean.kt

@@ -0,0 +1,22 @@
+package com.jld.vod.model.bean
+
+data class GEOAdvertBean(
+    val code: Int,
+    val `data`: List<Datas>,
+    val flag: Boolean,
+    val message: String
+)
+
+data class Datas(
+    val aid: Long,
+    val cid: Long,
+    val depict: String,
+    val filePath: String,
+    val fileType: Int,
+    val sid: Int,
+    val status: Int,
+    val titleName: String,
+    val type: Int,
+    val version: Int,
+    val weight: Int
+)

+ 15 - 0
app/src/main/java/com/jld/vod/model/bean/PositionAdvertBean.kt

@@ -0,0 +1,15 @@
+package com.jld.vod.model.bean
+
+data class PositionAdvertBean(
+    val aid: Long,
+    val cid: Long,
+    val depict: String,
+    val filePath: String,
+    val fileType: Int,
+    val sid: Int,
+    val status: Int,
+    val titleName: String,
+    val type: Int,
+    val version: Int,
+    val weight: Int
+)

+ 9 - 0
app/src/main/java/com/jld/vod/model/event/ReceiveEvent.java

@@ -0,0 +1,9 @@
+package com.jld.vod.model.event;
+
+public class ReceiveEvent {
+    public String data;
+    public ReceiveEvent(String data)
+    {
+        this.data = data;
+    }
+}

+ 57 - 16
app/src/main/java/com/jld/vod/service/LatLongService.kt

@@ -12,21 +12,27 @@ import android.graphics.BitmapFactory
 import android.os.Handler
 import android.os.IBinder
 import android.os.Message
+import android.view.WindowManager
+import android.widget.Toast
+import androidx.lifecycle.ViewModelProvider
+import androidx.lifecycle.observe
 import androidx.room.Room
 import com.google.android.gms.maps.model.LatLng
 import com.google.gson.Gson
+import com.google.gson.reflect.TypeToken
 import com.jld.vod.R
 import com.jld.vod.config.Config
 import com.jld.vod.db.CarSiteAllDatabase
-import com.jld.vod.model.bean.CarSiteAllBean
-import com.jld.vod.model.bean.LatLongBean
-import com.jld.vod.model.bean.NotificationInfoBean
+import com.jld.vod.model.bean.*
 import com.jld.vod.model.event.MapsEvent
 import com.jld.vod.model.event.SiteEvent
 import com.jld.vod.utils.LatLongUtils
 import com.jld.vod.utils.LogUtils
 import com.jld.vod.utils.http.OkHttpUtils
 import com.jld.vod.utils.SharedPrefUtils
+import com.jld.vod.view.widget.CustomGEOAdDialog
+import com.jld.vod.viewmodel.MainViewModel
+import okhttp3.Call
 import okhttp3.Response
 import org.greenrobot.eventbus.EventBus
 import java.io.IOException
@@ -50,6 +56,9 @@ class LatLongService :Service() {
     private var indexsite:Int = 0
     private var carinfo:CarSiteAllBean?=null
 
+    private lateinit var mCustom : CustomGEOAdDialog
+    private var mContext: Context ?= null
+
     private val mHandler: Handler = @SuppressLint("HandlerLeak")
     object : Handler() {
         override fun handleMessage(msg: Message) {
@@ -78,7 +87,7 @@ class LatLongService :Service() {
                                 if (Longitude <= 180 && Longitude >= -180 && Latitude <= 90 && Latitude >= -90) {
 
                                     for ((index, data) in mCarSiteAll.withIndex()) {
-                                      // LogUtils.logD("距离=test"+data.name)
+                                       //LogUtils.logD("距离=test"+data.name)
                                         //站台的位置
                                         val lat: Double = data.latitude.toDouble()
                                         val lng: Double = data.longitude.toDouble()
@@ -86,10 +95,10 @@ class LatLongService :Service() {
 
                                         //根据经纬度测算距离(米)
                                         val Distance: Double = LatLongUtils.getDistance(location, plalocation)
-                                       // LogUtils.logD("距离all="+data.name+Distance)
+                                        //LogUtils.logD("距离all="+data.name+Distance)
                                         //设置距离站点,然后报站
                                         if (Distance <= 1000) {
-                                         //   LogUtils.logD("距离<1000="+Distance)
+                                            //LogUtils.logD("距离<1000="+Distance)
                                             //判断最短距离报站
                                             if(min > Distance) {
                                                 min = Distance
@@ -105,16 +114,17 @@ class LatLongService :Service() {
                                     //通过id报站判断是否相同重复报站
                                     if(carinfo!=null){
                                         val siteIds = carinfo!!.siteId //记录当前站点id
-                                        //LogUtils.logD("siteIds="+siteIds+"====siteId"+data.siteId)
+                                       // LogUtils.logD("siteIds="+siteIds+"====siteId"+data.siteId)
                                         if (siteIds != siteId) {//判断不是同一个站点
                                             //报站通知
 //                                            addNotification(carinfo!!.name,carinfo!!.sInfo)
                                             //预加载通知
-                                            returnBitMap(carinfo!!.sImg,carinfo!!.name,carinfo!!.sInfo)
+//                                            returnBitMap(carinfo!!.sImg,carinfo!!.name,carinfo!!.sInfo)
                                             siteId = siteIds
-                                            //取消报站
-                                            Thread.sleep(15000)
-                                            cleanNotification()
+                                            initAdVert(siteId)
+//                                            //取消报站
+//                                            Thread.sleep(15000)
+//                                            cleanNotification()
                                         }
                                     }
                                 }
@@ -127,9 +137,18 @@ class LatLongService :Service() {
                     }
                 }
                 2->{
-                    val result = msg.obj as NotificationInfoBean
-                   //开启通知
-                    addNotification(result.pat,result.info,result.bitmap)
+                    //开启通知
+                    val result = msg.obj as GEOAdvertBean
+                    LogUtils.logD("result"+result)
+                    if (result.data != null)
+                    {
+                        mCustom = CustomGEOAdDialog(mContext)
+                        mCustom.getWindow()!!.setType((WindowManager.LayoutParams.TYPE_SYSTEM_ALERT));
+                        mCustom.setDataList(result.data)
+                        mCustom.show()
+                    }
+
+                 //   addNotification(result.pat,result.info,result.bitmap)
                 }
             }
         }
@@ -140,14 +159,13 @@ class LatLongService :Service() {
 
     override fun onCreate() {
         super.onCreate()
+        mContext = this
 
         //初始化db
         carsitealldb = Room.databaseBuilder(this, CarSiteAllDatabase::class.java, "carsiteall").build()
 
         //初始化gson
         gson = Gson()
-        //获取设备号
-
     }
 
     override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
@@ -157,6 +175,29 @@ class LatLongService :Service() {
     }
 
     /**
+     * 初始化广告模块
+     */
+    private fun initAdVert(sid : Long?) {
+
+        LogUtils.logD("sid"+sid)
+        OkHttpUtils.getInstance().getDataAsyn(Config.ApiBaseUrl+"/advert/findGEOAdvert?sid="+sid,object :OkHttpUtils.MyNetCall{
+            override fun failed(call: Call?, e: IOException?) {
+                LogUtils.logE(e.toString())
+            }
+            override fun success(call: Call?, response: Response?) {
+                val json = response!!.body!!.string()
+              //  LogUtils.logD("json"+json)
+
+                val mGEOAdvertBean= gson!!.fromJson(json, GEOAdvertBean::class.java)
+                val msg = Message()
+                msg.what = 2
+                msg.obj = mGEOAdvertBean
+                mHandler.sendMessage(msg)
+
+            }
+        })
+    }
+    /**
      * 心跳回调
      */
     private fun requestLocalLatLng() {

+ 5 - 1
app/src/main/java/com/jld/vod/service/MyAccessibilityService.kt

@@ -1,6 +1,7 @@
 package com.jld.vod.service
 
 import android.accessibilityservice.AccessibilityService
+import android.view.KeyEvent
 import android.view.accessibility.AccessibilityEvent
 import com.jld.vod.utils.LogUtils
 import org.greenrobot.eventbus.EventBus
@@ -22,7 +23,10 @@ class MyAccessibilityService : AccessibilityService() {
         EventBus.getDefault().register(this)
     }
 
-    override fun onAccessibilityEvent(event: AccessibilityEvent?) {}
+    override fun onAccessibilityEvent(event: AccessibilityEvent?) {
+        LogUtils.logD("event"+event)
+    }
+
     override fun onInterrupt() {}
 
     @Subscribe

+ 53 - 0
app/src/main/java/com/jld/vod/service/PositionAdvertService.kt

@@ -0,0 +1,53 @@
+package com.jld.vod.service
+
+import android.accessibilityservice.AccessibilityService
+import android.app.Service
+import android.content.Intent
+import android.os.IBinder
+import android.view.WindowManager
+import com.jld.vod.model.bean.PositionAdvertBean
+import com.jld.vod.utils.LogUtils
+import com.jld.vod.view.widget.CustomAdDialog
+import org.greenrobot.eventbus.EventBus
+import org.greenrobot.eventbus.Subscribe
+
+/**
+ * 固定位置广告服务
+ */
+class PositionAdvertService : Service() {
+    private var mCustom : CustomAdDialog? = null
+
+    override fun onCreate() {
+        EventBus.getDefault().register(this)
+        super.onCreate()
+    }
+
+
+    /**
+     * 接收广告数据
+     */
+    @Subscribe
+    fun onReceive( positionAdvert :List<PositionAdvertBean>) {
+        LogUtils.logD("我收到了消息"+positionAdvert)
+
+        if (mCustom == null)
+        {
+            mCustom = CustomAdDialog(this)
+            mCustom!!.getWindow()!!.setType((WindowManager.LayoutParams.TYPE_SYSTEM_ALERT));
+            mCustom!!.setDataList(positionAdvert)
+            mCustom!!.show()
+        }
+        mCustom!!.setOnClickBottomListener(object : CustomAdDialog.OnClickBottomListener{
+            override fun onBtnCloseClick() {
+                mCustom!!.dismiss()
+                mCustom = null
+            }
+        })
+    }
+
+
+    override fun onBind(intent: Intent?): IBinder? {
+        return null
+    }
+
+}

+ 174 - 0
app/src/main/java/com/jld/vod/service/SocketService.kt

@@ -0,0 +1,174 @@
+package com.jld.vod.service
+
+import android.app.Service
+import android.content.Intent
+import android.os.Handler
+import android.os.IBinder
+import android.os.Message
+import android.view.WindowManager
+import com.google.gson.Gson
+import com.jld.vod.R
+import com.jld.vod.config.Config
+import com.jld.vod.model.bean.GEOAdvertBean
+import com.jld.vod.model.bean.ResultBean
+import com.jld.vod.model.event.ReceiveEvent
+import com.jld.vod.socket.ReceiveSocketManager
+import com.jld.vod.socket.SendSocketManager
+import com.jld.vod.utils.LogUtils
+import com.jld.vod.utils.SharedPrefUtils
+import com.jld.vod.utils.http.OkHttpUtils
+import com.jld.vod.view.SplashActivity
+import com.jld.vod.view.widget.CustomAdDialog
+import com.jld.vod.view.widget.CustomBlackBgDialog
+import com.jld.vod.view.widget.CustomGEOAdDialog
+import com.jld.vod.view.widget.CustomScreenAdDialog
+import okhttp3.Call
+import okhttp3.Response
+import org.greenrobot.eventbus.EventBus
+import org.greenrobot.eventbus.Subscribe
+import org.greenrobot.eventbus.ThreadMode
+import org.json.JSONObject
+import java.io.IOException
+
+/**
+ * upd服务
+ */
+class SocketService : Service() {
+    private var sendSocketManager: SendSocketManager? = null
+    private var receiveSocketManager: ReceiveSocketManager? = null
+    private var mBgCustom : CustomBlackBgDialog? = null
+    private var mGEOCustom : CustomScreenAdDialog? = null
+    private var gson:Gson?= null
+    private val BLACKBG : Int  =  0x10
+    private val GEOAD :Int = 0x11
+    private val DISGEOAD :Int = 0x12
+
+    private val mHandler = Handler(Handler.Callback { message ->
+
+        when(message.what)
+        {
+            BLACKBG->{
+                val msg = message.obj.toString()
+                    if (msg == "true")
+                    {
+                        if (mBgCustom == null)
+                        {
+                            mBgCustom = CustomBlackBgDialog(this)
+                            mBgCustom!!.getWindow()!!.setType((WindowManager.LayoutParams.TYPE_SYSTEM_ALERT));
+                            mBgCustom!!.show()
+                        }
+                    }else if(msg == "false")
+                    {
+                        if (mBgCustom != null)
+                        {
+                            mBgCustom!!.dismiss()
+                            mBgCustom = null
+                        }
+                    }
+            }
+            GEOAD->{
+                val msgs = message.obj as GEOAdvertBean
+
+                if (msgs.data != null)
+                {
+                    if (mGEOCustom == null)
+                    {
+                        mGEOCustom = CustomScreenAdDialog(this)
+                        mGEOCustom!!.getWindow()!!.setType((WindowManager.LayoutParams.TYPE_SYSTEM_ALERT));
+                    }
+
+                    mGEOCustom!!.setDataList(msgs.data)
+                    mGEOCustom!!.show()
+                }
+            }
+            DISGEOAD->{
+
+                if (mGEOCustom != null)
+                {
+                    mGEOCustom!!.dismiss()
+                    mGEOCustom = null
+                }
+            }
+        }
+
+                false
+            })
+    override fun onCreate() {
+        EventBus.getDefault().register(this)
+
+        receiveSocketManager = ReceiveSocketManager.getInstance(this)
+        receiveSocketManager!!.startUdpConnection()
+
+        //初始化gson
+        gson = Gson()
+
+        super.onCreate()
+    }
+
+
+    /**
+     * 接收UDP广播
+     */
+    @Subscribe(threadMode = ThreadMode.MAIN)
+    fun onReceive( action : ReceiveEvent?) {
+        LogUtils.logD("接收广播"+action)
+        if (action!!.data == null)return
+        val jsonObject = JSONObject(action!!.data)
+        try {
+            val type = jsonObject.optString("type")
+            val msg = jsonObject.optString("msg")
+
+            when (type)
+            {
+                "CLOSE"->{
+                    receiveSocketManager!!.stopSocket()
+                }
+                Config.SCREEN->{
+                    val msgs = Message()
+                    msgs.what = BLACKBG
+                    msgs.obj = msg
+                    mHandler.sendMessage(msgs)
+                }
+                Config.ADS->{
+                    if (msg == "true")
+                    {
+                        initAdVert()
+                    }else if(msg == "false")
+                    {
+                        val msgs = Message()
+                        msgs.what = DISGEOAD
+                        mHandler.sendMessage(msgs)
+                    }
+                }
+            }
+        }catch (e:Exception)
+        {
+            e.printStackTrace()
+        }
+    }
+    /**
+     * 初始化广告模块
+     */
+    private fun initAdVert() {
+        OkHttpUtils.getInstance().getDataAsyn(Config.ApiBaseUrl+"/advert/findPositionAdvert",object : OkHttpUtils.MyNetCall{
+            override fun failed(call: Call?, e: IOException?) {
+                LogUtils.logE(e.toString())
+            }
+            override fun success(call: Call?, response: Response?) {
+                val json = response!!.body!!.string()
+
+                val mGEOAdvertBean= gson!!.fromJson(json, GEOAdvertBean::class.java)
+                val msg = Message()
+                msg.what = GEOAD
+                msg.obj = mGEOAdvertBean
+                mHandler.sendMessage(msg)
+
+            }
+        })
+    }
+
+    override fun onBind(intent: Intent?): IBinder? {
+        return null
+    }
+
+}

+ 58 - 0
app/src/main/java/com/jld/vod/socket/ReceiveSocketManager.java

@@ -0,0 +1,58 @@
+package com.jld.vod.socket;
+
+import android.content.Context;
+import android.text.TextUtils;
+
+import com.jld.vod.interfaces.OnMessageReceiveListener;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+public class ReceiveSocketManager {
+
+    private static volatile ReceiveSocketManager instance = null;
+    private ReceiveUDPSocket receiveUdpSocket;
+    private Context mContext;
+
+    private ReceiveSocketManager(Context context) {
+        mContext = context.getApplicationContext();
+    }
+
+    public static ReceiveSocketManager getInstance(Context context) {
+        // if already inited, no need to get lock everytime
+        if (instance == null) {
+            synchronized (ReceiveSocketManager.class) {
+                if (instance == null) {
+                    instance = new ReceiveSocketManager(context);
+                }
+            }
+        }
+
+        return instance;
+    }
+
+    /**
+     * 开启UPD接收连接
+     */
+    public void startUdpConnection() {
+        if (receiveUdpSocket == null) {
+            receiveUdpSocket = new ReceiveUDPSocket(mContext);
+        }
+        receiveUdpSocket.startUDPSocket();
+    }
+    /**
+     * 处理 udp 收到的消息
+     *
+     * @param message
+     */
+    private void handleUdpMessage(String message) {
+
+    }
+    public void stopSocket() {
+        if (receiveUdpSocket != null) {
+            receiveUdpSocket.stopUDPSocket();
+            receiveUdpSocket = null;
+        }
+    }
+
+}

+ 168 - 0
app/src/main/java/com/jld/vod/socket/ReceiveUDPSocket.java

@@ -0,0 +1,168 @@
+package com.jld.vod.socket;
+
+import android.content.Context;
+import android.util.Log;
+
+
+import com.jld.vod.config.Config;
+import com.jld.vod.interfaces.OnMessageReceiveListener;
+import com.jld.vod.model.event.ReceiveEvent;
+
+import org.greenrobot.eventbus.EventBus;
+
+import java.io.IOException;
+import java.net.DatagramPacket;
+import java.net.DatagramSocket;
+import java.net.SocketException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+
+public class ReceiveUDPSocket {
+
+    private static final String TAG = "UDPSocket";
+
+    private static final int BUFFER_LENGTH = 1024;
+    private byte[] receiveByte = new byte[BUFFER_LENGTH];
+
+    private static String BROADCAST_IP = "192.168.43.255";
+
+    // 端口号,飞鸽协议默认端口2425
+    public static final int CLIENT_PORT = 2425;
+
+    private boolean isThreadRunning = false;
+
+    private Context mContext;
+    private DatagramSocket client;
+    private DatagramPacket receivePacket;
+
+    private long lastReceiveTime = 0;
+    private static final long TIME_OUT = 120 * 1000;
+    private static final long HEARTBEAT_MESSAGE_DURATION = 5 * 1000;
+
+    private ExecutorService mThreadPool;
+    private Thread clientThread;
+
+    private final List<OnMessageReceiveListener> messageReceiveList;
+
+    public ReceiveUDPSocket(Context context) {
+
+        this.mContext = context;
+
+        int cpuNumbers = Runtime.getRuntime().availableProcessors();
+        // 根据CPU数目初始化线程池
+        mThreadPool = Executors.newFixedThreadPool(cpuNumbers * Config.POOL_SIZE);
+        // 记录创建对象时的时间
+        lastReceiveTime = System.currentTimeMillis();
+
+        messageReceiveList = new ArrayList<>();
+
+        Log.d(TAG, "创建 UDP 对象");
+//        createUser();
+    }
+
+    public void addOnMessageReceiveListener(OnMessageReceiveListener listener) {
+        messageReceiveList.add(listener);
+    }
+
+
+    public void startUDPSocket() {
+        if (client != null) return;
+        try {
+            // 表明这个 Socket 在设置的端口上监听数据。
+            client = new DatagramSocket(CLIENT_PORT);
+            client.setReuseAddress(true);
+            if (receivePacket == null) {
+                // 创建接受数据的 packet
+                receivePacket = new DatagramPacket(receiveByte, BUFFER_LENGTH);
+            }
+
+            startSocketThread();
+        } catch (SocketException e) {
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     * 开启接收数据的线程
+     */
+    private void startSocketThread() {
+        clientThread = new Thread(new Runnable() {
+            @Override
+            public void run() {
+                receiveMessage();
+            }
+        });
+        isThreadRunning = true;
+        clientThread.start();
+        Log.d(TAG, "开启 UDP 数据接收线程");
+    }
+
+    /**
+     * 处理接受到的消息
+     */
+    private void receiveMessage() {
+        while (isThreadRunning) {
+            try {
+                if (client != null && receivePacket != null) {
+                    client.receive(receivePacket);
+                }
+                lastReceiveTime = System.currentTimeMillis();
+                Log.d(TAG, "receive packet success...");
+            } catch (IOException e) {
+                Log.e(TAG, "UDP数据包接收失败!线程停止");
+                stopUDPSocket();
+                e.printStackTrace();
+                return;
+            }
+
+            if (receivePacket == null || receivePacket.getLength() == 0) {
+                Log.e(TAG, "无法接收UDP数据或者接收到的UDP数据为空");
+                continue;
+            }
+
+            String strReceive = new String(receivePacket.getData(), receivePacket.getOffset(), receivePacket.getLength());
+            Log.d(TAG, strReceive + " from " + receivePacket.getAddress().getHostAddress() + ":" + receivePacket.getPort());
+
+            EventBus.getDefault().post(new ReceiveEvent(strReceive));
+            //解析接收到的 json 信息
+            //notifyMessageReceive(strReceive);
+            // 每次接收完UDP数据后,重置长度。否则可能会导致下次收到数据包被截断。
+            if (receivePacket != null) {
+                receivePacket.setLength(BUFFER_LENGTH);
+            }
+        }
+    }
+
+    /**
+     * 将消息通过接口发送到每个页面
+     *
+     * @param strReceive
+     */
+    private void notifyMessageReceive(String strReceive) {
+        for (OnMessageReceiveListener listener : messageReceiveList) {
+            if (listener != null) {
+                listener.onMessageReceived(strReceive);
+            }
+        }
+    }
+
+    public void stopUDPSocket() {
+        isThreadRunning = false;
+        receivePacket = null;
+        if (clientThread != null) {
+            clientThread.interrupt();
+        }
+        if (mThreadPool != null) {
+            mThreadPool.shutdown();
+        }
+        if (client != null) {
+            client.close();
+            client = null;
+        }
+
+    }
+
+}

+ 64 - 0
app/src/main/java/com/jld/vod/socket/SendSocketManager.java

@@ -0,0 +1,64 @@
+package com.jld.vod.socket;
+
+import android.content.Context;
+
+
+import com.jld.vod.config.Config;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+
+public class SendSocketManager {
+
+    private static volatile SendSocketManager instance = null;
+    private SendUDPSocket udpSocket;
+    private Context mContext;
+
+    private SendSocketManager(Context context) {
+        mContext = context.getApplicationContext();
+    }
+
+    public static SendSocketManager getInstance(Context context) {
+        // if already inited, no need to get lock everytime
+        if (instance == null) {
+            synchronized (SendSocketManager.class) {
+                if (instance == null) {
+                    instance = new SendSocketManager(context);
+                }
+            }
+        }
+
+        return instance;
+    }
+
+    public void startUdpConnection() {
+        if (udpSocket == null) {
+            udpSocket = new SendUDPSocket(mContext);
+        }
+        udpSocket.startUDPSocket();
+
+    }
+
+
+
+    public void stopSocket() {
+        udpSocket.stopUDPSocket();
+        if (udpSocket != null) {
+            udpSocket = null;
+        }
+    }
+
+    public void sendMsg(String type, String msg)
+    {
+        JSONObject jsonObject = new JSONObject();
+        try {
+            jsonObject.put(Config.TYPE, type);
+            jsonObject.put(Config.MSG, msg);
+        } catch (JSONException e) {
+            e.printStackTrace();
+        }
+        udpSocket.sendMessage(jsonObject.toString());
+    }
+
+}

+ 133 - 0
app/src/main/java/com/jld/vod/socket/SendUDPSocket.java

@@ -0,0 +1,133 @@
+package com.jld.vod.socket;
+
+import android.content.Context;
+import android.util.Log;
+
+
+import com.jld.vod.config.Config;
+import com.jld.vod.interfaces.OnMessageReceiveListener;
+import com.jld.vod.utils.WifiUtil;
+
+import java.io.IOException;
+import java.net.DatagramPacket;
+import java.net.DatagramSocket;
+import java.net.InetAddress;
+import java.net.SocketException;
+import java.net.UnknownHostException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+
+
+public class SendUDPSocket {
+
+    private static final String TAG = "UDPSocket";
+
+    private static final int BUFFER_LENGTH = 1024;
+    private byte[] receiveByte = new byte[BUFFER_LENGTH];
+
+    private static String BROADCAST_IP = "192.168.43.255";
+
+    // 端口号,飞鸽协议默认端口2425
+    public static final int CLIENT_PORT = 2425;
+
+    private boolean isThreadRunning = false;
+
+    private Context mContext;
+    private DatagramSocket client;
+    private DatagramPacket receivePacket;
+
+    private long lastReceiveTime = 0;
+    private static final long TIME_OUT = 120 * 1000;
+    private static final long HEARTBEAT_MESSAGE_DURATION = 5 * 1000;
+
+    private ExecutorService mThreadPool;
+    private Thread clientThread;
+
+    private final List<OnMessageReceiveListener> messageReceiveList;
+
+    public SendUDPSocket(Context context) {
+
+        this.mContext = context;
+
+        int cpuNumbers = Runtime.getRuntime().availableProcessors();
+        // 根据CPU数目初始化线程池
+        mThreadPool = Executors.newFixedThreadPool(cpuNumbers * Config.POOL_SIZE);
+        // 记录创建对象时的时间
+        lastReceiveTime = System.currentTimeMillis();
+
+        messageReceiveList = new ArrayList<>();
+
+        Log.d(TAG, "创建 UDP 对象");
+//        createUser();
+    }
+
+    public void startUDPSocket() {
+        if (client != null) return;
+        try {
+            // 表明这个 Socket 在设置的端口上监听数据。
+            client = new DatagramSocket(CLIENT_PORT);
+            client.setReuseAddress(true);
+            if (receivePacket == null) {
+                // 创建接受数据的 packet
+                receivePacket = new DatagramPacket(receiveByte, BUFFER_LENGTH);
+            }
+        } catch (SocketException e) {
+            e.printStackTrace();
+        }
+    }
+
+
+
+    public void stopUDPSocket() {
+        isThreadRunning = false;
+        receivePacket = null;
+        if (clientThread != null) {
+            clientThread.interrupt();
+        }
+        if (mThreadPool != null) {
+            mThreadPool.shutdown();
+        }
+        if (client != null) {
+            client.close();
+            client = null;
+        }
+
+    }
+
+
+
+    /**
+     * 发送心跳包
+     *
+     * @param message
+     */
+    public void sendMessage(final String message) {
+        mThreadPool.execute(new Runnable() {
+            @Override
+            public void run() {
+                try {
+                    if (client == null)return;
+                    BROADCAST_IP = WifiUtil.getBroadcastAddress();
+                    Log.d(TAG, "BROADCAST_IP:" + BROADCAST_IP);
+                    InetAddress targetAddress = InetAddress.getByName(BROADCAST_IP);
+
+                    DatagramPacket packet = new DatagramPacket(message.getBytes(), message.length(), targetAddress, CLIENT_PORT);
+
+                    client.send(packet);
+
+                    // 数据发送事件
+                    Log.d(TAG, "数据发送成功");
+
+                } catch (UnknownHostException e) {
+                    e.printStackTrace();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+
+            }
+        });
+    }
+}

+ 4 - 3
app/src/main/java/com/jld/vod/ui/XBasicLibInit.kt

@@ -5,8 +5,9 @@ import android.app.Application
 import com.jld.vod.base.BaseActivity
 
 import com.jld.vod.base.MyApplication
-import com.xuexiang.xpage.AppPageConfig
+import com.jld.vod.view.MainActivity
 import com.xuexiang.xpage.PageConfig
+import com.xuexiang.xpage.config.AppPageConfig
 import com.xuexiang.xutil.XUtil
 
 
@@ -52,8 +53,8 @@ object XBasicLibInit {
                     AppPageConfig.getInstance().getPages()
                 }
                 .debug(if (MyApplication.isDebug())  "PageLog" else null)
-                .setContainActivityClazz(BaseActivity::class.java)
-                .enableWatcher(MyApplication.isDebug())
+                .setContainActivityClazz(MainActivity::class.java)
+                //enableWatcher(MyApplication.isDebug())
                 .init(application)
 
 

+ 36 - 3
app/src/main/java/com/jld/vod/utils/SilentInstall.java

@@ -2,7 +2,11 @@ package com.jld.vod.utils;
 
 import android.content.Context;
 import android.content.Intent;
+import android.content.pm.IPackageInstallObserver;
+import android.content.pm.PackageInstaller;
+import android.content.pm.PackageManager;
 import android.net.Uri;
+import android.os.Build;
 import android.util.Log;
 
 import java.io.BufferedReader;
@@ -10,6 +14,8 @@ import java.io.DataOutputStream;
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStreamReader;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
 import java.nio.charset.Charset;
 
 /**
@@ -36,7 +42,7 @@ public class SilentInstall {
 
             Process process = Runtime.getRuntime().exec("su");
             dataOutputStream = new DataOutputStream(process.getOutputStream());
-            Log.d("install", "申请权限 " );
+            Log.d("install", "申请权限 ");
             // 执行pm install命令
             String command = "pm install -r " + apkPath + "\n";
             dataOutputStream.write(command.getBytes(Charset.forName("utf-8")));
@@ -47,7 +53,7 @@ public class SilentInstall {
             errorStream = new BufferedReader(new InputStreamReader(process.getErrorStream()));
             String msg = "";
             String line;
-            Log.d("install", "读取执行命令结果 " );
+            Log.d("install", "读取执行命令结果 ");
             // 读取命令的执行结果
             while ((line = errorStream.readLine()) != null) {
                 msg += line;
@@ -75,7 +81,7 @@ public class SilentInstall {
         return result;
     }
 
-    public static boolean openFile(Context mContext,String path) {
+    public static boolean openFile(Context mContext, String path) {
         // 核心是下面几句代码
         if (path.isEmpty()) {
             return false;
@@ -89,4 +95,31 @@ public class SilentInstall {
         mContext.startActivity(intent);
         return true;
     }
+
+    public static boolean silentInstall(PackageManager packageManager, String apkPath) {
+
+        Class pmClz = packageManager.getClass();
+        try {
+            if (Build.VERSION.SDK_INT >= 21) {
+                Class aClass = Class.forName("android.app.PackageInstallObserver");
+                Constructor constructor = aClass.getDeclaredConstructor();
+                constructor.setAccessible(true);
+                Object installObserver = constructor.newInstance();
+                Method method = pmClz.getDeclaredMethod("installPackage", Uri.class, aClass, int.class, String.class);
+
+                method.setAccessible(true);
+                method.invoke(packageManager, Uri.fromFile(new File(apkPath)), installObserver, 2, null);
+            } else {
+                Method method = pmClz.getDeclaredMethod("installPackage", Uri.class, Class.forName("android.content.pm.IPackageInstallObserver"), int.class, String.class);
+                method.setAccessible(true);
+                method.invoke(packageManager, Uri.fromFile(new File(apkPath)), null, 2, null);
+            }
+            return true;
+        } catch (Exception e) {
+            Log.e("stxinu", e.toString());
+        }
+        return false;
+    }
+
+
 }

+ 127 - 0
app/src/main/java/com/jld/vod/utils/WifiUtil.java

@@ -0,0 +1,127 @@
+package com.jld.vod.utils;
+
+import android.content.Context;
+import android.net.DhcpInfo;
+import android.net.wifi.WifiInfo;
+import android.net.wifi.WifiManager;
+
+import java.lang.reflect.Method;
+import java.net.InetAddress;
+import java.net.InterfaceAddress;
+import java.net.NetworkInterface;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * Created by melo on 2017/9/23.
+ */
+
+public class WifiUtil {
+
+    private static final String TAG = "LocationUtils";
+
+    private static volatile WifiUtil instance = null;
+
+    private WifiManager mWifiManager;
+
+    private Context mContext;
+
+    private WifiUtil(Context context) {
+        mContext = context;
+        mWifiManager = (WifiManager) mContext.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
+    }
+
+    public static WifiUtil getInstance(Context context) {
+        if (instance == null) {
+            synchronized (WifiUtil.class) {
+                if (instance == null) {
+                    instance = new WifiUtil(context);
+                }
+            }
+        }
+        return instance;
+    }
+
+    public boolean isWifiApEnabled() {
+        try {
+            Method method = mWifiManager.getClass().getMethod("isWifiApEnabled");
+            method.setAccessible(true);
+            return (Boolean) method.invoke(mWifiManager);
+
+        } catch (NoSuchMethodException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        return false;
+    }
+
+    public String getLocalIPAddress() {
+        WifiInfo wifiInfo = mWifiManager.getConnectionInfo();
+        return intToIp(wifiInfo.getIpAddress());
+    }
+
+    public String getServerIPAddress() {
+        DhcpInfo mDhcpInfo = mWifiManager.getDhcpInfo();
+        return intToIp(mDhcpInfo.gateway);
+    }
+
+    private static String intToIp(int i) {
+        return (i & 0xFF) + "." + ((i >> 8) & 0xFF) + "." + ((i >> 16) & 0xFF) + "."
+                + ((i >> 24) & 0xFF);
+    }
+
+    /**
+     * @return 优先获取网卡地址
+     */
+    public static String getBroadcastAddress() {
+        String broadcast = getBroadcastAddress("p2p");
+        if (broadcast == null) {
+            return getBroadcastAddress("wlan0");
+        }
+        return broadcast;
+    }
+
+    /**
+     * @param netCardName 网卡名称
+     * @return 获取的广播地址
+     */
+    public static String getBroadcastAddress(String netCardName) {
+        try {
+            Enumeration<NetworkInterface> eni = NetworkInterface
+                    .getNetworkInterfaces();
+            while (eni.hasMoreElements()) {
+                NetworkInterface networkCard = eni.nextElement();
+                if (networkCard.getDisplayName().startsWith(netCardName)) {
+                    List<InterfaceAddress> ncAddrList = networkCard
+                            .getInterfaceAddresses();
+                    Iterator<InterfaceAddress> ncAddrIterator = ncAddrList.iterator();
+                    while (ncAddrIterator.hasNext()) {
+                        InterfaceAddress networkCardAddress = ncAddrIterator.next();
+                        InetAddress address = networkCardAddress.getAddress();
+                        if (!address.isLoopbackAddress()) {
+                            String hostAddress = address.getHostAddress();
+                            if (hostAddress.indexOf(":") > 0) {
+                                // case : ipv6
+                                continue;
+                            } else {
+                                // case : ipv4
+                                String broadcastAddress = networkCardAddress.getBroadcast().getHostAddress();
+                                return broadcastAddress;
+                            }
+                        }
+                    }
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        return null;
+    }
+
+
+}

+ 142 - 0
app/src/main/java/com/jld/vod/utils/WinCallback.java

@@ -0,0 +1,142 @@
+package com.jld.vod.utils;
+
+import android.annotation.TargetApi;
+import android.os.Build;
+import android.view.ActionMode;
+import android.view.KeyEvent;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.MotionEvent;
+import android.view.SearchEvent;
+import android.view.View;
+import android.view.Window;
+import android.view.WindowManager;
+import android.view.accessibility.AccessibilityEvent;
+
+import androidx.annotation.Nullable;
+
+public class WinCallback implements Window.Callback {
+    Window.Callback callback;
+
+    public WinCallback(Window.Callback callback) {
+        this.callback = callback;
+    }
+
+    @Override
+    public boolean dispatchKeyEvent(KeyEvent event) {
+        return callback.dispatchKeyEvent(event);
+    }
+
+    @Override
+    public boolean dispatchKeyShortcutEvent(KeyEvent event) {
+        return callback.dispatchKeyShortcutEvent(event);
+    }
+
+    @Override
+    public boolean dispatchTouchEvent(MotionEvent event) {
+        return callback.dispatchTouchEvent(event);
+    }
+
+    @Override
+    public boolean dispatchTrackballEvent(MotionEvent event) {
+        return callback.dispatchTrackballEvent(event);
+    }
+
+    @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1)
+    @Override
+    public boolean dispatchGenericMotionEvent(MotionEvent event) {
+        return callback.dispatchGenericMotionEvent(event);
+    }
+
+    @Override
+    public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
+        return callback.dispatchPopulateAccessibilityEvent(event);
+
+    }
+
+    @Override
+    public View onCreatePanelView(int featureId) {
+        return callback.onCreatePanelView(featureId);
+    }
+
+    @Override
+    public boolean onCreatePanelMenu(int featureId, Menu menu) {
+        return callback.onCreatePanelMenu(featureId, menu);
+    }
+
+    @Override
+    public boolean onPreparePanel(int featureId, View view, Menu menu) {
+        return callback.onPreparePanel(featureId, view, menu);
+    }
+
+    @Override
+    public boolean onMenuOpened(int featureId, Menu menu) {
+        return callback.onMenuOpened(featureId, menu);
+    }
+
+    @Override
+    public boolean onMenuItemSelected(int featureId, MenuItem item) {
+        return callback.onMenuItemSelected(featureId, item);
+    }
+
+    @Override
+    public void onWindowAttributesChanged(WindowManager.LayoutParams attrs) {
+        callback.onWindowAttributesChanged(attrs);
+    }
+
+    @Override
+    public void onContentChanged() {
+        callback.onContentChanged();
+    }
+
+    @Override
+    public void onWindowFocusChanged(boolean hasFocus) {
+        callback.onWindowFocusChanged(hasFocus);
+    }
+
+    @Override
+    public void onAttachedToWindow() {
+        callback.onAttachedToWindow();
+    }
+
+    @Override
+    public void onDetachedFromWindow() {
+        callback.onDetachedFromWindow();
+    }
+
+    @Override
+    public void onPanelClosed(int featureId, Menu menu) {
+        callback.onPanelClosed(featureId, menu);
+    }
+
+    @Override
+    public boolean onSearchRequested() {
+        return callback.onSearchRequested();
+    }
+
+    @Override
+    public boolean onSearchRequested(SearchEvent searchEvent) {
+        return false;
+    }
+
+    @Override
+    public ActionMode onWindowStartingActionMode(ActionMode.Callback callback) {
+        return this.callback.onWindowStartingActionMode(callback);
+    }
+
+    @Nullable
+    @Override
+    public ActionMode onWindowStartingActionMode(ActionMode.Callback callback, int type) {
+        return null;
+    }
+
+    @Override
+    public void onActionModeStarted(ActionMode mode) {
+        callback.onActionModeStarted(mode);
+    }
+
+    @Override
+    public void onActionModeFinished(ActionMode mode) {
+        callback.onActionModeFinished(mode);
+    }
+}

+ 33 - 0
app/src/main/java/com/jld/vod/utils/http/RetrofitUtils.kt

@@ -385,5 +385,38 @@ object RetrofitUtils {
                 .subscribe(observer, error)
         return disposable
     }
+    /**
+     * 获取固定位置广告
+     */
+    fun findPositionAdvert(observer: (userBean: BaseBean<List<PositionAdvertBean>>) -> Unit, error: (t: Throwable) -> Unit): Disposable {
+        val disposable = apis.findPositionAdvert().subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
+            .subscribe(observer, error)
+        return disposable
+    }
+    /**
+     * 获取GEO广告
+     */
+    fun findGEOAdvert(observer: (userBean: BaseBean<List<String>>) -> Unit, error: (t: Throwable) -> Unit): Disposable {
+        val disposable = apis.findGEOAdvert().subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
+            .subscribe(observer, error)
+        return disposable
+    }
+    /**
+     * 获取电影广告
+     */
+    fun findMovieAdvert(observer: (userBean: BaseBean<List<String>>) -> Unit, error: (t: Throwable) -> Unit): Disposable {
+        val disposable = apis.findMovieAdvert().subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
+            .subscribe(observer, error)
+        return disposable
+    }
+
+    /**
+     * 绑定用户
+     */
+    fun updateUser(userId:String,observer: (userBean: BaseBean<String>) -> Unit, error: (t: Throwable) -> Unit): Disposable {
+        val disposable = apis.updateUser(userId).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
+                .subscribe(observer, error)
+        return disposable
+    }
 }
 

+ 4 - 0
app/src/main/java/com/jld/vod/view/HomeActivity.kt

@@ -26,6 +26,7 @@ import com.jld.vod.base.BaseActivity
 import com.jld.vod.config.Config
 import com.jld.vod.model.bean.ModelAllBean
 import com.jld.vod.service.LatLongService
+import com.jld.vod.service.PositionAdvertService
 import com.jld.vod.ui.animator.HomeRatateImage
 import com.jld.vod.utils.DateUtils
 import com.jld.vod.utils.LogUtils
@@ -64,8 +65,11 @@ class HomeActivity : BaseActivity() {
     override fun initView() {
         super.initView()
 
+
         //开启获取经纬度服务
         startService(Intent(this,LatLongService::class.java))
+        //开启固定广告服务
+        startService(Intent(this,PositionAdvertService::class.java))
 
         //初始化mainviewmodel
         viewModel =ViewModelProvider.AndroidViewModelFactory(application).create(MainViewModel::class.java)

+ 71 - 14
app/src/main/java/com/jld/vod/view/MainActivity.kt

@@ -5,6 +5,7 @@ import android.content.Context
 import android.content.Intent
 import android.content.IntentFilter
 import android.graphics.drawable.Drawable
+import android.os.Handler
 import android.text.InputType
 import android.util.Log
 import android.view.MotionEvent
@@ -21,11 +22,13 @@ import com.jld.vod.R
 import com.jld.vod.base.BaseActivity
 import com.jld.vod.config.Config
 import com.jld.vod.model.bean.*
+import com.jld.vod.service.MyAccessibilityService
 import com.jld.vod.utils.DateUtils
 import com.jld.vod.utils.LogUtils
 import com.jld.vod.utils.PopupUtils
 import com.jld.vod.utils.SharedPrefUtils
 import com.jld.vod.view.fragment.*
+import com.jld.vod.view.widget.CustomGEOAdDialog
 import com.jld.vod.view.widget.UpCircleMenuLayout
 import com.jld.vod.viewmodel.MainViewModel
 import com.xuexiang.xpage.enums.CoreAnim
@@ -35,6 +38,7 @@ import com.xuexiang.xui.widget.dialog.materialdialog.MaterialDialog
 import com.xuexiang.xui.widget.popupwindow.popup.XUIListPopup
 import com.xuexiang.xui.widget.popupwindow.popup.XUIPopup
 import kotlinx.android.synthetic.main.activity_main.*
+import org.greenrobot.eventbus.EventBus
 import java.util.*
 
 
@@ -54,6 +58,7 @@ class MainActivity : BaseActivity() {
     private var mAllModularRotateImgBean:List<AllModularRotateImgBean> ?=null
     private val password : String = "123456"
     private var pos = 0
+    private val mHandler = Handler()
 
     private val mItemTexts = arrayOf(
         "电影", "音乐", "游戏",
@@ -76,7 +81,8 @@ class MainActivity : BaseActivity() {
         pos = bundle!!.getInt("pos")
 
         mUpCircleMenuLayout = findViewById(R.id.id_mymenulayout) as UpCircleMenuLayout
-        viewModel = ViewModelProvider.AndroidViewModelFactory(application).create(MainViewModel::class.java)
+        viewModel = ViewModelProvider.
+         AndroidViewModelFactory(application).create(MainViewModel::class.java)
 
 
         //初始化车牌号
@@ -110,8 +116,8 @@ class MainActivity : BaseActivity() {
         viewModel.getLanguage()
         //获取全部模块
         viewModel.getAllModular()
-
-
+        //获取固定广告
+        viewModel.findPositionAdvert()
     }
 
     override fun initData() {
@@ -127,19 +133,53 @@ class MainActivity : BaseActivity() {
         initIconRes()
         //初始化模块id
         initMid()
+        //初始化广告模块
+        initAdVert()
+    }
+
+    /**
+     * 初始化广告模块
+     */
+    private fun initAdVert() {
+        viewModel.findPositionAdvertLiveData.observe(this) {res->
+            LogUtils.logD("findPositionAdvertLiveData"+res.data)
+            when (res?.code) {
+                BaseBean.SUCCESS -> {
+                    if (res.data!!.size != 0)
+                    {
+                        val isFirstShowAds = SharedPrefUtils.getBoolean(this,"isFirstShowAds",true)
+                        if (isFirstShowAds)
+                        {
+                            mHandler.postDelayed(Runnable {
+                                EventBus.getDefault().post(res.data)
+                                SharedPrefUtils.putBoolean(this,"isFirstShowAds",false)
+                            },5000)
+                        }
+                    }
+
+                    finishLoading()
+                }
+                BaseBean.ERROR -> {
+                    finishLoading()
+                    Toast.makeText(this, res.message, Toast.LENGTH_SHORT).show()
+                }
+                BaseBean.LOADING -> showLoading()
+            }
+        }
     }
+
     override fun initEvent() {
         super.initEvent()
 
         mUpCircleMenuLayout!!.setOnMenuItemClickListener(object :UpCircleMenuLayout.OnMenuItemClickListener{
-
             override fun itemClick(pos: Int) {
                 //根据网络判断数据选择功能
                 if (mAllModularRotateImgBean!!.size != 0)
                 {
                     var modelType = mAllModularRotateImgBean!![pos].mid
                     var gardenType = mAllModularRotateImgBean!![pos].garden
-                    //LogUtils.logD("gardenType"+gardenType)
+
+                    LogUtils.logD("gardenType"+modelType)
                     //加载半圆图标
                     Glide.with(applicationContext)
                         .load(Config.ApiBaseUrl + "/synchronization/previewImg?imgUrl=" + gardenType)
@@ -147,48 +187,62 @@ class MainActivity : BaseActivity() {
                     if (modelType.equals("RES_MOVIE")) {
 //                        openPage(MovieFragment::class.java)
                         openPage("MovieFragment", null, CoreAnim.none,false)
+                        //changePage("MovieFragment", null, CoreAnim.none)
                         //    changePage(MovieFragment::class.java)
                     }else if (modelType.equals("RES_MUSIC")) {
                         //  openPage(MusicFragment::class.java)
                         openPage("MusicFragment",null, CoreAnim.none,false)
+                        //changePage("MusicFragment", null, CoreAnim.none)
 //                        changePage(MusicFragment::class.java)
                     }else if (modelType.equals("RES_GAME")) {
                         //  openPage(GameFragment::class.java)
                         openPage("GameFragment", null, CoreAnim.none,false)
+                        //changePage("GameFragment", null, CoreAnim.none)
                     }else if (modelType.equals("RES_NETWORK")) {
                         //  openPage(BrowserFragment::class.java)
                         openPage("BrowserFragment", null, CoreAnim.none,false)
+                        //changePage("BrowserFragment", null, CoreAnim.none)
                     }else if (modelType.equals("RES_MAP")) {
                         //  openPage(MapsFragment::class.java)
                         openPage("MapsFragment", null, CoreAnim.none,false)
+                        //changePage("MapsFragment", null, CoreAnim.none)
                     }else if (modelType.equals("RES_ABOUT")) {
                         //openPage(AboutFragment::class.java)
                         openPage("AboutFragment", null, CoreAnim.none,false)
+                        //changePage("AboutFragment", null, CoreAnim.none)
+                    }else if(modelType.equals("RES_ORDER")){
+                        openPage("OrderFragment", null, CoreAnim.none,false)
                     }
                 }else{
                     if (mItemTexts[pos].equals("电影")) {
                         // openPage(MovieFragment::class.java)
                         openPage("MovieFragment", null, CoreAnim.none,false)
+                        //changePage("MovieFragment", null, CoreAnim.none)
                         iv_mymenu_center.setImageResource(R.mipmap.round_moive)
                     }else if (mItemTexts[pos].equals("音乐")) {
                         // openPage(MusicFragment::class.java)
                         openPage("MusicFragment",null, CoreAnim.none,false)
+                        //changePage("MusicFragment", null, CoreAnim.none)
                         iv_mymenu_center.setImageResource(R.mipmap.round_music)
                     }else if (mItemTexts[pos].equals("游戏")) {
                         //  openPage(GameFragment::class.java)
                         openPage("GameFragment",null, CoreAnim.none,false)
+                        //changePage("GameFragment", null, CoreAnim.none)
                         iv_mymenu_center.setImageResource(R.mipmap.round_game)
                     }else if (mItemTexts[pos].equals("浏览器")) {
                         //openPage(BrowserFragment::class.java)
                         openPage("BrowserFragment",null, CoreAnim.none,false)
+                        //changePage("BrowserFragment", null, CoreAnim.none)
                         iv_mymenu_center.setImageResource(R.mipmap.round_network)
                     }else if (mItemTexts[pos].equals("地图")) {
                         //openPage(MapsFragment::class.java)
                         openPage("MapsFragment",null, CoreAnim.none,false)
+                        //changePage("MapsFragment", null, CoreAnim.none)
                         iv_mymenu_center.setImageResource(R.mipmap.round_maps)
                     }else if (mItemTexts[pos].equals("关于")) {
                         // openPage(AboutFragment::class.java)
                         openPage("AboutFragment",null, CoreAnim.none,false)
+                        //changePage("AboutFragment", null, CoreAnim.none)
                         iv_mymenu_center.setImageResource(R.mipmap.round_settings)
                     }
                 }
@@ -286,34 +340,37 @@ class MainActivity : BaseActivity() {
      */
     private fun initIconRes() {
         viewModel.findAllModularRotateImgBeanLiveData.observe(this){it->
-            LogUtils.logD("main"+it)
+            //LogUtils.logD("initIconRes"+it)
             if(it.data!!.size != 0) {
                 mUpCircleMenuLayout!!.setMenuItemIconsAndTexts(it.data)
                 mAllModularRotateImgBean = it.data
-                //LogUtils.logD("AllModularRotateImgBean"+it.data+"==" + it.data.get(pos)+"=="+pos)
+                //LogUtils.logD("AllModularRotateImgBean"+it.data+"==" + it.data.get(pos).mid+"=="+pos)
                 //加载半圆图标
                 Glide.with(this)
                     .load(Config.ApiBaseUrl + "/synchronization/previewImg?imgUrl=" + it.data.get(9).garden)
                     .into(iv_mymenu_center)
-                when (pos) {
-                    0 -> {
+                when (it.data.get(pos).mid) {
+                    "RES_MOVIE" -> {
                         openPage(MovieFragment::class.java)
                     }
-                    1 -> {
+                    "RES_MUSIC" -> {
                         openPage(MusicFragment::class.java)
                     }
-                    2 -> {
+                    "RES_GAME" -> {
                         openPage(GameFragment::class.java)
                     }
-                    3 -> {
+                    "RES_BROWSER" -> {
                         openPage(BrowserFragment::class.java)
                     }
-                    4 -> {
+                    "RES_MAP" -> {
                         openPage(MapsFragment::class.java)
                     }
-                    5 -> {
+                    "RES_ABOUT" -> {
                         openPage(AboutFragment::class.java)
                     }
+                    "RES_ORDER" -> {
+                        openPage(OrderFragment::class.java)
+                    }
                 }
             }
         }

+ 6 - 5
app/src/main/java/com/jld/vod/view/MusicPlayActivity.kt

@@ -146,7 +146,7 @@ class MusicPlayActivity : BaseActivity(),View.OnClickListener {
 
         override fun onPrepare() {
             LogUtils.logD(TAG, "onPrepare()")
-            runOnUiThread { showDialog() }
+            runOnUiThread { showLoading() }
         }
 
         override fun onPrepared(duration: Long) {
@@ -156,7 +156,7 @@ class MusicPlayActivity : BaseActivity(),View.OnClickListener {
 
         override fun onPlay() {
             LogUtils.logD(TAG, "onPlay()")
-            runOnUiThread { dismissDialog() }
+            runOnUiThread { finishLoading() }
         }
 
         override fun onStop() {
@@ -355,8 +355,8 @@ class MusicPlayActivity : BaseActivity(),View.OnClickListener {
     override fun initEvent() {
         super.initEvent()
         handler.sendEmptyMessage(MSG_SHOW_UI)
-        ratateImage = RatateImage(context, albumView)
-        ratateRobotArm = RatateRobotArm(context, discMagneticStripe!!)
+        ratateImage = RatateImage(this, albumView)
+        ratateRobotArm = RatateRobotArm(this, discMagneticStripe!!)
 
         //动态背景图片
         val main_bg_img = SharedPrefUtils.getString(this,"main_bg_img")
@@ -449,7 +449,7 @@ class MusicPlayActivity : BaseActivity(),View.OnClickListener {
     private fun setTest(music:List<MusicByMidBean>) {
         var musicName:String? = ""
         for ((index,e) in music.withIndex()) {
-            LogUtils.logD("清单:"+music[index])
+           // LogUtils.logD("清单:"+music[index])
              musicName = music[index].musicName
 
             val audio = Audio()
@@ -761,6 +761,7 @@ class MusicPlayActivity : BaseActivity(),View.OnClickListener {
             }
             unbindService(serviceConnection)
         }
+
         unregisterReceiver(receiver)
     }
 

+ 10 - 0
app/src/main/java/com/jld/vod/view/OrderActivity.kt

@@ -0,0 +1,10 @@
+package com.jld.vod.view
+
+import com.jld.vod.R
+import com.jld.vod.base.BaseActivity
+
+class OrderActivity : BaseActivity() {
+    override fun getLayoutId(): Int {
+        return R.layout.activity_order
+    }
+}

+ 1 - 0
app/src/main/java/com/jld/vod/view/PostFileActivity.kt

@@ -114,6 +114,7 @@ class PostFileActivity : BaseActivity() {
 
     override fun initView() {
         super.initView()
+
         context = this
         progressdialog = ProgressDialog(this@PostFileActivity)
     }

+ 43 - 0
app/src/main/java/com/jld/vod/view/SettingsActivity.kt

@@ -11,6 +11,14 @@ import androidx.appcompat.app.AppCompatActivity
 import androidx.preference.Preference
 import androidx.preference.PreferenceFragmentCompat
 import com.jld.vod.R
+import com.jld.vod.config.Config
+import com.jld.vod.model.event.ReceiveEvent
+import com.jld.vod.service.SocketService
+import com.jld.vod.socket.SendSocketManager
+import com.jld.vod.utils.LogUtils
+import org.greenrobot.eventbus.EventBus
+import org.json.JSONException
+import org.json.JSONObject
 
 class SettingsActivity : AppCompatActivity() {
 
@@ -32,6 +40,18 @@ class SettingsActivity : AppCompatActivity() {
             .commit()
         supportActionBar?.setDisplayHomeAsUpEnabled(true)
 
+
+        val jsonObject = JSONObject()
+        try {
+            jsonObject.put(Config.TYPE, "CLOSE")
+            jsonObject.put(Config.MSG, "false")
+        } catch (e: JSONException) {
+            e.printStackTrace()
+        }
+
+        //关闭udp接收
+        EventBus.getDefault().post(ReceiveEvent(jsonObject.toString()))
+
     }
 
     override fun onOptionsItemSelected(item: MenuItem): Boolean {
@@ -56,11 +76,19 @@ class SettingsActivity : AppCompatActivity() {
     }
 
     class SettingsFragment : PreferenceFragmentCompat() {
+        private var sendSocketManager: SendSocketManager? = null
+
         override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
+
+            sendSocketManager = SendSocketManager.getInstance(activity)
+            sendSocketManager!!.startUdpConnection()
+
             setPreferencesFromResource(R.xml.root_preferences, rootKey)
             val wifi_settings = findPreference<Preference>("wifi_settings")
             val seat_settings = findPreference<Preference>("seat_settings")
 
+            val ads_control = findPreference<Preference>("ads_control")
+            val screen_control = findPreference<Preference>("screen_control")
             wifi_settings!!.onPreferenceClickListener = Preference.OnPreferenceClickListener {
                 var i: Intent? = Intent()
                 i = Intent(Settings.ACTION_WIFI_SETTINGS)
@@ -74,6 +102,21 @@ class SettingsActivity : AppCompatActivity() {
                 startActivity(intent)
                 false
             }
+
+            //一键广告播放
+            ads_control!!.onPreferenceChangeListener = Preference.OnPreferenceChangeListener { preference, newValue ->
+                LogUtils.logD("preference"+preference+"newValue"+newValue)
+                sendSocketManager!!.sendMsg(Config.ADS, newValue.toString())
+                true
+            }
+
+            //一键熄屏
+            screen_control!!.onPreferenceChangeListener = Preference.OnPreferenceChangeListener { preference, newValue ->
+                LogUtils.logD("preference"+preference+"newValue"+newValue)
+                sendSocketManager!!.sendMsg(Config.SCREEN, newValue.toString())
+                true
+            }
+
         }
     }
 }

+ 96 - 32
app/src/main/java/com/jld/vod/view/SplashActivity.kt

@@ -3,6 +3,10 @@ import android.Manifest
 import android.app.PendingIntent
 import android.app.ProgressDialog
 import android.content.Intent
+import android.content.pm.IPackageInstallObserver
+import android.content.pm.PackageInfo
+import android.content.pm.PackageManager
+import android.net.Uri
 import android.os.Build
 import android.os.Handler
 import android.os.Message
@@ -19,11 +23,12 @@ import com.jld.vod.base.BaseActivity
 import com.jld.vod.config.Config
 import com.jld.vod.interfaces.IDownloadCallBack
 import com.jld.vod.model.bean.*
+import com.jld.vod.service.LatLongService
 import com.jld.vod.service.MyAccessibilityService
+import com.jld.vod.service.SocketService
 import com.jld.vod.utils.AppUtil
 import com.jld.vod.utils.LogUtils
 import com.jld.vod.utils.SharedPrefUtils
-import com.jld.vod.utils.SilentInstall
 import com.jld.vod.utils.http.OkHttpDownloadUtils
 import com.jld.vod.utils.http.OkHttpUtils
 import com.jld.vod.view.widget.UpdateVersionDialog
@@ -153,6 +158,10 @@ class SplashActivity : BaseActivity(){
         progressdialog = ProgressDialog(this@SplashActivity)
         deviceSN =  AppUtil.getDeviceSN()
 
+        startService(Intent(this, SocketService::class.java))
+
+        //第一次进入标识
+        SharedPrefUtils.putBoolean(this,"isFirstShowAds",true)
         //座位号显示
         val seatid = SharedPrefUtils.getString(this,"seatid")
         //欢迎提示
@@ -243,7 +252,7 @@ class SplashActivity : BaseActivity(){
     private fun initApkUpdate() {
         //1.Apk更新
         var data:String? = null
-        splashViewmodel.detectAppUpdatesliveData.observe(this){res->
+        splashViewmodel.detectAppUpdatesliveData.observe(this){ res->
             ajaxInfo(getString(R.string.check_for_version_updates)+"....",null)
             LogUtils.logD("检测版本更新---$res")
             //有更新
@@ -255,10 +264,21 @@ class SplashActivity : BaseActivity(){
             }else{
                 finishLoading()
                 ajaxInfo(getString(R.string.check_whether_the_vehicle_is_bound)+"....",null)
+                //判断是否绑定用户
+               // splashViewmodel.updateUser("1326427637489958913")
                 splashViewmodel.eqCar(this.userId!!)//检测是否绑定云
             }
         }
-
+//        splashViewmodel.updateUserLiveData.observe(this){res->
+//            if (res)//绑定用户成功
+//            {
+//                  splashViewmodel.eqCar(this.userId!!)//检测是否绑定云
+//                ajaxInfo(getString(R.string.User_binding_succeeded)+"....",null)
+//            }else{
+//                ajaxInfo(getString(R.string.Failure_to_Bind_a_user)+"....",null)
+//            }
+//
+//        }
         //3.获取apk路径,下载更新
         splashViewmodel.previewAPKliveData.observe(this){res ->
             //有更新
@@ -527,7 +547,9 @@ class SplashActivity : BaseActivity(){
         OkHttpDownloadUtils.getInstance()
             .download(Config.ApiBaseUrl+"/"+apkUrl, targetFile, object : IDownloadCallBack {
                 override fun success(apkfile: File) {
-                    LogUtils.logD(Config.ApiBaseUrl+"/"+apkUrl)
+                    //获取包名
+                    val packname =  AppUtil.getApkPackName(applicationContext,apkfile.absolutePath)
+
                     lenitem++
                     LogUtils.logD("apk"+apkfile.absolutePath)
                     val msg = Message()
@@ -536,40 +558,17 @@ class SplashActivity : BaseActivity(){
                     msg.obj = "installing apk"
                     mHandler.sendMessage(msg)
 
-                    val isOk = SilentInstall.install(apkfile.absolutePath)
+                    InstallGame( apkfile.absolutePath,packname,gid)
 
                     ajaxInfo(getString(R.string.download_games1)+getString(R.string.sum_total)+totalitem+getString(R.string.download_games2)+"${(totalitem-lenitem)}" + getString(R.string.fail_sum)+failitem,null)
-                    //是否安装成功
-                    if (isOk) {
-                        //获取包名
-                        val packname =  AppUtil.getApkPackName(applicationContext,apkfile.absolutePath)
-                        LogUtils.logD("GameObserver $isOk 下载完成安装完成.且更新安装状态:$packname")
-                        try {
-                            splashViewmodel.updateGameInstallState(gid.toString(),packname,deviceSN)
-                        }catch (e:Exception) {
-                            e.printStackTrace()
-                        }
-                        if (lenitem == totalitem) {
-                            lenitem = 0
-                            totalitem = 0
 
-                            splashViewmodel.getNuInstallGame(deviceSN)//开始卸载游戏
+                  //  val mPm = mContext.packageManager
+                    //val isOk = SilentInstall.silentInstall(mPm, apkfile.absolutePath)
 
-                            //flag = true
-                           // ajaxInfo(getString(R.string.welcometext),null)
-                        }
-
-                    }else{
-                        LogUtils.logD("游戏安装失败?")
-                        failitem++
+                    //  LogUtils.logD("安装状态"+isOk)
+                    // val isOk = SilentInstall.install(apkfile.absolutePath)
 
-                        if (lenitem == totalitem) {
-                            lenitem = 0
-                            totalitem = 0
-                            splashViewmodel.getNuInstallGame(deviceSN)//开始卸载游戏
 
-                        }
-                    }
                 }
                 override fun progress(progress: Int) {
 
@@ -969,4 +968,69 @@ class SplashActivity : BaseActivity(){
             progressdialog!!.dismiss()
         }
     }
+
+    /**
+     * 安装apk
+     */
+    fun InstallGame(fileName: String?, packageName: String?,gid:Long) //
+    {
+        if (fileName == null || fileName.length == 0) {
+            return
+        }
+
+        val file =  File(fileName);
+        if (file == null || file.length() <= 0 || !file.exists() || !file.isFile()) {
+            return
+        }
+        val uri: Uri = Uri.fromFile(file)
+        var installFlags = 0
+        val pm = packageManager
+        try {
+            val pi: PackageInfo? = pm.getPackageInfo(packageName, PackageManager.GET_UNINSTALLED_PACKAGES) //
+            if (pi != null) {
+                installFlags = installFlags or PackageManager.INSTALL_REPLACE_EXISTING
+            }
+        } catch (e: PackageManager.NameNotFoundException) {
+            e.printStackTrace()
+        }
+        val observer = PackageInstallObserver(gid)
+        pm.installPackage(uri, observer, installFlags, packageName) //下面有详细
+    }
+
+    //用于返回游戏安装状态
+    inner class PackageInstallObserver(gids: Long) : IPackageInstallObserver.Stub() {
+        var gid :Long = 0
+        init {
+            this.gid = gids
+        }
+        override fun packageInstalled(packageName: String?, returnCode: Int) { //如果returnCode == 1就为成功
+            LogUtils.logD("GameObserver $packageName 下载完成安装完成.且更新安装状态:$returnCode")
+            //是否安装成功
+            if (returnCode == 1) {
+                try {
+                    splashViewmodel.updateGameInstallState(gid.toString(),packageName!!,deviceSN)
+                }catch (e:Exception) {
+                    e.printStackTrace()
+                }
+                if (lenitem == totalitem) {
+                    lenitem = 0
+                    totalitem = 0
+
+                    splashViewmodel.getNuInstallGame(deviceSN)//开始卸载游戏
+                }
+
+            }else{
+                LogUtils.logD("游戏安装失败?")
+                failitem++
+
+                if (lenitem == totalitem) {
+                    lenitem = 0
+                    totalitem = 0
+                    splashViewmodel.getNuInstallGame(deviceSN)//开始卸载游戏
+
+                }
+            }
+
+        }
+    }
 }

+ 64 - 6
app/src/main/java/com/jld/vod/view/VideoPlayActivity.kt

@@ -1,8 +1,12 @@
 package com.jld.vod.view
 
+import android.media.MediaPlayer
+import android.os.CountDownTimer
+import android.util.Log
 import android.view.KeyEvent
 import android.view.MotionEvent
 import android.view.View
+import android.widget.RelativeLayout
 import cn.jzvd.Jzvd
 import com.bumptech.glide.Glide
 import com.jld.vod.R
@@ -10,7 +14,7 @@ import com.jld.vod.base.BaseActivity
 import com.jld.vod.config.Config
 import com.jld.vod.utils.PopupUtils
 import com.jld.vod.view.widget.MyJzvdStd
-import kotlinx.android.synthetic.main.jz_layout_std.view.*
+import kotlinx.android.synthetic.main.activity_play_video.*
 
 
 /**
@@ -21,13 +25,15 @@ import kotlinx.android.synthetic.main.jz_layout_std.view.*
  */
 class VideoPlayActivity : BaseActivity() {
     private var jzvdStd:MyJzvdStd ?= null
+    private var flagAdsComplete:Boolean = false
+
     override fun getLayoutId(): Int {
         return R.layout.activity_play_video
     }
 
     override fun initView() {
         super.initView()
-
+        flagAdsComplete  = false//广告未播放完成
 //        val intent= intent
 //        val movieFileUrl = intent.getStringExtra("movieFileUrl")
 //        val movieName = intent.getStringExtra("movieName")
@@ -80,8 +86,47 @@ class VideoPlayActivity : BaseActivity() {
             override fun onTouch(v: View?, event: MotionEvent?): Boolean {
                 return true
             }
-        });
+        })
+        vd_ad.setOnTouchListener(object :View.OnTouchListener{
+            override fun onTouch(v: View?, event: MotionEvent?): Boolean {
+                return true
+            }
+        })
+
+        //videoview全屏拉伸
+        val layoutParams = RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT)
+        layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM)
+        layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP)
+        layoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT)
+        layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT)
+        vd_ad.setLayoutParams(layoutParams)
+
+        val videoPath = "http://vfx.mtime.cn/Video/2019/07/12/mp4/190712140656051701.mp4";
+        //设置播放地址,网络视频同样使用此方法,将网址链接放入即可
+        vd_ad.setVideoPath(videoPath);
+        vd_ad.start()
+        //循环播放
+        vd_ad.setOnPreparedListener(MediaPlayer.OnPreparedListener { mp ->
+            mp.start()
+            mp.isLooping = true
+        })
+
+
+        /** 倒计时100秒,一次1秒 */
+        val timer = object : CountDownTimer(100 * 1000, 1000) {
+            override fun onTick(millisUntilFinished: Long) {
+                val s = millisUntilFinished / 1000
+                auto_ms_text.setText(s.toString() + "")
+            }
 
+            override fun onFinish() {
+                vd_ad.stopPlayback()
+                auto_ms_text.setText("0")
+                fl_bg_ad.visibility = View.GONE
+                jzvdStd!!.startButton.performClick()//自动播放电影
+                flagAdsComplete  = true//广告播放完成
+            }
+        }.start()
 
 //        val layoutParams = jzvdStd.backButton.getLayoutParams()
 //        layoutParams.width = 72
@@ -100,11 +145,24 @@ class VideoPlayActivity : BaseActivity() {
         jzvdStd!!.setUp(Config.ApiBaseUrl+"/"+movieFileUrl, movieName)
 
         jzvdStd!!.setScreenFullscreen()//全屏播放
-        jzvdStd!!.startButton.performClick()//自动播放
+
+       // jzvdStd!!.startButton.performClick()//自动播放
 
         Glide.with(this).load(movieImgUrl).into(jzvdStd!!.posterImageView)
     }
-
+    override fun onWindowFocusChanged(hasFocus: Boolean) {
+        if (flagAdsComplete)
+        {
+           if (hasFocus)
+           {
+                jzvdStd!!.startButton.performClick()//自动播放
+           }else{
+                jzvdStd!!.startButton.performClick()//自动播放
+           }
+        }
+        Log.e("zhaofuxin", "onWindowFocusChanged: activity焦点变化=="+hasFocus );
+        super.onWindowFocusChanged(hasFocus )
+    }
     override fun onBackPressed() {
         if(Jzvd.backPress()) { return }
         super.onBackPressed()
@@ -117,8 +175,8 @@ class VideoPlayActivity : BaseActivity() {
     }
 
     override fun onDestroy() {
-        if(Jzvd.backPress()) { return }
         super.onDestroy()
+        if(Jzvd.backPress()) { return }
     }
 
     override fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean {

+ 53 - 0
app/src/main/java/com/jld/vod/view/fragment/OrderFragment.kt

@@ -0,0 +1,53 @@
+package com.jld.vod.view.fragment
+
+import android.content.Intent
+import android.widget.ImageView
+import androidx.lifecycle.Observer
+import androidx.lifecycle.ViewModelProviders
+import androidx.lifecycle.lifecycleScope
+import androidx.paging.LoadState
+import androidx.recyclerview.widget.GridLayoutManager
+import androidx.recyclerview.widget.RecyclerView
+import com.jld.kotilntest.room.adapter.BrowserAdapter
+import com.jld.vod.R
+import com.jld.vod.base.BaseFragment
+import com.jld.vod.model.bean.BaseBean
+import com.jld.vod.model.bean.BrowserBean
+import com.jld.vod.model.bean.ModelAllBean
+import com.jld.vod.utils.AppUtil
+import com.jld.vod.utils.LogUtils
+import com.jld.vod.utils.SharedPrefUtils
+import com.jld.vod.view.AboutActivity
+import com.jld.vod.view.OrderActivity
+import com.jld.vod.view.WebActivity
+import com.jld.vod.viewmodel.BrowserViewModel
+import com.jld.vod.viewmodel.MainViewModel
+import com.xuexiang.xpage.annotation.Page
+import com.xuexiang.xpage.enums.CoreAnim
+import com.xuexiang.xui.widget.actionbar.TitleBar
+import kotlinx.android.synthetic.main.fragment_order.*
+import kotlinx.coroutines.flow.collect
+import kotlinx.coroutines.flow.collectLatest
+
+@Page(anim = CoreAnim.none)
+class OrderFragment : BaseFragment() {
+
+    private lateinit var iv_order:ImageView
+    override fun getLayoutId(): Int {
+        return R.layout.fragment_order
+    }
+
+    override fun initViews() {
+
+        iv_order = findViewById(R.id.iv_order)
+
+        iv_order.setOnClickListener {
+            val intent = Intent(activity, OrderActivity::class.java)
+            startActivity(intent)
+        }
+    }
+
+    override fun initTitle(): TitleBar? {
+        return null
+    }
+}

+ 151 - 0
app/src/main/java/com/jld/vod/view/widget/CustomAdDialog.java

@@ -0,0 +1,151 @@
+package com.jld.vod.view.widget;
+
+import android.annotation.SuppressLint;
+import android.app.Dialog;
+import android.content.Context;
+import android.os.Bundle;
+import android.text.TextUtils;
+import android.util.Log;
+import android.view.View;
+import android.view.Window;
+import android.view.WindowManager;
+import android.widget.Button;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import com.jld.vod.R;
+import com.jld.vod.config.Config;
+import com.jld.vod.model.bean.PositionAdvertBean;
+import com.youth.banner.Banner;
+import com.youth.banner.BannerConfig;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class CustomAdDialog
+        extends Dialog
+{
+
+    private ImageView mCloseImg;
+    private Banner mBanner;
+    private List<String> list = new ArrayList<>();
+    private Context mContext;
+    public OnClickBottomListener onClickBottomListener;
+
+
+    public CustomAdDialog(Context paramContext)
+    {
+        super(paramContext, R.style.MyDialog);
+        this.mContext = paramContext;
+
+
+    }
+
+    private void initEvent()
+    {
+        this.mCloseImg.setOnClickListener(new View.OnClickListener()
+        {
+            public void onClick(View paramAnonymousView)
+            {
+                if (CustomAdDialog.this.onClickBottomListener != null) {
+                    CustomAdDialog.this.onClickBottomListener.onBtnCloseClick();
+                }
+            }
+        });
+
+    }
+
+    private void initView()
+    {
+        this.mCloseImg = (ImageView)findViewById(R.id.iv_close_ads);
+        //轮播
+        this.mBanner = (Banner)findViewById(R.id.about_banner);
+        //设置图片加载器
+        mBanner.setImageLoader(new GlideImageLoader());
+        //设置图片集合
+        mBanner.setImages(list);
+        //banner设置方法全部调用完毕时最后调用
+        mBanner.setBannerStyle(BannerConfig.CIRCLE_INDICATOR);
+        mBanner.setDelayTime(3000);
+        mBanner.start();
+    }
+
+    public List<String> getTestData3() {
+        list.add("https://img-blog.csdnimg.cn/20200524220705330.png");
+        list.add("https://img-blog.csdnimg.cn/20200524220705336.png");
+        list.add("https://img-blog.csdnimg.cn/20200524220705336.png");
+
+        return list;
+    }
+
+    /**
+     * 设置数据
+     * @param positionAdvert
+     */
+    public void setDataList(List<PositionAdvertBean> positionAdvert)
+    {
+        list.clear();
+        for (int i = 0;i<positionAdvert.size();i++)
+        {
+            list.add(Config.ApiBaseUrl + "/synchronization/previewImg?imgUrl=" + positionAdvert.get(i).getFilePath());
+        }
+
+    }
+
+    @SuppressLint("WrongConstant")
+    private void refreshView()
+    {
+
+//        if (!TextUtils.isEmpty(this.tv_ok)) {
+//            this.mBtnOk.setText(this.tv_ok);
+//        }
+//        if (!TextUtils.isEmpty(this.tv_no)) {
+//            this.mBtnNo.setText(this.tv_no);
+//        }
+//        Button localButton = this.mBtnNo;
+//        if (this.visiable) {}
+//        for (int i = 0;; i = 8)
+//        {
+//            localButton.setVisibility(i);
+//            if (!TextUtils.isEmpty(this.tv_cus))
+//            {
+//                this.mBtnCus.setText(this.tv_cus);
+//                this.mBtnCus.setVisibility(View.VISIBLE);
+//            }
+//            return;
+//        }
+    }
+
+    protected void onCreate(Bundle paramBundle)
+    {
+        super.onCreate(paramBundle);
+        setContentView(R.layout.custom_ad_dialog);
+        setCanceledOnTouchOutside(false);
+        Window w = getWindow();
+        int width = 850;
+        int height = 600;
+        w.setLayout(width,height);
+        w.setGravity(17);
+        WindowManager.LayoutParams localLayoutParams = w.getAttributes();
+
+        w.setWindowAnimations(R.style.AnimationDialog);
+        w.setAttributes(localLayoutParams);
+
+        initView();
+        refreshView();
+        initEvent();
+    }
+
+
+    public CustomAdDialog setOnClickBottomListener(OnClickBottomListener paramOnClickBottomListener)
+    {
+        this.onClickBottomListener = paramOnClickBottomListener;
+        return this;
+    }
+
+
+    public static abstract interface OnClickBottomListener
+    {
+        public abstract void onBtnCloseClick();
+    }
+}

+ 110 - 0
app/src/main/java/com/jld/vod/view/widget/CustomBlackBgDialog.java

@@ -0,0 +1,110 @@
+package com.jld.vod.view.widget;
+
+import android.annotation.SuppressLint;
+import android.app.Dialog;
+import android.content.Context;
+import android.os.Bundle;
+import android.os.CountDownTimer;
+import android.view.Window;
+import android.view.WindowManager;
+import android.widget.TextView;
+
+import com.jld.vod.R;
+import com.jld.vod.config.Config;
+import com.jld.vod.model.bean.Datas;
+import com.youth.banner.Banner;
+import com.youth.banner.BannerConfig;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class CustomBlackBgDialog
+        extends Dialog
+{
+
+    //private ImageView mCloseImg;
+    private TextView auto_ms_text;
+    private Banner mBanner;
+    private List<String> list = new ArrayList<>();
+    private Context mContext;
+    public OnClickBottomListener onClickBottomListener;
+
+
+    public CustomBlackBgDialog(Context paramContext)
+    {
+        super(paramContext, R.style.MyDialog);
+        this.mContext = paramContext;
+
+
+    }
+
+    @Override
+    public void dismiss() {
+        super.dismiss();
+    }
+
+    private void initEvent()
+    {
+
+    }
+
+    @SuppressLint("WrongConstant")
+    private void refreshView()
+    {
+
+//        if (!TextUtils.isEmpty(this.tv_ok)) {
+//            this.mBtnOk.setText(this.tv_ok);
+//        }
+//        if (!TextUtils.isEmpty(this.tv_no)) {
+//            this.mBtnNo.setText(this.tv_no);
+//        }
+//        Button localButton = this.mBtnNo;
+//        if (this.visiable) {}
+//        for (int i = 0;; i = 8)
+//        {
+//            localButton.setVisibility(i);
+//            if (!TextUtils.isEmpty(this.tv_cus))
+//            {
+//                this.mBtnCus.setText(this.tv_cus);
+//                this.mBtnCus.setVisibility(View.VISIBLE);
+//            }
+//            return;
+//        }
+    }
+
+    protected void onCreate(Bundle paramBundle)
+    {
+        super.onCreate(paramBundle);
+        setContentView(R.layout.custom_geo_black_dialog);
+        setCanceledOnTouchOutside(false);
+        Window w = getWindow();
+//        int width = 850;
+//        int height = 600;
+//        w.setLayout(width,height);
+        w.setGravity(17);
+        WindowManager.LayoutParams localLayoutParams = w.getAttributes();
+
+        localLayoutParams.height = WindowManager.LayoutParams.MATCH_PARENT;
+        localLayoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
+
+        w.setWindowAnimations(R.style.AnimationDialog);
+        w.setAttributes(localLayoutParams);
+
+        //initView();
+        refreshView();
+        initEvent();
+    }
+
+
+    public CustomBlackBgDialog setOnClickBottomListener(OnClickBottomListener paramOnClickBottomListener)
+    {
+        this.onClickBottomListener = paramOnClickBottomListener;
+        return this;
+    }
+
+
+    public static abstract interface OnClickBottomListener
+    {
+        public abstract void onBtnCloseClick();
+    }
+}

+ 166 - 0
app/src/main/java/com/jld/vod/view/widget/CustomGEOAdDialog.java

@@ -0,0 +1,166 @@
+package com.jld.vod.view.widget;
+
+import android.annotation.SuppressLint;
+import android.app.Dialog;
+import android.content.Context;
+import android.os.Bundle;
+import android.os.CountDownTimer;
+import android.view.View;
+import android.view.Window;
+import android.view.WindowManager;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import com.jld.vod.R;
+import com.jld.vod.config.Config;
+import com.jld.vod.model.bean.Datas;
+import com.jld.vod.model.bean.PositionAdvertBean;
+import com.youth.banner.Banner;
+import com.youth.banner.BannerConfig;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class CustomGEOAdDialog
+        extends Dialog
+{
+
+    //private ImageView mCloseImg;
+    private TextView auto_ms_text;
+    private Banner mBanner;
+    private List<String> list = new ArrayList<>();
+    private Context mContext;
+    public OnClickBottomListener onClickBottomListener;
+
+
+    public CustomGEOAdDialog(Context paramContext)
+    {
+        super(paramContext, R.style.MyDialog);
+        this.mContext = paramContext;
+
+
+    }
+
+    @Override
+    public void dismiss() {
+        super.dismiss();
+    }
+
+    private void initEvent()
+    {
+
+    }
+
+    private void initView()
+    {
+
+        this.auto_ms_text = findViewById(R.id.auto_ms_text);
+
+        //轮播
+        this.mBanner = (Banner)findViewById(R.id.geo_banner);
+        if (list != null)
+        {
+            //设置图片加载器
+            mBanner.setImageLoader(new GlideImageLoader());
+            //设置图片集合
+            mBanner.setImages(list);
+            //banner设置方法全部调用完毕时最后调用
+            mBanner.setBannerStyle(BannerConfig.CIRCLE_INDICATOR);
+            mBanner.setDelayTime(3000);
+            mBanner.start();
+        }
+    }
+
+    @Override
+    public void show() {
+
+        /** 倒计时30秒,一次1秒 */
+        CountDownTimer timer = new CountDownTimer(30*1000, 1000) {
+            @Override
+            public void onTick(long millisUntilFinished) {
+                // TODO Auto-generated method stub
+                auto_ms_text.setText(millisUntilFinished/1000+"");
+            }
+
+            @Override
+            public void onFinish() {
+                auto_ms_text.setText("0");
+                dismiss();
+            }
+        }.start();
+        super.show();
+    }
+
+    /**
+     * 设置数据
+     * @param positionAdvert
+     */
+    public void setDataList(List<Datas> positionAdvert)
+    {
+        list.clear();
+        for (int i = 0;i<positionAdvert.size();i++)
+        {
+            list.add(Config.ApiBaseUrl + "/synchronization/previewImg?imgUrl=" + positionAdvert.get(i).getFilePath());
+        }
+    }
+
+    @SuppressLint("WrongConstant")
+    private void refreshView()
+    {
+
+//        if (!TextUtils.isEmpty(this.tv_ok)) {
+//            this.mBtnOk.setText(this.tv_ok);
+//        }
+//        if (!TextUtils.isEmpty(this.tv_no)) {
+//            this.mBtnNo.setText(this.tv_no);
+//        }
+//        Button localButton = this.mBtnNo;
+//        if (this.visiable) {}
+//        for (int i = 0;; i = 8)
+//        {
+//            localButton.setVisibility(i);
+//            if (!TextUtils.isEmpty(this.tv_cus))
+//            {
+//                this.mBtnCus.setText(this.tv_cus);
+//                this.mBtnCus.setVisibility(View.VISIBLE);
+//            }
+//            return;
+//        }
+    }
+
+    protected void onCreate(Bundle paramBundle)
+    {
+        super.onCreate(paramBundle);
+        setContentView(R.layout.custom_geo_ad_dialog);
+        setCanceledOnTouchOutside(false);
+        Window w = getWindow();
+//        int width = 850;
+//        int height = 600;
+//        w.setLayout(width,height);
+        w.setGravity(17);
+        WindowManager.LayoutParams localLayoutParams = w.getAttributes();
+
+        localLayoutParams.height = WindowManager.LayoutParams.MATCH_PARENT;
+        localLayoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
+
+        w.setWindowAnimations(R.style.AnimationDialog);
+        w.setAttributes(localLayoutParams);
+
+        initView();
+        refreshView();
+        initEvent();
+    }
+
+
+    public CustomGEOAdDialog setOnClickBottomListener(OnClickBottomListener paramOnClickBottomListener)
+    {
+        this.onClickBottomListener = paramOnClickBottomListener;
+        return this;
+    }
+
+
+    public static abstract interface OnClickBottomListener
+    {
+        public abstract void onBtnCloseClick();
+    }
+}

+ 2 - 2
app/src/main/java/com/jld/vod/view/widget/CustomProgressDialog.kt

@@ -19,8 +19,8 @@ class CustomProgressDialog : ProgressDialog {
     override fun onCreate(savedInstanceState: Bundle?) {
         super.onCreate(savedInstanceState)
 
-        setCancelable(false)
-        setCanceledOnTouchOutside(false)
+//        setCancelable(false)
+//        setCanceledOnTouchOutside(false)
 
         setContentView(R.layout.load_dialog)
         val params = window!!.attributes

+ 163 - 0
app/src/main/java/com/jld/vod/view/widget/CustomScreenAdDialog.java

@@ -0,0 +1,163 @@
+package com.jld.vod.view.widget;
+
+import android.annotation.SuppressLint;
+import android.app.Dialog;
+import android.content.Context;
+import android.os.Bundle;
+import android.os.CountDownTimer;
+import android.view.Window;
+import android.view.WindowManager;
+import android.widget.TextView;
+
+import com.jld.vod.R;
+import com.jld.vod.config.Config;
+import com.jld.vod.model.bean.Datas;
+import com.youth.banner.Banner;
+import com.youth.banner.BannerConfig;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class CustomScreenAdDialog
+        extends Dialog
+{
+
+    //private ImageView mCloseImg;
+    private TextView auto_ms_text;
+    private Banner mBanner;
+    private List<String> list = new ArrayList<>();
+    private Context mContext;
+    public OnClickBottomListener onClickBottomListener;
+
+
+    public CustomScreenAdDialog(Context paramContext)
+    {
+        super(paramContext, R.style.MyDialog);
+        this.mContext = paramContext;
+
+
+    }
+
+    @Override
+    public void dismiss() {
+        super.dismiss();
+    }
+
+    private void initEvent()
+    {
+
+    }
+
+    private void initView()
+    {
+
+  //      this.auto_ms_text = findViewById(R.id.auto_ms_text);
+
+        //轮播
+        this.mBanner = (Banner)findViewById(R.id.geo_banner);
+        if (list != null)
+        {
+            //设置图片加载器
+            mBanner.setImageLoader(new GlideImageLoader());
+            //设置图片集合
+            mBanner.setImages(list);
+            //banner设置方法全部调用完毕时最后调用
+            mBanner.setBannerStyle(BannerConfig.CIRCLE_INDICATOR);
+            mBanner.setDelayTime(3000);
+            mBanner.start();
+        }
+    }
+
+    @Override
+    public void show() {
+//
+//        /** 倒计时30秒,一次1秒 */
+//        CountDownTimer timer = new CountDownTimer(30*1000, 1000) {
+//            @Override
+//            public void onTick(long millisUntilFinished) {
+//                // TODO Auto-generated method stub
+//                auto_ms_text.setText(millisUntilFinished/1000+"");
+//            }
+//
+//            @Override
+//            public void onFinish() {
+//                auto_ms_text.setText("0");
+//                dismiss();
+//            }
+//        }.start();
+        super.show();
+    }
+
+    /**
+     * 设置数据
+     * @param positionAdvert
+     */
+    public void setDataList(List<Datas> positionAdvert)
+    {
+        list.clear();
+        for (int i = 0;i<positionAdvert.size();i++)
+        {
+            list.add(Config.ApiBaseUrl + "/synchronization/previewImg?imgUrl=" + positionAdvert.get(i).getFilePath());
+        }
+    }
+
+    @SuppressLint("WrongConstant")
+    private void refreshView()
+    {
+
+//        if (!TextUtils.isEmpty(this.tv_ok)) {
+//            this.mBtnOk.setText(this.tv_ok);
+//        }
+//        if (!TextUtils.isEmpty(this.tv_no)) {
+//            this.mBtnNo.setText(this.tv_no);
+//        }
+//        Button localButton = this.mBtnNo;
+//        if (this.visiable) {}
+//        for (int i = 0;; i = 8)
+//        {
+//            localButton.setVisibility(i);
+//            if (!TextUtils.isEmpty(this.tv_cus))
+//            {
+//                this.mBtnCus.setText(this.tv_cus);
+//                this.mBtnCus.setVisibility(View.VISIBLE);
+//            }
+//            return;
+//        }
+    }
+
+    protected void onCreate(Bundle paramBundle)
+    {
+        super.onCreate(paramBundle);
+        setContentView(R.layout.custom_screen_ad_dialog);
+        setCanceledOnTouchOutside(false);
+        Window w = getWindow();
+//        int width = 850;
+//        int height = 600;
+//        w.setLayout(width,height);
+        w.setGravity(17);
+        WindowManager.LayoutParams localLayoutParams = w.getAttributes();
+
+        localLayoutParams.height = WindowManager.LayoutParams.MATCH_PARENT;
+        localLayoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
+
+        w.setWindowAnimations(R.style.AnimationDialog);
+        w.setAttributes(localLayoutParams);
+
+        initView();
+        refreshView();
+        initEvent();
+    }
+
+
+    public CustomScreenAdDialog setOnClickBottomListener(OnClickBottomListener paramOnClickBottomListener)
+    {
+        this.onClickBottomListener = paramOnClickBottomListener;
+        return this;
+    }
+
+
+    public static abstract interface OnClickBottomListener
+    {
+        public abstract void onBtnCloseClick();
+    }
+}

+ 23 - 1
app/src/main/java/com/jld/vod/viewmodel/MainViewModel.kt

@@ -25,6 +25,8 @@ class MainViewModel (app: Application)  : AndroidViewModel(app)  {
     val modelAllLiveData: MutableLiveData<BaseBean<List<ModelAllBean>>> = MutableLiveData()
     val findAllModularImgLiveData: MutableLiveData<BaseBean<findAllModularImgBean>> = MutableLiveData()
     val findAllModularRotateImgBeanLiveData: MutableLiveData<BaseBean<List<AllModularRotateImgBean>>> = MutableLiveData()
+    val findPositionAdvertLiveData: MutableLiveData<BaseBean<List<PositionAdvertBean>>> = MutableLiveData()
+
     val carinfoLiveData: MutableLiveData<List<CarInfoBean>> = MutableLiveData()
     val ByrtNamesLiveData: MutableLiveData<List<ModelAllBean>> = MutableLiveData()
     val LanguageLiveData: MutableLiveData<List<LanguageBean>> = MutableLiveData()
@@ -112,7 +114,27 @@ class MainViewModel (app: Application)  : AndroidViewModel(app)  {
         )
         return findAllModularRotateImgBeanLiveData
     }
-
+    /**
+     * 获取固定位置广告
+     */
+    fun findPositionAdvert(): MutableLiveData<BaseBean<List<PositionAdvertBean>>> {
+        findPositionAdvertLiveData.postValue(BaseBean.loading(null))
+        RetrofitUtils.findPositionAdvert(
+                { t ->
+                    when (t.code) {
+                        20000 ->{
+                            findPositionAdvertLiveData.postValue(BaseBean.success(t.data))
+                        }
+                        else -> findPositionAdvertLiveData.postValue(BaseBean.error(t.message, t.data))
+                    }
+                },
+                { ex ->
+                    ex.printStackTrace()
+                    findAllModularRotateImgBeanLiveData.postValue(BaseBean.error(ex.message!!, null))
+                }
+        )
+        return findPositionAdvertLiveData
+    }
     /**
      * 获取车辆信息
      */

+ 20 - 0
app/src/main/java/com/jld/vod/viewmodel/SplashViewModel.kt

@@ -38,6 +38,8 @@ class SplashViewModel(app: Application) : AndroidViewModel(app) {
     val updateGameInstallStateliveData: MutableLiveData<String> = MutableLiveData()
     val findHomePageImgliveData: MutableLiveData<BaseBean<HomePageImgBean>> = MutableLiveData()
     val NuInstallGameLiveData: MutableLiveData<BaseBean<List<NuInstallGameBean>>> = MutableLiveData()
+    val updateUserLiveData: MutableLiveData<Boolean> = MutableLiveData()
+
     /**
      * 获取所有语言信息
      */
@@ -350,4 +352,22 @@ class SplashViewModel(app: Application) : AndroidViewModel(app) {
         )
         return NuInstallGameLiveData
     }
+    /**
+     * 绑定用户
+     */
+    fun updateUser(userId:String): MutableLiveData<Boolean> {
+        RetrofitUtils.updateUser(userId,
+                { t ->
+                    when (t.code) {
+                        20000 -> updateUserLiveData.postValue(true)
+                        else -> updateUserLiveData.postValue(false)
+                    }
+                },
+                { ex ->
+                    ex.printStackTrace()
+                    updateUserLiveData.postValue(false)
+                }
+        )
+        return updateUserLiveData
+    }
 }

+ 5 - 0
app/src/main/res/anim/dialog_scale_action.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<set
+  xmlns:android="http://schemas.android.com/apk/res/android">
+    <scale android:interpolator="@android:anim/linear_interpolator" android:duration="0" android:pivotX="25.0%" android:pivotY="25.0%" android:fillAfter="false" android:fromXScale="1.0" android:toXScale="1.0" android:fromYScale="1.0" android:toYScale="1.0" />
+</set>

+ 32 - 0
app/src/main/res/layout/activity_order.xml

@@ -0,0 +1,32 @@
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:orientation="horizontal">
+    <RelativeLayout
+        android:alpha="70"
+        android:layout_width="880dp"
+        android:layout_height="576dp"
+        android:background="@mipmap/bg_masking"
+        android:layout_marginLeft="50dp"
+        android:layout_marginBottom="20dp">
+
+        <ImageView
+            android:id="@+id/iv_order"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:src="@mipmap/order_icon"
+            android:layout_centerInParent="true"
+            />
+        <TextView
+            android:layout_centerInParent="true"
+            android:layout_below="@+id/iv_order"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:textColor="@color/white"
+            android:textSize="24sp"
+            android:layout_marginTop="10dp"
+            android:text="点餐"
+            />
+    </RelativeLayout>
+</RelativeLayout>

+ 32 - 2
app/src/main/res/layout/activity_play_video.xml

@@ -1,9 +1,39 @@
 <?xml version="1.0" encoding="utf-8"?>
-<LinearLayout
+<RelativeLayout
     xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
     android:layout_height="match_parent">
     <com.jld.vod.view.widget.MyJzvdStd
         android:id="@+id/jz_video"
         android:layout_width="match_parent"
         android:layout_height="match_parent" />
-</LinearLayout>
+    <FrameLayout
+        android:id="@+id/fl_bg_ad"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent">
+        <RelativeLayout
+            android:layout_width="match_parent"
+            android:layout_height="match_parent">
+            <VideoView
+                android:layout_width="match_parent"
+                android:layout_height="match_parent"
+                android:id="@+id/vd_ad"
+                />
+            <TextView
+                android:layout_alignParentTop="true"
+                android:layout_alignParentRight="true"
+                android:id="@+id/auto_ms_text"
+                android:textColor="@color/black"
+                android:textSize="16sp"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_margin="20dp"
+                android:paddingTop="5dp"
+                android:paddingBottom="5dp"
+                android:paddingLeft="10dp"
+                android:paddingRight="10dp"
+                android:background="@color/white"
+                />
+        </RelativeLayout>
+    </FrameLayout>
+
+</RelativeLayout>

+ 36 - 0
app/src/main/res/layout/custom_ad_dialog.xml

@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:background="@color/white"
+    android:orientation="vertical">
+    <com.youth.banner.Banner
+        android:id="@+id/about_banner"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent" />
+    <ImageView
+        android:layout_alignParentTop="true"
+        android:layout_alignParentRight="true"
+        android:id="@+id/iv_close_ads"
+        android:src="@mipmap/close_ads_icon"
+        android:layout_width="50px"
+        android:layout_height="50px"
+        android:layout_margin="20dp"
+        />
+    <TextView
+        android:layout_alignParentBottom="true"
+        android:layout_alignParentRight="true"
+        android:id="@+id/html_text"
+        android:textColor="@color/black"
+        android:text="Ads"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_margin="20dp"
+        android:paddingTop="5dp"
+        android:paddingBottom="5dp"
+        android:paddingLeft="10dp"
+        android:paddingRight="10dp"
+        android:background="@color/white"
+        />
+
+</RelativeLayout>

+ 28 - 0
app/src/main/res/layout/custom_geo_ad_dialog.xml

@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:background="@color/white"
+    android:orientation="vertical">
+    <com.youth.banner.Banner
+        android:id="@+id/geo_banner"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent" />
+
+    <TextView
+        android:layout_alignParentTop="true"
+        android:layout_alignParentRight="true"
+        android:id="@+id/auto_ms_text"
+        android:textColor="@color/black"
+        android:textSize="16sp"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_margin="20dp"
+        android:paddingTop="5dp"
+        android:paddingBottom="5dp"
+        android:paddingLeft="10dp"
+        android:paddingRight="10dp"
+        android:background="@color/white"
+        />
+
+</RelativeLayout>

+ 7 - 0
app/src/main/res/layout/custom_geo_black_dialog.xml

@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:background="@color/black"
+    android:orientation="vertical">
+</RelativeLayout>

+ 11 - 0
app/src/main/res/layout/custom_screen_ad_dialog.xml

@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:background="@color/white"
+    android:orientation="vertical">
+    <com.youth.banner.Banner
+        android:id="@+id/geo_banner"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent" />
+</RelativeLayout>

+ 32 - 0
app/src/main/res/layout/fragment_order.xml

@@ -0,0 +1,32 @@
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:orientation="horizontal">
+    <RelativeLayout
+        android:alpha="70"
+        android:layout_width="880dp"
+        android:layout_height="576dp"
+        android:background="@mipmap/bg_masking"
+        android:layout_marginLeft="50dp"
+        android:layout_marginBottom="20dp">
+
+        <ImageView
+            android:id="@+id/iv_order"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:src="@mipmap/order_icon"
+            android:layout_centerInParent="true"
+            />
+        <TextView
+            android:layout_centerInParent="true"
+            android:layout_below="@+id/iv_order"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:textColor="@color/white"
+            android:textSize="24sp"
+            android:layout_marginTop="10dp"
+            android:text="点餐"
+            />
+    </RelativeLayout>
+</RelativeLayout>

BIN
app/src/main/res/mipmap-hdpi/close_ads_icon.png


BIN
app/src/main/res/mipmap-hdpi/order_icon.png


+ 4 - 0
app/src/main/res/values-zh-rCN/strings.xml

@@ -64,6 +64,10 @@
     <string name="download_map">下载地图</string>
     <string name="map_loaded_successfully">地图加载成功</string>
     <string name="check_for_version_updates">"检测版本更新 "</string>
+    <!-- 绑定用户成功  -->
+    <string name="User_binding_succeeded">绑定用户成功</string>
+    <!-- 绑定用户失败  -->
+    <string name="Failure_to_Bind_a_user">绑定用户失败</string>
     <string name="check_whether_the_vehicle_is_bound">"检测车辆是否绑定 "</string>
     <string name="get_no_app_installed">"获取未安装的游戏应用 "</string>
     <string name="data_loading_successfully">数据加载完成</string>

+ 4 - 0
app/src/main/res/values/strings.xml

@@ -109,6 +109,10 @@
     <string name="check_for_version_updates">Check for version updates</string>
 <!-- 检测车辆是否绑定  -->
     <string name="check_whether_the_vehicle_is_bound">check_whether_the_vehicle_is_bound</string>
+    <!-- 绑定用户成功  -->
+    <string name="User_binding_succeeded">User binding succeeded</string>
+    <!-- 绑定用户失败  -->
+    <string name="Failure_to_Bind_a_user">Failure to Bind a user</string>
 <!-- 获取未安装的游戏应用-->
     <string name="get_no_app_installed">Get game apps that are not installed</string>
 

+ 15 - 0
app/src/main/res/values/styles.xml

@@ -24,4 +24,19 @@
         <item name="android:backgroundDimEnabled">false</item>
         <item name="android:windowBackground">@android:color/transparent</item>
     </style>
+
+
+    <style name="MyDialog" parent="@android:style/Theme.Dialog">
+        <item name="android:windowBackground">@android:color/transparent</item>
+        <item name="android:windowFrame">@null</item>
+        <item name="android:windowNoTitle">true</item>
+        <item name="android:windowIsFloating">true</item>
+        <item name="android:backgroundDimEnabled">false</item>
+    </style>
+
+    <style name="AnimationDialog">
+        <item name="android:windowEnterAnimation">@anim/dialog_scale_action</item>
+        <item name="android:windowExitAnimation">@anim/dialog_scale_action</item>
+    </style>
+
 </resources>

+ 8 - 0
app/src/main/res/xml/root_preferences.xml

@@ -11,6 +11,14 @@
             app:key="seat_settings"
             app:title="SeatNum Settings"
             />
+        <SwitchPreference
+            app:key="ads_control"
+            app:title="Ads Control"
+            />
+        <SwitchPreference
+            app:key="screen_control"
+            app:title="Screen Control"
+            />
 <!--        <EditTextPreference-->
 <!--            app:key="Password"-->
 <!--            app:title="Password"-->