Commit 7b13ec35 authored by Ricki Hirner's avatar Ricki Hirner 🐑

Show "Calendar permissions required" message, use TextInputLayout

parent 1f486a60
......@@ -11,9 +11,11 @@ package at.bitfire.icsdroid.ui
import android.Manifest
import android.content.pm.PackageManager
import android.os.Bundle
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import androidx.core.app.ActivityCompat
import androidx.lifecycle.ViewModelProviders
import at.bitfire.icsdroid.R
import at.bitfire.icsdroid.db.LocalCalendar
class AddCalendarActivity: AppCompatActivity() {
......@@ -63,8 +65,10 @@ class AddCalendarActivity: AppCompatActivity() {
if (grantResults[idx] != PackageManager.PERMISSION_GRANTED)
when (perm) {
Manifest.permission.READ_CALENDAR,
Manifest.permission.WRITE_CALENDAR ->
Manifest.permission.WRITE_CALENDAR -> {
Toast.makeText(this, R.string.calendar_permissions_required, Toast.LENGTH_LONG).show()
finish()
}
}
}
}
......
......@@ -25,6 +25,7 @@ import android.util.Log
import android.view.*
import android.widget.AdapterView
import android.widget.ArrayAdapter
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import androidx.core.app.ActivityCompat
import androidx.fragment.app.Fragment
......@@ -100,8 +101,10 @@ class CalendarListActivity:
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<out String>, grantResults: IntArray) {
if (grantResults.all { it == PackageManager.PERMISSION_GRANTED })
getModel()
else
else {
Toast.makeText(this, R.string.calendar_permissions_required, Toast.LENGTH_LONG).show()
finish()
}
}
override fun onCreateOptionsMenu(menu: Menu): Boolean {
......
......@@ -84,8 +84,10 @@ class EditCalendarActivity: AppCompatActivity() {
// permissions OK, load calendar from provider
val uri = intent.data ?: throw IllegalArgumentException("Intent data must be calendar URI")
model.loadCalendar(uri)
} else
} else {
Toast.makeText(this, R.string.calendar_permissions_required, Toast.LENGTH_LONG).show()
finish()
}
}
}
......
......@@ -21,14 +21,18 @@
android:layout_height="wrap_content"
android:orientation="vertical">
<EditText
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/url"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/add_calendar_url"
android:inputType="textUri"
android:singleLine="true"
android:text="@={model.url}"/>
android:layout_height="wrap_content">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/add_calendar_url"
android:inputType="textUri"
android:singleLine="true"
android:text="@={model.url}"/>
</com.google.android.material.textfield.TextInputLayout>
<TextView
android:id="@+id/insecure_authentication_warning"
......
......@@ -46,6 +46,7 @@
app:layout_anchor="@id/calendar_list"
app:layout_anchorGravity="bottom|right|end"
android:onClick="onAddCalendar"
android:tooltipText="@string/activity_add_calendar"
app:elevation="5dp"
app:borderWidth="0dp"/>
......
......@@ -32,13 +32,17 @@
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textNoSuggestions"
android:hint="@string/add_calendar_user_name"
android:singleLine="true"
android:text="@={model.username}"/>
android:layout_height="wrap_content">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textNoSuggestions"
android:hint="@string/add_calendar_user_name"
android:singleLine="true"
android:text="@={model.username}"/>
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/password"
......
......@@ -15,8 +15,11 @@
<!-- common strings -->
<string name="action_next">Next</string>
<string name="calendar_permissions_required">Calendar permissions required</string>
<string name="notification_channel_sync_problem">Sync problems</string>
<!-- CalendarListActivity -->
<string name="title_activity_calendar_list">My subscriptions</string>
<string name="calendar_list_empty_info">To subscribe to a Webcal feed, use the + button or open a Webcal URL.</string>
<string name="calendar_list_info">About ICSx⁵</string>
<string name="calendar_list_not_synced_yet">not synchronized yet</string>
......@@ -28,8 +31,7 @@
<string name="calendar_list_battery_whitelist">Battery: Whitelist ICSx⁵ for short sync intervals</string>
<string name="calendar_list_battery_whitelist_settings">Settings</string>
<string name="title_activity_calendar_list">My subscriptions</string>
<!-- AddCalendarActivity -->
<string name="activity_add_calendar">Subscribe to calendar</string>
<string name="add_calendar_need_valid_uri">Valid URI required</string>
<string name="add_calendar_authentication_without_https_warning">Third parties can easily intercept your credentials. Use HTTPS for secure authentication.</string>
......@@ -43,6 +45,7 @@
<string name="add_calendar_user_name">User name</string>
<string name="add_calendar_validating">Validating calendar resource…</string>
<!-- EditCalendarActivity -->
<string name="activity_edit_calendar">Edit subscription</string>
<string name="edit_calendar_cancel">Cancel</string>
<string name="edit_calendar_delete">Unsubscribe</string>
......@@ -56,6 +59,7 @@
<string name="edit_calendar_sync_this_calendar">Synchronize this calendar</string>
<string name="edit_calendar_unsaved_changes">There are unsaved changes.</string>
<!-- synchronization -->
<string name="sync_error_title">Synchronization error</string>
<string name="set_sync_interval_save">Save</string>
<string name="set_sync_interval_title">Set sync. interval:</string>
......@@ -77,7 +81,11 @@
<item>Once a day</item>
<item>Once a week</item>
</string-array>
<string name="sync_permission_required">Permission required</string>
<string name="sync_permission_required_sync_calendar">Needing permission to sync your calendar</string>
<string name="permission_required_external_storage">Storage permission is required to access local iCalendar files</string>
<!-- InfoActivity -->
<string name="activity_app_info">App info</string>
<string name="app_info_version">Version %1$s-%2$s</string>
<string name="app_info_gplv3" translatable="false">GPLv3</string>
......@@ -106,9 +114,4 @@ along with this program. If not, see <a href="https://www.gnu.org/licenses/">ht
<string name="donate_now">Show donation page</string>
<string name="donate_later">Maybe later</string>
<string name="sync_permission_required">Permission required</string>
<string name="sync_permission_required_sync_calendar">Needing permission to sync your calendar</string>
<string name="permission_required_external_storage">Storage permission is required to access local iCalendar files</string>
</resources>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment