Commit 81aae079 authored by Thomas Krex's avatar Thomas Krex
Browse files

fixed scaling issue: Scaling is done according of the width of the screen in...

fixed scaling issue: Scaling is done according of the width of the screen in comparison with the frame buffer width
parent 7f219de8
......@@ -6,36 +6,37 @@
android:background="@android:color/black"
android:keepScreenOn="true"
android:orientation="horizontal"
android:weightSum="6"
android:weightSum="8"
tools:context=".MainActivity" >
<FrameLayout
android:id="@+id/container"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="25dp"
android:layout_marginStart="25dp" >
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:layout_weight="7" >
<tttrec.customviews.ScaleAwareImageView
android:id="@+id/vncImageView"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:scaleType="fitXY"
android:src="@android:drawable/ic_popup_sync" />
<tttrec.customviews.AnnotationView
android:id="@+id/annotationView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center" />
android:layout_height="wrap_content"
android:layout_gravity="center_vertical" />
</FrameLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginLeft="25dp"
android:layout_marginStart="25dp"
android:layout_weight="1"
android:background="@android:color/background_light"
android:gravity="center_horizontal"
android:orientation="vertical"
......
......@@ -9,7 +9,6 @@ import tttrec.messages.Annotation;
import tttrec.recording.AudioRecorder;
import tttrec.util.MyColorPickerDialog;
import tttrec.util.ReconnectDialog;
import android.annotation.TargetApi;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
......@@ -19,7 +18,6 @@ import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
......@@ -91,11 +89,8 @@ public class MainActivity extends Activity {
@Override
public boolean onPreDraw() {
imgV.getViewTreeObserver().removeOnPreDrawListener(this);
int screenHeight = imgV.getMeasuredHeight();
int finalWidth = imgV.getMeasuredWidth();
Log.d("Measures", "Height: " + screenHeight + " Width: "
+ finalWidth);
tttRec.scaleView(screenHeight);
int screenWidth = imgV.getMeasuredWidth();
tttRec.scaleView(screenWidth);
return true;
}
});
......@@ -411,20 +406,4 @@ public class MainActivity extends Activity {
}
colorDialog.dismiss();
}
@TargetApi(Build.VERSION_CODES.KITKAT)
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if (hasFocus) {
annotationView
.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
}
}
}
......@@ -252,9 +252,8 @@ public class TTTRecorderAndroid implements Runnable {
}
public void scaleView(int screenHeight) {
rfbProtocol
.scaleView(screenHeight, rfbProtocol.prefs.framebufferHeight);
public void scaleView(int screenWidth) {
rfbProtocol.scaleView(screenWidth, rfbProtocol.prefs.framebufferWidth);
}
public void cancelConnection() {
......
......@@ -149,23 +149,23 @@ public abstract class GraphicsContext extends Observable {
}
public void scaleView(int screenHeight, int framebufferHeight) {
public void scaleView(int screenWidth, int framebufferWidth) {
float scaleRatio = screenHeight / (float) framebufferHeight;
float scaleRatio = screenWidth / (float) framebufferWidth;
annotationView.setScaleRatio(scaleRatio);
Log.d("Ratio", ": " + scaleRatio);
LayoutParams lp = imgView.getLayoutParams();
lp.width = (int) (scaleRatio * prefs.framebufferWidth);
lp.height = (int) (scaleRatio * prefs.framebufferHeight);
imgView.setLayoutParams(lp);
imgView.postInvalidate();
LayoutParams alp = annotationView.getLayoutParams();
alp.width = lp.width;
alp.height = LayoutParams.MATCH_PARENT;
alp.height = lp.height;
alp.width = LayoutParams.MATCH_PARENT;
annotationView.setLayoutParams(alp);
annotationView.getWidth();
......
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