1
0
Fork 0
mirror of https://github.com/rfc2822/GfxTablet synced 2025-10-03 09:39:16 +02:00
This commit is contained in:
Fatih BAKIR 2015-01-18 14:39:57 +00:00
commit aaa3af7028
11 changed files with 96 additions and 10 deletions

View 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>

View file

@ -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>

View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="White">#FFFFFF</color>
<color name="Black">#000000</color>
</resources>

View file

@ -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>

View 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>

View file

@ -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>

View file

@ -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>

View file

@ -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,12 +44,45 @@ 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

View file

@ -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,9 +47,10 @@ 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);
}

View file

@ -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;

View file

@ -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
@ -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);
}
}
}