Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

compose message: HACK to fix label colors in dialog

  • Loading branch information...
commit 34056c38b2debd5836067d1d3b9b39fc613671c5 1 parent 3e36c70
@talklittle authored
View
8 res/values-v11/styles.xml
@@ -19,13 +19,17 @@
-->
<resources>
- <style name="Reddit_Light_Dialog" parent="@android:style/Theme.Holo.Light.Dialog" />
+ <color name="reddit_light_dialog_text_color">@color/black</color>
+ <style name="Reddit_Light_Dialog" parent="@android:style/Theme.Holo.Light.Dialog">
+ <item name="android:textColor">@color/reddit_light_dialog_text_color</item>
+ </style>
<style name="Reddit_Light_Dialog_NoTitle" parent="@style/Reddit_Light_Dialog">
<item name="android:windowNoTitle">true</item>
</style>
+ <color name="reddit_dark_dialog_text_color">@color/white</color>
<style name="Reddit_Dark_Dialog" parent="@android:style/Theme.Holo.Dialog">
- <item name="android:textColor">@color/white</item>
+ <item name="android:textColor">@color/reddit_dark_dialog_text_color</item>
</style>
<style name="Reddit_Dark_Dialog_NoTitle" parent="@style/Reddit_Dark_Dialog">
<item name="android:windowNoTitle">true</item>
View
7 res/values/styles.xml
@@ -19,15 +19,18 @@
-->
<resources>
+ <!-- Old Android versions didn't have Dialog.Light -->
+ <color name="reddit_light_dialog_text_color">@color/white</color>
<style name="Reddit_Light_Dialog" parent="@android:style/Theme.Dialog">
- <item name="android:textColor">@color/white</item>
+ <item name="android:textColor">@color/reddit_light_dialog_text_color</item>
</style>
<style name="Reddit_Light_Dialog_NoTitle" parent="@style/Reddit_Light_Dialog">
<item name="android:windowNoTitle">true</item>
</style>
+ <color name="reddit_dark_dialog_text_color">@color/white</color>
<style name="Reddit_Dark_Dialog" parent="@android:style/Theme.Dialog">
- <item name="android:textColor">@color/white</item>
+ <item name="android:textColor">@color/reddit_dark_dialog_text_color</item>
</style>
<style name="Reddit_Dark_Dialog_NoTitle" parent="@style/Reddit_Dark_Dialog">
<item name="android:windowNoTitle">true</item>
View
67 src/com/andrewshu/android/reddit/mail/InboxActivity.java
@@ -49,6 +49,7 @@
import com.andrewshu.android.reddit.common.Common;
import com.andrewshu.android.reddit.common.Constants;
import com.andrewshu.android.reddit.common.RedditIsFunHttpClientFactory;
+import com.andrewshu.android.reddit.common.util.Util;
import com.andrewshu.android.reddit.settings.RedditSettings;
import com.andrewshu.android.reddit.things.ThingInfo;
@@ -155,6 +156,15 @@ protected Dialog onCreateDialog(int id) {
layout = inflater.inflate(R.layout.compose_dialog, null);
dialog = builder.setView(layout).create();
final Dialog composeDialog = dialog;
+
+ setTextColorFromTheme(
+ (TextView) layout.findViewById(R.id.compose_destination_textview),
+ (TextView) layout.findViewById(R.id.compose_subject_textview),
+ (TextView) layout.findViewById(R.id.compose_message_textview),
+ (TextView) layout.findViewById(R.id.compose_captcha_textview),
+ (TextView) layout.findViewById(R.id.compose_captcha_loading)
+ );
+
final EditText composeDestination = (EditText) layout.findViewById(R.id.compose_destination_input);
final EditText composeSubject = (EditText) layout.findViewById(R.id.compose_subject_input);
final EditText composeText = (EditText) layout.findViewById(R.id.compose_text_input);
@@ -164,23 +174,10 @@ protected Dialog onCreateDialog(int id) {
composeSendButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
ThingInfo thingInfo = new ThingInfo();
- // reddit.com performs these sanity checks too.
- if ("".equals(composeDestination.getText().toString().trim())) {
- Toast.makeText(InboxActivity.this, "please enter a username", Toast.LENGTH_LONG).show();
+
+ if (!validateInputFields(composeDestination, composeSubject, composeText, composeCaptcha))
return;
- }
- if ("".equals(composeSubject.getText().toString().trim())) {
- Toast.makeText(InboxActivity.this, "please enter a subject", Toast.LENGTH_LONG).show();
- return;
- }
- if ("".equals(composeText.getText().toString().trim())) {
- Toast.makeText(InboxActivity.this, "you need to enter a message", Toast.LENGTH_LONG).show();
- return;
- }
- if (composeCaptcha.getVisibility() == View.VISIBLE && "".equals(composeCaptcha.getText().toString().trim())) {
- Toast.makeText(InboxActivity.this, "", Toast.LENGTH_LONG).show();
- return;
- }
+
thingInfo.setDest(composeDestination.getText().toString().trim());
thingInfo.setSubject(composeSubject.getText().toString().trim());
new MyMessageComposeTask(
@@ -224,7 +221,43 @@ protected void onPrepareDialog(int id, Dialog dialog) {
}
}
- private class MyMessageComposeTask extends MessageComposeTask {
+ private void setTextColorFromTheme(TextView... textViews) {
+ int color;
+ if (Util.isLightTheme(mSettings.getTheme()))
+ color = getResources().getColor(R.color.reddit_light_dialog_text_color);
+ else
+ color = getResources().getColor(R.color.reddit_dark_dialog_text_color);
+ for (TextView textView : textViews)
+ textView.setTextColor(color);
+ }
+
+ private boolean validateInputFields(
+ final EditText composeDestination,
+ final EditText composeSubject,
+ final EditText composeText,
+ final EditText composeCaptcha
+ ) {
+ // reddit.com performs these sanity checks too.
+ if ("".equals(composeDestination.getText().toString().trim())) {
+ Toast.makeText(InboxActivity.this, "please enter a username", Toast.LENGTH_LONG).show();
+ return false;
+ }
+ if ("".equals(composeSubject.getText().toString().trim())) {
+ Toast.makeText(InboxActivity.this, "please enter a subject", Toast.LENGTH_LONG).show();
+ return false;
+ }
+ if ("".equals(composeText.getText().toString().trim())) {
+ Toast.makeText(InboxActivity.this, "you need to enter a message", Toast.LENGTH_LONG).show();
+ return false;
+ }
+ if (composeCaptcha.getVisibility() == View.VISIBLE && "".equals(composeCaptcha.getText().toString().trim())) {
+ Toast.makeText(InboxActivity.this, "", Toast.LENGTH_LONG).show();
+ return false;
+ }
+ return true;
+ }
+
+ private class MyMessageComposeTask extends MessageComposeTask {
public MyMessageComposeTask(Dialog dialog,
ThingInfo targetThingInfo, String captcha, String captchaIden,
Please sign in to comment.
Something went wrong with that request. Please try again.