mirror of
https://github.com/rfc2822/GfxTablet
synced 2025-10-03 09:39:16 +02:00
Option to add padding to canvas
This commit is contained in:
parent
5f477d641c
commit
fe8a9c7944
7 changed files with 36 additions and 9 deletions
|
@ -1,7 +1,9 @@
|
||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/relative_layout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
android:background="@color/Black"
|
||||||
tools:context=".CanvasActivity" >
|
tools:context=".CanvasActivity" >
|
||||||
|
|
||||||
<LinearLayout
|
<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>
|
|
@ -3,5 +3,6 @@
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:key="darkcanvas_preference"
|
android:key="darkcanvas_preference"
|
||||||
android:title="@string/dark_theme_preference" />
|
android:title="@string/dark_theme_preference" />
|
||||||
|
<EditTextPreference android:title="Padding" android:defaultValue="0" android:key="canvaspadding_preference" android:inputType = "number"/>
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
|
@ -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="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>
|
</PreferenceScreen>
|
||||||
|
|
|
@ -3,18 +3,20 @@ package at.bitfire.gfxtablet;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.ViewConfiguration;
|
import android.view.ViewConfiguration;
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.RelativeLayout;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
public class CanvasActivity extends Activity implements OnSharedPreferenceChangeListener {
|
||||||
public class CanvasActivity extends Activity {
|
|
||||||
CanvasView canvas;
|
CanvasView canvas;
|
||||||
SharedPreferences settings;
|
SharedPreferences settings;
|
||||||
NetworkClient netClient;
|
NetworkClient netClient;
|
||||||
|
@ -27,6 +29,7 @@ public class CanvasActivity extends Activity {
|
||||||
PreferenceManager.setDefaultValues(this, R.xml.drawing_preferences, false);
|
PreferenceManager.setDefaultValues(this, R.xml.drawing_preferences, false);
|
||||||
|
|
||||||
settings = PreferenceManager.getDefaultSharedPreferences(this);
|
settings = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
|
settings.registerOnSharedPreferenceChangeListener(this);
|
||||||
if (settings.getBoolean(SettingsActivity.KEY_PREF_FULLSCREEN, false)) {
|
if (settings.getBoolean(SettingsActivity.KEY_PREF_FULLSCREEN, false)) {
|
||||||
if (ViewConfiguration.get(this).hasPermanentMenuKey())
|
if (ViewConfiguration.get(this).hasPermanentMenuKey())
|
||||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||||
|
@ -44,6 +47,21 @@ public class CanvasActivity extends Activity {
|
||||||
|
|
||||||
canvas = new CanvasView(this, netClient);
|
canvas = new CanvasView(this, netClient);
|
||||||
layout.addView(canvas);
|
layout.addView(canvas);
|
||||||
|
this.reconfigureLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSharedPreferenceChanged(SharedPreferences pref, String key) {
|
||||||
|
if (key.equals(SettingsActivity.KEY_PREF_PADDING))
|
||||||
|
this.reconfigureLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -24,7 +24,6 @@ public class CanvasView extends View implements OnSharedPreferenceChangeListener
|
||||||
|
|
||||||
// disable until networking has been configured
|
// disable until networking has been configured
|
||||||
setEnabled(false);
|
setEnabled(false);
|
||||||
setBackgroundColor(0xFFD0D0D0);
|
|
||||||
|
|
||||||
settings = PreferenceManager.getDefaultSharedPreferences(context);
|
settings = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
settings.registerOnSharedPreferenceChangeListener(this);
|
settings.registerOnSharedPreferenceChangeListener(this);
|
||||||
|
@ -49,7 +48,7 @@ public class CanvasView extends View implements OnSharedPreferenceChangeListener
|
||||||
void reconfigureLayout()
|
void reconfigureLayout()
|
||||||
{
|
{
|
||||||
if (settings.getBoolean(SettingsActivity.KEY_PREF_DARKCANVAS, false))
|
if (settings.getBoolean(SettingsActivity.KEY_PREF_DARKCANVAS, false))
|
||||||
setBackgroundColor(0x2E2E2E);
|
setBackgroundColor(0xFF2E2E2E);
|
||||||
else
|
else
|
||||||
setBackgroundColor(0xFFD0D0D0);
|
setBackgroundColor(0xFFD0D0D0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,8 @@ public class SettingsActivity extends PreferenceActivity implements OnSharedPref
|
||||||
KEY_PREF_HOST = "host_preference",
|
KEY_PREF_HOST = "host_preference",
|
||||||
KEY_PREF_STYLUS_ONLY = "stylus_only_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_DARKCANVAS = "darkcanvas_preference",
|
||||||
|
KEY_PREF_PADDING = "canvaspadding_preference";
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue