├── app ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── font │ │ │ │ ├── ml.ttf │ │ │ │ ├── mm.ttf │ │ │ │ ├── mr.ttf │ │ │ │ └── myprior.xml │ │ │ ├── values │ │ │ │ ├── strings.xml │ │ │ │ ├── dimens.xml │ │ │ │ ├── colors.xml │ │ │ │ └── styles.xml │ │ │ ├── drawable │ │ │ │ ├── icnet.png │ │ │ │ ├── icvip.png │ │ │ │ ├── bgheader.png │ │ │ │ ├── bgmenus.png │ │ │ │ ├── icapps.png │ │ │ │ ├── icguide.png │ │ │ │ ├── iclist.png │ │ │ │ ├── icplug.png │ │ │ │ ├── userpic.png │ │ │ │ ├── icstarter.png │ │ │ │ ├── bgheaderminimal.png │ │ │ │ ├── icbusinessplayer.png │ │ │ │ ├── bgbtnguide.xml │ │ │ │ ├── ripple_effect_android_image.xml │ │ │ │ ├── ic_arrow_left.xml │ │ │ │ ├── ic_arrow_right.xml │ │ │ │ ├── ic_header_login.xml │ │ │ │ ├── ic_log_out.xml │ │ │ │ ├── ic_header.xml │ │ │ │ └── ic_launcher_background.xml │ │ │ ├── mipmap-hdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-mdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-anydpi-v26 │ │ │ │ ├── ic_launcher.xml │ │ │ │ └── ic_launcher_round.xml │ │ │ ├── animator │ │ │ │ ├── fade_appear.xml │ │ │ │ ├── fade_disappear.xml │ │ │ │ ├── slide_down.xml │ │ │ │ ├── slide_up.xml │ │ │ │ ├── slide_down_disappear.xml │ │ │ │ └── slide_up_disappear.xml │ │ │ ├── layout │ │ │ │ ├── activity_splash.xml │ │ │ │ ├── my_elections_fragment.xml │ │ │ │ ├── fragment_item_list.xml │ │ │ │ ├── activity_start.xml │ │ │ │ ├── fragment_item.xml │ │ │ │ ├── elections_fragment.xml │ │ │ │ ├── operations_fragment.xml │ │ │ │ ├── add_election_layout.xml │ │ │ │ ├── fragment_item_list_new.xml │ │ │ │ ├── election_item.xml │ │ │ │ ├── my_election_item.xml │ │ │ │ ├── empty_fragment.xml │ │ │ │ ├── login_fragment.xml │ │ │ │ ├── fragment_register.xml │ │ │ │ ├── activity_package.xml │ │ │ │ └── activity_master.xml │ │ │ ├── anim │ │ │ │ ├── atg.xml │ │ │ │ ├── atgthree.xml │ │ │ │ ├── atgtwo.xml │ │ │ │ └── packageimg.xml │ │ │ └── drawable-v24 │ │ │ │ └── ic_launcher_foreground.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── example │ │ │ │ └── tkd │ │ │ │ └── zvoting │ │ │ │ ├── model │ │ │ │ ├── User.java │ │ │ │ ├── Candidate.java │ │ │ │ ├── ResponseMessage.java │ │ │ │ ├── LoginChallenge.java │ │ │ │ ├── Vote.java │ │ │ │ ├── Election.java │ │ │ │ ├── ElectionResult.java │ │ │ │ └── Voter.java │ │ │ │ ├── rest │ │ │ │ ├── StartElectionRequest.java │ │ │ │ ├── CalculateResultRequest.java │ │ │ │ ├── GetCandidatesRequest.java │ │ │ │ ├── ApiClient.java │ │ │ │ ├── CreateElectionRequest.java │ │ │ │ ├── StartElectionResponse.java │ │ │ │ ├── CreateElectionResponse.java │ │ │ │ ├── ApiInterface.java │ │ │ │ ├── CastVoteResponse.java │ │ │ │ ├── LoginResponse.java │ │ │ │ ├── CastVoteRequest.java │ │ │ │ ├── AddCandidateRequest.java │ │ │ │ ├── AddVoterRequest.java │ │ │ │ └── VoterLoginRequest.java │ │ │ │ ├── SplashActivity.java │ │ │ │ ├── MasterPageAdapter.java │ │ │ │ ├── MyElectionsFragment.java │ │ │ │ ├── ElectionsViewModel.java │ │ │ │ ├── dummy │ │ │ │ └── DummyContent.java │ │ │ │ ├── ElectionsFragment.java │ │ │ │ ├── EmptyFragment.java │ │ │ │ ├── LoginFragment.java │ │ │ │ ├── MyItemRecyclerViewAdapter.java │ │ │ │ ├── PackageAct.java │ │ │ │ ├── AuthActivity.java │ │ │ │ ├── DataViewModel.java │ │ │ │ ├── OperationsViewModel.java │ │ │ │ ├── RegisterFragment.java │ │ │ │ ├── ElectionResultsViewModel.java │ │ │ │ ├── OperationsFragment.java │ │ │ │ ├── MasterActivity.java │ │ │ │ ├── ElectionResultsFragment.java │ │ │ │ ├── ElectionListAdapter.java │ │ │ │ ├── MyElectionsViewModel.java │ │ │ │ └── MyElectionsListAdapter.java │ │ └── AndroidManifest.xml │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── example │ │ │ └── tkd │ │ │ └── zvoting │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── example │ │ └── tkd │ │ └── zvoting │ │ └── ExampleInstrumentedTest.java ├── proguard-rules.pro └── build.gradle ├── settings.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .idea ├── caches │ └── build_file_checksums.ser ├── vcs.xml ├── misc.xml ├── runConfigurations.xml ├── gradle.xml ├── assetWizardSettings.xml └── codeStyles │ └── Project.xml ├── .gitignore ├── gradle.properties ├── gradlew.bat └── gradlew /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /app/src/main/res/font/ml.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Z-Voting/Z-Voting-App/HEAD/app/src/main/res/font/ml.ttf -------------------------------------------------------------------------------- /app/src/main/res/font/mm.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Z-Voting/Z-Voting-App/HEAD/app/src/main/res/font/mm.ttf -------------------------------------------------------------------------------- /app/src/main/res/font/mr.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Z-Voting/Z-Voting-App/HEAD/app/src/main/res/font/mr.ttf -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Z-Voting 3 | 4 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Z-Voting/Z-Voting-App/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/drawable/icnet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Z-Voting/Z-Voting-App/HEAD/app/src/main/res/drawable/icnet.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/icvip.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Z-Voting/Z-Voting-App/HEAD/app/src/main/res/drawable/icvip.png -------------------------------------------------------------------------------- /.idea/caches/build_file_checksums.ser: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Z-Voting/Z-Voting-App/HEAD/.idea/caches/build_file_checksums.ser -------------------------------------------------------------------------------- /app/src/main/res/drawable/bgheader.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Z-Voting/Z-Voting-App/HEAD/app/src/main/res/drawable/bgheader.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/bgmenus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Z-Voting/Z-Voting-App/HEAD/app/src/main/res/drawable/bgmenus.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/icapps.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Z-Voting/Z-Voting-App/HEAD/app/src/main/res/drawable/icapps.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/icguide.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Z-Voting/Z-Voting-App/HEAD/app/src/main/res/drawable/icguide.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/iclist.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Z-Voting/Z-Voting-App/HEAD/app/src/main/res/drawable/iclist.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/icplug.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Z-Voting/Z-Voting-App/HEAD/app/src/main/res/drawable/icplug.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/userpic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Z-Voting/Z-Voting-App/HEAD/app/src/main/res/drawable/userpic.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/icstarter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Z-Voting/Z-Voting-App/HEAD/app/src/main/res/drawable/icstarter.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/bgheaderminimal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Z-Voting/Z-Voting-App/HEAD/app/src/main/res/drawable/bgheaderminimal.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Z-Voting/Z-Voting-App/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Z-Voting/Z-Voting-App/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Z-Voting/Z-Voting-App/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/icbusinessplayer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Z-Voting/Z-Voting-App/HEAD/app/src/main/res/drawable/icbusinessplayer.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Z-Voting/Z-Voting-App/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Z-Voting/Z-Voting-App/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Z-Voting/Z-Voting-App/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Z-Voting/Z-Voting-App/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Z-Voting/Z-Voting-App/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Z-Voting/Z-Voting-App/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Z-Voting/Z-Voting-App/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/libraries 5 | /.idea/modules.xml 6 | /.idea/workspace.xml 7 | .DS_Store 8 | /build 9 | /captures 10 | .externalNativeBuild 11 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #313F8C 4 | #0288D1 5 | #173F5F 6 | 7 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Jan 22 03:05:26 BDT 2020 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip 7 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/bgbtnguide.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/font/myprior.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 11 | 12 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /app/src/main/res/animator/fade_appear.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/animator/fade_disappear.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/tkd/zvoting/model/User.java: -------------------------------------------------------------------------------- 1 | package com.example.tkd.zvoting.model; 2 | 3 | import java.io.Serializable; 4 | 5 | public class User implements Serializable { 6 | public String name; 7 | public String email; 8 | public String s1, s2, s3; 9 | 10 | public User() { 11 | 12 | } 13 | 14 | 15 | public User(String name, String email) { 16 | this.name = name; 17 | this.email = email; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ripple_effect_android_image.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_splash.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/anim/atg.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 12 | 13 | 17 | 18 | -------------------------------------------------------------------------------- /app/src/test/java/com/example/tkd/zvoting/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.example.tkd.zvoting; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /app/src/main/res/anim/atgthree.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 12 | 13 | 17 | 18 | -------------------------------------------------------------------------------- /app/src/main/res/anim/atgtwo.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 12 | 13 | 17 | 18 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_arrow_left.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_arrow_right.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/tkd/zvoting/rest/StartElectionRequest.java: -------------------------------------------------------------------------------- 1 | package com.example.tkd.zvoting.rest; 2 | 3 | public class StartElectionRequest { 4 | String electionId; 5 | 6 | public StartElectionRequest() { 7 | } 8 | 9 | public StartElectionRequest(String electionId) { 10 | this.electionId = electionId; 11 | } 12 | 13 | public String getElectionId() { 14 | return electionId; 15 | } 16 | 17 | public void setElectionId(String electionId) { 18 | this.electionId = electionId; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/tkd/zvoting/rest/CalculateResultRequest.java: -------------------------------------------------------------------------------- 1 | package com.example.tkd.zvoting.rest; 2 | 3 | public class CalculateResultRequest { 4 | String electionId; 5 | 6 | public CalculateResultRequest() { 7 | } 8 | 9 | public CalculateResultRequest(String electionId) { 10 | this.electionId = electionId; 11 | } 12 | 13 | public String getElectionId() { 14 | return electionId; 15 | } 16 | 17 | public void setElectionId(String electionId) { 18 | this.electionId = electionId; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /app/src/main/res/anim/packageimg.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 15 | 16 | 20 | 21 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/tkd/zvoting/rest/GetCandidatesRequest.java: -------------------------------------------------------------------------------- 1 | package com.example.tkd.zvoting.rest; 2 | 3 | import java.io.Serializable; 4 | 5 | public class GetCandidatesRequest implements Serializable { 6 | String electionId; 7 | 8 | public GetCandidatesRequest() { 9 | } 10 | 11 | public GetCandidatesRequest(String electionId) { 12 | this.electionId = electionId; 13 | } 14 | 15 | public String getElectionId() { 16 | return electionId; 17 | } 18 | 19 | public void setElectionId(String electionId) { 20 | this.electionId = electionId; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 15 | 16 | -------------------------------------------------------------------------------- /app/src/main/res/layout/my_elections_fragment.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 14 | 15 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/tkd/zvoting/rest/ApiClient.java: -------------------------------------------------------------------------------- 1 | package com.example.tkd.zvoting.rest; 2 | 3 | import com.example.tkd.zvoting.DataViewModel; 4 | 5 | import retrofit2.Retrofit; 6 | import retrofit2.converter.gson.GsonConverterFactory; 7 | 8 | public class ApiClient { 9 | 10 | private static final String BASE_URL = DataViewModel.URL; 11 | private static Retrofit retrofit = null; 12 | 13 | public static Retrofit getClient() { 14 | if (retrofit == null) { 15 | retrofit = new Retrofit.Builder() 16 | .baseUrl(BASE_URL) 17 | .addConverterFactory(GsonConverterFactory.create()) 18 | .build(); 19 | } 20 | return retrofit; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_item_list.xml: -------------------------------------------------------------------------------- 1 | 2 | 14 | 15 | -------------------------------------------------------------------------------- /app/src/main/res/animator/slide_down.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | 16 | -------------------------------------------------------------------------------- /app/src/main/res/animator/slide_up.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | 16 | -------------------------------------------------------------------------------- /app/src/main/res/animator/slide_down_disappear.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | 16 | -------------------------------------------------------------------------------- /app/src/main/res/animator/slide_up_disappear.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | 16 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | android.enableJetifier=true 10 | android.useAndroidX=true 11 | org.gradle.jvmargs=-Xmx1536m 12 | # When configured, Gradle will run in incubating parallel mode. 13 | # This option should only be used with decoupled projects. More details, visit 14 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 15 | # org.gradle.parallel=true 16 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_start.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 18 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 13 | 14 | 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/tkd/zvoting/rest/CreateElectionRequest.java: -------------------------------------------------------------------------------- 1 | package com.example.tkd.zvoting.rest; 2 | 3 | public class CreateElectionRequest { 4 | 5 | String electionName; 6 | String electionDuration; 7 | 8 | public CreateElectionRequest() { 9 | } 10 | 11 | public CreateElectionRequest(String electionName, String electionDuration) { 12 | this.electionName = electionName; 13 | this.electionDuration = electionDuration; 14 | } 15 | 16 | public String getElectionName() { 17 | return electionName; 18 | } 19 | 20 | public void setElectionName(String electionName) { 21 | this.electionName = electionName; 22 | } 23 | 24 | public String getElectionDuration() { 25 | return electionDuration; 26 | } 27 | 28 | public void setElectionDuration(String electionDuration) { 29 | this.electionDuration = electionDuration; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_header_login.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/example/tkd/zvoting/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.example.tkd.zvoting; 2 | 3 | import android.content.Context; 4 | 5 | import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner; 6 | import androidx.test.platform.app.InstrumentationRegistry; 7 | import androidx.test.ext.junit.runners.AndroidJUnit4; 8 | 9 | import org.junit.Test; 10 | import org.junit.runner.RunWith; 11 | 12 | import static org.junit.Assert.*; 13 | 14 | /** 15 | * Instrumented test, which will execute on an Android device. 16 | * 17 | * @see Testing documentation 18 | */ 19 | @RunWith(AndroidJUnit4ClassRunner.class) 20 | public class ExampleInstrumentedTest { 21 | @Test 22 | public void useAppContext() { 23 | // Context of the app under test. 24 | Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); 25 | 26 | assertEquals("com.example.tkd.zvoting", appContext.getPackageName()); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_log_out.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /app/src/main/res/layout/elections_fragment.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 22 | -------------------------------------------------------------------------------- /app/src/main/res/layout/operations_fragment.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 15 | 16 | 26 | -------------------------------------------------------------------------------- /.idea/assetWizardSettings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 31 | 32 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/tkd/zvoting/SplashActivity.java: -------------------------------------------------------------------------------- 1 | package com.example.tkd.zvoting; 2 | 3 | import androidx.annotation.NonNull; 4 | import androidx.appcompat.app.AppCompatActivity; 5 | 6 | import android.content.Intent; 7 | import android.os.Bundle; 8 | 9 | import com.google.firebase.auth.FirebaseAuth; 10 | 11 | public class SplashActivity extends AppCompatActivity { 12 | 13 | private FirebaseAuth firebaseAuth; 14 | 15 | @Override 16 | protected void onCreate(Bundle savedInstanceState) { 17 | super.onCreate(savedInstanceState); 18 | setContentView(R.layout.activity_splash); 19 | 20 | firebaseAuth = FirebaseAuth.getInstance(); 21 | firebaseAuth.addAuthStateListener(new FirebaseAuth.AuthStateListener() { 22 | @Override 23 | public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) { 24 | if(firebaseAuth.getCurrentUser()==null) { 25 | startActivity(new Intent(SplashActivity.this, AuthActivity.class)); 26 | finish(); 27 | } else { 28 | startActivity(new Intent(SplashActivity.this, MasterActivity.class)); 29 | finish(); 30 | } 31 | } 32 | }); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /app/src/main/res/layout/add_election_layout.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 13 | 14 | 24 | 25 | 32 | 33 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/tkd/zvoting/MasterPageAdapter.java: -------------------------------------------------------------------------------- 1 | package com.example.tkd.zvoting; 2 | 3 | import androidx.annotation.NonNull; 4 | import androidx.fragment.app.Fragment; 5 | import androidx.fragment.app.FragmentManager; 6 | import androidx.fragment.app.FragmentPagerAdapter; 7 | 8 | import java.util.List; 9 | 10 | class MasterPageAdapter extends FragmentPagerAdapter { 11 | List fragments; 12 | DataViewModel mDataViewModel; 13 | 14 | public MasterPageAdapter(FragmentManager fm, List fragments) { 15 | super(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT); 16 | this.fragments = fragments; 17 | this.mDataViewModel = DataViewModel.getInstance(null); 18 | } 19 | 20 | @NonNull 21 | @Override 22 | public Fragment getItem(int position) { 23 | switch (position) { 24 | case 0: mDataViewModel.mainfragment.setValue(DataViewModel.ElectionsFragment); break; 25 | case 1: mDataViewModel.mainfragment.setValue(DataViewModel.MyElectionsFragment); break; 26 | case 2: mDataViewModel.mainfragment.setValue(DataViewModel.ElectionResultsFragment); break; 27 | } 28 | 29 | return this.fragments.get(position); 30 | } 31 | 32 | @Override 33 | public int getCount() { 34 | return fragments.size(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_header.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/tkd/zvoting/rest/StartElectionResponse.java: -------------------------------------------------------------------------------- 1 | package com.example.tkd.zvoting.rest; 2 | 3 | import com.google.gson.annotations.Expose; 4 | import com.google.gson.annotations.SerializedName; 5 | 6 | import org.apache.commons.lang3.builder.ToStringBuilder; 7 | 8 | import java.io.Serializable; 9 | 10 | public class StartElectionResponse implements Serializable 11 | { 12 | 13 | @SerializedName("status") 14 | @Expose 15 | private String status; 16 | @SerializedName("message") 17 | @Expose 18 | private String message; 19 | private final static long serialVersionUID = 6209253831469656949L; 20 | 21 | /** 22 | * No args constructor for use in serialization 23 | * 24 | */ 25 | public StartElectionResponse() { 26 | } 27 | 28 | /** 29 | * 30 | * @param message 31 | * @param status 32 | */ 33 | public StartElectionResponse(String status, String message) { 34 | super(); 35 | this.status = status; 36 | this.message = message; 37 | } 38 | 39 | public String getStatus() { 40 | return status; 41 | } 42 | 43 | public void setStatus(String status) { 44 | this.status = status; 45 | } 46 | 47 | public String getMessage() { 48 | return message; 49 | } 50 | 51 | public void setMessage(String message) { 52 | this.message = message; 53 | } 54 | 55 | @Override 56 | public String toString() { 57 | return new ToStringBuilder(this).append("status", status).append("message", message).toString(); 58 | } 59 | 60 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/tkd/zvoting/rest/CreateElectionResponse.java: -------------------------------------------------------------------------------- 1 | package com.example.tkd.zvoting.rest; 2 | 3 | import com.google.gson.annotations.Expose; 4 | import com.google.gson.annotations.SerializedName; 5 | 6 | import org.apache.commons.lang3.builder.ToStringBuilder; 7 | 8 | import java.io.Serializable; 9 | 10 | public class CreateElectionResponse implements Serializable 11 | { 12 | 13 | @SerializedName("status") 14 | @Expose 15 | private String status; 16 | @SerializedName("message") 17 | @Expose 18 | private String message; 19 | private final static long serialVersionUID = 6209253831469656949L; 20 | 21 | /** 22 | * No args constructor for use in serialization 23 | * 24 | */ 25 | public CreateElectionResponse() { 26 | } 27 | 28 | /** 29 | * 30 | * @param message 31 | * @param status 32 | */ 33 | public CreateElectionResponse(String status, String message) { 34 | super(); 35 | this.status = status; 36 | this.message = message; 37 | } 38 | 39 | public String getStatus() { 40 | return status; 41 | } 42 | 43 | public void setStatus(String status) { 44 | this.status = status; 45 | } 46 | 47 | public String getMessage() { 48 | return message; 49 | } 50 | 51 | public void setMessage(String message) { 52 | this.message = message; 53 | } 54 | 55 | @Override 56 | public String toString() { 57 | return new ToStringBuilder(this).append("status", status).append("message", message).toString(); 58 | } 59 | 60 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/tkd/zvoting/model/Candidate.java: -------------------------------------------------------------------------------- 1 | package com.example.tkd.zvoting.model; 2 | 3 | public class Candidate { 4 | String id; 5 | String name; 6 | String sign; 7 | String imgAddress; 8 | String electionID; 9 | String doctype; 10 | 11 | public Candidate() { 12 | } 13 | 14 | public Candidate(String id, String name, String sign, String imgAddress, String electionID, String doctype) { 15 | this.id = id; 16 | this.name = name; 17 | this.sign = sign; 18 | this.imgAddress = imgAddress; 19 | this.electionID = electionID; 20 | this.doctype = doctype; 21 | } 22 | 23 | public String getId() { 24 | return id; 25 | } 26 | 27 | public void setId(String id) { 28 | this.id = id; 29 | } 30 | 31 | public String getName() { 32 | return name; 33 | } 34 | 35 | public void setName(String name) { 36 | this.name = name; 37 | } 38 | 39 | public String getSign() { 40 | return sign; 41 | } 42 | 43 | public void setSign(String sign) { 44 | this.sign = sign; 45 | } 46 | 47 | public String getImgAddress() { 48 | return imgAddress; 49 | } 50 | 51 | public void setImgAddress(String imgAddress) { 52 | this.imgAddress = imgAddress; 53 | } 54 | 55 | public String getElectionID() { 56 | return electionID; 57 | } 58 | 59 | public void setElectionID(String electionID) { 60 | this.electionID = electionID; 61 | } 62 | 63 | public String getDoctype() { 64 | return doctype; 65 | } 66 | 67 | public void setDoctype(String doctype) { 68 | this.doctype = doctype; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/tkd/zvoting/rest/ApiInterface.java: -------------------------------------------------------------------------------- 1 | package com.example.tkd.zvoting.rest; 2 | 3 | import com.example.tkd.zvoting.model.Candidate; 4 | import com.example.tkd.zvoting.model.Election; 5 | import com.example.tkd.zvoting.model.ElectionResult; 6 | import com.example.tkd.zvoting.model.LoginChallenge; 7 | import com.example.tkd.zvoting.model.ResponseMessage; 8 | 9 | import java.util.List; 10 | 11 | import retrofit2.Call; 12 | import retrofit2.http.Body; 13 | import retrofit2.http.GET; 14 | import retrofit2.http.POST; 15 | 16 | public interface ApiInterface { 17 | 18 | @GET("/getElections") 19 | Call> getElections(); 20 | 21 | @POST("/addCandidate") 22 | Call addCandidate(@Body AddCandidateRequest addCandidateRequest); 23 | 24 | @POST("/registerVoter") 25 | Call registerVoter(@Body AddVoterRequest addVoterRequest); 26 | 27 | @POST("/getCandidates") 28 | Call> getCandidates(@Body GetCandidatesRequest getCandidatesRequest); 29 | 30 | @POST("/getLoginChallenge") 31 | Call getLoginChallenge(); 32 | 33 | @POST("/voterLogin") 34 | Call voterLogin(@Body VoterLoginRequest voterLoginRequest); 35 | 36 | @POST("/castVote") 37 | Call castVote(@Body CastVoteRequest castVoteRequest); 38 | 39 | @POST("/calculateResult") 40 | Call calculateResult(@Body CalculateResultRequest calculateResultRequest); 41 | 42 | @POST("/createElection") 43 | Call createElection(@Body CreateElectionRequest createElectionRequest); 44 | 45 | @POST("/startElection") 46 | Call startElection(@Body StartElectionRequest startElectionRequest); 47 | } 48 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_item_list_new.xml: -------------------------------------------------------------------------------- 1 | 2 | 14 | 15 | 16 | 26 | 27 | 40 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/tkd/zvoting/model/ResponseMessage.java: -------------------------------------------------------------------------------- 1 | package com.example.tkd.zvoting.model; 2 | 3 | 4 | import java.io.Serializable; 5 | import com.google.gson.annotations.Expose; 6 | import com.google.gson.annotations.SerializedName; 7 | 8 | import org.apache.commons.lang3.builder.ToStringBuilder; 9 | 10 | 11 | public class ResponseMessage implements Serializable 12 | { 13 | @SerializedName("status") 14 | @Expose 15 | private String status; 16 | @SerializedName("data") 17 | @Expose 18 | private String data; 19 | @SerializedName("message") 20 | @Expose 21 | private String message; 22 | private final static long serialVersionUID = -8120151689709330544L; 23 | 24 | /** 25 | * No args constructor for use in serialization 26 | * 27 | */ 28 | public ResponseMessage() { 29 | } 30 | 31 | /** 32 | * 33 | * @param data 34 | * @param message 35 | * @param status 36 | */ 37 | public ResponseMessage(String status, String data, String message) { 38 | super(); 39 | this.status = status; 40 | this.data = data; 41 | this.message = message; 42 | } 43 | 44 | public String getStatus() { 45 | return status; 46 | } 47 | 48 | public void setStatus(String status) { 49 | this.status = status; 50 | } 51 | 52 | public String getData() { 53 | return data; 54 | } 55 | 56 | public void setData(String data) { 57 | this.data = data; 58 | } 59 | 60 | public String getMessage() { 61 | return message; 62 | } 63 | 64 | public void setMessage(String message) { 65 | this.message = message; 66 | } 67 | 68 | @Override 69 | public String toString() { 70 | return new ToStringBuilder(this).append("status", status).append("data", data).append("message", message).toString(); 71 | } 72 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/tkd/zvoting/rest/CastVoteResponse.java: -------------------------------------------------------------------------------- 1 | package com.example.tkd.zvoting.rest; 2 | 3 | import com.example.tkd.zvoting.model.Vote; 4 | import com.google.gson.annotations.Expose; 5 | import com.google.gson.annotations.SerializedName; 6 | 7 | import org.apache.commons.lang3.builder.ToStringBuilder; 8 | 9 | import java.io.Serializable; 10 | 11 | public class CastVoteResponse implements Serializable 12 | { 13 | 14 | @SerializedName("status") 15 | @Expose 16 | private String status; 17 | @SerializedName("data") 18 | @Expose 19 | private Vote data; 20 | @SerializedName("message") 21 | @Expose 22 | private String message; 23 | private final static long serialVersionUID = 9216839916904348263L; 24 | 25 | /** 26 | * No args constructor for use in serialization 27 | * 28 | */ 29 | public CastVoteResponse() { 30 | } 31 | 32 | /** 33 | * 34 | * @param data 35 | * @param message 36 | * @param status 37 | */ 38 | public CastVoteResponse(String status, Vote data, String message) { 39 | super(); 40 | this.status = status; 41 | this.data = data; 42 | this.message = message; 43 | } 44 | 45 | public String getStatus() { 46 | return status; 47 | } 48 | 49 | public void setStatus(String status) { 50 | this.status = status; 51 | } 52 | 53 | public Vote getData() { 54 | return data; 55 | } 56 | 57 | public void setData(Vote data) { 58 | this.data = data; 59 | } 60 | 61 | public String getMessage() { 62 | return message; 63 | } 64 | 65 | public void setMessage(String message) { 66 | this.message = message; 67 | } 68 | 69 | @Override 70 | public String toString() { 71 | return new ToStringBuilder(this).append("status", status).append("data", data).append("message", message).toString(); 72 | } 73 | 74 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/tkd/zvoting/rest/LoginResponse.java: -------------------------------------------------------------------------------- 1 | package com.example.tkd.zvoting.rest; 2 | 3 | import com.example.tkd.zvoting.model.Voter; 4 | import com.google.gson.annotations.Expose; 5 | import com.google.gson.annotations.SerializedName; 6 | 7 | import org.apache.commons.lang3.builder.ToStringBuilder; 8 | 9 | import java.io.Serializable; 10 | 11 | public class LoginResponse implements Serializable 12 | { 13 | 14 | @SerializedName("status") 15 | @Expose 16 | private String status; 17 | @SerializedName("data") 18 | @Expose 19 | private Voter data; 20 | @SerializedName("message") 21 | @Expose 22 | private String message; 23 | private final static long serialVersionUID = -2554450009593906821L; 24 | 25 | /** 26 | * No args constructor for use in serialization 27 | * 28 | */ 29 | public LoginResponse() { 30 | } 31 | 32 | /** 33 | * 34 | * @param data 35 | * @param message 36 | * @param status 37 | */ 38 | public LoginResponse(String status, Voter data, String message) { 39 | super(); 40 | this.status = status; 41 | this.data = data; 42 | this.message = message; 43 | } 44 | 45 | public String getStatus() { 46 | return status; 47 | } 48 | 49 | public void setStatus(String status) { 50 | this.status = status; 51 | } 52 | 53 | public Voter getData() { 54 | return data; 55 | } 56 | 57 | public void setData(Voter data) { 58 | this.data = data; 59 | } 60 | 61 | public String getMessage() { 62 | return message; 63 | } 64 | 65 | public void setMessage(String message) { 66 | this.message = message; 67 | } 68 | 69 | @Override 70 | public String toString() { 71 | return new ToStringBuilder(this).append("status", status).append("data", data).append("message", message).toString(); 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/tkd/zvoting/model/LoginChallenge.java: -------------------------------------------------------------------------------- 1 | package com.example.tkd.zvoting.model; 2 | 3 | import com.google.gson.annotations.Expose; 4 | import com.google.gson.annotations.SerializedName; 5 | import org.apache.commons.lang3.builder.ToStringBuilder; 6 | import java.io.Serializable; 7 | 8 | public class LoginChallenge implements Serializable 9 | { 10 | 11 | @SerializedName("a1") 12 | @Expose 13 | private Long a1; 14 | @SerializedName("a2") 15 | @Expose 16 | private Long a2; 17 | @SerializedName("a3") 18 | @Expose 19 | private Long a3; 20 | @SerializedName("n") 21 | @Expose 22 | private Long n; 23 | private final static long serialVersionUID = -1650088854618052301L; 24 | 25 | /** 26 | * No args constructor for use in serialization 27 | * 28 | */ 29 | public LoginChallenge() { 30 | } 31 | 32 | /** 33 | * 34 | * @param a1 35 | * @param a2 36 | * @param a3 37 | * @param n 38 | */ 39 | public LoginChallenge(Long a1, Long a2, Long a3, Long n) { 40 | super(); 41 | this.a1 = a1; 42 | this.a2 = a2; 43 | this.a3 = a3; 44 | this.n = n; 45 | } 46 | 47 | public Long getA1() { 48 | return a1; 49 | } 50 | 51 | public void setA1(Long a1) { 52 | this.a1 = a1; 53 | } 54 | 55 | public Long getA2() { 56 | return a2; 57 | } 58 | 59 | public void setA2(Long a2) { 60 | this.a2 = a2; 61 | } 62 | 63 | public Long getA3() { 64 | return a3; 65 | } 66 | 67 | public void setA3(Long a3) { 68 | this.a3 = a3; 69 | } 70 | 71 | public Long getN() { 72 | return n; 73 | } 74 | 75 | public void setN(Long n) { 76 | this.n = n; 77 | } 78 | 79 | @Override 80 | public String toString() { 81 | return new ToStringBuilder(this).append("a1", a1).append("a2", a2).append("a3", a3).append("n", n).toString(); 82 | } 83 | 84 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/tkd/zvoting/rest/CastVoteRequest.java: -------------------------------------------------------------------------------- 1 | package com.example.tkd.zvoting.rest; 2 | 3 | import com.google.gson.annotations.Expose; 4 | import com.google.gson.annotations.SerializedName; 5 | 6 | import org.apache.commons.lang3.builder.ToStringBuilder; 7 | 8 | import java.io.Serializable; 9 | 10 | public class CastVoteRequest implements Serializable 11 | { 12 | 13 | @SerializedName("email") 14 | @Expose 15 | private String email; 16 | @SerializedName("electionID") 17 | @Expose 18 | private String electionID; 19 | @SerializedName("voteContent") 20 | @Expose 21 | private String voteContent; 22 | private final static long serialVersionUID = 5653570959699010389L; 23 | 24 | /** 25 | * No args constructor for use in serialization 26 | * 27 | */ 28 | public CastVoteRequest() { 29 | } 30 | 31 | /** 32 | * 33 | * @param electionID 34 | * @param voteContent 35 | * @param email 36 | */ 37 | public CastVoteRequest(String email, String electionID, String voteContent) { 38 | super(); 39 | this.email = email; 40 | this.electionID = electionID; 41 | this.voteContent = voteContent; 42 | } 43 | 44 | public String getEmail() { 45 | return email; 46 | } 47 | 48 | public void setEmail(String email) { 49 | this.email = email; 50 | } 51 | 52 | public String getElectionID() { 53 | return electionID; 54 | } 55 | 56 | public void setElectionID(String electionID) { 57 | this.electionID = electionID; 58 | } 59 | 60 | public String getVoteContent() { 61 | return voteContent; 62 | } 63 | 64 | public void setVoteContent(String voteContent) { 65 | this.voteContent = voteContent; 66 | } 67 | 68 | @Override 69 | public String toString() { 70 | return new ToStringBuilder(this).append("email", email).append("electionID", electionID).append("voteContent", voteContent).toString(); 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/tkd/zvoting/MyElectionsFragment.java: -------------------------------------------------------------------------------- 1 | package com.example.tkd.zvoting; 2 | 3 | import androidx.lifecycle.Observer; 4 | import androidx.lifecycle.ViewModelProviders; 5 | 6 | import android.os.Bundle; 7 | 8 | import androidx.annotation.NonNull; 9 | import androidx.annotation.Nullable; 10 | import androidx.fragment.app.Fragment; 11 | import androidx.recyclerview.widget.RecyclerView; 12 | 13 | import android.view.LayoutInflater; 14 | import android.view.View; 15 | import android.view.ViewGroup; 16 | 17 | import com.example.tkd.zvoting.model.Election; 18 | import com.example.tkd.zvoting.model.User; 19 | 20 | import java.util.ArrayList; 21 | 22 | public class MyElectionsFragment extends Fragment { 23 | 24 | private MyElectionsViewModel mViewModel; 25 | RecyclerView content; 26 | ArrayList myElections; 27 | 28 | public static MyElectionsFragment newInstance() { 29 | return new MyElectionsFragment(); 30 | } 31 | 32 | @Override 33 | public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, 34 | @Nullable Bundle savedInstanceState) { 35 | View v = inflater.inflate(R.layout.my_elections_fragment, container, false); 36 | content = v.findViewById(R.id.content); 37 | if (myElections == null) 38 | myElections = new ArrayList<>(); 39 | return v; 40 | } 41 | 42 | @Override 43 | public void onResume() { 44 | super.onResume(); 45 | mViewModel.mDataViewModel.mainfragment.setValue(DataViewModel.MyElectionsFragment); 46 | 47 | mViewModel.liveMyElections.observe(this, elections -> { 48 | myElections = elections; 49 | mViewModel.mDataViewModel.liveUser.observe(MyElectionsFragment.this, user -> { 50 | content.setAdapter(new MyElectionsListAdapter(MyElectionsFragment.this, myElections, user)); 51 | }); 52 | }); 53 | } 54 | 55 | @Override 56 | public void onActivityCreated(@Nullable Bundle savedInstanceState) { 57 | super.onActivityCreated(savedInstanceState); 58 | mViewModel = ViewModelProviders.of(this).get(MyElectionsViewModel.class); 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/tkd/zvoting/ElectionsViewModel.java: -------------------------------------------------------------------------------- 1 | package com.example.tkd.zvoting; 2 | 3 | import android.app.Application; 4 | import android.os.CountDownTimer; 5 | import android.util.Log; 6 | 7 | import androidx.annotation.NonNull; 8 | import androidx.lifecycle.AndroidViewModel; 9 | import androidx.lifecycle.MutableLiveData; 10 | 11 | import com.example.tkd.zvoting.model.Election; 12 | import com.example.tkd.zvoting.rest.ApiClient; 13 | import com.example.tkd.zvoting.rest.ApiInterface; 14 | 15 | import java.util.ArrayList; 16 | import java.util.List; 17 | 18 | import retrofit2.Call; 19 | import retrofit2.Callback; 20 | import retrofit2.Response; 21 | 22 | public class ElectionsViewModel extends AndroidViewModel { 23 | DataViewModel mDataViewModel; 24 | 25 | MutableLiveData> liveElections; 26 | ApiInterface apiInterface; 27 | 28 | public ElectionsViewModel(@NonNull Application application) { 29 | super(application); 30 | mDataViewModel = DataViewModel.getInstance(application); 31 | liveElections = new MutableLiveData<>(new ArrayList<>()); 32 | 33 | apiInterface = ApiClient.getClient().create(ApiInterface.class); 34 | } 35 | 36 | public void getElections() { 37 | Call> call = apiInterface.getElections(); 38 | call.enqueue(new Callback>() { 39 | @Override 40 | public void onResponse(Call> call, Response> response) { 41 | List body = response.body(); 42 | 43 | ArrayList elections = new ArrayList<>(); 44 | elections.addAll(body); 45 | 46 | liveElections.setValue(elections); 47 | } 48 | 49 | @Override 50 | public void onFailure(Call> call, Throwable t) { 51 | Log.e("TKD", "Error: " + t); 52 | } 53 | }); 54 | 55 | new CountDownTimer(10000, 5000) { 56 | 57 | @Override 58 | public void onTick(long millisUntilFinished) { 59 | 60 | } 61 | 62 | @Override 63 | public void onFinish() { 64 | getElections(); 65 | } 66 | }.start(); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/tkd/zvoting/dummy/DummyContent.java: -------------------------------------------------------------------------------- 1 | package com.example.tkd.zvoting.dummy; 2 | 3 | import java.util.ArrayList; 4 | import java.util.HashMap; 5 | import java.util.List; 6 | import java.util.Map; 7 | 8 | /** 9 | * Helper class for providing sample content for user interfaces created by 10 | * Android template wizards. 11 | *

