mirror of
https://git.sr.ht/~thestr4ng3r/chiaki
synced 2025-08-05 22:43:54 -07:00
Start Session from MainActivity on Android
This commit is contained in:
parent
454d8048df
commit
63c89c63af
3 changed files with 113 additions and 94 deletions
android/app/src/main
java/com/metallic/chiaki/main
res/layout
|
@ -27,7 +27,7 @@ import com.metallic.chiaki.common.ext.inflate
|
||||||
import com.metallic.chiaki.lib.DiscoveryHost
|
import com.metallic.chiaki.lib.DiscoveryHost
|
||||||
import kotlinx.android.synthetic.main.item_display_host.view.*
|
import kotlinx.android.synthetic.main.item_display_host.view.*
|
||||||
|
|
||||||
class DisplayHostRecyclerViewAdapter: RecyclerView.Adapter<DisplayHostRecyclerViewAdapter.ViewHolder>()
|
class DisplayHostRecyclerViewAdapter(val clickCallback: (DisplayHost) -> Unit): RecyclerView.Adapter<DisplayHostRecyclerViewAdapter.ViewHolder>()
|
||||||
{
|
{
|
||||||
var hosts: List<DisplayHost> = listOf()
|
var hosts: List<DisplayHost> = listOf()
|
||||||
set(value)
|
set(value)
|
||||||
|
@ -78,6 +78,7 @@ class DisplayHostRecyclerViewAdapter: RecyclerView.Adapter<DisplayHostRecyclerVi
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
R.drawable.ic_console)
|
R.drawable.ic_console)
|
||||||
|
it.setOnClickListener { clickCallback(host) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -30,12 +30,16 @@ import androidx.lifecycle.ViewModelProviders
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import com.metallic.chiaki.R
|
import com.metallic.chiaki.R
|
||||||
import com.metallic.chiaki.TestStartActivity
|
import com.metallic.chiaki.TestStartActivity
|
||||||
|
import com.metallic.chiaki.common.DisplayHost
|
||||||
|
import com.metallic.chiaki.common.Preferences
|
||||||
import com.metallic.chiaki.common.ext.RevealActivity
|
import com.metallic.chiaki.common.ext.RevealActivity
|
||||||
import com.metallic.chiaki.common.ext.putRevealExtra
|
import com.metallic.chiaki.common.ext.putRevealExtra
|
||||||
import com.metallic.chiaki.common.getDatabase
|
import com.metallic.chiaki.common.getDatabase
|
||||||
import com.metallic.chiaki.common.ext.viewModelFactory
|
import com.metallic.chiaki.common.ext.viewModelFactory
|
||||||
|
import com.metallic.chiaki.lib.ConnectInfo
|
||||||
import com.metallic.chiaki.regist.RegistActivity
|
import com.metallic.chiaki.regist.RegistActivity
|
||||||
import com.metallic.chiaki.settings.SettingsActivity
|
import com.metallic.chiaki.settings.SettingsActivity
|
||||||
|
import com.metallic.chiaki.stream.StreamActivity
|
||||||
import io.reactivex.disposables.CompositeDisposable
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
import kotlinx.android.synthetic.main.activity_main.*
|
import kotlinx.android.synthetic.main.activity_main.*
|
||||||
|
|
||||||
|
@ -70,7 +74,7 @@ class MainActivity : AppCompatActivity()
|
||||||
.of(this, viewModelFactory { MainViewModel(getDatabase(this)) })
|
.of(this, viewModelFactory { MainViewModel(getDatabase(this)) })
|
||||||
.get(MainViewModel::class.java)
|
.get(MainViewModel::class.java)
|
||||||
|
|
||||||
val recyclerViewAdapter = DisplayHostRecyclerViewAdapter()
|
val recyclerViewAdapter = DisplayHostRecyclerViewAdapter(this::hostTriggered)
|
||||||
hostsRecyclerView.adapter = recyclerViewAdapter
|
hostsRecyclerView.adapter = recyclerViewAdapter
|
||||||
hostsRecyclerView.layoutManager = LinearLayoutManager(this)
|
hostsRecyclerView.layoutManager = LinearLayoutManager(this)
|
||||||
viewModel.displayHosts.observe(this, Observer {
|
viewModel.displayHosts.observe(this, Observer {
|
||||||
|
@ -161,4 +165,23 @@ class MainActivity : AppCompatActivity()
|
||||||
startActivity(it, ActivityOptions.makeSceneTransitionAnimation(this).toBundle())
|
startActivity(it, ActivityOptions.makeSceneTransitionAnimation(this).toBundle())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun hostTriggered(host: DisplayHost)
|
||||||
|
{
|
||||||
|
val registeredHost = host.registeredHost
|
||||||
|
if(registeredHost != null)
|
||||||
|
{
|
||||||
|
// TODO: check standby
|
||||||
|
|
||||||
|
val connectInfo = ConnectInfo(host.host, registeredHost.rpRegistKey, registeredHost.rpKey, Preferences(this).videoProfile)
|
||||||
|
Intent(this, StreamActivity::class.java).let {
|
||||||
|
it.putExtra(StreamActivity.EXTRA_CONNECT_INFO, connectInfo)
|
||||||
|
startActivity(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// TODO: show registration
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,109 +1,104 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout
|
|
||||||
|
<androidx.cardview.widget.CardView
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:orientation="vertical"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="250dp"
|
||||||
|
app:cardCornerRadius="4dp"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:layout_marginLeft="8dp"
|
||||||
|
android:layout_marginRight="8dp"
|
||||||
|
android:layout_marginBottom="0dp"
|
||||||
|
android:elevation="8dp"
|
||||||
|
android:foreground="?android:attr/selectableItemBackground">
|
||||||
|
|
||||||
<androidx.cardview.widget.CardView
|
<FrameLayout
|
||||||
android:layout_width="match_parent"
|
android:id="@+id/discoveredIndicatorLayout"
|
||||||
android:layout_height="250dp"
|
android:layout_width="wrap_content"
|
||||||
app:cardCornerRadius="4dp"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="8dp"
|
android:layout_gravity="left|top" >
|
||||||
android:layout_marginLeft="8dp"
|
<ImageView
|
||||||
android:layout_marginRight="8dp"
|
android:layout_width="72dp"
|
||||||
android:layout_marginBottom="0dp"
|
android:layout_height="72dp"
|
||||||
android:elevation="8dp">
|
android:src="@drawable/ic_triangle"/>
|
||||||
|
<ImageView
|
||||||
<FrameLayout
|
|
||||||
android:id="@+id/discoveredIndicatorLayout"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="left|top" >
|
android:src="@drawable/ic_discovered_on_secondary"
|
||||||
<ImageView
|
android:layout_gravity="left|top"
|
||||||
android:layout_width="72dp"
|
android:layout_margin="8dp" />
|
||||||
android:layout_height="72dp"
|
</FrameLayout>
|
||||||
android:src="@drawable/ic_triangle"/>
|
|
||||||
<ImageView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:src="@drawable/ic_discovered_on_secondary"
|
|
||||||
android:layout_gravity="left|top"
|
|
||||||
android:layout_margin="8dp" />
|
|
||||||
</FrameLayout>
|
|
||||||
|
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:padding="8dp">
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.AppCompatTextView
|
||||||
|
android:id="@+id/nameTextView"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="wrap_content"
|
||||||
android:padding="8dp">
|
android:fontFamily="sans-serif-condensed-medium"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
tools:text="Name"
|
||||||
|
android:textSize="32sp"
|
||||||
|
android:gravity="center"
|
||||||
|
android:textColor="?attr/colorOnSurface"/>
|
||||||
|
|
||||||
<androidx.appcompat.widget.AppCompatTextView
|
<androidx.appcompat.widget.AppCompatTextView
|
||||||
android:id="@+id/nameTextView"
|
android:id="@+id/hostTextView"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:fontFamily="sans-serif-condensed-medium"
|
android:fontFamily="sans-serif-condensed-medium"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toBottomOf="@id/nameTextView"
|
||||||
tools:text="Name"
|
tools:text="Address: Host"
|
||||||
android:textSize="32sp"
|
android:textSize="16sp"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:textColor="?attr/colorOnSurface"/>
|
android:textColor="?attr/colorOnSurface"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:ellipsize="end"/>
|
||||||
|
|
||||||
<androidx.appcompat.widget.AppCompatTextView
|
<androidx.appcompat.widget.AppCompatTextView
|
||||||
android:id="@+id/hostTextView"
|
android:id="@+id/idTextView"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:fontFamily="sans-serif-condensed-medium"
|
android:fontFamily="sans-serif-condensed-medium"
|
||||||
app:layout_constraintTop_toBottomOf="@id/nameTextView"
|
app:layout_constraintTop_toBottomOf="@id/hostTextView"
|
||||||
tools:text="Address: Host"
|
tools:text="ID: C0FFEE1337"
|
||||||
android:textSize="16sp"
|
android:textSize="16sp"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:textColor="?attr/colorOnSurface"
|
android:textColor="?attr/colorOnSurface"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
android:ellipsize="end"/>
|
android:ellipsize="end"/>
|
||||||
|
|
||||||
<androidx.appcompat.widget.AppCompatTextView
|
<ImageView
|
||||||
android:id="@+id/idTextView"
|
android:id="@+id/stateIndicatorImageView"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="0dp"
|
||||||
android:fontFamily="sans-serif-condensed-medium"
|
android:src="@drawable/ic_console"
|
||||||
app:layout_constraintTop_toBottomOf="@id/hostTextView"
|
app:layout_constraintTop_toBottomOf="@id/idTextView"
|
||||||
tools:text="ID: C0FFEE1337"
|
android:layout_marginLeft="32dp"
|
||||||
android:textSize="16sp"
|
android:layout_marginRight="32dp"
|
||||||
android:gravity="center"
|
android:layout_marginTop="8dp"/>
|
||||||
android:textColor="?attr/colorOnSurface"
|
|
||||||
android:maxLines="1"
|
|
||||||
android:ellipsize="end"/>
|
|
||||||
|
|
||||||
<ImageView
|
<androidx.appcompat.widget.AppCompatTextView
|
||||||
android:id="@+id/stateIndicatorImageView"
|
android:id="@+id/bottomInfoTextView"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="wrap_content"
|
||||||
android:src="@drawable/ic_console"
|
android:textColor="?attr/colorOnSurface"
|
||||||
app:layout_constraintTop_toBottomOf="@id/idTextView"
|
android:textSize="16sp"
|
||||||
android:layout_marginLeft="32dp"
|
android:fontFamily="sans-serif-condensed-light"
|
||||||
android:layout_marginRight="32dp"
|
android:gravity="center"
|
||||||
android:layout_marginTop="8dp"/>
|
tools:text="App: Persona 5\nTitle ID: 1337"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/stateIndicatorImageView"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
android:layout_marginBottom="8dp"
|
||||||
|
android:maxLines="2"
|
||||||
|
android:ellipsize="end"/>
|
||||||
|
|
||||||
<androidx.appcompat.widget.AppCompatTextView
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
android:id="@+id/bottomInfoTextView"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:textColor="?attr/colorOnSurface"
|
|
||||||
android:textSize="16sp"
|
|
||||||
android:fontFamily="sans-serif-condensed-light"
|
|
||||||
android:gravity="center"
|
|
||||||
tools:text="App: Persona 5\nTitle ID: 1337"
|
|
||||||
app:layout_constraintTop_toBottomOf="@id/stateIndicatorImageView"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
android:layout_marginBottom="8dp"
|
|
||||||
android:maxLines="2"
|
|
||||||
android:ellipsize="end"/>
|
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.cardview.widget.CardView>
|
||||||
|
|
||||||
</androidx.cardview.widget.CardView>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
Loading…
Add table
Add a link
Reference in a new issue