ControllerOverlay.Listener {
private VideoView mVideoView;
+ private TextView mSaveVideoTextView;
private TrimControllerOverlay mController;
private Context mContext;
private Uri mUri;
actionBar.setDisplayOptions(displayOptions, displayOptions);
actionBar.setCustomView(R.layout.trim_menu);
- TextView mSaveVideoTextView = (TextView) findViewById(R.id.start_trim);
+ mSaveVideoTextView = (TextView) findViewById(R.id.start_trim);
mSaveVideoTextView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
trimVideo();
}
});
+ mSaveVideoTextView.setEnabled(false);
Intent intent = getIntent();
mUri = intent.getData();
return dir[0];
}
- private void trimVideo() {
+ private boolean isModified() {
int delta = mTrimEndTime - mTrimStartTime;
+
// Considering that we only trim at sync frame, we don't want to trim
// when the time interval is too short or too close to the origin.
- if (delta < 100 ) {
- Toast.makeText(getApplicationContext(),
- getString(R.string.trim_too_short),
- Toast.LENGTH_SHORT).show();
- return;
- }
- if (Math.abs(mVideoView.getDuration() - delta) < 100) {
- // If no change has been made, go back
- onBackPressed();
- return;
+ if (delta < 100 || Math.abs(mVideoView.getDuration() - delta) < 100) {
+ return false;
+ } else {
+ return true;
}
+ }
+ private void trimVideo() {
// Use the default save directory if the source directory cannot be
// saved.
mSaveDirectory = getSaveDirectory();
mTrimStartTime = start;
mTrimEndTime = end;
setProgress();
+ // Enable save if there's modifications
+ mSaveVideoTextView.setEnabled(isModified());
}
@Override
private View mListGeometry = null;
private View mListColors = null;
private View mListFilterButtons = null;
+ private View mSaveButton = null;
private ImageButton mFxButton = null;
private ImageButton mBorderButton = null;
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
actionBar.setCustomView(R.layout.filtershow_actionbar);
- actionBar.getCustomView().setOnClickListener(new OnClickListener() {
+ mSaveButton = actionBar.getCustomView();
+ mSaveButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
saveImage();
return false;
}
+ public void enableSave(boolean enable) {
+ if (mSaveButton != null)
+ mSaveButton.setEnabled(enable);
+ }
+
private void fillListImages(LinearLayout listFilters) {
// TODO: use listview
// TODO: load the filters straight from the filesystem
}
updateSeekBar(parameter, minp, maxp);
invalidate();
+ mActivity.enableSave(hasModifications());
}
@Override
public void updateImagePresets(boolean force) {
ImagePreset preset = getImagePreset();
if (preset == null) {
+ mActivity.enableSave(false);
return;
}
if (force) {
mFiltersOnlyImage = null;
}
}
+ mActivity.enableSave(hasModifications());
}
public void requestFilteredImages() {