Skip to content

Commit eb50d8b

Browse files
jules20022000Paul Nadal
and
Paul Nadal
authored
add comments (#237)
* activities package * activities package * activities package * activities package * activities package * comments until call * comments * add comments to wallet package * comments * comments * comments * add comments to wallet package Co-authored-by: Paul Nadal <[email protected]>
1 parent e917cd0 commit eb50d8b

40 files changed

+950
-15
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ firestore.rules
1414
firestore.indexes.json
1515
firebase.json
1616
storage.rules
17-
17+
upload-keystore.jks

app/src/main/java/ch/epfl/sweng/hostme/account/Profile.java

+36-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ public class Profile {
99
private String school;
1010

1111
public Profile() {
12-
1312
}
1413

1514
public Profile(String firstName, String lastName, String email, String gender, String school) {
@@ -21,38 +20,74 @@ public Profile(String firstName, String lastName, String email, String gender, S
2120
}
2221

2322

23+
/**
24+
* get the first name of the user
25+
* @return first name
26+
*/
2427
public String getFirstName() {
2528
return firstName;
2629
}
2730

31+
/**
32+
* set the first name of the user
33+
* @param firstName to be set
34+
*/
2835
public void setFirstName(String firstName) {
2936
this.firstName = firstName;
3037
}
3138

39+
/**
40+
* get the last name of the user
41+
* @return last name
42+
*/
3243
public String getLastName() {
3344
return lastName;
3445
}
3546

47+
/**
48+
* set the last name of the user
49+
* @param lastName to be set
50+
*/
3651
public void setLastName(String lastName) {
3752
this.lastName = lastName;
3853
}
3954

55+
/**
56+
* get the gender of the user
57+
* @return gender
58+
*/
4059
public String getGender() {
4160
return gender;
4261
}
4362

63+
/**
64+
* set the gender of the user
65+
* @param gender to be set
66+
*/
4467
public void setGender(String gender) {
4568
this.gender = gender;
4669
}
4770

71+
/**
72+
* get the email of the user
73+
* @return email
74+
*/
4875
public String getEmail() {
4976
return email;
5077
}
5178

79+
/**
80+
* set the email of the user
81+
* @param email to be set
82+
*/
5283
public void setEmail(String email) {
5384
this.email = email;
5485
}
5586

87+
/**
88+
* get the school of the user
89+
* @return school
90+
*/
5691
public String getSchool() {
5792
return school;
5893
}

app/src/main/java/ch/epfl/sweng/hostme/activities/CallActivity.java

+75
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,17 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
9898
checkPermissionsAndInitEngine();
9999
}
100100

101+
/**
102+
* switch the front or back camera
103+
*/
101104
private void onSwitchCamera() {
102105
this.mRtcEngine.switchCamera();
103106
}
104107

108+
/**
109+
* Check that the permissions are enabled otherwise ask to the user
110+
* Init agora if permissions are enabled
111+
*/
105112
private void checkPermissionsAndInitEngine() {
106113
ArrayList<String> permissions = new ArrayList<>();
107114
permissions.add(Manifest.permission.RECORD_AUDIO);
@@ -119,13 +126,20 @@ private void checkPermissionsAndInitEngine() {
119126
}
120127
}
121128

129+
/**
130+
* Send a notification to the called user and update the database such that
131+
* the callee has access to the room name
132+
*/
122133
private void sendNotification() {
123134
FcmNotificationsSender sender = new FcmNotificationsSender(this.user.getToken(), NOTIFICATION_TITLE,
124135
NOTIFICATION_BODY, getApplicationContext(), CallActivity.this);
125136
sender.sendNotifications();
126137
reference.document(this.user.getId()).update(ROOM_NAME, currUserID);
127138
}
128139

140+
/**
141+
* Join the channel corresponding to the room name in the db
142+
*/
129143
private void joinChannel() {
130144
reference.document(Auth.getUid()).get().addOnSuccessListener(res -> {
131145
if (res.exists()) {
@@ -151,6 +165,10 @@ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permis
151165
}
152166
}
153167

168+
/**
169+
* Create the agora engine and
170+
* If the user is the caller join the channel and send notif otherwise just join the channel
171+
*/
154172
private void initAgoraEngine() {
155173
try {
156174
this.mRtcEngine = RtcEngine.create(getApplicationContext(), getString(R.string.agora_app_id), mRtcEventHandler);
@@ -165,6 +183,9 @@ private void initAgoraEngine() {
165183
}
166184
}
167185

186+
/**
187+
* Initialize basics of the RTC engine (video, audio...)
188+
*/
168189
private void setupSession() {
169190
this.mRtcEngine.setChannelProfile(io.agora.rtc.Constants.CHANNEL_PROFILE_COMMUNICATION);
170191
this.mRtcEngine.enableVideo();
@@ -174,6 +195,10 @@ private void setupSession() {
174195
VideoEncoderConfiguration.ORIENTATION_MODE.ORIENTATION_MODE_FIXED_PORTRAIT));
175196
}
176197

198+
/**
199+
* Set up the video of the local user and all the layout that
200+
* follows from that
201+
*/
177202
private void setupLocalVideoFeed() {
178203
this.mRtcEngine.setChannelProfile(CHANNEL_PROFILE_LIVE_BROADCASTING);
179204
this.mRtcEngine.enableVideo();
@@ -190,6 +215,12 @@ private void setupLocalVideoFeed() {
190215
this.mRtcEngine.setupLocalVideo(new VideoCanvas(videoSurface, VideoCanvas.RENDER_MODE_FIT, 0));
191216
}
192217

218+
/**
219+
* Set up the video of the remote user and all the layout that
220+
* follows from that
221+
*
222+
* @param uid of the user who joined the call
223+
*/
193224
private void setupRemoteVideoStream(int uid) {
194225
FrameLayout videoContainer = findViewById(R.id.bg_video_container);
195226
SurfaceView videoSurface = RtcEngine.CreateRendererView(getBaseContext());
@@ -198,26 +229,45 @@ private void setupRemoteVideoStream(int uid) {
198229
this.mRtcEngine.setRemoteSubscribeFallbackOption(io.agora.rtc.Constants.STREAM_FALLBACK_OPTION_AUDIO_ONLY);
199230
}
200231

232+
/**
233+
* CHange the layout if the remote user change his camera from selfie to field
234+
* or from field to selfie
235+
*
236+
* @param state selfie or field mode
237+
*/
201238
private void onRemoteUserVideoToggle(int state) {
202239
FrameLayout videoContainer = findViewById(R.id.bg_video_container);
203240
SurfaceView videoSurface = (SurfaceView) videoContainer.getChildAt(0);
204241
videoSurface.setVisibility(state == 0 ? View.GONE : View.VISIBLE);
205242
}
206243

244+
/**
245+
* init token, set room name and local video when user joined
246+
* channel
247+
*/
207248
private void onJoinChannelClicked() {
208249
String channelName = currUserID;
209250
initToken(channelName);
210251
this.mRtcEngine.joinChannel(this.result, channelName, null, 0);
211252
setupLocalVideoFeed();
212253
}
213254

255+
/**
256+
* Init the token for the channel with the corresponding channel name
257+
*
258+
* @param channelName of the caller (his user id)
259+
*/
214260
private void initToken(String channelName) {
215261
RtcTokenBuilder token = new RtcTokenBuilder();
216262
int timestamp = (int) (System.currentTimeMillis() / 1000 + expirationTimeInSeconds);
217263
this.result = token.buildTokenWithUid(getString(R.string.agora_app_id), getString(R.string.agora_certificate),
218264
channelName, 0, RtcTokenBuilder.Role.Role_Publisher, timestamp);
219265
}
220266

267+
/**
268+
* leave the channel with the RTC engine, remove video, update the room name
269+
* to null in the database and return to the menu
270+
*/
221271
private void onLeaveChannelClicked() {
222272
this.mRtcEngine.leaveChannel();
223273
removeVideo(R.id.floating_video_container);
@@ -229,18 +279,35 @@ private void onLeaveChannelClicked() {
229279
finish();
230280
}
231281

282+
/**
283+
* Remove the video
284+
*
285+
* @param containerID corresponding id the container
286+
*/
232287
private void removeVideo(int containerID) {
233288
FrameLayout videoContainer = findViewById(containerID);
234289
videoContainer.setVisibility(View.GONE);
235290
videoContainer.removeAllViews();
236291
}
237292

293+
/**
294+
* Mute the local audio stream when the local user clicks on the
295+
* microphone button
296+
*
297+
* @param view id of the button element
298+
*/
238299
private void onAudioMuteClicked(View view) {
239300
ImageView btn = (ImageView) view;
240301
changeButtonState(btn, R.drawable.btn_mute, R.drawable.btn_unmute);
241302
this.mRtcEngine.muteLocalAudioStream(btn.isSelected());
242303
}
243304

305+
/**
306+
* Stop the local video stream when the local user clicks on the
307+
* microphone button and adapt the corresponding layout
308+
*
309+
* @param view id of the video element
310+
*/
244311
private void onVideoMuteClicked(View view) {
245312
ImageView btn = (ImageView) view;
246313
changeButtonState(btn, R.drawable.video_toggle_active_btn, R.drawable.video_toggle_btn);
@@ -252,6 +319,14 @@ private void onVideoMuteClicked(View view) {
252319
videoSurface.setVisibility(btn.isSelected() ? View.GONE : View.VISIBLE);
253320
}
254321

322+
/**
323+
* CHange the button state depending on the previous buttton
324+
* state
325+
*
326+
* @param btn correspond ID of the button
327+
* @param active drawable of the active button
328+
* @param inactive drawable of the inactive button
329+
*/
255330
private void changeButtonState(ImageView btn, int active, int inactive) {
256331
if (btn.isSelected()) {
257332
btn.setSelected(false);

app/src/main/java/ch/epfl/sweng/hostme/activities/ChangePwdAccountActivity.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import ch.epfl.sweng.hostme.database.Auth;
1919

2020
public class ChangePwdAccountActivity extends AppCompatActivity {
21-
2221
private static final String MODIFICATION_SUCCEED = "Password successfully modified";
2322
private static final String MODIFICATION_FAILED = "Password modification failed";
2423
private static final String AUTH_FAILED = "Authentication failed";
@@ -58,8 +57,9 @@ private void changePasswordDB(String oldPassword, String newPassword) {
5857
AuthCredential credential = EmailAuthProvider.getCredential(Objects.requireNonNull(email), oldPassword);
5958

6059
user.reauthenticate(credential).addOnSuccessListener(result -> user.updatePassword(newPassword).addOnSuccessListener(result2 -> {
61-
Toast.makeText(this, MODIFICATION_SUCCEED, Toast.LENGTH_SHORT).show();
62-
this.getFragmentManager().popBackStack();
63-
}).addOnFailureListener(error2 -> Toast.makeText(this, MODIFICATION_FAILED, Toast.LENGTH_SHORT).show())).addOnFailureListener(error -> Toast.makeText(this, AUTH_FAILED, Toast.LENGTH_SHORT).show());
60+
Toast.makeText(this, MODIFICATION_SUCCEED, Toast.LENGTH_SHORT).show();
61+
this.getFragmentManager().popBackStack();
62+
}).addOnFailureListener(error2 -> Toast.makeText(this, MODIFICATION_FAILED, Toast.LENGTH_SHORT).show()))
63+
.addOnFailureListener(error -> Toast.makeText(this, AUTH_FAILED, Toast.LENGTH_SHORT).show());
6464
}
6565
}

app/src/main/java/ch/epfl/sweng/hostme/activities/ChangePwdHomeActivity.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ protected void onCreate(Bundle savedInstanceState) {
4949
}
5050

5151
/**
52-
* Send email to change password
52+
* Send email to the user to change password
5353
*/
5454
private void sendMail(String mailText) {
5555
Auth.resetEmail(mailText)

0 commit comments

Comments
 (0)