From 7d9129fe31ca55e8339d78399213818b6fb6fb28 Mon Sep 17 00:00:00 2001 From: Hieng Date: Mon, 30 Mar 2020 21:28:48 +0700 Subject: [PATCH] Customizable Smiley: setMaxSmiley(from 1 to 5), setReverseSmiley(boolean), setSmileys(array Smiley) --- app/src/main/AndroidManifest.xml | 1 + .../smilyrating/CustomSmileyActivity.java | 27 +++++++++++ .../com/example/smilyrating/MenuActivity.java | 4 ++ .../res/layout/activity_customized_smiley.xml | 12 +++++ app/src/main/res/layout/activity_menu.xml | 11 ++++- build.gradle | 2 +- .../com/hsalf/smileyrating/SmileyRating.java | 45 ++++++++++++++++++- 7 files changed, 98 insertions(+), 4 deletions(-) create mode 100644 app/src/main/java/com/example/smilyrating/CustomSmileyActivity.java create mode 100644 app/src/main/res/layout/activity_customized_smiley.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index e71d5e4..d6ed0fc 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -31,6 +31,7 @@ + diff --git a/app/src/main/java/com/example/smilyrating/CustomSmileyActivity.java b/app/src/main/java/com/example/smilyrating/CustomSmileyActivity.java new file mode 100644 index 0000000..d154020 --- /dev/null +++ b/app/src/main/java/com/example/smilyrating/CustomSmileyActivity.java @@ -0,0 +1,27 @@ +package com.example.smilyrating; + +import android.os.Bundle; + +import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; + +import com.hsalf.smileyrating.SmileyRating; + +/** + * This class is used for ... + * + * @autor MAO Hieng 3/30/2020 + */ +public class CustomSmileyActivity extends AppCompatActivity { + + @Override + protected void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_customized_smiley); + SmileyRating rating = findViewById(R.id.smiley); + + rating.setMaxSmiley(3); + rating.setReverseSmiley(true); + rating.setRating(1); + } +} diff --git a/app/src/main/java/com/example/smilyrating/MenuActivity.java b/app/src/main/java/com/example/smilyrating/MenuActivity.java index 608ebbb..26f8bf7 100644 --- a/app/src/main/java/com/example/smilyrating/MenuActivity.java +++ b/app/src/main/java/com/example/smilyrating/MenuActivity.java @@ -38,4 +38,8 @@ public void onClick(View v) { } startActivity(intent); } + + public void clickStartCustomizedSmiley(View view) { + startActivity(new Intent(this, CustomSmileyActivity.class)); + } } diff --git a/app/src/main/res/layout/activity_customized_smiley.xml b/app/src/main/res/layout/activity_customized_smiley.xml new file mode 100644 index 0000000..49179a5 --- /dev/null +++ b/app/src/main/res/layout/activity_customized_smiley.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_menu.xml b/app/src/main/res/layout/activity_menu.xml index 2d60838..6b73eed 100644 --- a/app/src/main/res/layout/activity_menu.xml +++ b/app/src/main/res/layout/activity_menu.xml @@ -6,8 +6,8 @@ + android:orientation="vertical" + android:padding="20dp">