| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * libjingle | |
| 3 * Copyright 2015 Google Inc. | |
| 4 * | |
| 5 * Redistribution and use in source and binary forms, with or without | |
| 6 * modification, are permitted provided that the following conditions are met: | |
| 7 * | |
| 8 * 1. Redistributions of source code must retain the above copyright notice, | |
| 9 * this list of conditions and the following disclaimer. | |
| 10 * 2. Redistributions in binary form must reproduce the above copyright notice, | |
| 11 * this list of conditions and the following disclaimer in the documentation | |
| 12 * and/or other materials provided with the distribution. | |
| 13 * 3. The name of the author may not be used to endorse or promote products | |
| 14 * derived from this software without specific prior written permission. | |
| 15 * | |
| 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED | |
| 17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | |
| 18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO | |
| 19 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
| 20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |
| 21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; | |
| 22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | |
| 23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR | |
| 24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | |
| 25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 26 */ | |
| 27 | |
| 28 package org.appspot.apprtc; | |
| 29 | |
| 30 import android.app.Activity; | |
| 31 import android.app.Fragment; | |
| 32 import android.os.Bundle; | |
| 33 import android.view.LayoutInflater; | |
| 34 import android.view.View; | |
| 35 import android.view.ViewGroup; | |
| 36 import android.widget.ImageButton; | |
| 37 import android.widget.TextView; | |
| 38 | |
| 39 import org.webrtc.VideoRendererGui.ScalingType; | |
| 40 | |
| 41 /** | |
| 42 * Fragment for call control. | |
| 43 */ | |
| 44 public class CallFragment extends Fragment { | |
| 45 private View controlView; | |
| 46 private TextView contactView; | |
| 47 private ImageButton disconnectButton; | |
| 48 private ImageButton cameraSwitchButton; | |
| 49 private ImageButton videoScalingButton; | |
| 50 private OnCallEvents callEvents; | |
| 51 private ScalingType scalingType; | |
| 52 private boolean videoCallEnabled = true; | |
| 53 | |
| 54 /** | |
| 55 * Call control interface for container activity. | |
| 56 */ | |
| 57 public interface OnCallEvents { | |
| 58 public void onCallHangUp(); | |
| 59 public void onCameraSwitch(); | |
| 60 public void onVideoScalingSwitch(ScalingType scalingType); | |
| 61 } | |
| 62 | |
| 63 @Override | |
| 64 public View onCreateView(LayoutInflater inflater, ViewGroup container, | |
| 65 Bundle savedInstanceState) { | |
| 66 controlView = | |
| 67 inflater.inflate(R.layout.fragment_call, container, false); | |
| 68 | |
| 69 // Create UI controls. | |
| 70 contactView = | |
| 71 (TextView) controlView.findViewById(R.id.contact_name_call); | |
| 72 disconnectButton = | |
| 73 (ImageButton) controlView.findViewById(R.id.button_call_disconnect); | |
| 74 cameraSwitchButton = | |
| 75 (ImageButton) controlView.findViewById(R.id.button_call_switch_camera); | |
| 76 videoScalingButton = | |
| 77 (ImageButton) controlView.findViewById(R.id.button_call_scaling_mode); | |
| 78 | |
| 79 // Add buttons click events. | |
| 80 disconnectButton.setOnClickListener(new View.OnClickListener() { | |
| 81 @Override | |
| 82 public void onClick(View view) { | |
| 83 callEvents.onCallHangUp(); | |
| 84 } | |
| 85 }); | |
| 86 | |
| 87 cameraSwitchButton.setOnClickListener(new View.OnClickListener() { | |
| 88 @Override | |
| 89 public void onClick(View view) { | |
| 90 callEvents.onCameraSwitch(); | |
| 91 } | |
| 92 }); | |
| 93 | |
| 94 videoScalingButton.setOnClickListener(new View.OnClickListener() { | |
| 95 @Override | |
| 96 public void onClick(View view) { | |
| 97 if (scalingType == ScalingType.SCALE_ASPECT_FILL) { | |
| 98 videoScalingButton.setBackgroundResource( | |
| 99 R.drawable.ic_action_full_screen); | |
| 100 scalingType = ScalingType.SCALE_ASPECT_FIT; | |
| 101 } else { | |
| 102 videoScalingButton.setBackgroundResource( | |
| 103 R.drawable.ic_action_return_from_full_screen); | |
| 104 scalingType = ScalingType.SCALE_ASPECT_FILL; | |
| 105 } | |
| 106 callEvents.onVideoScalingSwitch(scalingType); | |
| 107 } | |
| 108 }); | |
| 109 scalingType = ScalingType.SCALE_ASPECT_FILL; | |
| 110 | |
| 111 return controlView; | |
| 112 } | |
| 113 | |
| 114 @Override | |
| 115 public void onStart() { | |
| 116 super.onStart(); | |
| 117 | |
| 118 Bundle args = getArguments(); | |
| 119 if (args != null) { | |
| 120 String contactName = args.getString(CallActivity.EXTRA_ROOMID); | |
| 121 contactView.setText(contactName); | |
| 122 videoCallEnabled = args.getBoolean(CallActivity.EXTRA_VIDEO_CALL, true); | |
| 123 } | |
| 124 if (!videoCallEnabled) { | |
| 125 cameraSwitchButton.setVisibility(View.INVISIBLE); | |
| 126 } | |
| 127 } | |
| 128 | |
| 129 @Override | |
| 130 public void onAttach(Activity activity) { | |
| 131 super.onAttach(activity); | |
| 132 callEvents = (OnCallEvents) activity; | |
| 133 } | |
| 134 | |
| 135 } | |
| OLD | NEW |