Fix toolbar issues: setSupportActionBar in Editor and Settings

- Add toolbar setup in NoteEditorActivity
- Add toolbar setup in SettingsActivity
- Add toolbar to activity_settings.xml layout
- Fix back button and menu display issues
This commit is contained in:
inventory69
2025-12-20 01:12:44 +01:00
parent 0ef50d5d5a
commit 61ff005477
3 changed files with 142 additions and 120 deletions

View File

@@ -5,12 +5,13 @@ import android.view.Menu
import android.view.MenuItem import android.view.MenuItem
import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import com.google.android.material.appbar.MaterialToolbar
import com.google.android.material.textfield.TextInputEditText
import dev.dettmer.simplenotes.models.Note import dev.dettmer.simplenotes.models.Note
import dev.dettmer.simplenotes.models.SyncStatus import dev.dettmer.simplenotes.models.SyncStatus
import dev.dettmer.simplenotes.storage.NotesStorage import dev.dettmer.simplenotes.storage.NotesStorage
import dev.dettmer.simplenotes.utils.DeviceIdGenerator import dev.dettmer.simplenotes.utils.DeviceIdGenerator
import dev.dettmer.simplenotes.utils.showToast import dev.dettmer.simplenotes.utils.showToast
import com.google.android.material.textfield.TextInputEditText
class NoteEditorActivity : AppCompatActivity() { class NoteEditorActivity : AppCompatActivity() {
@@ -31,6 +32,8 @@ class NoteEditorActivity : AppCompatActivity() {
storage = NotesStorage(this) storage = NotesStorage(this)
// Setup toolbar // Setup toolbar
val toolbar = findViewById<MaterialToolbar>(R.id.toolbar)
setSupportActionBar(toolbar)
supportActionBar?.apply { supportActionBar?.apply {
setDisplayHomeAsUpEnabled(true) setDisplayHomeAsUpEnabled(true)
setHomeAsUpIndicator(android.R.drawable.ic_menu_close_clear_cancel) setHomeAsUpIndicator(android.R.drawable.ic_menu_close_clear_cancel)

View File

@@ -8,6 +8,7 @@ import android.widget.EditText
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.widget.SwitchCompat import androidx.appcompat.widget.SwitchCompat
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
import com.google.android.material.appbar.MaterialToolbar
import dev.dettmer.simplenotes.sync.WebDavSyncService import dev.dettmer.simplenotes.sync.WebDavSyncService
import dev.dettmer.simplenotes.utils.Constants import dev.dettmer.simplenotes.utils.Constants
import dev.dettmer.simplenotes.utils.showToast import dev.dettmer.simplenotes.utils.showToast
@@ -32,6 +33,9 @@ class SettingsActivity : AppCompatActivity() {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
setContentView(R.layout.activity_settings) setContentView(R.layout.activity_settings)
// Setup toolbar
val toolbar = findViewById<MaterialToolbar>(R.id.toolbar)
setSupportActionBar(toolbar)
supportActionBar?.apply { supportActionBar?.apply {
setDisplayHomeAsUpEnabled(true) setDisplayHomeAsUpEnabled(true)
title = "Einstellungen" title = "Einstellungen"

View File

@@ -1,150 +1,165 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<ScrollView <LinearLayout
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"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout <com.google.android.material.appbar.MaterialToolbar
android:id="@+id/toolbar"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="?attr/actionBarSize"
android:orientation="vertical" app:title="@string/settings"
android:padding="16dp"> app:navigationIcon="?attr/homeAsUpIndicator" />
<!-- Server Settings --> <ScrollView
<TextView android:layout_width="match_parent"
android:layout_width="match_parent" android:layout_height="0dp"
android:layout_height="wrap_content" android:layout_weight="1">
android:text="@string/server_settings"
android:textSize="18sp"
android:textStyle="bold"
android:layout_marginBottom="16dp" />
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/server_url"
android:layout_marginBottom="8dp"
style="@style/Widget.Material3.TextInputLayout.OutlinedBox">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/editTextServerUrl"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textUri" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/username"
android:layout_marginBottom="8dp"
style="@style/Widget.Material3.TextInputLayout.OutlinedBox">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/editTextUsername"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/password"
android:layout_marginBottom="16dp"
style="@style/Widget.Material3.TextInputLayout.OutlinedBox"
app:endIconMode="password_toggle">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/editTextPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPassword" />
</com.google.android.material.textfield.TextInputLayout>
<!-- WiFi Settings -->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/wifi_settings"
android:textSize="18sp"
android:textStyle="bold"
android:layout_marginTop="16dp"
android:layout_marginBottom="16dp" />
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal" android:orientation="vertical"
android:layout_marginBottom="8dp"> android:padding="16dp">
<!-- Server Settings -->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/server_settings"
android:textSize="18sp"
android:textStyle="bold"
android:layout_marginBottom="16dp" />
<com.google.android.material.textfield.TextInputLayout <com.google.android.material.textfield.TextInputLayout
android:layout_width="0dp" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:hint="@string/server_url"
android:hint="@string/home_ssid" android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
style="@style/Widget.Material3.TextInputLayout.OutlinedBox"> style="@style/Widget.Material3.TextInputLayout.OutlinedBox">
<com.google.android.material.textfield.TextInputEditText <com.google.android.material.textfield.TextInputEditText
android:id="@+id/editTextHomeSSID" android:id="@+id/editTextServerUrl"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textUri" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/username"
android:layout_marginBottom="8dp"
style="@style/Widget.Material3.TextInputLayout.OutlinedBox">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/editTextUsername"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:inputType="text" /> android:inputType="text" />
</com.google.android.material.textfield.TextInputLayout> </com.google.android.material.textfield.TextInputLayout>
<Button <com.google.android.material.textfield.TextInputLayout
android:id="@+id/buttonDetectSSID" android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:hint="@string/password"
android:text="Detect" android:layout_marginBottom="16dp"
style="@style/Widget.Material3.TextInputLayout.OutlinedBox"
app:endIconMode="password_toggle">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/editTextPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPassword" />
</com.google.android.material.textfield.TextInputLayout>
<!-- WiFi Settings -->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/wifi_settings"
android:textSize="18sp"
android:textStyle="bold"
android:layout_marginTop="16dp"
android:layout_marginBottom="16dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginBottom="8dp">
<com.google.android.material.textfield.TextInputLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="@string/home_ssid"
android:layout_marginEnd="8dp"
style="@style/Widget.Material3.TextInputLayout.OutlinedBox">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/editTextHomeSSID"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text" />
</com.google.android.material.textfield.TextInputLayout>
<Button
android:id="@+id/buttonDetectSSID"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="Detect"
style="@style/Widget.Material3.Button.OutlinedButton" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginBottom="16dp">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/auto_sync"
android:textSize="16sp"
android:layout_gravity="center_vertical" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/switchAutoSync"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<!-- Actions -->
<Button
android:id="@+id/buttonTestConnection"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/test_connection"
android:layout_marginTop="8dp"
style="@style/Widget.Material3.Button.OutlinedButton" /> style="@style/Widget.Material3.Button.OutlinedButton" />
</LinearLayout> <Button
android:id="@+id/buttonSyncNow"
<LinearLayout android:layout_width="match_parent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginBottom="16dp">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:text="@string/sync_now"
android:text="@string/auto_sync" android:layout_marginTop="8dp" />
android:textSize="16sp"
android:layout_gravity="center_vertical" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/switchAutoSync"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout> </LinearLayout>
<!-- Actions --> </ScrollView>
<Button
android:id="@+id/buttonTestConnection"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/test_connection"
android:layout_marginTop="8dp"
style="@style/Widget.Material3.Button.OutlinedButton" />
<Button </LinearLayout>
android:id="@+id/buttonSyncNow"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/sync_now"
android:layout_marginTop="8dp" />
</LinearLayout>
</ScrollView>