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+ }
0 commit comments