mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-02-06 05:42:40 -05:00
show connection status in appbar
This commit is contained in:
@@ -21,8 +21,8 @@ import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.app.ActivityCompat
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.lifecycle.Observer
|
||||
import androidx.viewpager2.adapter.FragmentStateAdapter
|
||||
import androidx.viewpager2.widget.ViewPager2
|
||||
import com.geeksville.android.Logging
|
||||
import com.geeksville.android.ServiceClient
|
||||
import com.geeksville.mesh.model.TextMessage
|
||||
@@ -35,8 +35,8 @@ import com.geeksville.util.exceptionReporter
|
||||
import com.google.android.gms.auth.api.signin.GoogleSignIn
|
||||
import com.google.android.gms.auth.api.signin.GoogleSignInAccount
|
||||
import com.google.android.gms.tasks.Task
|
||||
import com.google.android.material.tabs.TabLayout
|
||||
import com.google.android.material.tabs.TabLayoutMediator
|
||||
import kotlinx.android.synthetic.main.activity_main.*
|
||||
import java.nio.charset.Charset
|
||||
|
||||
/*
|
||||
@@ -280,8 +280,6 @@ class MainActivity : AppCompatActivity(), Logging,
|
||||
} */
|
||||
setContentView(R.layout.activity_main)
|
||||
|
||||
val tab_layout = findViewById<TabLayout>(R.id.tab_layout)
|
||||
val pager = findViewById<ViewPager2>(R.id.pager)
|
||||
pager.adapter = tabsAdapter
|
||||
pager.isUserInputEnabled =
|
||||
false // Gestures for screen switching doesn't work so good with the map view
|
||||
@@ -289,6 +287,12 @@ class MainActivity : AppCompatActivity(), Logging,
|
||||
// tab.text = tabInfos[position].text // I think it looks better with icons only
|
||||
tab.icon = getDrawable(tabInfos[position].icon)
|
||||
}.attach()
|
||||
|
||||
model.isConnected.observe(this, Observer { connected ->
|
||||
val image =
|
||||
if (connected != MeshService.ConnectionState.DISCONNECTED) R.drawable.cloud_on else R.drawable.cloud_off
|
||||
connectStatusImage.setImageDrawable(getDrawable(image))
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.geeksville.mesh.ui
|
||||
|
||||
import android.content.Intent
|
||||
import android.graphics.drawable.BitmapDrawable
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
@@ -68,9 +67,8 @@ class ChannelFragment : ScreenFragment("Channel"), Logging {
|
||||
channelNameEdit.visibility = View.VISIBLE
|
||||
channelNameEdit.setText(channel.name)
|
||||
editableCheckbox.isEnabled = true
|
||||
|
||||
val d = BitmapDrawable(resources, channel.getChannelQR())
|
||||
qrView.setImageDrawable(d)
|
||||
|
||||
qrView.setImageBitmap(channel.getChannelQR())
|
||||
// Share this particular channel if someone clicks share
|
||||
shareButton.setOnClickListener {
|
||||
GeeksvilleApplication.analytics.track(
|
||||
|
||||
@@ -11,15 +11,53 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:theme="@style/AppTheme.AppBarOverlay">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:minHeight="?actionBarSize"
|
||||
android:padding="16dp"
|
||||
android:text="@string/app_name"
|
||||
android:textAppearance="@style/TextAppearance.Widget.AppCompat.Toolbar.Title" />
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageView4"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:contentDescription="@string/application_icon"
|
||||
android:scaleType="center"
|
||||
android:scaleX="1.5"
|
||||
android:scaleY="1.5"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:srcCompat="@drawable/ic_baseline_settings_input_antenna_24" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:gravity="center"
|
||||
android:minHeight="?actionBarSize"
|
||||
android:padding="16dp"
|
||||
android:text="@string/app_name"
|
||||
android:textAppearance="@style/TextAppearance.Widget.AppCompat.Toolbar.Title"
|
||||
app:layout_constraintStart_toEndOf="@+id/imageView4"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/connectStatusImage"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_weight="1"
|
||||
android:backgroundTint="#FFFFFFFF"
|
||||
|
||||
android:contentDescription="@string/connection_status"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
|
||||
app:layout_constraintHeight_percent=".5"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:srcCompat="@drawable/cloud_off" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<com.google.android.material.tabs.TabLayout
|
||||
android:id="@+id/tab_layout"
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
android:layout_marginStart="64dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="64dp"
|
||||
android:hint="Channel Name"
|
||||
android:hint="@string/channel_name"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
@@ -21,8 +21,8 @@
|
||||
android:id="@+id/channelNameEdit"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="channel name"
|
||||
android:text="Unset" />
|
||||
android:hint="@string/channel_name"
|
||||
android:text="@string/unset" />
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<ImageView
|
||||
@@ -32,7 +32,7 @@
|
||||
android:layout_marginStart="96dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginEnd="96dp"
|
||||
android:contentDescription="QR code"
|
||||
android:contentDescription="@string/qr_code"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/channelNameView"
|
||||
@@ -86,7 +86,7 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="96dp"
|
||||
android:contentDescription="Share button"
|
||||
android:contentDescription="@string/share_button"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@+id/editableCheckbox"
|
||||
app:srcCompat="@drawable/ic_twotone_share_24" />
|
||||
@@ -98,7 +98,7 @@
|
||||
android:layout_marginStart="64dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginEnd="64dp"
|
||||
android:hint="Channel options"
|
||||
android:hint="@string/channel_options"
|
||||
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
@@ -107,7 +107,8 @@
|
||||
<AutoCompleteTextView
|
||||
android:id="@+id/filled_exposed_dropdown"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/channel_options" />
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -1,4 +1,11 @@
|
||||
<resources>
|
||||
<string name="app_name">Meshtastic</string>
|
||||
<string name="action_settings">Settings</string>
|
||||
<string name="channel_name">Channel Name</string>
|
||||
<string name="channel_options">Channel options</string>
|
||||
<string name="share_button">Share button</string>
|
||||
<string name="qr_code">QR code</string>
|
||||
<string name="unset">Unset</string>
|
||||
<string name="connection_status">Connection status</string>
|
||||
<string name="application_icon">application icon</string>
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user