From f45c57b4560a0a40e5276442ba902325459d0a18 Mon Sep 17 00:00:00 2001 From: Amab Date: Sat, 8 Jul 2023 11:17:21 +0200 Subject: [PATCH] Fix permissions management on document download for Android 10+. Fixes #419 (#421) ## What changes were proposed in this pull request? * Fix permissions management on document download for Android 10+. Fixes #419 ## How was this patch tested? Manually. Reviewed-on: https://git.cuernodehipnos.es/Marown/SWADroid/pulls/421 Co-authored-by: Amab Co-committed-by: Amab --- .drone.yml | 4 - .../java/es/ugr/swad/swadroid/SWADMain.java | 171 +++++++++--------- .../modules/downloads/DirectoryNavigator.java | 6 +- .../modules/downloads/DownloadFactory.java | 5 +- .../modules/downloads/DownloadManager.java | 7 +- .../swadroid/modules/downloads/Downloads.java | 2 +- .../modules/downloads/DownloadsManager.java | 95 +++++----- SWADroid/src/main/res/raw-es/changes.html | 5 + SWADroid/src/main/res/raw/changes.html | 5 + 9 files changed, 141 insertions(+), 159 deletions(-) diff --git a/.drone.yml b/.drone.yml index bbc1d41e..2667fc84 100644 --- a/.drone.yml +++ b/.drone.yml @@ -26,7 +26,3 @@ steps: # from_secret: sonar_host # sonar_token: # from_secret: sonar_token - -trigger: - event: - - pull_request diff --git a/SWADroid/src/main/java/es/ugr/swad/swadroid/SWADMain.java b/SWADroid/src/main/java/es/ugr/swad/swadroid/SWADMain.java index 4d3a9a92..a87cd784 100644 --- a/SWADroid/src/main/java/es/ugr/swad/swadroid/SWADMain.java +++ b/SWADroid/src/main/java/es/ugr/swad/swadroid/SWADMain.java @@ -309,7 +309,7 @@ public class SWADMain extends MenuExpandableListActivity { SyncUtils.removePeriodicSync(Constants.AUTHORITY, Bundle.EMPTY, this); if(!Preferences.getSyncTime().equals("0") && Preferences.isSyncEnabled()) { SyncUtils.addPeriodicSync(Constants.AUTHORITY, Bundle.EMPTY, - Long.valueOf(Preferences.getSyncTime()), this); + Long.parseLong(Preferences.getSyncTime()), this); } } @@ -680,96 +680,91 @@ public class SWADMain extends MenuExpandableListActivity { mProgressScreen = new ProgressScreen(mProgressScreenView, mCoursesListView, getString(R.string.coursesProgressDescription), this); - OnChildClickListener mExpandableClickListener = new OnChildClickListener() { + OnChildClickListener mExpandableClickListener = (parent, v, groupPosition, childPosition, id) -> { + // Get the item that was clicked + Object o = parent.getExpandableListAdapter().getChild(groupPosition, childPosition); + @SuppressWarnings("unchecked") + String keyword = (String) ((Map) o).get(NAME); + Intent activity; + Context ctx = getApplicationContext(); - @Override - public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, - int childPosition, long id) { - // Get the item that was clicked - Object o = parent.getExpandableListAdapter().getChild(groupPosition, childPosition); - @SuppressWarnings("unchecked") - String keyword = (String) ((Map) o).get(NAME); - Intent activity; - Context ctx = getApplicationContext(); - - if (keyword.equals(getString(R.string.notificationsModuleLabel))) { - activity = new Intent(ctx, Notifications.class); - startActivityForResult(activity, Constants.NOTIFICATIONS_REQUEST_CODE); - } else if (keyword.equals(getString(R.string.testsModuleLabel))) { - activity = new Intent(ctx, Tests.class); - startActivityForResult(activity, Constants.TESTS_REQUEST_CODE); - } else if (keyword.equals(getString(R.string.messagesModuleLabel))) { - activity = new Intent(ctx, Messages.class); - activity.putExtra("eventCode", Long.valueOf(0)); - startActivityForResult(activity, Constants.MESSAGES_REQUEST_CODE); - } else if (keyword.equals(getString(R.string.noticesModuleLabel))) { - activity = new Intent(ctx, Notices.class); - startActivityForResult(activity, Constants.NOTICES_REQUEST_CODE); - } else if (keyword.equals(getString(R.string.rollcallModuleLabel))) { - if (Utils.connectionAvailable(ctx)) { - activity = new Intent(ctx, Rollcall.class); - startActivityForResult(activity, Constants.ROLLCALL_REQUEST_CODE); - } else { - Toast.makeText(ctx, R.string.noConnectionMsg, Toast.LENGTH_LONG).show(); - } - } else if (keyword.equals(getString(R.string.generateQRModuleLabel))) { - activity = new Intent(ctx, GenerateQR.class); - startActivityForResult(activity, Constants.GENERATE_QR_REQUEST_CODE); - } else if (keyword.equals(getString(R.string.manageLocation))) { - activity = new Intent(ctx, IndoorLocation.class); - startActivityForResult(activity, Constants.MANAGE_LOCATION); - } else if (keyword.equals(getString(R.string.documentsDownloadModuleLabel))) { - activity = new Intent(ctx, DownloadsManager.class); - activity.putExtra("downloadsAreaCode", Constants.DOCUMENTS_AREA_CODE); - startActivityForResult(activity, Constants.DOWNLOADSMANAGER_REQUEST_CODE); - } else if (keyword.equals(getString(R.string.sharedsDownloadModuleLabel))) { - activity = new Intent(ctx, DownloadsManager.class); - activity.putExtra("downloadsAreaCode", Constants.SHARE_AREA_CODE); - startActivityForResult(activity, Constants.DOWNLOADSMANAGER_REQUEST_CODE); - } else if (keyword.equals(getString(R.string.marksModuleLabel))) { - activity = new Intent(ctx, DownloadsManager.class); - activity.putExtra("downloadsAreaCode", Constants.MARKS_AREA_CODE); - startActivityForResult(activity, Constants.DOWNLOADSMANAGER_REQUEST_CODE); - } else if (keyword.equals(getString(R.string.myGroupsModuleLabel))) { - activity = new Intent(ctx, MyGroupsManager.class); - activity.putExtra("courseCode", Courses.getSelectedCourseCode()); - startActivityForResult(activity, Constants.MYGROUPSMANAGER_REQUEST_CODE); - } else if (keyword.equals(getString(R.string.introductionModuleLabel))) { - activity = new Intent(ctx, Information.class); - activity.putExtra("requestCode", Constants.INTRODUCTION_REQUEST_CODE); - startActivityForResult(activity, Constants.INTRODUCTION_REQUEST_CODE); - } else if (keyword.equals(getString(R.string.faqsModuleLabel))) { - activity = new Intent(ctx, Information.class); - activity.putExtra("requestCode", Constants.FAQS_REQUEST_CODE); - startActivityForResult(activity, Constants.FAQS_REQUEST_CODE); - } else if (keyword.equals(getString(R.string.bibliographyModuleLabel))) { - activity = new Intent(ctx, Information.class); - activity.putExtra("requestCode", Constants.BIBLIOGRAPHY_REQUEST_CODE); - startActivityForResult(activity, Constants.BIBLIOGRAPHY_REQUEST_CODE); - } else if (keyword.equals(getString(R.string.syllabusPracticalsModuleLabel))) { - activity = new Intent(ctx, Information.class); - activity.putExtra("requestCode", Constants.SYLLABUSPRACTICALS_REQUEST_CODE); - startActivityForResult(activity, Constants.SYLLABUSPRACTICALS_REQUEST_CODE); - } else if (keyword.equals(getString(R.string.syllabusLecturesModuleLabel))) { - activity = new Intent(ctx, Information.class); - activity.putExtra("requestCode", Constants.SYLLABUSLECTURES_REQUEST_CODE); - startActivityForResult(activity, Constants.SYLLABUSLECTURES_REQUEST_CODE); - } else if (keyword.equals(getString(R.string.linksModuleLabel))) { - activity = new Intent(ctx, Information.class); - activity.putExtra("requestCode", Constants.LINKS_REQUEST_CODE); - startActivityForResult(activity, Constants.LINKS_REQUEST_CODE); - } else if (keyword.equals(getString(R.string.teachingguideModuleLabel))) { - activity = new Intent(ctx, Information.class); - activity.putExtra("requestCode", Constants.TEACHINGGUIDE_REQUEST_CODE); - startActivityForResult(activity, Constants.TEACHINGGUIDE_REQUEST_CODE); - } else if (keyword.equals(getString(R.string.assessmentModuleLabel))) { - activity = new Intent(ctx, Information.class); - activity.putExtra("requestCode", Constants.ASSESSMENT_REQUEST_CODE); - startActivityForResult(activity, Constants.ASSESSMENT_REQUEST_CODE); + if (keyword.equals(getString(R.string.notificationsModuleLabel))) { + activity = new Intent(ctx, Notifications.class); + startActivityForResult(activity, Constants.NOTIFICATIONS_REQUEST_CODE); + } else if (keyword.equals(getString(R.string.testsModuleLabel))) { + activity = new Intent(ctx, Tests.class); + startActivityForResult(activity, Constants.TESTS_REQUEST_CODE); + } else if (keyword.equals(getString(R.string.messagesModuleLabel))) { + activity = new Intent(ctx, Messages.class); + activity.putExtra("eventCode", Long.valueOf(0)); + startActivityForResult(activity, Constants.MESSAGES_REQUEST_CODE); + } else if (keyword.equals(getString(R.string.noticesModuleLabel))) { + activity = new Intent(ctx, Notices.class); + startActivityForResult(activity, Constants.NOTICES_REQUEST_CODE); + } else if (keyword.equals(getString(R.string.rollcallModuleLabel))) { + if (Utils.connectionAvailable(ctx)) { + activity = new Intent(ctx, Rollcall.class); + startActivityForResult(activity, Constants.ROLLCALL_REQUEST_CODE); + } else { + Toast.makeText(ctx, R.string.noConnectionMsg, Toast.LENGTH_LONG).show(); } - - return true; + } else if (keyword.equals(getString(R.string.generateQRModuleLabel))) { + activity = new Intent(ctx, GenerateQR.class); + startActivityForResult(activity, Constants.GENERATE_QR_REQUEST_CODE); + } else if (keyword.equals(getString(R.string.manageLocation))) { + activity = new Intent(ctx, IndoorLocation.class); + startActivityForResult(activity, Constants.MANAGE_LOCATION); + } else if (keyword.equals(getString(R.string.documentsDownloadModuleLabel))) { + activity = new Intent(ctx, DownloadsManager.class); + activity.putExtra("downloadsAreaCode", Constants.DOCUMENTS_AREA_CODE); + startActivityForResult(activity, Constants.DOWNLOADSMANAGER_REQUEST_CODE); + } else if (keyword.equals(getString(R.string.sharedsDownloadModuleLabel))) { + activity = new Intent(ctx, DownloadsManager.class); + activity.putExtra("downloadsAreaCode", Constants.SHARE_AREA_CODE); + startActivityForResult(activity, Constants.DOWNLOADSMANAGER_REQUEST_CODE); + } else if (keyword.equals(getString(R.string.marksModuleLabel))) { + activity = new Intent(ctx, DownloadsManager.class); + activity.putExtra("downloadsAreaCode", Constants.MARKS_AREA_CODE); + startActivityForResult(activity, Constants.DOWNLOADSMANAGER_REQUEST_CODE); + } else if (keyword.equals(getString(R.string.myGroupsModuleLabel))) { + activity = new Intent(ctx, MyGroupsManager.class); + activity.putExtra("courseCode", Courses.getSelectedCourseCode()); + startActivityForResult(activity, Constants.MYGROUPSMANAGER_REQUEST_CODE); + } else if (keyword.equals(getString(R.string.introductionModuleLabel))) { + activity = new Intent(ctx, Information.class); + activity.putExtra("requestCode", Constants.INTRODUCTION_REQUEST_CODE); + startActivityForResult(activity, Constants.INTRODUCTION_REQUEST_CODE); + } else if (keyword.equals(getString(R.string.faqsModuleLabel))) { + activity = new Intent(ctx, Information.class); + activity.putExtra("requestCode", Constants.FAQS_REQUEST_CODE); + startActivityForResult(activity, Constants.FAQS_REQUEST_CODE); + } else if (keyword.equals(getString(R.string.bibliographyModuleLabel))) { + activity = new Intent(ctx, Information.class); + activity.putExtra("requestCode", Constants.BIBLIOGRAPHY_REQUEST_CODE); + startActivityForResult(activity, Constants.BIBLIOGRAPHY_REQUEST_CODE); + } else if (keyword.equals(getString(R.string.syllabusPracticalsModuleLabel))) { + activity = new Intent(ctx, Information.class); + activity.putExtra("requestCode", Constants.SYLLABUSPRACTICALS_REQUEST_CODE); + startActivityForResult(activity, Constants.SYLLABUSPRACTICALS_REQUEST_CODE); + } else if (keyword.equals(getString(R.string.syllabusLecturesModuleLabel))) { + activity = new Intent(ctx, Information.class); + activity.putExtra("requestCode", Constants.SYLLABUSLECTURES_REQUEST_CODE); + startActivityForResult(activity, Constants.SYLLABUSLECTURES_REQUEST_CODE); + } else if (keyword.equals(getString(R.string.linksModuleLabel))) { + activity = new Intent(ctx, Information.class); + activity.putExtra("requestCode", Constants.LINKS_REQUEST_CODE); + startActivityForResult(activity, Constants.LINKS_REQUEST_CODE); + } else if (keyword.equals(getString(R.string.teachingguideModuleLabel))) { + activity = new Intent(ctx, Information.class); + activity.putExtra("requestCode", Constants.TEACHINGGUIDE_REQUEST_CODE); + startActivityForResult(activity, Constants.TEACHINGGUIDE_REQUEST_CODE); + } else if (keyword.equals(getString(R.string.assessmentModuleLabel))) { + activity = new Intent(ctx, Information.class); + activity.putExtra("requestCode", Constants.ASSESSMENT_REQUEST_CODE); + startActivityForResult(activity, Constants.ASSESSMENT_REQUEST_CODE); } + + return true; }; mExpandableListView.setOnChildClickListener(mExpandableClickListener); diff --git a/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/downloads/DirectoryNavigator.java b/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/downloads/DirectoryNavigator.java index 666255d1..7b2cad34 100644 --- a/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/downloads/DirectoryNavigator.java +++ b/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/downloads/DirectoryNavigator.java @@ -214,10 +214,10 @@ public class DirectoryNavigator { if (firstChild != null) { switch (tag) { case "code": - fileCode = Long.valueOf(firstChild.getNodeValue()); + fileCode = Long.parseLong(firstChild.getNodeValue()); break; case "time": - time = Long.valueOf(firstChild.getNodeValue()); + time = Long.parseLong(firstChild.getNodeValue()); break; case "license": license = firstChild.getNodeValue(); @@ -397,4 +397,4 @@ public class DirectoryNavigator { */ class InvalidPathException extends IllegalArgumentException { private static final long serialVersionUID = 1L; -} \ No newline at end of file +} diff --git a/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/downloads/DownloadFactory.java b/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/downloads/DownloadFactory.java index 6c1ada97..5aaadc05 100644 --- a/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/downloads/DownloadFactory.java +++ b/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/downloads/DownloadFactory.java @@ -18,11 +18,9 @@ */ package es.ugr.swad.swadroid.modules.downloads; -import android.annotation.TargetApi; import android.app.DownloadManager; import android.content.Context; import android.net.Uri; -import android.os.Build; import android.os.Environment; import android.util.Log; @@ -50,7 +48,6 @@ public class DownloadFactory { * @param title title of the download notification * @param description description of the download notification */ - @TargetApi(Build.VERSION_CODES.HONEYCOMB) public static boolean downloadFile(Context context, String url, String fileName, String title, String description) { @@ -77,7 +74,7 @@ public class DownloadFactory { /** * Method to show file size in bytes in a human readable way - * http://stackoverflow.com/questions/3758606/how-to-convert-byte-size-into-human-readable-format-in-java + * @see how-to-convert-byte-size-into-human-readable-format-in-java */ public static String humanReadableByteCount(long bytes, boolean si) { int unit = si ? 1000 : 1024; diff --git a/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/downloads/DownloadManager.java b/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/downloads/DownloadManager.java index 7fedf5d3..5ebe9efb 100644 --- a/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/downloads/DownloadManager.java +++ b/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/downloads/DownloadManager.java @@ -18,7 +18,6 @@ */ package es.ugr.swad.swadroid.modules.downloads; -import android.annotation.TargetApi; import android.content.ContentResolver; import android.content.ContentUris; import android.content.ContentValues; @@ -27,7 +26,6 @@ import android.database.Cursor; import android.database.CursorWrapper; import android.net.ConnectivityManager; import android.net.Uri; -import android.os.Build; import android.os.Environment; import android.os.ParcelFileDescriptor; import android.provider.BaseColumns; @@ -827,7 +825,6 @@ public class DownloadManager { * method will only work when called from within the download manager's process. * @param ids the IDs of the downloads */ - @TargetApi(Build.VERSION_CODES.KITKAT) public void restartDownload(long... ids) { try (Cursor cursor = query(new Query().setFilterById(ids))) { for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) { @@ -1019,7 +1016,7 @@ public class DownloadManager { private long translateLong(String column) { if (!isLongColumn(column)) { // mimic behavior of underlying cursor -- most likely, throw NumberFormatException - return Long.valueOf(translateString(column)); + return Long.parseLong(translateString(column)); } if (column.equals(COLUMN_ID)) { @@ -1139,4 +1136,4 @@ public class DownloadManager { } } } -} \ No newline at end of file +} diff --git a/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/downloads/Downloads.java b/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/downloads/Downloads.java index 61d2238a..669cb563 100644 --- a/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/downloads/Downloads.java +++ b/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/downloads/Downloads.java @@ -1215,4 +1215,4 @@ public final class Downloads { public static final String INSERT_KEY_PREFIX = "http_header_"; } } -} \ No newline at end of file +} diff --git a/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/downloads/DownloadsManager.java b/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/downloads/DownloadsManager.java index 71ab858c..c284a689 100644 --- a/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/downloads/DownloadsManager.java +++ b/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/downloads/DownloadsManager.java @@ -19,7 +19,6 @@ package es.ugr.swad.swadroid.modules.downloads; import android.Manifest; -import android.annotation.TargetApi; import android.app.Activity; import android.app.AlertDialog; import android.content.ActivityNotFoundException; @@ -31,10 +30,6 @@ import android.graphics.Typeface; import android.os.Build; import android.os.Bundle; import android.os.Environment; -import androidx.annotation.NonNull; -import androidx.core.app.ActivityCompat; -import androidx.core.content.ContextCompat; -import androidx.core.content.FileProvider; import android.util.Log; import android.view.KeyEvent; import android.view.View; @@ -48,6 +43,11 @@ import android.widget.Spinner; import android.widget.TextView; import android.widget.Toast; +import androidx.annotation.NonNull; +import androidx.core.app.ActivityCompat; +import androidx.core.content.ContextCompat; +import androidx.core.content.FileProvider; + import java.io.File; import java.net.URLConnection; import java.util.ArrayList; @@ -190,9 +190,11 @@ public class DownloadsManager extends MenuActivity { protected void onStart() { super.onStart(); - // check Android 6 permission - if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) + // check permissions + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q + && ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { + ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, Constants.PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE); @@ -238,28 +240,18 @@ public class DownloadsManager extends MenuActivity { TextView homeButton = (TextView) this .findViewById(R.id.home_button); - homeButton.setOnClickListener((new OnClickListener() { - - @Override - public void onClick(View v) { - if (navigator != null) { - updateView(navigator.goToRoot()); - } + homeButton.setOnClickListener((v -> { + if (navigator != null) { + updateView(navigator.goToRoot()); } - })); TextView parentButton = (TextView) this .findViewById(R.id.parent_button); - parentButton.setOnClickListener((new OnClickListener() { - - @Override - public void onClick(View v) { - if (navigator != null) { - updateView(navigator.goToParentDirectory()); - } + parentButton.setOnClickListener((v -> { + if (navigator != null) { + updateView(navigator.goToParentDirectory()); } - })); //Set Font Awesome typeface @@ -272,30 +264,27 @@ public class DownloadsManager extends MenuActivity { messageText = (TextView) this.findViewById(R.id.messageText); grid = (GridView) this.findViewById(R.id.gridview); - grid.setOnItemClickListener((new OnItemClickListener() { - public void onItemClick(AdapterView parent, View v, - int position, long id) { + grid.setOnItemClickListener(((parent, v, position, id) -> { - DirectoryItem node = navigator.getDirectoryItem(position); - if (node.getFileCode() == -1) //it is a directory therefore navigates into it - updateView(navigator.goToSubDirectory(position)); - else { //it is a files therefore gets its information through web service GETFILE - chosenNodeName = node.getName(); - fileSize = node.getSize(); - File f = new File(Constants.DOWNLOADS_PATH + File.separator + chosenNodeName); + DirectoryItem node = navigator.getDirectoryItem(position); + if (node.getFileCode() == -1) //it is a directory therefore navigates into it + updateView(navigator.goToSubDirectory(position)); + else { //it is a files therefore gets its information through web service GETFILE + chosenNodeName = node.getName(); + fileSize = node.getSize(); + File f = new File(Constants.DOWNLOADS_PATH + File.separator + chosenNodeName); - //If a student is requesting the marks, gets the marks and call the Marks module - if((downloadsAreaCode == Constants.MARKS_AREA_CODE) - && (Login.getLoggedUser().getUserRole() == Constants.STUDENT_TYPE_CODE)) { + //If a student is requesting the marks, gets the marks and call the Marks module + if((downloadsAreaCode == Constants.MARKS_AREA_CODE) + && (Login.getLoggedUser().getUserRole() == Constants.STUDENT_TYPE_CODE)) { - requestGetMarks(node.getFileCode()); - } else { //Otherwise treat as a regular file - if (isDownloaded(f)) { - viewFile(f); - } else { - AlertDialog fileInfoDialog = createFileInfoDialog(node.getName(), node.getSize(), node.getTime(), node.getPublisher(), node.getFileCode(), node.getLicense()); - fileInfoDialog.show(); - } + requestGetMarks(node.getFileCode()); + } else { //Otherwise treat as a regular file + if (isDownloaded(f)) { + viewFile(f); + } else { + AlertDialog fileInfoDialog = createFileInfoDialog(node.getName(), node.getSize(), node.getTime(), node.getPublisher(), node.getFileCode(), node.getLicense()); + fileInfoDialog.show(); } } } @@ -322,22 +311,20 @@ public class DownloadsManager extends MenuActivity { } @Override - public boolean onKeyDown(int keyCode, KeyEvent event) - { + public boolean onKeyDown(int keyCode, KeyEvent event) { //If back button is pressed, go to parent directory - if ((keyCode == KeyEvent.KEYCODE_BACK)) - { - if (navigator != null) { - //If current directory is not the root, go to parent directory + if ((keyCode == KeyEvent.KEYCODE_BACK)) { + if (navigator != null) { + //If current directory is not the root, go to parent directory if (!navigator.isRootDirectory()) { updateView(navigator.goToParentDirectory()); - //If current directory is the root, exit module + //If current directory is the root, exit module } else { return super.onKeyDown(keyCode, event); } } - return true; + return true; } return super.onKeyDown(keyCode, event); @@ -802,7 +789,6 @@ public class DownloadsManager extends MenuActivity { /** * Set up the {@link android.app.ActionBar}, if the API is available. */ - @TargetApi(Build.VERSION_CODES.HONEYCOMB) private void setupActionBar() { getSupportActionBar().setDisplayHomeAsUpEnabled(true); @@ -820,8 +806,9 @@ public class DownloadsManager extends MenuActivity { } @Override - public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[], + public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { + super.onRequestPermissionsResult(requestCode, permissions, grantResults); switch (requestCode) { case Constants.PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE: { if (grantResults.length > 0 diff --git a/SWADroid/src/main/res/raw-es/changes.html b/SWADroid/src/main/res/raw-es/changes.html index 402efbe3..c8013704 100644 --- a/SWADroid/src/main/res/raw-es/changes.html +++ b/SWADroid/src/main/res/raw-es/changes.html @@ -23,6 +23,11 @@
  • Añadido módulo para localización en interiores
  • --> +

    1.5.10

    +
      +
    • Corregida gestión de permisos en la descarga de documentos para Android 10+
    • +
    +

    1.5.9

    • Añadido soporte para la descarga de notificaciones en segundo plano cuando la optimización de batería está habilitada
    • diff --git a/SWADroid/src/main/res/raw/changes.html b/SWADroid/src/main/res/raw/changes.html index dc294391..985b68c2 100644 --- a/SWADroid/src/main/res/raw/changes.html +++ b/SWADroid/src/main/res/raw/changes.html @@ -23,6 +23,11 @@
    • Added indoor location module
    --> +

    1.5.10

    +
      +
    • Fixed permissions management on document download for Android 10+
    • +
    +

    1.5.9

    • Added support for background notification download when power save mode is enabled