Skip to content

Commit

Permalink
Merge pull request #91 from learning-layers/integration
Browse files Browse the repository at this point in the history
Release v1.4.0
  • Loading branch information
melonmanchan committed May 4, 2016
2 parents ee4a602 + fc12d74 commit f34282d
Show file tree
Hide file tree
Showing 13 changed files with 43 additions and 322 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ public final class VideoCreatorService extends IntentService {
public static final String ARG_VIDEO_URI = "ARG_VIDEO_URI";
public static final String ARG_VIDEO_ID = "ARG_VIDEO_ID";
public static final String ARG_VIDEO_TITLE = "ARG_VIDEO_TITLE";
public static final String ARG_VIDEO_GENRE = "ARG_VIDEO_GENRE";
public static final String ARG_VIDEO_TAG = "ARG_VIDEO_TAG";
public static final String ARG_VIDEO_DATE = "ARG_VIDEO_DATE";
public static final String ARG_VIDEO_AUTHOR_NAME = "ARG_VIDEO_AUTHOR_NAME";
Expand All @@ -64,18 +63,18 @@ public final class VideoCreatorService extends IntentService {
private Bus bus;

/**
* Returns a builder for a video. Video URI and genre must be supplied via the builder's setters
* Returns a builder for a video. Video URI must be supplied via the builder's setters
* before calling VideoBuilder#create().
*/
public static VideoBuilder build() {
return new VideoBuilder(null, null);
return new VideoBuilder();
}

/**
* Returns a builder for a video.
*/
public static VideoBuilder build(Uri videoUri, String videoGenre) {
return new VideoBuilder(videoUri, videoGenre);
public static VideoBuilder build(Uri videoUri) {
return new VideoBuilder(videoUri);
}

/**
Expand Down Expand Up @@ -103,7 +102,6 @@ protected void onHandleIntent(Intent intent) {
Uri videoContentUri = intent.getParcelableExtra(ARG_VIDEO_URI);
UUID id = (UUID) intent.getSerializableExtra(ARG_VIDEO_ID);
String title = intent.getStringExtra(ARG_VIDEO_TITLE);
String genre = intent.getStringExtra(ARG_VIDEO_GENRE);
String tag = intent.getStringExtra(ARG_VIDEO_TAG);
Date date = (Date) intent.getSerializableExtra(ARG_VIDEO_DATE);
String authorName = intent.getStringExtra(ARG_VIDEO_AUTHOR_NAME);
Expand Down Expand Up @@ -154,7 +152,7 @@ protected void onHandleIntent(Intent intent) {
}

// Send an analytics hit
sendAnalytics(genre, getDuration(videoFile));
sendAnalytics(getDuration(videoFile));

Uri manifestUri = Uri.fromFile(manifestFile);
Uri videoUri = Uri.fromFile(videoFile);
Expand All @@ -164,7 +162,7 @@ protected void onHandleIntent(Intent intent) {
int formatVersion = Video.VIDEO_FORMAT_VERSION;

Video video = new Video(App.videoRepository, manifestUri, videoUri, thumbUri, id, title,
genre, tag, rotation, date, author, location, formatVersion, annotations);
tag, rotation, date, author, location, formatVersion, annotations);

video.save();

Expand Down Expand Up @@ -285,14 +283,12 @@ private String getAddress(@Nullable Location location) {
/**
* Sends an analytics hit for creating a video.
*
* @param genre Genre of the created video.
* @param duration Duration of the created video (in milliseconds) or -1 to not report it.
*/
private void sendAnalytics(String genre, long duration) {
private void sendAnalytics(long duration) {
HitBuilders.EventBuilder event = new HitBuilders.EventBuilder()
.setCategory(AppAnalytics.CATEGORY_VIDEOS)
.setAction(AppAnalytics.ACTION_CREATE)
.setLabel(genre);
.setAction(AppAnalytics.ACTION_CREATE);

// Round the duration
if (duration != -1) {
Expand Down Expand Up @@ -359,7 +355,6 @@ public static final class VideoBuilder implements Parcelable {

private UUID id = UUID.randomUUID();
private Uri videoUri;
private String genre;

private String title;
private String tag;
Expand All @@ -372,19 +367,19 @@ public static final class VideoBuilder implements Parcelable {
/**
* If null, missing parameters must be supplied via their setters before calling #create().
*/
private VideoBuilder(@Nullable Uri videoUri, @Nullable String genre) {
private VideoBuilder(@Nullable Uri videoUri) {
this.videoUri = videoUri;
this.genre = genre;
}

private VideoBuilder() {}

protected VideoBuilder(Parcel parcel) {
id = (UUID) parcel.readValue(UUID.class.getClassLoader());
videoUri = (Uri) parcel.readValue(Uri.class.getClassLoader());
authorUri = (Uri) parcel.readValue(Uri.class.getClassLoader());
location = (Location) parcel.readValue(Location.class.getClassLoader());

title = parcel.readString();
genre = parcel.readString();
tag = parcel.readString();
authorName = parcel.readString();

Expand Down Expand Up @@ -414,10 +409,6 @@ public VideoBuilder setVideoUri(Uri videoUri) {
return this;
}

public VideoBuilder setGenre(String genre) {
this.genre = genre;
return this;
}

public VideoBuilder setTitle(String title) {
this.title = title;
Expand Down Expand Up @@ -451,15 +442,14 @@ public VideoBuilder setAnnotations(List<Annotation> annotations) {
}

public void create(Context context) {
if (this.videoUri == null || this.genre == null) {
throw new IllegalArgumentException("Video URI and genre must be supplied.");
if (this.videoUri == null) {
throw new IllegalArgumentException("Video URI must be supplied.");
}

Intent intent = new Intent(context, VideoCreatorService.class);

intent.putExtra(ARG_VIDEO_ID, this.id);
intent.putExtra(ARG_VIDEO_URI, this.videoUri);
intent.putExtra(ARG_VIDEO_GENRE, this.genre);

intent.putExtra(ARG_VIDEO_TITLE, this.title);
intent.putExtra(ARG_VIDEO_TAG, this.tag);
Expand All @@ -486,7 +476,6 @@ public void writeToParcel(Parcel parcel, int flags) {
parcel.writeValue(location);

parcel.writeString(title);
parcel.writeString(genre);
parcel.writeString(tag);
parcel.writeString(authorName);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
import fi.aalto.legroup.achso.authentication.LoginRequestEvent;
import fi.aalto.legroup.achso.authentication.LoginStateEvent;
import fi.aalto.legroup.achso.authentication.OIDCConfig;
import fi.aalto.legroup.achso.authoring.GenreDialogFragment;
import fi.aalto.legroup.achso.authoring.QRHelper;
import fi.aalto.legroup.achso.authoring.VideoCreatorService;
import fi.aalto.legroup.achso.settings.SettingsActivity;
Expand Down Expand Up @@ -421,17 +420,7 @@ private void createVideo(int resultCode, @Nullable Intent resultData) {
videoBuilder.setVideoUri(resultData.getData());
}

GenreDialogFragment fragment = new GenreDialogFragment();

fragment.setCallback(new GenreDialogFragment.Callback() {
@Override
public void onGenreSelected(String genre) {
videoBuilder.setGenre(genre);
videoBuilder.create(BrowserActivity.this);
}
});

fragment.show(getFragmentManager(), fragment.getClass().getSimpleName());
videoBuilder.create(BrowserActivity.this);
}

private void showSettings() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,16 @@
import com.nispok.snackbar.SnackbarManager;

import fi.aalto.legroup.achso.R;
import fi.aalto.legroup.achso.authoring.GenreDialogFragment;
import fi.aalto.legroup.achso.entities.Video;
import fi.aalto.legroup.achso.utilities.TranslationHelper;

public final class DetailFragment extends Fragment {

private TextView titleField;
private TextView genreField;
private TextView creatorField;
private TextView qrCodeField;
private TextView uploadedField;

private ImageButton titleEditButton;
private ImageButton genreEditButton;

private Video video;

Expand All @@ -50,13 +46,11 @@ public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);

titleField = (TextView) view.findViewById(R.id.titleField);
genreField = (TextView) view.findViewById(R.id.genreField);
creatorField = (TextView) view.findViewById(R.id.creatorField);
qrCodeField = (TextView) view.findViewById(R.id.qrCodeField);
uploadedField = (TextView) view.findViewById(R.id.uploadedField);

titleEditButton = (ImageButton) view.findViewById(R.id.titleEditButton);
genreEditButton = (ImageButton) view.findViewById(R.id.genreEditButton);
}

@Override
Expand All @@ -74,12 +68,6 @@ public void onClick(View view) {
}
});

genreEditButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
showGenreEditDialog();
}
});
}

private void populateInformation() {
Expand All @@ -101,10 +89,7 @@ private void populateInformation() {
uploaded = getString(R.string.no);
}

TranslationHelper translationHelper = TranslationHelper.get(getActivity());

titleField.setText(video.getTitle());
genreField.setText(translationHelper.getGenreText(video.getGenre()));
creatorField.setText(authorName);
qrCodeField.setText(qrCode);
uploadedField.setText(uploaded);
Expand Down Expand Up @@ -139,23 +124,6 @@ public void onClick(DialogInterface dialogInterface, int which) {
.show();
}

private void showGenreEditDialog() {
GenreDialogFragment fragment = new GenreDialogFragment();

fragment.setCallback(new GenreDialogFragment.Callback() {
@Override
public void onGenreSelected(String genre) {
video.setGenre(genre);

if (!video.save()) {
SnackbarManager.show(Snackbar.with(getActivity()).text(R.string.storage_error));
}

populateInformation();
}
});

fragment.show(getFragmentManager(), "GenreDialogFragment");
}
private void showGenreEditDialog() {}

}
Loading

0 comments on commit f34282d

Please sign in to comment.