Skip to content

Commit 6def741

Browse files
committed
AC-770 Migrating ContactUS package to Kotlin
1 parent f224277 commit 6def741

4 files changed

Lines changed: 94 additions & 111 deletions

File tree

openmrs-client/src/main/java/org/openmrs/mobile/activities/community/contact/ContactUsActivity.java

Lines changed: 0 additions & 93 deletions
This file was deleted.
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
/*
2+
* The contents of this file are subject to the OpenMRS Public License
3+
* Version 1.0 (the "License"); you may not use this file except in
4+
* compliance with the License. You may obtain a copy of the License at
5+
* http://license.openmrs.org
6+
*
7+
* Software distributed under the License is distributed on an "AS IS"
8+
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
9+
* License for the specific language governing rights and limitations
10+
* under the License.
11+
*
12+
* Copyright (C) OpenMRS, LLC. All Rights Reserved.
13+
*/
14+
package org.openmrs.mobile.activities.community.contact
15+
16+
import android.content.ActivityNotFoundException
17+
import android.content.Intent
18+
import android.net.Uri
19+
import android.os.Bundle
20+
import android.view.Menu
21+
import android.view.MenuItem
22+
import org.openmrs.mobile.R
23+
import org.openmrs.mobile.activities.ACBaseActivity
24+
import org.openmrs.mobile.databinding.ActvityContactUsBinding
25+
import org.openmrs.mobile.utilities.ToastUtil
26+
27+
class ContactUsActivity : ACBaseActivity(), ContactUsContract.View {
28+
29+
var presenter: ContactUsContract.Presenter? = null
30+
private lateinit var binding: ActvityContactUsBinding
31+
32+
override fun onCreate(savedInstanceState: Bundle?) {
33+
super.onCreate(savedInstanceState)
34+
binding = ActvityContactUsBinding.inflate(layoutInflater)
35+
setContentView(binding.root)
36+
presenter = ContactUsPresenter()
37+
38+
val actionBar = supportActionBar
39+
if (actionBar != null) {
40+
actionBar.elevation = 0f
41+
actionBar.setDisplayHomeAsUpEnabled(true)
42+
}
43+
44+
binding.contactEmailButton.setOnClickListener {
45+
val sendMailIntent = Intent(Intent.ACTION_SENDTO)
46+
val mailTo = "mailto:" + binding.contactEmailText.text.toString()
47+
sendMailIntent.data = Uri.parse(mailTo)
48+
try {
49+
startActivity(sendMailIntent)
50+
} catch (ex: ActivityNotFoundException) {
51+
ToastUtil.showShortToast(this, ToastUtil.ToastType.ERROR, getString(R.string.no_mailing_client_found))
52+
}
53+
}
54+
55+
binding.talksButton.setOnClickListener {
56+
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.contact_forum_url)))
57+
startActivity(intent)
58+
}
59+
60+
binding.ircButton.setOnClickListener {
61+
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.contact_irc_url)))
62+
startActivity(intent)
63+
}
64+
}
65+
66+
override fun onCreateOptionsMenu(menu: Menu): Boolean {
67+
super.onCreateOptionsMenu(menu)
68+
//Disable Contact Option in Menu
69+
val contactItem = menu.findItem(R.id.actionContact)
70+
contactItem.isVisible = false
71+
val logOutItem = menu.findItem(R.id.actionLogout)
72+
logOutItem.isVisible = false
73+
val locationItem = menu.findItem(R.id.actionLocation)
74+
locationItem.isVisible = false
75+
val settingItem = menu.findItem(R.id.actionSettings)
76+
settingItem.isVisible = false
77+
return true
78+
}
79+
80+
override fun onOptionsItemSelected(item: MenuItem): Boolean {
81+
if (item.itemId == android.R.id.home) {
82+
finish()
83+
return true
84+
}
85+
return super.onOptionsItemSelected(item)
86+
}
87+
}

openmrs-client/src/main/java/org/openmrs/mobile/activities/community/contact/ContactUsContract.java renamed to openmrs-client/src/main/java/org/openmrs/mobile/activities/community/contact/ContactUsContract.kt

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,9 @@
1212
* Copyright (C) OpenMRS, LLC. All Rights Reserved.
1313
*/
1414

15-
package org.openmrs.mobile.activities.community.contact;
15+
package org.openmrs.mobile.activities.community.contact
1616

17-
public class ContactUsContract {
18-
interface View {
19-
20-
}
21-
22-
interface Presenter {
23-
24-
}
25-
}
17+
class ContactUsContract {
18+
interface View
19+
interface Presenter
20+
}

openmrs-client/src/main/java/org/openmrs/mobile/activities/community/contact/ContactUsPresenter.java renamed to openmrs-client/src/main/java/org/openmrs/mobile/activities/community/contact/ContactUsPresenter.kt

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,6 @@
1212
* Copyright (C) OpenMRS, LLC. All Rights Reserved.
1313
*/
1414

15-
package org.openmrs.mobile.activities.community.contact;
15+
package org.openmrs.mobile.activities.community.contact
1616

17-
public class ContactUsPresenter implements ContactUsContract.Presenter {
18-
ContactUsContract.View contactUsView;
19-
20-
public ContactUsPresenter(ContactUsContract.View contactUsView) {
21-
this.contactUsView = contactUsView;
22-
}
23-
}
17+
class ContactUsPresenter : ContactUsContract.Presenter

0 commit comments

Comments
 (0)