Skip to content

Commit

Permalink
remove submit button
Browse files Browse the repository at this point in the history
  • Loading branch information
hu2di committed Nov 17, 2017
1 parent 0b999a4 commit 9a52f36
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 106 deletions.
15 changes: 1 addition & 14 deletions .idea/misc.xml

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

Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ public void fiveStars() {
rateUs();
}
},
"Comment aimeriez-vous cette application?", R.mipmap.ic_launcher, "Merci").show();
"Comment aimeriez-vous cette application?",
R.mipmap.ic_launcher).show();
}
});
}
Expand Down
89 changes: 27 additions & 62 deletions myrate/src/main/java/com/blogspot/hu2di/myrate/MyRate.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public class MyRate {
private String title = "How would you like this app?";
private int icon;
private int stars = 0;
private String rate = "Submit";

public MyRate(@NonNull Context context, @NonNull RateListener rateListener,
@NonNull int icon) {
Expand All @@ -34,13 +33,12 @@ public MyRate(@NonNull Context context, @NonNull RateListener rateListener,
}

public MyRate(@NonNull Context context, @NonNull RateListener rateListener,
@NonNull String title, @NonNull int icon, @NonNull String rateText) {
@NonNull String title, @NonNull int icon) {
this.context = context;
this.rateListener = rateListener;

this.title = title;
this.icon = icon;
this.rate = rateText;
}

public void show() {
Expand All @@ -52,47 +50,14 @@ private void dialogRate() {
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.dialog_rate);

TextView tvTitle, tvRate;
TextView tvTitle;
final ImageView ivIcon, ivOne, ivTwo, ivThree, ivFour, ivFive;
final RelativeLayout rlRate;

tvTitle = (TextView) dialog.findViewById(R.id.tvTitle);
tvTitle.setText(title);
ivIcon = (ImageView) dialog.findViewById(R.id.ivIcon);
ivIcon.setImageResource(icon);

rlRate = (RelativeLayout) dialog.findViewById(R.id.rlRate);
tvRate = (TextView) dialog.findViewById(R.id.tvRate);
tvRate.setText(rate);
tvRate.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
switch (stars) {
case 0:
break;
case 1:
rateListener.oneStar();
break;
case 2:
rateListener.twoStars();
break;
case 3:
rateListener.threeStars();
break;
case 4:
rateListener.fourStars();
break;
case 5:
rateListener.fiveStars();
break;
}

SharePref.putStars(context, stars);
dialog.dismiss();
}
});


ivOne = (ImageView) dialog.findViewById(R.id.ivOne);
ivTwo = (ImageView) dialog.findViewById(R.id.ivTwo);
ivThree = (ImageView) dialog.findViewById(R.id.ivThree);
Expand All @@ -104,44 +69,34 @@ public void onClick(View view) {
case 0:
break;
case 1:
rlRate.setVisibility(View.VISIBLE);

ivOne.setImageResource(R.drawable.stared);
ivTwo.setImageResource(R.drawable.star);
ivThree.setImageResource(R.drawable.star);
ivFour.setImageResource(R.drawable.star);
ivFive.setImageResource(R.drawable.star);
break;
case 2:
rlRate.setVisibility(View.VISIBLE);

ivOne.setImageResource(R.drawable.stared);
ivTwo.setImageResource(R.drawable.stared);
ivThree.setImageResource(R.drawable.star);
ivFour.setImageResource(R.drawable.star);
ivFive.setImageResource(R.drawable.star);
break;
case 3:
rlRate.setVisibility(View.VISIBLE);

ivOne.setImageResource(R.drawable.stared);
ivTwo.setImageResource(R.drawable.stared);
ivThree.setImageResource(R.drawable.stared);
ivFour.setImageResource(R.drawable.star);
ivFive.setImageResource(R.drawable.star);
break;
case 4:
rlRate.setVisibility(View.VISIBLE);

ivOne.setImageResource(R.drawable.stared);
ivTwo.setImageResource(R.drawable.stared);
ivThree.setImageResource(R.drawable.stared);
ivFour.setImageResource(R.drawable.stared);
ivFive.setImageResource(R.drawable.star);
break;
case 5:
rlRate.setVisibility(View.VISIBLE);

ivOne.setImageResource(R.drawable.stared);
ivTwo.setImageResource(R.drawable.stared);
ivThree.setImageResource(R.drawable.stared);
Expand All @@ -153,70 +108,80 @@ public void onClick(View view) {
ivOne.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
stars = 1;
rlRate.setVisibility(View.VISIBLE);

ivOne.setImageResource(R.drawable.stared);
ivTwo.setImageResource(R.drawable.star);
ivThree.setImageResource(R.drawable.star);
ivFour.setImageResource(R.drawable.star);
ivFive.setImageResource(R.drawable.star);

stars = 1;
SharePref.putStars(context, stars);
dialog.dismiss();
rateListener.oneStar();
}
});

ivTwo.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
stars = 2;
rlRate.setVisibility(View.VISIBLE);

ivOne.setImageResource(R.drawable.stared);
ivTwo.setImageResource(R.drawable.stared);
ivThree.setImageResource(R.drawable.star);
ivFour.setImageResource(R.drawable.star);
ivFive.setImageResource(R.drawable.star);

stars = 2;
SharePref.putStars(context, stars);
dialog.dismiss();
rateListener.twoStars();
}
});

ivThree.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
stars = 3;
rlRate.setVisibility(View.VISIBLE);

ivOne.setImageResource(R.drawable.stared);
ivTwo.setImageResource(R.drawable.stared);
ivThree.setImageResource(R.drawable.stared);
ivFour.setImageResource(R.drawable.star);
ivFive.setImageResource(R.drawable.star);

stars = 3;
SharePref.putStars(context, stars);
dialog.dismiss();
rateListener.threeStars();
}
});

ivFour.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
stars = 4;
rlRate.setVisibility(View.VISIBLE);

ivOne.setImageResource(R.drawable.stared);
ivTwo.setImageResource(R.drawable.stared);
ivThree.setImageResource(R.drawable.stared);
ivFour.setImageResource(R.drawable.stared);
ivFive.setImageResource(R.drawable.star);

stars = 4;
SharePref.putStars(context, stars);
dialog.dismiss();
rateListener.fourStars();
}
});

ivFive.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
stars = 5;
rlRate.setVisibility(View.VISIBLE);

ivOne.setImageResource(R.drawable.stared);
ivTwo.setImageResource(R.drawable.stared);
ivThree.setImageResource(R.drawable.stared);
ivFour.setImageResource(R.drawable.stared);
ivFive.setImageResource(R.drawable.stared);

stars = 5;
SharePref.putStars(context, stars);
dialog.dismiss();
rateListener.fiveStars();
}
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package com.blogspot.hu2di.myrate;

/**
* Created by HUNGDH on 11/15/2017.
*/

public interface RateListener {
void oneStar();

Expand Down
9 changes: 0 additions & 9 deletions myrate/src/main/res/drawable/bg_rec_white.xml

This file was deleted.

21 changes: 1 addition & 20 deletions myrate/src/main/res/layout/dialog_rate.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg_rec_white"
android:background="#ffffff"
android:orientation="vertical">

<LinearLayout
Expand Down Expand Up @@ -81,23 +81,4 @@

</RelativeLayout>

<RelativeLayout
android:id="@+id/rlRate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone">

<TextView
android:id="@+id/tvRate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:paddingBottom="16dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:text="Thanks for your feedback!"
android:textSize="16sp" />

</RelativeLayout>

</LinearLayout>

0 comments on commit 9a52f36

Please sign in to comment.