Read qrcode from assitant
This commit is contained in:
parent
1e1db71a00
commit
8ff76c100d
4 changed files with 28 additions and 15 deletions
|
@ -193,16 +193,6 @@ private static AssistantActivity instance;
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onQrcodeFound(Core lc, String result) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(AssistantActivity.instance());
|
||||
builder.setMessage("QRCODE found: " + result);
|
||||
builder.setCancelable(false);
|
||||
builder.setNeutralButton(getString(R.string.ok), null);
|
||||
builder.show();
|
||||
}
|
||||
|
||||
};
|
||||
instance = this;
|
||||
}
|
||||
|
@ -322,7 +312,7 @@ private static AssistantActivity instance;
|
|||
displayCreateAccount();
|
||||
}
|
||||
} else if (currentFragment == AssistantFragmentsEnum.QRCODE_READER) {
|
||||
displayRemoteProvisioning();
|
||||
displayRemoteProvisioning("");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -515,8 +505,11 @@ private static AssistantActivity instance;
|
|||
back.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
public void displayRemoteProvisioning() {
|
||||
public void displayRemoteProvisioning(String url) {
|
||||
fragment = new RemoteProvisioningFragment();
|
||||
Bundle extra = new Bundle();
|
||||
extra.putString("RemoteUrl", url);
|
||||
fragment.setArguments(extra);
|
||||
changeFragment(fragment);
|
||||
currentFragment = AssistantFragmentsEnum.REMOTE_PROVISIONING;
|
||||
back.setVisibility(View.VISIBLE);
|
||||
|
|
|
@ -20,19 +20,22 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
*/
|
||||
|
||||
import android.app.Fragment;
|
||||
import android.opengl.GLSurfaceView;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.SurfaceView;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import org.linphone.LinphoneManager;
|
||||
import org.linphone.R;
|
||||
import org.linphone.core.Core;
|
||||
import org.linphone.core.CoreListenerStub;
|
||||
import org.linphone.mediastream.video.AndroidVideoWindowImpl;
|
||||
import org.linphone.mediastream.video.capture.hwconf.AndroidCameraConfiguration;
|
||||
|
||||
public class QrcodeFragment extends Fragment {
|
||||
private SurfaceView mQrcodeView;
|
||||
private CoreListenerStub mListener;
|
||||
private AndroidVideoWindowImpl androidVideoWindowImpl;
|
||||
|
||||
@Override
|
||||
|
@ -42,12 +45,26 @@ public class QrcodeFragment extends Fragment {
|
|||
|
||||
mQrcodeView = (SurfaceView) view.findViewById(R.id.qrcodeCaptureSurface);
|
||||
|
||||
mListener = new CoreListenerStub() {
|
||||
@Override
|
||||
public void onQrcodeFound(Core lc, String result) {
|
||||
enableQrcodeReader(false);
|
||||
AssistantActivity.instance().displayRemoteProvisioning(result);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
private void enableQrcodeReader(boolean enable) {
|
||||
LinphoneManager.getLc().enableQrcodeVideoPreview(enable);
|
||||
LinphoneManager.getLc().enableVideoPreview(enable);
|
||||
if (enable) {
|
||||
LinphoneManager.getLc().addListener(mListener);
|
||||
} else {
|
||||
LinphoneManager.getLc().removeListener(mListener);
|
||||
}
|
||||
}
|
||||
|
||||
private void setBackCamera(boolean useBackCamera) {
|
||||
|
@ -84,7 +101,6 @@ public class QrcodeFragment extends Fragment {
|
|||
});
|
||||
|
||||
enableQrcodeReader(true);
|
||||
//LinphoneManager.getLc().setQrcodeDecodeRect(500,220,280,280);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -53,6 +53,10 @@ public class RemoteProvisioningFragment extends Fragment implements OnClickListe
|
|||
apply.setEnabled(false);
|
||||
apply.setOnClickListener(this);
|
||||
|
||||
if (!getArguments().getString("RemoteUrl").isEmpty()) {
|
||||
remoteProvisioningUrl.setText(getArguments().getString("RemoteUrl"));
|
||||
}
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ public class WelcomeFragment extends Fragment implements OnClickListener {
|
|||
} else if (id == R.id.create_account) {
|
||||
AssistantActivity.instance().displayCreateAccount();
|
||||
} else if (id == R.id.remote_provisioning) {
|
||||
AssistantActivity.instance().displayRemoteProvisioning();
|
||||
AssistantActivity.instance().displayRemoteProvisioning("");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue