From e81a5ad73459ef42fe52048b429de75bfd60ba13 Mon Sep 17 00:00:00 2001 From: Sam Bosley Date: Fri, 5 Apr 2013 17:21:54 -0700 Subject: [PATCH] Hide the timer shortcut button by default --- .../astrid/notes/EditNoteActivity.java | 76 +++++++++++-------- astrid/res/values/keys.xml | 2 + astrid/res/values/strings-core.xml | 2 + astrid/res/xml/preferences.xml | 5 ++ 4 files changed, 52 insertions(+), 33 deletions(-) diff --git a/astrid/plugin-src/com/todoroo/astrid/notes/EditNoteActivity.java b/astrid/plugin-src/com/todoroo/astrid/notes/EditNoteActivity.java index e7ebad4ad..0645b827e 100644 --- a/astrid/plugin-src/com/todoroo/astrid/notes/EditNoteActivity.java +++ b/astrid/plugin-src/com/todoroo/astrid/notes/EditNoteActivity.java @@ -49,6 +49,7 @@ import com.todoroo.andlib.service.ContextManager; import com.todoroo.andlib.service.DependencyInjectionService; import com.todoroo.andlib.sql.Query; import com.todoroo.andlib.utility.DateUtilities; +import com.todoroo.andlib.utility.Preferences; import com.todoroo.astrid.actfm.ActFmCameraModule; import com.todoroo.astrid.actfm.ActFmCameraModule.CameraResultCallback; import com.todoroo.astrid.actfm.ActFmCameraModule.ClearImageCallback; @@ -214,6 +215,48 @@ public class EditNoteActivity extends LinearLayout implements TimerActionListene timerView = commentsBar.findViewById(R.id.timer_container); commentButton = commentsBar.findViewById(R.id.commentButton); commentField = (EditText) commentsBar.findViewById(R.id.commentField); + + boolean showTimerShortcut = Preferences.getBoolean(R.string.p_show_timer_shortcut, false); + + if (showTimerShortcut) { + commentField.addTextChangedListener(new TextWatcher() { + @Override + public void afterTextChanged(Editable s) { + commentButton.setVisibility((s.length() > 0 || pendingCommentPicture != null) ? View.VISIBLE + : View.GONE); + timerView.setVisibility((s.length() > 0 || pendingCommentPicture != null) ? View.GONE + : View.VISIBLE); + } + + @Override + public void beforeTextChanged(CharSequence s, int start, int count, int after) { + // + } + @Override + public void onTextChanged(CharSequence s, int start, int before, int count) { + // + } + }); + + commentField.setOnFocusChangeListener(new OnFocusChangeListener() { + + @Override + public void onFocusChange(View v, boolean hasFocus) { + if (hasFocus) { + timerView.setVisibility(View.GONE); + commentButton.setVisibility(View.VISIBLE); + } + else { + timerView.setVisibility(View.VISIBLE); + commentButton.setVisibility(View.GONE); + } + } + }); + } else { + timerView.setVisibility(View.GONE); + commentButton.setVisibility(View.VISIBLE); + } + commentField.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView view, int actionId, KeyEvent event) { @@ -224,39 +267,6 @@ public class EditNoteActivity extends LinearLayout implements TimerActionListene return false; } }); - commentField.addTextChangedListener(new TextWatcher() { - @Override - public void afterTextChanged(Editable s) { - commentButton.setVisibility((s.length() > 0 || pendingCommentPicture != null) ? View.VISIBLE - : View.GONE); - timerView.setVisibility((s.length() > 0 || pendingCommentPicture != null) ? View.GONE - : View.VISIBLE); - } - - @Override - public void beforeTextChanged(CharSequence s, int start, int count, int after) { - // - } - @Override - public void onTextChanged(CharSequence s, int start, int before, int count) { - // - } - }); - - commentField.setOnFocusChangeListener(new OnFocusChangeListener() { - - @Override - public void onFocusChange(View v, boolean hasFocus) { - if (hasFocus) { - timerView.setVisibility(View.GONE); - commentButton.setVisibility(View.VISIBLE); - } - else { - timerView.setVisibility(View.VISIBLE); - commentButton.setVisibility(View.GONE); - } - } - }); commentButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { diff --git a/astrid/res/values/keys.xml b/astrid/res/values/keys.xml index 3c3ccd6a5..1fd66bc4e 100644 --- a/astrid/res/values/keys.xml +++ b/astrid/res/values/keys.xml @@ -283,6 +283,8 @@ p_hide_plus_button + p_show_timer_shortcut + p_configurations p_config_default diff --git a/astrid/res/values/strings-core.xml b/astrid/res/values/strings-core.xml index d3d13f842..b2d2129ea 100644 --- a/astrid/res/values/strings-core.xml +++ b/astrid/res/values/strings-core.xml @@ -687,6 +687,8 @@ Use date shortcuts + Show timer shortcut + Customize the layout of the task edit screen diff --git a/astrid/res/xml/preferences.xml b/astrid/res/xml/preferences.xml index 7d1b2b01c..85644e403 100644 --- a/astrid/res/xml/preferences.xml +++ b/astrid/res/xml/preferences.xml @@ -91,6 +91,11 @@ android:key="@string/p_time_increment" android:title="@string/EPr_time_increment" android:defaultValue="true"/> + +