diff --git a/.idea/misc.xml b/.idea/misc.xml
index 29bb4c5..8a8f75b 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -5,7 +5,7 @@
-
+
diff --git a/app/build.gradle b/app/build.gradle
index 53c2975..9b4292b 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -17,6 +17,11 @@ android {
compileOptions {
targetCompatibility JavaVersion.VERSION_1_8
+ sourceCompatibility JavaVersion.VERSION_1_8
+ }
+
+ kotlinOptions {
+ jvmTarget = "1.8"
}
buildTypes {
@@ -30,21 +35,21 @@ android {
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.appcompat:appcompat:1.1.0'
+ implementation 'androidx.core:core-ktx:1.2.0'
+ implementation 'com.google.android.material:material:1.1.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 'androidx.vectordrawable:vectordrawable:1.1.0'
+ implementation 'androidx.navigation:navigation-fragment:2.2.1'
+ implementation 'androidx.navigation:navigation-ui:2.2.1'
+ implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
+ implementation 'androidx.navigation:navigation-fragment-ktx:2.2.1'
+ implementation 'androidx.navigation:navigation-ui-ktx:2.2.1'
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'
+ androidTestImplementation 'androidx.test.ext:junit:1.1.1'
+ androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
diff --git a/app/src/main/java/com/google/android/material/lists/SingleLineItemViewHolder.java b/app/src/main/java/com/google/android/material/lists/SingleLineItemViewHolder.java
new file mode 100644
index 0000000..afc5e75
--- /dev/null
+++ b/app/src/main/java/com/google/android/material/lists/SingleLineItemViewHolder.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.android.material.lists;
+
+import net.theoks.customstreams.android.R;
+
+import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.RecyclerView.ViewHolder;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+/** A simple single line list item. */
+public class SingleLineItemViewHolder extends ViewHolder {
+
+ public final ImageView icon;
+ public final TextView text;
+
+ public SingleLineItemViewHolder(@NonNull View view) {
+ super(view);
+ this.icon = itemView.findViewById(R.id.mtrl_list_item_icon);
+ this.text = itemView.findViewById(R.id.mtrl_list_item_text);
+ }
+
+ @NonNull
+ public static SingleLineItemViewHolder create(@NonNull ViewGroup parent) {
+ return new SingleLineItemViewHolder(LayoutInflater.from(parent.getContext())
+ .inflate(R.layout.material_list_item_single_line, parent, false));
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/google/android/material/lists/ThreeLineItemViewHolder.java b/app/src/main/java/com/google/android/material/lists/ThreeLineItemViewHolder.java
new file mode 100644
index 0000000..cd97863
--- /dev/null
+++ b/app/src/main/java/com/google/android/material/lists/ThreeLineItemViewHolder.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.android.material.lists;
+
+import net.theoks.customstreams.android.R;
+
+import androidx.annotation.NonNull;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.TextView;
+
+/** A simple three line list item. */
+public class ThreeLineItemViewHolder extends TwoLineItemViewHolder {
+
+ public final TextView tertiary;
+
+ public ThreeLineItemViewHolder(@NonNull View view) {
+ super(view);
+ this.tertiary = itemView.findViewById(R.id.mtrl_list_item_tertiary_text);
+ }
+
+ @NonNull
+ public static ThreeLineItemViewHolder create(@NonNull ViewGroup parent) {
+ return new ThreeLineItemViewHolder(
+ LayoutInflater.from(parent.getContext())
+ .inflate(R.layout.material_list_item_three_line, parent, false));
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/google/android/material/lists/TwoLineItemViewHolder.java b/app/src/main/java/com/google/android/material/lists/TwoLineItemViewHolder.java
new file mode 100644
index 0000000..3d94f24
--- /dev/null
+++ b/app/src/main/java/com/google/android/material/lists/TwoLineItemViewHolder.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.android.material.lists;
+
+import net.theoks.customstreams.android.R;
+
+import androidx.annotation.NonNull;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.TextView;
+
+/** A simple two line list item. */
+public class TwoLineItemViewHolder extends SingleLineItemViewHolder {
+
+ public final TextView secondary;
+
+ public TwoLineItemViewHolder(@NonNull View view) {
+ super(view);
+ this.secondary = itemView.findViewById(R.id.mtrl_list_item_secondary_text);
+ }
+
+ @NonNull
+ public static TwoLineItemViewHolder create(@NonNull ViewGroup parent) {
+ return new TwoLineItemViewHolder(
+ LayoutInflater.from(parent.getContext())
+ .inflate(R.layout.material_list_item_two_line, parent, false));
+ }
+}
\ 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
index 5e5994d..adca119 100644
--- a/app/src/main/java/net/theoks/customstreams/android/MainActivity.kt
+++ b/app/src/main/java/net/theoks/customstreams/android/MainActivity.kt
@@ -20,11 +20,11 @@ class MainActivity : AppCompatActivity() {
// menu should be considered as top level destinations.
// val appBarConfiguration = AppBarConfiguration(
// setOf(
-// R.id.navigation_home, R.id.navigation_dashboard, R.id.navigation_player
+// R.id.navigation_home, R.id.navigation_dashboard, R.id.navigation_settings
// )
// )
// setupActionBarWithNavController(navController, appBarConfiguration)
- actionBar?.hide()
+// actionBar?.hide()
navView.setupWithNavController(navController)
}
}
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
index 117bc69..64ef17a 100644
--- 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
@@ -1,14 +1,28 @@
package net.theoks.customstreams.android.ui.dashboard
+import android.graphics.Typeface
import android.os.Bundle
+import android.text.TextUtils
+import android.util.Log
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 androidx.lifecycle.ViewModelProviders
+import androidx.recyclerview.widget.LinearLayoutManager
+import androidx.recyclerview.widget.RecyclerView
+import com.android.volley.Request
+import com.android.volley.Response
+import com.android.volley.toolbox.JsonArrayRequest
+import com.android.volley.toolbox.Volley
+import com.google.android.material.lists.SingleLineItemViewHolder
import net.theoks.customstreams.android.R
+import org.json.JSONArray
+import org.json.JSONObject
+import com.google.android.material.lists.ThreeLineItemViewHolder
+import com.google.android.material.lists.TwoLineItemViewHolder
class DashboardFragment : Fragment() {
@@ -19,13 +33,74 @@ class DashboardFragment : Fragment() {
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
- dashboardViewModel =
- ViewModelProviders.of(this).get(DashboardViewModel::class.java)
+// 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
-// })
+ val recyclerView = root.findViewById(R.id.dashboard_recycler_view)
+ recyclerView.layoutManager = LinearLayoutManager(context)
+ recyclerView.adapter = DashboardAdapter()
+
+ val queue = Volley.newRequestQueue(context)
+ val url = "https://buyvm-cf.theoks.net/custom-streams-player/get_stream_list.php"
+ val streamListJsonRequest = JsonArrayRequest(Request.Method.GET, url, null,
+ Response.Listener {
+ val stringArr = arrayOfNulls(it.length())
+ for(i in 0 until it.length()) {
+ val thisItem = it.get(i) as JSONObject
+ if(thisItem["stream_is_game"] as Boolean) {
+ stringArr[i] = "${thisItem["stream_key"]}\n${thisItem["stream_title"]}\nPlaying ${thisItem["stream_game_name"]}"
+ } else {
+ stringArr[i] = "${thisItem["stream_key"]}\n${thisItem["stream_title"]}"
+ }
+ }
+ (recyclerView.adapter as DashboardAdapter).receiveData(stringArr)
+ },
+ Response.ErrorListener { Log.e("OKSCustom-StreamList", "Error when requesting list of streams.") })
+ queue.add(streamListJsonRequest)
return root
}
+
+ class DashboardAdapter : RecyclerView.Adapter() {
+
+ private var dataMessages = arrayOf("Loading..")
+
+ fun receiveData(data: Array) {
+ dataMessages = data.requireNoNulls()
+ notifyDataSetChanged()
+ }
+
+ override fun onCreateViewHolder(parent: ViewGroup, position: Int): RecyclerView.ViewHolder {
+ return ThreeLineItemViewHolder.create(parent)
+ }
+
+ override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
+ var message = "We don't have data for this ViewHolder!"
+ if(position < dataMessages.size) message = dataMessages[position]
+ bind(holder as ThreeLineItemViewHolder, message)
+ }
+
+ private fun bind(vh: ThreeLineItemViewHolder, str: String) {
+ val split = str.split("\n")
+ vh.text.text = split[0]
+ vh.text.typeface = Typeface.defaultFromStyle(Typeface.BOLD)
+ if(split.size > 1)
+ {
+ vh.secondary.text = split[1]
+ vh.secondary.ellipsize = TextUtils.TruncateAt.END
+ }
+ if(split.size > 2) {
+ vh.tertiary.text = split[2]
+ vh.secondary.ellipsize = TextUtils.TruncateAt.END
+ }
+ }
+
+ override fun getItemCount(): Int {
+ return dataMessages.size
+ }
+
+ override fun getItemViewType(position: Int): Int {
+ if(position >= dataMessages.size) return 1
+ return dataMessages[position].split("\n").size
+ }
+ }
}
\ 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
index 3b10c68..853ae3e 100644
--- 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
@@ -12,26 +12,27 @@ import android.widget.TextView
import androidx.appcompat.app.AlertDialog
import androidx.fragment.app.Fragment
import androidx.lifecycle.Observer
-import androidx.lifecycle.ViewModelProviders
+//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 com.google.android.material.dialog.MaterialAlertDialogBuilder
import net.theoks.customstreams.android.PlayerActivity
import net.theoks.customstreams.android.R
import org.json.JSONObject
class HomeFragment : Fragment() {
- private lateinit var homeViewModel: HomeViewModel
+// private lateinit var homeViewModel: HomeViewModel
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
- homeViewModel =
- ViewModelProviders.of(this).get(HomeViewModel::class.java)
+// 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
@@ -39,7 +40,7 @@ class HomeFragment : Fragment() {
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 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")) {
@@ -48,10 +49,9 @@ class HomeFragment : Fragment() {
}
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)
+ val builder = MaterialAlertDialogBuilder(context ?: throw Exception("Couldn't get context while building alert"))
+ builder.setTitle(R.string.stream_not_live).setMessage("Stream $streamKey is not live.").setPositiveButton(R.string.ok, null).show()
Log.i("OKSCustom-StreamInfo", "Stream $streamKey is not live!")
- builder.create()
}
},
Response.ErrorListener {Log.e("OKSCustom-StreamInfo", "Error when requesting stream info ${it.message}")})
diff --git a/app/src/main/res/color/mtrl_list_item_tint.xml b/app/src/main/res/color/mtrl_list_item_tint.xml
new file mode 100644
index 0000000..a273725
--- /dev/null
+++ b/app/src/main/res/color/mtrl_list_item_tint.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable/logo_avatar_anonymous_40dp.xml b/app/src/main/res/drawable/logo_avatar_anonymous_40dp.xml
new file mode 100644
index 0000000..de015ca
--- /dev/null
+++ b/app/src/main/res/drawable/logo_avatar_anonymous_40dp.xml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index f1db649..721f662 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -3,8 +3,8 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/container"
android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:paddingTop="?attr/actionBarSize">
+ android:layout_height="match_parent">
+
-
\ No newline at end of file
+ android:layout_height="match_parent"
+ android:orientation="vertical"
+ android:paddingStart="10dp"
+ android:paddingEnd="10dp">
+
+
+
diff --git a/app/src/main/res/layout/list_item_dashboard.xml b/app/src/main/res/layout/list_item_dashboard.xml
new file mode 100644
index 0000000..4eb36cf
--- /dev/null
+++ b/app/src/main/res/layout/list_item_dashboard.xml
@@ -0,0 +1,6 @@
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/material_list_item_single_line.xml b/app/src/main/res/layout/material_list_item_single_line.xml
new file mode 100644
index 0000000..78571af
--- /dev/null
+++ b/app/src/main/res/layout/material_list_item_single_line.xml
@@ -0,0 +1,42 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/material_list_item_three_line.xml b/app/src/main/res/layout/material_list_item_three_line.xml
new file mode 100644
index 0000000..78969e7
--- /dev/null
+++ b/app/src/main/res/layout/material_list_item_three_line.xml
@@ -0,0 +1,66 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/material_list_item_two_line.xml b/app/src/main/res/layout/material_list_item_two_line.xml
new file mode 100644
index 0000000..d4d1ce9
--- /dev/null
+++ b/app/src/main/res/layout/material_list_item_two_line.xml
@@ -0,0 +1,52 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 39ad6ab..07d5a19 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -1,11 +1,12 @@
OKS Streams
Home
- Dashboard
+ Live Streams
Stream Key
Watch
OKS Custom Streams
Player
Settings
OK
+ Stream Not Live
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
index 8028c3b..c179879 100644
--- a/app/src/main/res/values/styles.xml
+++ b/app/src/main/res/values/styles.xml
@@ -1,13 +1,13 @@
-
-