▽Original Thread
http://forum.xda-developers.com/galaxy-s2/themes-apps/guide-how-to-create-button-notification-t2730988
Thanks to:"gerryS2"
》이것은 [퀵패널]에 갤럭시S5퀵패널에 있는 "S파인더" "퀵커넥트"버튼을 추가하는 방법입니다.
(실제 S파인더와 퀵커넥트는 아니고, Activity를 이용한 "바로가기"버튼이라고 이해하시면 됩니다.)
》디컴파일/컴파일이 가능한 분들에게 해당됩니다.
》이 작업에 필요한 파일은 SystemUI.apk입니다.
》엥간하면 컴퓨터로 보시기 바랍니다.(빨간색 구문을 확인해야 합니다.)
1.First decompile SystemUI, go to res/layout, open tw_status_bar_expanded.xml and add the red line:
#아래 보이는 빨간색 구문을
SystemUI.apk/res/layout/tw_status_bar_expanded.xml의 저 위치에 추가하세요.
<HorizontalScrollView android:id="@id/quicksetting_scroller" android:scrollbars="none" android:layout_width="wrap_content" android:layout_height="wrap_content"> <com.android.systemui.statusbar.policy.quicksetting.QuickSettingPanel android:orientation="horizontal" android:id="@id/quicksetting_container" android:layout_width="wrap_content" android:layout_height="wrap_content" android:divider="@drawable/tw_black_bg" android:showDividers="middle" />
</HorizontalScrollView>
<LinearLayout android:orientation="vertical" android:id="@id/sfinder_qconnect_layout" android:visibility="visible" android:layout_width="fill_parent" android:layout_height="wrap_content">
<LinearLayout android:gravity="center_vertical" android:orientation="horizontal" android:paddingLeft="@dimen/finder_connect_button_padding_right" android:paddingTop="@dimen/finder_connect_button_padding_top" android:paddingRight="@dimen/finder_connect_button_padding_left" android:paddingBottom="@dimen/finder_connect_button_padding_bottom" android:layout_width="fill_parent" android:layout_height="wrap_content">
<Button android:textSize="@dimen/tw_quick_panel_sfinder_qconnect_button_text_size" android:textColor="@drawable/tw_quick_panel_sfinder_qconnect_button_text_color" android:id="@id/sfinder_button_big" android:background="@drawable/tw_quick_panel_sfinder_qconnect_button" android:layout_width="0.0dip" android:layout_height="@dimen/finder_connect_button_height" android:layout_marginRight="10.0dip" android:text="@string/big_button_barra" android:layout_weight="0.5" />
<Button android:textSize="@dimen/tw_quick_panel_sfinder_qconnect_button_text_size" android:textColor="@drawable/tw_quick_panel_sfinder_qconnect_button_text_color" android:id="@id/qconnect_button_big" android:background="@drawable/tw_quick_panel_sfinder_qconnect_button" android:layout_width="0.0dip" android:layout_height="@dimen/finder_connect_button_height" android:layout_marginLeft="10.0dip" android:text="@string/big_button_panel" android:layout_weight="0.5" />
</LinearLayout>
<View android:id="@id/sfinder_qconnect_divider" android:background="@drawable/notification_bottom_line" android:layout_width="fill_parent" android:layout_height="1.0dip" />
</LinearLayout>
<LinearLayout android:orientation="vertical" android:id="@id/brightness_controller" android:background="#ff000000" android:layout_width="fill_parent" android:layout_height="56.0dip">
<LinearLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="55.0dip">
<ImageView android:id="@id/brightness_icon" android:clickable="true" android:layout_width="25.0dip" android:layout_height="fill_parent" android:layout_marginLeft="13.0dip" android:src="@drawable/ic_sysbar_brightness" android:contentDescription="@string/accessibility_brightness_icon" />
<FrameLayout android:id="@id/brightness_group" android:layout_width="fill_parent" android:layout_height="fill_parent">
<com.android.systemui.statusbar.policy.ToggleSlider android:id="@id/brightness" android:layout_width="fill_parent" android:layout_height="fill_parent" systemui:text="@string/status_bar_settings_auto_brightness_label" />
<com.android.systemui.statusbar.policy.ToggleSlider android:id="@id/auto_brightness" android:layout_width="fill_parent" android:layout_height="fill_parent" systemui:text="@string/status_bar_settings_auto_brightness_label" />
</FrameLayout>
</LinearLayout>
<View android:background="#ff091a24" android:layout_width="fill_parent" android:layout_height="1.0dip" />
</LinearLayout>
2.Now go to values folder and add this line in this files.
#res/values폴더의 ids.xml/dimens.xml/strings.xml에 각각 아래 해당되는 구문을 맨 밑 </resources>바로 위에 추가하세요.
<item type="id" name="sfinder_qconnect_layout">false</item>
<item type="id" name="sfinder_button_big">false</item>
<item type="id" name="qconnect_button_big">false</item>
<item type="id" name="sfinder_qconnect_divider">false</item>
-In dimens.xml
<dimen name="finder_connect_button_padding_top">11.0dip</dimen>
<dimen name="finder_connect_button_padding_bottom">10.0dip</dimen>
<dimen name="finder_connect_button_padding_right">20.0dip</dimen>
<dimen name="finder_connect_button_padding_left">20.0dip</dimen>
<dimen name="finder_connect_button_height">37.0dip</dimen>
<dimen name="tw_quick_panel_sfinder_qconnect_button_text_size">16.0dip</dimen>
-In strings.xml
#만약, 퀵패널에 추가될 버튼 글자를 "한글"로 표기하고자 할때는,
res/values-ko폴더를 열어 strins.xml에 아래와 같은 구문을 똑같이 맨 밑에 추가해주고,
Display와 sound 글자를 원하는 한글로 수정해주면 됩니다.
<string name="big_button_barra">Display</string>
<string name="big_button_panel">Sound</string>
3.Add the res files in drawable and drawable-hdpi.
#이 게시글에 첨부된 [Button Files]를 압축풀면 res폴더에 drawable/drawable-hdpi폴더 두개가 나옵니다.
drawable폴더안의 파일은 drawable에 넣으면 되고,
drawable-hdpi폴더안의 파일은 각자 폰의 해상도에 맞는 dpi폴더에 넣으세요.(노트1_drawable-xhdpi)
4.Recompile SystemUI and decompile for insert the value of ids in public.xml
#여기서 일단, SystemUI.apk를 "컴파일"하세요.
그리고, 컴파일된 UnsignedSystemUI.apk를 다시 디컴파일 하여
UnsignedSystemUI.apk/res/values/public.xml을 일단 열어두세요.
이건, 새로 추가한 "버튼 이미지"의 public.xml값을 알아야 다음 작업을 진행할수 있기 때문입니다.
(트윜 포팅할때 자주 사용하는 방법이기도 하죠.)
5.Now there is the smali part.
Go to smali/com/android/systemui/statusbar/phone and open PhoneStatusbar.smali
#이 작업은 계속 SystemUI.apk로 하는 작업 smali입니다.
(UnsignedSsytemUI.apk와 헷갈리면 안됩니다.)
먼저,
SystemUI/smali/com/android/systemui/statusbar/phone and open PhoneStatusbar.smali를 열어
# instance fields의 맨밑에 아래 두 구문을 추가하세요.
.field private mBigButtonListener:Landroid/view/View$OnClickListener;
.field private mBigButtonListener2:Landroid/view/View$OnClickListener;
6.Add the red line at the end of the .method public constructor <init>()V
#같은 PhoneStatusbar.smali에서 .method public constructor <init>()V
이 메소드를 찾아
메소드의 맨 밑에 아래 빨간색 구문을 추가하세요.
new-instance v0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar$X1;
invoke-direct {v0, p0}, Lcom/android/systemui/statusbar/phone/PhoneStatusBar$X1;-><init>(Lcom/android/systemui/statusbar/phone/PhoneStatusBar;)V
iput-object v0, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mBigButtonListener:Landroid/view/View$OnClickListener;
new-instance v0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar$X2;
invoke-direct {v0, p0}, Lcom/android/systemui/statusbar/phone/PhoneStatusBar$X2;-><init>(Lcom/android/systemui/statusbar/phone/PhoneStatusBar;)V
iput-object v0, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mBigButtonListener2:Landroid/view/View$OnClickListener;
return-void
.end method
7.Add the red line in .method protected makeStatusBarView()Lcom/android/systemui/statusbar/phone/PhoneStatusBarView;
#이것 역시 PhoneStatusbar.smali에서
.method protected makeStatusBarView()Lcom/android/systemui/statusbar/phone/PhoneStatusBarView;
이 메소드를 찾아서,
아래 빨간색 구문을 저 위치에 추가하세요.
(비슷한 구문들이 여러개 있기 때문에 정확하게 잘 찾아서 추가해야 합니다.)
iget-object v9, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mStatusBarWindow:Lcom/android/systemui/statusbar/phone/StatusBarWindowView;
const v10, 0x7f0d0051
invoke-virtual {v9, v10}, Lcom/android/systemui/statusbar/phone/StatusBarWindowView;->findViewById(I)Landroid/view/View;
move-result-object v9
iput-object v9, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mSettingsButton:Landroid/view/View;
iget-object v9, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mSettingsButton:Landroid/view/View;
iget-object v10, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mSettingsButtonListener:Landroid/view/View$OnClickListener;
invoke-virtual {v9, v10}, Landroid/view/View;->setOnClickListener(Landroid/view/View$OnClickListener;)V
iget-object v9, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mStatusBarWindow:Lcom/android/systemui/statusbar/phone/StatusBarWindowView;
const v10, 0x7f0d01ea
invoke-virtual {v9, v10}, Lcom/android/systemui/statusbar/phone/StatusBarWindowView;->findViewById(I)Landroid/view/View;
move-result-object v9
check-cast v9, Landroid/widget/Button;
iget-object v10, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mBigButtonListener:Landroid/view/View$OnClickListener;
invoke-virtual {v9, v10}, Landroid/widget/Button;->setOnClickListener(Landroid/view/View$OnClickListener;)V
iget-object v9, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mStatusBarWindow:Lcom/android/systemui/statusbar/phone/StatusBarWindowView;
const v10, 0x7f0d01eb
invoke-virtual {v9, v10}, Lcom/android/systemui/statusbar/phone/StatusBarWindowView;->findViewById(I)Landroid/view/View;
move-result-object v9
check-cast v9, Landroid/widget/Button;
iget-object v10, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mBigButtonListener2:Landroid/view/View$OnClickListener;
invoke-virtual {v9, v10}, Landroid/widget/Button;->setOnClickListener(Landroid/view/View$OnClickListener;)V
8.0x7f0d01ea is the public id of "sfinder_button_big"
0x7f0d01eb is the public id of "qconnect_button_big"
#여기서 중요합니다.
아까 UnsignedSystemUI.apk/res/values/public.xml을 열어두라고 했죠.
방금 위에서 추가한 빨간색 구문중에 0x7f0..으로 시작되는 구문이 두개 포함돼 있습니다.
처음에 나오는 값은 "sfinder_button_big"의 값이여야하고,
두번째 나오는 값은 "qconnect_button_big"값이여야 합니다.
그 두 값을 아까 열어두라고 했던 UnsignedSystemUI.apk/res/values/public.xml에서 각각 찾아
7번에서 추가한 빨간색 구문에 있는 값과 바꿔주면 됩니다.
9.Now add the file of smali folder.
#첨부된 [Button Files]안에 smali폴더가 있는데 쭉쭉~ 들어가보면 두개의 smali파일이 있습니다.
PhoneStatusBar$X1.smlai
PhoneStatusBar$X2.smlai
→SystemUI/smali/com/android/systemui/statusbar/phone폴더에 그 두개의 smali파일을 넣어주세요.
10.If you want to change the intent of the button, you must open the two smali files(PhoneStatusbar$X1 and PhoneStatusbar$X2) and change the parts highlighted in red, adding the names of the resulting applications and tasks that you want to open.
#이게 무슨말이냐하면,
방금 위 9번에서 추가한 두개의 smali파일을 각각 열어보면,
(아래 예시에 있는 smali는 PhoneStatusBar$X1.smlai입니다.)
아래와 같은 빨간색 구문들이 적혀 있습니다.
이것은 퀵패널에 추가하는 두개의 버튼중에서 왼쪽에 있는 버튼(PhoneStatusBar$X1.smlai)을 터치했을때,
→환경설정/"디스플레이 설정(com.android.settings.Settings$DisplaySettingsActivity)창이 열리게 설정돼 있습니다.
마찬가지 개념으로 오른쪽에 추가될 버튼((PhoneStatusBar$X2.smlai)을 터치하면,
→환경설정/"소리 설정(com.android.settings.Settings$SoundSettingsActivity)창이 열리게 설정돼 있습니다.
따라서,
두개의 smlai를 열어 사용자가 원하는 "바로가기(Activity)"를 각각 마음대로수정할수 있다는 뜻입니다.
new-instance v2, Landroid/content/Intent;
invoke-direct {v2}, Landroid/content/Intent;-><init>()V
const-string v3, "android.intent.action.MAIN"
invoke-virtual {v2, v3}, Landroid/content/Intent;->setAction(Ljava/lang/String;)Landroid/content/Intent;
const/high16 v4, 0x1000
invoke-virtual {v2, v4}, Landroid/content/Intent;->setFlags(I)Landroid/content/Intent;
const-string v5, "com.android.settings"
const-string v6, "com.android.settings.Settings$DisplaySettingsActivity"
invoke-virtual {v2, v5, v6}, Landroid/content/Intent;->setClassName(Ljava/lang/String;Ljava/lang/String;)Landroid/content/Intent;
move-result-object v2
invoke-virtual {v1, v2}, Landroid/content/Context;->startActivity(Landroid/content/Intent;)V
iget-object v1, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar$X1;->this$0:Lcom/android/systemui/statusbar/phone/PhoneStatusBar;
invoke-virtual {v1}, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->animateCollapse()V
11.끝.
컴파일 하세요.
감사합니다.^^
첨부파일은, xda게시글에 있는 파일을 다운로드하세요.^^(이 게시글을 수정하면...원상복구?가 안됩니다.)