Tuesday, April 14, 2009

Elephant Memory

One of the most frequently annoying things when using computers is to seek a document in same folders of previously opened one and facing an 'Open File' dialog pointing stubbornly to home directory. A simple tip to improve user experience, would be that computer can 'remember' permanently last used directories per application showing last opened file and access date.


A simple preview on KDE4:

Wednesday, April 8, 2009

Activities are for humans

Computers are very versatile tools, used in a variety of situations, to work, listen music, write documents, but it is very difficult to create a comfortable user environment for each task. When working to an important document, mail notifications are very annoying, but turning off completely notifications is not the ideal solution, mails related to the activity are welcomed. What is missing is the possibility that the computer adapts his environment to different activities.

Virtual desktops are the more advanced solution to implement activities today, but this is only a start.

There is a difference between a virtual desktop and an activity: virtual desktop is a collection of resources (windows mainly), an activity is a collection of related resources. You can work for a project, read documents, contact people, receive mails and so on and all these items can stay associated to the activity you are currently operating.

We can roughly consider an activity on top of a collections of virtual desktops.

A 'recent document' menu can contain a lot of unrelated documents, a personal letter written in a pause together with work documents and worst, it has a finite length, so new documents of unrelated activities are pushing into oblivion very important bookmarks.

Activities are useful to categorize and filter environment items, but it is not practical to manually label each resource that can reside in an activity, so the workspace should automatically collect informations, like the mylyn plugin in Eclipse world

http://www.ibm.com/developerworks/java/library/j-mylyn2/

When in an activity you can associate not only documents related to that activity, but also contacts, sites, and so on.

We work on different projects and we use the computer for personal activity each day. Computers are universal devices and can be used for different purposes.

As a further example, it is an annoyance to receive mail notifications from people not related to projects ( with obvious exception for emergencies ) in working hours. An activity can filter what that can distract, without hiding information, but focusing out of view not relevant factors.

It is important to have a simple 'relations' manager to handle what resources are related to an activity and move or copy them from a workspace to another (maybe using the KDE plasmoid zoom interface).

It is important to have multiple activity configurations, you can use same laptop at work and at home, even applications menu can change in different situations.

Activities attributes and resources should be shared between teams.

There are two types of applications: specialized ones (video, audio, graphics editor for instance ) and generics ones ( word processors, time tracker, etc) that should have different behavior. How horizontal applications like file browsers should behave? Why not filter activity related directories in 'Open File' dialogs? Currently this dialog supports only a simple filter that maps to file type (a word processor filter documents, a spreadsheet csv and so on)

How to save data in application specific format and not using specialized Desktop Environment routines? How to integrate, for example, Open Office? We should use the metadata we are using for browsers: the tags, but there is the problem to maintain metadata in sync with data when moving files, doing backups and so on. All the files that user opens or write should be logged, but the metainformations should be stored in the document or in the filesystem?

Even phones have different modes: mute, normal, meeting etc.

Tags and activities are separate concepts, tags are traversal and additive, activities are thematic.

Desktop Environment should leads the user how to enter and how to exit from an activity. We should decrease normal desktops visual clutter that confuses the user about his state.

Another problem is how to include external resources if the filter are restrictives, maybe by adding a button in each “Open File” dialog that let us choose to stay in the current activity environment or see all the resources.

Other open problems are how to integrate in this vision externals resources like network infrastructure, network, printers, etc.

Talking about concrete cases, like the recent documents menu, why not make it central for a desktop or expand it to order it for ( I often need this ) creation date, write date, access timestamp or access frequency, category?

Why not display this menu in a cloud representation? More, the vertical list used is a very short and useless representation. A timeline can be more useful.

Different activities can be created for different purposes even using same programs.

In a desktop system I can save programs state on disk passing from an activity to another one, but not on phone system for device limits.

Anyway each journey begins with a single step, and Plasma is a good one.

http://techbase.kde.org/Projects/Plasma

Friday, March 20, 2009

A Journey to WebKit via Plasmaland.

While writing a little Plasma utility I was tempted to use the new QT WebKit toolkit to handle the User Interface.

To integrate WebKit in a KDE or QT program is no too diffcult, thanks to metadata that QT adds to C++ classes. It is possible to call directly methods of objects resident in our program from HTML pages via Javascipt taking advantage of slot and signals mechanism.

Firstly, we need to insert references to our application C++ objects in HTML pages, as if thery were native JavaScript variables, using an identifier that will be mapped later to physical objects.

After that we can encode JavaScript functions that take advantage of the methods declared as slots, at certain events, such as pressing a button.

We can then excute embedded objects methods from HTML passing as parameters a HTML level defined entities, such as the values of a form fields.

Each link between WebKit and our application will begin through Javascript functions, so WebKit will commence operations but we can call frame 'evaluateJavascript' to execute a script in the frame context from our host program.

Let's do an example:

Suppose that our goal is to recall the method 'reload' of an instance of a C++ class described in the following way from Javascript :

class DBusApplet : public Plasma::PopupApplet
{
Q_OBJECT
...
public
slots:
void reload(const QString &selection);
private:
...
};

In Javascript our application class instance may be mapped as follows, assuming that it is associated to the variable 'appletInterface':



function execute(selection)
{
appletInterface.reload(selection);
}


Since the conversion of basic types is automatic, what we should do is to 'inject' our C++ objects into WebKit component, but we have to wait until the component alerts us when is the right moment to do it.

After that WebKit has fully laoded a HTML page, assigned by the program directly as string or through a URL, the current frame emits the signal "javaScriptWindowObjectCleared" which must have taken care of in the usual way that QT will make available:


connect(page()->mainFrame(),

SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(populateJavaScriptWindowObject()));

