From 72f9c04beba1856c214e62ddb64bc7921502ce86 Mon Sep 17 00:00:00 2001 From: yazeed44 Date: Thu, 17 Sep 2015 23:33:00 +0300 Subject: [PATCH] Implemented #74 --- app/app.iml | 4 ++-- imagepicker/imagepicker.iml | 2 +- .../java/net/yazeed44/imagepicker/ui/PickerActivity.java | 7 ++++--- .../main/java/net/yazeed44/imagepicker/util/Picker.java | 8 ++++++++ 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/app/app.iml b/app/app.iml index 0b1a6a7..42d67ee 100644 --- a/app/app.iml +++ b/app/app.iml @@ -100,10 +100,10 @@ - + + - \ No newline at end of file diff --git a/imagepicker/imagepicker.iml b/imagepicker/imagepicker.iml index 2fb4586..9f24256 100644 --- a/imagepicker/imagepicker.iml +++ b/imagepicker/imagepicker.iml @@ -93,9 +93,9 @@ + - diff --git a/imagepicker/src/main/java/net/yazeed44/imagepicker/ui/PickerActivity.java b/imagepicker/src/main/java/net/yazeed44/imagepicker/ui/PickerActivity.java index db9eb5a..e6bfa11 100644 --- a/imagepicker/src/main/java/net/yazeed44/imagepicker/ui/PickerActivity.java +++ b/imagepicker/src/main/java/net/yazeed44/imagepicker/ui/PickerActivity.java @@ -133,11 +133,12 @@ private void initActionbar(final Bundle savedInstanceState) { if (savedInstanceState == null) { - getSupportActionBar().setDisplayHomeAsUpEnabled(false); + mShouldShowUp = mPickOptions.backBtnInMainActivity; + getSupportActionBar().setDisplayHomeAsUpEnabled(mPickOptions.backBtnInMainActivity); getSupportActionBar().setTitle(R.string.albums_title); } else { mShouldShowUp = savedInstanceState.getBoolean(KEY_SHOULD_SHOW_ACTIONBAR_UP); - getSupportActionBar().setDisplayHomeAsUpEnabled(mShouldShowUp); + getSupportActionBar().setDisplayHomeAsUpEnabled(mShouldShowUp && mPickOptions.backBtnInMainActivity); getSupportActionBar().setTitle(savedInstanceState.getString(KEY_ACTION_BAR_TITLE)); @@ -457,7 +458,7 @@ public void onBackPressed() { //Return to albums fragment getSupportFragmentManager().popBackStack(); getSupportActionBar().setTitle(R.string.albums_title); - mShouldShowUp = false; + mShouldShowUp = mPickOptions.backBtnInMainActivity; getSupportActionBar().setDisplayHomeAsUpEnabled(mShouldShowUp); hideSelectAll(); hideDeselectAll(); diff --git a/imagepicker/src/main/java/net/yazeed44/imagepicker/util/Picker.java b/imagepicker/src/main/java/net/yazeed44/imagepicker/util/Picker.java index d3926eb..fb5e9f6 100644 --- a/imagepicker/src/main/java/net/yazeed44/imagepicker/util/Picker.java +++ b/imagepicker/src/main/java/net/yazeed44/imagepicker/util/Picker.java @@ -41,6 +41,7 @@ public final class Picker { public final int doneFabIconTintColor; public final boolean shouldShowCaptureMenuItem; public final int checkIconTintColor; + public final boolean backBtnInMainActivity; private Picker(final Builder builder) { @@ -63,6 +64,7 @@ private Picker(final Builder builder) { doneFabIconTintColor = builder.mDoneFabIconTintColor; shouldShowCaptureMenuItem = builder.mShouldShowCaptureMenuItem; checkIconTintColor = builder.mCheckIconTintColor; + backBtnInMainActivity = builder.mBackBtnInMainActivity; @@ -112,6 +114,7 @@ public static class Builder { private int mCaptureItemIconTintColor; private boolean mShouldShowCaptureMenuItem; private int mCheckIconTintColor; + private boolean mBackBtnInMainActivity; //Use (Context,PickListener,themeResId) instead @@ -252,6 +255,11 @@ public Picker.Builder setCheckIconTintColor(@ColorInt final int color) { return this; } + public Picker.Builder setBackBtnInMainActivity(final boolean backBtn) { + mBackBtnInMainActivity = backBtn; + return this; + } + public Picker build() { return new Picker(this);