OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2015 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2015 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 package org.appspot.apprtc; | 11 package org.appspot.apprtc; |
12 | 12 |
13 import android.app.Activity; | 13 import android.app.Activity; |
14 import android.app.Fragment; | 14 import android.app.Fragment; |
15 import android.os.Bundle; | 15 import android.os.Bundle; |
16 import android.util.TypedValue; | |
16 import android.view.LayoutInflater; | 17 import android.view.LayoutInflater; |
17 import android.view.View; | 18 import android.view.View; |
18 import android.view.ViewGroup; | 19 import android.view.ViewGroup; |
19 import android.widget.ImageButton; | 20 import android.widget.ImageButton; |
21 import android.widget.LinearLayout; | |
22 import android.widget.RelativeLayout; | |
23 import android.widget.SeekBar; | |
20 import android.widget.TextView; | 24 import android.widget.TextView; |
21 | 25 |
22 import org.webrtc.RendererCommon.ScalingType; | 26 import org.webrtc.RendererCommon.ScalingType; |
23 | 27 |
24 /** | 28 /** |
25 * Fragment for call control. | 29 * Fragment for call control. |
26 */ | 30 */ |
27 public class CallFragment extends Fragment { | 31 public class CallFragment extends Fragment { |
28 private View controlView; | 32 private View controlView; |
29 private TextView contactView; | 33 private TextView contactView; |
30 private ImageButton disconnectButton; | 34 private ImageButton disconnectButton; |
31 private ImageButton cameraSwitchButton; | 35 private ImageButton cameraSwitchButton; |
32 private ImageButton videoScalingButton; | 36 private ImageButton videoScalingButton; |
33 private OnCallEvents callEvents; | 37 private OnCallEvents callEvents; |
34 private ScalingType scalingType; | 38 private ScalingType scalingType; |
35 private boolean videoCallEnabled = true; | 39 private boolean videoCallEnabled = true; |
36 | 40 |
37 /** | 41 /** |
38 * Call control interface for container activity. | 42 * Call control interface for container activity. |
39 */ | 43 */ |
40 public interface OnCallEvents { | 44 public interface OnCallEvents { |
41 public void onCallHangUp(); | 45 public void onCallHangUp(); |
42 public void onCameraSwitch(); | 46 public void onCameraSwitch(); |
43 public void onVideoScalingSwitch(ScalingType scalingType); | 47 public void onVideoScalingSwitch(ScalingType scalingType); |
48 public void onCaptureFormatChange(int width, int height, int framerate); | |
44 } | 49 } |
45 | 50 |
46 @Override | 51 @Override |
47 public View onCreateView(LayoutInflater inflater, ViewGroup container, | 52 public View onCreateView(LayoutInflater inflater, ViewGroup container, |
48 Bundle savedInstanceState) { | 53 Bundle savedInstanceState) { |
49 controlView = | 54 controlView = |
50 inflater.inflate(R.layout.fragment_call, container, false); | 55 inflater.inflate(R.layout.fragment_call, container, false); |
51 | 56 |
52 // Create UI controls. | 57 // Create UI controls. |
53 contactView = | 58 contactView = |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
91 }); | 96 }); |
92 scalingType = ScalingType.SCALE_ASPECT_FILL; | 97 scalingType = ScalingType.SCALE_ASPECT_FILL; |
93 | 98 |
94 return controlView; | 99 return controlView; |
95 } | 100 } |
96 | 101 |
97 @Override | 102 @Override |
98 public void onStart() { | 103 public void onStart() { |
99 super.onStart(); | 104 super.onStart(); |
100 | 105 |
106 boolean captureSliderEnabled = false; | |
101 Bundle args = getArguments(); | 107 Bundle args = getArguments(); |
102 if (args != null) { | 108 if (args != null) { |
103 String contactName = args.getString(CallActivity.EXTRA_ROOMID); | 109 String contactName = args.getString(CallActivity.EXTRA_ROOMID); |
104 contactView.setText(contactName); | 110 contactView.setText(contactName); |
105 videoCallEnabled = args.getBoolean(CallActivity.EXTRA_VIDEO_CALL, true); | 111 videoCallEnabled = args.getBoolean(CallActivity.EXTRA_VIDEO_CALL, true); |
112 captureSliderEnabled = videoCallEnabled | |
113 && args.getBoolean(CallActivity.EXTRA_VIDEO_CAPTUREQUALITYSLIDER_ENABL ED, false); | |
106 } | 114 } |
107 if (!videoCallEnabled) { | 115 if (!videoCallEnabled) { |
108 cameraSwitchButton.setVisibility(View.INVISIBLE); | 116 cameraSwitchButton.setVisibility(View.INVISIBLE); |
109 } | 117 } |
118 if (captureSliderEnabled) { | |
119 final TextView captureFormatText = new TextView(getActivity()); | |
AlexG
2015/09/23 23:56:38
I think it may be better to move most of these pro
magjed_webrtc
2015/09/24 15:08:17
Done.
| |
120 final SeekBar captureQualitySeekBar = new SeekBar(getActivity()); | |
121 final LinearLayout buttonsContainer = | |
122 (LinearLayout) controlView.findViewById(R.id.buttons_call_container); | |
123 captureFormatText.setId(1); | |
124 captureQualitySeekBar.setId(2); | |
125 | |
126 final RelativeLayout.LayoutParams textParams = | |
127 new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTE NT, | |
128 RelativeLayout.LayoutParams.WRAP_CONTE NT); | |
129 textParams.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); | |
130 textParams.addRule(RelativeLayout.ABOVE, captureQualitySeekBar.getId()); | |
131 captureFormatText.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16); | |
132 | |
133 final RelativeLayout.LayoutParams seekBarParams = | |
134 new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARE NT, | |
135 RelativeLayout.LayoutParams.WRAP_CONTE NT); | |
136 seekBarParams.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRU E); | |
137 seekBarParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.T RUE); | |
138 final int margin32dp = (int) TypedValue.applyDimension( | |
139 TypedValue.COMPLEX_UNIT_DIP, 32, getResources().getDisplayMetrics()); | |
140 seekBarParams.setMargins(margin32dp, 0, margin32dp, margin32dp); | |
141 captureQualitySeekBar.setProgress(50); | |
142 | |
143 final RelativeLayout parentView = (RelativeLayout) buttonsContainer.getPar ent(); | |
144 parentView.addView(captureFormatText, textParams); | |
145 parentView.addView(captureQualitySeekBar, seekBarParams); | |
146 | |
147 RelativeLayout.LayoutParams buttonsContainerParams = | |
148 (RelativeLayout.LayoutParams) buttonsContainer.getLayoutParams(); | |
149 buttonsContainerParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 0); | |
150 buttonsContainerParams.addRule(RelativeLayout.ABOVE, captureFormatText.get Id()); | |
151 buttonsContainer.setLayoutParams(buttonsContainerParams); | |
152 | |
153 captureQualitySeekBar.setOnSeekBarChangeListener( | |
154 new CaptureQualityController(captureFormatText, callEvents)); | |
155 } | |
110 } | 156 } |
111 | 157 |
112 @Override | 158 @Override |
113 public void onAttach(Activity activity) { | 159 public void onAttach(Activity activity) { |
114 super.onAttach(activity); | 160 super.onAttach(activity); |
115 callEvents = (OnCallEvents) activity; | 161 callEvents = (OnCallEvents) activity; |
116 } | 162 } |
117 | 163 |
118 } | 164 } |
OLD | NEW |