Skip to content
This repository has been archived by the owner on Oct 13, 2022. It is now read-only.

Commit

Permalink
Implemented disabling capturing images from camera
Browse files Browse the repository at this point in the history
Picker.Builder.disableCaptureImageFromCamera
  • Loading branch information
yazeed44 committed Jul 22, 2015
1 parent 4f6816a commit 905d2b4
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 21 deletions.
3 changes: 2 additions & 1 deletion .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 3 additions & 5 deletions app/app.iml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,10 @@
<option name="SELECTED_TEST_ARTIFACT" value="_android_test_" />
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
<option name="SOURCE_GEN_TASK_NAME" value="generateDebugSources" />
<option name="ASSEMBLE_TEST_TASK_NAME" value="assembleDebugAndroidTest" />
<option name="COMPILE_JAVA_TEST_TASK_NAME" value="compileDebugAndroidTestSources" />
<afterSyncTasks>
<task>generateDebugAndroidTestSources</task>
<task>generateDebugSources</task>
</afterSyncTasks>
<option name="TEST_SOURCE_GEN_TASK_NAME" value="generateDebugAndroidTestSources" />
<option name="ALLOW_USER_CONFIGURATION" value="false" />
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
<option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
Expand Down Expand Up @@ -100,8 +98,8 @@
<orderEntry type="library" exported="" name="support-v4-22.2.0" level="project" />
<orderEntry type="library" exported="" name="commons-lang3-3.3.2" level="project" />
<orderEntry type="library" exported="" name="robospice-cache-1.4.14" level="project" />
<orderEntry type="library" exported="" name="commons-io-1.3.2" level="project" />
<orderEntry type="library" exported="" name="robospice-1.4.14" level="project" />
<orderEntry type="library" exported="" name="commons-io-1.3.2" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-22.2.0" level="project" />
<orderEntry type="library" exported="" name="glide-3.6.0" level="project" />
<orderEntry type="module" module-name="imagepicker" exported="" />
Expand Down
11 changes: 3 additions & 8 deletions imagepicker/imagepicker.iml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,10 @@
<option name="SELECTED_TEST_ARTIFACT" value="_android_test_" />
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
<option name="SOURCE_GEN_TASK_NAME" value="generateDebugSources" />
<option name="ASSEMBLE_TEST_TASK_NAME" value="assembleDebugAndroidTest" />
<option name="COMPILE_JAVA_TEST_TASK_NAME" value="compileDebugAndroidTestSources" />
<afterSyncTasks>
<task>generateDebugAndroidTestSources</task>
<task>generateDebugSources</task>
</afterSyncTasks>
<option name="TEST_SOURCE_GEN_TASK_NAME" value="generateDebugAndroidTestSources" />
<option name="ALLOW_USER_CONFIGURATION" value="false" />
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
<option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
Expand Down Expand Up @@ -65,7 +63,6 @@
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/docs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
Expand All @@ -85,9 +82,7 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
<excludeFolder url="file://$MODULE_DIR$/build/libs" />
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
<excludeFolder url="file://$MODULE_DIR$/build/poms" />
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
</content>
<orderEntry type="jdk" jdkName="Android API 22 Platform" jdkType="Android SDK" />
Expand All @@ -98,8 +93,8 @@
<orderEntry type="library" exported="" name="support-annotations-22.2.0" level="project" />
<orderEntry type="library" exported="" name="support-v4-22.2.0" level="project" />
<orderEntry type="library" exported="" name="floatingactionbutton-1.3.0" level="project" />
<orderEntry type="library" exported="" name="robospice-1.4.14" level="project" />
<orderEntry type="library" exported="" name="robospice-cache-1.4.14" level="project" />
<orderEntry type="library" exported="" name="robospice-1.4.14" level="project" />
<orderEntry type="library" exported="" name="commons-io-1.3.2" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-22.2.0" level="project" />
<orderEntry type="library" exported="" name="library-1.2.3" level="project" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,18 +233,17 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) {
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_take_photo, menu);
getMenuInflater().inflate(R.menu.menu_select_all, menu);
getMenuInflater().inflate(R.menu.menu_deselect_all, menu);


final Drawable captureIconDrawable = ContextCompat.getDrawable(this, R.drawable.ic_action_camera_white);
if (mPickOptions.shouldShowCaptureMenuItem) {
initCaptureMenuItem(menu);
}

getMenuInflater().inflate(R.menu.menu_select_all, menu);
getMenuInflater().inflate(R.menu.menu_deselect_all, menu);

final Drawable captureIconDrawableWrapped = DrawableCompat.wrap(captureIconDrawable);

DrawableCompat.setTint(captureIconDrawableWrapped, mPickOptions.captureItemIconTintColor);

menu.findItem(R.id.action_take_photo).setIcon(captureIconDrawableWrapped);

mSelectAllMenuItem = menu.findItem(R.id.action_select_all);
mDeselectAllMenuItem = menu.findItem(R.id.action_deselect_all);
Expand All @@ -255,6 +254,17 @@ public boolean onCreateOptionsMenu(Menu menu) {
return true;
}

private void initCaptureMenuItem(final Menu menu) {
getMenuInflater().inflate(R.menu.menu_take_photo, menu);
Drawable captureIconDrawable = ContextCompat.getDrawable(this, R.drawable.ic_action_camera_white);
captureIconDrawable = DrawableCompat.wrap(captureIconDrawable);

DrawableCompat.setTint(captureIconDrawable, mPickOptions.captureItemIconTintColor);

menu.findItem(R.id.action_take_photo).setIcon(captureIconDrawable);

}

private void hideDeselectAll() {
mDeselectAllMenuItem.setVisible(false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public final class Picker {
public final int popupThemeResId;
public final int captureItemIconTintColor;
public final int doneFabIconTintColor;
public boolean shouldShowCaptureMenuItem;


private Picker(final Builder builder) {
Expand All @@ -58,6 +59,7 @@ private Picker(final Builder builder) {
popupThemeResId = builder.mPopupThemeResId;
captureItemIconTintColor = builder.mCaptureItemIconTintColor;
doneFabIconTintColor = builder.mDoneFabIconTintColor;
shouldShowCaptureMenuItem = builder.mShouldShowCaptureMenuItem;



Expand Down Expand Up @@ -105,6 +107,7 @@ public static class Builder {
private int mPopupThemeResId;
private int mDoneFabIconTintColor;
private int mCaptureItemIconTintColor;
private boolean mShouldShowCaptureMenuItem;



Expand Down Expand Up @@ -147,6 +150,8 @@ private void init() {
mPopupThemeResId = Util.getDefaultPopupTheme(mContext);
mCaptureItemIconTintColor = mDoneFabIconTintColor = Util.getDefaultIconTintColor(mContext);

mShouldShowCaptureMenuItem = true;

}


Expand Down Expand Up @@ -232,6 +237,11 @@ public Picker.Builder setCaptureItemIconTintColor(@ColorInt final int color) {
return this;
}

public Picker.Builder disableCaptureImageFromCamera() {
mShouldShowCaptureMenuItem = false;
return this;
}

public Picker build() {
return new Picker(this);
}
Expand Down

0 comments on commit 905d2b4

Please sign in to comment.