Skip to content

Commit ab675aa

Browse files
committed
Camera share dialog show function and layout done
1 parent 4902ed3 commit ab675aa

File tree

9 files changed

+330
-27
lines changed

9 files changed

+330
-27
lines changed

Android/Layout_Version/app/src/main/java/com/example/layout_version/MainTab/Streaming/StreamingFragment.java

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
import androidx.annotation.NonNull;
1414
import androidx.annotation.Nullable;
15+
import androidx.appcompat.app.AlertDialog;
1516
import androidx.appcompat.content.res.AppCompatResources;
1617
import androidx.lifecycle.ViewModelProvider;
1718

@@ -35,8 +36,12 @@ public class StreamingFragment extends StateFragment<RecordingState> {
3536
private ImageButton recordingButton;
3637
private ImageButton streamRefreshButton;
3738

39+
private ImageButton optionButton;
40+
private ImageButton shareButton;
3841
private Recorder recorder;
3942

43+
private boolean optionFlag;
44+
4045
@Override
4146
public View onCreateView(LayoutInflater inflater, ViewGroup container,
4247
Bundle savedInstanceState) {
@@ -59,8 +64,12 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
5964
deviceStatusView = layout.findViewById(R.id.deviceStatusView);
6065
recordingButton = layout.findViewById(R.id.recordingButton);
6166
streamRefreshButton = layout.findViewById(R.id.streamRefreshButton);
67+
optionButton = layout.findViewById(R.id.optionButton);
68+
shareButton = layout.findViewById(R.id.shareButton);
6269
recorder = new Recorder(context, streamingViewModel);
6370

71+
hideOptions();
72+
6473
return layout;
6574
}
6675

@@ -87,6 +96,16 @@ else if(status == RecordingState.FAILED)
8796
update(streamingViewModel.getSelectedItem().getValue());
8897
});
8998

99+
optionButton.setOnClickListener(view1 -> {
100+
if(optionFlag)
101+
hideOptions();
102+
else
103+
showOptions();
104+
});
105+
106+
shareButton.setOnClickListener(view1 -> {
107+
showShareDialog();
108+
});
90109
}
91110

