Project JStock Development Blog

Keep track the development progress of JStock - Free Stock Market Software and JStock Android

Saturday, June 28, 2014

Google Finance is now being supported for 6 countries

I'm extremely happy to announce that, realtime Google Finance is now being supported for countries US, UK, Singapore, Taiwan, China and India. For more information, please refer to http://www.jstock.org/help_real_time_info.html#delay

If you like our work so far, a little donation does show BIG encouragement. Thank you! http://www.jstock.org/donation.html

Very soon, we should see realtime Google Finance being supported in JStock Android as well. Porting work is still in progress.

Sunday, June 01, 2014

Upcoming development plans for June and onward

Although we have 3 releases in May, the development progress is some how sluggish. Here's what I wish to accomplish in next coming months.

Support both Yahoo! and Google Finance
Currently, only India is using Google Finance data feed. There's technical barrier which holds us to make Google Finance work for other countries.

Our core stock engine is RealTimeStockMonitor. If our watchlist contains both United States (assume Google Finance is picked for United States) and Malaysia (assume Yahoo Finance is picked for Malaysia) stocks, JStock won't work. RealTimeStockMonitor only able to support single country stock server factory, not multiple countries stock server factories.

Re-architecture the entire RealTimeStockMonitor to support multiple countries stock server factories is essential

Displays multiple countries watchlist in single page
Ability to display both United State stocks & Malaysia stocks in single page.

Split & merge stock in JStock Android

Revise UI/UX for dividend page in JStock Android

Thursday, May 29, 2014

Launch chart and news info from portfolio page directly

Previously, if we were in portfolio page, in order to launch chart and news info page, we need to switch back to watchlist page. In upcoming release, we are going to add an info button in detailed buy/sell info page. 

With such newly added button, you may launch chart and news info page, without having to leave portfolio page.


Wednesday, May 28, 2014

New notification UI for JStock Android's background alert feature

For users who have access to "background alert" feature, we had fine tuned notification UI. We had implemented multi-line notification. On the left hand side, it will be the new upcoming UI. The right hand side is current old UI.

This feature will be available in next few days. Stay tune




Wednesday, May 07, 2014

JStock is using highly secure oAuth 2.0 for Google Drive (Cloud feature) and Google Calendar (SMS alert feature)

Google is slowly depreciated non oAuth 2.0 authentication. To adapt such changes, we make JStock to use highly secure oAuth 2.0 for Google Drive (Cloud feature) and Google Calendar (SMS alert feature).

Kindly let us know, if you encounter any problem with these new features.




Sunday, April 20, 2014

Upcoming plan for JStock


  1. Migration from username/password authentication to oAuth 2.0 authentication. All cloud data shall be migrated to appdata scope. This is a very critical and urgent move, as it takes time for users to perform such migration. Note, we had to complete all migration before August 2014, when old API deprecated.
  2. Provides presentation chart, so that users can find out their investment return of multiple countries in single glance.

Wednesday, April 09, 2014

Technical sharing on recent launched home widget feature


With recent launched of JStock Android, I manage to deliver home widget feature (finally). It took much longer time than I initial estimation. 8 weeks! (I work on it part-time)

Developing home widget is harder than I thought. There're 2 reasons for that.

No direct access to UI components

Developer doesn't have direct access to UI components of home widget. All UI manipulation, like setting text, is done through service. Service is only able to help developer to "set" UI's attributes. When developer wants to "get" UI's attributes, he can't! The only way is
  • When setting an attribute of an UI, like setting text for a TextView, save the attribute value in persistence storage. For instance, SharedPreferences, SQLite, ...
  • To get an attribute of an UI, read from previous stored value in SharedPreferences, SQLite, ...

No easy way to store current state of home widget

To fetch the latest stock price, and show it in ListView, here's what my first attempt looks like :-

1st Wrong Attempt - Doesn't use user thread and store data in static variables

public class JStockAppWidgetProvider extends AppWidgetProvider {
  public static final Map<Integer, Stock> stocksMap = new java.util.concurrent.ConcurrentHashMap<Integer, Stock>();

  @Override
  public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
    for (int appWidgetId : appWidgetIds) {
      List<Stock> stocks = getStocks(appWidgetId);      
      stocksMap.put(appWidgetId, stocks);
      appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetId, android.R.id.list);
    }
  }
}

// For ListView updating
public class AppWidgetRemoteViewsService extends RemoteViewsService {
  @Override
  public void onDataSetChanged() {
    this.stocks = JStockAppWidgetProvider.stocksMap.get(appWidgetId);
  }
}

There're 2 problem with such approach.
  • getStocks is a time consuming operation. It should be done in user thread.
  • Android OS might destroy AppWidgetProvider anytime. Hence, RemoteViewsService might get a null value.
2nd Attempt - Still not optimized

public class JStockAppWidgetProvider extends AppWidgetProvider {
  private static ExecutorService executor = Executors.newFixedThreadPool(1);

  @Override
  public void onUpdate(Context context, final AppWidgetManager appWidgetManager, 
    final int[] appWidgetIds) 
  {
    Runnable runnable = new Runnable() {
      @Override
      public void run() {
        for (int appWidgetId : appWidgetIds) {
          List<Stock> stocks = getStocks(appWidgetId);      
          storeStocksInSQLite(appWidgetId, stocks);
          appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetId, android.R.id.list);
      }
    };
    executor.execute(runnable);
  }
}

// For ListView updating
public class AppWidgetRemoteViewsService extends RemoteViewsService {
  @Override
  public void onDataSetChanged() {
    this.stocks = readStocksFromSQLite(appWidgetId);
  }
}

This solution is not optimized yet. As, having to perform DB read access for every onDataSetChanged doesn't sound good to me. (Consume more battery, slower, ...) I modify the above code slightly, to reduce number of DB read access.

3rd Attempt - Optimized solution

public class JStockAppWidgetProvider extends AppWidgetProvider {
  public static final Map<Integer, Stock> stocksMap = new java.util.concurrent.ConcurrentHashMap<Integer, Stock>();
  private static ExecutorService executor = Executors.newFixedThreadPool(1);

  @Override
  public void onUpdate(Context context, final AppWidgetManager appWidgetManager, 
    final int[] appWidgetIds) 
  {
    Runnable runnable = new Runnable() {
      @Override
      public void run() {
        for (int appWidgetId : appWidgetIds) {
          List<Stock> stocks = getStocks(appWidgetId);      
          storeStocksInSQLite(appWidgetId, stocks);
          stocksMap.put(appWidgetId, stocks);
          appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetId, android.R.id.list);
      }
    };
    executor.execute(runnable);
  }
}

// For ListView updating
public class AppWidgetRemoteViewsService extends RemoteViewsService {
  @Override
  public void onDataSetChanged() {
    this.stocks = JStockAppWidgetProvider.stocksMap.get(appWidgetId);
    // Is JStockAppWidgetProvider destroyed?
    if (this.stocks == null) {
      this.stocks = readStocksFromSQLite(appWidgetId);
    }
  }
}

This is what I had learnt during home widget development process. If you find out any mistake in my finding, feel free to let me know through

Thank you very much :)

Followers