/** * Create option menus. */ @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.ef_image_picker_menu_main, menu); return true; }
super.onCreate(savedInstanceState); setResult(RESULT_CANCELED); Intent intent = getIntent(); if (intent == null || intent.getExtras() == null) { IpLogger.getInstance().e("This should not happen. Please open an issue!"); finish(); return; config = getIntent().getExtras().getParcelable(ImagePickerConfig.class.getSimpleName()); CameraOnlyConfig cameraOnlyConfig = getIntent().getExtras().getParcelable(CameraOnlyConfig.class.getSimpleName()); setTheme(config.getTheme()); setContentView(R.layout.ef_activity_image_picker); setupView(); } else { setContentView(createCameraLayout()); imagePickerFragment = (ImagePickerFragment) getSupportFragmentManager().findFragmentById(R.id.ef_imagepicker_fragment_placeholder); } else { imagePickerFragment = ImagePickerFragment.newInstance(config, cameraOnlyConfig); FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); ft.replace(R.id.ef_imagepicker_fragment_placeholder, imagePickerFragment); ft.commit();
private void setupView() { Toolbar toolbar = findViewById(R.id.toolbar); setSupportActionBar(toolbar); actionBar = getSupportActionBar(); if (actionBar != null) { final Drawable arrowDrawable = ViewUtils.getArrowIcon(this); final int arrowColor = config.getArrowColor(); if (arrowColor != ImagePickerConfig.NO_COLOR && arrowDrawable != null) { arrowDrawable.setColorFilter(arrowColor, PorterDuff.Mode.SRC_ATOP); } actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setHomeAsUpIndicator(arrowDrawable); actionBar.setDisplayShowTitleEnabled(true); } }
@Override public void cancel() { finish(); }
/** * Handle option menu's click event */ @Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); if (id == android.R.id.home) { onBackPressed(); return true; } if (id == R.id.menu_done) { imagePickerFragment.onDone(); return true; } if (id == R.id.menu_camera) { imagePickerFragment.captureImageWithPermission(); return true; } return super.onOptionsItemSelected(item); }