Merge branch 'android_network_address' of https://github.com/DDRBoxman/MPD
This commit is contained in:
commit
59ed18e112
@ -1,6 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="org.musicpd"
|
|
||||||
android:installLocation="auto"
|
android:installLocation="auto"
|
||||||
android:versionCode="73"
|
android:versionCode="73"
|
||||||
android:versionName="0.23.15">
|
android:versionName="0.23.15">
|
||||||
@ -12,6 +11,7 @@
|
|||||||
android:name="android.hardware.touchscreen"
|
android:name="android.hardware.touchscreen"
|
||||||
android:required="false" />
|
android:required="false" />
|
||||||
|
|
||||||
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
|
31
android/app/src/main/java/org/musicpd/NetworkUtil.java
Normal file
31
android/app/src/main/java/org/musicpd/NetworkUtil.java
Normal file
@ -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<LinkAddress> 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;
|
||||||
|
}
|
||||||
|
}
|
@ -213,6 +213,10 @@ public class Settings extends Activity {
|
|||||||
if (Preferences.getBoolean(this, Preferences.KEY_PAUSE_ON_HEADPHONES_DISCONNECT, false))
|
if (Preferences.getBoolean(this, Preferences.KEY_PAUSE_ON_HEADPHONES_DISCONNECT, false))
|
||||||
checkbox.setChecked(true);
|
checkbox.setChecked(true);
|
||||||
|
|
||||||
|
TextView networkAddressTextView = (TextView) findViewById(R.id.networkAddress);
|
||||||
|
String deviceIPV4Address = NetworkUtil.getDeviceIPV4Address(this);
|
||||||
|
networkAddressTextView.setText(deviceIPV4Address);
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
5
android/app/src/main/res/drawable/baseline_wifi_24.xml
Normal file
5
android/app/src/main/res/drawable/baseline_wifi_24.xml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<vector android:height="24dp" android:tint="#000000"
|
||||||
|
android:viewportHeight="24" android:viewportWidth="24"
|
||||||
|
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<path android:fillColor="@android:color/white" android:pathData="M1,9l2,2c4.97,-4.97 13.03,-4.97 18,0l2,-2C16.93,2.93 7.08,2.93 1,9zM9,17l3,3 3,-3c-1.65,-1.66 -4.34,-1.66 -6,0zM5,13l2,2c2.76,-2.76 7.24,-2.76 10,0l2,-2C15.14,9.14 8.87,9.14 5,13z"/>
|
||||||
|
</vector>
|
@ -4,12 +4,34 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center_vertical">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:scaleType="center"
|
||||||
|
android:src="@drawable/baseline_wifi_24"
|
||||||
|
android:layout_margin="4dp"/>
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.AppCompatTextView
|
||||||
|
android:id="@+id/networkAddress"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginRight="24sp"
|
||||||
|
android:gravity="center"
|
||||||
|
android:padding="4dp"
|
||||||
|
android:textSize="24sp" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<ToggleButton
|
<ToggleButton
|
||||||
android:id="@+id/run"
|
android:id="@+id/run"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textOn="@string/toggle_button_run_on"
|
android:textOff="@string/toggle_button_run_off"
|
||||||
android:textOff="@string/toggle_button_run_off" />
|
android:textOn="@string/toggle_button_run_on" />
|
||||||
|
|
||||||
<CheckBox
|
<CheckBox
|
||||||
android:id="@+id/run_on_boot"
|
android:id="@+id/run_on_boot"
|
||||||
|
Loading…
Reference in New Issue
Block a user