Upon receipt of the signal our 'populateJavaScriptWindowObject' method will be called so we can assign the reference of our objects to WebKit using frame 'addToJavaScriptWindowObject' method, whose arguments are the name of Javascript variable that will contain the reference, and our object address.

page->mainFrame()->addToJavaScriptWindowObject(”appletInterface”, this);


http://doc.trolltech.com/4.4/qtwebkit.html

http://webkit.org/

http://code.google.com/p/dbusapplet/

Friday, January 4, 2008

Happy Birthday KDE 4.0.0

Maybe it is not the move that can save the mankind or a masterpiece like the Gioconda, but KDE 4.0.0 is virtually ready for the half January release, in a style event at the Google base in Mountain View.
Actual version is not going to be an environment designed to replace KDE 3.5 right now, but instead it is a base over which tomorrow's KDE can grow. Open Source software development process is different from proprietary software one and Aaron Seigo's post explains how: http://aseigo.blogspot.com/2008/01/talking-bluntly.html.
Last moment translations (and code freeze) hurry and chaos to respect the settled deadline, seemed to me the mood of a newspaper. After all, more than 700 commit in a couple of days is not a usual event.
Maybe it is too late for desktop applications, but KDE Four is a really charming adventure.

Good Year, KDE; on Monday we have to return to work using Windows :(

Sunday, December 9, 2007

Android: how to show items with different styles in a ListView

In the Android environment we can visualize ListView items using ArrayAdapter object, which act as interface between textual data representation and ListView. Its constructor accept a layout resource id pointing to a TextView instanced at each data row visualization.
If we have the need to present the various items with different layouts, we can do it in a simple way by using the excellent engineering of the base Adapter class, adapting it for our needs. Let's suppose to want to show an icon next to the textual item description if item text contains a given character sequence, let's say it starts with 'a' character to make a simple example.
First of all we need two View class derived objects to show the data into the ListView. The first one, 'SView1' in our example, simply derives from TextView class and it will be populated with text string passed as parameter in its constructor.

public class SView1 extends TextView {
TextView mText;
public SView1 (Context context, String text)
{
super(context);
setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT));
setText(text);
}
}

The second one, 'SView2', is slightly more complex and extends LinearLayout, a class designed to group and organize child Views. In SView2 we'll create two children objects, an ImageView to handle the icon, read from the resources, and a TextView which will contains the data strings.

public class SView2 extends LinearLayout {
String Title="";
TextView mText;
ImageView mView;
public SView2 (Context context, String text)
{
super(context);
this.setOrientation(HORIZONTAL);
setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT));
mView = new ImageView(mContext);
mView.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT));
mView.setImageResource(R.drawable.icon);
addView(mView);
mText = new TextView(context);
mText.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT));
addView(mText);
setText(text);
}
public void setText(String text)
{
mText.setText(text);
}
}

Now we have only to personalize the data hander, Adapter class. We can create a class that extends directly ArrayAdapter<> class. The data handling methods can be inherited from the superclass, by overloading only getView() method, called by parent ListView, at each data row visualization. What we will do in this method is only to check string content, and decide view type, SView1 or SView2 instantiate. Parent ListView can propose us to reuse an existent View object, if we want to use it, we should check that the proposed View type is coherent with data. Final step is in the Activity object: we should instantiate an Adapter e populate it with our data.

I was forgetting: yesterday RubyOnRails 2.0 was born, congratulations.
http://weblog.rubyonrails.org/2007/12/7/rails-2-0-it-s-done

Adapter:
public class SimpleStringAdapter extends ArrayAdapter {

public SimpleStringAdapter(Context context, List Items ) {
super(context,R.layout.a,Items);
}
public View getView(int position, View convertView, ViewGroup parent) {
String s = getItem(position);
boolean isType1 = true;
if( s==null )
s = "";
if(s.startsWith("a"))
{
isType1 = false;
}
if(isType1)
{
SView1 theView ;
if((null==convertView )||!(convertView instanceof SView1))
theView = new SView1(super.getContext(),s);
else
{
theView = (SView1)convertView;
theView.setText(s);
}
return theView ;
} else
{
SView2 theView ;
if((null==convertView )||!(convertView instanceof SView2))
theView = new SView2(super.getContext(),s);
else
{
theView = (SView2)convertView;
theView.setText(s);
}
return theView ;
}
}
}

Activity:

public class SimpleView extends ListActivity {
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);

List items = new ArrayList();
items.add("a riga 1");
items.add("a riga 2");
items.add("b riga 3");
items.add("a riga 4");

SimpleStringAdapter strings =
new SimpleStringAdapter(this, items);
setListAdapter(strings);
}
}

Thursday, December 6, 2007

Life with Android

I was finally able to explore the Android development environment. The first thing I noted is the easy SDK installation process, you only have to unzip a file and to set an environment variable. If you want to use Eclipse as development environment, you need to download a plugin from Google site. A wonderful thing is the porting of the SDK under different Operating Systems: Linux, MacOS and Windows.
The SDK comes with a good emulator included but sometimes, at least in Linux environment, it loses the synchronism with Eclipse in debug phase.
Anyway the tools used under the hood are command line commands, adb in this case, that reside in SDK tools directory, and in a hurry we can kill its process so Eclipse can restart it in its next debug session. The same SDK seems to be the first step toward a more complete system and various features are reporting not working in the project mailing list. All things considered Android is a very good first step, documentation is complete and it covers each toolkit area, but we can expect a good growth. As a pilot project I wrote a little program to read planet.kde.org
feeds, one of my favorite sites. I explored some Android technologies, background services, sqlite database, custom views, and integrated browser, and I enjoyed the system very much, even though I didn't explore multimedia features. The project has been published on Google Code at http://code.google.com/p/planetandroid/ address. The license is obviously GPL.