Skip to content

Commit

Permalink
show current version
Browse files Browse the repository at this point in the history
  • Loading branch information
lizongying committed Dec 5, 2023
1 parent 03a6efe commit dfe446e
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,5 @@ jobs:
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ steps.sign_app.outputs.signedReleaseFile }}
asset_name: my_tv.apk
asset_name: my-tv.apk
asset_content_type: application/vnd.android.package-archive
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# 我的电视

安卓电视直播软件,内置直播源

## 使用

下载安装[releases](https://github.com/lizongying/my-tv/releases)

## 其他

小米电视可以使用小米电视助手进行安装

如电视可以启用ADB,也可以通过ADB进行安装:

```shell
adb install my-tv.apk
```

## 赞赏

![image](./screenshots/appreciate.jpeg)
22 changes: 22 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ android {
targetSdk 33
versionCode 11
versionName "1.1"
versionCode getVersionCode()
versionName getVersionName()
}

buildTypes {
Expand All @@ -32,6 +34,26 @@ android {
}
}

static def getVersionCode() {
try {
def process = 'git rev-list --count HEAD'.execute()
process.waitFor()
return process.text.toInteger()
} catch (ignored) {
return 0
}
}

static def getVersionName() {
try {
def process = 'git describe --tags --always'.execute()
process.waitFor()
return process.text.trim()
} catch (ignored) {
return "1.0.0"
}
}

dependencies {

implementation 'androidx.core:core-ktx:1.11.0-beta02'
Expand Down
4 changes: 0 additions & 4 deletions app/src/main/java/com/lizongying/mytv/CardPresenter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ import kotlinx.coroutines.withContext
class CardPresenter(private val lifecycleScope: LifecycleCoroutineScope) : Presenter() {

override fun onCreateViewHolder(parent: ViewGroup): ViewHolder {
Log.d(TAG, "onCreateViewHolder")

val cardView = object :
ImageCardView(ContextThemeWrapper(parent.context, R.style.CustomImageCardTheme)) {
override fun setSelected(selected: Boolean) {
Expand All @@ -40,7 +38,6 @@ class CardPresenter(private val lifecycleScope: LifecycleCoroutineScope) : Prese
val tv = item as TV
val cardView = viewHolder.view as ImageCardView

Log.d(TAG, "onBindViewHolder")
if (tv.videoUrl != null) {
cardView.titleText = tv.title
cardView.setMainImageDimensions(CARD_WIDTH, CARD_HEIGHT)
Expand All @@ -57,7 +54,6 @@ class CardPresenter(private val lifecycleScope: LifecycleCoroutineScope) : Prese
}

override fun onUnbindViewHolder(viewHolder: ViewHolder) {
Log.d(TAG, "onUnbindViewHolder")
val cardView = viewHolder.view as ImageCardView
// Remove references to images so that the garbage collector can free up memory
cardView.badgeImage = null
Expand Down
16 changes: 13 additions & 3 deletions app/src/main/java/com/lizongying/mytv/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import android.widget.Toast
import androidx.core.content.ContextCompat
import androidx.fragment.app.FragmentActivity


/**
* Loads [MainFragment].
*/
Expand Down Expand Up @@ -64,7 +65,7 @@ class MainActivity : FragmentActivity() {
mainFragment.focus()
}

fun fragmentIsHidden(): Boolean {
fun mainFragmentIsHidden(): Boolean {
return mainFragment.isHidden
}

Expand All @@ -79,12 +80,16 @@ class MainActivity : FragmentActivity() {
override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean {
when (keyCode) {
KeyEvent.KEYCODE_BACK -> {
if (!mainFragmentIsHidden()) {
hideMainFragment()
return true
}

if (doubleBackToExitPressedOnce) {
super.onBackPressed()
return true
}

hideMainFragment()
this.doubleBackToExitPressedOnce = true
Toast.makeText(this, "再按一次退出", Toast.LENGTH_SHORT).show()

Expand Down Expand Up @@ -112,9 +117,14 @@ class MainActivity : FragmentActivity() {
layoutParams.gravity = Gravity.BOTTOM
imageView.layoutParams = layoutParams


val packageInfo = packageManager.getPackageInfo(packageName, 0)

val versionName = packageInfo.versionName

val builder: AlertDialog.Builder = AlertDialog.Builder(this)
builder
.setTitle("https://github.com/lizongying/my-tv/releases")
.setTitle("当前版本: $versionName, 获取最新: https://github.com/lizongying/my-tv/releases/")
.setView(linearLayout)

val dialog: AlertDialog = builder.create()
Expand Down
1 change: 0 additions & 1 deletion app/src/main/java/com/lizongying/mytv/MainFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ class MainFragment : BrowseSupportFragment() {
) {
if (item is TV) {
Log.i(TAG, "Item: ${item.id}")

}
if (itemViewHolder == null) {
view?.post {
Expand Down
9 changes: 5 additions & 4 deletions app/src/main/java/com/lizongying/mytv/PlaybackControlGlue.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,31 @@ class PlaybackControlGlue(
}

KeyEvent.KEYCODE_DPAD_UP -> {
if ((context as? MainActivity)?.fragmentIsHidden() == true) {
if ((context as? MainActivity)?.mainFragmentIsHidden() == true) {
(context as? MainActivity)?.prev()
}
}

KeyEvent.KEYCODE_DPAD_DOWN -> {
if ((context as? MainActivity)?.fragmentIsHidden() == true) {
if ((context as? MainActivity)?.mainFragmentIsHidden() == true) {
(context as? MainActivity)?.next()
}
}

KeyEvent.KEYCODE_DPAD_LEFT -> {
if ((context as? MainActivity)?.fragmentIsHidden() == true) {
if ((context as? MainActivity)?.mainFragmentIsHidden() == true) {
(context as? MainActivity)?.prev()
}
}

KeyEvent.KEYCODE_DPAD_RIGHT -> {
if ((context as? MainActivity)?.fragmentIsHidden() == true) {
if ((context as? MainActivity)?.mainFragmentIsHidden() == true) {
(context as? MainActivity)?.next()
}
}
}
}

return super.onKey(v, keyCode, event)
}

Expand Down
1 change: 0 additions & 1 deletion app/src/main/java/com/lizongying/mytv/PlaybackFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ class PlaybackFragment : VideoSupportFragment() {
try {
playerAdapter?.setDataSource(Uri.parse(tv.videoUrl))
} catch (e: IOException) {
// Handle the exception
return
}
hideControlsOverlay(false)
Expand Down
Binary file added screenshots/appreciate.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit dfe446e

Please sign in to comment.