Page 1 of 1

[Android Client] Adding DashClock support - Help needed

Posted: 20 May 2013, 21:15
by mcbyte
I Forked the Android client source and started adding to it support for the DashClock app.

Making DashClock extensions is very easy, sample app is here: https://code.google.com/p/dashclock/

And I already made the first part by making the initial code, that displays a static count on the dashclock (check attachment), but how can I get the Unread count of all feeds? I can't seem to find the single location that returns the total count of unread articles.

hope someone can point me to the correct place, so that I can later make a pull request to make this an official feature.

Re: [Android Client] Adding DashClock support - Help needed

Posted: 20 May 2013, 21:25
by fox
> I can't seem to find the single location that returns the total count of unread articles.

I... oh.

Re: [Android Client] Adding DashClock support - Help needed

Posted: 21 May 2013, 11:14
by mcbyte
I checked the most of the classes for methods that seems to do what I want, but found nothing that can be used. There is in the HeadlinesActivity a refresh method, but it is protected.

any help would be appreciated.

here is my DashClock class:

Code: Select all

package org.fox.ttrss;

import java.util.Date;
import android.content.Intent;
import com.google.android.apps.dashclock.api.DashClockExtension;
import com.google.android.apps.dashclock.api.ExtensionData;

public class DashClock extends DashClockExtension {
   @Override
   protected void onInitialize(boolean isReconnect) {
      super.onInitialize(isReconnect);
      setUpdateWhenScreenOn(true);
   }

   @Override
   protected void onUpdateData(int reason) {
      HeadlinesActivity ha = new HeadlinesActivity();
      /*
       * Do something here to get unread count, for now just a static number
       */
      int allUnread = 6;

      ExtensionData updatedData = null; // when null DashClock hides the widget

      if (allUnread > 0) {
         updatedData = new ExtensionData();
         updatedData.visible(true);

         updatedData.icon(R.drawable.icon);
         updatedData.status(String.valueOf(allUnread));

         updatedData.expandedTitle(getString(R.string.app_name));
         updatedData.expandedBody(allUnread + " new unread articles");

         updatedData.clickIntent(new Intent().setClassName("org.fox.ttrss",
               "org.fox.ttrss.OnlineActivity"));
      }
      publishUpdate(updatedData);
   }
}

Re: [Android Client] Adding DashClock support - Help needed

Posted: 21 May 2013, 14:30
by fox
Make an API request, parse the results.

Re: [Android Client] Adding DashClock support - Help needed

Posted: 21 May 2013, 17:35
by mcbyte
Ok fox, I checked how API Requests works and it seems I have a working DashClock extension.

I made a commit of my changes to my fork on the github, which can be found here. the code need some cleaning maybe, and also the icons (DashClock takes the icon and make whatever is not transparent to white, and the transparent remains transparent, currently I did a quick and dirty work on the icon to make it OK for dashclock).

Update:
and I just discovered that today you released an update that includes a 1x1 widget, which does exactly what I wanted, but I did mine by myself....

Re: [Android Client] Adding DashClock support - Help needed

Posted: 21 May 2013, 18:31
by fobe
Would you be so kind to post it on this forum, so I can also test/check it?

Re: [Android Client] Adding DashClock support - Help needed

Posted: 22 May 2013, 15:47
by mcbyte
For the information, Andrew included this feature in TinyTiny RSS version 1.7.8, already downloadable from the Google Play Store.

Thanks...