12 | * TODO: Replace all uses of this class before publishing your app. 13 | */ 14 | public class DummyContent { 15 | 16 | /** 17 | * An array of sample (dummy) items. 18 | */ 19 | public static final List ITEMS = new ArrayList(); 20 | 21 | /** 22 | * A map of sample (dummy) items, by ID. 23 | */ 24 | public static final Map ITEM_MAP = new HashMap(); 25 | 26 | private static final int COUNT = 25; 27 | 28 | static { 29 | // Add some sample items. 30 | for (int i = 1; i <= COUNT; i++) { 31 | addItem(createDummyItem(i)); 32 | } 33 | } 34 | 35 | private static void addItem(DummyItem item) { 36 | ITEMS.add(item); 37 | ITEM_MAP.put(item.id, item); 38 | } 39 | 40 | private static DummyItem createDummyItem(int position) { 41 | return new DummyItem(String.valueOf(position), "Item " + position, makeDetails(position)); 42 | } 43 | 44 | private static String makeDetails(int position) { 45 | StringBuilder builder = new StringBuilder(); 46 | builder.append("Details about Item: ").append(position); 47 | for (int i = 0; i < position; i++) { 48 | builder.append("\nMore details information here."); 49 | } 50 | return builder.toString(); 51 | } 52 | 53 | /** 54 | * A dummy item representing a piece of content. 55 | */ 56 | public static class DummyItem { 57 | public final String id; 58 | public final String content; 59 | public final String details; 60 | 61 | public DummyItem(String id, String content, String details) { 62 | this.id = id; 63 | this.content = content; 64 | this.details = details; 65 | } 66 | 67 | @Override 68 | public String toString() { 69 | return content; 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/tkd/zvoting/rest/AddCandidateRequest.java: -------------------------------------------------------------------------------- 1 | package com.example.tkd.zvoting.rest; 2 | 3 | import java.io.Serializable; 4 | import com.google.gson.annotations.Expose; 5 | import com.google.gson.annotations.SerializedName; 6 | 7 | import org.apache.commons.lang3.builder.ToStringBuilder; 8 | 9 | 10 | public class AddCandidateRequest implements Serializable 11 | { 12 | 13 | @SerializedName("name") 14 | @Expose 15 | private String name; 16 | @SerializedName("sign") 17 | @Expose 18 | private String sign; 19 | @SerializedName("imgAddress") 20 | @Expose 21 | private String imgAddress; 22 | @SerializedName("electionId") 23 | @Expose 24 | private String electionId; 25 | private final static long serialVersionUID = -1785708481179338667L; 26 | 27 | /** 28 | * No args constructor for use in serialization 29 | * 30 | */ 31 | public AddCandidateRequest() { 32 | } 33 | 34 | /** 35 | * 36 | * @param electionId 37 | * @param name 38 | * @param sign 39 | * @param imgAddress 40 | */ 41 | public AddCandidateRequest(String name, String sign, String imgAddress, String electionId) { 42 | super(); 43 | this.name = name; 44 | this.sign = sign; 45 | this.imgAddress = imgAddress; 46 | this.electionId = electionId; 47 | } 48 | 49 | public String getName() { 50 | return name; 51 | } 52 | 53 | public void setName(String name) { 54 | this.name = name; 55 | } 56 | 57 | public String getSign() { 58 | return sign; 59 | } 60 | 61 | public void setSign(String sign) { 62 | this.sign = sign; 63 | } 64 | 65 | public String getImgAddress() { 66 | return imgAddress; 67 | } 68 | 69 | public void setImgAddress(String imgAddress) { 70 | this.imgAddress = imgAddress; 71 | } 72 | 73 | public String getElectionId() { 74 | return electionId; 75 | } 76 | 77 | public void setElectionId(String electionId) { 78 | this.electionId = electionId; 79 | } 80 | 81 | @Override 82 | public String toString() { 83 | return new ToStringBuilder(this).append("name", name).append("sign", sign).append("imgAddress", imgAddress).append("electionId", electionId).toString(); 84 | } 85 | 86 | } 87 | -------------------------------------------------------------------------------- /app/src/main/res/layout/election_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 10 | 11 | 18 | 19 | 23 | 24 | 33 | 34 | 39 | 40 |