Change description control to EditText

pull/253/head
Alex Baker 11 years ago
parent 626e486f7e
commit b0f8c077d9

@ -384,7 +384,7 @@ ViewPager.OnPageChangeListener, EditNoteActivity.UpdatesChangedListener {
controlSetMap.put(getString(R.string.TEA_ctrl_importance_pref), controlSetMap.put(getString(R.string.TEA_ctrl_importance_pref),
importanceControl); importanceControl);
DescriptionControlSet notesControlSet = new DescriptionControlSet(preferences, getActivity()); DescriptionControlSet notesControlSet = new DescriptionControlSet(getActivity());
EditText notesEditText = (EditText) notesControlSet.getView().findViewById(R.id.notes); EditText notesEditText = (EditText) notesControlSet.getView().findViewById(R.id.notes);
controls.add(notesControlSet); controls.add(notesControlSet);
controlSetMap.put(getString(R.string.TEA_ctrl_notes_pref), controlSetMap.put(getString(R.string.TEA_ctrl_notes_pref),

@ -6,93 +6,33 @@
package com.todoroo.astrid.ui; package com.todoroo.astrid.ui;
import android.app.Activity; import android.app.Activity;
import android.content.Context;
import android.graphics.Color;
import android.text.TextUtils;
import android.text.util.Linkify;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText; import android.widget.EditText;
import android.widget.TextView;
import com.todoroo.astrid.data.Task; import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.helper.TaskEditControlSetBase;
import org.tasks.R; import org.tasks.R;
import org.tasks.preferences.ActivityPreferences;
public class DescriptionControlSet extends PopupControlSet { public class DescriptionControlSet extends TaskEditControlSetBase {
protected EditText editText; protected EditText editText;
protected TextView notesPreview;
public DescriptionControlSet(ActivityPreferences preferences, Activity activity) { public DescriptionControlSet(Activity activity) {
super(preferences, activity, R.layout.control_set_description_edit, R.layout.control_set_description, R.string.TEA_note_label); super(activity, R.layout.control_set_description);
}
@Override
protected void refreshDisplayView() {
String textToUse;
if (initialized) {
textToUse = editText.getText().toString();
} else {
textToUse = model.getNotes();
}
if (TextUtils.isEmpty(textToUse)) {
notesPreview.setText(R.string.TEA_notes_empty);
notesPreview.setTextColor(unsetColor);
} else {
notesPreview.setText(textToUse);
notesPreview.setTextColor(themeColor);
}
linkifyDisplayView();
}
private void linkifyDisplayView() {
if(!TextUtils.isEmpty(notesPreview.getText())) {
notesPreview.setLinkTextColor(Color.rgb(100, 160, 255));
Linkify.addLinks(notesPreview, Linkify.ALL);
}
} }
@Override @Override
protected void afterInflate() { protected void afterInflate() {
editText = (EditText) getView().findViewById(R.id.notes); editText = (EditText) getView().findViewById(R.id.notes);
notesPreview = (TextView) getDisplayView().findViewById(R.id.display_row_edit);
}
@Override
protected void additionalDialogSetup() {
super.additionalDialogSetup();
dialog.getWindow()
.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE
| WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
} }
@Override @Override
protected void readFromTaskOnInitialize() { protected void readFromTaskOnInitialize() {
editText.setTextKeepState(model.getNotes()); editText.setTextKeepState(model.getNotes());
notesPreview.setText(model.getNotes());
linkifyDisplayView();
} }
@Override @Override
protected void writeToModelAfterInitialized(Task task) { protected void writeToModelAfterInitialized(Task task) {
task.setNotes(editText.getText().toString()); task.setNotes(editText.getText().toString().trim());
}
@Override
protected boolean onOkClick() {
InputMethodManager imm = (InputMethodManager)activity.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(editText.getWindowToken(), 0);
return super.onOkClick();
}
@Override
protected void onCancelClick() {
super.onCancelClick();
InputMethodManager imm = (InputMethodManager)activity.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(editText.getWindowToken(), 0);
} }
} }

@ -21,20 +21,23 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical"> android:orientation="vertical">
<TextView <EditText
android:id="@+id/display_row_edit" android:id="@+id/notes"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:gravity="start"
android:textColor="?attr/asThemeTextColor"
android:textSize="@dimen/task_edit_text_size"
android:paddingTop="@dimen/task_edit_padding_top_bottom" android:paddingTop="@dimen/task_edit_padding_top_bottom"
android:paddingBottom="@dimen/task_edit_padding_top_bottom" android:paddingBottom="@dimen/task_edit_padding_top_bottom"
android:layout_marginTop="@dimen/task_edit_padding_top_bottom" android:layout_marginTop="@dimen/task_edit_padding_top_bottom"
android:layout_marginBottom="@dimen/task_edit_padding_top_bottom" android:layout_marginBottom="@dimen/task_edit_padding_top_bottom"
android:paddingRight="@dimen/task_edit_padding_right" android:paddingRight="@dimen/task_edit_padding_right"
android:paddingEnd="@dimen/task_edit_padding_right" /> android:paddingEnd="@dimen/task_edit_padding_right"
android:scrollbars="vertical"
android:hint="@string/TEA_notes_empty"
android:inputType="textCapSentences|textMultiLine"
android:imeOptions="flagNoExtractUi"
android:textColor="?attr/asTextColor"
android:freezesText="true"
android:background="@android:color/transparent"/>
<include layout="@layout/task_edit_divider" /> <include layout="@layout/task_edit_divider" />

@ -1,47 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
** Copyright (c) 2012 Todoroo Inc
**
** See the file "LICENSE" for the full license governing this code.
-->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingLeft="5dip"
android:paddingRight="5dip">
<!-- notes -->
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="100">
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical">
<EditText
android:id="@+id/notes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minHeight="100dip"
android:layout_marginLeft="9dip"
android:layout_marginRight="9dip"
android:layout_marginTop="5dip"
android:layout_weight="100"
android:scrollbars="vertical"
android:gravity="top"
android:background="@null"
android:hint="@string/TEA_notes_hint"
android:autoText="true"
android:capitalize="sentences"
android:singleLine="false"
android:textColor="?attr/asTextColor"
android:freezesText="true" />
</LinearLayout>
</ScrollView>
<include layout="@layout/control_dialog_ok"/>
</LinearLayout>
Loading…
Cancel
Save