mirror of
https://github.com/rfc2822/GfxTablet
synced 2025-10-03 01:29:17 +02:00
Merge 08d0a19d2d
into ff865c297b
This commit is contained in:
commit
aaa3af7028
11 changed files with 96 additions and 10 deletions
7
app-android/res/drawable-hdpi/layout_bg.xml
Normal file
7
app-android/res/drawable-hdpi/layout_bg.xml
Normal file
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<solid android:color="#FFFFFF"/>
|
||||
<stroke android:width="1dip" android:color="#FFFFFF" />
|
||||
<corners android:radius="5dip"/>
|
||||
<padding android:left="0dip" android:top="0dip" android:right="0dip" android:bottom="0dip" />
|
||||
</shape>
|
|
@ -1,7 +1,9 @@
|
|||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/relative_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/Black"
|
||||
tools:context=".CanvasActivity" >
|
||||
|
||||
<LinearLayout
|
||||
|
@ -10,6 +12,7 @@
|
|||
android:layout_height="fill_parent"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:background="@drawable/layout_bg"
|
||||
android:orientation="vertical" >
|
||||
|
||||
</LinearLayout>
|
||||
|
|
6
app-android/res/values/colors.xml
Normal file
6
app-android/res/values/colors.xml
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="White">#FFFFFF</color>
|
||||
<color name="Black">#000000</color>
|
||||
|
||||
</resources>
|
|
@ -9,5 +9,6 @@
|
|||
<string name="menu_about">About / Help</string>
|
||||
<string name="fullscreen_preference_summary">Title bar will only be hidden when hardware menu button is present</string>
|
||||
<string name="stylus_preference_summary">Ignores touch events from fingers</string>
|
||||
<string name="dark_theme_preference">Use Dark Background</string>
|
||||
|
||||
</resources>
|
||||
|
|
8
app-android/res/xml/layout_preferences.xml
Normal file
8
app-android/res/xml/layout_preferences.xml
Normal file
|
@ -0,0 +1,8 @@
|
|||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
|
||||
<CheckBoxPreference
|
||||
android:key="darkcanvas_preference"
|
||||
android:title="@string/dark_theme_preference" />
|
||||
<EditTextPreference android:title="Padding" android:defaultValue="0" android:key="canvaspadding_preference" android:inputType = "number"/>
|
||||
|
||||
</PreferenceScreen>
|
|
@ -1,4 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
<EditTextPreference android:title="@string/preferences_host_title" android:key="host_preference" android:defaultValue="please-replace.invalid" android:singleLine="true"/>
|
||||
<EditTextPreference android:title="@string/preferences_host_title" android:key="host_preference" android:defaultValue="0.0.0.0" android:singleLine="true"/>
|
||||
</PreferenceScreen>
|
||||
|
|
|
@ -5,5 +5,7 @@
|
|||
android:title="Networking" />
|
||||
<header android:fragment="at.bitfire.gfxtablet.SettingsActivity$DrawingPrefsFragment"
|
||||
android:title="Drawing" />
|
||||
<header android:fragment="at.bitfire.gfxtablet.SettingsActivity$LayoutPrefsFragment"
|
||||
android:title="Layout" />
|
||||
|
||||
</preference-headers>
|
||||
|
|
|
@ -3,22 +3,27 @@ package at.bitfire.gfxtablet;
|
|||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
|
||||
import android.graphics.drawable.GradientDrawable;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.ViewConfiguration;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.Toast;
|
||||
|
||||
public class CanvasActivity extends Activity {
|
||||
public class CanvasActivity extends Activity implements OnSharedPreferenceChangeListener {
|
||||
CanvasView canvas;
|
||||
SharedPreferences settings;
|
||||
NetworkClient netClient;
|
||||
|
||||
LinearLayout layout;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
@ -27,6 +32,7 @@ public class CanvasActivity extends Activity {
|
|||
PreferenceManager.setDefaultValues(this, R.xml.drawing_preferences, false);
|
||||
|
||||
settings = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
settings.registerOnSharedPreferenceChangeListener(this);
|
||||
if (settings.getBoolean(SettingsActivity.KEY_PREF_FULLSCREEN, false)) {
|
||||
if (ViewConfiguration.get(this).hasPermanentMenuKey())
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
|
@ -38,14 +44,47 @@ public class CanvasActivity extends Activity {
|
|||
}
|
||||
|
||||
setContentView(R.layout.activity_canvas);
|
||||
LinearLayout layout = (LinearLayout)findViewById(R.id.canvas_layout);
|
||||
layout = (LinearLayout)findViewById(R.id.canvas_layout);
|
||||
|
||||
new Thread(netClient = new NetworkClient(PreferenceManager.getDefaultSharedPreferences(this))).start();
|
||||
|
||||
|
||||
canvas = new CanvasView(this, netClient);
|
||||
layout.addView(canvas);
|
||||
|
||||
this.reconfigureLayout();
|
||||
this.reconfigureColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSharedPreferenceChanged(SharedPreferences pref, String key) {
|
||||
if (key.equals(SettingsActivity.KEY_PREF_PADDING))
|
||||
this.reconfigureLayout();
|
||||
else if (key.equals(SettingsActivity.KEY_PREF_DARKCANVAS))
|
||||
this.reconfigureColor();
|
||||
}
|
||||
|
||||
void reconfigureLayout()
|
||||
{
|
||||
String padding = settings.getString(SettingsActivity.KEY_PREF_PADDING, "0");
|
||||
int p = Integer.parseInt(padding);
|
||||
RelativeLayout l = (RelativeLayout)findViewById(R.id.relative_layout);
|
||||
l.setPadding(p, p, p, p);
|
||||
}
|
||||
|
||||
void reconfigureColor()
|
||||
{
|
||||
GradientDrawable sd = (GradientDrawable) layout.getBackground().mutate();
|
||||
if (settings.getBoolean(SettingsActivity.KEY_PREF_DARKCANVAS, false))
|
||||
sd.setColor(0xFF263248);
|
||||
else
|
||||
sd.setColor(0xFF7E8AA2);
|
||||
sd.invalidateSelf();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
netClient.getQueue().add(new NetEvent(NetEvent.Type.TYPE_DISCONNECT));
|
||||
|
|
|
@ -1,10 +1,17 @@
|
|||
package at.bitfire.gfxtablet;
|
||||
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.GradientDrawable;
|
||||
import android.graphics.drawable.LayerDrawable;
|
||||
import android.graphics.drawable.ShapeDrawable;
|
||||
import android.os.AsyncTask;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.view.MotionEvent;
|
||||
|
@ -24,12 +31,13 @@ public class CanvasView extends View implements OnSharedPreferenceChangeListener
|
|||
|
||||
// disable until networking has been configured
|
||||
setEnabled(false);
|
||||
setBackgroundColor(0xFFD0D0D0);
|
||||
|
||||
|
||||
settings = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
settings.registerOnSharedPreferenceChangeListener(this);
|
||||
|
||||
reconfigureAcceptedInputDevices();
|
||||
|
||||
//this.reconfigureLayout();
|
||||
this.netClient = netClient;
|
||||
new ConfigureNetworkingTask().execute();
|
||||
}
|
||||
|
@ -39,8 +47,9 @@ public class CanvasView extends View implements OnSharedPreferenceChangeListener
|
|||
if (key.equals(SettingsActivity.KEY_PREF_HOST))
|
||||
new ConfigureNetworkingTask().execute();
|
||||
else if (key.equals(SettingsActivity.KEY_PREF_STYLUS_ONLY))
|
||||
reconfigureAcceptedInputDevices();
|
||||
this.reconfigureAcceptedInputDevices();
|
||||
}
|
||||
|
||||
|
||||
void reconfigureAcceptedInputDevices() {
|
||||
acceptStylusOnly = settings.getBoolean(SettingsActivity.KEY_PREF_STYLUS_ONLY, false);
|
||||
|
|
|
@ -6,6 +6,7 @@ import java.net.InetAddress;
|
|||
import java.net.UnknownHostException;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
|
||||
import android.bluetooth.BluetoothSocket;
|
||||
import android.content.SharedPreferences;
|
||||
import android.util.Log;
|
||||
import at.bitfire.gfxtablet.NetEvent.Type;
|
||||
|
|
|
@ -18,7 +18,9 @@ public class SettingsActivity extends PreferenceActivity implements OnSharedPref
|
|||
public static final String
|
||||
KEY_PREF_HOST = "host_preference",
|
||||
KEY_PREF_STYLUS_ONLY = "stylus_only_preference",
|
||||
KEY_PREF_FULLSCREEN = "fullscreen_preference";
|
||||
KEY_PREF_FULLSCREEN = "fullscreen_preference",
|
||||
KEY_PREF_DARKCANVAS = "darkcanvas_preference",
|
||||
KEY_PREF_PADDING = "canvaspadding_preference";
|
||||
|
||||
|
||||
@Override
|
||||
|
@ -30,7 +32,7 @@ public class SettingsActivity extends PreferenceActivity implements OnSharedPref
|
|||
PreferenceManager.getDefaultSharedPreferences(this)
|
||||
.registerOnSharedPreferenceChangeListener(this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onBuildHeaders(List<Header> target) {
|
||||
loadHeadersFromResource(R.xml.preference_headers, target);
|
||||
|
@ -64,4 +66,12 @@ public class SettingsActivity extends PreferenceActivity implements OnSharedPref
|
|||
addPreferencesFromResource(R.xml.drawing_preferences);
|
||||
}
|
||||
}
|
||||
|
||||
public static class LayoutPrefsFragment extends PreferenceFragment {
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
addPreferencesFromResource(R.xml.layout_preferences);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue