+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- * Copyright (c) 2017, 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.
-*/
--->
-<resources>
- <!-- The height of the quick settings footer that holds the user switcher, settings icon,
- etc. in the car setting.-->
- <dimen name="qs_footer_height">74dp</dimen>
-</resources>
import static android.app.StatusBarManager.WINDOW_STATE_HIDDEN;
import static android.app.StatusBarManager.WINDOW_STATE_SHOWING;
import static android.app.StatusBarManager.windowStateToString;
-import static android.content.res.Configuration.UI_MODE_TYPE_CAR;
import static com.android.systemui.keyguard.WakefulnessLifecycle.WAKEFULNESS_ASLEEP;
import static com.android.systemui.keyguard.WakefulnessLifecycle.WAKEFULNESS_AWAKE;
ExtensionFragmentListener.attachExtensonToFragment(container, QS.TAG, R.id.qs_frame,
Dependency.get(ExtensionController.class).newExtension(QS.class)
.withPlugin(QS.class)
- .withUiMode(UI_MODE_TYPE_CAR, () -> new CarQSFragment())
+ .withFeature(
+ PackageManager.FEATURE_AUTOMOTIVE, () -> new CarQSFragment())
.withDefault(() -> new QSFragment())
.build());
final QSTileHost qsh = SystemUIFactory.getInstance().createQSTileHost(mContext, this,
public static final int SORT_ORDER_PLUGIN = 0;
public static final int SORT_ORDER_TUNER = 1;
- public static final int SORT_ORDER_UI_MODE = 2;
- public static final int SORT_ORDER_DEFAULT = 3;
+ public static final int SORT_ORDER_FEATURE = 2;
+ public static final int SORT_ORDER_UI_MODE = 3;
+ public static final int SORT_ORDER_DEFAULT = 4;
private final Context mDefaultContext;
return this;
}
+ @Override
public ExtensionController.ExtensionBuilder<T> withUiMode(int uiMode,
Supplier<T> supplier) {
mExtension.addUiMode(uiMode, supplier);
}
@Override
+ public ExtensionController.ExtensionBuilder<T> withFeature(String feature,
+ Supplier<T> supplier) {
+ mExtension.addFeature(feature, supplier);
+ return this;
+ }
+
+ @Override
public ExtensionController.ExtensionBuilder<T> withCallback(
Consumer<T> callback) {
mExtension.mCallbacks.add(callback);
@Override
public ExtensionController.Extension build() {
- // Manually sort, plugins first, tuners second, defaults last.
+ // Sort items in ascending order
Collections.sort(mExtension.mProducers, Comparator.comparingInt(Item::sortOrder));
mExtension.notifyChanged();
return mExtension;
mProducers.add(new UiModeItem(uiMode, mode));
}
+ public void addFeature(String feature, Supplier<T> mode) {
+ mProducers.add(new FeatureItem<>(feature, mode));
+ }
+
private class PluginItem<P extends Plugin> implements Item<T>, PluginListener<P> {
private final PluginConverter<T, P> mConverter;
private T mItem;
}
}
+ private class FeatureItem<T> implements Item<T> {
+ private final String mFeature;
+ private final Supplier<T> mSupplier;
+
+ public FeatureItem(String feature, Supplier<T> supplier) {
+ mSupplier = supplier;
+ mFeature = feature;
+ }
+
+ @Override
+ public T get() {
+ return mDefaultContext.getPackageManager().hasSystemFeature(mFeature)
+ ? mSupplier.get() : null;
+ }
+
+ @Override
+ public void destroy() {
+
+ }
+
+ @Override
+ public int sortOrder() {
+ return SORT_ORDER_FEATURE;
+ }
+ }
+
private class Default<T> implements Item<T> {
private final Supplier<T> mSupplier;