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

Commit 0b3f300a authored by Ben Lin's avatar Ben Lin Committed by Android (Google) Code Review
Browse files

Merge "Update Authentication UI strings to match Android UX spec." into oc-dev

parents fe18b6f1 62d54bac
Loading
Loading
Loading
Loading
+6 −3
Original line number Original line Diff line number Diff line
@@ -341,10 +341,13 @@
    <string name="name_conflict">A file with this name already exists.</string>
    <string name="name_conflict">A file with this name already exists.</string>


    <!-- Error message shown when more authentication is necessary to view files  -->
    <!-- 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 -->
    <!-- Error message shown when content cannot be displayed due to lack of authentication -->
    <string name="open_app">Open <xliff:g id="name" example="Cloud Storage">%1$s</xliff:g></string>
    <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). -->
    <!-- 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>
    <string name="new_archive_file_name">archive<xliff:g id="extension" example=".zip">%s</xliff:g></string>
+14 −5
Original line number Original line Diff line number Diff line
@@ -22,6 +22,7 @@ import android.app.PendingIntent;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.Drawable;
import android.util.Log;
import android.util.Log;


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


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



        private void updateToInflatedErrorMesage(@Nullable String debugString) {
        private void updateToInflatedErrorMesage(@Nullable String debugString) {
            if (debugString == null) {
            if (debugString == null) {
                update(mEnv.getContext().getResources().getText(R.string.query_error), 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() {
        private void updateToInflatedEmptyMessage() {
            final CharSequence message;
            final CharSequence message;
            if (mEnv.isInSearchMode()) {
            if (mEnv.isInSearchMode()) {
+1 −1
Original line number Original line Diff line number Diff line
@@ -66,7 +66,7 @@ public class FilesActivityUiTest extends ActivityTest<FilesActivity> {
        bots.main.switchToListMode();
        bots.main.switchToListMode();
        bots.directory.openDocument("throw a authentication exception");
        bots.directory.openDocument("throw a authentication exception");
        bots.directory.assertHeaderMessageText(
        bots.directory.assertHeaderMessageText(
                "Authentication is required to see the content of this directory");
                "To view this directory, sign in to DocumentsUI Tests");


    }
    }