mirror of
https://github.com/rfc2822/GfxTablet
synced 2025-10-03 09:39:16 +02:00
* Added "About" action bar item
* Default hostname is invalid so that widget will be disabled with a warning by default until a host is set * Bug fix when sending resolution to X server
This commit is contained in:
parent
f7fe39c657
commit
410516a7da
5 changed files with 19 additions and 17 deletions
|
@ -5,4 +5,9 @@
|
||||||
android:showAsAction="ifRoom"
|
android:showAsAction="ifRoom"
|
||||||
android:title="@string/menu_settings" android:onClick="showSettings"/>
|
android:title="@string/menu_settings" android:onClick="showSettings"/>
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:orderInCategory="100"
|
||||||
|
android:showAsAction="never"
|
||||||
|
android:title="@string/menu_about" android:onClick="showAbout"/>
|
||||||
|
|
||||||
</menu>
|
</menu>
|
|
@ -5,5 +5,6 @@
|
||||||
<string name="menu_settings">Settings</string>
|
<string name="menu_settings">Settings</string>
|
||||||
<string name="preferences_host_title">X.org host</string>
|
<string name="preferences_host_title">X.org host</string>
|
||||||
<string name="stylus_preference">Sense stylus only</string>
|
<string name="stylus_preference">Sense stylus only</string>
|
||||||
|
<string name="menu_about">About</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
|
@ -1,4 +1,4 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||||
<EditTextPreference android:title="@string/preferences_host_title" android:key="host_preference" android:defaultValue="127.0.0.1" android:singleLine="true"/>
|
<EditTextPreference android:title="@string/preferences_host_title" android:key="host_preference" android:defaultValue="please-replace.invalid" android:singleLine="true"/>
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.gimpusers.xorgtablet;
|
package com.gimpusers.xorgtablet;
|
||||||
|
|
||||||
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
@ -44,6 +45,10 @@ public class CanvasActivity extends Activity {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void showAbout(MenuItem item) {
|
||||||
|
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(("https://github.com/rfc2822/XorgTablet"))));
|
||||||
|
}
|
||||||
|
|
||||||
public void showSettings(MenuItem item) {
|
public void showSettings(MenuItem item) {
|
||||||
startActivity(new Intent(CanvasActivity.this, SettingsActivity.class));
|
startActivity(new Intent(CanvasActivity.this, SettingsActivity.class));
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,27 +2,16 @@ package com.gimpusers.xorgtablet;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.OutputStreamWriter;
|
|
||||||
import java.net.DatagramPacket;
|
import java.net.DatagramPacket;
|
||||||
import java.net.DatagramSocket;
|
import java.net.DatagramSocket;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.SocketException;
|
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
import java.util.concurrent.LinkedBlockingQueue;
|
import java.util.concurrent.LinkedBlockingQueue;
|
||||||
|
|
||||||
import android.app.Service;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.Binder;
|
|
||||||
import android.os.IBinder;
|
|
||||||
import android.preference.PreferenceManager;
|
|
||||||
import android.provider.ContactsContract.Contacts.Data;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.MotionEvent;
|
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
// see protocol.h in xf86-networktablet driver for details about the protocol
|
// see xf86-networktablet on Github for details about the protocol
|
||||||
|
|
||||||
|
|
||||||
public class XorgClient implements Runnable {
|
public class XorgClient implements Runnable {
|
||||||
|
@ -39,7 +28,7 @@ public class XorgClient implements Runnable {
|
||||||
|
|
||||||
boolean configureNetworking() {
|
boolean configureNetworking() {
|
||||||
try {
|
try {
|
||||||
String hostName = preferences.getString(SettingsActivity.KEY_PREF_HOST, "127.0.0.1");
|
String hostName = preferences.getString(SettingsActivity.KEY_PREF_HOST, "unknown.invalid");
|
||||||
destAddress = InetAddress.getByName(hostName);
|
destAddress = InetAddress.getByName(hostName);
|
||||||
|
|
||||||
if (lastConfiguration != null)
|
if (lastConfiguration != null)
|
||||||
|
@ -63,14 +52,16 @@ public class XorgClient implements Runnable {
|
||||||
while (true) {
|
while (true) {
|
||||||
XEvent event = motionQueue.take();
|
XEvent event = motionQueue.take();
|
||||||
|
|
||||||
if (destAddress == null)
|
// save resolution, even if not sending it
|
||||||
continue;
|
|
||||||
|
|
||||||
if (event.getClass() == XConfigurationEvent.class)
|
if (event.getClass() == XConfigurationEvent.class)
|
||||||
lastConfiguration = (XConfigurationEvent)event;
|
lastConfiguration = (XConfigurationEvent)event;
|
||||||
|
// graceful shutdown
|
||||||
else if (event.getClass() == XDisconnectEvent.class)
|
else if (event.getClass() == XDisconnectEvent.class)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
if (destAddress == null) // no valid destination host
|
||||||
|
continue;
|
||||||
|
|
||||||
byte[] data = event.toByteArray();
|
byte[] data = event.toByteArray();
|
||||||
DatagramPacket pkt = new DatagramPacket(data, data.length, destAddress, 40117);
|
DatagramPacket pkt = new DatagramPacket(data, data.length, destAddress, 40117);
|
||||||
socket.send(pkt);
|
socket.send(pkt);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue