[4.2] [QuickSettings] How to add new toggles to 4.2 Android

Search This thread

mDroidd

Senior Member
Aug 27, 2011
1,844
1,362
mappz-development.com
I have one problem... How can I got this button to display the tiles? I'd like to port this to ICS...

Thanks for advices



ascudccqaaaum5.jpg

Only smart people can do that.
A lot of modification to source files is necessary for that, and I don't think you are capable of doing that (yet - ofcourse).

Also I don't think there are guides on how to port. So it's a no-go for you buddy.

Sent from my Galaxy Nexus running Android 4.2 JB
 
im trying to do this. but i only have these QuickSettings files

Code:
./frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettingsScrollView.java
./frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettingsContainerView.java
./frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettingsTileView.java

am i missing something?
 

zamzameir

Senior Member
Sep 11, 2013
347
418
Kuala Lumpur
Can you help me?I want to add my favorite contacts in my tile..but I'm be here..knows nothing on coding..I wish someone can help me though I'll be glad for that :D
 
  • Like
Reactions: root user

Top Liked Posts

  • There are no posts matching your filters.
  • 49
    This is just going to be a quick rundown on what do to add new toggles to android new QuickSettings system. This will take place in SystemUI.

    Custom QuickSettings Toggles
    NTlkx.png


    Path: frameworks/base/packages/SystemUI
    Files:
    src/com/android/systemui/statusbar/phone/QuickSettings.java
    There are two options when creating a toggle.
    addSystemTiles:380 - Static tiles with useful information.
    addTemporaryTiles:571 - This type of tile will get removed without activity, for example, the alarm quick setting is a temp tile.

    I used SystemTiles
    Code:
            // CpuInfo tile
            QuickSettingsTileView cpuInfoTile = (QuickSettingsTileView)
                    inflater.inflate(R.layout.quick_settings_tile, parent, false);
            cpuInfoTile.setContent(R.layout.quick_settings_tile_cpuinfo, inflater);
            cpuInfoTile.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    startSettingsActivity(Intent.ACTION_POWER_USAGE_SUMMARY);
                }
            });
            mModel.addCpuInfoTile(cpuInfoTile, new QuickSettingsModel.RefreshCallback() {
                @Override
                public void refreshView(QuickSettingsTileView view, State state) {
                    ImageView iv = (ImageView) view.findViewById(R.id.cpuinfo_image);
                    TextView tva = (TextView) view.findViewById(R.id.cpuinfoa_textview);
                    TextView tvb = (TextView) view.findViewById(R.id.cpuinfob_textview);
                    Drawable d = mContext.getResources().getDrawable(R.drawable.ic_settings_performance);
    		String GOV = fileReadOneLine(GOV_FILE);
    		String FREQ = fileReadOneLine(SCALE_CUR_FILE);
                    iv.setImageDrawable(d);
                    tva.setText(GOV);
                    tvb.setText(FREQ);
                    view.setContentDescription(
                            mContext.getString(R.string.accessibility_quick_settings_cpuinfo, GOV));
                }
            });
            parent.addView(cpuInfoTile);

    src/com/android/systemui/statusbar/phone/QuickSettingsModel.java:174
    This is needed for the widget inside the toggle to get updated. You can view other definitions in here to update various states.
    Code:
        private QuickSettingsTileView mCpuInfoTile;
        private RefreshCallback mCpuInfoCallback;
        private State mCpuInfoState = new State();

    res/layout/quick_settings_tile_cpuinfo.xml
    This is where we create the layout of the tile and call it from java.
    Code:
    <?xml version="1.0" encoding="utf-8"?>
    <!-- Copyright (C) 2012 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.
    -->
    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:orientation="vertical">
        <ImageView
            android:id="@+id/cpuinfo_image"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:paddingBottom="10dp"
            />
        <TextView
            style="@style/TextAppearance.QuickSettings.TileView"
            android:id="@+id/cpuinfoa_textview"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:textColor="#287AA9"
            android:gravity="center"
            />
        <TextView
            style="@style/TextAppearance.QuickSettings.TileView"
            android:id="@+id/cpuinfob_textview"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:textColor="#287AA9"
            android:gravity="center"
            />
    </LinearLayout>

    res/values/strings.xml
    Needed to setContentDescription()
    Code:
        <string name="accessibility_quick_settings_cpuinfo">CpuInfo <xliff:g id="meminfo" example="CpuInfo">%s</xliff:g>.</string>

    I know this is a very general overview, but the actuality is there is so much that can be done with this, it would be hard to go into extreme detail. Would be better to just simply leave that stuff for questions in this thread.

    If you want to know more, please just ask. Lets make android OURS!​
    5
    I'd assume he process would be very similar as cm is based off aosp...

    Anyways I'm currently downloading the 4.2 aosp, gonna be making (trying) my own rom and will definitely be using this guide in the near future after Im sure I can get everything built. Thanks for the guide, if I'm successfully with what I plan to do, you will definitely be linked and credited.

    Sent from my SGH-I997 using Tapatalk 2
    I was thinking about putting myself in front of a rom recently. If you are at all interested in teaming up for a rom project, PM. You seem legit and wouldn't mind it one bit.
    4
    Great tut man... Thanks!!! :good:

    How do I get sources?

    This is the best part of learning android IMO.

    First, you can't build android in windows unless you want to do it in a VM. I have never done that. I partitioned a hard drive when I was beginning and soon realized that wasn't enough so I have a dedicated 1TB hard drive for Linux. You can build on mac but I've never done that either. Here are few links to get you headed in the right direction.


    http://source.android.com/source/initializing.html

    http://wiki.cyanogenmod.org/wiki/Galaxy_Nexus_(GSM):_Compile_CyanogenMod_(Linux)

    http://www.paranoid-rom.com/forum/guides-references/203-tut-how-to-compile-paranoidandroid-from-sauces

    EDIT: after linking you, I glanced at your thanks meter then googled you lol. Not sure if you are serious or not now. :)
    3
    Or just create a flashable zip. Then flash the new modded app
    Not really the point of this thread.
    1
    Would root be required to implement this?

    Sent from my SGH-I997 using xda premium
    It would be since you have to push the file back onto the system.