With a couple of timeline items sharing the same bundle ID, I create the bundle cover with:
TimelineItem timelineCover = new TimelineItem();
timelineCover.setText("Help Options");
timelineCover.setBundleId(bundleId);
timelineCover.setNotification(new NotificationConfig().setLevel("DEFAULT"));
timelineCover.setIsBundleCover(true);
timelineCover.setIsPinned(true);
MirrorClient.insertTimelineItem(credential, timelineCover);
It comes through to the timeline properly bundled but with isPinned = false.
I tried updating the isPinned field to true in the timeline playground but it stays false.
Is it possible to pin a bundle?
You can only pin a bundle by setting a non-cover item of the bundle to have the menu action TOGGLE_PINNED, and then the user has to tap on the cover, drill into a child card that can be pinned, tap it for the pin option and then pin it. This has the result of pinning the entire bundle, including the cover which as David pointed out in a comment, even when set to be able to be pinned, can't since clicking it just goes into the bundle.
Something else related in that it's also kind of weird and related to bundles, is that if you allow a user to delete the cover of a bundle, and they do, the children do not get deleted, instead the most recently added card becomes the new cover.
I think this is a great question. Thanks for it Daniel.
The isPinned property cannot be directly set to true. Your user must pin the card themselves using the TOGGLE_PINNED built-in menu item.
Your code for the timeline item insert would look like this:
TimelineItem timelineCover = new TimelineItem();
timelineCover.setText("Help Options");
timelineCover.setBundleId(bundleId);
timelineCover.setNotification(new NotificationConfig().setLevel("DEFAULT"));
timelineCover.setIsBundleCover(true);
List<MenuItem> menuItemList = new ArrayList<MenuItem>();
menuItemList.add(new MenuItem().setAction("TOGGLE_PINNED"));
timelineCover.setMenuItems(menuItemList);
MirrorClient.insertTimelineItem(credential, timelineCover);
Once inserted your user could use the menu to make this card pinned.
Related
I'm making a to-do list app and after user presses the button I create a new GridLayout(and all the data about time and name of the task inside of it) and add it into my RelativeLayout. How do I save those GridLayouts in UI so after the activity is destroyed and launched again those layouts are there.
After pressing the button I trigger the Create Activity method
public void CreateActivity(String name,int hours, int minutes,int i)
{
RelativeLayout.LayoutParams relparams= new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
relparams.addRule(RelativeLayout.BELOW,i);
relparams.setMargins(0,50,0,100);
Glayouts.add(new GridLayout(this));
Glayouts.get(i+1).setBackgroundColor(Color.GRAY);
Glayouts.get(i+1).setMinimumWidth(relative.getWidth());
Glayouts.get(i+1).setId(i+1);
Glayouts.get(i+1).setPadding(10,0,0,0);
GridLayout.LayoutParams namee = new GridLayout.LayoutParams();
namee.columnSpec = GridLayout.spec(0);
namee.rowSpec = GridLayout.spec(0);
namee.setGravity(Gravity.LEFT);
final TextView Actname = new TextView(this);
Actname.setText(name);
GridLayout.LayoutParams checkbox = new GridLayout.LayoutParams();
checkbox.columnSpec = GridLayout.spec(1);
checkbox.rowSpec = GridLayout.spec(0);
checkbox.setGravity(Gravity.RIGHT);
CheckBox check = new CheckBox(this);
// ADDING TO LAYOUT
Glayouts.get(i+1).addView(Actname,namee);
Glayouts.get(i+1).addView(check,checkbox);
relative.addView(Glayouts.get(i+1),relparams);
Theoretically when you extends View, then you can also override onSaveInstanceState and onRestoreInstanceState methods, where you must provide your own SavedState class that typically extends BaseSavedState. You can find info on that here
In your case, your layout is dynamic, therefore this doesn't really work. To tell you the truth, your layout probably shouldn't be constructed this way, you should be rendering the grid using a RecyclerView based on a "model" that describes this layout, render the items of the grid via the RecyclerView.Adapter, and you should persist either the "model", or the data you use to construct this model along with the user-inputted state so that you can re-construct the model that will be rendered via your RecyclerView.
You can read more about RecyclerView here.
You can read more about data persistence here.
You can read about using onSaveInstanceState to save data in Activities/Fragments across config change and process death (but not finishing then restarting the app) here.
You can’t. The best way to save state is to use some persistence mechanism, for example database (I’d recommend Room as it is officially supported by Google).
After clicking a button, you should put all the needed information (name, hours, minutes) in the database and when Activity is created, you can read all persisted data and - basing on it - create all needed layouts again.
Another option is storing data in SharedPreferences - it is much easier to setup, so you can also start with this solution. Please note, I'm suggesting it as a first step in the world of persistency in Android, not as a preferred solution for storing data.
What have I done so far:
I am currenctly facing some problems with the launchers.
My application adds shortcuts to the workspace of the launcher (homescreen).
But on some devices (Samsum Duos) for example, the titles and /or icons
are changed back after reboot to my default application one.
So I am currently going through 1000s of lines code in the android
source to identify the problem, but was not able to find it.
I saw in InstallShortcutReceiver
a comment in line 183 that the "name" provided by Intent.EXTRA_SHORTCUT_NAME can in
some situations be used only for comparison etc and will be replaced
with the applications default name.
// This name is only used for comparisons and notifications, so fall back to activity name
// if not supplied
But (my Samsum Duos is rooted) I could find the complete information's
about the cell position and shortcutInfo's inside of the launcher.db.
So it was not gone, after reboot, but maybe only not correct initialized!
First Question:
Does anybody know the reason for a custom, programmatically created shortcut to change the title and or icon back to the application's one that created it?
Next story:
I noticed that this issue was reproducible on my Samsum Duos, so I decided
to exclude the Devices Launcher from my "save launcher" list.
To receive the default launcher I am doing the following:
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_HOME);
ResolveInfo resolveInfo = null;
try {
resolveInfo = context.getPackageManager().resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY); //can return null!
}catch(RuntimeException e){
ExceptionHandler.logAndSendException(e);//package manager has died
return false;
}
But the problem now is, that it always returns that the default launchers
package is: com.android.launcher2.Launcher, which would be the standard
android stock launcher. But I know that Samsum uses the TouchWiz home
launcher, whos Package is located under com.sec.android.app.launcher!
That is also where I found the launcher.db and all its ShortcutInfo's.
2. Second Question
How do I get reproducible the correct default launcher package to identify
which launcher is used?
edit:
I kind of fixed the second problem. Somehow the ResolveInfo I get from
the PackageManager seems to be not reliable.
For the Samsum Duos I get:
resolveInfo.activityInfo.name = com.android.launcher2.Launcher
resolveInfo.activityInfo.packageName = com.sec.android.app.launcher //this is what I need
But for the Redmi MIUI:
resolveInfo.activityInfo.name = com.miui.home.launcher.Launcher //this time I would need this
resolveInfo.activityInfo.packageName = com.miui.home //the packageName is not complete!
I need an unique identifier for the launcher! So I thought activityInfo.name would be the
way to go, but it isn't in some situations. And the packageManager seems to apply to too many devices. Any suggestions?
Cheers!
Is it possible to the view menu using SWTBot? An example of an view menu is the one of Problems view (see screenshot). For example how can I change the grouping to Type using SWTBot? I've tried:
for (final SWTBotViewMenu a : this.bot.viewById("org.eclipse.ui.views.ProblemView").menus()) {
System.out.println(a.getText());
}
this.bot.viewById("org.eclipse.ui.views.ProblemView").toolbarDropDownButton("View Menu").menuItem("Group By").menu("None").click();
The for loop doesn't give anything at all, and the second one gives an error, that the "View Menu" cannot be found. I have no idea how to navigate this menu ?
It's probably too late for the OP, but here goes:
For some reason, the straight-forward way to activate a view like "Problems" doesn't work. You can use this workaround:
this.bot.menu("Window").menu("Show View").menu("Problems").click();
SWTBotView problemsView = bot.activeView();
This will only help with the first part, though. You now have access to the toolbar buttons via:
List<SWTBotToolbarButton> toolbarButtons = problemsView.getToolbarButtons();
For the Problems view, this gives you access to the "Focus on active task" button, but the three buttons in the cornern, "view menu", "minimize" and "maximize" do not appear in this list. Unfortunately, I have no solution for this as of now.
[Edit]
You can bring up the view menu like that:
this.bot.menu("Window").menu("Navigation").menu("Show View Menu").click();
but I don't know how to select an item from it afterwards. Maybe someone else will know...
try this:
SWTBotView view = bot.viewByTitle("MyView");
view.show();
view.viewMenu().menu("MyContextOption").click();
The problem come from the fact that this menu is populated with dynamic entries. SWTBot doesn't handle this kind of entry.
See ViewMenuFinder.getMenuItem(). Different kind of IContributionItem are handled but in the situation of the Problems View, the items are of type DynamicMenuContributionItem.
I think you can try with:
theView.viewMenu().menu("Group By").menu("Type").click();
I am able to do the same thing with SWTBot 2.8.0 for Project Explorer view
TLDR:
I'm setting myListView.setVisibility(View.GONE);, but it's not dissappearing until later... do I need to let it know somehow that I've changed it's visibility? Or do I need to also hide it's inner elements or something?
Description of Problem:
I have a normal news app. You see a list of articles for the "main" section, then you can click the options to select a new section.
When the user clicked, the section title changed, but the articles in the list would just sit there with "old" content until the new content is loaded, then it would flash to the new content.
This isn't ideal obviously. I'd like the list to disappear, show a loading animation, then, after the new data is retrieved (either from DB or online, then DB), it shows the new content.
I found this SO question which seemed like what I want, but...
I'm setting GONE immediately upon selection of the menu, then VISIBLE after it import the articles and loads the new ones... but it's not disappearing at all during that. I know the GONE code works, because if I remove my VISIBLE code, the articles never reappear.
Do I need to say "View.GONE", then tell it to update it's visibility or something?
My Code (MainActivity):
public static void sectionSelected()
{
String selectedText = sectionsSpinner.getSelectedItem().toString();
String[] selectedSection = Section.stringToSection(selectedText);
//check if it was already the current section
if(!Section.isEqual(Section.currentSection, selectedText))
{
//hides list of articles
articleEntryListView.setVisibility(View.GONE);
//sets new currentSection
Section.currentSection = selectedSection; // Section.stringToSection(sectionsSpinner.getSelectedItem().toString());
//imports articles (if it's been more than an hour since last import)
articlesDataSource.importArticles(Section.currentSection, true, false);
//loads article from database to the list
loadArticlesIntoList(Section.currentSection);
}
}
public static void loadArticlesIntoList(String[] section)
{
//clears the list
//articleEntryAdapter.clear(); //don't think I need this now that I'm just going to hide it
//articleEntryAdapter.notifyDataSetChanged();
//POPULATES THE LIST OF ARTICLES, THROUGH THE ADAPTER
for(final Article a1 : articlesDataSource.getArticles(section))
{
articleEntryAdapter.add(a1);
}
articleEntryAdapter.notifyDataSetChanged();
//shows list of articles
articleEntryListView.setVisibility(View.VISIBLE);
}
ADDITION: here is my importAricles() code: http://pastebin.com/8j6JZBej
You have to invalidate the view anytime you make a change to its appearance, so make a call to articleEntryListView.invalidate() after setting the visibility.
Is it possible to add a blackberry PIN to a device's 'black berry messenger' contact list programmatically?
Can anyone verify this for me?
I have looked through the API, but I do not see a clear way.
Thank you.
Before you begin: Make sure that you have completed the task, Register your application with the BlackBerry Messenger platform, and that the class that displays the MyBBMChatScreen screen passes in a reference to the application's associated BBMPlatformContext object into the screen's contructor. (as always :D)
I use this codes to add just one contact. You can modify it to add multiple contact. Just change the size of contacts array.
String PIN = "123456";
String name = "Someone";
BBMInvitationRequest[] contacts = new BBMInvitationRequest[1];
contacts[0] = new BBMInvitationRequest(PIN, name);
platformContext.getUIService().inviteToBBM(contacts);
May this help :)