From 8b4b79db88350e2b25c487071bc14508b8d8f561 Mon Sep 17 00:00:00 2001 From: Tim Su Date: Tue, 10 Aug 2010 00:19:07 -0700 Subject: [PATCH] Added default dashboard option. It's not hooked up to anything right now. --- .../producteev/ProducteevPreferences.java | 41 +++++++++++++++++++ .../producteev/ProducteevUtilities.java | 6 +++ astrid/res/values/keys.xml | 1 + astrid/res/values/strings-producteev.xml | 17 +++++++- astrid/res/xml/preferences_producteev.xml | 6 ++- 5 files changed, 68 insertions(+), 3 deletions(-) diff --git a/astrid/plugin-src/com/todoroo/astrid/producteev/ProducteevPreferences.java b/astrid/plugin-src/com/todoroo/astrid/producteev/ProducteevPreferences.java index 66247ab13..e2d135a6c 100644 --- a/astrid/plugin-src/com/todoroo/astrid/producteev/ProducteevPreferences.java +++ b/astrid/plugin-src/com/todoroo/astrid/producteev/ProducteevPreferences.java @@ -1,8 +1,13 @@ package com.todoroo.astrid.producteev; import android.content.Intent; +import android.content.res.Resources; +import android.os.Bundle; +import android.preference.ListPreference; +import android.preference.Preference; import com.timsu.astrid.R; +import com.todoroo.andlib.utility.AndroidUtilities; import com.todoroo.astrid.common.SyncProviderPreferences; import com.todoroo.astrid.common.SyncProviderUtilities; import com.todoroo.astrid.producteev.sync.ProducteevSyncProvider; @@ -37,5 +42,41 @@ public class ProducteevPreferences extends SyncProviderPreferences { return ProducteevUtilities.INSTANCE; } + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + ListPreference defaultDash = (ListPreference)findPreference(getString(R.string.producteev_PPr_defaultdash_key)); + if(ProducteevUtilities.INSTANCE.isLoggedIn()) { + // + } + String[] entries = new String[2]; + entries[0] = getString(R.string.producteev_no_dashboard); + entries[1] = getString(R.string.producteev_default_dashboard); + + String[] entryValues = new String[2]; + entryValues[0] = Integer.toString(ProducteevUtilities.DASHBOARD_NO_SYNC); + entryValues[1] = Integer.toString(ProducteevUtilities.DASHBOARD_DEFAULT); + defaultDash.setEntries(entries); + defaultDash.setEntryValues(entryValues); + } + @Override + public void updatePreferences(Preference preference, Object value) { + super.updatePreferences(preference, value); + final Resources r = getResources(); + + if (r.getString(R.string.producteev_PPr_defaultdash_key).equals( + preference.getKey())) { + int index = AndroidUtilities.indexOf(((ListPreference)preference).getEntryValues(), (String)value); + if(index == -1) + index = 1; + if(index == 0) + preference.setSummary(R.string.producteev_PPr_defaultdash_summary_none); + else + preference.setSummary(r.getString( + R.string.producteev_PPr_defaultdash_summary, + ((ListPreference)preference).getEntries()[index])); + } + } } \ No newline at end of file diff --git a/astrid/plugin-src/com/todoroo/astrid/producteev/ProducteevUtilities.java b/astrid/plugin-src/com/todoroo/astrid/producteev/ProducteevUtilities.java index e1578bbfd..fb6dc7d2d 100644 --- a/astrid/plugin-src/com/todoroo/astrid/producteev/ProducteevUtilities.java +++ b/astrid/plugin-src/com/todoroo/astrid/producteev/ProducteevUtilities.java @@ -19,6 +19,12 @@ public class ProducteevUtilities extends SyncProviderUtilities { public static final ProducteevUtilities INSTANCE = new ProducteevUtilities(); + /** setting for dashboard to not synchronize */ + public static final int DASHBOARD_NO_SYNC = -1; + + /** setting for dashboard to use default one */ + public static final int DASHBOARD_DEFAULT = 0; + @Override public String getIdentifier() { return IDENTIFIER; diff --git a/astrid/res/values/keys.xml b/astrid/res/values/keys.xml index 186095a6f..89a23d4cf 100644 --- a/astrid/res/values/keys.xml +++ b/astrid/res/values/keys.xml @@ -211,6 +211,7 @@ producteev_sync_freq producteev_email producteev_password + producteev_defaultdash diff --git a/astrid/res/values/strings-producteev.xml b/astrid/res/values/strings-producteev.xml index 80b353b3d..77faecaec 100644 --- a/astrid/res/values/strings-producteev.xml +++ b/astrid/res/values/strings-producteev.xml @@ -5,13 +5,28 @@ - Producteev dashboard: %s + Workspace: %s Producteev + + Default Workspace + + + Do Not Synchronize + + + Default Workspace + + + New tasks will be added to: %s + + + New tasks will not be synchronized by default + diff --git a/astrid/res/xml/preferences_producteev.xml b/astrid/res/xml/preferences_producteev.xml index d99d0fe1f..834f91ffe 100644 --- a/astrid/res/xml/preferences_producteev.xml +++ b/astrid/res/xml/preferences_producteev.xml @@ -21,12 +21,15 @@ android:entries="@array/rmilk_MPr_interval_entries" android:entryValues="@array/rmilk_MPr_interval_values" android:title="@string/rmilk_MPr_interval_title" /> + + - @@ -35,7 +38,6 @@ android:key="@string/rmilk_MPr_forget_key" android:title="@string/rmilk_MPr_forget" android:summary="@string/rmilk_MPr_forget_description" /> - \ No newline at end of file