mirror of
https://github.com/peterosterlund2/droidfish.git
synced 2025-01-30 17:13:50 +01:00
DroidFish: Added button touch visual feedback.
This commit is contained in:
parent
4932e44a92
commit
789c734337
153
DroidFish/res/raw/touch.svg
Normal file
153
DroidFish/res/raw/touch.svg
Normal file
|
@ -0,0 +1,153 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="36"
|
||||
height="32"
|
||||
id="svg3092"
|
||||
version="1.1"
|
||||
inkscape:version="0.48.1 r9760"
|
||||
sodipodi:docname="button.svg">
|
||||
<defs
|
||||
id="defs3094">
|
||||
<linearGradient
|
||||
id="linearGradient4004">
|
||||
<stop
|
||||
style="stop-color:#e0e0e0;stop-opacity:1;"
|
||||
offset="0"
|
||||
id="stop4006" />
|
||||
<stop
|
||||
id="stop4012"
|
||||
offset="0.69999999"
|
||||
style="stop-color:#e0e0e0;stop-opacity:0.627451;" />
|
||||
<stop
|
||||
style="stop-color:#e0e0e0;stop-opacity:0;"
|
||||
offset="1"
|
||||
id="stop4008" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
id="linearGradient6679"
|
||||
y1="903.00256"
|
||||
x1="413.91833"
|
||||
y2="876.73859"
|
||||
x2="413.9183"
|
||||
gradientUnits="userSpaceOnUse">
|
||||
<stop
|
||||
offset="0"
|
||||
style="stop-color:#0000ff;stop-opacity:1;"
|
||||
id="stop3076" />
|
||||
<stop
|
||||
offset="1"
|
||||
style="stop-color:#d9d9ff;stop-opacity:1;"
|
||||
id="stop3078" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
y2="876.73859"
|
||||
x2="413.9183"
|
||||
y1="903.00256"
|
||||
x1="413.91833"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
id="linearGradient3918"
|
||||
xlink:href="#linearGradient6679"
|
||||
inkscape:collect="always" />
|
||||
<radialGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient4004"
|
||||
id="radialGradient4010"
|
||||
cx="17.864586"
|
||||
cy="15.999999"
|
||||
fx="17.864586"
|
||||
fy="15.999999"
|
||||
r="17.5"
|
||||
gradientTransform="matrix(1.3714287,-7.8784533e-8,6.4012425e-8,1.1142857,-6.5000057,-1.828569)"
|
||||
gradientUnits="userSpaceOnUse" />
|
||||
<linearGradient
|
||||
id="linearGradient3806">
|
||||
<stop
|
||||
style="stop-color:#000000;stop-opacity:1;"
|
||||
offset="0"
|
||||
id="stop3808" />
|
||||
<stop
|
||||
style="stop-color:#000000;stop-opacity:0.1254902;"
|
||||
offset="1"
|
||||
id="stop3810" />
|
||||
</linearGradient>
|
||||
<radialGradient
|
||||
r="12"
|
||||
fy="12"
|
||||
fx="12"
|
||||
cy="12"
|
||||
cx="12"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
id="radialGradient3846"
|
||||
xlink:href="#linearGradient3806"
|
||||
inkscape:collect="always"
|
||||
gradientTransform="matrix(2.5625,1.0190477e-7,-9.7865861e-8,1.9444443,-12.749998,-7.3333345)" />
|
||||
</defs>
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="23.157748"
|
||||
inkscape:cx="19.228777"
|
||||
inkscape:cy="15.670632"
|
||||
inkscape:document-units="px"
|
||||
inkscape:current-layer="layer1"
|
||||
showgrid="true"
|
||||
fit-margin-top="0"
|
||||
fit-margin-left="0"
|
||||
fit-margin-right="0"
|
||||
fit-margin-bottom="0"
|
||||
inkscape:window-width="1441"
|
||||
inkscape:window-height="1145"
|
||||
inkscape:window-x="235"
|
||||
inkscape:window-y="0"
|
||||
inkscape:window-maximized="0"
|
||||
showguides="true">
|
||||
<inkscape:grid
|
||||
type="xygrid"
|
||||
id="grid3104"
|
||||
empspacing="5"
|
||||
visible="true"
|
||||
enabled="true"
|
||||
snapvisiblegridlinesonly="true"
|
||||
spacingx="0.5px"
|
||||
spacingy="0.5px" />
|
||||
</sodipodi:namedview>
|
||||
<metadata
|
||||
id="metadata3097">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title />
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
inkscape:label="Layer 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1">
|
||||
<rect
|
||||
style="fill:url(#radialGradient3846);fill-opacity:1;stroke:none"
|
||||
id="rect3804"
|
||||
width="36"
|
||||
height="32"
|
||||
x="1.7763568e-15"
|
||||
y="-5.0753054e-15"
|
||||
inkscape:transform-center-x="1.5" />
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 4.2 KiB |
|
@ -75,6 +75,7 @@ import android.content.pm.PackageManager.NameNotFoundException;
|
|||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Typeface;
|
||||
import android.graphics.drawable.StateListDrawable;
|
||||
import android.media.MediaPlayer;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
|
@ -114,6 +115,7 @@ import android.view.View.OnTouchListener;
|
|||
import android.webkit.WebView;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView.ScaleType;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
@ -803,38 +805,30 @@ public class DroidFish extends Activity implements GUIInterface {
|
|||
bWidth = bWidth * 3 / 2;
|
||||
bHeight = bHeight * 3 / 2;
|
||||
}
|
||||
SVG svg = SVGParser.getSVGFromResource(getResources(),
|
||||
custom1ButtonActions.getIcon());
|
||||
custom1Button.setBackgroundDrawable(new SVGPictureDrawable(svg));
|
||||
svg = SVGParser.getSVGFromResource(getResources(),
|
||||
custom2ButtonActions.getIcon());
|
||||
custom2Button.setBackgroundDrawable(new SVGPictureDrawable(svg));
|
||||
svg = SVGParser.getSVGFromResource(getResources(),
|
||||
custom3ButtonActions.getIcon());
|
||||
custom3Button.setBackgroundDrawable(new SVGPictureDrawable(svg));
|
||||
|
||||
svg = SVGParser.getSVGFromResource(getResources(), R.raw.right);
|
||||
redoButton.setBackgroundDrawable(new SVGPictureDrawable(svg));
|
||||
|
||||
svg = SVGParser.getSVGFromResource(getResources(), R.raw.left);
|
||||
undoButton.setBackgroundDrawable(new SVGPictureDrawable(svg));
|
||||
|
||||
svg = SVGParser.getSVGFromResource(getResources(), R.raw.mode);
|
||||
modeButton.setBackgroundDrawable(new SVGPictureDrawable(svg));
|
||||
|
||||
setButtonSize(custom1Button, bWidth, bHeight);
|
||||
setButtonSize(custom2Button, bWidth, bHeight);
|
||||
setButtonSize(custom3Button, bWidth, bHeight);
|
||||
setButtonSize(modeButton, bWidth, bHeight);
|
||||
setButtonSize(undoButton, bWidth, bHeight);
|
||||
setButtonSize(redoButton, bWidth, bHeight);
|
||||
SVG svg = SVGParser.getSVGFromResource(getResources(), R.raw.touch);
|
||||
setButtonData(custom1Button, bWidth, bHeight, custom1ButtonActions.getIcon(), svg);
|
||||
setButtonData(custom2Button, bWidth, bHeight, custom2ButtonActions.getIcon(), svg);
|
||||
setButtonData(custom3Button, bWidth, bHeight, custom3ButtonActions.getIcon(), svg);
|
||||
setButtonData(modeButton, bWidth, bHeight, R.raw.mode, svg);
|
||||
setButtonData(undoButton, bWidth, bHeight, R.raw.left, svg);
|
||||
setButtonData(redoButton, bWidth, bHeight, R.raw.right, svg);
|
||||
}
|
||||
|
||||
private static void setButtonSize(ImageButton button, int bWidth, int bHeight) {
|
||||
private void setButtonData(ImageButton button, int bWidth, int bHeight,
|
||||
int svgResId, SVG touched) {
|
||||
SVG svg = SVGParser.getSVGFromResource(getResources(), svgResId);
|
||||
button.setBackgroundDrawable(new SVGPictureDrawable(svg));
|
||||
|
||||
StateListDrawable sld = new StateListDrawable();
|
||||
sld.addState(new int[]{android.R.attr.state_pressed}, new SVGPictureDrawable(touched));
|
||||
button.setImageDrawable(sld);
|
||||
|
||||
LayoutParams lp = button.getLayoutParams();
|
||||
lp.height = bHeight;
|
||||
lp.width = bWidth;
|
||||
button.setLayoutParams(lp);
|
||||
button.setPadding(0,0,0,0);
|
||||
button.setScaleType(ScaleType.FIT_XY);
|
||||
}
|
||||
|
||||
private synchronized final void setWakeLock(boolean enableLock) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user