mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 11:28:06 +00:00
99 lines
2.9 KiB
Java
99 lines
2.9 KiB
Java
package org.linphone;
|
|
/*
|
|
CallAudioFragment.java
|
|
Copyright (C) 2015 Belledonne Communications, Grenoble, France
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
modify it under the terms of the GNU General Public License
|
|
as published by the Free Software Foundation; either version 2
|
|
of the License, or (at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program; if not, write to the Free Software
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
*/
|
|
import android.app.Fragment;
|
|
import android.os.Bundle;
|
|
import android.view.LayoutInflater;
|
|
import android.view.MotionEvent;
|
|
import android.view.View;
|
|
import android.view.View.OnTouchListener;
|
|
import android.view.ViewGroup;
|
|
|
|
/**
|
|
* @author Sylvain Berfini
|
|
*/
|
|
public class CallAudioFragment extends Fragment {
|
|
private CallActivity incallActvityInstance;
|
|
|
|
@Override
|
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
|
Bundle savedInstanceState) {
|
|
View view = inflater.inflate(R.layout.audio, container, false);
|
|
return view;
|
|
}
|
|
|
|
@Override
|
|
public void onStart() {
|
|
super.onStart();
|
|
incallActvityInstance = (CallActivity) getActivity();
|
|
|
|
if (incallActvityInstance != null) {
|
|
incallActvityInstance.bindAudioFragment(this);
|
|
}
|
|
|
|
// Just to be sure we have incall controls
|
|
if (incallActvityInstance != null) {
|
|
incallActvityInstance.removeCallbacks();
|
|
}
|
|
}
|
|
|
|
class SwipeGestureDetector implements OnTouchListener {
|
|
static final int MIN_DISTANCE = 100;
|
|
private float downX, upX;
|
|
private boolean lock;
|
|
|
|
private SwipeListener listener;
|
|
|
|
public SwipeGestureDetector(SwipeListener swipeListener) {
|
|
super();
|
|
listener = swipeListener;
|
|
}
|
|
|
|
@Override
|
|
public boolean onTouch(View v, MotionEvent event) {
|
|
switch(event.getAction()){
|
|
case MotionEvent.ACTION_DOWN:
|
|
lock = false;
|
|
downX = event.getX();
|
|
return true;
|
|
|
|
case MotionEvent.ACTION_MOVE:
|
|
if (lock) {
|
|
return false;
|
|
}
|
|
upX = event.getX();
|
|
|
|
float deltaX = downX - upX;
|
|
|
|
if (Math.abs(deltaX) > MIN_DISTANCE) {
|
|
lock = true;
|
|
if (deltaX < 0) { listener.onLeftToRightSwipe(); return true; }
|
|
if (deltaX > 0) { listener.onRightToLeftSwipe(); return true; }
|
|
}
|
|
break;
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
|
|
interface SwipeListener {
|
|
void onRightToLeftSwipe();
|
|
void onLeftToRightSwipe();
|
|
}
|
|
}
|