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

Commit 6a1754e8 authored by Kelvin Kwan's avatar Kelvin Kwan Committed by Automerger Merge Worker
Browse files

Merge "Show a spinner when user click on cross profile button" into rvc-dev am: fa6e14ca

Change-Id: I41e290a02f624ddac8ebe055c8ad9059af5aa3db
parents 37595a4f fa6e14ca
Loading
Loading
Loading
Loading
+37 −20
Original line number Diff line number Diff line
@@ -25,6 +25,22 @@
    android:paddingStart="72dp"
    android:paddingEnd="72dp">

    <ProgressBar
        android:id="@+id/cross_profile_progress"
        style="@android:style/Widget.Material.Light.ProgressBar"
        android:visibility="gone"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:indeterminate="true"
        android:indeterminateTint="?attr/colorAccent"/>

    <LinearLayout
        android:id="@+id/cross_profile_content"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:gravity="center_horizontal">

        <ImageView
            android:id="@+id/artwork"
            android:layout_width="24dp"
@@ -49,3 +65,4 @@
            android:layout_height="wrap_content"
            style="@style/EmptyStateButton"/>
    </LinearLayout>
</LinearLayout>
+5 −0
Original line number Diff line number Diff line
@@ -176,6 +176,11 @@ public abstract class AbstractActionHandler<T extends FragmentActivity & CommonA
        }
    }

    @Override
    public void requestQuietModeDisabled(RootInfo info, UserId userId) {
        new RequestQuietModeDisabledTask(mActivity, userId).execute();
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        switch (requestCode) {
+2 −0
Original line number Diff line number Diff line
@@ -89,6 +89,8 @@ public interface ActionHandler {
     */
    void startAuthentication(PendingIntent intent);

    void requestQuietModeDisabled(RootInfo info, UserId userId);

    void showAppDetails(ResolveInfo info, UserId userId);

    void openRoot(RootInfo root);
+49 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2020 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.documentsui;

import static androidx.core.util.Preconditions.checkNotNull;

import android.content.Context;
import android.os.AsyncTask;

import com.android.documentsui.base.UserId;

import java.lang.ref.WeakReference;

/**
 * A task to request disabling quiet mode for a given user.
 */
class RequestQuietModeDisabledTask extends AsyncTask<Void, Void, Void> {

    private final WeakReference<Context> mContextWeakReference;
    private final UserId mUserId;

    RequestQuietModeDisabledTask(Context context, UserId userId) {
        mContextWeakReference = new WeakReference<>(checkNotNull(context));
        mUserId = checkNotNull(userId);
    }

    @Override
    protected Void doInBackground(Void... voids) {
        Context context = mContextWeakReference.get();
        if (context != null) {
            mUserId.requestQuietModeDisabled(context);
        }
        return null;
    }
}
+12 −2
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;

import com.android.documentsui.R;
@@ -47,11 +48,15 @@ final class InflateMessageDocumentHolder extends MessageHolder {

    private View mContentView;
    private View mCrossProfileView;
    private View mCrossProfileContent;
    private ProgressBar mCrossProfileProgress;

    public InflateMessageDocumentHolder(Context context, ViewGroup parent) {
        super(context, parent, R.layout.item_doc_inflated_message);
        mContentView = itemView.findViewById(R.id.content);
        mCrossProfileView = itemView.findViewById(R.id.cross_profile);
        mCrossProfileContent = mCrossProfileView.findViewById(R.id.cross_profile_content);
        mCrossProfileProgress = mCrossProfileView.findViewById(R.id.cross_profile_progress);

        mContentMessage = mContentView.findViewById(R.id.message);
        mContentImage = mContentView.findViewById(R.id.artwork);
@@ -76,7 +81,9 @@ final class InflateMessageDocumentHolder extends MessageHolder {
        }
    }

    private void onButtonClick(View button) {
    private void onCrossProfileButtonClick(View button) {
        mCrossProfileContent.setVisibility(View.GONE);
        mCrossProfileProgress.setVisibility(View.VISIBLE);
        mMessage.runCallback();
    }

@@ -91,6 +98,9 @@ final class InflateMessageDocumentHolder extends MessageHolder {
    private void bindCrossProfileMessageView() {
        mContentView.setVisibility(View.GONE);
        mCrossProfileView.setVisibility(View.VISIBLE);
        mCrossProfileContent.setVisibility(View.VISIBLE);
        mCrossProfileProgress.setVisibility(View.GONE);

        mCrossProfileTitle.setText(mMessage.getTitleString());
        if (!TextUtils.isEmpty(mMessage.getMessageString())) {
            mCrossProfileMessage.setVisibility(View.VISIBLE);
@@ -102,7 +112,7 @@ final class InflateMessageDocumentHolder extends MessageHolder {
        if (!TextUtils.isEmpty(mMessage.getButtonString())) {
            mCrossProfileButton.setVisibility(View.VISIBLE);
            mCrossProfileButton.setText(mMessage.getButtonString());
            mCrossProfileButton.setOnClickListener(this::onButtonClick);
            mCrossProfileButton.setOnClickListener(this::onCrossProfileButtonClick);
        } else {
            mCrossProfileButton.setVisibility(View.GONE);
        }
Loading