Skip to content

Commit

Permalink
Merge pull request #100 from learning-layers/integration
Browse files Browse the repository at this point in the history
Release v1.8.2
  • Loading branch information
melonmanchan authored Dec 18, 2016
2 parents 0bd41d9 + b170cac commit 9db314e
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,21 @@ public User getUser() {
return user;
}

public boolean isDefaultUser(User user) {
String name = user.getName();

// TODO: Better way of doing this
if (name.equals("Unknown") || name.equals("Unbekannt") || name.equals("Tuntematon") || name.equals("Tundmatu")) {
return true;
}

if (user.equals(defaultUser)) {
return true;
}

return false;
}

public boolean isLoggedIn() {
return state == LoginState.LOGGED_IN || isLoggingOut();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -523,12 +523,6 @@ public void onVideoCreationState(VideoCreatorService.VideoCreationStateEvent eve
if (fragment != null) {
manager.beginTransaction().remove(fragment).commit();
}

UUID id = event.getId();
Intent infoIntent = new Intent(this, DetailActivity.class);
infoIntent.putExtra(DetailActivity.ARG_VIDEO_ID, id);
startActivity(infoIntent);

break;

case ERROR:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ public void onCreate(Bundle savedInstanceState) {
initializeIsLocal();

if (!App.videoRepository.isAuthorizedToShareVideo(video.getId())) {
System.out.println("not authorized!");
isPublicCheckbox.setEnabled(false);
groupsButton.setEnabled(false);
SnackbarManager.show(Snackbar.with(DetailActivity.this).text("You do not have the rights to share this video!"));
Expand Down Expand Up @@ -302,6 +301,16 @@ public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
}

private void initializeUploadButton() {
if (!App.loginManager.isLoggedIn()) {
String loginPrompt = getString(R.string.login_before_upload);

uploadButton.setEnabled(false);
uploadButton.setAlpha(.5f);
uploadButton.setText(loginPrompt);

return;
}

if (!video.isLocal()) {
uploadButton.setEnabled(false);
uploadButton.setVisibility(View.GONE);
Expand All @@ -316,6 +325,12 @@ public void onClick(View view) {
uploadButton.setAlpha(.5f);
uploadButton.setText(currentlyUploading);

// Set author to currently logged in user
if (App.loginManager.isDefaultUser(video.getAuthor())) {
video.setAuthor(App.loginManager.getUser());
video.save(null);
}

UUID id = video.getId();
UploadService.upload(DetailActivity.this, id);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -753,6 +753,11 @@ public boolean isAuthorizedToShareVideo(UUID id) {
currentUser = App.loginManager.getUser();
author = UserPool.getInternedUser(video.getAuthorUserIndex());

// Allow anybody to manipulate videos made by the default user
if (App.loginManager.isDefaultUser(author)) {
return true;
}

if (currentUser.equals(author)) {
return true;
}
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -135,5 +135,6 @@
<string name="qr_tag_fail">Etikettieren Video mit QR fehlgeschlagen!</string>
<string name="qr_tag_success">Video markiert mit QR-Code</string>
<string name="add_qr">In QR</string>
<string name="login_before_upload">Melden Sie sich vor dem Hochladen an</string>

</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-et/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -131,5 +131,6 @@
<string name="qr_tag_fail">Sildi video QR ebaõnnestus!</string>
<string name="qr_tag_success">Video sildistatud QR koodi</string>
<string name="add_qr">Lisa QR</string>
<string name="login_before_upload">Logi sisse enne üleslaadimist</string>

</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-fi/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -162,4 +162,5 @@
<string name="qr_tag_fail">QR-koodin lisäys videoon epäonnistuo</string>
<string name="qr_tag_success">QR-koodin lisäys videoon onnistui</string>
<string name="add_qr">Lisää QR</string>
<string name="login_before_upload">Kirjaudu sisään ennen lähetystä</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -185,5 +185,6 @@
<string name="qr_tag_success">Video tagged with QR code</string>
<string name="qr_tag_fail">Tagging video with QR failed!</string>
<string name="add_qr">Add QR</string>
<string name="login_before_upload">Log in before uploading</string>

</resources>
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.0'
classpath 'com.android.tools.build:gradle:2.2.3'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down

0 comments on commit 9db314e

Please sign in to comment.