Skip to content

Commit

Permalink
Add menu to 5GMS Aware Application (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsilhavy authored Nov 23, 2023
1 parent d0517d7 commit aca9baf
Show file tree
Hide file tree
Showing 30 changed files with 739 additions and 24 deletions.
1 change: 1 addition & 0 deletions fivegmag_5GMSdAwareApplication/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ dependencies {
implementation 'com.google.android.material:material:1.8.0'
implementation 'org.greenrobot:eventbus:3.3.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'com.google.android.gms:play-services-oss-licenses:17.0.1'
implementation 'com.fivegmag:a5gmscommonlibrary:1.1.0'
implementation 'com.fivegmag:a5gmsmediastreamhandler:1.1.0'
testImplementation 'junit:junit:4.13.2'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
android:supportsRtl="true"
android:theme="@style/Theme.5GMSdAwareApplication"
tools:targetApi="31">
<activity
android:name=".AboutActivity"
android:exported="false" />
<activity
android:name=".LicenseActivity"
android:exported="false" />
<activity
android:name="com.fivegmag.a5gmsdawareapplication.MainActivity"
android:exported="true">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<!-- <entry key="m8LocalMultiMedia">m8/config_multi_media.json</entry> -->
<!--<entry key="m8LocalAfAndAs">m8/config_local_af.json</entry>-->
<entry key="m85GMAGHost">https://rt.5g-mag.com/</entry>
<entry key="m8LocalDummyHost">http://10.147.67.10:3003/m8/</entry>
<!-- <entry key="m8LocalDummyHost">http://192.168.178.78:3003/m8/</entry> -->
<!-- <entry key="m8LocalDummyHost">http://10.147.67.10:3003/m8/</entry> -->
<entry key="m8LocalDummyHost">http://192.168.178.78:3003/m8/</entry>
<!-- <entry key="m8LocalDummyHost">http://194.95.175.90:3003/m8/</entry> -->
</properties>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.fivegmag.a5gmsdawareapplication

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle

class AboutActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_about)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.fivegmag.a5gmsdawareapplication

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle

class LicenseActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_license)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,24 @@ https://drive.google.com/file/d/1cinCiA778IErENZ3JN52VFW-1ffHpx7Z/view
package com.fivegmag.a5gmsdawareapplication

import android.Manifest
import android.content.Context
import android.app.AlertDialog
import android.content.Intent
import android.content.pm.PackageManager
import android.net.Uri
import android.os.Bundle
import android.text.Html
import android.util.Log
import android.view.LayoutInflater
import android.view.Menu
import android.view.MenuItem
import android.view.View
import android.widget.AdapterView
import android.widget.ArrayAdapter
import android.widget.Button
import android.widget.Spinner
import android.widget.TextView
import androidx.activity.result.contract.ActivityResultContracts
import com.google.android.gms.oss.licenses.OssLicensesMenuActivity;
import androidx.appcompat.app.AppCompatActivity
import androidx.core.app.ActivityCompat
import androidx.media3.common.util.UnstableApi
Expand Down Expand Up @@ -64,6 +71,104 @@ class MainActivity : AppCompatActivity(), AdapterView.OnItemSelectedListener {
setContentView(R.layout.activity_main)
requestUserPermissions()
}
override fun onCreateOptionsMenu(menu: Menu): Boolean {
menuInflater.inflate(R.menu.menu_main, menu)
return true
}

override fun onOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) {
R.id.actionLicense -> {
val dialogView = LayoutInflater.from(this).inflate(R.layout.activity_license, null)
val textView = dialogView.findViewById<TextView>(R.id.licenseTextView)
val formattedText = getString(R.string.license_text)
textView.text = Html.fromHtml(formattedText, Html.FROM_HTML_MODE_LEGACY)
val builder = AlertDialog.Builder(this)
.setView(dialogView)
.setPositiveButton("OK") { dialog, _ ->
dialog.dismiss()
}
val dialog = builder.create()
dialog.show()
return true
}

R.id.actionAbout -> {
val dialogView = LayoutInflater.from(this).inflate(R.layout.activity_about, null)
addVersionNumber(dialogView)
setClickListeners(dialogView)
formatAboutText(dialogView)
val builder = AlertDialog.Builder(this)
.setView(dialogView)
.setPositiveButton("OK") { dialog, _ ->
dialog.dismiss()
}
val dialog = builder.create()
dialog.show()
return true
}

R.id.actionAttribution -> {
OssLicensesMenuActivity.setActivityTitle(getString(R.string.action_attribution_notice))
val licensesIntent = Intent(this, OssLicensesMenuActivity::class.java)
startActivity(licensesIntent)
return true
}
}
return super.onOptionsItemSelected(item)
}

private fun addVersionNumber(dialogView: View) {
val packageInfo = packageManager.getPackageInfo(packageName, 0)
val versionName = packageInfo.versionName
val versionTextView = dialogView.findViewById<TextView>(R.id.versionNumberView)
val versionText = getString(R.string.version_text_field, versionName)
versionTextView.text = versionText
}

