Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 62d54bac authored by Ben Lin's avatar Ben Lin
Browse files

Update Authentication UI strings to match Android UX spec.

Test: Updated UI test, passing.
Bug: 36869182
Bug: 36869091
Change-Id: Ib3538c6607a852d436469b34d94b66f3534e9083
parent dd3af83f
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -341,10 +341,13 @@
    <string name="name_conflict">A file with this name already exists.</string>

    <!-- Error message shown when more authentication is necessary to view files  -->
    <string name="authentication_required">Authentication is required to see the content of this directory</string>
    <string name="authentication_required">To view this directory, sign in to <xliff:g id="name" example="Cloud Storage">%1$s</xliff:g></string>

    <!-- Text shown on button to open an application -->
    <string name="open_app">Open <xliff:g id="name" example="Cloud Storage">%1$s</xliff:g></string>
    <!-- Error message shown when content cannot be displayed due to lack of authentication -->
    <string name="cant_display_content">Can\u2019t display contents</string>

    <!-- Text shown on button to open an application that needs user to sign in -->
    <string name="sign_in">Sign in</string>

    <!-- File name of an archive file created when compressing files, without the file extension (.zip). -->
    <string name="new_archive_file_name">archive<xliff:g id="extension" example=".zip">%s</xliff:g></string>
+14 −5
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import android.app.PendingIntent;
import android.graphics.drawable.Drawable;
import android.util.Log;

import com.android.documentsui.DocumentsApplication;
import com.android.documentsui.Model.Update;
import com.android.documentsui.R;
import com.android.documentsui.base.RootInfo;
@@ -106,7 +107,7 @@ abstract class Message {
            // TODO: These should be different Message objects getting updated instead of
            // overwriting.
            if (event.hasAuthenticationException()) {
                updateToRecoverableExceptionHeader(event);
                updateToAuthenticationExceptionHeader(event);
            } else if (mEnv.getModel().error != null) {
                update(mEnv.getModel().error, null,
                        mEnv.getContext().getDrawable(R.drawable.ic_dialog_alert));
@@ -116,12 +117,14 @@ abstract class Message {
            }
        }

        private void updateToRecoverableExceptionHeader(Update event) {
        private void updateToAuthenticationExceptionHeader(Update event) {
            assert(mEnv.getFeatures().isRemoteActionsEnabled());

            RootInfo root = mEnv.getDisplayState().stack.getRoot();
            update(mEnv.getContext().getResources().getText(R.string.authentication_required),
                    mEnv.getContext().getString(R.string.open_app, root.title),
            String appName = DocumentsApplication
                    .getProvidersCache(mEnv.getContext()).getApplicationName(root.authority);
            update(mEnv.getContext().getString(R.string.authentication_required, appName),
                    mEnv.getContext().getResources().getText(R.string.sign_in),
                    mEnv.getContext().getDrawable(R.drawable.ic_dialog_info));
            mCallback = () -> {
                AuthenticationRequiredException exception =
@@ -147,12 +150,13 @@ abstract class Message {
            if (event.hasException() && !event.hasAuthenticationException()) {
                updateToInflatedErrorMesage(
                        Shared.DEBUG ? Shared.getStackTrace(event.getException()) : null);
            } else if (event.hasAuthenticationException()) {
                updateToCantDisplayContentMessage();
            } else if (mEnv.getModel().getModelIds().length == 0) {
                updateToInflatedEmptyMessage();
            }
        }


        private void updateToInflatedErrorMesage(@Nullable String debugString) {
            if (debugString == null) {
                update(mEnv.getContext().getResources().getText(R.string.query_error), null,
@@ -163,6 +167,11 @@ abstract class Message {
            }
        }

        private void updateToCantDisplayContentMessage() {
            update(mEnv.getContext().getResources().getText(R.string.cant_display_content), null,
                    mEnv.getContext().getDrawable(R.drawable.cabinet));
        }

        private void updateToInflatedEmptyMessage() {
            final CharSequence message;
            if (mEnv.isInSearchMode()) {
+1 −1
Original line number Diff line number Diff line
@@ -66,7 +66,7 @@ public class FilesActivityUiTest extends ActivityTest<FilesActivity> {
        bots.main.switchToListMode();
        bots.directory.openDocument("throw a authentication exception");
        bots.directory.assertHeaderMessageText(
                "Authentication is required to see the content of this directory");
                "To view this directory, sign in to DocumentsUI Tests");

    }