mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2026-04-04 15:06:08 +00:00
Added in a GUI to allow custom IP (because fuck MDNS)
This commit is contained in:
@@ -7,21 +7,59 @@ import org.xmlpull.v1.XmlPullParserException;
|
||||
import com.limelight.nvstream.NvConnection;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
import android.app.Activity;
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
public class Connection extends Activity {
|
||||
private Button statusButton;
|
||||
private TextView hostText;
|
||||
private SharedPreferences prefs;
|
||||
|
||||
private static final String DEFAULT_HOST = "141.213.191.238";
|
||||
public static final String HOST_KEY = "hostText";
|
||||
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
SharedPreferences.Editor editor = prefs.edit();
|
||||
|
||||
editor.putString(this.HOST_KEY, this.hostText.toString());
|
||||
editor.apply();
|
||||
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_connection);
|
||||
|
||||
new Thread(new Runnable() {
|
||||
|
||||
|
||||
this.statusButton = (Button) findViewById(R.id.statusButton);
|
||||
this.hostText = (TextView) findViewById(R.id.hostTextView);
|
||||
|
||||
prefs = getPreferences(0);
|
||||
this.hostText.setText(prefs.getString(this.HOST_KEY, this.DEFAULT_HOST));
|
||||
|
||||
this.statusButton.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void run() {
|
||||
public void onClick(View arg0) {
|
||||
try {
|
||||
new NvConnection("141.213.191.238").doShit();
|
||||
new NvConnection(Connection.this.statusButton.getText().toString()).doShit();
|
||||
} catch (XmlPullParserException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
@@ -31,7 +69,7 @@ public class Connection extends Activity {
|
||||
}
|
||||
}
|
||||
|
||||
}).start();
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
27
src/com/limelight/nvstream/NvMDNS.java
Normal file
27
src/com/limelight/nvstream/NvMDNS.java
Normal file
@@ -0,0 +1,27 @@
|
||||
package com.limelight.nvstream;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
public class NvMDNS {
|
||||
|
||||
|
||||
|
||||
public static String NVSTREAM_MDNS_QUERY = "_nvstream._tcp.local.";
|
||||
public static final short MDNS_PORT = 5353;
|
||||
public static final int REPLY_TIMEOUT = 3000;
|
||||
public static final int REPLY_TRIES = 10;
|
||||
public static InetAddress MDNS_ADDRESS;
|
||||
|
||||
static {
|
||||
try {
|
||||
// 224.0.0.251 is the mDNS multicast address
|
||||
MDNS_ADDRESS = InetAddress.getByName("224.0.0.251");
|
||||
} catch (UnknownHostException e) {
|
||||
MDNS_ADDRESS = null;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Implement this shit
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user