private fun setClickListeners(dialogView: View) {

val githubTextView = dialogView.findViewById<TextView>(R.id.githubLink)
githubTextView.setOnClickListener {
val url = getString(R.string.github_url)
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
startActivity(intent)
}

val twitterTextView = dialogView.findViewById<TextView>(R.id.twitterLink)
twitterTextView.setOnClickListener {
val url = getString(R.string.twitter_url)
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
startActivity(intent)
}

val linkedInView = dialogView.findViewById<TextView>(R.id.linkedInLink)
linkedInView.setOnClickListener {
val url = getString(R.string.linked_in_url)
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
startActivity(intent)
}

val slackView = dialogView.findViewById<TextView>(R.id.slackLink)
slackView.setOnClickListener {
val url = getString(R.string.slack_url)
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
startActivity(intent)
}

val websiteView = dialogView.findViewById<TextView>(R.id.websiteLink)
websiteView.setOnClickListener {
val url = getString(R.string.website_url)
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
startActivity(intent)
}
}

private fun formatAboutText(dialogView: View) {
val textView = dialogView.findViewById<TextView>(R.id.descriptionText)
val formattedText = getString(R.string.description_text)
textView.text = Html.fromHtml(formattedText, Html.FROM_HTML_MODE_LEGACY)
}

private fun requestUserPermissions() {
val requestPermissionLauncher =
Expand Down Expand Up @@ -104,7 +209,7 @@ class MainActivity : AppCompatActivity(), AdapterView.OnItemSelectedListener {
exoPlayerAdapter,
::onConnectionToMediaSessionHandlerEstablished
)
val representationInfoTextView = findViewById<TextView>(R.id.representationInfo)
val representationInfoTextView = findViewById<TextView>(R.id.representation_info)
mediaStreamHandlerEventHandler.initialize(representationInfoTextView, this)
} catch (e: Exception) {
e.printStackTrace()
Expand All @@ -127,7 +232,7 @@ class MainActivity : AppCompatActivity(), AdapterView.OnItemSelectedListener {
val packageInfo = packageManager.getPackageInfo(packageName, 0)
val versionName = packageInfo.versionName
val versionTextView = findViewById<TextView>(R.id.versionNumber)
val versionText = getString(R.string.versionTextField, versionName)
val versionText = getString(R.string.version_text_field, versionName)
versionTextView.text = versionText
} catch (e: PackageManager.NameNotFoundException) {
e.printStackTrace()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class MediaStreamHandlerEventHandler {
val kbitsPerSecond =
event.mediaLoadData.trackFormat?.peakBitrate?.div(1000).toString()
val id = event.mediaLoadData.trackFormat?.id.toString()
val text = context.getString(R.string.representationInfo, kbitsPerSecond, id)
val text = context.getString(R.string.representation_info, kbitsPerSecond, id)
representationInfoTextView.text = text
}
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<font-family xmlns:app="http://schemas.android.com/apk/res-auto"
app:fontProviderAuthority="com.google.android.gms.fonts"
app:fontProviderPackage="com.google.android.gms"
app:fontProviderQuery="name=Poppins&amp;weight=600"
app:fontProviderCerts="@array/com_google_android_gms_fonts_certs">
</font-family>
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
android:layout_height="57dp"
android:layout_marginStart="20dp"
android:layout_marginTop="4dp"
android:contentDescription="@string/_5g_mag_logo_description"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/logo_5g_mag_reference_tools" />
Expand Down Expand Up @@ -42,7 +43,7 @@
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="12dp"
android:text="@string/labelStreamSelection"
android:text="@string/label_stream_selection"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/idM8Spinner" />

Expand All @@ -61,7 +62,7 @@
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="20dp"
android:text="@string/labelM8Selection"
android:text="@string/label_M8_selection"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/imageView" />

Expand All @@ -71,14 +72,14 @@
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="20dp"
android:text="@string/startPlaybackButton"
android:text="@string/start_playback_button"
android:backgroundTint="@color/fivegmag_blue"
android:textColor="@color/white"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/idStreamSpinner" />

<TextView
android:id="@+id/representationInfo"
android:id="@+id/representation_info"
android:layout_width="348dp"
android:layout_height="19dp"
android:text=""
Expand All @@ -91,7 +92,7 @@
android:layout_width="146dp"
android:layout_height="20dp"
android:layout_marginBottom="16dp"
android:text="@string/versionTextField"
android:text="@string/version_text_field"
android:textAlignment="textEnd"
app:layout_constraintBottom_toTopOf="@+id/idExoPlayerVIew"
app:layout_constraintEnd_toEndOf="@+id/idExoPlayerVIew"
Expand All @@ -103,7 +104,7 @@
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:autoLink="web"
android:text="http://developer.5g-mag.com"
android:text="@string/_5gmag_developer_link"
android:textColorLink="@color/fivegmag_blue"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@+id/idExoPlayerVIew"
Expand Down
Loading

0 comments on commit aca9baf

Please sign in to comment.