[TSAM-2289]Saved the state while closing the application. 62/66162/1 accepted/tizen/mobile/20160418.012619 submit/tizen_mobile/20160415.140140
authorRahul Dadhich <r.dadhich@samsung.com>
Fri, 15 Apr 2016 12:45:20 +0000 (18:15 +0530)
committerRahul Dadhich <r.dadhich@samsung.com>
Fri, 15 Apr 2016 12:45:20 +0000 (18:15 +0530)
Change-Id: I15327ced23c348674accb77a91fce65d5a0bc472
Signed-off-by: Rahul Dadhich <r.dadhich@samsung.com>
inc/gallery.h
inc/util/gl-util.h
src/2dview/gl-timeline.c
src/features/gl-main.c
src/gallery.c
src/util/gl-util.c

index d13d12a..a80d5b0 100644 (file)
@@ -21,6 +21,7 @@
 #include <pthread.h>
 #include <app.h>
 #include <efl_extension.h>
+#include <app_preference.h>
 #include <storage.h>
 #include "gl-data.h"
 #include "gl-util.h"
@@ -223,6 +224,8 @@ extern "C"
 #endif
 #define GL_NAVIFRAME_POP_CB_KEY "gl_naviframe_pop_cb_key"
 
+#define GL_LAUNCH_STATE "gallery_launch_state"
+
 /******** Enumeration ********/
 typedef enum _gl_view_mode
 {
index 68e3c90..09efab3 100755 (executable)
@@ -260,6 +260,8 @@ int _gl_dlclose_imageviewer(void *data);
 char *_gl_get_edje_path(void);
 char *_gl_get_directory_path(int storage_directory_type);
 char *_gl_get_root_directory_path(int storage_type);
+void _gl_set_launch_state_preference(void *data);
+bool _gl_get_launch_state_preference();
 
 #ifdef __cplusplus
 }
index 451a481..46ac23b 100644 (file)
@@ -3159,6 +3159,9 @@ static Evas_Object *__gl_timeline_create_list_view(gl_timeline_s *timeline_d, bo
        timeline_d->date_layout = layout;
 
        if (_gl_timeline_create_grid_view(timeline_d, genlist, update) < 0) {
+               if (timeline_d->nocontents) {
+                       return timeline_d->nocontents;
+               }
                return NULL;
        }
 
@@ -4600,6 +4603,7 @@ int _gl_timeline_create_view(void *data, Evas_Object *parent)
                GL_IF_DEL_OBJ(layout);
                return -1;
        }
+       _gl_main_add_reg_idler(ad);
        timeline_d->view = view;
        elm_object_part_content_set(timeline_d->layout, "elm.swallow", view);
 
index ee8545e..3137307 100644 (file)
@@ -483,7 +483,11 @@ Eina_Bool _gl_main_update_view(void *data)
        _gl_data_get_cluster_list(ad);
        GL_CHECK_FALSE(ad->albuminfo.elist);
        gl_dbg("_gl_data_get_cluster_list:done");
-       _gl_ctrl_show_view(data, GL_STR_ALBUMS);
+       if(_gl_get_launch_state_preference()) {
+               _gl_ctrl_show_view(data, "Timeline");
+       } else {
+               _gl_ctrl_show_view(data, GL_STR_ALBUMS);
+       }
        gl_dbg("done");
        GL_PROFILE_OUT;
        return ECORE_CALLBACK_CANCEL;
@@ -495,7 +499,6 @@ int _gl_main_reset_view(void *data)
        gl_appdata *ad = (gl_appdata *)data;
        GL_CHECK_VAL(ad->maininfo.win, -1);
        int view_mode = gl_get_view_mode(ad);
-       gl_dbg("");
 
        if (view_mode == GL_VIEW_NONE) {
                /* First launch gallery then show shortcut album/tag */
@@ -503,10 +506,17 @@ int _gl_main_reset_view(void *data)
                gl_dbg("Launch gallery at the first time");
                _gl_data_get_cluster_list(ad);
                GL_CHECK_VAL(ad->albuminfo.elist, -1);
-               /* Set view mode */
-               gl_set_view_mode(ad, GL_VIEW_ALBUMS);
-               /* Select tabbar item contains shortcut item */
-               _gl_ctrl_show_view(data, GL_STR_ALBUMS);
+               if(_gl_get_launch_state_preference()) {
+                       /* Set view mode */
+                       gl_set_view_mode(ad, GL_VIEW_TIMELINE);
+                       /* Select tabbar item contains shortcut item */
+                       _gl_ctrl_show_view(data, "Timeline");
+               } else {
+                       /* Set view mode */
+                       gl_set_view_mode(ad, GL_VIEW_ALBUMS);
+                       /* Select tabbar item contains shortcut item */
+                       _gl_ctrl_show_view(data, GL_STR_ALBUMS);
+               }
                /* Register servier if albums view wasn't created */
                _gl_main_add_reg_idler(data);
        }
index 9d19bf6..8b7017c 100644 (file)
@@ -136,6 +136,7 @@ static void _gallery_terminate(void *data)
 {
        gl_dbgW("==Terminate==");
        GL_CHECK(data);
+       _gl_set_launch_state_preference(data);
        _gallery_close_app(data);
 }
 
index f9bee1a..c16a8f2 100644 (file)
@@ -2535,3 +2535,28 @@ char *_gl_get_root_directory_path(int storage_type)
        storage_get_root_directory(storage_type, &path);
        return path;
 }
+
+void _gl_set_launch_state_preference(void *data)
+{
+       int ret;
+       if (gl_get_view_mode(data) == GL_VIEW_TIMELINE) {
+               ret = preference_set_boolean(GL_LAUNCH_STATE, true);
+       } else {
+               ret = preference_set_boolean(GL_LAUNCH_STATE, false);
+       }
+       if (ret != PREFERENCE_ERROR_NONE) {
+               gl_dbgE(" Unable to set preference for launch State ERROR(%d)", ret);
+       }
+}
+
+bool _gl_get_launch_state_preference()
+{
+       int ret;
+       bool launch_state = true;
+       ret = preference_get_boolean(GL_LAUNCH_STATE, &launch_state);
+       if (ret != PREFERENCE_ERROR_NONE) {
+               gl_dbgE("Unable to get preference for launch State ERROR(%d)",ret);
+               return false;
+       }
+       return launch_state;
+}