Skip to content

Commit

Permalink
*Optimizing dimensions , ui and ux
Browse files Browse the repository at this point in the history
  • Loading branch information
fawzy committed Aug 26, 2019
1 parent 0773aa3 commit 79d8a41
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 42 deletions.
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,14 @@ setCodeTypeListener(new DialogPlus.CodeTypeListener() {
<dimen name="dialog_header_text_size">@dimen/_14ssp</dimen>
<dimen name="dialog_header_padding">@dimen/_8sdp</dimen>

<dimen name="dialog_content_margin">@dimen/_25sdp</dimen>
<dimen name="dialog_content_margin">@dimen/_15sdp</dimen>
<dimen name="dialog_content_message_text_size">@dimen/_12ssp</dimen>

<dimen name="dialog_action_buttons_margin">@dimen/_15sdp</dimen>
<dimen name="dialog_action_buttons_margin">@dimen/_10sdp</dimen>
<dimen name="dialog_action_button_corner">50dp</dimen>
<dimen name="dialog_action_buttons_height">@dimen/_30sdp</dimen>
<dimen name="dialog_action_buttons_height">@dimen/_35sdp</dimen>
<!-- space for showing elevation-->
<dimen name="dialog_action_buttons_bottom_margin">2dp</dimen>

<dimen name="dialog_action_button_textSize">@dimen/_12ssp</dimen>

Expand All @@ -190,7 +192,8 @@ setCodeTypeListener(new DialogPlus.CodeTypeListener() {
<dimen name="dialog_negative_button_elevation">0dp</dimen>

<dimen name="dialog_close_icon_radius">@dimen/_16sdp</dimen>
<dimen name="dialog_zero">0dp</dimen>
<dimen name="dialog_zero">0dp</dimen>
<dimen name="dialog_code_entry_margin">@dimen/_8sdp</dimen>
````
#### Integers
````
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@
<color name="white">#ffffff</color>
<color name="black">#000000</color>

<dimen name="dialog_content_margin">10dp</dimen>
</resources>
4 changes: 2 additions & 2 deletions dialogPlus/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ ext {
//library name will be like -> publishedGroupId:artifact:libraryVersion
publishedGroupId = 'com.dialog' //the ID you want to add in the 'implementation line'
artifact = 'plus' //the artifact you want to add in the 'implementation line'
libraryVersion = '3.1.3'
libraryVersion = '3.2.0'
libraryDescription = 'An Android library that lets you show Dialog in a custom simple and fast way.'

siteUrl = 'https://github.com/ma7madfawzy/DialogPlus'
Expand All @@ -42,7 +42,7 @@ android {
minSdkVersion 19
targetSdkVersion 29
versionCode 1
versionName "3.1.3"
versionName "3.2.0"
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

Expand Down
43 changes: 23 additions & 20 deletions dialogPlus/src/main/java/com/dialog/plus/ui/DialogPlus.java
Original file line number Diff line number Diff line change
Expand Up @@ -255,17 +255,8 @@ public void afterTextChanged(Editable editable) {
});
}

private void hideKeyboard() {
KeyboardUtil.getInstance().hideKeyboard(getDialogAddedView(R.id.txtPinEntry));
}

private boolean validateCode() {
if (model.isCorrectCode()) {
onCorrect();
return true;
} else
onWrong();
return false;
return model.isCorrectCode();
}

private void onCorrect() {
Expand Down Expand Up @@ -412,31 +403,43 @@ else if (view.getId() == R.id.cancelButton || view.getId() == R.id.closeIV)
}

private void onPositiveClicked() {
onConfirmClicked();
if (dialogActionListener != null)
dialogActionListener.onPositive(this);
else dismiss(true);
}

private void sendCode() {
if (model.getCodeEntry() != null && model.getCodeEntry().length() == correct_code.length()) {
if (validateCode()) {
cancelTimer();
dismiss(true);
}
onCompleteCodeTyped();
} else
Toast.makeText(getActivity(), getString(R.string.dialog_incomplete_code_msg), Toast.LENGTH_SHORT).show();
}

private void onCompleteCodeTyped() {
if (validateCode()) {
onCorrect();
cancelTimer();
dismiss(true);
} else {
onWrong();
showKeyboard();
}
}

private void hideKeyboard() {
KeyboardUtil.getInstance().hideKeyboard(getDialogAddedView(R.id.txtPinEntry));
}

private void showKeyboard() {
KeyboardUtil.getInstance().showKeyboard(getDialogAddedView(R.id.txtPinEntry));
}

private void onNegativeClicked() {
if (dialogActionListener != null)
dialogActionListener.onNegative(this);
else dismiss(true);
}

private void onConfirmClicked() {
if (dialogActionListener != null)
dialogActionListener.onPositive(this);
else dismiss(true);
}

private void handleResendCode() {
if (codeTypeListener != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ public void setSeparateActionButtons(boolean separateActionButtons) {

@Bindable
public int getDialogWhite() {
return R.color.dialog_white;
return R.color.dialogTransparent;
}

@Bindable
Expand Down
13 changes: 8 additions & 5 deletions dialogPlus/src/main/res/layout/layout_code_dialog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="@dimen/_8sdp"
android:layout_marginStart="@dimen/dialog_code_entry_margin"
android:layout_marginEnd="@dimen/dialog_code_entry_margin"
android:layout_marginBottom="2dp"
android:cursorVisible="false"
android:digits="1234567890"
android:inputType="number"
Expand All @@ -58,7 +60,7 @@
android:layout_height="wrap_content"
android:layout_gravity="end"
android:layout_marginEnd="@dimen/_20sdp"
android:layout_marginBottom="@dimen/_8sdp"
android:layout_marginBottom="@dimen/dialog_code_entry_margin"
android:text="@{model.timeLeft>0?model.timeLeft+``:@string/dialog_time_up}"
android:textColor="@color/dialogTimeUpTextColor"
android:textSize="@dimen/dialog_timeup_text_size"
Expand All @@ -69,16 +71,17 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="@dimen/_16sdp"
android:layout_marginBottom="@dimen/_16sdp"
android:layout_marginBottom="@dimen/dialog_action_buttons_margin"
android:alpha="@{model.codeEntry.length==model.correctCode.length?1f:0.5f}"
android:background="@color/dialog_send_background"
android:enabled="@{model.codeEntry.length==model.correctCode.length}"
android:text="@string/dialog_positive_text"
android:textAllCaps="false"
android:textColor="@color/dialog_white"
bind:backgroundColor="@{model.positiveBgColor}"
bind:backgroundDrawable="@{model.positiveBgDrawable}"
bind:carbon_cornerRadius="@dimen/dialog_corner_radius"
bind:visible="@{model.withSend &amp; model.codeEntry.length==model.correctCode.length}" />
bind:visible="@{model.withSend &amp;model.timeLeft!=0}" />

<carbon.widget.TextView
android:id="@+id/resendCode"
Expand Down
12 changes: 6 additions & 6 deletions dialogPlus/src/main/res/layout/layout_confirmation_dialog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@
android:layout_gravity="center"
android:layout_marginStart="@dimen/dialog_action_buttons_margin"
android:layout_marginEnd="@dimen/dialog_action_buttons_margin"
android:layout_marginBottom="@dimen/dialog_action_buttons_margin"
android:background="@{model.separateActionButtons?@color/dialog_white:@color/dialogNegativeBgColor}"
android:gravity="center"
android:orientation="horizontal"
bind:backgroundColor="@{model.separateActionButtons?model.dialogWhite:model.negativeBgColor}"
bind:backgroundDrawable="@{model.separateActionButtons?model.noDrawable:model.negativeBgDrawable}"
bind:cornerRadius="@{model.separateActionButtons?@dimen/dialog_zero:@dimen/dialog_action_button_corner}"
bind:marginBottom="@{model.separateActionButtons?@dimen/dialog_zero:@dimen/dialog_action_buttons_margin}"
bind:marginTop="@{model.separateActionButtons?@dimen/dialog_zero:@dimen/dialog_action_buttons_margin}"
bind:marginTop="@{model.separateActionButtons?@dimen/dialog_zero:@dimen/dialog_action_buttons_bottom_margin}"
bind:strokeColor="@{model.separateActionButtons?@color/dialog_white:@color/dialogActionButtonsStrokeColor}"
bind:strokeWidth="@{model.separateActionButtons?@dimen/dialog_zero:@dimen/dialog_negative_button_stroke}">

Expand All @@ -69,8 +69,8 @@
bind:cornerRadius="@{model.separateActionButtons?@dimen/dialog_action_button_corner:@dimen/dialog_zero}"
bind:elevation="@{model.separateActionButtons?@dimen/dialog_negative_button_elevation:@dimen/dialog_zero}"
bind:layout_weight="@{model.separateActionButtons?1f:0.9f}"
bind:marginBottom="@{model.separateActionButtons?@dimen/dialog_action_buttons_margin:@dimen/dialog_zero}"
bind:marginTop="@{model.separateActionButtons?@dimen/dialog_action_buttons_margin:@dimen/dialog_zero}"
bind:marginBottom="@{model.separateActionButtons?@dimen/dialog_action_buttons_bottom_margin:@dimen/dialog_zero}"
bind:marginTop="@{model.separateActionButtons?@dimen/dialog_action_buttons_bottom_margin:@dimen/dialog_zero}"
bind:strokeWidth="@{model.separateActionButtons?@dimen/dialog_negative_button_stroke:@dimen/dialog_zero}"
bind:text_color="@{model.negativeTextColor}"
bind:visible="@{!model.typeMessage}"
Expand All @@ -94,8 +94,8 @@
bind:carbon_cornerRadius="@dimen/dialog_action_button_corner"
bind:carbon_elevation="@dimen/dialog_positive_button_elevation"
bind:layout_weight="@{model.separateActionButtons?1f:1.1f}"
bind:marginBottom="@{model.separateActionButtons?@dimen/dialog_action_buttons_margin:@dimen/dialog_zero}"
bind:marginTop="@{model.separateActionButtons?@dimen/dialog_action_buttons_margin:@dimen/dialog_zero}"
bind:marginBottom="@{model.separateActionButtons?@dimen/dialog_action_buttons_bottom_margin:@dimen/dialog_zero}"
bind:marginTop="@{model.separateActionButtons?@dimen/dialog_action_buttons_bottom_margin:@dimen/dialog_zero}"
bind:text_color="@{model.positiveTextColor}" />

</carbon.widget.LinearLayout>
Expand Down
9 changes: 6 additions & 3 deletions dialogPlus/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@
<dimen name="dialog_header_text_size">@dimen/_14ssp</dimen>
<dimen name="dialog_header_padding">@dimen/_8sdp</dimen>

<dimen name="dialog_content_margin">@dimen/_25sdp</dimen>
<dimen name="dialog_content_margin">@dimen/_15sdp</dimen>
<dimen name="dialog_content_message_text_size">@dimen/_12ssp</dimen>

<dimen name="dialog_action_buttons_margin">@dimen/_15sdp</dimen>
<dimen name="dialog_action_buttons_margin">@dimen/_10sdp</dimen>
<dimen name="dialog_action_button_corner">50dp</dimen>
<dimen name="dialog_action_buttons_height">@dimen/_30sdp</dimen>
<dimen name="dialog_action_buttons_height">@dimen/_35sdp</dimen>
<!-- space for showing elevation-->
<dimen name="dialog_action_buttons_bottom_margin">2dp</dimen>

<dimen name="dialog_action_button_textSize">@dimen/_12ssp</dimen>

Expand All @@ -24,4 +26,5 @@

<dimen name="dialog_close_icon_radius">@dimen/_16sdp</dimen>
<dimen name="dialog_zero">0dp</dimen>
<dimen name="dialog_code_entry_margin">@dimen/_8sdp</dimen>
</resources>

0 comments on commit 79d8a41

Please sign in to comment.