2016년 11월 14일 월요일

Android workspace widget & shortcut 설정하기


  • 용어설명
- workspace: 안드로이드 바탕화면
- workspace의 아이콘은 앱링크인 App shortscut과, workspace에서 동작하는 appwidget으로 나뉜다.
- Hotseat 영역은 화면의 가장아래 가상버튼위 공간으로 통화버튼이 들어간 자리다.

  • 런처 설정 파일
- Launcher2/res/xml-sw600dp/default_workspace.xml : DB생성 초기 값으로 favorite table에 등록된다. 어느 스크린에 어떤 아이콘이 들어갈지 설정할 수 있으며 shortcut은 favorite xml tag로 표시된다.
 30 <!-- Middle screen [2] --> 31 <!--appwidget 32 launcher:packageName="com.android.deskclock" 33 launcher:className="com.android.alarmclock.AnalogAppWidgetProvider" 34 launcher:screen="2" 35 launcher:x="1" 36 launcher:y="0" 37 launcher:spanX="2" 38 launcher:spanY="2" /> 39 <favorite 40 launcher:packageName="com.android.camera" 41 launcher:className="com.android.camera.Camera" 42 launcher:screen="2" 43 launcher:x="0" 44 launcher:y="3" /-->
- Launcher2/res/values-sw600dp/config.xml : Hotseat 자리 개수, workspace rotation 등 설정파일:
- res/xml/dimens.xml : 아이콘 사이즈, 위치 등 설정파일:

  • 데이터 베이스 확인
sqlite3 /data/data/com.android.launcher/databases/launcher.db

sqlite> .table
android_metadata  favorites       

sqlite> select * from favorites;

1|||-100|2|2|3|2|2|4|2||||||||0    << 아날로그시계 앱위젯
3|갤러리|#Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10200000;component=com.android.gallery3d/.app.Gallery;end|-100|3|1|3|1|1|0|-1||||||||0
5|설정|#Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10200000;component=com.android.settings/.Settings;end|-100|3|2|3|1|1|0|-1||||||||0
7|전화|#Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10200000;component=com.android.dialer/.DialtactsActivity;end|-101|1|1|0|1|1|0|-1||||||||0
9|주소록|#Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10200000;component=com.android.contacts/.activities.PeopleActivity;end|-101|2|2|0|1|1|0|-1||||||||0
11|메시지|#Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10200000;component=com.android.mms/.ui.ConversationList;end|-101|4|4|0|1|1|0|-1||||||||0
13|인터넷|#Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10200000;component=com.android.browser/.BrowserActivity;end|-101|5|5|0|1|1|0|-1||||||||0
14|Dev Tools|#Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10200000;component=com.android.development/.Development;end|-100|2|3|2|1|1|0|-1||0|||�PNG|||0

sqlite> delete from favorites where  _id=1  
launcher.db의 favorites 테이블의 모든 행을 지우면 google search bar만 남는다.

  • 코드내 favorite DB 생성명령
302             db.execSQL("CREATE TABLE favorites (" +                             
303                     "_id INTEGER PRIMARY KEY," +                                
304                     "title TEXT," +                                             
305                     "intent TEXT," +                                            
306                     "container INTEGER," +                                      
307                     "screen INTEGER," +                                         
308                     "cellX INTEGER," +                                          
309                     "cellY INTEGER," +                                          
310                     "spanX INTEGER," +                                          
311                     "spanY INTEGER," +                                          
312                     "itemType INTEGER," +                                       
313                     "appWidgetId INTEGER NOT NULL DEFAULT -1," +                
314                     "isShortcut INTEGER," +                                     
315                     "iconType INTEGER," +                                       
316                     "iconPackage TEXT," +                                       
317                     "iconResource TEXT," +                                      
318                     "icon BLOB," +                                              
319                     "uri TEXT," +                                               
320                     "displayMode INTEGER," +                                    
321                     "profileId INTEGER DEFAULT " + userSerialNumber +           
322                     ");");



참조:
https://developer.android.com/guide/practices/ui_guidelines/widget_design.html
https://developer.android.com/guide/topics/appwidgets/index.html



댓글 없음:

댓글 쓰기