Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert Most Class java to Kotlin #51

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package com.college.collegeconnect.activities

import android.content.Intent
import android.content.pm.ResolveInfo
import android.os.Bundle
import android.widget.CompoundButton
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import com.college.collegeconnect.databinding.ActivityContributeBinding

class ContributeActivity : AppCompatActivity() {

private lateinit var binding: ActivityContributeBinding

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityContributeBinding.inflate(layoutInflater)

setContentView(binding.root)

binding.develoeprCheck.setOnCheckedChangeListener(CompoundButton.OnCheckedChangeListener { buttonView, isChecked -> if (isChecked) binding.nondeveloperCheck.setEnabled(false) else binding.nondeveloperCheck.setEnabled(true) })
binding.nondeveloperCheck.setOnCheckedChangeListener(CompoundButton.OnCheckedChangeListener { buttonView, isChecked -> if (isChecked) binding.develoeprCheck.setEnabled(false) else binding.develoeprCheck.setEnabled(true) })

// Send email to developers
binding.submitContri.setOnClickListener {
if (binding.collegeContri.getEditText()!!.text.toString() == null || binding.courseContri.getEditText()!!.text.toString() == null || binding.mobileContri.getEditText()!!.text.toString() == null) Toast.makeText(this@ContributeActivity, "Please ensure all the fields are not empty.", Toast.LENGTH_SHORT).show() else {
val intent = intent
val name = intent.getStringExtra("Name")
val dev_status: String
dev_status = if (binding.develoeprCheck.isChecked) "Yes" else "No"

// Forming email body
val mesaage = """
My name is $name

Am I a developer?: $dev_status

College Name: ${binding.collegeContri.getEditText()!!.text}

Course: ${binding.courseContri.getEditText()!!.text}

Contact
Mobile Number: ${binding.mobileContri.getEditText()!!.text}

Type below this line for any extra message
---------------------

""".trimIndent()
val intent_email = Intent(Intent.ACTION_SEND)
intent_email.type = "text/plain"
val recipients = arrayOf("[email protected]")
intent_email.putExtra(Intent.EXTRA_EMAIL, recipients)
intent_email.putExtra(Intent.EXTRA_TEXT, mesaage)
val pm = packageManager
val matches = pm.queryIntentActivities(intent_email, 0)
var best: ResolveInfo? = null
for (info in matches) if (info.activityInfo.packageName.endsWith(".gm") ||
info.activityInfo.name.toLowerCase().contains("gmail")
) best = info
if (best != null) intent_email.setClassName(best.activityInfo.packageName, best.activityInfo.name)
startActivity(intent_email)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package com.college.collegeconnect.activities

import android.content.ActivityNotFoundException
import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.view.MenuItem
import androidx.appcompat.app.AlertDialog
Expand All @@ -22,15 +19,14 @@ import com.hsalf.smileyrating.SmileyRating
import kotlinx.android.synthetic.main.activity_feedback.*
import kotlinx.android.synthetic.main.toolbar_main.*


class FeedbackActivity : AppCompatActivity() {

private lateinit var mood: String
lateinit var databaseReference: DatabaseReference
lateinit var firebaseAuth: FirebaseAuth
lateinit var alertDialog: AlertDialog.Builder
var email: String = ""
private lateinit var manager:ReviewManager
private lateinit var manager: ReviewManager
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_feedback)
Expand All @@ -47,7 +43,7 @@ class FeedbackActivity : AppCompatActivity() {
manager = ReviewManagerFactory.create(this)
alertDialog = MaterialAlertDialogBuilder(this)
alertDialog.setTitle("Thank you")
.setMessage("Rate us on Playstore?")
.setMessage("Rate us on Playstore?")

// alertDialog.setPositiveButton("Sure") { _, _ ->
// val uri = Uri.parse("market://details?id=" + this.packageName)
Expand Down Expand Up @@ -75,27 +71,26 @@ class FeedbackActivity : AppCompatActivity() {
val reviewInfo = request.result
val flow = manager.launchReviewFlow(this, reviewInfo)
flow.addOnCompleteListener {
SaveSharedPreference.setRev(this,true)
SaveSharedPreference.setRev(this, true)
}
} else {
// There was some problem, continue regardless of the result.
dialog.dismiss()
finish()
Navigation.act.finish()
Navigation.act?.finish()
}
}
}.setNegativeButton("Later") { dialog, _ ->
dialog.dismiss()
finish()
Navigation.act.finish()
Navigation.act?.finish()
}

ansProblem.editText?.doAfterTextChanged { ansProblem.error = null }
ansFeature.editText?.doAfterTextChanged { ansFeature.error = null }
ansNoFeature.editText?.doAfterTextChanged { ansNoFeature.error = null }
ansFeature.editText?.doAfterTextChanged { ansFeature.error = null }


smileyRating.setRating(SmileyRating.Type.GREAT, true)
solveAns.setIndicatorTextFormat("\${TICK_TEXT}")
indicatorSeekBar.setIndicatorTextFormat("\${TICK_TEXT}")
Expand Down Expand Up @@ -131,16 +126,18 @@ class FeedbackActivity : AppCompatActivity() {
}

private fun submit() {
val feedback = Feedback(email,
mood,
ansProblem.editText?.text.toString(),
solveAns.progress,
ansNoFeature.editText?.text.toString(),
indicatorSeekBar.progress,
ansConfused.editText?.text.toString(),
ansFeature.editText?.text.toString())
val feedback = Feedback(
email,
mood,
ansProblem.editText?.text.toString(),
solveAns.progress,
ansNoFeature.editText?.text.toString(),
indicatorSeekBar.progress,
ansConfused.editText?.text.toString(),
ansFeature.editText?.text.toString()
)
databaseReference.setValue(feedback)
if(!SaveSharedPreference.getReview(this)) {
if (!SaveSharedPreference.getReview(this)) {
val dialog = alertDialog.create()
dialog.show()
}
Expand All @@ -154,4 +151,4 @@ class FeedbackActivity : AppCompatActivity() {
}
return super.onOptionsItemSelected(item)
}
}
}
Loading