Skip to content

Commit

Permalink
android: Move settings to compose and material UI 3
Browse files Browse the repository at this point in the history
This changes lets us use the latest UI design from Google, Material 3.

Google only provides the material UI 3 themes for compose, compose only works with kotlin.
  • Loading branch information
DDRBoxman committed Dec 23, 2023
1 parent 625ab6d commit 8bc5420
Show file tree
Hide file tree
Showing 12 changed files with 407 additions and 339 deletions.
7 changes: 7 additions & 0 deletions android/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ dependencies {

implementation("androidx.compose.material3:material3")
implementation("androidx.activity:activity-compose:1.8.2")
implementation("androidx.compose.material:material-icons-extended")
implementation("androidx.lifecycle:lifecycle-viewmodel-compose:2.6.2")
implementation("androidx.lifecycle:lifecycle-runtime-compose:2.6.2")

implementation("com.github.alorma:compose-settings-ui-m3:1.0.3")
implementation("com.github.alorma:compose-settings-storage-preferences:1.0.3")
implementation("com.google.accompanist:accompanist-permissions:0.33.2-alpha")

// Android Studio Preview support
implementation("androidx.compose.ui:ui-tooling-preview")
Expand Down
7 changes: 5 additions & 2 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,19 @@
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:requestLegacyExternalStorage="true"
android:roundIcon="@mipmap/ic_launcher_round">
android:roundIcon="@mipmap/ic_launcher_round"
android:theme="@style/Theme.MPD">
<activity
android:name=".Settings"
android:name=".ui.SettingsActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LEANBACK_LAUNCHER" />
</intent-filter>
</activity>
Expand Down
3 changes: 3 additions & 0 deletions android/app/src/main/java/org/musicpd/NetworkUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@
import android.net.LinkAddress;
import android.net.LinkProperties;

import androidx.annotation.Nullable;

import java.net.Inet4Address;
import java.net.InetAddress;
import java.util.List;

public class NetworkUtil {

@Nullable
public static String getDeviceIPV4Address(Context context) {
ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
LinkProperties linkProperties = connectivityManager.getLinkProperties(connectivityManager.getActiveNetwork());
Expand Down
267 changes: 0 additions & 267 deletions android/app/src/main/java/org/musicpd/Settings.java

This file was deleted.

39 changes: 39 additions & 0 deletions android/app/src/main/java/org/musicpd/ui/NetworkAddress.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package org.musicpd.ui

import android.app.Application
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Wifi
import androidx.compose.material3.Icon
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.unit.dp
import org.musicpd.NetworkUtil

@Composable
fun NetworkAddress() {
val address = NetworkUtil.getDeviceIPV4Address(LocalContext.current)
val padding = 4.dp
Row(
Modifier
.padding(padding)
.fillMaxWidth(),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.Center
) {
Icon(
imageVector = Icons.Default.Wifi,
contentDescription = "Wifi")
Spacer(Modifier.size(padding))
Text(text = address ?: "")
}
}

Loading

0 comments on commit 8bc5420

Please sign in to comment.