Skip to content

Commit

Permalink
Merge pull request #98 from navasmdc/develop
Browse files Browse the repository at this point in the history
Add ProgressDialog widget and fix bugs
  • Loading branch information
navasmdc committed Jan 14, 2015
2 parents c8f18bf + 4c12fbe commit 469c3e9
Show file tree
Hide file tree
Showing 9 changed files with 193 additions and 13 deletions.
8 changes: 4 additions & 4 deletions MaterialDesign/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ android {
defaultConfig {
minSdkVersion 8
targetSdkVersion 21
versionCode 3
versionName '1.1.1'
versionCode 5
versionName '1.3'
}
}

Expand All @@ -35,8 +35,8 @@ ext.issueUrl = 'https://github.com/navasmdc/MaterialDesignLibrary/issues'
ext.gitUrl = 'https://github.com/navasmdc/MaterialDesignLibrary.git'

bintray {
user = hasProperty('BINTRAY_USER') ? BINTRAY_USER : "navasmdc"
key = hasProperty('BINTRAY_KEY') ? BINTRAY_PASSWORD : "c27d6095b4b3880b5eacf18a5eed3a4ed582e5f3"
user = hasProperty('BINTRAY_USER') ? BINTRAY_USER : ""
key = hasProperty('BINTRAY_KEY') ? BINTRAY_PASSWORD : ""

configurations = ["archives"]
pkg {
Expand Down
36 changes: 36 additions & 0 deletions MaterialDesign/res/layout/progress_dialog.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/dialog_rootView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#55000000"
android:padding="32dp" >

<RelativeLayout
android:id="@+id/contentDialog"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="@drawable/dialog_background"
android:padding="24dp" >

<com.gc.materialdesign.views.ProgressBarCircularIndeterminate
android:id="@+id/progressBarCircularIndetermininate"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_centerVertical="true"
android:background="#1E88E5" />

<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toRightOf="@+id/progressBarCircularIndetermininate"
android:layout_marginLeft="8dp"
android:text="Title"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#000" />
</RelativeLayout>

</RelativeLayout>
9 changes: 7 additions & 2 deletions MaterialDesign/src/com/gc/materialdesign/views/Button.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,17 @@ public abstract class Button extends CustomView {
int minWidth;
int minHeight;
int background;
float rippleSpeed = 10f;
float rippleSpeed = 12f;
int rippleSize = 3;
Integer rippleColor;
OnClickListener onClickListener;
boolean clickAfterRipple = true;
int backgroundColor = Color.parseColor("#1E88E5");

public Button(Context context, AttributeSet attrs) {
super(context, attrs);
setDefaultProperties();
clickAfterRipple = attrs.getAttributeBooleanValue(MATERIALDESIGNXML,"animate", true);
setAttributes(attrs);
beforeBackground = backgroundColor;
if(rippleColor==null)
Expand Down Expand Up @@ -80,6 +82,9 @@ public boolean onTouchEvent(MotionEvent event) {
if ((event.getX() <= getWidth() && event.getX() >= 0)
&& (event.getY() <= getHeight() && event.getY() >= 0)) {
radius++;
if(!clickAfterRipple && onClickListener != null){
onClickListener.onClick(this);
}
} else {
isLastTouch = false;
x = -1;
Expand Down Expand Up @@ -125,7 +130,7 @@ public Bitmap makeCircle() {
x = -1;
y = -1;
radius = getHeight() / rippleSize;
if (onClickListener != null)
if (onClickListener != null&& clickAfterRipple)
onClickListener.onClick(this);
}
return output;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ protected void onDraw(Canvas canvas) {
x = -1;
y = -1;
radius = getHeight()/rippleSize;
if(onClickListener != null)
if(onClickListener != null&& clickAfterRipple)
onClickListener.onClick(this);
}
invalidate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class ButtonIcon extends ButtonFloat {
public ButtonIcon(Context context, AttributeSet attrs) {
super(context, attrs);
setBackground(new ColorDrawable(getResources().getColor(android.R.color.transparent)));
rippleSpeed = Utils.dpToPx(2, getResources());
rippleSpeed = Utils.dpToPx(6, getResources());
rippleSize = Utils.dpToPx(5, getResources());
}

Expand All @@ -43,7 +43,7 @@ protected void onDraw(Canvas canvas) {
x = -1;
y = -1;
radius = getHeight()/rippleSize;
if(onClickListener != null)
if(onClickListener != null && clickAfterRipple)
onClickListener.onClick(this);
}
invalidate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public void setOnCancelButtonClickListener(
View.OnClickListener onCancelButtonClickListener) {
this.onCancelButtonClickListener = onCancelButtonClickListener;
if(buttonCancel != null)
buttonCancel.setOnClickListener(onAcceptButtonClickListener);
buttonCancel.setOnClickListener(onCancelButtonClickListener);
}

@Override
Expand Down
139 changes: 139 additions & 0 deletions MaterialDesign/src/com/gc/materialdesign/widgets/ProgressDialog.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
package com.gc.materialdesign.widgets;

import android.content.Context;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.view.Window;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.AnimationUtils;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.gc.materialdesign.R;
import com.gc.materialdesign.views.ButtonFlat;
import com.gc.materialdesign.views.ProgressBarCircularIndeterminate;

public class ProgressDialog extends android.app.Dialog{

Context context;
View view;
View backView;
String title;
TextView titleTextView;

int progressColor = -1;

public ProgressDialog(Context context,String title) {
super(context, android.R.style.Theme_Translucent);
this.title = title;
this.context = context;
}

public ProgressDialog(Context context,String title, int progressColor) {
super(context, android.R.style.Theme_Translucent);
this.title = title;
this.progressColor = progressColor;
this.context = context;
}

@Override
protected void onCreate(Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
setContentView(R.layout.progress_dialog);

view = (RelativeLayout)findViewById(R.id.contentDialog);
backView = (RelativeLayout)findViewById(R.id.dialog_rootView);
backView.setOnTouchListener(new OnTouchListener() {

@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getX() < view.getLeft()
|| event.getX() >view.getRight()
|| event.getY() > view.getBottom()
|| event.getY() < view.getTop()) {
dismiss();
}
return false;
}
});

this.titleTextView = (TextView) findViewById(R.id.title);
setTitle(title);
if(progressColor != -1){
ProgressBarCircularIndeterminate progressBarCircularIndeterminate = (ProgressBarCircularIndeterminate) findViewById(R.id.progressBarCircularIndetermininate);
progressBarCircularIndeterminate.setBackgroundColor(progressColor);
}


}

@Override
public void show() {
// TODO 自动生成的方法存根
super.show();
// set dialog enter animations
view.startAnimation(AnimationUtils.loadAnimation(context, R.anim.dialog_main_show_amination));
backView.startAnimation(AnimationUtils.loadAnimation(context, R.anim.dialog_root_show_amin));
}

// GETERS & SETTERS

public String getTitle() {
return title;
}

public void setTitle(String title) {
this.title = title;
if(title == null)
titleTextView.setVisibility(View.GONE);
else{
titleTextView.setVisibility(View.VISIBLE);
titleTextView.setText(title);
}
}

public TextView getTitleTextView() {
return titleTextView;
}

public void setTitleTextView(TextView titleTextView) {
this.titleTextView = titleTextView;
}

@Override
public void dismiss() {
Animation anim = AnimationUtils.loadAnimation(context, R.anim.dialog_main_hide_amination);
anim.setAnimationListener(new AnimationListener() {

@Override
public void onAnimationStart(Animation animation) {
}

@Override
public void onAnimationRepeat(Animation animation) {
}

@Override
public void onAnimationEnd(Animation animation) {
view.post(new Runnable() {
@Override
public void run() {
ProgressDialog.super.dismiss();
}
});

}
});
Animation backAnim = AnimationUtils.loadAnimation(context, R.anim.dialog_root_hide_amin);

view.startAnimation(anim);
backView.startAnimation(backAnim);
}



}
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ allprojects {
}

group = "com.github.navasmdc"
version = "1.1.1"
version = "1.3"
}

4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true

VERSION_NAME=1.1.1
VERSION_CODE=3
VERSION_NAME=1.3
VERSION_CODE=5

GROUP=com.github.navasmdc

Expand Down

0 comments on commit 469c3e9

Please sign in to comment.