92111
public void update(@Nullable ChannelItem channel)
@@ -114,4 +133,30 @@ public void onDestroy() {
114133
streamingPlayer.removeListener(playerListener);
115134
streamingPlayer.release();
116135
}
136+
137+
public void hideOptions()
138+
{
139+
optionFlag = false;
140+
optionButton.setImageDrawable(AppCompatResources.getDrawable(context, R.drawable.baseline_vert_options_24));
141+
recordingButton.setVisibility(View.INVISIBLE);
142+
shareButton.setVisibility(View.INVISIBLE);
143+
}
144+
145+
public void showOptions()
146+
{
147+
optionFlag = true;
148+
optionButton.setImageDrawable(AppCompatResources.getDrawable(context, R.drawable.baseline_close_24));
149+
recordingButton.setVisibility(View.VISIBLE);
150+
shareButton.setVisibility(View.VISIBLE);
151+
}
152+
153+
public void showShareDialog()
154+
{
155+
View view = getActivity().getLayoutInflater().inflate(R.layout.device_share, null);
156+
new AlertDialog.Builder(getActivity())
157+
.setView(view)
158+
.show();
159+
}
160+
161+
117162
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<vector android:autoMirrored="true" android:height="24dp"
2+
android:tint="#222222" android:viewportHeight="24"
3+
android:viewportWidth="24" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
4+
<path android:fillColor="@android:color/white" android:pathData="M11,7L9.6,8.4l2.6,2.6H2v2h10.2l-2.6,2.6L11,17l5,-5L11,7zM20,19h-8v2h8c1.1,0 2,-0.9 2,-2V5c0,-1.1 -0.9,-2 -2,-2h-8v2h8V19z"/>
5+
</vector>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<vector android:autoMirrored="true" android:height="24dp"
2+
android:tint="#222222" android:viewportHeight="24"
3+
android:viewportWidth="24" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
4+
<path android:fillColor="@android:color/white" android:pathData="M17,7l-1.41,1.41L18.17,11H8v2h10.17l-2.58,2.58L17,17l5,-5zM4,5h8V3H4c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h8v-2H4V5z"/>
5+
</vector>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<vector android:height="24dp" android:tint="#555555"
2+
android:viewportHeight="24" android:viewportWidth="24"
3+
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
4+
<path android:fillColor="@android:color/white" android:pathData="M18,16.08c-0.76,0 -1.44,0.3 -1.96,0.77L8.91,12.7c0.05,-0.23 0.09,-0.46 0.09,-0.7s-0.04,-0.47 -0.09,-0.7l7.05,-4.11c0.54,0.5 1.25,0.81 2.04,0.81 1.66,0 3,-1.34 3,-3s-1.34,-3 -3,-3 -3,1.34 -3,3c0,0.24 0.04,0.47 0.09,0.7L8.04,9.81C7.5,9.31 6.79,9 6,9c-1.66,0 -3,1.34 -3,3s1.34,3 3,3c0.79,0 1.5,-0.31 2.04,-0.81l7.12,4.16c-0.05,0.21 -0.08,0.43 -0.08,0.65 0,1.61 1.31,2.92 2.92,2.92 1.61,0 2.92,-1.31 2.92,-2.92s-1.31,-2.92 -2.92,-2.92z"/>
5+
</vector>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
3+
<stroke
4+
android:width="0dp" />
5+
6+
<solid android:color="#4dace3" />
7+
8+
<padding
9+
android:left="1dp"
10+
android:right="1dp"
11+
android:bottom="1dp"
12+
android:top="1dp" />
13+
14+
<corners android:radius="10dp" />
15+
</shape>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
3+
<stroke
4+
android:width="0dp" />
5+
6+
<solid android:color="#ffff54" />
7+
8+
<padding
9+
android:left="1dp"
10+
android:right="1dp"
11+
android:bottom="1dp"
12+
android:top="1dp" />
13+
14+
<corners android:radius="10dp" />
15+
</shape>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
3+
<stroke
4+
android:width="0dp" />
5+
6+
<solid android:color="#FFFFFF" />
7+
8+
<padding
9+
android:left="1dp"
10+
android:right="1dp"
11+
android:bottom="1dp"
12+
android:top="1dp" />
13+
14+
<corners android:radius="20dp" />
15+
</shape>
Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:app="http://schemas.android.com/apk/res-auto"
4+
xmlns:tools="http://schemas.android.com/tools"
5+
android:layout_width="match_parent"
6+
android:layout_height="match_parent">
7+
8+
<androidx.constraintlayout.widget.ConstraintLayout
9+
android:layout_width="300dp"
10+
android:layout_height="240dp"
11+
android:layout_margin="30dp"
12+
android:layout_marginTop="30dp"
13+
app:layout_constraintBottom_toBottomOf="parent"
14+
app:layout_constraintEnd_toEndOf="parent"
15+
app:layout_constraintHorizontal_bias="0.504"
16+
app:layout_constraintStart_toStartOf="parent"
17+
app:layout_constraintTop_toBottomOf="@+id/constraintLayout6">
18+
19+
<ImageView
20+
android:id="@+id/imageView5"
21+
android:layout_width="50dp"
22+
android:layout_height="50dp"
23+
app:layout_constraintStart_toStartOf="parent"
24+
app:layout_constraintTop_toTopOf="parent"
25+
app:srcCompat="@drawable/baseline_logout_24" />
26+
27+
<TextView
28+
android:id="@+id/textView6"
29+
android:layout_width="0dp"
30+
android:layout_height="wrap_content"
31+
android:layout_marginStart="15dp"
32+
android:text="Share Device"
33+
android:textSize="20sp"
34+
app:layout_constraintEnd_toEndOf="parent"
35+
app:layout_constraintStart_toEndOf="@+id/imageView5"
36+
app:layout_constraintTop_toTopOf="parent" />
37+
38+
<TextView
39+
android:id="@+id/textView8"
40+
android:layout_width="0dp"
41+
android:layout_height="wrap_content"
42+
android:layout_marginStart="15dp"
43+
android:layout_marginTop="10dp"
44+
android:text="341784"
45+
android:textSize="24sp"
46+
app:layout_constraintEnd_toEndOf="parent"
47+
app:layout_constraintHorizontal_bias="0.0"
48+
app:layout_constraintStart_toEndOf="@+id/imageView5"
49+
app:layout_constraintTop_toBottomOf="@+id/textView10" />
50+
51+
<Button
52+
android:id="@+id/shareButton"
53+
android:layout_width="wrap_content"
54+
android:layout_height="wrap_content"
55+
android:layout_marginStart="15dp"
56+
android:background="@drawable/round_button_share"
57+
android:text="Share"
58+
android:textColor="#3C3C3C"
59+
app:layout_constraintBottom_toBottomOf="parent"
60+
app:layout_constraintStart_toEndOf="@+id/imageView5"
61+
app:layout_constraintTop_toBottomOf="@+id/textView8" />
62+
63+
<TextView
64+
android:id="@+id/textView9"
65+
android:layout_width="0dp"
66+
android:layout_height="wrap_content"
67+
android:layout_marginStart="15dp"
68+
android:layout_marginTop="20dp"
69+
android:text="Use a generated code to share device with friends and family"
70+
app:layout_constraintEnd_toEndOf="parent"
71+
app:layout_constraintStart_toEndOf="@+id/imageView5"
72+
app:layout_constraintTop_toBottomOf="@+id/textView6" />
73+
74+
<TextView
75+
android:id="@+id/textView10"
76+
android:layout_width="0dp"
77+
android:layout_height="wrap_content"
78+
android:layout_marginStart="15dp"
79+
android:layout_marginTop="20dp"
80+
android:text="Share code with friends"
81+
app:layout_constraintEnd_toEndOf="parent"
82+
app:layout_constraintStart_toEndOf="@+id/imageView5"
83+
app:layout_constraintTop_toBottomOf="@+id/textView9" />
84+
</androidx.constraintlayout.widget.ConstraintLayout>
85+
86+
<TextView
87+
android:id="@+id/textView3"
88+
android:layout_width="wrap_content"
89+
android:layout_height="wrap_content"
90+
android:layout_marginTop="30dp"
91+
android:text="Share Device"
92+
android:textSize="28sp"
93+
android:textStyle="bold"
94+
app:layout_constraintEnd_toEndOf="parent"
95+
app:layout_constraintStart_toStartOf="parent"
96+
app:layout_constraintTop_toTopOf="parent" />
97+
98+
<androidx.constraintlayout.widget.ConstraintLayout
99+
android:id="@+id/constraintLayout6"
100+
android:layout_width="300dp"
101+
android:layout_height="240dp"
102+
android:layout_margin="30dp"
103+
app:layout_constraintEnd_toEndOf="parent"
104+
app:layout_constraintStart_toStartOf="parent"
105+
app:layout_constraintTop_toBottomOf="@+id/textView3">
106+
107+
<ImageView
108+
android:id="@+id/imageView15"
109+
android:layout_width="50dp"
110+
android:layout_height="50dp"
111+
app:layout_constraintStart_toStartOf="parent"
112+
app:layout_constraintTop_toTopOf="parent"
113+
app:srcCompat="@drawable/baseline_login_24" />
114+
115+
<TextView
116+
android:id="@+id/textView16"
117+
android:layout_width="0dp"
118+
android:layout_height="wrap_content"
119+
android:layout_marginStart="15dp"
120+
android:text="Get Device"
121+
android:textSize="20sp"
122+
app:layout_constraintEnd_toEndOf="parent"
123+
app:layout_constraintStart_toEndOf="@+id/imageView15"
124+
app:layout_constraintTop_toTopOf="parent" />
125+
126+
<EditText
127+
android:id="@+id/textView18"
128+
android:layout_width="0dp"
129+
android:layout_height="wrap_content"
130+
android:layout_marginStart="15dp"
131+
android:layout_marginTop="10dp"
132+
android:hint="Code"
133+
android:text="341784"
134+
android:textSize="24sp"
135+
app:layout_constraintEnd_toEndOf="parent"
136+
app:layout_constraintHorizontal_bias="0.0"
137+
app:layout_constraintStart_toEndOf="@+id/imageView15"
138+
app:layout_constraintTop_toBottomOf="@+id/textView110" />
139+
140+
<Button
141+
android:id="@+id/connectButton"
142+
android:layout_width="wrap_content"
143+
android:layout_height="wrap_content"
144+
android:layout_marginStart="15dp"
145+
android:background="@drawable/round_button"
146+
android:text="Connect"
147+
android:textColor="#FFFFFF"
148+
app:layout_constraintBottom_toBottomOf="parent"
149+
app:layout_constraintStart_toEndOf="@+id/imageView15"
150+
app:layout_constraintTop_toBottomOf="@+id/textView18" />
151+
152+
<TextView
153+
android:id="@+id/textView19"
154+
android:layout_width="0dp"
155+
android:layout_height="wrap_content"
156+
android:layout_marginStart="15dp"
157+
android:layout_marginTop="20dp"
158+
android:text="Type code from another device to get device on your phone"
159+
app:layout_constraintEnd_toEndOf="parent"
160+
app:layout_constraintStart_toEndOf="@+id/imageView15"
161+
app:layout_constraintTop_toBottomOf="@+id/textView16" />
162+
163+
<TextView
164+
android:id="@+id/textView110"
165+
android:layout_width="0dp"
166+
android:layout_height="wrap_content"
167+
android:layout_marginStart="15dp"
168+
android:layout_marginTop="20dp"
169+
android:text="Security code from friend"
170+
app:layout_constraintEnd_toEndOf="parent"
171+
app:layout_constraintStart_toEndOf="@+id/imageView15"
172+
app:layout_constraintTop_toBottomOf="@+id/textView19" />
173+
</androidx.constraintlayout.widget.ConstraintLayout>
174+
175+
</androidx.constraintlayout.widget.ConstraintLayout>

0 commit comments

Comments
 (0)