Commit Graph

355 Commits

Author SHA1 Message Date
6bab548591 android: Use "compact_fonts" LibreOfficeKit option
For Android Viewer, set the "compact_fonts" LibreOfficeKit
option via environment variable `SAL_LOK_OPTIONS` introduced in

    Change-Id: I3dc9f5de876def6e4afc09a43105b1740f7c621f
    Author: Michael Meeks <michael.meeks@collabora.com>
    Date:   Fri May 17 21:25:29 2024 +0100

        lok: stop amazing waste of repeated font sizes in each font element.

and adjust the handling in `FontController` to process
the flat lists for font names and sizes that is reported
with that options set, rather than processing
font sizes for each individual font.

(See also discussion in original Gerrit change
for the distro/collabora/co-24.04 branch: [1].).

[1] https://gerrit.libreoffice.org/c/core/+/167799

Change-Id: I85734c1876d152f4f95f9182629affd6b250fdbc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167963
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Tested-by: Jenkins
2024-05-23 15:53:26 +02:00
86050dc7c7 android: Disable multidex, only needed for minSdkVersion < 21
multidex was enabled in

    commit 037680488b56aa2c4eb21900168aa88ef35d5b07
    Author: Michael Weghorn <m.weghorn@posteo.de>
    Date:   Tue Dec 27 12:51:54 2022 +0100

        android: Enable multidex, update com.google.android.material to 1.7.0

as it was needed when building for minSdkVersion <= 20, see [1]
and the full commit message of the above-mentioned commit
for more details.

However, since

    commit c2fc2c8c7c63ca4e43bca6e8c9b82c50418422d2
    Author: Michael Weghorn <m.weghorn@posteo.de>
    Date:   Tue Dec 5 09:57:22 2023 +0100

        android: Bump minSdkVersion to 21 (Android 5.0)

, the minSdkVersion is greater than that, so this
is no longer needed.

[1] https://developer.android.com/build/multidex

Change-Id: I31502ec74e9c4201a8a11be42820f70e5fd5a1fd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167735
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Tested-by: Jenkins
2024-05-16 15:13:20 +02:00
69189de8fa tdf#157009 android: Add icon symlink for F-Droid
Add a symlink to the app icon at the expected
location when using the Triple-T data structure
that can be used to provide metadata for F-Droid. [1]

As Android Viewer currently uses a non-default directory layout,
this currently needs to be placed in a different subdirectory than
the actual source code in order for F-Droid to find it, see the
discussion in [2] for more details.

This should cause the app icon to show up in F-Droid
after the next update.

[1] https://f-droid.org/en/docs/All_About_Descriptions_Graphics_and_Screenshots/#triple-t-structure
[2] https://gitlab.com/fdroid/fdroiddata/-/merge_requests/13643#note_1538888683

Change-Id: Ic1a987e430b6e92134ac19d7f1c264953cd3cf0c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167732
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Tested-by: Jenkins
2024-05-16 12:14:04 +02:00
91fa1f792d android: Avoid unnecessary prefs processing
When the experimental editing mode preference
was toggled, it was processed twice:

Toggling that pref requires starting the
`SettingsActivity`, and when returning to
`LibreOfficeMainActivity`, its `onResume` method
was called which updates `mIsExperimentalMode` as needed.
In addition, the `LibreOfficeMainActivity#onSharedPreferenceChanged`
callback was called that also processed that preference.

The latter is more "targeted" and only called when a preference
actually changes.
Call `updatePreferences()` from there so other preferences
are also handled and drop the call to `updatePreferences`
from the `onResume` method, which is no longer needed
with that in place.

Change-Id: Ic0cacd8ad551137d5aea14cda6838d2ac50de8db
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167724
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-05-16 12:13:51 +02:00
3865c81e96 android: Drop indirection listening to pref change
Let `LibreOfficeMainActivity` implement the standard
Android `SharedPreferences.OnSharedPreferenceChangeListener`
interface directly, rather than having a custom
`SettingsListenerModel.OnSettingsPreferenceChangedListener`
indirection and the `SettingsFragment` implementing the
standard interface.

This simplifies the code and removes one level of
indirection.

Drop the now unused `SettingsListenerModel`.

Change-Id: I8c7d6088e711631409f9189bba966439db3daa44
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167723
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-05-16 12:13:45 +02:00
4d4c313494 android: Apply enabled experimental mode when doc open
Use a `mbReadOnlyDoc` member that keeps
track of the readonly status of the document only
instead of a `mbISReadOnlyMode` that at the same
time also was taking into account whether experimental
editing features were enabled.
Let `LibreOfficeMainActivity#isReadOnlyMode()` take
experimental status into account instead.

With this in place, opening a (writable) document
with experimental editing mode disabled, then enabling
experimental editing mode makes editing possible after
clicking on the LibreOffice logo in the toolbar.

Previously, it was necessary to open the document
anew.

Change-Id: Ia5fde9b6019251d76d46df97fad2ffd64a0f5a30
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167721
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-05-16 12:13:38 +02:00
39ed595d60 android: No longer manually set UI language
Drop the possibility to manually set a UI language
introduced in

    commit f2e35a695671028b32139df1824ff536e7610d35
    Author: Mert Tumer <merttumer@outlook.com>
    Date:   Tue Sep 18 23:29:57 2018 +0300

        Added language support on Android Viewer

