use of org.odk.collect.android.views.DrawView in project collect by opendatakit.
the class DrawActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.draw_layout);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
fabActions = findViewById(R.id.fab_actions);
final FloatingActionButton fabSetColor = findViewById(R.id.fab_set_color);
final CardView cardViewSetColor = findViewById(R.id.cv_set_color);
final FloatingActionButton fabSaveAndClose = findViewById(R.id.fab_save_and_close);
final CardView cardViewSaveAndClose = findViewById(R.id.cv_save_and_close);
final FloatingActionButton fabClear = findViewById(R.id.fab_clear);
final CardView cardViewClear = findViewById(R.id.cv_clear);
fabActions.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
int status = Integer.parseInt(view.getTag().toString());
if (status == 0) {
status = 1;
fabActions.animate().rotation(45).setInterpolator(new AccelerateDecelerateInterpolator()).setDuration(100).start();
AnimateUtils.scaleInAnimation(fabSetColor, 50, 150, new OvershootInterpolator(), true);
AnimateUtils.scaleInAnimation(cardViewSetColor, 50, 150, new OvershootInterpolator(), true);
AnimateUtils.scaleInAnimation(fabSaveAndClose, 100, 150, new OvershootInterpolator(), true);
AnimateUtils.scaleInAnimation(cardViewSaveAndClose, 100, 150, new OvershootInterpolator(), true);
AnimateUtils.scaleInAnimation(fabClear, 150, 150, new OvershootInterpolator(), true);
AnimateUtils.scaleInAnimation(cardViewClear, 150, 150, new OvershootInterpolator(), true);
} else {
status = 0;
fabActions.animate().rotation(0).setInterpolator(new AccelerateDecelerateInterpolator()).setDuration(100).start();
fabSetColor.setVisibility(View.INVISIBLE);
cardViewSetColor.setVisibility(View.INVISIBLE);
fabSaveAndClose.setVisibility(View.INVISIBLE);
cardViewSaveAndClose.setVisibility(View.INVISIBLE);
fabClear.setVisibility(View.INVISIBLE);
cardViewClear.setVisibility(View.INVISIBLE);
}
view.setTag(status);
}
});
Bundle extras = getIntent().getExtras();
if (extras == null) {
loadOption = OPTION_DRAW;
refImage = null;
savepointImage = new File(Collect.TMPDRAWFILE_PATH);
savepointImage.delete();
output = new File(Collect.TMPFILE_PATH);
} else {
if (extras.getInt(SCREEN_ORIENTATION) == 1) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
loadOption = extras.getString(OPTION);
if (loadOption == null) {
loadOption = OPTION_DRAW;
}
// refImage can also be present if resuming a drawing
Uri uri = (Uri) extras.get(REF_IMAGE);
if (uri != null) {
refImage = new File(uri.getPath());
}
String savepoint = extras.getString(SAVEPOINT_IMAGE);
if (savepoint != null) {
savepointImage = new File(savepoint);
if (!savepointImage.exists() && refImage != null && refImage.exists()) {
FileUtils.copyFile(refImage, savepointImage);
}
} else {
savepointImage = new File(Collect.TMPDRAWFILE_PATH);
savepointImage.delete();
if (refImage != null && refImage.exists()) {
FileUtils.copyFile(refImage, savepointImage);
}
}
uri = (Uri) extras.get(EXTRA_OUTPUT);
if (uri != null) {
output = new File(uri.getPath());
} else {
output = new File(Collect.TMPFILE_PATH);
}
}
if (OPTION_SIGNATURE.equals(loadOption)) {
alertTitleString = getString(R.string.quit_application, getString(R.string.sign_button));
} else if (OPTION_ANNOTATE.equals(loadOption)) {
alertTitleString = getString(R.string.quit_application, getString(R.string.markup_image));
} else {
alertTitleString = getString(R.string.quit_application, getString(R.string.draw_image));
}
drawView = findViewById(R.id.drawView);
drawView.setupView(OPTION_SIGNATURE.equals(loadOption));
}
Aggregations