diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index d35d06883..7dc120a0f 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -1,6 +1,5 @@ @@ -12,6 +11,7 @@ android:name="android.hardware.touchscreen" android:required="false" /> + diff --git a/android/app/src/main/java/org/musicpd/NetworkUtil.java b/android/app/src/main/java/org/musicpd/NetworkUtil.java new file mode 100644 index 000000000..2579f2d51 --- /dev/null +++ b/android/app/src/main/java/org/musicpd/NetworkUtil.java @@ -0,0 +1,31 @@ +package org.musicpd; + +import android.content.Context; +import android.net.ConnectivityManager; +import android.net.LinkAddress; +import android.net.LinkProperties; + +import java.net.Inet4Address; +import java.net.InetAddress; +import java.util.List; + +public class NetworkUtil { + + public static String getDeviceIPV4Address(Context context) { + ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); + LinkProperties linkProperties = connectivityManager.getLinkProperties(connectivityManager.getActiveNetwork()); + if (linkProperties != null) { + List linkAddresses = linkProperties.getLinkAddresses(); + for (LinkAddress address : linkAddresses) { + if (!address.getAddress().isLinkLocalAddress() && !address.getAddress().isLoopbackAddress()) { + InetAddress address1 = address.getAddress(); + if (address1 instanceof Inet4Address) { + return address1.getHostAddress(); + } + } + } + } + + return null; + } +} diff --git a/android/app/src/main/java/org/musicpd/Settings.java b/android/app/src/main/java/org/musicpd/Settings.java index 246cd4657..c0c00b9ac 100644 --- a/android/app/src/main/java/org/musicpd/Settings.java +++ b/android/app/src/main/java/org/musicpd/Settings.java @@ -213,6 +213,10 @@ public class Settings extends Activity { if (Preferences.getBoolean(this, Preferences.KEY_PAUSE_ON_HEADPHONES_DISCONNECT, false)) checkbox.setChecked(true); + TextView networkAddressTextView = (TextView) findViewById(R.id.networkAddress); + String deviceIPV4Address = NetworkUtil.getDeviceIPV4Address(this); + networkAddressTextView.setText(deviceIPV4Address); + super.onCreate(savedInstanceState); } diff --git a/android/app/src/main/res/drawable/baseline_wifi_24.xml b/android/app/src/main/res/drawable/baseline_wifi_24.xml new file mode 100644 index 000000000..dabd1f1be --- /dev/null +++ b/android/app/src/main/res/drawable/baseline_wifi_24.xml @@ -0,0 +1,5 @@ + + + diff --git a/android/app/src/main/res/layout/settings.xml b/android/app/src/main/res/layout/settings.xml index 3b0a103c3..c7c6c400b 100644 --- a/android/app/src/main/res/layout/settings.xml +++ b/android/app/src/main/res/layout/settings.xml @@ -2,14 +2,36 @@ + android:orientation="vertical"> + + + + + + + + android:textOff="@string/toggle_button_run_off" + android:textOn="@string/toggle_button_run_on" /> + android:id="@+id/log_list" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:paddingTop="10dip" />