Loading packages/SystemUI/res/drawable/ic_close_white.xml 0 → 100644 +24 −0 Original line number Diff line number Diff line <!-- Copyright (C) 2015 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. --> <vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24.0dp" android:height="24.0dp" android:viewportWidth="24.0" android:viewportHeight="24.0"> <path android:pathData="M19.000000,6.400000l-1.400000,-1.400000 -5.600000,5.600000 -5.600000,-5.600000 -1.400000,1.400000 5.600000,5.600000 -5.600000,5.600000 1.400000,1.400000 5.600000,-5.600000 5.600000,5.600000 1.400000,-1.400000 -5.600000,-5.600000z" android:fillColor="#FFFFFFFF"/> </vector> packages/SystemUI/res/layout/qs_customize_panel.xml +50 −5 Original line number Diff line number Diff line Loading @@ -21,13 +21,58 @@ android:orientation="vertical" android:background="?android:attr/windowBackground"> <FrameLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:background="?android:attr/colorPrimary"> <LinearLayout android:id="@+id/drag_buttons" android:layout_width="match_parent" android:layout_height="fill_parent" android:orientation="horizontal"> <FrameLayout android:layout_width="0dp" android:layout_height="fill_parent" android:layout_weight="1"> <com.android.systemui.qs.customize.DropButton android:id="@+id/info_button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:gravity="center" android:drawableStart="@drawable/ic_info" android:drawablePadding="10dp" android:textAppearance="?android:attr/textAppearanceMedium" android:textColor="@android:color/white" android:text="@string/qs_customize_info" /> </FrameLayout> <FrameLayout android:layout_width="0dp" android:layout_height="fill_parent" android:layout_weight="1"> <com.android.systemui.qs.customize.DropButton android:id="@+id/remove_button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:gravity="center" android:drawableStart="@drawable/ic_close_white" android:drawablePadding="10dp" android:textAppearance="?android:attr/textAppearanceMedium" android:textColor="@android:color/white" android:text="@string/qs_customize_remove" /> </FrameLayout> </LinearLayout> <Toolbar android:id="@*android:id/action_bar" android:layout_width="match_parent" android:layout_height="wrap_content" android:navigationContentDescription="@*android:string/action_bar_up_description" android:background="?android:attr/colorPrimary" style="?android:attr/toolbarStyle" /> style="?android:attr/toolbarStyle" android:background="?android:attr/colorPrimary" /> </FrameLayout> <com.android.systemui.tuner.AutoScrollView android:layout_width="match_parent" Loading packages/SystemUI/res/values/strings.xml +2 −0 Original line number Diff line number Diff line Loading @@ -1158,5 +1158,7 @@ <string name="save" translatable="false">Save</string> <string name="qs_customize" translatable="false">Allow long-press customize in Quick Settings</string> <string name="qs_customize_info" translatable="false">Info</string> <string name="qs_customize_remove" translatable="false">Remove</string> </resources> packages/SystemUI/src/com/android/systemui/qs/customize/CustomQSPanel.java +14 −45 Original line number Diff line number Diff line Loading @@ -19,26 +19,21 @@ import android.content.ClipData; import android.content.Context; import android.util.AttributeSet; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; import android.view.View.OnTouchListener; import com.android.systemui.R; import com.android.systemui.qs.QSPanel; import com.android.systemui.qs.QSTile; import com.android.systemui.qs.QSTileView; import com.android.systemui.statusbar.phone.QSTileHost; /** * A version of QSPanel that allows tiles to be dragged around rather than * clicked on. Dragging is started here, receiving is handled in the NonPagedTileLayout, * clicked on. Dragging starting and receiving is handled in the NonPagedTileLayout, * and the saving/ordering is handled by the CustomQSTileHost. */ public class CustomQSPanel extends QSPanel implements OnTouchListener { public class CustomQSPanel extends QSPanel { private CustomQSTileHost mCustomHost; private ClipData mCurrentClip; private View mCurrentView; public CustomQSPanel(Context context, AttributeSet attrs) { super(context, attrs); Loading @@ -62,52 +57,26 @@ public class CustomQSPanel extends QSPanel implements OnTouchListener { } } @Override protected void addTile(QSTile<?> tile) { super.addTile(tile); if (tile.getTileType() != QSTileView.QS_TYPE_QUICK) { TileRecord record = mRecords.get(mRecords.size() - 1); if (record.tileView.getTag() == record.tile) { return; } record.tileView.setTag(record.tile); record.tileView.setVisibility(View.VISIBLE); record.tileView.init(null, null, null); record.tileView.setOnTouchListener(this); if (mCurrentClip != null && mCurrentClip.getItemAt(0).getText().toString().equals(tile.getTileSpec())) { record.tileView.setAlpha(.3f); mCurrentView = record.tileView; } } public CustomQSTileHost getCustomHost() { return mCustomHost; } public void tileSelected(View v) { String sourceSpec = mCurrentClip.getItemAt(0).getText().toString(); String destSpec = ((QSTile<?>) v.getTag()).getTileSpec(); public void tileSelected(QSTile<?> tile, ClipData currentClip) { String sourceSpec = getSpec(currentClip); String destSpec = tile.getTileSpec(); if (!sourceSpec.equals(destSpec)) { mCustomHost.moveTo(sourceSpec, destSpec); } } @Override public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: String tileSpec = (String) ((QSTile<?>) v.getTag()).getTileSpec(); mCurrentView = v; mCurrentClip = ClipData.newPlainText(tileSpec, tileSpec); View.DragShadowBuilder shadow = new View.DragShadowBuilder(v); ((View) getParent().getParent()).startDrag(mCurrentClip, shadow, null, 0); v.setAlpha(.3f); return true; } return false; public ClipData getClip(QSTile<?> tile) { String tileSpec = tile.getTileSpec(); // TODO: Something better than plain text. // TODO: Once using something better than plain text, stop listening to non-QS drag events. return ClipData.newPlainText(tileSpec, tileSpec); } public void onDragEnded() { mCurrentView.setAlpha(1f); mCurrentView = null; mCurrentClip = null; public String getSpec(ClipData data) { return data.getItemAt(0).getText().toString(); } } packages/SystemUI/src/com/android/systemui/qs/customize/CustomQSTileHost.java +16 −0 Original line number Diff line number Diff line Loading @@ -37,6 +37,7 @@ public class CustomQSTileHost extends QSTileHost { private static final String TAG = "CustomHost"; private List<String> mTiles; private List<String> mSavedTiles; private ArrayList<String> mStash; public CustomQSTileHost(Context context, QSTileHost host) { super(context, null, host.getBluetoothController(), host.getLocationController(), Loading Loading @@ -70,6 +71,14 @@ public class CustomQSTileHost extends QSTileHost { TextUtils.join(",", mTiles), ActivityManager.getCurrentUser()); } public void stashCurrentTiles() { mStash = new ArrayList<>(mTiles); } public void unstashTiles() { setTiles(mStash); } public void moveTo(String from, String to) { int fromIndex = mTiles.indexOf(from); if (fromIndex < 0) { Loading @@ -86,6 +95,13 @@ public class CustomQSTileHost extends QSTileHost { super.onTuningChanged(TILES_SETTING, null); } public void remove(String spec) { if (!mTiles.remove(spec)) { Log.e(TAG, "Unknown remove spec " + spec); } super.onTuningChanged(TILES_SETTING, null); } public void setTiles(List<String> tiles) { mTiles = new ArrayList<>(tiles); super.onTuningChanged(TILES_SETTING, null); Loading Loading
packages/SystemUI/res/drawable/ic_close_white.xml 0 → 100644 +24 −0 Original line number Diff line number Diff line <!-- Copyright (C) 2015 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. --> <vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24.0dp" android:height="24.0dp" android:viewportWidth="24.0" android:viewportHeight="24.0"> <path android:pathData="M19.000000,6.400000l-1.400000,-1.400000 -5.600000,5.600000 -5.600000,-5.600000 -1.400000,1.400000 5.600000,5.600000 -5.600000,5.600000 1.400000,1.400000 5.600000,-5.600000 5.600000,5.600000 1.400000,-1.400000 -5.600000,-5.600000z" android:fillColor="#FFFFFFFF"/> </vector>
packages/SystemUI/res/layout/qs_customize_panel.xml +50 −5 Original line number Diff line number Diff line Loading @@ -21,13 +21,58 @@ android:orientation="vertical" android:background="?android:attr/windowBackground"> <FrameLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:background="?android:attr/colorPrimary"> <LinearLayout android:id="@+id/drag_buttons" android:layout_width="match_parent" android:layout_height="fill_parent" android:orientation="horizontal"> <FrameLayout android:layout_width="0dp" android:layout_height="fill_parent" android:layout_weight="1"> <com.android.systemui.qs.customize.DropButton android:id="@+id/info_button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:gravity="center" android:drawableStart="@drawable/ic_info" android:drawablePadding="10dp" android:textAppearance="?android:attr/textAppearanceMedium" android:textColor="@android:color/white" android:text="@string/qs_customize_info" /> </FrameLayout> <FrameLayout android:layout_width="0dp" android:layout_height="fill_parent" android:layout_weight="1"> <com.android.systemui.qs.customize.DropButton android:id="@+id/remove_button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:gravity="center" android:drawableStart="@drawable/ic_close_white" android:drawablePadding="10dp" android:textAppearance="?android:attr/textAppearanceMedium" android:textColor="@android:color/white" android:text="@string/qs_customize_remove" /> </FrameLayout> </LinearLayout> <Toolbar android:id="@*android:id/action_bar" android:layout_width="match_parent" android:layout_height="wrap_content" android:navigationContentDescription="@*android:string/action_bar_up_description" android:background="?android:attr/colorPrimary" style="?android:attr/toolbarStyle" /> style="?android:attr/toolbarStyle" android:background="?android:attr/colorPrimary" /> </FrameLayout> <com.android.systemui.tuner.AutoScrollView android:layout_width="match_parent" Loading
packages/SystemUI/res/values/strings.xml +2 −0 Original line number Diff line number Diff line Loading @@ -1158,5 +1158,7 @@ <string name="save" translatable="false">Save</string> <string name="qs_customize" translatable="false">Allow long-press customize in Quick Settings</string> <string name="qs_customize_info" translatable="false">Info</string> <string name="qs_customize_remove" translatable="false">Remove</string> </resources>
packages/SystemUI/src/com/android/systemui/qs/customize/CustomQSPanel.java +14 −45 Original line number Diff line number Diff line Loading @@ -19,26 +19,21 @@ import android.content.ClipData; import android.content.Context; import android.util.AttributeSet; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; import android.view.View.OnTouchListener; import com.android.systemui.R; import com.android.systemui.qs.QSPanel; import com.android.systemui.qs.QSTile; import com.android.systemui.qs.QSTileView; import com.android.systemui.statusbar.phone.QSTileHost; /** * A version of QSPanel that allows tiles to be dragged around rather than * clicked on. Dragging is started here, receiving is handled in the NonPagedTileLayout, * clicked on. Dragging starting and receiving is handled in the NonPagedTileLayout, * and the saving/ordering is handled by the CustomQSTileHost. */ public class CustomQSPanel extends QSPanel implements OnTouchListener { public class CustomQSPanel extends QSPanel { private CustomQSTileHost mCustomHost; private ClipData mCurrentClip; private View mCurrentView; public CustomQSPanel(Context context, AttributeSet attrs) { super(context, attrs); Loading @@ -62,52 +57,26 @@ public class CustomQSPanel extends QSPanel implements OnTouchListener { } } @Override protected void addTile(QSTile<?> tile) { super.addTile(tile); if (tile.getTileType() != QSTileView.QS_TYPE_QUICK) { TileRecord record = mRecords.get(mRecords.size() - 1); if (record.tileView.getTag() == record.tile) { return; } record.tileView.setTag(record.tile); record.tileView.setVisibility(View.VISIBLE); record.tileView.init(null, null, null); record.tileView.setOnTouchListener(this); if (mCurrentClip != null && mCurrentClip.getItemAt(0).getText().toString().equals(tile.getTileSpec())) { record.tileView.setAlpha(.3f); mCurrentView = record.tileView; } } public CustomQSTileHost getCustomHost() { return mCustomHost; } public void tileSelected(View v) { String sourceSpec = mCurrentClip.getItemAt(0).getText().toString(); String destSpec = ((QSTile<?>) v.getTag()).getTileSpec(); public void tileSelected(QSTile<?> tile, ClipData currentClip) { String sourceSpec = getSpec(currentClip); String destSpec = tile.getTileSpec(); if (!sourceSpec.equals(destSpec)) { mCustomHost.moveTo(sourceSpec, destSpec); } } @Override public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: String tileSpec = (String) ((QSTile<?>) v.getTag()).getTileSpec(); mCurrentView = v; mCurrentClip = ClipData.newPlainText(tileSpec, tileSpec); View.DragShadowBuilder shadow = new View.DragShadowBuilder(v); ((View) getParent().getParent()).startDrag(mCurrentClip, shadow, null, 0); v.setAlpha(.3f); return true; } return false; public ClipData getClip(QSTile<?> tile) { String tileSpec = tile.getTileSpec(); // TODO: Something better than plain text. // TODO: Once using something better than plain text, stop listening to non-QS drag events. return ClipData.newPlainText(tileSpec, tileSpec); } public void onDragEnded() { mCurrentView.setAlpha(1f); mCurrentView = null; mCurrentClip = null; public String getSpec(ClipData data) { return data.getItemAt(0).getText().toString(); } }
packages/SystemUI/src/com/android/systemui/qs/customize/CustomQSTileHost.java +16 −0 Original line number Diff line number Diff line Loading @@ -37,6 +37,7 @@ public class CustomQSTileHost extends QSTileHost { private static final String TAG = "CustomHost"; private List<String> mTiles; private List<String> mSavedTiles; private ArrayList<String> mStash; public CustomQSTileHost(Context context, QSTileHost host) { super(context, null, host.getBluetoothController(), host.getLocationController(), Loading Loading @@ -70,6 +71,14 @@ public class CustomQSTileHost extends QSTileHost { TextUtils.join(",", mTiles), ActivityManager.getCurrentUser()); } public void stashCurrentTiles() { mStash = new ArrayList<>(mTiles); } public void unstashTiles() { setTiles(mStash); } public void moveTo(String from, String to) { int fromIndex = mTiles.indexOf(from); if (fromIndex < 0) { Loading @@ -86,6 +95,13 @@ public class CustomQSTileHost extends QSTileHost { super.onTuningChanged(TILES_SETTING, null); } public void remove(String spec) { if (!mTiles.remove(spec)) { Log.e(TAG, "Unknown remove spec " + spec); } super.onTuningChanged(TILES_SETTING, null); } public void setTiles(List<String> tiles) { mTiles = new ArrayList<>(tiles); super.onTuningChanged(TILES_SETTING, null); Loading