mirror of
https://git.sr.ht/~thestr4ng3r/chiaki
synced 2025-08-13 02:06:51 -07:00
Add more Empty Infos on Android
This commit is contained in:
parent
7b8cf9cec0
commit
2ed1961c3f
5 changed files with 84 additions and 0 deletions
android/app/src/main
java/com/metallic/chiaki
res
|
@ -22,6 +22,7 @@ import android.content.Intent
|
|||
import android.os.Bundle
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.lifecycle.Observer
|
||||
import androidx.lifecycle.ViewModelProviders
|
||||
|
@ -78,13 +79,28 @@ class MainActivity : AppCompatActivity()
|
|||
recyclerViewAdapter.hosts = it
|
||||
if(top)
|
||||
hostsRecyclerView.scrollToPosition(0)
|
||||
updateEmptyInfo()
|
||||
})
|
||||
|
||||
viewModel.discoveryActive.observe(this, Observer { active ->
|
||||
discoveryMenuItem?.let { updateDiscoveryMenuItem(it, active) }
|
||||
updateEmptyInfo()
|
||||
})
|
||||
}
|
||||
|
||||
private fun updateEmptyInfo()
|
||||
{
|
||||
if(viewModel.displayHosts.value?.isEmpty() ?: true)
|
||||
{
|
||||
emptyInfoLayout.visibility = View.VISIBLE
|
||||
val discoveryActive = viewModel.discoveryActive.value ?: false
|
||||
emptyInfoImageView.setImageResource(if(discoveryActive) R.drawable.ic_discover_on else R.drawable.ic_discover_off)
|
||||
emptyInfoTextView.setText(if(discoveryActive) R.string.display_hosts_empty_discovery_on_info else R.string.display_hosts_empty_discovery_off_info)
|
||||
}
|
||||
else
|
||||
emptyInfoLayout.visibility = View.GONE
|
||||
}
|
||||
|
||||
private fun expandFloatingActionButton(expand: Boolean)
|
||||
{
|
||||
floatingActionButton.isExpanded = expand
|
||||
|
|
|
@ -75,6 +75,7 @@ class SettingsRegisteredHostsFragment: AppCompatDialogFragment(), TitleFragment
|
|||
ItemTouchHelper(itemTouchSwipeCallback).attachToRecyclerView(hostsRecyclerView)
|
||||
viewModel.registeredHosts.observe(this, Observer {
|
||||
adapter.hosts = it
|
||||
emptyInfoGroup.visibility = if(it.isEmpty()) View.VISIBLE else View.GONE
|
||||
})
|
||||
|
||||
floatingActionButton.setOnClickListener {
|
||||
|
|
|
@ -16,6 +16,40 @@
|
|||
android:clipChildren="false"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/emptyInfoLayout"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center_horizontal">
|
||||
<ImageView
|
||||
android:id="@+id/emptyInfoImageView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/ic_discover_off"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toTopOf="@id/emptyInfoTextView"
|
||||
app:layout_constraintVertical_chainStyle="packed"
|
||||
android:alpha="0.5"/>
|
||||
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/emptyInfoTextView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:fontFamily="sans-serif-condensed"
|
||||
android:text="@string/display_hosts_empty_discovery_off_info"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/emptyInfoImageView"
|
||||
android:gravity="center_horizontal"
|
||||
android:maxWidth="300dp"/>
|
||||
</LinearLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/floatingActionButtonDialBackground"
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -22,4 +22,34 @@
|
|||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/emptyInfoImageView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/ic_console_simple"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toTopOf="@id/emptyInfoTextView"
|
||||
app:layout_constraintVertical_chainStyle="packed"
|
||||
android:alpha="0.5"/>
|
||||
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/emptyInfoTextView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:fontFamily="sans-serif-condensed"
|
||||
android:text="@string/registered_hosts_empty_info"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/emptyInfoImageView" />
|
||||
|
||||
<androidx.constraintlayout.widget.Group
|
||||
android:id="@+id/emptyInfoGroup"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:constraint_referenced_ids="emptyInfoImageView,emptyInfoTextView"/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
|
|
@ -75,6 +75,9 @@
|
|||
<string name="action_delete">Delete</string>
|
||||
<string name="action_edit">Edit</string>
|
||||
<string name="session_logs_empty_info">No Session Logs recorded.</string>
|
||||
<string name="registered_hosts_empty_info">No Consoles registered.</string>
|
||||
<string name="display_hosts_empty_discovery_off_info">No consoles added yet.\nEnable Discovery to automatically find consoles on your local network.</string>
|
||||
<string name="display_hosts_empty_discovery_on_info">No consoles added or discovered.</string>
|
||||
|
||||
<!-- Don't localize these -->
|
||||
<string name="preferences_discovery_enabled_key">discovery_enabled</string>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue