## 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: #421 Co-authored-by: Amab <juanmi1982@gmail.com> Co-committed-by: Amab <juanmi1982@gmail.com>
This commit is contained in:
parent
8fd41782ad
commit
f45c57b456
|
@ -26,7 +26,3 @@ steps:
|
||||||
# from_secret: sonar_host
|
# from_secret: sonar_host
|
||||||
# sonar_token:
|
# sonar_token:
|
||||||
# from_secret: sonar_token
|
# from_secret: sonar_token
|
||||||
|
|
||||||
trigger:
|
|
||||||
event:
|
|
||||||
- pull_request
|
|
||||||
|
|
|
@ -309,7 +309,7 @@ public class SWADMain extends MenuExpandableListActivity {
|
||||||
SyncUtils.removePeriodicSync(Constants.AUTHORITY, Bundle.EMPTY, this);
|
SyncUtils.removePeriodicSync(Constants.AUTHORITY, Bundle.EMPTY, this);
|
||||||
if(!Preferences.getSyncTime().equals("0") && Preferences.isSyncEnabled()) {
|
if(!Preferences.getSyncTime().equals("0") && Preferences.isSyncEnabled()) {
|
||||||
SyncUtils.addPeriodicSync(Constants.AUTHORITY, Bundle.EMPTY,
|
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,
|
mProgressScreen = new ProgressScreen(mProgressScreenView, mCoursesListView,
|
||||||
getString(R.string.coursesProgressDescription), this);
|
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<String, Object>) o).get(NAME);
|
||||||
|
Intent activity;
|
||||||
|
Context ctx = getApplicationContext();
|
||||||
|
|
||||||
@Override
|
if (keyword.equals(getString(R.string.notificationsModuleLabel))) {
|
||||||
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition,
|
activity = new Intent(ctx, Notifications.class);
|
||||||
int childPosition, long id) {
|
startActivityForResult(activity, Constants.NOTIFICATIONS_REQUEST_CODE);
|
||||||
// Get the item that was clicked
|
} else if (keyword.equals(getString(R.string.testsModuleLabel))) {
|
||||||
Object o = parent.getExpandableListAdapter().getChild(groupPosition, childPosition);
|
activity = new Intent(ctx, Tests.class);
|
||||||
@SuppressWarnings("unchecked")
|
startActivityForResult(activity, Constants.TESTS_REQUEST_CODE);
|
||||||
String keyword = (String) ((Map<String, Object>) o).get(NAME);
|
} else if (keyword.equals(getString(R.string.messagesModuleLabel))) {
|
||||||
Intent activity;
|
activity = new Intent(ctx, Messages.class);
|
||||||
Context ctx = getApplicationContext();
|
activity.putExtra("eventCode", Long.valueOf(0));
|
||||||
|
startActivityForResult(activity, Constants.MESSAGES_REQUEST_CODE);
|
||||||
if (keyword.equals(getString(R.string.notificationsModuleLabel))) {
|
} else if (keyword.equals(getString(R.string.noticesModuleLabel))) {
|
||||||
activity = new Intent(ctx, Notifications.class);
|
activity = new Intent(ctx, Notices.class);
|
||||||
startActivityForResult(activity, Constants.NOTIFICATIONS_REQUEST_CODE);
|
startActivityForResult(activity, Constants.NOTICES_REQUEST_CODE);
|
||||||
} else if (keyword.equals(getString(R.string.testsModuleLabel))) {
|
} else if (keyword.equals(getString(R.string.rollcallModuleLabel))) {
|
||||||
activity = new Intent(ctx, Tests.class);
|
if (Utils.connectionAvailable(ctx)) {
|
||||||
startActivityForResult(activity, Constants.TESTS_REQUEST_CODE);
|
activity = new Intent(ctx, Rollcall.class);
|
||||||
} else if (keyword.equals(getString(R.string.messagesModuleLabel))) {
|
startActivityForResult(activity, Constants.ROLLCALL_REQUEST_CODE);
|
||||||
activity = new Intent(ctx, Messages.class);
|
} else {
|
||||||
activity.putExtra("eventCode", Long.valueOf(0));
|
Toast.makeText(ctx, R.string.noConnectionMsg, Toast.LENGTH_LONG).show();
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
} else if (keyword.equals(getString(R.string.generateQRModuleLabel))) {
|
||||||
return true;
|
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);
|
mExpandableListView.setOnChildClickListener(mExpandableClickListener);
|
||||||
|
|
|
@ -214,10 +214,10 @@ public class DirectoryNavigator {
|
||||||
if (firstChild != null) {
|
if (firstChild != null) {
|
||||||
switch (tag) {
|
switch (tag) {
|
||||||
case "code":
|
case "code":
|
||||||
fileCode = Long.valueOf(firstChild.getNodeValue());
|
fileCode = Long.parseLong(firstChild.getNodeValue());
|
||||||
break;
|
break;
|
||||||
case "time":
|
case "time":
|
||||||
time = Long.valueOf(firstChild.getNodeValue());
|
time = Long.parseLong(firstChild.getNodeValue());
|
||||||
break;
|
break;
|
||||||
case "license":
|
case "license":
|
||||||
license = firstChild.getNodeValue();
|
license = firstChild.getNodeValue();
|
||||||
|
@ -397,4 +397,4 @@ public class DirectoryNavigator {
|
||||||
*/
|
*/
|
||||||
class InvalidPathException extends IllegalArgumentException {
|
class InvalidPathException extends IllegalArgumentException {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,11 +18,9 @@
|
||||||
*/
|
*/
|
||||||
package es.ugr.swad.swadroid.modules.downloads;
|
package es.ugr.swad.swadroid.modules.downloads;
|
||||||
|
|
||||||
import android.annotation.TargetApi;
|
|
||||||
import android.app.DownloadManager;
|
import android.app.DownloadManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
@ -50,7 +48,6 @@ public class DownloadFactory {
|
||||||
* @param title title of the download notification
|
* @param title title of the download notification
|
||||||
* @param description description 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,
|
public static boolean downloadFile(Context context, String url, String fileName, String title,
|
||||||
String description) {
|
String description) {
|
||||||
|
|
||||||
|
@ -77,7 +74,7 @@ public class DownloadFactory {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method to show file size in bytes in a human readable way
|
* 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 <a href="http://stackoverflow.com/questions/3758606/how-to-convert-byte-size-into-human-readable-format-in-java">how-to-convert-byte-size-into-human-readable-format-in-java</a>
|
||||||
*/
|
*/
|
||||||
public static String humanReadableByteCount(long bytes, boolean si) {
|
public static String humanReadableByteCount(long bytes, boolean si) {
|
||||||
int unit = si ? 1000 : 1024;
|
int unit = si ? 1000 : 1024;
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
*/
|
*/
|
||||||
package es.ugr.swad.swadroid.modules.downloads;
|
package es.ugr.swad.swadroid.modules.downloads;
|
||||||
|
|
||||||
import android.annotation.TargetApi;
|
|
||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
import android.content.ContentUris;
|
import android.content.ContentUris;
|
||||||
import android.content.ContentValues;
|
import android.content.ContentValues;
|
||||||
|
@ -27,7 +26,6 @@ import android.database.Cursor;
|
||||||
import android.database.CursorWrapper;
|
import android.database.CursorWrapper;
|
||||||
import android.net.ConnectivityManager;
|
import android.net.ConnectivityManager;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
import android.os.ParcelFileDescriptor;
|
import android.os.ParcelFileDescriptor;
|
||||||
import android.provider.BaseColumns;
|
import android.provider.BaseColumns;
|
||||||
|
@ -827,7 +825,6 @@ public class DownloadManager {
|
||||||
* method will only work when called from within the download manager's process.
|
* method will only work when called from within the download manager's process.
|
||||||
* @param ids the IDs of the downloads
|
* @param ids the IDs of the downloads
|
||||||
*/
|
*/
|
||||||
@TargetApi(Build.VERSION_CODES.KITKAT)
|
|
||||||
public void restartDownload(long... ids) {
|
public void restartDownload(long... ids) {
|
||||||
try (Cursor cursor = query(new Query().setFilterById(ids))) {
|
try (Cursor cursor = query(new Query().setFilterById(ids))) {
|
||||||
for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) {
|
for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) {
|
||||||
|
@ -1019,7 +1016,7 @@ public class DownloadManager {
|
||||||
private long translateLong(String column) {
|
private long translateLong(String column) {
|
||||||
if (!isLongColumn(column)) {
|
if (!isLongColumn(column)) {
|
||||||
// mimic behavior of underlying cursor -- most likely, throw NumberFormatException
|
// mimic behavior of underlying cursor -- most likely, throw NumberFormatException
|
||||||
return Long.valueOf(translateString(column));
|
return Long.parseLong(translateString(column));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (column.equals(COLUMN_ID)) {
|
if (column.equals(COLUMN_ID)) {
|
||||||
|
@ -1139,4 +1136,4 @@ public class DownloadManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1215,4 +1215,4 @@ public final class Downloads {
|
||||||
public static final String INSERT_KEY_PREFIX = "http_header_";
|
public static final String INSERT_KEY_PREFIX = "http_header_";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
package es.ugr.swad.swadroid.modules.downloads;
|
package es.ugr.swad.swadroid.modules.downloads;
|
||||||
|
|
||||||
import android.Manifest;
|
import android.Manifest;
|
||||||
import android.annotation.TargetApi;
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.content.ActivityNotFoundException;
|
import android.content.ActivityNotFoundException;
|
||||||
|
@ -31,10 +30,6 @@ import android.graphics.Typeface;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Environment;
|
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.util.Log;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
@ -48,6 +43,11 @@ import android.widget.Spinner;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
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.io.File;
|
||||||
import java.net.URLConnection;
|
import java.net.URLConnection;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -190,9 +190,11 @@ public class DownloadsManager extends MenuActivity {
|
||||||
protected void onStart() {
|
protected void onStart() {
|
||||||
super.onStart();
|
super.onStart();
|
||||||
|
|
||||||
// check Android 6 permission
|
// check permissions
|
||||||
if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q
|
||||||
|
&& ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
||||||
!= PackageManager.PERMISSION_GRANTED) {
|
!= PackageManager.PERMISSION_GRANTED) {
|
||||||
|
|
||||||
ActivityCompat.requestPermissions(this,
|
ActivityCompat.requestPermissions(this,
|
||||||
new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
|
new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
|
||||||
Constants.PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE);
|
Constants.PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE);
|
||||||
|
@ -238,28 +240,18 @@ public class DownloadsManager extends MenuActivity {
|
||||||
|
|
||||||
TextView homeButton = (TextView) this
|
TextView homeButton = (TextView) this
|
||||||
.findViewById(R.id.home_button);
|
.findViewById(R.id.home_button);
|
||||||
homeButton.setOnClickListener((new OnClickListener() {
|
homeButton.setOnClickListener((v -> {
|
||||||
|
if (navigator != null) {
|
||||||
@Override
|
updateView(navigator.goToRoot());
|
||||||
public void onClick(View v) {
|
|
||||||
if (navigator != null) {
|
|
||||||
updateView(navigator.goToRoot());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
TextView parentButton = (TextView) this
|
TextView parentButton = (TextView) this
|
||||||
.findViewById(R.id.parent_button);
|
.findViewById(R.id.parent_button);
|
||||||
parentButton.setOnClickListener((new OnClickListener() {
|
parentButton.setOnClickListener((v -> {
|
||||||
|
if (navigator != null) {
|
||||||
@Override
|
updateView(navigator.goToParentDirectory());
|
||||||
public void onClick(View v) {
|
|
||||||
if (navigator != null) {
|
|
||||||
updateView(navigator.goToParentDirectory());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
//Set Font Awesome typeface
|
//Set Font Awesome typeface
|
||||||
|
@ -272,30 +264,27 @@ public class DownloadsManager extends MenuActivity {
|
||||||
messageText = (TextView) this.findViewById(R.id.messageText);
|
messageText = (TextView) this.findViewById(R.id.messageText);
|
||||||
|
|
||||||
grid = (GridView) this.findViewById(R.id.gridview);
|
grid = (GridView) this.findViewById(R.id.gridview);
|
||||||
grid.setOnItemClickListener((new OnItemClickListener() {
|
grid.setOnItemClickListener(((parent, v, position, id) -> {
|
||||||
public void onItemClick(AdapterView<?> parent, View v,
|
|
||||||
int position, long id) {
|
|
||||||
|
|
||||||
DirectoryItem node = navigator.getDirectoryItem(position);
|
DirectoryItem node = navigator.getDirectoryItem(position);
|
||||||
if (node.getFileCode() == -1) //it is a directory therefore navigates into it
|
if (node.getFileCode() == -1) //it is a directory therefore navigates into it
|
||||||
updateView(navigator.goToSubDirectory(position));
|
updateView(navigator.goToSubDirectory(position));
|
||||||
else { //it is a files therefore gets its information through web service GETFILE
|
else { //it is a files therefore gets its information through web service GETFILE
|
||||||
chosenNodeName = node.getName();
|
chosenNodeName = node.getName();
|
||||||
fileSize = node.getSize();
|
fileSize = node.getSize();
|
||||||
File f = new File(Constants.DOWNLOADS_PATH + File.separator + chosenNodeName);
|
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 a student is requesting the marks, gets the marks and call the Marks module
|
||||||
if((downloadsAreaCode == Constants.MARKS_AREA_CODE)
|
if((downloadsAreaCode == Constants.MARKS_AREA_CODE)
|
||||||
&& (Login.getLoggedUser().getUserRole() == Constants.STUDENT_TYPE_CODE)) {
|
&& (Login.getLoggedUser().getUserRole() == Constants.STUDENT_TYPE_CODE)) {
|
||||||
|
|
||||||
requestGetMarks(node.getFileCode());
|
requestGetMarks(node.getFileCode());
|
||||||
} else { //Otherwise treat as a regular file
|
} else { //Otherwise treat as a regular file
|
||||||
if (isDownloaded(f)) {
|
if (isDownloaded(f)) {
|
||||||
viewFile(f);
|
viewFile(f);
|
||||||
} else {
|
} else {
|
||||||
AlertDialog fileInfoDialog = createFileInfoDialog(node.getName(), node.getSize(), node.getTime(), node.getPublisher(), node.getFileCode(), node.getLicense());
|
AlertDialog fileInfoDialog = createFileInfoDialog(node.getName(), node.getSize(), node.getTime(), node.getPublisher(), node.getFileCode(), node.getLicense());
|
||||||
fileInfoDialog.show();
|
fileInfoDialog.show();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -322,22 +311,20 @@ public class DownloadsManager extends MenuActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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 back button is pressed, go to parent directory
|
||||||
if ((keyCode == KeyEvent.KEYCODE_BACK))
|
if ((keyCode == KeyEvent.KEYCODE_BACK)) {
|
||||||
{
|
if (navigator != null) {
|
||||||
if (navigator != null) {
|
//If current directory is not the root, go to parent directory
|
||||||
//If current directory is not the root, go to parent directory
|
|
||||||
if (!navigator.isRootDirectory()) {
|
if (!navigator.isRootDirectory()) {
|
||||||
updateView(navigator.goToParentDirectory());
|
updateView(navigator.goToParentDirectory());
|
||||||
//If current directory is the root, exit module
|
//If current directory is the root, exit module
|
||||||
} else {
|
} else {
|
||||||
return super.onKeyDown(keyCode, event);
|
return super.onKeyDown(keyCode, event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.onKeyDown(keyCode, event);
|
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.
|
* Set up the {@link android.app.ActionBar}, if the API is available.
|
||||||
*/
|
*/
|
||||||
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
|
|
||||||
private void setupActionBar() {
|
private void setupActionBar() {
|
||||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
|
|
||||||
|
@ -820,8 +806,9 @@ public class DownloadsManager extends MenuActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[],
|
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
|
||||||
@NonNull int[] grantResults) {
|
@NonNull int[] grantResults) {
|
||||||
|
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||||
switch (requestCode) {
|
switch (requestCode) {
|
||||||
case Constants.PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE: {
|
case Constants.PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE: {
|
||||||
if (grantResults.length > 0
|
if (grantResults.length > 0
|
||||||
|
|
|
@ -23,6 +23,11 @@
|
||||||
<li type="disc">Añadido módulo para localización en interiores</li>
|
<li type="disc">Añadido módulo para localización en interiores</li>
|
||||||
</ul>-->
|
</ul>-->
|
||||||
|
|
||||||
|
<h4>1.5.10</h4>
|
||||||
|
<ul>
|
||||||
|
<li type="disc">Corregida gestión de permisos en la descarga de documentos para Android 10+</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
<h4>1.5.9</h4>
|
<h4>1.5.9</h4>
|
||||||
<ul>
|
<ul>
|
||||||
<li type="disc">Añadido soporte para la descarga de notificaciones en segundo plano cuando la optimización de batería está habilitada</li>
|
<li type="disc">Añadido soporte para la descarga de notificaciones en segundo plano cuando la optimización de batería está habilitada</li>
|
||||||
|
|
|
@ -23,6 +23,11 @@
|
||||||
<li type="disc">Added indoor location module</li>
|
<li type="disc">Added indoor location module</li>
|
||||||
</ul>-->
|
</ul>-->
|
||||||
|
|
||||||
|
<h4>1.5.10</h4>
|
||||||
|
<ul>
|
||||||
|
<li type="disc">Fixed permissions management on document download for Android 10+</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
<h4>1.5.9</h4>
|
<h4>1.5.9</h4>
|
||||||
<ul>
|
<ul>
|
||||||
<li type="disc">Added support for background notification download when power save mode is enabled</li>
|
<li type="disc">Added support for background notification download when power save mode is enabled</li>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user