From 713f088ac188609273087a79312d60fb3bb37760 Mon Sep 17 00:00:00 2001 From: FongMi Date: Thu, 9 Nov 2023 01:29:02 +0800 Subject: [PATCH] Clean coe --- .gitignore | 2 +- app/build.gradle | 2 +- .../{25.json => 26.json} | 20 ++++--------------- .../java/com/fongmi/android/tv/bean/Site.java | 14 +------------ .../com/fongmi/android/tv/db/AppDatabase.java | 13 +++++++++++- .../com/fongmi/android/tv/player/ExoUtil.java | 4 ++-- .../com/fongmi/android/tv/player/Players.java | 1 + .../android/tv/ui/activity/LiveActivity.java | 8 ++++++++ .../tv/ui/custom/CustomKeyDownLive.java | 7 +++++-- .../res/layout/view_control_live_action.xml | 6 ++++++ build.gradle | 1 + .../ijk/media/player/ui/IjkVideoView.java | 2 +- settings.gradle | 1 + 13 files changed, 44 insertions(+), 37 deletions(-) rename app/schemas/com.fongmi.android.tv.db.AppDatabase/{25.json => 26.json} (95%) diff --git a/.gitignore b/.gitignore index 3ef1eaf8d..29a48243c 100644 --- a/.gitignore +++ b/.gitignore @@ -3,5 +3,5 @@ *build *.jks /local.properties -/media +/media* /Release \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index be599e83a..d98237208 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -86,13 +86,13 @@ dependencies { implementation project(':jianpian') implementation project(':forcetech') implementation project(':ijkplayer') + implementation project(':media3ext') pythonImplementation project(':pyramid') implementation project(':media-lib-database') implementation project(':media-lib-datasource') implementation project(':media-lib-datasource-okhttp') implementation project(':media-lib-datasource-rtmp') implementation project(':media-lib-decoder-av1') - implementation project(':media-lib-decoder-ffmpeg') implementation project(':media-lib-exoplayer') implementation project(':media-lib-exoplayer-dash') implementation project(':media-lib-exoplayer-hls') diff --git a/app/schemas/com.fongmi.android.tv.db.AppDatabase/25.json b/app/schemas/com.fongmi.android.tv.db.AppDatabase/26.json similarity index 95% rename from app/schemas/com.fongmi.android.tv.db.AppDatabase/25.json rename to app/schemas/com.fongmi.android.tv.db.AppDatabase/26.json index fe365ee6c..49984530b 100644 --- a/app/schemas/com.fongmi.android.tv.db.AppDatabase/25.json +++ b/app/schemas/com.fongmi.android.tv.db.AppDatabase/26.json @@ -1,8 +1,8 @@ { "formatVersion": 1, "database": { - "version": 25, - "identityHash": "aa43d70f082d5a861c294a307ca6ce6f", + "version": 26, + "identityHash": "67f0132775fe3d51407f4715ee568544", "entities": [ { "tableName": "Keep", @@ -62,7 +62,7 @@ }, { "tableName": "Site", - "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`key` TEXT NOT NULL, `name` TEXT, `searchable` INTEGER, `filterable` INTEGER, `changeable` INTEGER, `recordable` INTEGER, `activated` INTEGER NOT NULL, PRIMARY KEY(`key`))", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`key` TEXT NOT NULL, `name` TEXT, `searchable` INTEGER, `changeable` INTEGER, `recordable` INTEGER, PRIMARY KEY(`key`))", "fields": [ { "fieldPath": "key", @@ -82,12 +82,6 @@ "affinity": "INTEGER", "notNull": false }, - { - "fieldPath": "filterable", - "columnName": "filterable", - "affinity": "INTEGER", - "notNull": false - }, { "fieldPath": "changeable", "columnName": "changeable", @@ -99,12 +93,6 @@ "columnName": "recordable", "affinity": "INTEGER", "notNull": false - }, - { - "fieldPath": "activated", - "columnName": "activated", - "affinity": "INTEGER", - "notNull": true } ], "primaryKey": { @@ -444,7 +432,7 @@ "views": [], "setupQueries": [ "CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)", - "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'aa43d70f082d5a861c294a307ca6ce6f')" + "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '67f0132775fe3d51407f4715ee568544')" ] } } \ No newline at end of file diff --git a/app/src/main/java/com/fongmi/android/tv/bean/Site.java b/app/src/main/java/com/fongmi/android/tv/bean/Site.java index 5fb7616ee..657faced9 100644 --- a/app/src/main/java/com/fongmi/android/tv/bean/Site.java +++ b/app/src/main/java/com/fongmi/android/tv/bean/Site.java @@ -22,7 +22,7 @@ import java.util.List; import okhttp3.Headers; -@Entity(ignoredColumns = {"api", "ext", "jar", "type", "playUrl", "timeout", "playerType", "categories", "header", "style"}) +@Entity(ignoredColumns = {"api", "ext", "jar", "playUrl", "type", "timeout", "playerType", "categories", "header", "style", "activated"}) public class Site implements Parcelable { @NonNull @@ -48,8 +48,6 @@ public class Site implements Parcelable { private Integer playerType; @SerializedName("searchable") private Integer searchable; - @SerializedName("filterable") - private Integer filterable; @SerializedName("changeable") private Integer changeable; @SerializedName("recordable") @@ -151,14 +149,6 @@ public class Site implements Parcelable { this.searchable = searchable; } - public Integer getFilterable() { - return filterable == null ? 1 : filterable; - } - - public void setFilterable(Integer filterable) { - this.filterable = filterable; - } - public Integer getChangeable() { return changeable == null ? 1 : changeable; } @@ -280,7 +270,6 @@ public class Site implements Parcelable { dest.writeValue(this.timeout); dest.writeValue(this.playerType); dest.writeValue(this.searchable); - dest.writeValue(this.filterable); dest.writeValue(this.changeable); dest.writeValue(this.recordable); dest.writeStringList(this.categories); @@ -299,7 +288,6 @@ public class Site implements Parcelable { this.timeout = (Integer) in.readValue(Integer.class.getClassLoader()); this.playerType = (Integer) in.readValue(Integer.class.getClassLoader()); this.searchable = (Integer) in.readValue(Integer.class.getClassLoader()); - this.filterable = (Integer) in.readValue(Integer.class.getClassLoader()); this.changeable = (Integer) in.readValue(Integer.class.getClassLoader()); this.recordable = (Integer) in.readValue(Integer.class.getClassLoader()); this.categories = in.createStringArrayList(); diff --git a/app/src/main/java/com/fongmi/android/tv/db/AppDatabase.java b/app/src/main/java/com/fongmi/android/tv/db/AppDatabase.java index 5473be208..117342645 100644 --- a/app/src/main/java/com/fongmi/android/tv/db/AppDatabase.java +++ b/app/src/main/java/com/fongmi/android/tv/db/AppDatabase.java @@ -34,7 +34,7 @@ import java.util.Locale; @Database(entities = {Keep.class, Site.class, Track.class, Config.class, Device.class, History.class}, version = AppDatabase.VERSION) public abstract class AppDatabase extends RoomDatabase { - public static final int VERSION = 25; + public static final int VERSION = 26; public static final String NAME = "tv"; public static final String SYMBOL = "@@@"; @@ -99,6 +99,7 @@ public abstract class AppDatabase extends RoomDatabase { .addMigrations(MIGRATION_22_23) .addMigrations(MIGRATION_23_24) .addMigrations(MIGRATION_24_25) + .addMigrations(MIGRATION_25_26) .allowMainThreadQueries() .fallbackToDestructiveMigration() .build(); @@ -220,4 +221,14 @@ public abstract class AppDatabase extends RoomDatabase { database.execSQL("ALTER TABLE Site ADD COLUMN recordable INTEGER DEFAULT 1"); } }; + + static final Migration MIGRATION_25_26 = new Migration(25, 26) { + @Override + public void migrate(@NonNull SupportSQLiteDatabase database) { + database.execSQL("CREATE TABLE Site_Backup (`key` TEXT NOT NULL, name TEXT, searchable INTEGER, changeable INTEGER, recordable INTEGER, PRIMARY KEY (`key`))"); + database.execSQL("INSERT INTO Site_Backup SELECT `key`, name, searchable, changeable, recordable FROM Site"); + database.execSQL("DROP TABLE Site"); + database.execSQL("ALTER TABLE Site_Backup RENAME to Site"); + } + }; } diff --git a/app/src/main/java/com/fongmi/android/tv/player/ExoUtil.java b/app/src/main/java/com/fongmi/android/tv/player/ExoUtil.java index 1c3507cb4..2bc2b5709 100644 --- a/app/src/main/java/com/fongmi/android/tv/player/ExoUtil.java +++ b/app/src/main/java/com/fongmi/android/tv/player/ExoUtil.java @@ -22,7 +22,6 @@ import androidx.media3.datasource.cache.NoOpCacheEvictor; import androidx.media3.datasource.cache.SimpleCache; import androidx.media3.datasource.okhttp.OkHttpDataSource; import androidx.media3.exoplayer.DefaultLoadControl; -import androidx.media3.exoplayer.DefaultRenderersFactory; import androidx.media3.exoplayer.ExoPlayer; import androidx.media3.exoplayer.LoadControl; import androidx.media3.exoplayer.RenderersFactory; @@ -54,6 +53,7 @@ import java.util.Collections; import java.util.List; import java.util.Map; +import io.github.anilbeesetti.nextlib.media3ext.ffdecoder.NextRenderersFactory; import okhttp3.Call; public class ExoUtil { @@ -75,7 +75,7 @@ public class ExoUtil { } public static RenderersFactory buildRenderersFactory() { - return new DefaultRenderersFactory(App.get()).setExtensionRendererMode(Math.abs(Setting.getDecode() - 2)); + return new NextRenderersFactory(App.get()).setEnableDecoderFallback(true).setExtensionRendererMode(Math.abs(Setting.getDecode() - 2)); } public static CaptionStyleCompat getCaptionStyle() { diff --git a/app/src/main/java/com/fongmi/android/tv/player/Players.java b/app/src/main/java/com/fongmi/android/tv/player/Players.java index 9b5cf76b2..38cd0984f 100644 --- a/app/src/main/java/com/fongmi/android/tv/player/Players.java +++ b/app/src/main/java/com/fongmi/android/tv/player/Players.java @@ -124,6 +124,7 @@ public class Players implements Player.Listener, IMediaPlayer.Listener, Analytic exoPlayer = new ExoPlayer.Builder(App.get()).setLoadControl(ExoUtil.buildLoadControl()).setRenderersFactory(ExoUtil.buildRenderersFactory()).setTrackSelector(ExoUtil.buildTrackSelector()).build(); exoPlayer.setAudioAttributes(AudioAttributes.DEFAULT, true); exoPlayer.addAnalyticsListener(new EventLogger()); + exoPlayer.setHandleAudioBecomingNoisy(true); exoPlayer.addAnalyticsListener(this); exoPlayer.setPlayWhenReady(true); exoPlayer.addListener(this); diff --git a/app/src/mobile/java/com/fongmi/android/tv/ui/activity/LiveActivity.java b/app/src/mobile/java/com/fongmi/android/tv/ui/activity/LiveActivity.java index b148ea825..56c2d157a 100644 --- a/app/src/mobile/java/com/fongmi/android/tv/ui/activity/LiveActivity.java +++ b/app/src/mobile/java/com/fongmi/android/tv/ui/activity/LiveActivity.java @@ -190,6 +190,7 @@ public class LiveActivity extends BaseActivity implements CustomKeyDownLive.List mBinding.control.action.line.setOnClickListener(view -> onLine()); mBinding.control.action.scale.setOnClickListener(view -> onScale()); mBinding.control.action.speed.setOnClickListener(view -> onSpeed()); + mBinding.control.action.invert.setOnClickListener(view -> onInvert()); mBinding.control.action.across.setOnClickListener(view -> onAcross()); mBinding.control.action.change.setOnClickListener(view -> onChange()); mBinding.control.action.player.setOnClickListener(view -> onPlayer()); @@ -225,6 +226,7 @@ public class LiveActivity extends BaseActivity implements CustomKeyDownLive.List getExo().getSubtitleView().setStyle(ExoUtil.getCaptionStyle()); getIjk().getSubtitleView().setStyle(ExoUtil.getCaptionStyle()); mBinding.control.action.speed.setText(mPlayers.getSpeedText()); + mBinding.control.action.invert.setActivated(Setting.isInvert()); mBinding.control.action.across.setActivated(Setting.isAcross()); mBinding.control.action.change.setActivated(Setting.isChange()); mBinding.control.action.home.setVisibility(LiveConfig.isOnly() ? View.GONE : View.VISIBLE); @@ -376,6 +378,12 @@ public class LiveActivity extends BaseActivity implements CustomKeyDownLive.List return true; } + private void onInvert() { + setR1Callback(); + Setting.putInvert(!Setting.isInvert()); + mBinding.control.action.invert.setActivated(Setting.isInvert()); + } + private void onAcross() { setR1Callback(); Setting.putAcross(!Setting.isAcross()); diff --git a/app/src/mobile/java/com/fongmi/android/tv/ui/custom/CustomKeyDownLive.java b/app/src/mobile/java/com/fongmi/android/tv/ui/custom/CustomKeyDownLive.java index 2c437ca2b..90b017e30 100644 --- a/app/src/mobile/java/com/fongmi/android/tv/ui/custom/CustomKeyDownLive.java +++ b/app/src/mobile/java/com/fongmi/android/tv/ui/custom/CustomKeyDownLive.java @@ -10,6 +10,7 @@ import android.view.WindowManager; import androidx.annotation.NonNull; +import com.fongmi.android.tv.Setting; import com.fongmi.android.tv.utils.ResUtil; import com.fongmi.android.tv.utils.Util; @@ -113,9 +114,11 @@ public class CustomKeyDownLive extends GestureDetector.SimpleOnGestureListener { } else if (e2.getX() - e1.getX() > DISTANCE && Math.abs(velocityX) > VELOCITY) { listener.onFlingRight(); } else if (e1.getY() - e2.getY() > DISTANCE && Math.abs(velocityY) > VELOCITY) { - listener.onFlingUp(); + if (Setting.isInvert()) listener.onFlingDown(); + else listener.onFlingUp(); } else if (e2.getY() - e1.getY() > DISTANCE && Math.abs(velocityY) > VELOCITY) { - listener.onFlingDown(); + if (Setting.isInvert()) listener.onFlingUp(); + else listener.onFlingDown(); } } diff --git a/app/src/mobile/res/layout/view_control_live_action.xml b/app/src/mobile/res/layout/view_control_live_action.xml index 647971ff0..0a8b5fa52 100644 --- a/app/src/mobile/res/layout/view_control_live_action.xml +++ b/app/src/mobile/res/layout/view_control_live_action.xml @@ -75,6 +75,12 @@ android:visibility="gone" tools:visibility="visible" /> + +