Tab ordering is stored using the preference api.
Whenever the user swaps the position of two tabs
the preference keys are updated.
When the aplication is launched the tab order
is set using the positions stored in the preferences
Change-Id: Ic2f639f7aba4d06e5a98736a736062e3da786950
Signed-off-by: Michal Skorupinski <m.skorupinsk@samsung.com>
src/common/utils.c
src/common/viewmgr.c
src/data/settings_picture.c
+ src/data/settings_preferences.c
src/data/system/settings_clock.c
src/data/system/settings_language.c
src/data/system/settings_pincode.c
--- /dev/null
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __AIR_SETTINGS_PREFERENCES_H__
+#define __AIR_SETTINGS_PREFERENCES_H__
+
+bool settings_preferences_tab_order_get(int tab_index, char **ret_value);
+bool settings_preferences_tab_order_set(int tab_index, const char *new_value);
+
+#endif
--- /dev/null
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdbool.h>
+#include <app_preference.h>
+#include <Eina.h>
+#include "app_debug.h"
+
+#define PREFERENCE_TAB_ORDERING_FORMAT "tab_ordering_%d"
+
+bool settings_preferences_tab_order_get(int tab_index, char **ret_value)
+{
+ Eina_Stringshare *key = eina_stringshare_printf(PREFERENCE_TAB_ORDERING_FORMAT, tab_index);
+ bool is_key_existing = false;
+ int ret = preference_is_existing(key, &is_key_existing);
+
+ if(ret != PREFERENCE_ERROR_NONE) {
+ _ERR("Could not check the existence of key: %s. Error message: %s", key, get_error_message(ret));
+ eina_stringshare_del(key);
+ return false;
+ }
+
+ if(!is_key_existing) {
+ _ERR("The key: %s doesn't exist", key);
+ eina_stringshare_del(key);
+ return false;
+ }
+
+ ret = preference_get_string(key, ret_value);
+ if(ret != PREFERENCE_ERROR_NONE) {
+ _ERR("Could not get the key value. Key: %s. Error message: %s", key, get_error_message(ret));
+ eina_stringshare_del(key);
+ return false;
+ }
+
+ eina_stringshare_del(key);
+ return true;
+}
+
+bool settings_preferences_tab_order_set(int tab_index, const char *new_value)
+{
+ Eina_Stringshare *key = eina_stringshare_printf(PREFERENCE_TAB_ORDERING_FORMAT, tab_index);
+
+ int ret = preference_set_string(key, new_value);
+ if(ret != PREFERENCE_ERROR_NONE) {
+ _ERR("Could not get the key value. Key: %s. Error message: %s", key, get_error_message(ret));
+ eina_stringshare_del(key);
+ return false;
+ }
+
+ eina_stringshare_del(key);
+ return true;
+}
#include "common/layoutmgr.h"
#include "common/utils.h"
#include "common/viewmgr.h"
+#include "data/settings_preferences.h"
#include "define.h"
#include "layout.h"
#include "view/view_action_menu.h"
inputmgr_add_callback(priv->menu[item1], item1, &_menu_input_handler, priv);
inputmgr_add_callback(priv->menu[item2], item2, &_menu_input_handler, priv);
+
+ settings_preferences_tab_order_set(item1, _mdata_p[item1]->layout_id);
+ settings_preferences_tab_order_set(item2, _mdata_p[item2]->layout_id);
}
static void _show_toast_message(Evas_Object *parent, char *text)
priv->cur_menu = i;
}
+static struct _menu_data *_find_layout_by_id(char *layout_id)
+{
+ int i = 0;
+ for (i = 0; i < LAYOUT_MAX; ++i) {
+ if (!strcmp(_mdata[i].layout_id, layout_id))
+ return &_mdata[i];
+ }
+
+ _ERR("Layout %d NOT found", layout_id);
+ return NULL;
+}
+
+static void _tab_order_restore(void)
+{
+ char *layout_id = NULL;
+ struct _menu_data *found_md = NULL;
+
+ int i = 0;
+ for(i = 0; i < LAYOUT_MAX; ++i)
+ {
+ if(!settings_preferences_tab_order_get(i, &layout_id)) {
+ settings_preferences_tab_order_set(i, _mdata[i].layout_id);
+ } else {
+ found_md = _find_layout_by_id(layout_id);
+ if (!found_md) {
+ _ERR("found_md == NULL");
+ continue;
+ }
+
+ _mdata_p[i] = found_md;
+ }
+ }
+}
+
static Evas_Object *_create(Evas_Object *win, void *data)
{
SETTING_TRACE_BEGIN;
return NULL;
}
+ _tab_order_restore();
+
priv->base = utils_add_layout(win, GRP_VIEW_BASE, EINA_TRUE);
if (!priv->base) {
_ERR("Add layout failed.");