diff options
author | Rash419 <rashesh.padia@collabora.com> | 2023-08-29 12:58:55 +0530 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2023-08-31 13:12:22 +0200 |
commit | a02cde2565fdaafd5def87b8b1a7319880d0b0e3 (patch) | |
tree | e117de7ce58ab781bb1d3ed18dc1749b78aa4319 /android | |
parent | android: add ndkVersion in build.gradle (diff) | |
download | online-a02cde2565fdaafd5def87b8b1a7319880d0b0e3.tar.gz online-a02cde2565fdaafd5def87b8b1a7319880d0b0e3.zip |
android: fix lint errors
RecentFilesAdapter.java:76: Error: Value must be ≥ 0 [Range]
filename = cursor.getString(cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME));
RecentFilesAdapter.java:97: Error: Value must be ≥ 0 [Range]
length = cursor.getLong(cursor.getColumnIndex(OpenableColumns.SIZE));
file_explorer_grid_item.xml:42: Error: Inconsistent alignment specification between textAlignment and gravity attributes: was center_vertical, expected center_horizontal [RtlCompat]
android:textAlignment="center"
Signed-off-by: Rash419 <rashesh.padia@collabora.com>
Change-Id: I663a89b0ecce03b067e1fa216a030a19fa578da5
Diffstat (limited to 'android')
3 files changed, 13 insertions, 16 deletions
diff --git a/android/app/src/main/java/org/libreoffice/androidapp/ui/RecentFilesAdapter.java b/android/app/src/main/java/org/libreoffice/androidapp/ui/RecentFilesAdapter.java index 74a0f12b9d..1879e87d22 100644 --- a/android/app/src/main/java/org/libreoffice/androidapp/ui/RecentFilesAdapter.java +++ b/android/app/src/main/java/org/libreoffice/androidapp/ui/RecentFilesAdapter.java @@ -73,7 +73,7 @@ class RecentFilesAdapter extends RecyclerView.Adapter<RecentFilesAdapter.ViewHol try { cursor = activity.getContentResolver().query(uri, null, null, null, null); if (cursor != null && cursor.moveToFirst()) - filename = cursor.getString(cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME)); + filename = cursor.getString(cursor.getColumnIndexOrThrow(OpenableColumns.DISPLAY_NAME)); } catch (Exception e) { return null; } finally { @@ -94,7 +94,7 @@ class RecentFilesAdapter extends RecyclerView.Adapter<RecentFilesAdapter.ViewHol try { cursor = activity.getContentResolver().query(uri, null, null, null, null); if (cursor != null && cursor.moveToFirst()) - length = cursor.getLong(cursor.getColumnIndex(OpenableColumns.SIZE)); + length = cursor.getLong(cursor.getColumnIndexOrThrow(OpenableColumns.SIZE)); } catch (Exception e) { return 0; } finally { diff --git a/android/app/src/main/res/layout/file_explorer_grid_item.xml b/android/app/src/main/res/layout/file_explorer_grid_item.xml index a84161e496..b741a90916 100644 --- a/android/app/src/main/res/layout/file_explorer_grid_item.xml +++ b/android/app/src/main/res/layout/file_explorer_grid_item.xml @@ -37,7 +37,7 @@ android:layout_gravity="center" android:layout_weight="1" android:ellipsize="end" - android:gravity="center_vertical" + android:gravity="center" android:maxLines="2" android:textAlignment="center" android:textColor="?android:attr/textColorPrimary" @@ -52,8 +52,8 @@ android:layout_gravity="center" android:contentDescription="@string/file_actions_icon_desc" android:scaleType="fitStart" - android:tint="?android:attr/textColorPrimary" - app:srcCompat="@drawable/ic_more_vert_black_24dp" /> + app:srcCompat="@drawable/ic_more_vert_black_24dp" + app:tint="?android:attr/textColorPrimary" /> </LinearLayout> </LinearLayout> diff --git a/android/lib/src/main/java/org/libreoffice/androidlib/LOActivity.java b/android/lib/src/main/java/org/libreoffice/androidlib/LOActivity.java index e5dac6ed43..fcdd0f95f4 100644 --- a/android/lib/src/main/java/org/libreoffice/androidlib/LOActivity.java +++ b/android/lib/src/main/java/org/libreoffice/androidlib/LOActivity.java @@ -642,6 +642,7 @@ public class LOActivity extends AppCompatActivity { @Override public void onActivityResult(int requestCode, int resultCode, Intent intent) { + super.onActivityResult(requestCode, resultCode, intent); if (resultCode != RESULT_OK) { if (requestCode == REQUEST_SELECT_IMAGE_FILE) { valueCallback.onReceiveValue(null); @@ -660,18 +661,15 @@ public class LOActivity extends AppCompatActivity { requestCopy = true; if (getMimeType().equals("text/plain")) { requestCode = REQUEST_SAVEAS_ODT; - } - else if (getMimeType().equals("text/comma-separated-values")) { + } else if (getMimeType().equals("text/comma-separated-values")) { requestCode = REQUEST_SAVEAS_ODS; - } - else if (getMimeType().equals("application/vnd.ms-excel.sheet.binary.macroenabled.12")) { + } else if (getMimeType().equals("application/vnd.ms-excel.sheet.binary.macroenabled.12")) { requestCode = REQUEST_SAVEAS_ODS; - } - else { + } else { String filename = getFileName(true); String extension = filename.substring(filename.lastIndexOf('.') + 1); requestCode = getRequestIDForFormat(extension); - assert(requestCode != 0); + assert (requestCode != 0); } } switch (requestCode) { @@ -708,8 +706,7 @@ public class LOActivity extends AppCompatActivity { inputStream = new FileInputStream(tempFile); try { outputStream = getContentResolver().openOutputStream(intent.getData(), "wt"); - } - catch (FileNotFoundException e) { + } catch (FileNotFoundException e) { Log.i(TAG, "failed with the 'wt' mode, trying without: " + e.getMessage()); outputStream = getContentResolver().openOutputStream(intent.getData()); } @@ -734,7 +731,7 @@ public class LOActivity extends AppCompatActivity { } } if (requestCopy == true) { - assert(_tempFile != null); + assert (_tempFile != null); mTempFile = _tempFile; getIntent().setData(intent.getData()); /** add the document to recents */ @@ -1149,7 +1146,7 @@ public class LOActivity extends AppCompatActivity { try { cursor = getContentResolver().query(getIntent().getData(), null, null, null, null); if (cursor != null && cursor.moveToFirst()) - filename = cursor.getString(cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME)); + filename = cursor.getString(cursor.getColumnIndexOrThrow(OpenableColumns.DISPLAY_NAME)); } catch (Exception e) { return null; } |