Skip to content

Commit

Permalink
add reset
Browse files Browse the repository at this point in the history
  • Loading branch information
lizongying committed May 21, 2024
1 parent c1143af commit ef17427
Show file tree
Hide file tree
Showing 18 changed files with 81 additions and 58 deletions.
4 changes: 4 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## 更新日志

### v2.0.5

* 设置页增加恢复默认按钮,目前只用于同步系统时间

### v2.0.4

* 修复不能播放的问题
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />

<application
android:name=".MyTvApplication"
android:name=".MyTVApplication"
android:allowBackup="true"
android:banner="@drawable/banner"
android:icon="@drawable/logo"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/lizongying/mytv/CardAdapter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class CardAdapter(
val inflater = LayoutInflater.from(parent.context)
val binding = CardBinding.inflate(inflater, parent, false)

val application = mainFragment.requireActivity().applicationContext as MyTvApplication
val application = mainFragment.requireActivity().applicationContext as MyTVApplication

binding.card.layoutParams.width = application.px2Px(binding.card.layoutParams.width)
binding.card.layoutParams.height = application.px2Px(binding.card.layoutParams.height)
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/lizongying/mytv/ChannelFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class ChannelFragment : Fragment() {
_binding = ChannelBinding.inflate(inflater, container, false)
_binding!!.root.visibility = View.GONE

val application = requireActivity().applicationContext as MyTvApplication
val application = requireActivity().applicationContext as MyTVApplication

binding.channel.layoutParams.width = application.px2Px(binding.channel.layoutParams.width)
binding.channel.layoutParams.height = application.px2Px(binding.channel.layoutParams.height)
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/lizongying/mytv/ErrorFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class ErrorFragment : Fragment() {
): View {
_binding = ErrorBinding.inflate(inflater, container, false)

val application = requireActivity().applicationContext as MyTvApplication
val application = requireActivity().applicationContext as MyTVApplication

binding.logo.layoutParams.width = application.px2Px(binding.logo.layoutParams.width)
binding.logo.layoutParams.height = application.px2Px(binding.logo.layoutParams.height)
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/lizongying/mytv/InfoFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class InfoFragment : Fragment() {
): View {
_binding = InfoBinding.inflate(inflater, container, false)

val application = requireActivity().applicationContext as MyTvApplication
val application = requireActivity().applicationContext as MyTVApplication

binding.info.layoutParams.width = application.px2Px(binding.info.layoutParams.width)
binding.info.layoutParams.height = application.px2Px(binding.info.layoutParams.height)
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/com/lizongying/mytv/ItemDecoration.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import androidx.recyclerview.widget.RecyclerView

class ItemDecoration(context: Context) : RecyclerView.ItemDecoration() {

private var application: MyTvApplication
private var application: MyTVApplication

init {
application = context.applicationContext as MyTvApplication
application = context.applicationContext as MyTVApplication
}

override fun getItemOffsets(
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/lizongying/mytv/LoadingFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class LoadingFragment : Fragment() {
): View {
_binding = LoadingBinding.inflate(inflater, container, false)

val application = requireActivity().applicationContext as MyTvApplication
val application = requireActivity().applicationContext as MyTVApplication

binding.bar.layoutParams.width = application.px2Px(binding.bar.layoutParams.width)
binding.bar.layoutParams.height = application.px2Px(binding.bar.layoutParams.height)
Expand Down
21 changes: 17 additions & 4 deletions app/src/main/java/com/lizongying/mytv/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import android.util.Log
import android.view.GestureDetector
import android.view.KeyEvent
import android.view.MotionEvent
import android.view.View
import android.view.View.SYSTEM_UI_FLAG_FULLSCREEN
import android.view.View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
import android.view.View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
Expand Down Expand Up @@ -50,7 +51,7 @@ class MainActivity : FragmentActivity(), Request.RequestListener, OnSharedPrefer
Utils.setRequestListener(this)
}

private fun syncTime() {
fun syncTime() {
lifecycleScope.launch(Dispatchers.IO) {
val utilsJob = async(start = CoroutineStart.LAZY) { Utils.init() }
utilsJob.start()
Expand All @@ -59,9 +60,6 @@ class MainActivity : FragmentActivity(), Request.RequestListener, OnSharedPrefer

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)

Request.setRequestListener(this)

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
val lp = window.attributes
Expand All @@ -70,6 +68,17 @@ class MainActivity : FragmentActivity(), Request.RequestListener, OnSharedPrefer
window.setAttributes(lp)
}


window.decorView.apply {
systemUiVisibility =
SYSTEM_UI_FLAG_FULLSCREEN or
SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or
View.SYSTEM_UI_FLAG_LAYOUT_STABLE or
SYSTEM_UI_FLAG_HIDE_NAVIGATION or
SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or
View.SYSTEM_UI_FLAG_IMMERSIVE
}

window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN)
window.decorView.systemUiVisibility =
Expand All @@ -82,6 +91,10 @@ class MainActivity : FragmentActivity(), Request.RequestListener, OnSharedPrefer
// window.navigationBarColor = Color.TRANSPARENT
// }

setContentView(R.layout.activity_main)

Request.setRequestListener(this)

if (savedInstanceState == null) {
val transaction = supportFragmentManager.beginTransaction()
.add(R.id.main_browse_fragment, playerFragment)
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/com/lizongying/mytv/MainFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class MainFragment : Fragment(), CardAdapter.ItemListener {

private var lastVideoUrl = ""

private lateinit var application: MyTvApplication
private lateinit var application: MyTVApplication

private lateinit var gestureDetector: GestureDetector

Expand All @@ -53,7 +53,7 @@ class MainFragment : Fragment(), CardAdapter.ItemListener {
val context = requireContext()
_binding = MenuBinding.inflate(inflater, container, false)

application = requireActivity().applicationContext as MyTvApplication
application = requireActivity().applicationContext as MyTVApplication

binding.menu.layoutParams.width = application.shouldWidthPx()
binding.menu.layoutParams.height = application.shouldHeightPx()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import android.view.WindowManager
import androidx.multidex.MultiDex


class MyTvApplication : Application() {
class MyTVApplication : Application() {
private lateinit var displayMetrics: DisplayMetrics
private lateinit var realDisplayMetrics: DisplayMetrics

Expand Down
64 changes: 31 additions & 33 deletions app/src/main/java/com/lizongying/mytv/SettingFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import androidx.core.content.ContextCompat
import androidx.core.view.marginEnd
import androidx.core.view.marginTop
import androidx.fragment.app.DialogFragment
import com.lizongying.mytv.api.YSP
import com.lizongying.mytv.databinding.SettingBinding


Expand Down Expand Up @@ -97,7 +98,14 @@ class SettingFragment : DialogFragment() {
requestInstallPermissions()
}

val application = requireActivity().applicationContext as MyTvApplication
binding.clear.setOnClickListener {
(requireActivity() as MainActivity).syncTime()
SP.guid = ""
YSP.getGuid()
}

val application = requireActivity().applicationContext as MyTVApplication
val textSize = application.px2PxFont(binding.switchChannelReversal.textSize)

binding.content.layoutParams.width =
application.px2Px(binding.content.layoutParams.width)
Expand All @@ -108,51 +116,41 @@ class SettingFragment : DialogFragment() {
application.px2Px(binding.content.paddingBottom)
)
binding.name.textSize = application.px2PxFont(binding.name.textSize)
binding.version.textSize = application.px2PxFont(binding.version.textSize)
binding.version.textSize = textSize
val layoutParamsVersion = binding.version.layoutParams as ViewGroup.MarginLayoutParams
layoutParamsVersion.topMargin = application.px2Px(binding.version.marginTop)
binding.version.layoutParams = layoutParamsVersion

binding.checkVersion.textSize = application.px2PxFont(binding.checkVersion.textSize)
binding.checkVersion.textSize = textSize
val layoutParamsCheckVersion =
binding.checkVersion.layoutParams as ViewGroup.MarginLayoutParams
layoutParamsCheckVersion.marginEnd = application.px2Px(binding.checkVersion.marginEnd)
binding.checkVersion.layoutParams = layoutParamsCheckVersion

binding.versionName.textSize = application.px2PxFont(binding.versionName.textSize)
binding.versionName.textSize = textSize

binding.exit.textSize = application.px2PxFont(binding.exit.textSize)
binding.clear.textSize = textSize
binding.exit.textSize = textSize

binding.switchChannelReversal.textSize =
application.px2PxFont(binding.switchChannelReversal.textSize)
val layoutParamsChannelReversal =
val layoutParamsChannelSwitch =
binding.switchChannelReversal.layoutParams as ViewGroup.MarginLayoutParams
layoutParamsChannelReversal.topMargin =
layoutParamsChannelSwitch.topMargin =
application.px2Px(binding.switchChannelReversal.marginTop)
binding.switchChannelReversal.layoutParams = layoutParamsChannelReversal

binding.switchChannelNum.textSize = application.px2PxFont(binding.switchChannelNum.textSize)
val layoutParamsChannelNum =
binding.switchChannelNum.layoutParams as ViewGroup.MarginLayoutParams
layoutParamsChannelNum.topMargin = application.px2Px(binding.switchChannelNum.marginTop)
binding.switchChannelNum.layoutParams = layoutParamsChannelNum

binding.switchTime.textSize = application.px2PxFont(binding.switchTime.textSize)
val layoutParamsTime = binding.switchTime.layoutParams as ViewGroup.MarginLayoutParams
layoutParamsTime.topMargin = application.px2Px(binding.switchTime.marginTop)
binding.switchTime.layoutParams = layoutParamsTime

binding.switchBootStartup.textSize =
application.px2PxFont(binding.switchBootStartup.textSize)
val layoutParamsBootStartup =
binding.switchBootStartup.layoutParams as ViewGroup.MarginLayoutParams
layoutParamsBootStartup.topMargin = application.px2Px(binding.switchBootStartup.marginTop)
binding.switchBootStartup.layoutParams = layoutParamsBootStartup

binding.switchGrid.textSize = application.px2PxFont(binding.switchGrid.textSize)
val layoutParamsGrid = binding.switchGrid.layoutParams as ViewGroup.MarginLayoutParams
layoutParamsGrid.topMargin = application.px2Px(binding.switchGrid.marginTop)
binding.switchGrid.layoutParams = layoutParamsGrid

binding.switchChannelReversal.textSize = textSize
binding.switchChannelReversal.layoutParams = layoutParamsChannelSwitch

binding.switchChannelNum.textSize = textSize
binding.switchChannelNum.layoutParams = layoutParamsChannelSwitch

binding.switchTime.textSize = textSize
binding.switchTime.layoutParams = layoutParamsChannelSwitch

binding.switchBootStartup.textSize = textSize
binding.switchBootStartup.layoutParams = layoutParamsChannelSwitch

binding.switchGrid.textSize = textSize
binding.switchGrid.layoutParams = layoutParamsChannelSwitch

binding.appreciate.layoutParams.width =
application.px2Px(binding.appreciate.layoutParams.width)
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/lizongying/mytv/TimeFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class TimeFragment : Fragment() {
): View {
_binding = TimeBinding.inflate(inflater, container, false)

val application = requireActivity().applicationContext as MyTvApplication
val application = requireActivity().applicationContext as MyTVApplication

binding.time.layoutParams.width = application.px2Px(binding.time.layoutParams.width)
binding.time.layoutParams.height = application.px2Px(binding.time.layoutParams.height)
Expand Down
14 changes: 7 additions & 7 deletions app/src/main/java/com/lizongying/mytv/api/YSP.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.lizongying.mytv.api

import android.content.Context
import android.util.Log
import com.lizongying.mytv.SP
import com.lizongying.mytv.Utils.getDateTimestamp
import com.lizongying.mytv.models.TVViewModel
Expand Down Expand Up @@ -103,18 +102,18 @@ object YSP {
cKey =
encryptor.encrypt(cnlid, timeStr, appVer, guid, platform)

Log.i(TAG,"yspsdkinput ${"""{"cnlid":"$cnlid","livepid":"$livepid","stream":"$stream","guid":"$guid","cKey":"$cKey","adjust":$adjust,"sphttps":"$sphttps","platform":"$platform","cmd":"$cmd","encryptVer":"$encryptVer","dtype":"$dtype","devid":"$devid","otype":"$otype","appVer":"$appVer","app_version":"$appVersion","channel":"$channel","defn":"$defn"}"""}" )

yspsdkinput = md("adjust=$adjust&app_version=$appVersion&appVer=$appVer&channel=$channel&cKey=$cKey&cmd=$cmd&cnlid=$cnlid&defn=$defn&devid=$devid&dtype=$dtype&encryptVer=$encryptVer&guid=$guid&livepid=$livepid&otype=$otype&platform=$platform&sphttps=$sphttps&stream=$stream")
yspsdkinput =
md("adjust=$adjust&app_version=$appVersion&appVer=$appVer&channel=$channel&cKey=$cKey&cmd=$cmd&cnlid=$cnlid&defn=$defn&devid=$devid&dtype=$dtype&encryptVer=$encryptVer&guid=$guid&livepid=$livepid&otype=$otype&platform=$platform&sphttps=$sphttps&stream=$stream")

nseqId++

nrequest_id = "999999" + getRand() + getTimeStr()
nrequest_id = "999999" + getRand() + getTimeStr()

openapi_signature = md("yspappid:519748109;host:www.yangshipin.cn;protocol:https:;token:$token2;input:$yspsdkinput-$guid-$nseqId-$nrequest_id;")
openapi_signature =
md("yspappid:519748109;host:www.yangshipin.cn;protocol:https:;token:$token2;input:$yspsdkinput-$guid-$nseqId-$nrequest_id;")
}

fun md(str:String):String {
fun md(str: String): String {
val md = MessageDigest.getInstance("MD5")
md.update(str.toByteArray())
val digest = md.digest()
Expand Down Expand Up @@ -148,6 +147,7 @@ object YSP {
var guid = SP.guid
if (guid.length < 18) {
guid = generateGuid()
this.guid = guid
SP.guid = guid
}
return guid
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class TVViewModel(private var tv: TV) : ViewModel() {
private var itemPosition: Int = 0

var retryTimes = 0
var retryMaxTimes = 1
var retryMaxTimes = 8
var authYSPRetryTimes = 0
var authYSPRetryMaxTimes = 3
var tokenYSPRetryTimes = 0
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/res/layout/setting.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<Button
android:id="@+id/clear"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:text="@string/clear"
/>
<Button
android:id="@+id/exit"
android:layout_width="wrap_content"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
<string name="title_boot_startup">开机自启</string>
<string name="title_grid">频道列表采用网格样式</string>
<string name="title_time">显示时间</string>
<string name="clear">恢复默认</string>
<string name="exit">退出应用</string>
</resources>
2 changes: 1 addition & 1 deletion version.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"version_code": 33555456, "version_name": "v2.0.4"}
{"version_code": 33555712, "version_name": "v2.0.5"}

0 comments on commit ef17427

Please sign in to comment.