Android Launcher Analysis-hotseat Advanced

Source: Internet
Author: User

The previous article has written hotseat analysis, mainly to explain how to configure and modify hotseat parameters in the launcher.

Today's main explanation is how to display the item name in hotseat.

(PS: New QQ Group, interested to join the discussion: Android Group: 322599434)

The default hotseat element has no caption

1.Hotseat hidden folder title

The idea of trying to solve this problem was to find the place where the button object was generated, and modify it just fine. Because I analyzed hotseat last time, remember there is a place to hotseat the button text block, I think as long as the open is good.

Edited by Mythou
http://www.cnblogs.com/mythou/

if (container = = LauncherSettings.Favorites.CONTAINER_HOTSEAT)
{
if (owllauncherdebug.hotseat) log.d (Mythou, "Addinscreen------->container_hotseat");
Layout = Mlauncher.gethotseat (). GetLayout ();
Child.setonkeylistener (NULL);

Hide the name of the folder inside the hotseat
if (Child instanceof Foldericon)
{
((Foldericon) child). Settextvisible (false);
}

//.........
}

The above code is in the workspace inside the Addinscreen () part of the code, is bound workspace element when the method called, there is a judge whether to hide the name of the folder, but did not see the code to hide the normal shortcut.

I first removed the folder title hidden function, but the folder inside the hotseat is not a name. No way, just look at the hotseat above how those shortcuts are added and loaded.

How item on 2.Hotseat is generated

Hotseat the above shortcut can be divided into two, one is a normal shortcut, can be configured in the Default_workspace. The other one is the button for all the application lists, which is Hotseat.java dynamically generated inside. We first look at how ordinary shortcuts are generated, general shortcuts, by loading default_workspace, this process with workspace above the button, the front has been detailed analysis, here not much to say. We mainly look at how to generate shortcut objects, in fact this is the same as workspace, we look at the following code:

Edited by Mythou
http://www.cnblogs.com/mythou/

public void Binditems (arraylist<iteminfo> shortcuts, int start, int end)
{
... for (int i=start; i<end; i++)
{
... if (owllauncherdebug.hotseat) log.d ("Owl_launcher", "Binditems------->item=" +item);
Switch (item.itemtype)
{
Case LauncherSettings.Favorites.ITEM_TYPE_APPLICATION:
Case LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT:
The view object that generated the item
View shortcut = CreateShortcut ((shortcutinfo) item);
Add to the corresponding screen inside
Workspace.addinscreen (shortcut, Item.container, Item.screen, ITEM.CELLX,
item.celly, 1, 1, false);
Break
}
}

}

Above is launcher inside of the Binditems () method part of the Code, Binditems () This method, looked at my previous analysis launcher data loading friends should not be unfamiliar,

This is a method of launcher callback when binding launcher data, and the Hotseat item object is generated here. Called the CreateShortcut () method, let's look at how CreateShortcut () generates the item object.

3.Item added to hotseat

Edited by Mythou
http://www.cnblogs.com/mythou/

View createshortcut (int layoutresid, viewgroup parent, Shortcutinfo info)
{
if (owllauncherdebug.hotseat) log.d ("Owl_lancher", "Addinscreen------->info=" +info);
Create a shortcut to item, hotseat inside the button is also Bubbletextview
Bubbletextview favorite = (Bubbletextview) minflater.inflate (Layoutresid, parent, false);
Favorite.applyfromshortcutinfo (info, miconcache);
Favorite.setonclicklistener (this);
return favorite;
}

From here can be seen, in fact hotseat inside the button is also Bubbletextview object, that is, with the general workspace inside the same button. Object generation will be added to the corresponding screen inside. The previous hotseat article I also said, Hotseat is actually a celllayout screen. Inside the program is marked as the last screen.

Allapp button for 4.Hotseat

Edited by Mythou
http://www.cnblogs.com/mythou/

void Addinscreen (View child, Long container, int screen, int x, int y, int spanX, int spany,boolean insert)
{
if (owllauncherdebug.hotseat) log.d (OWL, "Addinscreen------->screen=" +screen);
Final celllayout layout;
Special treatment is done for hotseat objects Mythou
if (container = = LauncherSettings.Favorites.CONTAINER_HOTSEAT)
{
if (owllauncherdebug.hotseat) log.d (OWL, "Addinscreen------->container_hotseat");

Layout = Mlauncher.gethotseat (). GetLayout ();
Child.setonkeylistener (NULL);

Hide Hotseat folder title
if (Child instanceof Foldericon)
{
((Foldericon) child). Settextvisible (false);
}if (owllauncherdebug.hotseat) log.d (OWL, "Addinscreen------->container_hotseat screen=" +screen);

if (Screen < 0)
{
Screen = Mlauncher.gethotseat (). getorderinhotseat (x, y);
}
Else
{//Get child's position, return True add succeeded, false failed here is actually the location of the item in the hotseat
x = Mlauncher.gethotseat (). Getcellxfromorder (screen);
y = Mlauncher.gethotseat (). Getcellyfromorder (screen);
}

if (owllauncherdebug.hotseat) log.d (OWL, "Addinscreen-------> x=" +x + "y=" +y);

}
}

Above is the hotseat inside the element to add to the hotseat corresponding to the celllayout inside, there is a part of the special treatment for the hotseat element, that is, the first to say the hidden folder title and technical elements of the location of the code. In addition to these, I did not find the way to hide the button text. Later can only see hotseat inside another button (Allapp) can display text.

Allapp button for 4.Hotseat

Edited by Mythou
http://www.cnblogs.com/mythou/

void Resetlayout ()
{
Empty all the elements inside the hotseat.
Mcontent.removeallviewsinlayout ();

Add Allapp button
Context context = GetContext ();
Layoutinflater Inflater = layoutinflater.from (context);
Modify the button configuration for your own definition application, Mythou
Bubbletextview Allappsbutton = (Bubbletextview)
Inflater.inflate (R.layout.application, mcontent, false);
Set the picture of the Allapp button
Allappsbutton.setcompounddrawableswithintrinsicbounds (NULL,
Context.getresources (). Getdrawable (R.drawable.all_apps_button_icon), NULL, NULL);
Allappsbutton.settext (context.getstring (R.string.all_apps_button_label));
Allappsbutton.setcontentdescription (context.getstring (R.string.all_apps_button_label));

int width = allappsbutton.getwidth ();
int heigh = Allappsbutton.getheight ();
LOG.D ("Owl_hotseat", "Allappsbutton width=" +width+ "heigh=" +heigh);
//.........

}

5.Hotseat Show Item Title

I didn't say anything about how to change the display title. In fact, this is very simple to say, hotseat inside the elements, each saved the item title, I also deliberately print out the data to see, because just beginning to think the system directly to the header data deleted. The reason why it is not shown is because the height of the hotseat setting is too low, which causes the title section to show the blocked, very practical and embarrassing method. In addition, there may be people to ask, since the display space is limited, why also add a Judgment folder title hidden? The answer to this question, as long as you look at the folder height to know, practice it to be impressive.

Reprint Address:

Http://www.cnblogs.com/mythou/p/3211443.html

Android Launcher Analysis-hotseat Advanced

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.