Since

    commit 5bf2ec9ed8728a2042e110122ea2b0e4ff55104a
    Author: Michael Weghorn <m.weghorn@posteo.de>
    Date:   Fri Dec 20 10:40:34 2019 +0100

        android: Use system locale by default

, Android Viewer defaulted to the system
language for its UI language as well.

In addition, current Android versions allow to set
a specific language for apps: [1]

The previous approach of manually setting a language
in Android Viewer shouldn't really be necessary any more.

With the app now being available for translation on
Weblate and having been translated to more languages,
the list of available languages had become out of sync.

Additionally, the manually selected language wasn't
consistently applied everywhere:

* On the start activity where a document can be selected,
  it was only applied after closing the app, then opening
  it again.

* in the Settings, the language was not applied at all,
  that was always using the system locale anyway

Changes to the system locale are applied immediately
and consistently, so stick to the default Android mechanism
and reduce the overall complexity and maintenance burden.

[1] https://support.google.com/android/answer/12395118?hl=en

Change-Id: Ida61650b888a563f2346ea94a14b260802b1d24d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167718
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-05-16 12:13:30 +02:00
567891fdf7 android: Port Settings{Activity,Fragment} from deprecated API
API used in `SettingsActivity` and `SettingsFragment` has
been deprecated, e.g. `PreferenceFragment` was deprecated in
API level 28 [1].

Port that to non-deprecated API from the androidx.preference
library [2].

