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

Commit 2d41d21a authored by Liran Binyamin's avatar Liran Binyamin Committed by Android (Google) Code Review
Browse files

Merge "Minor kotlin cleanup" into main

parents 7d960039 4a4e7788
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -1291,7 +1291,7 @@ public class BubbleStackView extends FrameLayout
            // We only show user education for conversation bubbles right now
            return false;
        }
        final boolean seen = getPrefBoolean(ManageEducationViewKt.PREF_MANAGED_EDUCATION);
        final boolean seen = getPrefBoolean(ManageEducationView.PREF_MANAGED_EDUCATION);
        final boolean shouldShow = (!seen || BubbleDebugConfig.forceShowUserEducation(mContext))
                && mExpandedBubble != null && mExpandedBubble.getExpandedView() != null;
        if (BubbleDebugConfig.DEBUG_USER_EDUCATION) {
@@ -1342,7 +1342,7 @@ public class BubbleStackView extends FrameLayout
            // We only show user education for conversation bubbles right now
            return false;
        }
        final boolean seen = getPrefBoolean(StackEducationViewKt.PREF_STACK_EDUCATION);
        final boolean seen = getPrefBoolean(StackEducationView.PREF_STACK_EDUCATION);
        final boolean shouldShow = !seen || BubbleDebugConfig.forceShowUserEducation(mContext);
        if (BubbleDebugConfig.DEBUG_USER_EDUCATION) {
            Log.d(TAG, "Show stack edu: " + shouldShow);
+12 −13
Original line number Diff line number Diff line
@@ -33,15 +33,16 @@ import com.android.wm.shell.animation.Interpolators
 * User education view to highlight the manage button that allows a user to configure the settings
 * for the bubble. Shown only the first time a user expands a bubble.
 */
class ManageEducationView(context: Context, positioner: BubblePositioner) : LinearLayout(context) {
class ManageEducationView(
    context: Context,
    private val positioner: BubblePositioner
) : LinearLayout(context) {

    private val TAG =
        if (BubbleDebugConfig.TAG_WITH_CLASS_NAME) "ManageEducationView"
        else BubbleDebugConfig.TAG_BUBBLES

    private val ANIMATE_DURATION: Long = 200
    companion object {
        const val PREF_MANAGED_EDUCATION: String = "HasSeenBubblesManageOnboarding"
        private const val ANIMATE_DURATION: Long = 200
    }

    private val positioner: BubblePositioner = positioner
    private val manageView by lazy { requireViewById<ViewGroup>(R.id.manage_education_view) }
    private val manageButton by lazy { requireViewById<Button>(R.id.manage_button) }
    private val gotItButton by lazy { requireViewById<Button>(R.id.got_it) }
@@ -128,7 +129,7 @@ class ManageEducationView(context: Context, positioner: BubblePositioner) : Line
                .setInterpolator(Interpolators.FAST_OUT_SLOW_IN)
                .alpha(1f)
        }
        setShouldShow(false)
        updateManageEducationSeen()
    }

    /**
@@ -218,13 +219,11 @@ class ManageEducationView(context: Context, positioner: BubblePositioner) : Line
            }
    }

    private fun setShouldShow(shouldShow: Boolean) {
    private fun updateManageEducationSeen() {
        context
            .getSharedPreferences(context.packageName, Context.MODE_PRIVATE)
            .edit()
            .putBoolean(PREF_MANAGED_EDUCATION, !shouldShow)
            .putBoolean(PREF_MANAGED_EDUCATION, true)
            .apply()
    }
}

const val PREF_MANAGED_EDUCATION: String = "HasSeenBubblesManageOnboarding"
+10 −16
Original line number Diff line number Diff line
@@ -34,19 +34,15 @@ import com.android.wm.shell.animation.Interpolators
 */
class StackEducationView(
    context: Context,
    positioner: BubblePositioner,
    controller: BubbleController
    private val positioner: BubblePositioner,
    private val controller: BubbleController
) : LinearLayout(context) {

    private val TAG =
        if (BubbleDebugConfig.TAG_WITH_CLASS_NAME) "BubbleStackEducationView"
        else BubbleDebugConfig.TAG_BUBBLES

    private val ANIMATE_DURATION: Long = 200
    private val ANIMATE_DURATION_SHORT: Long = 40

    private val positioner: BubblePositioner = positioner
    private val controller: BubbleController = controller
    companion object {
        const val PREF_STACK_EDUCATION: String = "HasSeenBubblesOnboarding"
        private const val ANIMATE_DURATION: Long = 200
        private const val ANIMATE_DURATION_SHORT: Long = 40
    }

    private val view by lazy { requireViewById<View>(R.id.stack_education_layout) }
    private val titleTextView by lazy { requireViewById<TextView>(R.id.stack_education_title) }
@@ -175,7 +171,7 @@ class StackEducationView(
                .setInterpolator(Interpolators.FAST_OUT_SLOW_IN)
                .alpha(1f)
        }
        setShouldShow(false)
        updateStackEducationSeen()
        return true
    }

@@ -196,13 +192,11 @@ class StackEducationView(
            .withEndAction { visibility = GONE }
    }

    private fun setShouldShow(shouldShow: Boolean) {
    private fun updateStackEducationSeen() {
        context
            .getSharedPreferences(context.packageName, Context.MODE_PRIVATE)
            .edit()
            .putBoolean(PREF_STACK_EDUCATION, !shouldShow)
            .putBoolean(PREF_STACK_EDUCATION, true)
            .apply()
    }
}

const val PREF_STACK_EDUCATION: String = "HasSeenBubblesOnboarding"
+2 −2
Original line number Diff line number Diff line
@@ -28,8 +28,8 @@ import androidx.test.filters.SmallTest
import com.android.systemui.model.SysUiStateTest
import com.android.wm.shell.bubbles.Bubble
import com.android.wm.shell.bubbles.BubbleEducationController
import com.android.wm.shell.bubbles.PREF_MANAGED_EDUCATION
import com.android.wm.shell.bubbles.PREF_STACK_EDUCATION
import com.android.wm.shell.bubbles.ManageEducationView.Companion.PREF_MANAGED_EDUCATION
import com.android.wm.shell.bubbles.StackEducationView.Companion.PREF_STACK_EDUCATION
import com.google.common.truth.Truth.assertThat
import com.google.common.util.concurrent.MoreExecutors.directExecutor
import org.junit.Assert.assertEquals
+6 −6
Original line number Diff line number Diff line
@@ -29,8 +29,6 @@ import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn;

import static com.google.common.truth.Truth.assertThat;

import static kotlinx.coroutines.flow.FlowKt.emptyFlow;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
@@ -50,6 +48,8 @@ import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import static kotlinx.coroutines.flow.FlowKt.emptyFlow;

import android.app.ActivityManager;
import android.app.IActivityManager;
import android.app.INotificationManager;
@@ -186,7 +186,7 @@ import com.android.wm.shell.bubbles.BubbleStackView;
import com.android.wm.shell.bubbles.BubbleViewInfoTask;
import com.android.wm.shell.bubbles.BubbleViewProvider;
import com.android.wm.shell.bubbles.Bubbles;
import com.android.wm.shell.bubbles.StackEducationViewKt;
import com.android.wm.shell.bubbles.StackEducationView;
import com.android.wm.shell.bubbles.properties.BubbleProperties;
import com.android.wm.shell.common.DisplayController;
import com.android.wm.shell.common.FloatingContentCoordinator;
@@ -1930,7 +1930,7 @@ public class BubblesTest extends SysuiTestCase {
    @Test
    public void testShowStackEdu_isNotConversationBubble() {
        // Setup
        setPrefBoolean(StackEducationViewKt.PREF_STACK_EDUCATION, false);
        setPrefBoolean(StackEducationView.PREF_STACK_EDUCATION, false);
        BubbleEntry bubbleEntry = createBubbleEntry(false /* isConversation */);
        mBubbleController.updateBubble(bubbleEntry);
        assertTrue(mBubbleController.hasBubbles());
@@ -1948,7 +1948,7 @@ public class BubblesTest extends SysuiTestCase {
    @Test
    public void testShowStackEdu_isConversationBubble() {
        // Setup
        setPrefBoolean(StackEducationViewKt.PREF_STACK_EDUCATION, false);
        setPrefBoolean(StackEducationView.PREF_STACK_EDUCATION, false);
        BubbleEntry bubbleEntry = createBubbleEntry(true /* isConversation */);
        mBubbleController.updateBubble(bubbleEntry);
        assertTrue(mBubbleController.hasBubbles());
@@ -1966,7 +1966,7 @@ public class BubblesTest extends SysuiTestCase {
    @Test
    public void testShowStackEdu_isSeenConversationBubble() {
        // Setup
        setPrefBoolean(StackEducationViewKt.PREF_STACK_EDUCATION, true);
        setPrefBoolean(StackEducationView.PREF_STACK_EDUCATION, true);
        BubbleEntry bubbleEntry = createBubbleEntry(true /* isConversation */);
        mBubbleController.updateBubble(bubbleEntry);
        assertTrue(mBubbleController.hasBubbles());