Improved preview movement
This commit is contained in:
parent
26cfc34bb1
commit
7fbe488772
1 changed files with 14 additions and 40 deletions
|
@ -24,7 +24,6 @@ import android.app.Dialog;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.graphics.Point;
|
|
||||||
import android.graphics.drawable.ColorDrawable;
|
import android.graphics.drawable.ColorDrawable;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
@ -104,7 +103,7 @@ public class CallActivity extends LinphoneGenericActivity
|
||||||
|
|
||||||
private final HideControlsRunnable mHideControlsRunnable = new HideControlsRunnable(this);
|
private final HideControlsRunnable mHideControlsRunnable = new HideControlsRunnable(this);
|
||||||
|
|
||||||
private int mPreviewX, mPreviewY;
|
private float mPreviewX, mPreviewY;
|
||||||
private TextureView mLocalPreview, mRemoteVideo;
|
private TextureView mLocalPreview, mRemoteVideo;
|
||||||
private RelativeLayout mButtons,
|
private RelativeLayout mButtons,
|
||||||
mActiveCalls,
|
mActiveCalls,
|
||||||
|
@ -142,8 +141,7 @@ public class CallActivity extends LinphoneGenericActivity
|
||||||
new View.OnTouchListener() {
|
new View.OnTouchListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onTouch(View v, MotionEvent event) {
|
public boolean onTouch(View v, MotionEvent event) {
|
||||||
moveLocalPreview(event);
|
return moveLocalPreview(v, event);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -817,48 +815,24 @@ public class CallActivity extends LinphoneGenericActivity
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void moveLocalPreview(MotionEvent motionEvent) {
|
private boolean moveLocalPreview(View view, MotionEvent motionEvent) {
|
||||||
switch (motionEvent.getAction()) {
|
switch (motionEvent.getAction()) {
|
||||||
case MotionEvent.ACTION_DOWN:
|
case MotionEvent.ACTION_DOWN:
|
||||||
mPreviewX = (int) motionEvent.getX();
|
mPreviewX = view.getX() - motionEvent.getRawX();
|
||||||
mPreviewY = (int) motionEvent.getY();
|
mPreviewY = view.getY() - motionEvent.getRawY();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MotionEvent.ACTION_MOVE:
|
case MotionEvent.ACTION_MOVE:
|
||||||
int x = (int) motionEvent.getX();
|
view.animate()
|
||||||
int y = (int) motionEvent.getY();
|
.x(motionEvent.getRawX() + mPreviewX)
|
||||||
|
.y(motionEvent.getRawY() + mPreviewY)
|
||||||
RelativeLayout.LayoutParams lp =
|
.setDuration(0)
|
||||||
(RelativeLayout.LayoutParams) mLocalPreview.getLayoutParams();
|
.start();
|
||||||
|
|
||||||
lp.removeRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
|
|
||||||
lp.removeRule(RelativeLayout.ALIGN_PARENT_RIGHT);
|
|
||||||
|
|
||||||
int left = lp.leftMargin + (x - mPreviewX);
|
|
||||||
int top = lp.topMargin + (y - mPreviewY);
|
|
||||||
|
|
||||||
int width = lp.width;
|
|
||||||
int height = lp.height;
|
|
||||||
|
|
||||||
Point screenSize = new Point();
|
|
||||||
getWindow().getWindowManager().getDefaultDisplay().getSize(screenSize);
|
|
||||||
|
|
||||||
int statusBarHeight = 0;
|
|
||||||
int resource =
|
|
||||||
getResources().getIdentifier("status_bar_height", "dimen", "android");
|
|
||||||
if (resource > 0) {
|
|
||||||
statusBarHeight = getResources().getDimensionPixelSize(resource);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (left < 0
|
|
||||||
|| top < 0
|
|
||||||
|| left + width >= screenSize.x
|
|
||||||
|| top + height + statusBarHeight >= screenSize.y) return;
|
|
||||||
|
|
||||||
lp.leftMargin = left;
|
|
||||||
lp.topMargin = top;
|
|
||||||
mLocalPreview.setLayoutParams(lp);
|
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// NAVIGATION
|
// NAVIGATION
|
||||||
|
|
Loading…
Reference in a new issue