Skip to content

Commit

Permalink
Merge pull request #147 from ProMode7/master
Browse files Browse the repository at this point in the history
If only 1 PickType is given then automatically open the camera/gallery
  • Loading branch information
yogeshpaliyal committed Aug 25, 2021
2 parents 0a660a3 + 3760d58 commit 2374266
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.os.Handler;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.DialogFragment;
import androidx.cardview.widget.CardView;
import androidx.appcompat.widget.LinearLayoutCompat;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand Down Expand Up @@ -196,50 +198,57 @@ public void onClick(View view) {


private void onSetup() {
if (setup.getBackgroundColor() != android.R.color.white) {
card.setCardBackgroundColor(setup.getBackgroundColor());
if (showCamera && !showGallery) {
launchCamera();
} else if (showGallery && !showCamera) {
launchGallery();
} else {
card.setVisibility(View.VISIBLE);
if (setup.getBackgroundColor() != android.R.color.white) {
card.setCardBackgroundColor(setup.getBackgroundColor());

if (showCamera)
Util.background(tvCamera, Util.getAdaptiveRippleDrawable(setup.getBackgroundColor()));
if (showCamera)
Util.background(tvCamera, Util.getAdaptiveRippleDrawable(setup.getBackgroundColor()));

if (showGallery)
Util.background(tvGallery, Util.getAdaptiveRippleDrawable(setup.getBackgroundColor()));
}
if (showGallery)
Util.background(tvGallery, Util.getAdaptiveRippleDrawable(setup.getBackgroundColor()));
}

tvTitle.setTextColor(setup.getTitleColor());
tvTitle.setTextColor(setup.getTitleColor());

if (setup.getButtonTextColor() != 0) {
tvCamera.setTextColor(setup.getButtonTextColor());
tvGallery.setTextColor(setup.getButtonTextColor());
}
if (setup.getButtonTextColor() != 0) {
tvCamera.setTextColor(setup.getButtonTextColor());
tvGallery.setTextColor(setup.getButtonTextColor());
}

if (setup.getProgressTextColor() != 0)
tvProgress.setTextColor(setup.getProgressTextColor());
if (setup.getProgressTextColor() != 0)
tvProgress.setTextColor(setup.getProgressTextColor());

if (setup.getCancelTextColor() != 0)
tvCancel.setTextColor(setup.getCancelTextColor());
if (setup.getCancelTextColor() != 0)
tvCancel.setTextColor(setup.getCancelTextColor());

if (setup.getCameraButtonText() != null)
tvCamera.setText(setup.getCameraButtonText());
if (setup.getCameraButtonText() != null)
tvCamera.setText(setup.getCameraButtonText());

if (setup.getGalleryButtonText() != null)
tvGallery.setText(setup.getGalleryButtonText());
if (setup.getGalleryButtonText() != null)
tvGallery.setText(setup.getGalleryButtonText());

tvCancel.setText(setup.getCancelText());
tvTitle.setText(setup.getTitle());
tvProgress.setText(setup.getProgressText());
tvCancel.setText(setup.getCancelText());
tvTitle.setText(setup.getTitle());
tvProgress.setText(setup.getProgressText());

showProgress(false);
showProgress(false);

Util.gone(tvCamera, !showCamera);
Util.gone(tvGallery, !showGallery);
Util.gone(tvCamera, !showCamera);
Util.gone(tvGallery, !showGallery);

llButtons.setOrientation(setup.getButtonOrientation() == LinearLayoutCompat.HORIZONTAL ? LinearLayout.HORIZONTAL : LinearLayout.VERTICAL);
llButtons.setOrientation(setup.getButtonOrientation() == LinearLayoutCompat.HORIZONTAL ? LinearLayout.HORIZONTAL : LinearLayout.VERTICAL);

Util.setIcon(tvCamera, setup.getCameraIcon(), setup.getIconGravity());
Util.setIcon(tvGallery, setup.getGalleryIcon(), setup.getIconGravity());
Util.setIcon(tvCamera, setup.getCameraIcon(), setup.getIconGravity());
Util.setIcon(tvGallery, setup.getGalleryIcon(), setup.getIconGravity());

Util.setDimAmount(setup.getDimAmount(), getDialog());
Util.setDimAmount(setup.getDimAmount(), getDialog());
}
}


Expand Down
1 change: 1 addition & 0 deletions library/src/main/res/layout/dialog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:visibility="gone"
android:layout_gravity="center"
card_view:cardBackgroundColor="@android:color/white"
card_view:cardCornerRadius="4dp"
Expand Down

0 comments on commit 2374266

Please sign in to comment.