From 5842171d635eaef4b15b71dabffa7e36e6910479 Mon Sep 17 00:00:00 2001 From: Sam Bosley Date: Thu, 27 Sep 2012 11:59:16 -0700 Subject: [PATCH] Screen flow update messages basically working, dialog text color refactor --- astrid/AndroidManifest.xml | 3 +- .../subtasks/OrderedListFragmentHelper.java | 2 +- .../todoroo/astrid/service/ThemeService.java | 15 ++++-- .../astrid/service/UpdateMessageService.java | 49 ++++++++++++------- .../astrid/service/UpgradeService.java | 2 +- .../astrid/ui/TaskListFragmentPager.java | 2 +- 6 files changed, 47 insertions(+), 26 deletions(-) diff --git a/astrid/AndroidManifest.xml b/astrid/AndroidManifest.xml index 074592751..a610c530a 100644 --- a/astrid/AndroidManifest.xml +++ b/astrid/AndroidManifest.xml @@ -168,7 +168,8 @@ + android:screenOrientation="portrait" + android:theme="@android:style/Theme.Dialog"/> diff --git a/astrid/plugin-src/com/todoroo/astrid/subtasks/OrderedListFragmentHelper.java b/astrid/plugin-src/com/todoroo/astrid/subtasks/OrderedListFragmentHelper.java index dae32877e..22fd07b54 100644 --- a/astrid/plugin-src/com/todoroo/astrid/subtasks/OrderedListFragmentHelper.java +++ b/astrid/plugin-src/com/todoroo/astrid/subtasks/OrderedListFragmentHelper.java @@ -110,7 +110,7 @@ public class OrderedListFragmentHelper { "subtasks_horizontal.png", getActivity().getString(R.string.subtasks_help_3)); - String color = ThemeService.getDialogTextColor(); + String color = ThemeService.getDialogTextColorString(); String html = String.format("%s", color, body); diff --git a/astrid/src/com/todoroo/astrid/service/ThemeService.java b/astrid/src/com/todoroo/astrid/service/ThemeService.java index c2dd69132..4c98b2d66 100644 --- a/astrid/src/com/todoroo/astrid/service/ThemeService.java +++ b/astrid/src/com/todoroo/astrid/service/ThemeService.java @@ -112,18 +112,25 @@ public class ThemeService { return theme; } - public static String getDialogTextColor() { + public static int getDialogTextColor() { if (AndroidUtilities.getSdkVersion() >= 11) { int theme = getTheme(); if (theme == R.style.Theme || theme == R.style.Theme_Transparent) - return "white"; + return android.R.color.white; else - return "black"; + return android.R.color.black; } else { - return "white"; + return android.R.color.white; } } + public static String getDialogTextColorString() { + int color = getDialogTextColor(); + if (color == android.R.color.white) + return "white"; + return "black"; + } + public static int getDrawable(int lightDrawable) { return getDrawable(lightDrawable, 0); } diff --git a/astrid/src/com/todoroo/astrid/service/UpdateMessageService.java b/astrid/src/com/todoroo/astrid/service/UpdateMessageService.java index 64c832aae..d8d9e5f36 100644 --- a/astrid/src/com/todoroo/astrid/service/UpdateMessageService.java +++ b/astrid/src/com/todoroo/astrid/service/UpdateMessageService.java @@ -16,14 +16,17 @@ import org.weloveastrid.rmilk.MilkUtilities; import android.app.Activity; import android.app.AlertDialog; +import android.app.Dialog; import android.content.Intent; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.text.Spannable; import android.text.TextUtils; +import android.text.method.LinkMovementMethod; import android.text.style.ClickableSpan; import android.view.View; +import android.view.View.OnClickListener; import android.view.WindowManager.BadTokenException; import android.widget.TextView; @@ -37,9 +40,7 @@ import com.todoroo.andlib.service.RestClient; import com.todoroo.andlib.sql.Query; import com.todoroo.andlib.utility.AndroidUtilities; import com.todoroo.andlib.utility.DialogUtilities; -import com.todoroo.astrid.actfm.ActFmLoginActivity; import com.todoroo.astrid.actfm.sync.ActFmPreferenceService; -import com.todoroo.astrid.activity.EditPreferences; import com.todoroo.astrid.dao.StoreObjectDao; import com.todoroo.astrid.dao.StoreObjectDao.StoreObjectCriteria; import com.todoroo.astrid.data.StoreObject; @@ -79,19 +80,20 @@ public class UpdateMessageService { JSONArray updates = checkForUpdates(); System.err.println("UPDATES: " + updates); - try { - JSONObject test = new JSONObject(); - test.put("date", "09/26/12"); - test.put("message", "Screens!"); - test.put("type", "screen"); - JSONArray screenArray = new JSONArray(); - screenArray.put(ActFmLoginActivity.class.getName()); - screenArray.put(EditPreferences.class.getName()); - test.put("screens", screenArray); - updates.put(test); - } catch (JSONException e) { - e.printStackTrace(); - } +// try { +// JSONObject test = new JSONObject(); +// test.put("date", "09/26/12"); +// test.put("message", "Screens!"); +// test.put("type", "screen"); +// test.put("link", "Click me"); +// JSONArray screenArray = new JSONArray(); +// screenArray.put(ActFmLoginActivity.class.getName()); +// screenArray.put(EditPreferences.class.getName()); +// test.put("screens", screenArray); +// updates.put(test); +// } catch (JSONException e) { +// e.printStackTrace(); +// } if(updates == null || updates.length() == 0) return; @@ -129,18 +131,29 @@ public class UpdateMessageService { final DialogShower shower; if (message instanceof Spannable) { final TextView textView = new TextView(activity); + textView.setText(message); + textView.setTextSize(16); + textView.setTextColor(activity.getResources().getColor(ThemeService.getDialogTextColor())); + textView.setMovementMethod(LinkMovementMethod.getInstance()); shower = new DialogShower() { @Override public void showDialog(Activity a) { - new AlertDialog.Builder(a) + final Dialog d = new AlertDialog.Builder(a) .setTitle(R.string.UpS_updates_title) .setView(textView) .setPositiveButton(R.string.DLG_ok, null) - .show(); + .create(); + textView.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + d.dismiss(); + } + }); + d.show(); } }; } else { - String color = ThemeService.getDialogTextColor(); + String color = ThemeService.getDialogTextColorString(); final String html = "" + message + ""; shower = new DialogShower() { diff --git a/astrid/src/com/todoroo/astrid/service/UpgradeService.java b/astrid/src/com/todoroo/astrid/service/UpgradeService.java index 9702c5202..1acd8a699 100644 --- a/astrid/src/com/todoroo/astrid/service/UpgradeService.java +++ b/astrid/src/com/todoroo/astrid/service/UpgradeService.java @@ -540,7 +540,7 @@ public final class UpgradeService { return; changeLog.append("Enjoy!"); - String color = ThemeService.getDialogTextColor(); + String color = ThemeService.getDialogTextColorString(); String changeLogHtml = "" + changeLog; DialogUtilities.htmlDialog(context, changeLogHtml, diff --git a/astrid/src/com/todoroo/astrid/ui/TaskListFragmentPager.java b/astrid/src/com/todoroo/astrid/ui/TaskListFragmentPager.java index 07c76d129..1fed544c1 100644 --- a/astrid/src/com/todoroo/astrid/ui/TaskListFragmentPager.java +++ b/astrid/src/com/todoroo/astrid/ui/TaskListFragmentPager.java @@ -117,7 +117,7 @@ public class TaskListFragmentPager extends ViewPager { "subtasks_horizontal.png", activity.getString(R.string.swipe_lists_helper_subtitle)); - String color = ThemeService.getDialogTextColor(); + String color = ThemeService.getDialogTextColorString(); String html = String.format("%s", color, body);