From 279b9c5d5f2455d4eed8ecba63577a1083f6a8c1 Mon Sep 17 00:00:00 2001 From: Darren VanBuren Date: Tue, 11 Feb 2020 02:41:41 -0800 Subject: [PATCH] Initial commit, plays any stream on OKS, avoids trying to play non-live streams --- .gitignore | 14 ++ .idea/.name | 1 + .idea/codeStyles/Project.xml | 125 +++++++++++++ .idea/codeStyles/codeStyleConfig.xml | 5 + .idea/gradle.xml | 19 ++ .idea/misc.xml | 14 ++ .idea/runConfigurations.xml | 12 ++ .idea/vcs.xml | 6 + app/.gitignore | 1 + app/build.gradle | 50 +++++ app/proguard-rules.pro | 21 +++ .../android/ExampleInstrumentedTest.kt | 24 +++ app/src/main/AndroidManifest.xml | 29 +++ .../customstreams/android/MainActivity.kt | 30 +++ .../customstreams/android/PlayerActivity.kt | 46 +++++ .../android/ui/dashboard/DashboardFragment.kt | 31 ++++ .../ui/dashboard/DashboardViewModel.kt | 13 ++ .../android/ui/home/HomeFragment.kt | 64 +++++++ .../android/ui/home/HomeViewModel.kt | 13 ++ .../android/ui/player/PlayerFragment.kt | 41 +++++ .../android/ui/player/PlayerViewModel.kt | 7 + .../android/ui/settings/SettingsFragment.kt | 20 ++ .../drawable-v24/ic_launcher_foreground.xml | 34 ++++ .../res/drawable/ic_dashboard_black_24dp.xml | 9 + .../main/res/drawable/ic_home_black_24dp.xml | 9 + .../res/drawable/ic_launcher_background.xml | 170 +++++++++++++++++ .../drawable/ic_notifications_black_24dp.xml | 9 + app/src/main/res/layout/activity_main.xml | 33 ++++ .../main/res/layout/fragment_dashboard.xml | 6 + app/src/main/res/layout/fragment_home.xml | 47 +++++ app/src/main/res/layout/fragment_player.xml | 20 ++ app/src/main/res/layout/fragment_settings.xml | 6 + app/src/main/res/menu/bottom_nav_menu.xml | 19 ++ .../res/mipmap-anydpi-v26/ic_launcher.xml | 5 + .../mipmap-anydpi-v26/ic_launcher_round.xml | 5 + app/src/main/res/mipmap-hdpi/ic_launcher.png | Bin 0 -> 2963 bytes .../res/mipmap-hdpi/ic_launcher_round.png | Bin 0 -> 4905 bytes app/src/main/res/mipmap-mdpi/ic_launcher.png | Bin 0 -> 2060 bytes .../res/mipmap-mdpi/ic_launcher_round.png | Bin 0 -> 2783 bytes app/src/main/res/mipmap-xhdpi/ic_launcher.png | Bin 0 -> 4490 bytes .../res/mipmap-xhdpi/ic_launcher_round.png | Bin 0 -> 6895 bytes .../main/res/mipmap-xxhdpi/ic_launcher.png | Bin 0 -> 6387 bytes .../res/mipmap-xxhdpi/ic_launcher_round.png | Bin 0 -> 10413 bytes .../main/res/mipmap-xxxhdpi/ic_launcher.png | Bin 0 -> 9128 bytes .../res/mipmap-xxxhdpi/ic_launcher_round.png | Bin 0 -> 15132 bytes .../main/res/navigation/mobile_navigation.xml | 25 +++ app/src/main/res/values/colors.xml | 6 + app/src/main/res/values/dimens.xml | 5 + app/src/main/res/values/strings.xml | 11 ++ app/src/main/res/values/styles.xml | 15 ++ .../customstreams/android/ExampleUnitTest.kt | 17 ++ build.gradle | 28 +++ gradle.properties | 21 +++ gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 54329 bytes gradle/wrapper/gradle-wrapper.properties | 6 + gradlew | 172 ++++++++++++++++++ gradlew.bat | 84 +++++++++ settings.gradle | 2 + 58 files changed, 1350 insertions(+) create mode 100644 .gitignore create mode 100644 .idea/.name create mode 100644 .idea/codeStyles/Project.xml create mode 100644 .idea/codeStyles/codeStyleConfig.xml create mode 100644 .idea/gradle.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/runConfigurations.xml create mode 100644 .idea/vcs.xml create mode 100644 app/.gitignore create mode 100644 app/build.gradle create mode 100644 app/proguard-rules.pro create mode 100644 app/src/androidTest/java/net/theoks/customstreams/android/ExampleInstrumentedTest.kt create mode 100644 app/src/main/AndroidManifest.xml create mode 100644 app/src/main/java/net/theoks/customstreams/android/MainActivity.kt create mode 100644 app/src/main/java/net/theoks/customstreams/android/PlayerActivity.kt create mode 100644 app/src/main/java/net/theoks/customstreams/android/ui/dashboard/DashboardFragment.kt create mode 100644 app/src/main/java/net/theoks/customstreams/android/ui/dashboard/DashboardViewModel.kt create mode 100644 app/src/main/java/net/theoks/customstreams/android/ui/home/HomeFragment.kt create mode 100644 app/src/main/java/net/theoks/customstreams/android/ui/home/HomeViewModel.kt create mode 100644 app/src/main/java/net/theoks/customstreams/android/ui/player/PlayerFragment.kt create mode 100644 app/src/main/java/net/theoks/customstreams/android/ui/player/PlayerViewModel.kt create mode 100644 app/src/main/java/net/theoks/customstreams/android/ui/settings/SettingsFragment.kt create mode 100644 app/src/main/res/drawable-v24/ic_launcher_foreground.xml create mode 100644 app/src/main/res/drawable/ic_dashboard_black_24dp.xml create mode 100644 app/src/main/res/drawable/ic_home_black_24dp.xml create mode 100644 app/src/main/res/drawable/ic_launcher_background.xml create mode 100644 app/src/main/res/drawable/ic_notifications_black_24dp.xml create mode 100644 app/src/main/res/layout/activity_main.xml create mode 100644 app/src/main/res/layout/fragment_dashboard.xml create mode 100644 app/src/main/res/layout/fragment_home.xml create mode 100644 app/src/main/res/layout/fragment_player.xml create mode 100644 app/src/main/res/layout/fragment_settings.xml create mode 100644 app/src/main/res/menu/bottom_nav_menu.xml create mode 100644 app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml create mode 100644 app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml create mode 100644 app/src/main/res/mipmap-hdpi/ic_launcher.png create mode 100644 app/src/main/res/mipmap-hdpi/ic_launcher_round.png create mode 100644 app/src/main/res/mipmap-mdpi/ic_launcher.png create mode 100644 app/src/main/res/mipmap-mdpi/ic_launcher_round.png create mode 100644 app/src/main/res/mipmap-xhdpi/ic_launcher.png create mode 100644 app/src/main/res/mipmap-xhdpi/ic_launcher_round.png create mode 100644 app/src/main/res/mipmap-xxhdpi/ic_launcher.png create mode 100644 app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png create mode 100644 app/src/main/res/mipmap-xxxhdpi/ic_launcher.png create mode 100644 app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png create mode 100644 app/src/main/res/navigation/mobile_navigation.xml create mode 100644 app/src/main/res/values/colors.xml create mode 100644 app/src/main/res/values/dimens.xml create mode 100644 app/src/main/res/values/strings.xml create mode 100644 app/src/main/res/values/styles.xml create mode 100644 app/src/test/java/net/theoks/customstreams/android/ExampleUnitTest.kt create mode 100644 build.gradle create mode 100644 gradle.properties create mode 100644 gradle/wrapper/gradle-wrapper.jar create mode 100644 gradle/wrapper/gradle-wrapper.properties create mode 100644 gradlew create mode 100644 gradlew.bat create mode 100644 settings.gradle diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..603b140 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 0000000..68d6aa7 --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +OKS Streams \ No newline at end of file diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..45b5654 --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,125 @@ + + + + + + + + + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
+ + +
+
\ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..79ee123 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..169fd0d --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,19 @@ + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..29bb4c5 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..53c2975 --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,50 @@ +apply plugin: 'com.android.application' + +apply plugin: 'kotlin-android' + +apply plugin: 'kotlin-android-extensions' + +android { + compileSdkVersion 28 + defaultConfig { + applicationId "net.theoks.customstreams.android" + minSdkVersion 19 + targetSdkVersion 28 + versionCode 1 + versionName "1.0" + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + compileOptions { + targetCompatibility JavaVersion.VERSION_1_8 + } + + buildTypes { + release { + minifyEnabled true + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation 'androidx.appcompat:appcompat:1.0.2' + implementation 'androidx.core:core-ktx:1.0.2' + implementation 'com.google.android.material:material:1.0.0' + implementation 'androidx.constraintlayout:constraintlayout:1.1.3' + implementation 'androidx.vectordrawable:vectordrawable:1.0.1' + implementation 'androidx.navigation:navigation-fragment:2.0.0' + implementation 'androidx.navigation:navigation-ui:2.0.0' + implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0' + implementation 'androidx.navigation:navigation-fragment-ktx:2.0.0' + implementation 'androidx.navigation:navigation-ui-ktx:2.0.0' + implementation 'com.google.android.exoplayer:exoplayer-core:2.11.1' + implementation 'com.google.android.exoplayer:exoplayer-hls:2.11.1' + implementation 'com.google.android.exoplayer:exoplayer-ui:2.11.1' + implementation 'com.android.volley:volley:1.1.1' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test.ext:junit:1.1.0' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1' +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/app/src/androidTest/java/net/theoks/customstreams/android/ExampleInstrumentedTest.kt b/app/src/androidTest/java/net/theoks/customstreams/android/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..cf31bac --- /dev/null +++ b/app/src/androidTest/java/net/theoks/customstreams/android/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package net.theoks.customstreams.android + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("net.theoks.customstreams.android", appContext.packageName) + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..5de5b92 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/net/theoks/customstreams/android/MainActivity.kt b/app/src/main/java/net/theoks/customstreams/android/MainActivity.kt new file mode 100644 index 0000000..5e5994d --- /dev/null +++ b/app/src/main/java/net/theoks/customstreams/android/MainActivity.kt @@ -0,0 +1,30 @@ +package net.theoks.customstreams.android + +import android.os.Bundle +import com.google.android.material.bottomnavigation.BottomNavigationView +import androidx.appcompat.app.AppCompatActivity +import androidx.navigation.findNavController +import androidx.navigation.ui.AppBarConfiguration +import androidx.navigation.ui.setupActionBarWithNavController +import androidx.navigation.ui.setupWithNavController + +class MainActivity : AppCompatActivity() { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_main) + val navView: BottomNavigationView = findViewById(R.id.nav_view) + + val navController = findNavController(R.id.nav_host_fragment) + // Passing each menu ID as a set of Ids because each + // menu should be considered as top level destinations. +// val appBarConfiguration = AppBarConfiguration( +// setOf( +// R.id.navigation_home, R.id.navigation_dashboard, R.id.navigation_player +// ) +// ) +// setupActionBarWithNavController(navController, appBarConfiguration) + actionBar?.hide() + navView.setupWithNavController(navController) + } +} diff --git a/app/src/main/java/net/theoks/customstreams/android/PlayerActivity.kt b/app/src/main/java/net/theoks/customstreams/android/PlayerActivity.kt new file mode 100644 index 0000000..7cdf318 --- /dev/null +++ b/app/src/main/java/net/theoks/customstreams/android/PlayerActivity.kt @@ -0,0 +1,46 @@ +package net.theoks.customstreams.android + +import android.net.Uri +import android.os.Bundle +import android.widget.Toast +import androidx.appcompat.app.AppCompatActivity +import com.google.android.exoplayer2.SimpleExoPlayer +import com.google.android.exoplayer2.source.hls.HlsMediaSource +import com.google.android.exoplayer2.ui.PlayerView +import com.google.android.exoplayer2.upstream.DataSource +import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory +import com.google.android.exoplayer2.util.Util + +class PlayerActivity : AppCompatActivity() { + private lateinit var player: SimpleExoPlayer + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + val streamKey = intent.getStringExtra("net.theoks.customstreams.streamkey") + if(streamKey == null || streamKey == "") { + val duration = Toast.LENGTH_LONG + val toast = Toast.makeText(applicationContext, "Stream Key null or blank", duration) + toast.show() + finish() + return + } + + setContentView(R.layout.fragment_player) + player = SimpleExoPlayer.Builder(applicationContext ?: throw Exception("Don't have context when trying to build player")).build() + val playerView = findViewById(R.id.player_view) as PlayerView + playerView.player = player + val dataSourceFactory : DataSource.Factory = DefaultDataSourceFactory(applicationContext, Util.getUserAgent(applicationContext ?: + throw Exception("Don't have context when trying to build DataSource.Factory"), "OKS Custom Streams Android") ) + val mediaSource = HlsMediaSource.Factory(dataSourceFactory).createMediaSource(Uri.parse("https://buyvm-cf.theoks.net/hls-segments/$streamKey.m3u8")) + player.prepare(mediaSource) + player.playWhenReady = true + } + + override fun onDestroy() { + if(this::player.isInitialized) { + player.stop() + player.release() + } + super.onDestroy() + } +} \ No newline at end of file diff --git a/app/src/main/java/net/theoks/customstreams/android/ui/dashboard/DashboardFragment.kt b/app/src/main/java/net/theoks/customstreams/android/ui/dashboard/DashboardFragment.kt new file mode 100644 index 0000000..117bc69 --- /dev/null +++ b/app/src/main/java/net/theoks/customstreams/android/ui/dashboard/DashboardFragment.kt @@ -0,0 +1,31 @@ +package net.theoks.customstreams.android.ui.dashboard + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.TextView +import androidx.fragment.app.Fragment +import androidx.lifecycle.Observer +import androidx.lifecycle.ViewModelProviders +import net.theoks.customstreams.android.R + +class DashboardFragment : Fragment() { + + private lateinit var dashboardViewModel: DashboardViewModel + + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? + ): View? { + dashboardViewModel = + ViewModelProviders.of(this).get(DashboardViewModel::class.java) + val root = inflater.inflate(R.layout.fragment_dashboard, container, false) +// val textView: TextView = root.findViewById(R.id.text_dashboard) +// dashboardViewModel.text.observe(this, Observer { +// textView.text = it +// }) + return root + } +} \ No newline at end of file diff --git a/app/src/main/java/net/theoks/customstreams/android/ui/dashboard/DashboardViewModel.kt b/app/src/main/java/net/theoks/customstreams/android/ui/dashboard/DashboardViewModel.kt new file mode 100644 index 0000000..17ad547 --- /dev/null +++ b/app/src/main/java/net/theoks/customstreams/android/ui/dashboard/DashboardViewModel.kt @@ -0,0 +1,13 @@ +package net.theoks.customstreams.android.ui.dashboard + +import androidx.lifecycle.LiveData +import androidx.lifecycle.MutableLiveData +import androidx.lifecycle.ViewModel + +class DashboardViewModel : ViewModel() { + + private val _text = MutableLiveData().apply { + value = "This is dashboard Fragment" + } + val text: LiveData = _text +} \ No newline at end of file diff --git a/app/src/main/java/net/theoks/customstreams/android/ui/home/HomeFragment.kt b/app/src/main/java/net/theoks/customstreams/android/ui/home/HomeFragment.kt new file mode 100644 index 0000000..3b10c68 --- /dev/null +++ b/app/src/main/java/net/theoks/customstreams/android/ui/home/HomeFragment.kt @@ -0,0 +1,64 @@ +package net.theoks.customstreams.android.ui.home + +import android.content.Intent +import android.os.Bundle +import android.util.Log +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.Button +import android.widget.EditText +import android.widget.TextView +import androidx.appcompat.app.AlertDialog +import androidx.fragment.app.Fragment +import androidx.lifecycle.Observer +import androidx.lifecycle.ViewModelProviders +import com.android.volley.Request +import com.android.volley.Response +import com.android.volley.toolbox.JsonObjectRequest +import com.android.volley.toolbox.Volley +import net.theoks.customstreams.android.PlayerActivity +import net.theoks.customstreams.android.R +import org.json.JSONObject + +class HomeFragment : Fragment() { + + private lateinit var homeViewModel: HomeViewModel + + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? + ): View? { + homeViewModel = + ViewModelProviders.of(this).get(HomeViewModel::class.java) + val root = inflater.inflate(R.layout.fragment_home, container, false) + + val button = root.findViewById(R.id.watchButton) as Button + button.setOnClickListener { + val streamKey = (it.rootView.findViewById(R.id.streamKeyEdit) as EditText).text.toString() + Log.i("OKSCustomHome", "Button pressed, found stream key $streamKey") + + var queue = Volley.newRequestQueue(it.context) + val url = "https://buyvm-cf.theoks.net/custom-streams-player/get_title.php?streamkey=$streamKey" + val streamInfoJsonRequest = JsonObjectRequest(Request.Method.GET, url, null, Response.Listener { + if(it.getBoolean("stream_is_live")) { + val intent = Intent(context, PlayerActivity::class.java).apply { + putExtra("net.theoks.customstreams.streamkey", streamKey) + } + startActivity(intent) + } else { + val builder = AlertDialog.Builder(context ?: throw Exception("Couldn't get context while building alert")) + builder.setMessage("Stream $streamKey is not live.").setNeutralButton(R.string.ok, null) + Log.i("OKSCustom-StreamInfo", "Stream $streamKey is not live!") + builder.create() + } + }, + Response.ErrorListener {Log.e("OKSCustom-StreamInfo", "Error when requesting stream info ${it.message}")}) + queue.add(streamInfoJsonRequest) + } + return root + } + + +} \ No newline at end of file diff --git a/app/src/main/java/net/theoks/customstreams/android/ui/home/HomeViewModel.kt b/app/src/main/java/net/theoks/customstreams/android/ui/home/HomeViewModel.kt new file mode 100644 index 0000000..ab8fe9b --- /dev/null +++ b/app/src/main/java/net/theoks/customstreams/android/ui/home/HomeViewModel.kt @@ -0,0 +1,13 @@ +package net.theoks.customstreams.android.ui.home + +import androidx.lifecycle.LiveData +import androidx.lifecycle.MutableLiveData +import androidx.lifecycle.ViewModel + +class HomeViewModel : ViewModel() { + + private val _text = MutableLiveData().apply { + value = "This is home Fragment" + } + val text: LiveData = _text +} \ No newline at end of file diff --git a/app/src/main/java/net/theoks/customstreams/android/ui/player/PlayerFragment.kt b/app/src/main/java/net/theoks/customstreams/android/ui/player/PlayerFragment.kt new file mode 100644 index 0000000..8c2c05b --- /dev/null +++ b/app/src/main/java/net/theoks/customstreams/android/ui/player/PlayerFragment.kt @@ -0,0 +1,41 @@ +package net.theoks.customstreams.android.ui.player + +import android.net.Uri +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.fragment.app.Fragment +import net.theoks.customstreams.android.R +import com.google.android.exoplayer2.SimpleExoPlayer +import com.google.android.exoplayer2.source.hls.HlsMediaSource +import com.google.android.exoplayer2.ui.PlayerView +import com.google.android.exoplayer2.upstream.DataSource +import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory +import com.google.android.exoplayer2.util.Util + + +class PlayerFragment : Fragment() { + private lateinit var player: SimpleExoPlayer + + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? + ): View? { + val root = inflater.inflate(R.layout.fragment_player, container, false) + player = SimpleExoPlayer.Builder(this.context ?: throw Exception("Don't have context when trying to build player")).build() + val playerView = root.findViewById(R.id.player_view) as PlayerView + playerView.player = player + val dataSourceFactory : DataSource.Factory = DefaultDataSourceFactory(context, Util.getUserAgent(context ?: + throw Exception("Don't have context when trying to build DataSource.Factory"), "OKS Custom Streams Android") ) + val mediaSource = HlsMediaSource.Factory(dataSourceFactory).createMediaSource(Uri.parse("https://buyvm-cf.theoks.net/hls-segments/testsg.m3u8")) + player.prepare(mediaSource) + return root + } + + override fun onDestroyView() { + player.release() + super.onDestroyView() + } +} \ No newline at end of file diff --git a/app/src/main/java/net/theoks/customstreams/android/ui/player/PlayerViewModel.kt b/app/src/main/java/net/theoks/customstreams/android/ui/player/PlayerViewModel.kt new file mode 100644 index 0000000..201f422 --- /dev/null +++ b/app/src/main/java/net/theoks/customstreams/android/ui/player/PlayerViewModel.kt @@ -0,0 +1,7 @@ +package net.theoks.customstreams.android.ui.player + +import androidx.lifecycle.ViewModel + +class PlayerViewModel : ViewModel() { + +} \ No newline at end of file diff --git a/app/src/main/java/net/theoks/customstreams/android/ui/settings/SettingsFragment.kt b/app/src/main/java/net/theoks/customstreams/android/ui/settings/SettingsFragment.kt new file mode 100644 index 0000000..7bb8dcd --- /dev/null +++ b/app/src/main/java/net/theoks/customstreams/android/ui/settings/SettingsFragment.kt @@ -0,0 +1,20 @@ +package net.theoks.customstreams.android.ui.settings + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.fragment.app.Fragment +import net.theoks.customstreams.android.R + +class SettingsFragment : Fragment() { + + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? + ): View? { + val root = inflater.inflate(R.layout.fragment_settings, container, false) + return root + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..1f6bb29 --- /dev/null +++ b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_dashboard_black_24dp.xml b/app/src/main/res/drawable/ic_dashboard_black_24dp.xml new file mode 100644 index 0000000..46fc8de --- /dev/null +++ b/app/src/main/res/drawable/ic_dashboard_black_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_home_black_24dp.xml b/app/src/main/res/drawable/ic_home_black_24dp.xml new file mode 100644 index 0000000..f8bb0b5 --- /dev/null +++ b/app/src/main/res/drawable/ic_home_black_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..0d025f9 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_notifications_black_24dp.xml b/app/src/main/res/drawable/ic_notifications_black_24dp.xml new file mode 100644 index 0000000..78b75c3 --- /dev/null +++ b/app/src/main/res/drawable/ic_notifications_black_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..f1db649 --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,33 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_dashboard.xml b/app/src/main/res/layout/fragment_dashboard.xml new file mode 100644 index 0000000..3eb793b --- /dev/null +++ b/app/src/main/res/layout/fragment_dashboard.xml @@ -0,0 +1,6 @@ + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_home.xml b/app/src/main/res/layout/fragment_home.xml new file mode 100644 index 0000000..d1060eb --- /dev/null +++ b/app/src/main/res/layout/fragment_home.xml @@ -0,0 +1,47 @@ + + + +