diff --git a/electionvote/CustomizationActivity.java b/electionvote/CustomizationActivity.java new file mode 100644 index 0000000..5b03d38 --- /dev/null +++ b/electionvote/CustomizationActivity.java @@ -0,0 +1,151 @@ +package com.example.impactmakers.electionvote; + +import android.Manifest; +import android.app.DownloadManager; +import android.content.Intent; +import android.content.pm.PackageManager; +import android.net.Uri; +import android.os.Bundle; +import android.os.Environment; +import android.text.Editable; +import android.text.TextWatcher; +import android.view.View; +import android.widget.Button; +import android.widget.EditText; +import android.widget.ImageView; +import android.widget.TextView; +import android.widget.Toast; + +import androidx.appcompat.app.AppCompatActivity; +import androidx.core.app.ActivityCompat; +import androidx.core.content.ContextCompat; +import androidx.core.content.FileProvider; + +import java.io.File; + +public class CustomizationActivity extends AppCompatActivity { + + private static final int REQUEST_CODE_SELECT_PHOTO = 1; + + private static final int REQUEST_CODE_SHARE = 123; + + private ImageView mImageViewTemplate; + private ImageView mImageViewUserPhoto; + private EditText mEditTextName; + private Button mButtonSave; + + private int mTemplateId; + + private boolean isAdjustingText = false; + + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_customize); + + // Get references to UI elements + mImageViewTemplate = findViewById(R.id.image_user_photo); + mEditTextName = findViewById(R.id.edit_text_name); + mButtonSave = findViewById(R.id.button_save); + + EditText editText = findViewById(R.id.edit_text_name); + TextView textView = findViewById(R.id.memeTopText); + + // Get the ID of the selected template + Intent intent = getIntent(); + mTemplateId = intent.getIntExtra("template_id", 0); + + // Set the selected template as the background of the template image view + mImageViewTemplate.setImageResource(mTemplateId); + mImageViewTemplate = findViewById(R.id.image_user_photo); + mTemplateId = intent.getIntExtra("template_id", 0); + + + editText.addTextChangedListener(new TextWatcher() { + @Override + public void beforeTextChanged(CharSequence s, int start, int count, int after) { + // do nothing + } + + @Override + public void onTextChanged(CharSequence s, int start, int before, int count) { + // update the text of the TextView with the user entered text + textView.setText(s.toString()); + } + + @Override + public void afterTextChanged(Editable s) { + // do nothing + } + }); + + // Add an onClickListener to the "Save" button + mButtonSave.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + // Save the customized poster + } + }); + Button buttonShare = findViewById(R.id.button_save); + buttonShare.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + // Share the image file + File imageFile = new File(getExternalFilesDir(Environment.DIRECTORY_PICTURES), "my_image.jpg"); + Intent shareIntent = new Intent(Intent.ACTION_SEND); + shareIntent.setType("image/*"); + Uri imageUri = FileProvider.getUriForFile(CustomizationActivity.this, BuildConfig.APPLICATION_ID + ".fileprovider", imageFile); + shareIntent.putExtra(Intent.EXTRA_STREAM, imageUri); + shareIntent.putExtra(Intent.EXTRA_TEXT, "Check out this image"); + shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); + startActivityForResult(Intent.createChooser(shareIntent, "Share image via"), REQUEST_CODE_SHARE); + } + }); + Button buttonDownload = findViewById(R.id.button_save1); + buttonDownload.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (ContextCompat.checkSelfPermission(CustomizationActivity.this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { + // Permission not granted, request it again + ActivityCompat.requestPermissions(CustomizationActivity.this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 1); + } else { + // Permission already granted, proceed with download + String imageUrl = getIntent().getStringExtra("imageUri"); + DownloadManager.Request request = new DownloadManager.Request(Uri.parse(imageUrl)); + request.setTitle("Image Download"); + request.setDescription("Downloading image"); + request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED); + request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, "image.jpg"); + DownloadManager downloadManager = (DownloadManager) getSystemService(DOWNLOAD_SERVICE); + if (downloadManager != null) { + downloadManager.enqueue(request); + Toast.makeText(CustomizationActivity.this, "Downloading...", Toast.LENGTH_SHORT).show(); + } + } + } + }); + } +} + + + + + + + + + + + + + + + + + + + + + + diff --git a/electionvote/MainActivity.java b/electionvote/MainActivity.java new file mode 100644 index 0000000..4ef723a --- /dev/null +++ b/electionvote/MainActivity.java @@ -0,0 +1,97 @@ +package com.example.impactmakers.electionvote; + +import androidx.appcompat.app.AppCompatActivity; + +import android.content.Intent; +import android.net.Uri; +import android.os.Bundle; +import android.view.View; +import android.widget.LinearLayout; +import android.widget.MediaController; +import android.widget.TextView; +import android.widget.VideoView; + +import com.denzcoskun.imageslider.ImageSlider; +import com.denzcoskun.imageslider.constants.ScaleTypes; +import com.denzcoskun.imageslider.models.SlideModel; +import com.google.android.material.bottomnavigation.BottomNavigationView; + +import java.util.ArrayList; + +public class MainActivity extends AppCompatActivity { + + LinearLayout points_layout; + + + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + + points_layout = findViewById(R.id.points_layout); + points_layout.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Intent intent = new Intent(MainActivity.this,RewardActivity.class); + startActivity(intent); + } + }); + + + ImageSlider imageSlider = findViewById(R.id.imageSlider); + ArrayList slideModels = new ArrayList<>(); + + slideModels.add(new SlideModel(R.drawable.vote1, ScaleTypes.FIT)); + slideModels.add(new SlideModel(R.drawable.vote2, ScaleTypes.FIT)); + slideModels.add(new SlideModel(R.drawable.vote4, ScaleTypes.FIT)); + slideModels.add(new SlideModel(R.drawable.vote3, ScaleTypes.FIT)); + slideModels.add(new SlideModel(R.drawable.vote5, ScaleTypes.FIT)); + imageSlider.setImageList(slideModels, ScaleTypes.FIT); + + BottomNavigationView bottomNavigationView = findViewById(R.id.bottomNavigation); + bottomNavigationView.setSelectedItemId(R.id.bottom_home); + + bottomNavigationView.setOnItemSelectedListener(item -> { + switch (item.getItemId()) { + case R.id.bottom_home: + return true; + case R.id.bottom_search: + startActivity(new Intent(getApplicationContext(), vote_activity.class)); + overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left); + finish(); + return true; + case R.id.bottom_settings: + startActivity(new Intent(getApplicationContext(), reward_activity.class)); + overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left); + finish(); + return true; + case R.id.bottom_profile: + startActivity(new Intent(getApplicationContext(), profile_activity.class)); + overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left); + finish(); + return true; + } + return false; + }); + + + TextView greetingTextView = findViewById(R.id.greeting_text_view); + String name = getIntent().getStringExtra( "name"); + greetingTextView.setText("Welcome " + name); + + VideoView videoView = findViewById(R.id.video_view); + String videoPath = "android.resource://" + getPackageName() + "/" + R.raw.awarevideo; + + Uri uri = Uri.parse(videoPath); + videoView.setVideoURI(uri); + + MediaController mediaController = new MediaController(this); + videoView.setMediaController(mediaController); + mediaController.setAnchorView(videoView); + + + + + } +} \ No newline at end of file diff --git a/electionvote/NameActivity.java b/electionvote/NameActivity.java new file mode 100644 index 0000000..e8c5b05 --- /dev/null +++ b/electionvote/NameActivity.java @@ -0,0 +1,68 @@ +package com.example.impactmakers.electionvote; + +import android.content.Intent; +import android.os.Bundle; +import android.view.View; +import android.widget.Button; +import android.widget.EditText; +import android.widget.TextView; +import android.widget.Toast; +import androidx.annotation.NonNull; +import androidx.appcompat.app.AppCompatActivity; + +import com.google.android.gms.tasks.OnCompleteListener; +import com.google.android.gms.tasks.Task; +import com.google.android.material.textfield.TextInputLayout; +import com.google.firebase.auth.FirebaseAuth; +import com.google.firebase.auth.FirebaseUser; +import com.google.firebase.database.DatabaseReference; +import com.google.firebase.database.FirebaseDatabase; + +public class NameActivity extends AppCompatActivity { + + private EditText nameEditText; + private Button submitButton; + private DatabaseReference databaseReference; + private FirebaseUser currentUser; + + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_name); + + nameEditText = findViewById(R.id.name_edittext); + submitButton = findViewById(R.id.submit_button); + + currentUser = FirebaseAuth.getInstance().getCurrentUser(); + if (currentUser != null) { + databaseReference = FirebaseDatabase.getInstance().getReference().child("Users").child(currentUser.getUid()); + } + + submitButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + String name = nameEditText.getText().toString().trim(); + + if (name.isEmpty()) { + Toast.makeText(NameActivity.this, "Please enter your name", Toast.LENGTH_SHORT).show(); + } else { + databaseReference.child("name").setValue(name).addOnCompleteListener(new OnCompleteListener() { + @Override + public void onComplete(@NonNull Task task) { + if (task.isSuccessful()) { + Toast.makeText(NameActivity.this, "Name saved successfully", Toast.LENGTH_SHORT).show(); + Intent intent = new Intent(NameActivity.this, MainActivity.class); + intent.putExtra("name", name); + startActivity(intent); + finish(); // finish this activity and go back to MainActivity + } else { + Toast.makeText(NameActivity.this, "Error: " + task.getException().getMessage(), Toast.LENGTH_SHORT).show(); + } + } + }); + } + } + }); + } +} \ No newline at end of file diff --git a/electionvote/OtpSendActivity.java b/electionvote/OtpSendActivity.java new file mode 100644 index 0000000..231b085 --- /dev/null +++ b/electionvote/OtpSendActivity.java @@ -0,0 +1,89 @@ +package com.example.impactmakers.electionvote; + +import android.content.Intent; +import android.os.Bundle; +import android.view.View; +import android.widget.Toast; + +import androidx.annotation.NonNull; +import androidx.appcompat.app.AppCompatActivity; + +import com.example.impactmakers.electionvote.databinding.ActivityOtpSendBinding; +import com.google.firebase.FirebaseException; +import com.google.firebase.auth.FirebaseAuth; +import com.google.firebase.auth.PhoneAuthCredential; +import com.google.firebase.auth.PhoneAuthOptions; +import com.google.firebase.auth.PhoneAuthProvider; + +import java.util.concurrent.TimeUnit; + +public class OtpSendActivity extends AppCompatActivity { + + private ActivityOtpSendBinding binding; + public FirebaseAuth mAuth; + private PhoneAuthProvider.OnVerificationStateChangedCallbacks mCallbacks; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + binding = ActivityOtpSendBinding.inflate(getLayoutInflater()); + setContentView(binding.getRoot()); + + mAuth = FirebaseAuth.getInstance(); + + binding.btnSend.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (binding.etPhone.getText().toString().trim().isEmpty()) { + Toast.makeText(OtpSendActivity.this, "Invalid Phone Number", Toast.LENGTH_SHORT).show(); + } else if (binding.etPhone.getText().toString().trim().length() != 10) { + Toast.makeText(OtpSendActivity.this, "Type valid Phone Number", Toast.LENGTH_SHORT).show(); + } else { + otpSend(); + } + } + }); + } + + private void otpSend() { + binding.progressBar.setVisibility(View.VISIBLE); + binding.btnSend.setVisibility(View.INVISIBLE); + + mCallbacks = new PhoneAuthProvider.OnVerificationStateChangedCallbacks() { + + @Override + public void onVerificationCompleted(PhoneAuthCredential credential) { + + } + + @Override + public void onVerificationFailed(FirebaseException e) { + binding.progressBar.setVisibility(View.GONE); + binding.btnSend.setVisibility(View.VISIBLE); + Toast.makeText(OtpSendActivity.this, e.getLocalizedMessage(), Toast.LENGTH_SHORT).show(); + } + + @Override + public void onCodeSent(@NonNull String verificationId, + @NonNull PhoneAuthProvider.ForceResendingToken token) { + binding.progressBar.setVisibility(View.GONE); + binding.btnSend.setVisibility(View.VISIBLE); + Toast.makeText(OtpSendActivity.this, "OTP is successfully send.", Toast.LENGTH_SHORT).show(); + Intent intent = new Intent(OtpSendActivity.this, OtpVerifyActivity.class); + intent.putExtra("phone", binding.etPhone.getText().toString().trim()); + intent.putExtra("verificationId", verificationId); + startActivity(intent); + } + + }; + + PhoneAuthOptions options = + PhoneAuthOptions.newBuilder(mAuth) + .setPhoneNumber("+91" + binding.etPhone.getText().toString().trim()) + .setTimeout(60L, TimeUnit.SECONDS) + .setActivity(this) + .setCallbacks(mCallbacks) + .build(); + PhoneAuthProvider.verifyPhoneNumber(options); + } +} \ No newline at end of file diff --git a/electionvote/OtpVerifyActivity.java b/electionvote/OtpVerifyActivity.java new file mode 100644 index 0000000..ca611ec --- /dev/null +++ b/electionvote/OtpVerifyActivity.java @@ -0,0 +1,185 @@ +package com.example.impactmakers.electionvote; + +import android.content.Intent; +import android.os.Bundle; +import android.text.Editable; +import android.text.TextWatcher; +import android.view.View; +import android.widget.Toast; + +import androidx.annotation.NonNull; +import androidx.appcompat.app.AppCompatActivity; + +import com.example.impactmakers.electionvote.databinding.ActivityOtpVerifyBinding; +import com.google.android.gms.tasks.OnCompleteListener; +import com.google.android.gms.tasks.Task; +import com.google.firebase.auth.AuthResult; +import com.google.firebase.auth.FirebaseAuth; +import com.google.firebase.auth.FirebaseUser; +import com.google.firebase.auth.PhoneAuthCredential; +import com.google.firebase.auth.PhoneAuthProvider; + +import org.jetbrains.annotations.NotNull; + +public class OtpVerifyActivity extends AppCompatActivity { + + private ActivityOtpVerifyBinding binding; + private String verificationId; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + binding = ActivityOtpVerifyBinding.inflate(getLayoutInflater()); + setContentView(binding.getRoot()); + + editTextInput(); + FirebaseAuth mAuth = FirebaseAuth.getInstance(); + + binding.tvMobile.setText(String.format( + "+91-%s", getIntent().getStringExtra("phone") + )); + + verificationId = getIntent().getStringExtra("verificationId"); + + binding.tvResendBtn.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Toast.makeText(OtpVerifyActivity.this, "OTP Send Successfully.", Toast.LENGTH_SHORT).show(); + } + }); + + binding.btnVerify.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + binding.progressBarVerify.setVisibility(View.VISIBLE); + binding.btnVerify.setVisibility(View.INVISIBLE); + if (binding.etC1.getText().toString().trim().isEmpty() || + binding.etC2.getText().toString().trim().isEmpty() || + binding.etC3.getText().toString().trim().isEmpty() || + binding.etC4.getText().toString().trim().isEmpty() || + binding.etC5.getText().toString().trim().isEmpty() || + binding.etC6.getText().toString().trim().isEmpty()) { + Toast.makeText(OtpVerifyActivity.this, "OTP is not Valid!", Toast.LENGTH_SHORT).show(); + } else { + if (verificationId != null) { + String code = binding.etC1.getText().toString().trim() + + binding.etC2.getText().toString().trim() + + binding.etC3.getText().toString().trim() + + binding.etC4.getText().toString().trim() + + binding.etC5.getText().toString().trim() + + binding.etC6.getText().toString().trim(); + + PhoneAuthCredential credential = PhoneAuthProvider.getCredential(verificationId, code); + FirebaseAuth + .getInstance() + .signInWithCredential(credential) + .addOnCompleteListener(new OnCompleteListener() { + @Override + public void onComplete(@NonNull @NotNull Task task) { + if (task.isSuccessful()) { + binding.progressBarVerify.setVisibility(View.VISIBLE); + binding.btnVerify.setVisibility(View.INVISIBLE); + Toast.makeText(OtpVerifyActivity.this, "Welcome...", Toast.LENGTH_SHORT).show(); + Intent intent = new Intent(OtpVerifyActivity.this, NameActivity.class); + intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK); + startActivity(intent); + finish(); + } else { + binding.progressBarVerify.setVisibility(View.GONE); + binding.btnVerify.setVisibility(View.VISIBLE); + Toast.makeText(OtpVerifyActivity.this, "OTP is not Valid!", Toast.LENGTH_SHORT).show(); + + } + } + }); + } + } + } + }); + } + + private void editTextInput() { + binding.etC1.addTextChangedListener(new TextWatcher() { + @Override + public void beforeTextChanged(CharSequence s, int start, int count, int after) { + + } + + @Override + public void onTextChanged(CharSequence s, int start, int before, int count) { + binding.etC2.requestFocus(); + } + + @Override + public void afterTextChanged(Editable s) { + + } + }); + binding.etC2.addTextChangedListener(new TextWatcher() { + @Override + public void beforeTextChanged(CharSequence s, int start, int count, int after) { + + } + + @Override + public void onTextChanged(CharSequence s, int start, int before, int count) { + binding.etC3.requestFocus(); + } + + @Override + public void afterTextChanged(Editable s) { + + } + }); + binding.etC3.addTextChangedListener(new TextWatcher() { + @Override + public void beforeTextChanged(CharSequence s, int start, int count, int after) { + + } + + @Override + public void onTextChanged(CharSequence s, int start, int before, int count) { + binding.etC4.requestFocus(); + } + + @Override + public void afterTextChanged(Editable s) { + + } + }); + binding.etC4.addTextChangedListener(new TextWatcher() { + @Override + public void beforeTextChanged(CharSequence s, int start, int count, int after) { + + } + + @Override + public void onTextChanged(CharSequence s, int start, int before, int count) { + binding.etC5.requestFocus(); + } + + @Override + public void afterTextChanged(Editable s) { + + } + }); + binding.etC5.addTextChangedListener(new TextWatcher() { + @Override + public void beforeTextChanged(CharSequence s, int start, int count, int after) { + + } + + @Override + public void onTextChanged(CharSequence s, int start, int before, int count) { + binding.etC6.requestFocus(); + } + + @Override + public void afterTextChanged(Editable s) { + + + } + + }); + } +} \ No newline at end of file diff --git a/electionvote/QueueActivity.java b/electionvote/QueueActivity.java new file mode 100644 index 0000000..821cf35 --- /dev/null +++ b/electionvote/QueueActivity.java @@ -0,0 +1,103 @@ +package com.example.impactmakers.electionvote; + +import android.os.Bundle; +import android.view.View; +import android.widget.AdapterView; +import android.widget.ArrayAdapter; +import android.widget.EditText; +import android.widget.Spinner; +import android.widget.Toast; + +import androidx.appcompat.app.AppCompatActivity; + +public class QueueActivity extends AppCompatActivity implements AdapterView.OnItemSelectedListener { + private Spinner stateSpinner, districtSpinner, constituencySpinner; + private EditText queueEditText; + + private String[] indianStates = {"Select a state", "Andhra Pradesh", "Arunachal Pradesh", "Assam", "Bihar", "Chhattisgarh", "Goa", "Gujarat", "Haryana", "Himachal Pradesh", "Jharkhand", "Karnataka", "Kerala", "Madhya Pradesh", "Maharashtra", "Manipur", "Meghalaya", "Mizoram", "Nagaland", "Odisha", "Punjab", "Rajasthan", "Sikkim", "Tamil Nadu", "Telangana", "Tripura", "Uttar Pradesh", "Uttarakhand", "West Bengal"}; + + private String[] tamilNaduDistricts = {"Select a district", "Chennai", "Coimbatore", "Cuddalore", "Dindigul", "Erode", "Kanchipuram", "Kanyakumari", "Karur", "Krishnagiri", "Madurai", "Nagapattinam", "Namakkal", "Perambalur", "Pudukkottai", "Ramanathapuram", "Salem", "Sivaganga", "Thanjavur", "The Nilgiris", "Theni", "Thiruvallur", "Thiruvarur", "Thoothukkudi", "Tiruchirappalli", "Tirunelveli", "Tirupathur", "Tiruppur", "Tiruvannamalai", "Vellore", "Viluppuram", "Virudhunagar"}; + + private String[] keralaDistricts = {"Select a district", "Alappuzha", "Ernakulam", "Idukki", "Kannur", "Kasaragod", "Kollam", "Kottayam", "Kozhikode", "Malappuram", "Palakkad", "Pathanamthitta", "Thiruvananthapuram", "Thrissur", "Wayanad"}; + + private String[] maduraiConstituents = {"Select a constituent", "Madurai East", "Madurai West"}; + + private String[] dindigulConstituents = {"Select a constituent", "Dindigul"}; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_queue); + + stateSpinner = findViewById(R.id.state_spinner); + districtSpinner = findViewById(R.id.district_spinner); + constituencySpinner = findViewById(R.id.constituency_spinner); + queueEditText = findViewById(R.id.queue_edit_text); + + ArrayAdapter stateAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, indianStates); + stateAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + stateSpinner.setAdapter(stateAdapter); + stateSpinner.setOnItemSelectedListener(this); + + ArrayAdapter districtAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, tamilNaduDistricts); + districtAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + districtSpinner.setAdapter(districtAdapter); + districtSpinner.setOnItemSelectedListener(this); + ArrayAdapter constituencyAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, maduraiConstituents); + constituencyAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + constituencySpinner.setAdapter(constituencyAdapter); + constituencySpinner.setOnItemSelectedListener(this); + } + + @Override + public void onItemSelected(AdapterView parent, View view, int position, long id) { + switch (parent.getId()) { + case R.id.state_spinner: + String selectedState = indianStates[position]; + if (selectedState.equals("Tamil Nadu")) { + ArrayAdapter districtAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, tamilNaduDistricts); + districtAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + districtSpinner.setAdapter(districtAdapter); + } else if (selectedState.equals("Kerala")) { + ArrayAdapter districtAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, keralaDistricts); + districtAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + districtSpinner.setAdapter(districtAdapter); + } else { + districtSpinner.setAdapter(null); + constituencySpinner.setAdapter(null); + } + break; + case R.id.district_spinner: + String selectedDistrict = (String) parent.getItemAtPosition(position); + if (selectedDistrict.equals("Madurai")) { + ArrayAdapter constituencyAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, maduraiConstituents); + constituencyAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + constituencySpinner.setAdapter(constituencyAdapter); + } else if (selectedDistrict.equals("Dindigul")) { + ArrayAdapter constituencyAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, dindigulConstituents); + constituencyAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + constituencySpinner.setAdapter(constituencyAdapter); + } else { + constituencySpinner.setAdapter(null); + } + break; + default: + break; + } + } + + @Override + public void onNothingSelected(AdapterView parent) { + Toast.makeText(this, "Nothing selected", Toast.LENGTH_SHORT).show(); + } + + public void saveQueueStatus(View view) { + String queueStatus = queueEditText.getText().toString().trim(); + if (queueStatus.isEmpty()) { + Toast.makeText(this, "Please enter the queue status", Toast.LENGTH_SHORT).show(); + } else { + // Save the queue status to the database or perform any other action + Toast.makeText(this, "Queue status saved: " + queueStatus, Toast.LENGTH_SHORT).show(); + } + } +} \ No newline at end of file diff --git a/electionvote/RewardActivity.java b/electionvote/RewardActivity.java new file mode 100644 index 0000000..e225d6c --- /dev/null +++ b/electionvote/RewardActivity.java @@ -0,0 +1,109 @@ +package com.example.impactmakers.electionvote; + +import androidx.appcompat.app.AppCompatActivity; + +import android.graphics.Bitmap; +import android.os.Bundle; +import android.view.Gravity; +import android.view.View; +import android.view.ViewGroup; +import android.widget.Button; +import android.widget.ImageView; +import android.widget.PopupWindow; + +import com.google.zxing.BarcodeFormat; +import com.google.zxing.WriterException; +import com.journeyapps.barcodescanner.BarcodeEncoder; + +public class RewardActivity extends AppCompatActivity { + + private Bitmap qrCodeBitmap = null; + private Button Btn1,Btn2,Btn3,Btn4; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_reward2); + + Btn1 = findViewById(R.id.redeem_button_1); + Btn2 = findViewById(R.id.redeem_button_2); + Btn3 = findViewById(R.id.redeem_button_3); + Btn4 = findViewById(R.id.redeem_button_4); + + Btn1.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + // Generate the unique QR code for reward 1 + generateQRCode("Reward 1 QR code data"); + + // Display the QR code in a popup + showQRCodePopup(); + } + }); + + Btn2.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + // Generate the unique QR code for reward 2 + generateQRCode("Reward 2 QR code data"); + + // Display the QR code in a popup + showQRCodePopup(); + } + }); + + Btn3.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + // Generate the unique QR code for reward 1 + generateQRCode("Reward 3 QR code data"); + + // Display the QR code in a popup + showQRCodePopup(); + } + }); + + Btn4.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + // Generate the unique QR code for reward 1 + generateQRCode("Reward 4 QR code data"); + + // Display the QR code in a popup + showQRCodePopup(); + } + }); + } + + private void generateQRCode(String data) { + try { + // Encode the data into a QR code bitmap + BarcodeEncoder barcodeEncoder = new BarcodeEncoder(); + qrCodeBitmap = barcodeEncoder.encodeBitmap(data, BarcodeFormat.QR_CODE, 400, 400); + } catch (WriterException e) { + e.printStackTrace(); + } + } + +// Similarly for the other two redeem buttons + + private void showQRCodePopup() { + // Inflate the layout for the popup + View popupView = getLayoutInflater().inflate(R.layout.qr_code_popup, null); + + // Set the QR code bitmap to the ImageView in the popup + ImageView qrCodeImageView = popupView.findViewById(R.id.qr_code_image); + qrCodeImageView.setImageBitmap(qrCodeBitmap); + + // Create the popup window + PopupWindow popupWindow = new PopupWindow(popupView, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); + popupWindow.setFocusable(true); + popupWindow.setOutsideTouchable(true); + + // Show the popup window at the center of the screen + popupWindow.showAtLocation(getWindow().getDecorView(), Gravity.CENTER, 0, 0); + } + + + +} \ No newline at end of file diff --git a/electionvote/SongActivity.java b/electionvote/SongActivity.java new file mode 100644 index 0000000..789200f --- /dev/null +++ b/electionvote/SongActivity.java @@ -0,0 +1,160 @@ +package com.example.impactmakers.electionvote; + +import android.Manifest; +import android.app.DownloadManager; +import android.content.DialogInterface; +import android.content.Intent; +import android.content.pm.PackageManager; +import android.content.pm.ResolveInfo; +import android.net.Uri; +import android.os.Bundle; +import android.os.Environment; +import android.view.View; +import android.widget.Button; +import android.widget.Toast; + +import androidx.annotation.NonNull; +import androidx.appcompat.app.AlertDialog; +import androidx.appcompat.app.AppCompatActivity; +import androidx.core.app.ActivityCompat; +import androidx.core.content.ContextCompat; +import androidx.core.content.FileProvider; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.List; + +import android.media.AudioManager; +import android.media.MediaPlayer; + + +public class SongActivity extends AppCompatActivity { + + private MediaPlayer mediaPlayer; + private String userName; + private static final int REQUEST_CODE_SHARE = 123; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_song); + + if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) + != PackageManager.PERMISSION_GRANTED) { + + ActivityCompat.requestPermissions(this, + new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, + 1); + } + + // Get the user name passed from MainActivity + Intent intent = getIntent(); + Uri songUri = Uri.parse(intent.getStringExtra("songUri")); + userName = new File(songUri.getPath()).getName().replace(".mp3", ""); + + // Initialize the MediaPlayer with the song file + mediaPlayer = new MediaPlayer(); + mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); + try { + mediaPlayer.setDataSource(getApplicationContext(), songUri); + mediaPlayer.prepare(); + } catch (IOException e) { + e.printStackTrace(); + } + + // Set up the play button + Button buttonPlay = findViewById(R.id.button_play); + buttonPlay.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (mediaPlayer.isPlaying()) { + mediaPlayer.pause(); + } else { + mediaPlayer.start(); + } + } + }); + + Button buttonDownload = findViewById(R.id.button_download); + buttonDownload.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (ContextCompat.checkSelfPermission(SongActivity.this, Manifest.permission.WRITE_EXTERNAL_STORAGE) + != PackageManager.PERMISSION_GRANTED) { + // Permission not granted, request it again + ActivityCompat.requestPermissions(SongActivity.this, + new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, + 1); + } else { + // Permission already granted, proceed with download + String downloadUrl = intent.getStringExtra("songUri"); + DownloadManager.Request request = new DownloadManager.Request(Uri.parse(downloadUrl)); + request.setTitle(userName); + request.setDescription("Downloading " + userName); + request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED); + request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, userName + ".mp3"); + DownloadManager downloadManager = (DownloadManager) getSystemService(DOWNLOAD_SERVICE); + if (downloadManager != null) { + downloadManager.enqueue(request); + Toast.makeText(SongActivity.this, "Downloading...", Toast.LENGTH_SHORT).show(); + } + } + } + }); + + Button buttonShare = findViewById(R.id.button_share); + buttonShare.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + // Share the MP3 file + File mp3File = new File(getExternalFilesDir(Environment.DIRECTORY_MUSIC), userName + ".mp3"); + Intent shareIntent = new Intent(Intent.ACTION_SEND); + shareIntent.setType("audio/mp3"); + Uri mp3Uri = FileProvider.getUriForFile(SongActivity.this, BuildConfig.APPLICATION_ID + ".fileprovider", mp3File); + shareIntent.putExtra(Intent.EXTRA_STREAM, mp3Uri); + shareIntent.putExtra(Intent.EXTRA_TEXT, "Download this Song"); + shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); + startActivityForResult(Intent.createChooser(shareIntent, "Share song via"), REQUEST_CODE_SHARE); + } + }); + } + + @Override + protected void onActivityResult(int requestCode, int resultCode, Intent data) { + super.onActivityResult(requestCode, resultCode, data); + if (requestCode == REQUEST_CODE_SHARE && resultCode == RESULT_OK) { + // Handle the result of the sharing activity + } + } + + @Override + protected void onDestroy() { + super.onDestroy(); + // Release the MediaPlayer before exiting + if (mediaPlayer != null) { + mediaPlayer.release(); + mediaPlayer = null; + } + } + @Override + public void onBackPressed () { + new AlertDialog.Builder(this) + .setTitle("Confirm exit") + .setMessage("Do you really want to exit?") + .setPositiveButton("Yes", new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + // Release the MediaPlayer before exiting + if (mediaPlayer != null) { + mediaPlayer.release(); + mediaPlayer = null; + } + SongActivity.super.onBackPressed(); + } + }) + .setNegativeButton("No", null) + .show(); + } + } \ No newline at end of file diff --git a/electionvote/SongNameActivity.java b/electionvote/SongNameActivity.java new file mode 100644 index 0000000..8fc7130 --- /dev/null +++ b/electionvote/SongNameActivity.java @@ -0,0 +1,71 @@ +package com.example.impactmakers.electionvote; + +import androidx.annotation.NonNull; +import androidx.appcompat.app.AppCompatActivity; + +import android.content.Intent; +import android.net.Uri; +import android.os.Bundle; +import android.view.View; +import android.widget.Button; +import android.widget.EditText; +import android.widget.ProgressBar; +import android.widget.Toast; + +import com.google.android.gms.tasks.OnFailureListener; +import com.google.android.gms.tasks.OnSuccessListener; +import com.google.firebase.FirebaseApp; +import com.google.firebase.storage.FirebaseStorage; +import com.google.firebase.storage.StorageReference; + +public class SongNameActivity extends AppCompatActivity { + private EditText editTextName; + private Button buttonGenerateSong; + private ProgressBar progressBar; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_song_name); + + FirebaseApp.initializeApp(this); + + editTextName = findViewById(R.id.editTextName); + buttonGenerateSong = findViewById(R.id.buttonGenerateSong); + progressBar = findViewById(R.id.progressBar); + + buttonGenerateSong.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + generateSong(); + } + }); + } + + private void generateSong() { + // Show the progress bar + progressBar.setVisibility(View.VISIBLE); + + // Search for the song with the user's name + String fileName = editTextName.getText().toString() + ".mp3"; + StorageReference storageRef = FirebaseStorage.getInstance().getReference().child("songs/" + fileName); + storageRef.getDownloadUrl().addOnSuccessListener(new OnSuccessListener() { + @Override + public void onSuccess(Uri uri) { + // Song found, move to SongActivity + progressBar.setVisibility(View.GONE); + Intent intent = new Intent(SongNameActivity.this, SongActivity.class); + intent.putExtra("songUri", uri.toString()); + startActivity(intent); + } + }).addOnFailureListener(new OnFailureListener() { + @Override + public void onFailure(@NonNull Exception e) { + // Song not found, show a toast message + progressBar.setVisibility(View.GONE); + Toast.makeText(SongNameActivity.this, "We couldn't find your name, try again later.", Toast.LENGTH_SHORT).show(); + } + }); + } + +} \ No newline at end of file diff --git a/electionvote/Splash_Activity.java b/electionvote/Splash_Activity.java new file mode 100644 index 0000000..1a62f25 --- /dev/null +++ b/electionvote/Splash_Activity.java @@ -0,0 +1,28 @@ +package com.example.impactmakers.electionvote; + +import androidx.appcompat.app.AppCompatActivity; +import androidx.constraintlayout.motion.widget.Animatable; + +import android.content.Intent; +import android.os.Bundle; +import android.os.Handler; +import android.widget.ImageView; + +public class Splash_Activity extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_splash); + + new Handler().postDelayed(new Runnable() { + @Override + public void run() { + startActivity(new Intent(Splash_Activity.this,OtpSendActivity.class)); + finish(); + + } + },3000); + } + +} \ No newline at end of file diff --git a/electionvote/TemplateAdapter.java b/electionvote/TemplateAdapter.java new file mode 100644 index 0000000..2319726 --- /dev/null +++ b/electionvote/TemplateAdapter.java @@ -0,0 +1,65 @@ +package com.example.impactmakers.electionvote; + +import android.content.Context; +import android.view.View; +import android.view.ViewGroup; +import android.widget.BaseAdapter; +import android.widget.GridView; +import android.widget.ImageView; + +import java.util.List; + +public class TemplateAdapter extends BaseAdapter { + + private Context mContext; + private List mTemplateIds; + private OnTemplateClickListener mListener; + + public TemplateAdapter(Context context, List templateIds, OnTemplateClickListener listener) { + mContext = context; + mTemplateIds = templateIds; + mListener = listener; + } + + @Override + public int getCount() { + return mTemplateIds.size(); + } + + @Override + public Object getItem(int position) { + return mTemplateIds.get(position); + } + + @Override + public long getItemId(int position) { + return position; + } + + @Override + public View getView(int position, View convertView, ViewGroup parent) { + ImageView imageView; + if (convertView == null) { + // If it's not recycled, initialize some attributes + imageView = new ImageView(mContext); + imageView.setLayoutParams(new GridView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 500)); + imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); + imageView.setPadding(8, 8, 8, 8); + } else { + imageView = (ImageView) convertView; + } + + // Load the template image into the ImageView + int templateId = mTemplateIds.get(position); + imageView.setImageResource(templateId); + + // Set a click listener for the ImageView + imageView.setOnClickListener(v -> mListener.onTemplateClick(templateId)); + + return imageView; + } + + public interface OnTemplateClickListener { + void onTemplateClick(int templateId); + } +} diff --git a/electionvote/TemplateSelectionActivity.java b/electionvote/TemplateSelectionActivity.java new file mode 100644 index 0000000..9fbb12f --- /dev/null +++ b/electionvote/TemplateSelectionActivity.java @@ -0,0 +1,50 @@ +package com.example.impactmakers.electionvote; + +import androidx.appcompat.app.AppCompatActivity; + +import android.content.Intent; +import android.os.Bundle; +import android.widget.GridView; + +import java.util.ArrayList; +import java.util.List; + +public class TemplateSelectionActivity extends AppCompatActivity implements TemplateAdapter.OnTemplateClickListener { + + private GridView mGridView; + private TemplateAdapter mAdapter; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_templateselection); + + + + // Create a list of template IDs + List templateIds = new ArrayList<>(); + templateIds.add(R.drawable.template1); + templateIds.add(R.drawable.template2); + templateIds.add(R.drawable.template3); + templateIds.add(R.drawable.template4); + templateIds.add(R.drawable.template1); + templateIds.add(R.drawable.template2); + templateIds.add(R.drawable.template3); + templateIds.add(R.drawable.template4); + + // Create the adapter and set it to the GridView + mAdapter = new TemplateAdapter(this, templateIds, this); + mGridView = findViewById(R.id.grid_view_templates); + mGridView.setAdapter(mAdapter); + } + + @Override + public void onTemplateClick(int templateId) { + String imageUrl = "https://example.com/image.jpg"; + Intent intent = new Intent(this, CustomizationActivity.class); + intent.putExtra("template_id", templateId); + intent.putExtra("imageUri", imageUrl); + startActivity(intent); + } + +} diff --git a/electionvote/VideoActivity.java b/electionvote/VideoActivity.java new file mode 100644 index 0000000..d1cee5a --- /dev/null +++ b/electionvote/VideoActivity.java @@ -0,0 +1,49 @@ +package com.example.impactmakers.electionvote; + +import androidx.appcompat.app.AppCompatActivity; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import android.os.Bundle; + +import java.util.ArrayList; +import java.util.List; + +public class VideoActivity extends AppCompatActivity { + + private RecyclerView recyclerView; + private YouTubeAdapter adapter; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_video); + + recyclerView = findViewById(R.id.recycler_view); + adapter = new YouTubeAdapter(); + + // Set layout manager for the RecyclerView + LinearLayoutManager layoutManager = new LinearLayoutManager(this); + recyclerView.setLayoutManager(layoutManager); + + // Set adapter for the RecyclerView + recyclerView.setAdapter(adapter); + + // Load YouTube video data and set it to the adapter + List videos = loadYouTubeData(); + adapter.setVideos(videos); + } + + private List loadYouTubeData() { + List videos = new ArrayList<>(); + + // Add sample YouTube videos + videos.add(new YouTubeVideo("HW9hEzIF9DM", "Vote Awarenes", "https://img.youtube.com/vi/HW9hEzIF9DM/0.jpg")); + videos.add(new YouTubeVideo("Pwmv7vAFv4g", "Voter Awareness - Motivational Song", "https://img.youtube.com/vi/Pwmv7vAFv4g/0.jpg")); + videos.add(new YouTubeVideo("8c2YEQw9acs", "Video Msg on Voter Awareness", "https://img.youtube.com/vi/8c2YEQw9acs/0.jpg")); + videos.add(new YouTubeVideo("NbH11R3f910", "Election awareness Short Film", "https://img.youtube.com/vi/NbH11R3f910/0.jpg")); + videos.add(new YouTubeVideo("iqp3iIxHWNE", "Election Awareness Video", "https://img.youtube.com/vi/iqp3iIxHWNE/0.jpg")); + + return videos; + } +} \ No newline at end of file diff --git a/electionvote/YouTubeAdapter.java b/electionvote/YouTubeAdapter.java new file mode 100644 index 0000000..3100ab8 --- /dev/null +++ b/electionvote/YouTubeAdapter.java @@ -0,0 +1,74 @@ +package com.example.impactmakers.electionvote; + +import android.content.Intent; +import android.net.Uri; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + + +import com.squareup.picasso.Picasso; + +import java.util.List; + +public class YouTubeAdapter extends RecyclerView.Adapter { + + private List videos; + + public void setVideos(List videos) { + this.videos = videos; + notifyDataSetChanged(); + } + + @NonNull + @Override + public VideoViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_youtube_video, parent, false); + return new VideoViewHolder(view); + } + + @Override + public void onBindViewHolder(@NonNull VideoViewHolder holder, int position) { + YouTubeVideo video = videos.get(position); + holder.bind(video); + } + + @Override + public int getItemCount() { + return videos != null ? videos.size() : 0; + } + + static class VideoViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { + + private final ImageView thumbnail; + private final TextView title; + private String videoId; + + public VideoViewHolder(@NonNull View itemView) { + super(itemView); + thumbnail = itemView.findViewById(R.id.thumbnail_image_view); + title = itemView.findViewById(R.id.title_text_view); + itemView.setOnClickListener(this); + } + + public void bind(YouTubeVideo video) { + videoId = video.getVideoId(); + String thumbnailUrl = video.getThumbnailUrl(); + String titleText = video.getTitle(); + Picasso.get().load(thumbnailUrl).into(thumbnail); + title.setText(titleText); + } + + @Override + public void onClick(View v) { + // Play the video in the YouTube app or website + Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.youtube.com/watch?v=" + videoId)); + v.getContext().startActivity(intent); + } + } +} \ No newline at end of file diff --git a/electionvote/YouTubeVideo.java b/electionvote/YouTubeVideo.java new file mode 100644 index 0000000..65f2fae --- /dev/null +++ b/electionvote/YouTubeVideo.java @@ -0,0 +1,25 @@ +package com.example.impactmakers.electionvote; + +public class YouTubeVideo { + private String videoId; + private String title; + private String thumbnailUrl; + + public YouTubeVideo(String videoId, String title, String thumbnailUrl) { + this.videoId = videoId; + this.title = title; + this.thumbnailUrl = thumbnailUrl; + } + + public String getVideoId() { + return videoId; + } + + public String getTitle() { + return title; + } + + public String getThumbnailUrl() { + return thumbnailUrl; + } +} diff --git a/electionvote/profile_activity.java b/electionvote/profile_activity.java new file mode 100644 index 0000000..03fb52f --- /dev/null +++ b/electionvote/profile_activity.java @@ -0,0 +1,43 @@ +package com.example.impactmakers.electionvote; + +import androidx.appcompat.app.AppCompatActivity; + +import android.content.Intent; +import android.os.Bundle; + +import com.google.android.material.bottomnavigation.BottomNavigationView; + +public class profile_activity extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_profile); + + BottomNavigationView bottomNavigationView = findViewById(R.id.bottomNavigation); + bottomNavigationView.setSelectedItemId(R.id.bottom_settings); + + bottomNavigationView.setOnItemSelectedListener(item -> { + switch (item.getItemId()) { + case R.id.bottom_home: + startActivity(new Intent(getApplicationContext(),MainActivity.class)); + overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left); + finish(); + return true; + case R.id.bottom_search: + startActivity(new Intent(getApplicationContext(), vote_activity.class)); + overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left); + finish(); + return true; + case R.id.bottom_settings: + return true; + case R.id.bottom_profile: + startActivity(new Intent(getApplicationContext(), profile_activity.class)); + overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left); + finish(); + return true; + } + return false; + }); + } +} \ No newline at end of file diff --git a/electionvote/reward_activity.java b/electionvote/reward_activity.java new file mode 100644 index 0000000..7f59e11 --- /dev/null +++ b/electionvote/reward_activity.java @@ -0,0 +1,68 @@ +package com.example.impactmakers.electionvote; + +import androidx.appcompat.app.AppCompatActivity; +import androidx.cardview.widget.CardView; + +import android.content.Intent; +import android.os.Bundle; +import android.view.View; + +import com.google.android.material.bottomnavigation.BottomNavigationView; + +public class reward_activity extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_reward); + + BottomNavigationView bottomNavigationView = findViewById(R.id.bottomNavigation); + bottomNavigationView.setSelectedItemId(R.id.bottom_search); + + CardView cardview4 = findViewById(R.id.cardview4); + + cardview4.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Intent intent = new Intent(reward_activity.this, VideoActivity.class); + startActivity(intent); + } + }); + + CardView cardview5 = findViewById(R.id.cardview5); + + cardview5.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Intent intent = new Intent(reward_activity.this, MainActivity.class); + startActivity(intent); + } + }); + + + bottomNavigationView.setOnItemSelectedListener(item -> { + switch (item.getItemId()) { + case R.id.bottom_home: + startActivity(new Intent(getApplicationContext(),MainActivity.class)); + overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left); + finish(); + return true; + case R.id.bottom_search: + return true; + case R.id.bottom_settings: + startActivity(new Intent(getApplicationContext(), vote_activity.class)); + overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left); + finish(); + return true; + case R.id.bottom_profile: + startActivity(new Intent(getApplicationContext(), profile_activity.class)); + overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left); + finish(); + return true; + } + return false; + }); + } + + +} \ No newline at end of file diff --git a/electionvote/vote_activity.java b/electionvote/vote_activity.java new file mode 100644 index 0000000..75536b0 --- /dev/null +++ b/electionvote/vote_activity.java @@ -0,0 +1,78 @@ +package com.example.impactmakers.electionvote; + +import androidx.appcompat.app.AppCompatActivity; +import androidx.cardview.widget.CardView; + +import android.content.Intent; +import android.os.Bundle; +import android.view.View; +import android.widget.Button; + +import com.google.android.material.bottomnavigation.BottomNavigationView; + +public class vote_activity extends AppCompatActivity { + + Button songBtn; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_vote); + + BottomNavigationView bottomNavigationView = findViewById(R.id.bottomNavigation); + bottomNavigationView.setSelectedItemId(R.id.bottom_search); + + CardView cardview1 = findViewById(R.id.cardview1); + + cardview1.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Intent intent = new Intent(vote_activity.this, SongNameActivity.class); + startActivity(intent); + } + }); + + CardView cardview2 = findViewById(R.id.cardview2); + + cardview2.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Intent intent = new Intent(vote_activity.this, TemplateSelectionActivity.class); + startActivity(intent); + } + }); + + CardView cardview3 = findViewById(R.id.cardview3); + + cardview3.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Intent intent = new Intent(vote_activity.this, QueueActivity.class); + startActivity(intent); + } + }); + + bottomNavigationView.setOnItemSelectedListener(item -> { + switch (item.getItemId()) { + case R.id.bottom_home: + startActivity(new Intent(getApplicationContext(),MainActivity.class)); + overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left); + finish(); + return true; + case R.id.bottom_search: + return true; + case R.id.bottom_settings: + startActivity(new Intent(getApplicationContext(), reward_activity.class)); + overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left); + finish(); + return true; + case R.id.bottom_profile: + startActivity(new Intent(getApplicationContext(), profile_activity.class)); + overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left); + finish(); + return true; + } + return false; + }); + } +} \ No newline at end of file diff --git a/layout/activity_adaptor.xml b/layout/activity_adaptor.xml new file mode 100644 index 0000000..0326344 --- /dev/null +++ b/layout/activity_adaptor.xml @@ -0,0 +1,12 @@ + + + + + diff --git a/layout/activity_customize.xml b/layout/activity_customize.xml new file mode 100644 index 0000000..8a0822f --- /dev/null +++ b/layout/activity_customize.xml @@ -0,0 +1,96 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/layout/activity_main.xml b/layout/activity_main.xml new file mode 100644 index 0000000..87e630b --- /dev/null +++ b/layout/activity_main.xml @@ -0,0 +1,125 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/layout/activity_name.xml b/layout/activity_name.xml new file mode 100644 index 0000000..1b8e937 --- /dev/null +++ b/layout/activity_name.xml @@ -0,0 +1,58 @@ + + + + + + + + + \ No newline at end of file diff --git a/layout/activity_otp_send.xml b/layout/activity_otp_send.xml new file mode 100644 index 0000000..19df69b --- /dev/null +++ b/layout/activity_otp_send.xml @@ -0,0 +1,118 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/layout/activity_otp_verify.xml b/layout/activity_otp_verify.xml new file mode 100644 index 0000000..fa7fce9 --- /dev/null +++ b/layout/activity_otp_verify.xml @@ -0,0 +1,228 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/layout/activity_poster.xml b/layout/activity_poster.xml new file mode 100644 index 0000000..37e687a --- /dev/null +++ b/layout/activity_poster.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/layout/activity_profile.xml b/layout/activity_profile.xml new file mode 100644 index 0000000..f9cb4d9 --- /dev/null +++ b/layout/activity_profile.xml @@ -0,0 +1,35 @@ + + + + + + + + \ No newline at end of file diff --git a/layout/activity_queue.xml b/layout/activity_queue.xml new file mode 100644 index 0000000..ecc0d7f --- /dev/null +++ b/layout/activity_queue.xml @@ -0,0 +1,96 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/layout/activity_reward.xml b/layout/activity_reward.xml new file mode 100644 index 0000000..1222f65 --- /dev/null +++ b/layout/activity_reward.xml @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/layout/activity_reward2.xml b/layout/activity_reward2.xml new file mode 100644 index 0000000..9cb8ca2 --- /dev/null +++ b/layout/activity_reward2.xml @@ -0,0 +1,289 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/layout/activity_song.xml b/layout/activity_song.xml new file mode 100644 index 0000000..d455744 --- /dev/null +++ b/layout/activity_song.xml @@ -0,0 +1,73 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/layout/activity_song_name.xml b/layout/activity_song_name.xml new file mode 100644 index 0000000..c8bfcf9 --- /dev/null +++ b/layout/activity_song_name.xml @@ -0,0 +1,50 @@ + + + + + + + + + + \ No newline at end of file diff --git a/layout/activity_splash.xml b/layout/activity_splash.xml new file mode 100644 index 0000000..b963903 --- /dev/null +++ b/layout/activity_splash.xml @@ -0,0 +1,21 @@ + + + + + \ No newline at end of file diff --git a/layout/activity_templateselection.xml b/layout/activity_templateselection.xml new file mode 100644 index 0000000..53216b6 --- /dev/null +++ b/layout/activity_templateselection.xml @@ -0,0 +1,14 @@ + + + + + diff --git a/layout/activity_video.xml b/layout/activity_video.xml new file mode 100644 index 0000000..3d180a0 --- /dev/null +++ b/layout/activity_video.xml @@ -0,0 +1,16 @@ + + + + + + \ No newline at end of file diff --git a/layout/activity_vote.xml b/layout/activity_vote.xml new file mode 100644 index 0000000..afc12db --- /dev/null +++ b/layout/activity_vote.xml @@ -0,0 +1,90 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/layout/item_youtube_video.xml b/layout/item_youtube_video.xml new file mode 100644 index 0000000..c93f3f1 --- /dev/null +++ b/layout/item_youtube_video.xml @@ -0,0 +1,34 @@ + + + + + + + + + + \ No newline at end of file diff --git a/layout/qr_code_popup.xml b/layout/qr_code_popup.xml new file mode 100644 index 0000000..43f577f --- /dev/null +++ b/layout/qr_code_popup.xml @@ -0,0 +1,23 @@ + + + + + + + + +