Skip to content

Commit

Permalink
Implement single request approval dialog for app access to Contacts a…
Browse files Browse the repository at this point in the history
…nd Phone calls (#27)

* 3-22-2020 edits (mostly accessibility issues)
1. fragment_communities_browse.xml
- created horizontal/vertical constraints for recyclerview
- added content description for FAB (Create New Community), for screen-reader accessibility
2. fragment_select_contacts_from...
- FAB focusable true
- added content descriptions
- added fab margin to FAB for consistency
3. fragment_show_community.xml
- added constraints to contacts_list
4. fragment_show_contact.xml
- changed TextView to more descriptive default text
5. SelectContactsFromPhonebookFragment...
- edited requestPermission to include both Contacts and Phone Calls
- checks for both permissions in one dialog

* Implemented dialog requesting both Contacts and Phone Calls at once

* Implemented dialog requesting both Contacts and Phone Calls at once, included some accessibility fixes
  • Loading branch information
JetPlaneJJ authored Mar 23, 2020
1 parent 3488abe commit 9f211b5
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,11 @@ public void onClick(View v) {
setHasOptionsMenu(true);
mDataStorage = new ViewModelProvider(requireActivity()).get(DataStorage.class);

// asks for both access to Contacts and Phone calls in single dialog
if (ActivityCompat.checkSelfPermission(getActivity(), android.Manifest.permission.READ_CONTACTS)
!= PackageManager.PERMISSION_GRANTED) {
!= PackageManager.PERMISSION_GRANTED ||
ActivityCompat.checkSelfPermission(getActivity(),
android.Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) {
requestPermission(getActivity());
} else {
startReadContacts();
Expand Down Expand Up @@ -115,7 +118,8 @@ private void requestPermission(Activity activity) {
if (shouldShowRequestPermissionRationale(android.Manifest.permission.READ_CONTACTS)) {
// show UI part if you want here to show some rationale !!!
} else {
requestPermissions(new String[]{android.Manifest.permission.READ_CONTACTS},
requestPermissions(new String[]{android.Manifest.permission.READ_CONTACTS,
android.Manifest.permission.CALL_PHONE},
REQUEST_READ_CONTACTS);
}
}
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/res/layout/fragment_communities_browse.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
android:id="@+id/recycler_view"
android:layout_width="409dp"
android:layout_height="729dp"
tools:layout_editor_absoluteX="1dp"
tools:layout_editor_absoluteY="1dp" />
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab"
android:contentDescription="@string/add_community"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
android:id="@+id/action_next"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/fab_margin"
android:clickable="true"
android:focusable="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:srcCompat="@android:drawable/ic_media_next" />
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/res/layout/fragment_show_community.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
Expand All @@ -8,6 +9,6 @@
android:id="@+id/contacts_list"
android:layout_width="409dp"
android:layout_height="729dp"
tools:layout_editor_absoluteX="1dp"
tools:layout_editor_absoluteY="1dp" />
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
9 changes: 5 additions & 4 deletions app/src/main/res/layout/fragment_show_contact.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
android:layout_width="0dp"
android:layout_height="192dp"
android:adjustViewBounds="true"
android:contentDescription="@string/contact_picture"
android:scaleType="centerCrop"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
Expand All @@ -43,9 +44,9 @@
android:layout_height="wrap_content"
android:layout_marginStart="120dp"
android:layout_marginEnd="16dp"
android:text="TextView"
app:layout_constraintStart_toStartOf="parent"
android:text="@string/enter_name"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@id/label_name" />

<TextView
Expand All @@ -62,9 +63,9 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:text="TextView"
app:layout_constraintStart_toStartOf="@id/field_name"
android:text="@string/enter_community_name"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="@id/field_name"
app:layout_constraintTop_toTopOf="@id/label_community" />

<!-- Actions -->
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@
<string name="label_community_description">Description</string>
<string name="hint_community_description">A brief text describing the group</string>
<string name="command_menu_community_addconfirm">Create</string>
<string name="add_community">Create New Community</string>
<string name="label_select_contacts">Select contacts</string>
<string name="contact_picture">Contact Picture</string>
<string name="label_contact_name">Name:</string>
<string name="enter_name">Enter Name of Contact</string>
<string name="enter_community_name">Enter Community Name</string>
<string name="label_contact_community">Community:</string>
<string name="label_contact_phone">Phone:</string>
<string name="label_contact_freetext_notes">Notes</string>
Expand Down

0 comments on commit 9f211b5

Please sign in to comment.