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

Commit 39759a9e authored by Ibrahim Yilmaz's avatar Ibrahim Yilmaz Committed by Android (Google) Code Review
Browse files

Merge "Use PrecomputedTextView" into udc-qpr-dev

parents 52b464fd d098df30
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.systemui.statusbar.notification.row;

import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.flags.FeatureFlags;
import com.android.systemui.flags.Flags;

import dagger.Binds;
import dagger.Module;
@@ -58,9 +59,13 @@ public abstract class NotificationRowModule {
    @ElementsIntoSet
    @Named(NOTIF_REMOTEVIEWS_FACTORIES)
    static Set<NotifRemoteViewsFactory> provideNotifRemoteViewsFactories(
            FeatureFlags featureFlags
            FeatureFlags featureFlags,
            PrecomputedTextViewFactory precomputedTextViewFactory
    ) {
        final Set<NotifRemoteViewsFactory> replacementFactories = new HashSet<>();
        if (featureFlags.isEnabled(Flags.PRECOMPUTED_TEXT)) {
            replacementFactories.add(precomputedTextViewFactory);
        }
        return replacementFactories;
    }
}
+41 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2023 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.systemui.statusbar.notification.row

import android.content.Context
import android.util.AttributeSet
import android.view.View
import android.widget.TextView
import com.android.internal.widget.ImageFloatingTextView
import javax.inject.Inject

class PrecomputedTextViewFactory @Inject constructor() : NotifRemoteViewsFactory {
    override fun instantiate(
        parent: View?,
        name: String,
        context: Context,
        attrs: AttributeSet
    ): View? {
        return when (name) {
            TextView::class.java.name,
            TextView::class.java.simpleName -> PrecomputedTextView(context, attrs)
            ImageFloatingTextView::class.java.name ->
                PrecomputedImageFloatingTextView(context, attrs)
            else -> null
        }
    }
}