This addresses these deprecation warnings:

    /home/michi/development/git/libreoffice-WORKTREE-android/android/source/src/java/org/libreoffice/SettingsActivity.java:14: warning: [deprecation] PreferenceFragment in android.preference has been deprecated
    import android.preference.PreferenceFragment;
                             ^
    /home/michi/development/git/libreoffice-WORKTREE-android/android/source/src/java/org/libreoffice/SettingsActivity.java:15: warning: [deprecation] PreferenceGroup in android.preference has been deprecated

    /home/michi/development/git/libreoffice-WORKTREE-android/android/source/src/java/org/libreoffice/SettingsActivity.java:23: warning: [deprecation] getFragmentManager() in Activity has been deprecated
            getFragmentManager().beginTransaction()
            ^
    /home/michi/development/git/libreoffice-WORKTREE-android/android/source/src/java/org/libreoffice/SettingsActivity.java:23: warning: [deprecation] beginTransaction() in FragmentManager has been deprecated
            getFragmentManager().beginTransaction()
                                ^
    /home/michi/development/git/libreoffice-WORKTREE-android/android/source/src/java/org/libreoffice/SettingsActivity.java:24: warning: [deprecation] replace(int,Fragment) in FragmentTransaction has been deprecated
                .replace(android.R.id.content, new SettingsFragment())
                ^
    /home/michi/development/git/libreoffice-WORKTREE-android/android/source/src/java/org/libreoffice/SettingsActivity.java:25: warning: [deprecation] commit() in FragmentTransaction has been deprecated
                .commit();
                ^
    /home/michi/development/git/libreoffice-WORKTREE-android/android/source/src/java/org/libreoffice/SettingsActivity.java:28: warning: [deprecation] PreferenceFragment in android.preference has been deprecated
        public static class SettingsFragment extends PreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener {
                                                     ^
    /home/michi/development/git/libreoffice-WORKTREE-android/android/source/src/java/org/libreoffice/SettingsActivity.java:28: warning: [deprecation] PreferenceFragment() in PreferenceFragment has been deprecated
        public static class SettingsFragment extends PreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener {
                      ^
    /home/michi/development/git/libreoffice-WORKTREE-android/android/source/src/java/org/libreoffice/SettingsActivity.java:30: warning: [deprecation] onCreate(Bundle) in PreferenceFragment has been deprecated
            public void onCreate(Bundle savedInstanceState) {
                        ^
    /home/michi/development/git/libreoffice-WORKTREE-android/android/source/src/java/org/libreoffice/SettingsActivity.java:31: warning: [deprecation] onCreate(Bundle) in PreferenceFragment has been deprecated
                super.onCreate(savedInstanceState);
                     ^
    /home/michi/development/git/libreoffice-WORKTREE-android/android/source/src/java/org/libreoffice/SettingsActivity.java:32: warning: [deprecation] addPreferencesFromResource(int) in PreferenceFragment has been deprecated
                addPreferencesFromResource(R.xml.libreoffice_preferences);
                ^
    /home/michi/development/git/libreoffice-WORKTREE-android/android/source/src/java/org/libreoffice/SettingsActivity.java:34: warning: [deprecation] PreferenceGroup in android.preference has been deprecated
                    PreferenceGroup generalGroup = (PreferenceGroup) findPreference("PREF_CATEGORY_GENERAL");
                    ^
    /home/michi/development/git/libreoffice-WORKTREE-android/android/source/src/java/org/libreoffice/SettingsActivity.java:34: warning: [deprecation] PreferenceGroup in android.preference has been deprecated
                    PreferenceGroup generalGroup = (PreferenceGroup) findPreference("PREF_CATEGORY_GENERAL");
                                                    ^
    /home/michi/development/git/libreoffice-WORKTREE-android/android/source/src/java/org/libreoffice/SettingsActivity.java:34: warning: [deprecation] findPreference(CharSequence) in PreferenceFragment has been deprecated
                    PreferenceGroup generalGroup = (PreferenceGroup) findPreference("PREF_CATEGORY_GENERAL");
                                                                     ^
    /home/michi/development/git/libreoffice-WORKTREE-android/android/source/src/java/org/libreoffice/SettingsActivity.java:35: warning: [deprecation] findPreference(CharSequence) in PreferenceGroup has been deprecated
                    generalGroup.removePreference(generalGroup.findPreference("ENABLE_EXPERIMENTAL"));
                                                              ^
    /home/michi/development/git/libreoffice-WORKTREE-android/android/source/src/java/org/libreoffice/SettingsActivity.java:35: warning: [deprecation] removePreference(Preference) in PreferenceGroup has been deprecated
                    generalGroup.removePreference(generalGroup.findPreference("ENABLE_EXPERIMENTAL"));
                                ^
    /home/michi/development/git/libreoffice-WORKTREE-android/android/source/src/java/org/libreoffice/SettingsActivity.java:36: warning: [deprecation] findPreference(CharSequence) in PreferenceGroup has been deprecated
                    generalGroup.removePreference(generalGroup.findPreference("ENABLE_DEVELOPER"));
                                                              ^
    /home/michi/development/git/libreoffice-WORKTREE-android/android/source/src/java/org/libreoffice/SettingsActivity.java:36: warning: [deprecation] removePreference(Preference) in PreferenceGroup has been deprecated
                    generalGroup.removePreference(generalGroup.findPreference("ENABLE_DEVELOPER"));
                                ^
    /home/michi/development/git/libreoffice-WORKTREE-android/android/source/src/java/org/libreoffice/SettingsActivity.java:41: warning: [deprecation] onResume() in Fragment has been deprecated
            public void onResume() {
                        ^
    /home/michi/development/git/libreoffice-WORKTREE-android/android/source/src/java/org/libreoffice/SettingsActivity.java:42: warning: [deprecation] onResume() in Fragment has been deprecated
                super.onResume();
                     ^
    /home/michi/development/git/libreoffice-WORKTREE-android/android/source/src/java/org/libreoffice/SettingsActivity.java:43: warning: [deprecation] getPreferenceScreen() in PreferenceFragment has been deprecated
                getPreferenceScreen().getSharedPreferences()
                ^
    /home/michi/development/git/libreoffice-WORKTREE-android/android/source/src/java/org/libreoffice/SettingsActivity.java:43: warning: [deprecation] getSharedPreferences() in Preference has been deprecated
                getPreferenceScreen().getSharedPreferences()
                                     ^
    /home/michi/development/git/libreoffice-WORKTREE-android/android/source/src/java/org/libreoffice/SettingsActivity.java:48: warning: [deprecation] onPause() in Fragment has been deprecated
            public void onPause() {
                        ^
    /home/michi/development/git/libreoffice-WORKTREE-android/android/source/src/java/org/libreoffice/SettingsActivity.java:49: warning: [deprecation] onPause() in Fragment has been deprecated
                super.onPause();
                     ^
    /home/michi/development/git/libreoffice-WORKTREE-android/android/source/src/java/org/libreoffice/SettingsActivity.java:50: warning: [deprecation] getPreferenceScreen() in PreferenceFragment has been deprecated
                getPreferenceScreen().getSharedPreferences()
                ^
    /home/michi/development/git/libreoffice-WORKTREE-android/android/source/src/java/org/libreoffice/SettingsActivity.java:50: warning: [deprecation] getSharedPreferences() in Preference has been deprecated
                getPreferenceScreen().getSharedPreferences()
                                     ^
    /home/michi/development/git/libreoffice-WORKTREE-android/android/source/src/java/org/libreoffice/SettingsActivity.java:58: warning: [deprecation] getActivity() in Fragment has been deprecated

[1] https://developer.android.com/reference/android/preference/PreferenceFragment
[2] https://developer.android.com/reference/androidx/preference/package-summary

Change-Id: I3365a487345787056c91fa7addf987edca38e94f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167717
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-05-16 12:13:24 +02:00
7b0d2829fe android: Port to non-deprecated androidx PreferenceManager
The `android.preference.PreferenceManager` class was
deprecated in API level 29 [1].

Port to `androidx.preference.PreferenceManager` from
the AndroidX Preference library instead.

All that needs to be done for this is to add the new library
dependency and adjust the import, no further code changes
needed for this step. (There are uses of more deprecated
preferences-related classes, though. Those will have to be
dealt with separately.)

This addresses depreaction warnings like

    > Task :compileStrippedUIEditingDebugJavaWithJavac
    /home/michi/development/git/libreoffice-WORKTREE-android/android/source/src/java/org/libreoffice/LibreOfficeMainActivity.java:16: warning: [deprecation] PreferenceManager in android.preference has been deprecated
    import android.preference.PreferenceManager;
                             ^

[1] https://developer.android.com/reference/android/preference/PreferenceManager

Change-Id: Ied168ffbd0591d69e0797e2a0a5bab067e133d22
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167716
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Tested-by: Jenkins
2024-05-16 12:13:18 +02:00
e99991216e android: Fix taking photos by dropping permission
At least on recent devices (seen e.g. on an AVD
with API level 34 and a Fairphone 3 with LineageOS 20
(based on Android 13)), inserting a picture by
taking a photo using the camera didn't work,
"nothing was happening" when choosing the corresponding
option from the formatting toolbar with experimental
editing mode enabled.

This is due to the system filtering information about
other apps/packages with target API level >= 30 for
privacy reasons, see [1] for more details.

As described at [2], requesting the `CAMERA`
permission is not required:

> Users might take pictures in your app, using the pre-installed
> system camera app.
>
> In this situation, don't declare the CAMERA permission. Instead,
> invoke the ACTION_IMAGE_CAPTURE intent action.

In fact, specifying the permission is even counter-productive
and would cause this to not work, as also described at [2]:

> Note: If your app declares Manifest.permission.CAMERA
> permission and is not granted, then the action results in
> a SecurityException.

Rather than explicitly requesting the permission, just
drop it from the AndroidManifest, as it's not needed.
Also drop the additional code interacting with the package
manager, as that doesn't work with newer API
versions as described above.

With these changes in place, inserting a photo works fine
in tests in API 21 and API 34 AVDs and on the
above-mentioned Fairphone 3.

[1] https://developer.android.com/training/package-visibility
[2] https://developer.android.com/privacy-and-security/minimize-permission-requests#take-photo

Change-Id: Ia1ee4e4de577a269e2b79bf5460d08b1bf2bee56
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167603
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Tested-by: Jenkins
2024-05-14 08:37:49 +02:00
5ad26dfac2 android: Don't restrict taking photo to rear camera
Check for `FEATURE_CAMERA_ANY` ("The device has at least
one camera pointing in some direction, or can support an
external camera being connected to it.") [1] instead
of only the rear camera via `FEATURE_CAMERA`
("The device has a camera facing away from the screen.") [2]
when taking a photo is selected in the "Insert" menu, as
there's no need to restrict this to the rear camera.

This addresses this warning shown in Android Studio:

> You should look for any camera available on the device, not just the rear

Note however that trying to use that feature (with or
without this change in place) currently doesn't actually
work at least on a current device (e.g. an API 34 AVD),
"nothing happens" rather than the camera showing up to
be able to take a photo. This will be addressed
in an upcoming commit.

[1] https://developer.android.com/reference/android/content/pm/PackageManager#FEATURE_CAMERA_ANY
[2] https://developer.android.com/reference/android/content/pm/PackageManager#FEATURE_CAMERA

Change-Id: I52d2147df8fb3f1fdfb277376d7796380f9a8da0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167602
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-05-14 08:37:43 +02:00
4bba7fbc22 android lint: Add API level check for EXTRA_INITIAL_URI
`DocumentsContract.EXTRA_INITIAL_URI` was added in API level 26,
so only set it conditionally when that API level is avaible.

Change-Id: I6783e89f50354c017968b74cc45fb1a3b6faab83
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160468
Tested-by: Jenkins
Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com>
2023-12-11 19:04:49 +01:00
c2fc2c8c7c android: Bump minSdkVersion to 21 (Android 5.0)
NDK 26 dropped support for API levels < 21 [1] [2].
Do the same for our Android build, to ease the
maintenance.

Adapt configure.ac accordingly and drop the
now obsolete code paths in Android Viewer
Java code.

This in also means that the same minSdkVersion will
be used for all architectures now, while API level 21
was already used for the 64-bit variants (for which
the minimum supported version was 21 anyway) and
API level 19 was used for x86 and 32-bit ARM when
building with NDK 24/25, API level 16 when building
with NDK 23.

According to [1] and [3], more than 99% of
Android devices have at least Android version 5,
i.e. support API level 21.

[1] https://github.com/android/ndk/issues/1751
[2] https://developer.android.com/ndk/downloads/revision_history
[3] https://apilevels.com/

Change-Id: I875e784dd4e62993f51059ae6a280d425cb49c0a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160334
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2023-12-08 10:39:37 +01:00
35b7aa3a86 android: Separate build ID and vendor from versionName
So far, the versionName for the LibreOffice APK/app bundle
included the build ID and vendor, was e.g.
"24.2.0.0.alpha1+/2972af9045a5/The Document Foundation".

That versionName would be split again to extract the build ID
and vendor to display them in the about dialog.

No longer include build ID and vendor in the `versionName`,
but use separate build config variables, similar to what
is done for the privacy policy.

This slightly simplifies the code for the about dialog.

But more importantly, the previous `versionName` scheme
would make it impossible to automate the F-Droid update
of the app, because the scheme is not compatible with
the expectations of F-Droid's update mechanism, see the
F-Droid merge request to update LibreOffice Viewer to 7.6.3 [1]
for more details, in particular the (eventually not merged)
commit [2] mentioning what manual steps would still be needed
when trying to semi-automate the update at least.

[1] https://gitlab.com/fdroid/fdroiddata/-/merge_requests/14080
[2] https://gitlab.com/fdroid/fdroiddata/-/merge_requests/14080/diffs?commit_id=bfc062a358dc574326a29f08e01c0e80cadd80cb

Change-Id: Ibede06d13095d8e83dcc88ee09a8a610d6a9de0f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160150
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2023-11-30 14:40:24 +01:00
3ee963afc7 android: Simplify vendor info handling for about dialog
Similar to

    Change-Id: Iaa78f5a6020bea4ed80a1b41d3b23cc8d313813c
    Author: Michael Weghorn <m.weghorn@posteo.de>
    Date:   Thu Nov 30 12:00:52 2023 +0100

    android: Simplify version info handling for about dialog

, also simplify the handling of the vendor info text by
retrieving the text from the string resource right away.

Change-Id: I7d56b1814454be2bc8d13e01265f0a0db6d865be
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160147
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2023-11-30 14:40:08 +01:00
4958e21332 android: Simplify version info handling for about dialog
* Don't set and retrieve the placeholder text in/from
  the TexView in the about dialog, but use the string
  resource directly.
* Add the HTML code directly in the string resource,
  rather than having to fiddle with that in the Java
  code.

With this in place, only the version name and the
commit hash need to be replaced.

Since there is no placeholder text in the text view,
it's also no longer necessary to explicitly set an
empty string in case of an exception.

Change-Id: Iaa78f5a6020bea4ed80a1b41d3b23cc8d313813c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160146
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2023-11-30 14:39:59 +01:00
322f8e8cb7 tdf#124480 android: Use an actual button for "Select file to open"
Instead of using a TextView and setting `?attr/colorButtonNormal`
for the background color, just use a button right away, which also
makes sure that the proper button color is used and avoids
using `colorButtonNormal` only available from API level 21 on. [1]

Also drop the extra `LinearLayout` parent that was only containing
this one TextView.

While at it, drop an unused import.

[1] https://developer.android.com/reference/android/R.attr#colorButtonNormal

Change-Id: Ie2f7e2646d20f4051fb2513fb8fd72572ce19217
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160076
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2023-11-30 12:17:07 +01:00
d134615570 tdf#158398 android: Draw light gray background for Calc headers
Similar to the desktop version, use a light gray background
color for the Calc header cells.

There was already code in place to draw darker gray background
to highlight the header cell when a cell in that row/column is
selected.
(The actually highlighted header cell didn't wasn't always the
correct one in a quick test, but that's independent of this change.)

Adapt that to always fill the rectangle, but use a lighter gray
(lower alpha value) when not selected.
Use a separate `Paint` object for the frame (stroke).
Set the frame color and text color to black instead of gray, for
better contrast to the light gray fill/background.

Change-Id: I0490811e928ebd1b3840242fc1aa4682b2786b00
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159989
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2023-11-27 14:04:21 +01:00
7c7e044f3c tdf#158398 android: Center Calc header text
Center the header text in the Calc header cell, to
make better use of the space. This is in line with
what the desktop version also does.

Setting the text alignment to `Paint.Align.CENTER`
is sufficient for centering horizontally.
There's no equivalent for centering vertically, so
calculate the position based on the text bounds.

Change-Id: Ia8d5d8434b703cb7daecd34ae70405883f22f0d5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159988
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2023-11-27 14:04:13 +01:00
808a94d859 android: Make CalcHeaderCell fields final
Change-Id: I7e14145569428a2803f9376cf719e524aa8963a8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159987
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2023-11-27 14:04:04 +01:00
872d26d4a8 android: Suggest file name for PDF export
When using the PDF export feature in Android Viewer,
suggest a file name for the PDF file that matches
the current display name (which is usually the
file name, or "untitled" for a newly created doc
that hasn't been saved yet).

This can be achieved by setting `Intent.EXTRA_TITLE`
for the `ACTION_CREATE_DOCUMENT`. [1]

The `DocumentsContract.EXTRA_INITIAL_URI` already
set previously already results in the same
directory as the doc being preselected in the
file chooser:

> Callers can set a document URI through
> DocumentsContract#EXTRA_INITIAL_URI to indicate the initial location of
> documents navigator. System will do its best to launch the navigator in
> the specified document if it's a folder, or the folder that contains the
> specified document if not.

Filling in the current file name was suggested
in a Google Play review comment for the app.

[1] https://developer.android.com/reference/android/content/Intent#ACTION_CREATE_DOCUMENT

Change-Id: Idbd4a89416089f927e0232ce65161b43059ca46d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159959
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2023-11-26 18:07:37 +01:00
934a4937e3 tdf#158331 android: Fix "Save As" for non-experimental mode
While "Save" (i.e. saving back to the original location)
doesn't make sense when editing is disabled (because the
doc cannot be changed) and the menu entry is therefore
not available when the experimental editing mode is
disabled, "Save As" does make sense, e.g. in order to
save a copy of a file opened from another app.

The menu entry was there, but not working as expected,
a 0-byte file was created.

This is because `LibreOfficeMainActivity#saveFileToOriginalSource`
would return early if experimental mode is disabled.
No longer do that, but save the file as requested.

Change-Id: I5785b6060c4ba9cdf3e9c3591b9f941ab987bf4f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159857
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2023-11-23 13:20:56 +01:00
129c493adc android: Reuse launcher icon in activities
Instead of duplicating the icon as drawable,
just use the one from the mipmap folder that's
used for the app launcher.

Change-Id: Idd6691c4639fb570357280cec63636d07fe06b20
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159553
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2023-11-17 12:35:38 +01:00
f9b9e70246 android: Add button to open privacy URL
In the About dialog, add a "Privacy Policy"
button when a privacy URL is set, i.e.
the `--with-privacy-policy-url=<URL>` autogen
option is used.
Clicking the button will fire an Intent
to open that URL.

Use a custom build config field as described at [1]
to make the privacy policy URL available to
the Java code.

[1] https://developer.android.com/build/gradle-tips#share-custom-fields-and-resource-values-with-your-app-code

Change-Id: I6e1a9aff885e4ce132284f49e722b3343fc51b79
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159445
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2023-11-15 18:26:41 +01:00
1d7b1e2d40 android: Drop "More Info" item in "About" dialog
Drop the "More Info" button from the dialog, which
opened a sample document with more information
about LibreOffice.

There's already a link to the website, and the
"neutral" button in that dialog will be reintroduced
to show the privacy policy instead, if set.
(An `AlertDialog` has at most 3 buttons.)

Change-Id: Ib760daba1ed6f8cfc26eefc7412553bf97c77d70
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159444
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2023-11-15 18:26:33 +01:00
c5c2d31951 android: Drop unused LayerView#mFullScreen
... and the getters and setters.

Change-Id: I14e69e2543d92dc63954bc3faf5a7456d2343fff
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159200
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2023-11-09 14:40:43 +01:00
f324220e87 android: Drop Robocop comment
Robocop is a tool for UI-testing fore Firefox on Android [1],
but not used for LibreOffice Viewer, so drop the misleading
comment.

[1] https://wiki.mozilla.org/Auto-tools/Projects/Robocop

Change-Id: I270735b2258f18691f60865c683856d58a94bb04
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159199
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2023-11-09 13:18:17 +01:00
aef1b023d5 android: Drop never-assigned to LayerRenderer#mPixelBuffer
That member was never assigned a value but only read
from by code claiming to be "used by robocop for testing purposes".

[1] describes Robocop as a UI-level testing framework for Firefox
for Android, which we don't use, so drop the class member and
related test code.

[1] https://wiki.mozilla.org/Auto-tools/Projects/Robocop

Change-Id: I467296874d4295060cc9670d1f1c8b0dfeb77523
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159198
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2023-11-09 13:18:11 +01:00
d9a43fa5f9 tdf#158125 android: Don't insist on RGB 565 EGL config
As the `eglChooseConfig` doc [1] says:

> eglChooseConfig returns in configs a list of all EGL frame buffer
> configurations that match the attributes specified
> [...]
> Attributes are matched in an attribute-specific manner. Some of the
> attributes, such as EGL_LEVEL, must match the specified value exactly.
> Others, such as, EGL_RED_SIZE must meet or exceed the specified minimum
> values.

The config/attribute list used for Android Viewer specifies
EGL_RED_SIZE=5, EGL_GREEN_SIZE=6, and EGL_BLUE_SIZE=5 and so
far, only configs using exactly those bit sizes were accepted,
causing 1 of the 11 devices used in automated tests in Google Play CI
crashing with this stack trace:

    Exception org.mozilla.gecko.gfx.GLController$GLControllerException: No suitable EGL configuration found
      at org.mozilla.gecko.gfx.GLController.chooseConfig (GLController.java:219)
      at org.mozilla.gecko.gfx.GLController.initEGL (GLController.java:172)
      at org.mozilla.gecko.gfx.GLController.initEGLContext (GLController.java:176)
      at org.mozilla.gecko.gfx.GLController.initGLContext (GLController.java:57)
      at org.mozilla.gecko.gfx.RenderControllerThread.doSurfaceCreated (RenderControllerThread.java:132)
      at org.mozilla.gecko.gfx.RenderControllerThread.execute (RenderControllerThread.java:52)
      at org.mozilla.gecko.gfx.RenderControllerThread.run (RenderControllerThread.java:30)

Since only configs fulfilling the minimium specification
have been returned, I don't see a reason to insist on
having one that uses exactly the specified amount of bits
for the individual color components.

I also didn't see any rendering issues in a quick test (also using
the colorful Calc sheet attachment 188343 from tdf#156182) forcing the
use of a configuration using EGL_RED_SIZE=8, EGL_GREEN_SIZE=8, and
EGL_BLUE_SIZE=8 with an x86_64 AVD and on a Fairphone 3+ (arm64)
using this temporary local change:

    diff --git a/android/source/src/java/org/mozilla/gecko/gfx/GLController.java b/android/source/src/java/org/mozilla/gecko/gfx/GLController.java
    index 45600e9f1e7c..9e7f348e9e72 100644
    --- a/android/source/src/java/org/mozilla/gecko/gfx/GLController.java
    +++ b/android/source/src/java/org/mozilla/gecko/gfx/GLController.java
    @@ -171,7 +171,7 @@ public class GLController {
                 mEGL.eglGetConfigAttrib(mEGLDisplay, config, EGL10.EGL_RED_SIZE, red);
                 mEGL.eglGetConfigAttrib(mEGLDisplay, config, EGL10.EGL_GREEN_SIZE, green);
                 mEGL.eglGetConfigAttrib(mEGLDisplay, config, EGL10.EGL_BLUE_SIZE, blue);
    -            if (red[0] == 5 && green[0] == 6 && blue[0] == 5) {
    +            if (red[0] == 8 && green[0] == 8 && blue[0] == 8) {
                     return config;
                 }
             }

Therefore, fall back to using another config that fulfils the
specification.
(Leave the previously required config as preferred one for now,
maybe it still has advantages, e.g. might be more efficient due
to not wasting extra bits for the color components that are
not needed for the rendering in LibreOffice Viewer. (?))

[1] https://registry.khronos.org/EGL/sdk/docs/man/html/eglChooseConfig.xhtml

Change-Id: I953d292248004bc6f7e9384ceef78c8a88c21e9e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159204
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2023-11-09 13:16:16 +01:00
560cb9c53e android: Drop obsolete TODO comment
This comment was originally for the code
underneath, that has already been separated
into a separate method in gecko-dev commit [1]

    commit 60ed20fee4095523ee498579c71fc17032d1004b
    Author: Patrick Walton <pwalton@mozilla.com>
    Date:   Mon Feb 13 12:27:09 2012 -0800

        Split out Java compositor shader program activation and deactivation into separate functions

, but the comment was left behind.

[1] 60ed20fee4

Change-Id: Ied0a4aaec4d8228665748b834026b54c8e9615bc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159184
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2023-11-09 07:56:07 +01:00
f435857825 android: Drop unused GLController#checkForLostContext
Change-Id: Ia9f313a1937d4d491b76e9e5d6e4689eeb20431b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159183
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2023-11-09 07:55:53 +01:00
46c0c48990 android: Cast to GL10 in getter, not callers
Better have a clear method signature than callers
relying on implementation details.

Change-Id: I4532f67aee8f8eac723401e43d3b6856ba37b346
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159182
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2023-11-09 07:55:44 +01:00
b6e5a8d60b android: Use local var instead of 'mGL' member
It's never used except where it's also previously
assigned, so use a local variable instead.

Even the getter `GLController#getGL` gets
it from the EGLContext instead of using the
member.

Change-Id: Icec909f6e3e508a16fb455e81474bb336dc09362
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159181
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2023-11-09 07:55:32 +01:00
e4a56c1996 android: Use local var instead of class member
It's only used in this one place.

Change-Id: Ia11ebc2ea60c4015698ac00bbec6711a20c0a22e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159168
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2023-11-09 07:55:18 +01:00
3cedd0780e android: Drop unused LayerRenderer#Frame#getMaskForLayer
Unused since

    commit 96a498b44c0a0ca48ac9938d9414191850d47d18
    Date:   Fri Dec 19 16:24:02 2014 +0900

        android: remove screenshot layer

Change-Id: I3b83596bb854cb4bdfc6281ca487c8be15bc61d0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159167
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2023-11-09 07:55:09 +01:00
61bfc27f04 android: Drop LayerRenderer#Frame#mFrameStartTime
The member is assigned a value that is never used, so just drop it.

Might have been more useful before

    commit 8734422b0b85b54c3fccc2b678171ed174c2b8bd
    Date:   Mon Feb 23 20:53:35 2015 +0900

        android: remove DrawTimingQueue and PanningPerfAPI

Change-Id: Ieec958c0d5a75fc47af467c73b218d6150ceaab4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159166
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2023-11-09 07:55:01 +01:00
120e76b45b android: Inline LayerRenderer#createFrame
No need for an extra method just to call the ctor,
and which is only used once.

Change-Id: Ide909ad81c78dc822a721771ee068e0240750089
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159165
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2023-11-09 07:54:53 +01:00
8b3f0a66b4 android: Add "@Override"
... to make clear that these are overriden methods from
the `GLSurfaceView.Renderer` interface.

Change-Id: I7ffc47ee8a7ca4b481f7d28c0a5084c89d9c7ae8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159164
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2023-11-09 07:54:44 +01:00
ae61af8364 android: Drop misleading comments wrt methods invoked via JNI
These methods are not invoked via JNI for LibreOffice Viewer.
It might have been true for Fennec/Gecko, but isn't here, so
drop the misleading comments.

Change-Id: Ib3187b129f076f42706b3097f9535a7cca7ad55f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159163
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2023-11-09 07:54:34 +01:00
30a981cc20 android: Drop unused LayerView#registerCxxCompositor
The comment saying it's called via JNI is not true
for LibreOffice Viewer, is probably from Gecko/Fennec
days like the ones for previously dropped methods.

Now that the method is gone, `mContext` no longer
needs to be static, so make it non-static and drop
the corresponding TODO comment.

Change-Id: I32db3728234715bc29af1ad757c715003c70ca4b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159162
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2023-11-09 07:54:24 +01:00
d088e3cfc5 android: Drop unused LayerView#{g,s}etPaintState
... and the now also unused `mPaintState` member and
related constants.

Change-Id: Iefd40ca4a72d32807b136830833e88e250f8f38b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159161
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2023-11-09 07:54:16 +01:00
0a5bf928d9 android: Drop unused GLController#waitForValidSurface
The method is unused, so drop it, and also the now never
read `mSurfaceValid` member.

Likely, the comment that the method is invoked via JNI
was never valid for LibreOffice Viewer, but is from Gecko/Fennec
days, similar to the case in the previous commit,

    Change-Id I54dd33a2ce30ebdc375a7c1fefacca6e99d2f571
    Author: Michael Weghorn <m.weghorn@posteo.de>
    Date:   Wed Nov 8 15:10:19 2023 +0100

        android: Drop unused GLController#resumeCompositorIfValid etc.

Change-Id: I165d2c7ebf5b9ce940b608d738d9a10d5bef69ea
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159160
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2023-11-09 07:54:08 +01:00
3242398926 android: Drop unused GLController#resumeCompositorIfValid etc.
The comment claiming that this function is invoked
by JNI was true when the method was added upstream
in Fennec/Gecko in commit [1]

    commit ae9420729da323d02a3f2f02d5a4b3043a619007
    Author: Kartikaya Gupta <kgupta@mozilla.com>
    Date:   Fri Jul 13 10:19:46 2012 -0400

        Bug 769269 - Update the graphics code to be able to deal with blowing away the layer controller, client, and view and creating them afresh. r=ajuma

, but it's not true for the copy here in
Android Viewer, so drop the unused method
and `RenderControllerThread#compositionResumeRequested`
that would only have been called from there and wouldn't
have done anything anyway.

[1] ae9420729d

Change-Id: I54dd33a2ce30ebdc375a7c1fefacca6e99d2f571
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159159
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2023-11-09 07:54:01 +01:00
9032551306 android: Drop unused GLController#provideEGLSurface
It was already unused when added in

    commit a6ecd8b2a9f0f3eaa66388861a6dcc6260ec72b9
    Date:   Thu Jun 26 11:22:21 2014 +0200

        LOAndroid3: ant/make for building, Bootstrap project

The method looks similar to the first half of
`GLController#provideEGLSurface` and is unused,
so drop  it.

Change-Id: I0cabfddefcdcca97048cb6f494590afdde5c1dc7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159158
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2023-11-09 07:53:52 +01:00
9844a197bf tdf#147906 used StrictMath.hypot for Pythagorean addition
Change-Id: I529dc199c2cc20ce91b7181f650c36db8d81fc9c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157098
Reviewed-by: Bartosz Kosiorek <gang65@poczta.onet.pl>
Tested-by: Ilmari Lauhakangas <ilmari.lauhakangas@libreoffice.org>
Reviewed-by: Ilmari Lauhakangas <ilmari.lauhakangas@libreoffice.org>
2023-09-21 07:15:22 +02:00
60e804f31c android: Drop unused TextureView
It's unused since

    commit 3860bff1013f9608b934c4cdb9ddb8d2dbbc3e52
    Date:   Fri Dec 19 16:25:23 2014 +0900

        android: never use TextureView for now (for performance reasons)

        Get align with latest Fennec code which also has this disabled.

        Change-Id: Ie4c27935bacd29218207e47593f073bdce0cf7e3

Change-Id: I808ce73928120c10f4e3721a11b1e74bac3a413c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147196
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2023-02-17 12:06:41 +00:00
b60fc720d7 android: Drop unused LayerView#isIMEEEnabled
... that always returns false anyway.

(And the `InputConnectionHandler#isIMEEnabled`
that would be called in the commented out code
doesn't exist either.)

Change-Id: I6031672ee2835c64a1efcab946574ca2ce94b6a1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147195
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2023-02-17 12:06:31 +00:00
08cfcea7fe tdf#147906 Use Math.hypot() for Pythagorean addition
Change-Id: I644947ca22f493bbc805c45334450db8d4b4808b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146137
Tested-by: Hossein <hossein@libreoffice.org>
Reviewed-by: Hossein <hossein@libreoffice.org>
2023-02-06 18:37:58 +00:00
f5e4a54f8c android: Hide UI to creat new files for SDK version < 19
Just like for the the case where editing is disabled
(s. Change-Id I2f8c86f5db96a5135ff8a66a7a7078b664d05a5e,
"android: Only offer creating docs when editing enabled"),
just hide the UI to create new files when running on devices
that don't support `Intent.ACTION_CREATE_DOCUMENT`, rather
than showing the button, but then showing a message that
creating files is not supported once the button is clicked.

Change-Id: Ifedf40e22dc8906557d5364ecf9ec3a9db2315e6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145736
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2023-01-18 13:03:54 +00:00
5e4bcb501f android: Only offer creating docs when editing enabled
Hide the UI to create new documents unless the
experimental editing mode is enabled. There is
little use in creating new empty documents when there
is no way to edit them...

Change-Id: I2f8c86f5db96a5135ff8a66a7a7078b664d05a5e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145735
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2023-01-18 13:03:46 +00:00