Commit ad5a7595 authored by Claes Sjofors's avatar Claes Sjofors

Android app density fix

parent 5d92030d
...@@ -1613,38 +1613,52 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd ...@@ -1613,38 +1613,52 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd
int action; int action;
Object data1; Object data1;
Object data2; Object data2;
int sts;
public ReaderTaskArg(int action, Object data1, Object data2) { public ReaderTaskArg(int action, Object data1, Object data2) {
this.action = action; this.action = action;
this.data1 = data1; this.data1 = data1;
this.data2 = data2; this.data2 = data2;
this.sts = 0;
} }
} }
private class ReaderTask extends AsyncTask<ReaderTaskArg, Void, Void> { private class ReaderTask extends AsyncTask<ReaderTaskArg, Void, ReaderTaskArg> {
public static final int FLOW_READ = 1; public static final int FLOW_READ = 1;
public static final int CRR_READ = 2; public static final int CRR_READ = 2;
public static final int GROW_READ = 3; public static final int GROW_READ = 3;
@Override @Override
protected Void doInBackground(ReaderTaskArg... arg) { protected ReaderTaskArg doInBackground(ReaderTaskArg... arg) {
switch ( arg[0].action) { switch ( arg[0].action) {
case FLOW_READ: case FLOW_READ:
readFlow((PwrtObjid)arg[0].data1, (String)arg[0].data2); readFlow((PwrtObjid)arg[0].data1, (String)arg[0].data2);
break; return new ReaderTaskArg(0,null,null);
case GROW_READ: case GROW_READ:
readGrow((String)arg[0].data1, (String)arg[0].data2); try {
break; readGrow((String)arg[0].data1, (String)arg[0].data2);
return new ReaderTaskArg(0,null,null);
}
catch ( FileNotFoundException e) {
ReaderTaskArg result = new ReaderTaskArg(arg[0].action,
arg[0].data1, arg[0].data2);
result.sts = 2;
return result;
}
} }
return null; return new ReaderTaskArg(0,null,null);
} }
@Override @Override
protected void onPostExecute(Void params) { protected void onPostExecute(ReaderTaskArg params) {
super.onPostExecute(params); super.onPostExecute(params);
//cmn.draw(); //cmn.draw();
view.invalidate(); view.invalidate();
if ( params != null && params.sts == 2) {
// TODO Try superclass
}
} }
} }
public Resources getApplResources() { public Resources getApplResources() {
...@@ -1724,7 +1738,7 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd ...@@ -1724,7 +1738,7 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd
(((GraphCmn)currentCmn).getAppMotion() == Glow.eAppMotion_Both && (((GraphCmn)currentCmn).getAppMotion() == Glow.eAppMotion_Both &&
((GraphCmn)currentCmn).getSliderActive())) { ((GraphCmn)currentCmn).getSliderActive())) {
new GdhTask().execute(new GdhTaskArg(GdhTask.EVENTHANDLER, new GdhTask().execute(new GdhTaskArg(GdhTask.EVENTHANDLER,
new GdhEventArg(GraphCmn.ACTION_MOVE, x, y-viewOffsetY))); new GdhEventArg(GraphCmn.ACTION_MOVE, x/density, (y-viewOffsetY)/density)));
scroll = false; scroll = false;
sliderActive = true; sliderActive = true;
} }
...@@ -1775,7 +1789,7 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd ...@@ -1775,7 +1789,7 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd
me.getEventTime() - me.getDownTime() < 700) { me.getEventTime() - me.getDownTime() < 700) {
System.out.println("Event Click " + action + " (" + x + "," + y + ") cmn " + currentCmn.type()); System.out.println("Event Click " + action + " (" + x + "," + y + ") cmn " + currentCmn.type());
new GdhTask().execute(new GdhTaskArg(GdhTask.EVENTHANDLER, new GdhTask().execute(new GdhTaskArg(GdhTask.EVENTHANDLER,
new GdhEventArg(GraphCmn.ACTION_CLICK, x, y-viewOffsetY))); new GdhEventArg(GraphCmn.ACTION_CLICK, x/density, (y-viewOffsetY)/density)));
} }
else { else {
new GdhTask().execute(new GdhTaskArg(GdhTask.EVENTHANDLER, new GdhTask().execute(new GdhTaskArg(GdhTask.EVENTHANDLER,
...@@ -1822,7 +1836,7 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd ...@@ -1822,7 +1836,7 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd
lastYSpeed = 0; lastYSpeed = 0;
if ( currentCmn.type() == PlowCmnIfc.TYPE_GRAPH) { if ( currentCmn.type() == PlowCmnIfc.TYPE_GRAPH) {
new GdhTask().execute(new GdhTaskArg(GdhTask.EVENTHANDLER, new GdhTask().execute(new GdhTaskArg(GdhTask.EVENTHANDLER,
new GdhEventArg(GraphCmn.ACTION_DOWN, x, y-viewOffsetY))); new GdhEventArg(GraphCmn.ACTION_DOWN, x/density, (y-viewOffsetY)/density)));
} }
else if ( currentCmn.type() == PlowCmnIfc.TYPE_OPWIN) { else if ( currentCmn.type() == PlowCmnIfc.TYPE_OPWIN) {
currentCmn.eventHandler(PlowCmnIfc.ACTION_DOWN, x, y-viewOffsetY); currentCmn.eventHandler(PlowCmnIfc.ACTION_DOWN, x, y-viewOffsetY);
...@@ -1909,6 +1923,7 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd ...@@ -1909,6 +1923,7 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd
if ( bitmap == null) { if ( bitmap == null) {
bitmap = Bitmap.createBitmap(canvas.getWidth(), canvas.getHeight(), Bitmap.Config.ARGB_8888); bitmap = Bitmap.createBitmap(canvas.getWidth(), canvas.getHeight(), Bitmap.Config.ARGB_8888);
drawCanvas = new Canvas(bitmap); drawCanvas = new Canvas(bitmap);
drawCanvas.scale(density, density, 0, 0);
drawCanvas.drawColor(graph.cmn.gdraw.getColor(graph.cmn.background_color)); drawCanvas.drawColor(graph.cmn.gdraw.getColor(graph.cmn.background_color));
} }
try { try {
...@@ -1942,14 +1957,14 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd ...@@ -1942,14 +1957,14 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd
if ( currentCmn.type() == PlowCmnIfc.TYPE_FLOW) if ( currentCmn.type() == PlowCmnIfc.TYPE_FLOW)
gdraw.setDensity(1, density); gdraw.setDensity(1, density);
else else
gdraw.setDensity(density * density, density); gdraw.setDensity(density, 1);
currentCmn.setCanvas(currentCanvas); currentCmn.setCanvas(currentCanvas);
currentCmn.draw(); currentCmn.draw();
/* Test */ /* Test
Paint paint = new Paint(); Paint paint = new Paint();
currentCanvas.drawText( "Density " + density, 10, 100, paint); currentCanvas.drawText( "Density " + density, 10, 100, paint);
/* */ */
getHolder().unlockCanvasAndPost(currentCanvas); getHolder().unlockCanvasAndPost(currentCanvas);
// currentCanvas = getHolder().lockCanvas(); // currentCanvas = getHolder().lockCanvas();
...@@ -2031,7 +2046,7 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd ...@@ -2031,7 +2046,7 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd
new GdhTask().execute(new GdhTaskArg(GdhTask.DYNAMIC_OPEN, null)); new GdhTask().execute(new GdhTaskArg(GdhTask.DYNAMIC_OPEN, null));
} }
public void readGrow( String file, String instance) { public void readGrow( String file, String instance) throws FileNotFoundException {
/* /*
AssetManager am = getAssets(); AssetManager am = getAssets();
InputStream inputStream; InputStream inputStream;
...@@ -2059,7 +2074,7 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd ...@@ -2059,7 +2074,7 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd
reader = new BufferedReader(new InputStreamReader(url.openStream(), "ISO-8859-1")); reader = new BufferedReader(new InputStreamReader(url.openStream(), "ISO-8859-1"));
} catch ( IOException e) { } catch ( IOException e) {
System.out.println( "Unable to open file " + filename + " " + url); System.out.println( "Unable to open file " + filename + " " + url);
return; throw new FileNotFoundException();
} }
graph = new Graph(this, gdh); graph = new Graph(this, gdh);
graphObject.add(instance); graphObject.add(instance);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment