Add hamburger menu that opens the About screen
This commit is contained in:
@@ -44,6 +44,10 @@
|
||||
android:name=".PhotoViewActivity"
|
||||
android:exported="false"
|
||||
android:label="@string/title_photo_view" />
|
||||
</application>
|
||||
<activity
|
||||
android:name=".AboutActivity"
|
||||
android:exported="false"
|
||||
android:theme="@style/Theme.AndPictures" />
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
|
||||
34
app/src/main/java/com/bm/andpictures/AboutActivity.kt
Normal file
34
app/src/main/java/com/bm/andpictures/AboutActivity.kt
Normal file
@@ -0,0 +1,34 @@
|
||||
package com.bm.andpictures
|
||||
|
||||
import android.os.Bundle
|
||||
import android.widget.TextView
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
|
||||
/** Shows the app icon, name and version. Reached from the main screen's hamburger. */
|
||||
class AboutActivity : AppCompatActivity() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_about)
|
||||
|
||||
// The activity theme is DarkActionBar, so the built-in action bar is
|
||||
// already there — no second toolbar needed, just the up arrow.
|
||||
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
||||
|
||||
findViewById<TextView>(R.id.versionText).text =
|
||||
"Version " + BuildInfo.versionName(this)
|
||||
|
||||
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
|
||||
val bars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
|
||||
v.setPadding(bars.left, bars.top, bars.right, bars.bottom)
|
||||
insets
|
||||
}
|
||||
}
|
||||
|
||||
override fun onSupportNavigateUp(): Boolean {
|
||||
finish()
|
||||
return true
|
||||
}
|
||||
}
|
||||
13
app/src/main/java/com/bm/andpictures/BuildInfo.kt
Normal file
13
app/src/main/java/com/bm/andpictures/BuildInfo.kt
Normal file
@@ -0,0 +1,13 @@
|
||||
package com.bm.andpictures
|
||||
|
||||
import android.content.Context
|
||||
|
||||
/** Version string for the About screen, kept in one place. */
|
||||
object BuildInfo {
|
||||
fun versionName(context: Context): String = try {
|
||||
@Suppress("DEPRECATION")
|
||||
context.packageManager.getPackageInfo(context.packageName, 0).versionName ?: "unknown"
|
||||
} catch (e: Exception) {
|
||||
"unknown"
|
||||
}
|
||||
}
|
||||
@@ -52,6 +52,12 @@ class MainActivity : AppCompatActivity() {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_main)
|
||||
bindViews()
|
||||
|
||||
// Hamburger menu → About. The framework action bar is already present
|
||||
// (theme is DarkActionBar), so just dress it with the menu icon.
|
||||
supportActionBar?.setHomeAsUpIndicator(R.drawable.ic_hamburger)
|
||||
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
||||
|
||||
populate()
|
||||
requestNotificationPermissionIfNeeded()
|
||||
|
||||
@@ -70,6 +76,12 @@ class MainActivity : AppCompatActivity() {
|
||||
refreshStatus()
|
||||
}
|
||||
|
||||
/** The hamburger is the action bar's "home" affordance: it opens About. */
|
||||
override fun onSupportNavigateUp(): Boolean {
|
||||
startActivity(Intent(this, AboutActivity::class.java))
|
||||
return true
|
||||
}
|
||||
|
||||
private fun bindViews() {
|
||||
statusText = findViewById(R.id.statusText)
|
||||
lastSyncText = findViewById(R.id.lastSyncText)
|
||||
|
||||
19
app/src/main/res/drawable/ic_hamburger.xml
Normal file
19
app/src/main/res/drawable/ic_hamburger.xml
Normal file
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Three bars, the conventional "menu" affordance. White so it reads on the
|
||||
brand-blue toolbar; drawn on a 24dp grid to match the other action icons. -->
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
android:tint="@android:color/white">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M3,6h18v2h-18z" />
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M3,11h18v2h-18z" />
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M3,16h18v2h-18z" />
|
||||
</vector>
|
||||
55
app/src/main/res/layout/activity_about.xml
Normal file
55
app/src/main/res/layout/activity_about.xml
Normal file
@@ -0,0 +1,55 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- No toolbar here: the activity theme (DarkActionBar) supplies the action bar,
|
||||
so the layout is just the content. -->
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/main"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fillViewport="true">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center_horizontal"
|
||||
android:padding="32dp">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="120dp"
|
||||
android:layout_marginTop="24dp"
|
||||
android:src="@mipmap/ic_launcher"
|
||||
android:contentDescription="@string/app_name" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="24dp"
|
||||
android:text="@string/app_name"
|
||||
android:textSize="24sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/versionText"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="Version"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="32dp"
|
||||
android:gravity="center"
|
||||
android:text="@string/about_blurb"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="32dp"
|
||||
android:text="@string/about_copyright"
|
||||
android:textSize="14sp" />
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
@@ -11,4 +11,7 @@
|
||||
<string name="title_file_browser">Files</string>
|
||||
<string name="title_photo_view">Photo</string>
|
||||
<string name="photo_view_failed">Could not load this photo.</string>
|
||||
<string name="about_title">About</string>
|
||||
<string name="about_copyright">© 2026 UmbraTools</string>
|
||||
<string name="about_blurb">Copies new photos from the phone to the NAS over SMB whenever you are on the home network, filed by decade / year / month.</string>
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user