Add butterknife

pull/253/head
Alex Baker 10 years ago
parent c56ef5fd2e
commit e1bbbb636e

@ -74,6 +74,8 @@ dependencies {
provided group: 'com.squareup.dagger', name: 'dagger-compiler', version: '1.2.2' provided group: 'com.squareup.dagger', name: 'dagger-compiler', version: '1.2.2'
compile group: 'com.squareup.dagger', name: 'dagger', version: '1.2.2' compile group: 'com.squareup.dagger', name: 'dagger', version: '1.2.2'
compile group: 'com.jakewharton', name: 'butterknife', version: '6.0.0'
compile group: 'com.android.support', name: 'support-v4', version: '21.0.2' compile group: 'com.android.support', name: 'support-v4', version: '21.0.2'
compile group: 'com.android.support', name: 'appcompat-v7', version: '21.0.2' compile group: 'com.android.support', name: 'appcompat-v7', version: '21.0.2'

@ -0,0 +1,54 @@
<?xml version='1.0' encoding='utf-8' ?>
<astrid version="335" format="3">
<task calendarUri="" completed="0" created="1417551321182" deleted="0" dueDate="0" elapsedSeconds="0" estimatedSeconds="0" hideUntil="0" importance="2" modified="1417553024844" notes="" recurrence="" notificationFlags="6" lastNotified="0" notifications="0" snoozeTime="0" repeatUntil="0" timerStart="0" title="Pick up dry cleaning" remoteId="133782773930938436">
<metadata created="0" deleted="0" key="tags-tag" value="Errands" value2="2897444787088657972" value3="133782773930938436" />
<metadata created="0" deleted="0" key="tags-tag" value="Office" value2="2420148479398577777" value3="133782773930938436" />
</task>
<task calendarUri="" completed="0" created="1417551329313" deleted="0" dueDate="1417716000000" elapsedSeconds="0" estimatedSeconds="0" hideUntil="0" importance="1" modified="1417553868229" notes="" recurrence="RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=TH" notificationFlags="6" lastNotified="0" notifications="0" snoozeTime="0" repeatUntil="0" timerStart="0" title="Take out the trash" remoteId="4317275025040816663">
<metadata created="0" deleted="1417553774420" key="tags-tag" value="Chores" value2="333819150464009127" value3="4317275025040816663" />
<metadata created="0" deleted="1417553862367" key="tags-tag" value="Chores" value2="506322051329938728" value3="4317275025040816663" />
<metadata created="0" deleted="0" key="tags-tag" value="Home" value2="1625835829806617352" value3="4317275025040816663" />
</task>
<task calendarUri="" completed="0" created="1417551350659" deleted="0" dueDate="1417629600000" elapsedSeconds="0" estimatedSeconds="0" hideUntil="0" importance="0" modified="1417551486960" notes="" recurrence="" notificationFlags="6" lastNotified="0" notifications="0" snoozeTime="0" repeatUntil="0" timerStart="0" title="Return movie" remoteId="1374046331562929600">
<metadata created="0" deleted="0" key="tags-tag" value="Errands" value2="2897444787088657972" value3="1374046331562929600" />
</task>
<task calendarUri="" completed="0" created="1417551365816" deleted="0" dueDate="0" elapsedSeconds="0" estimatedSeconds="0" hideUntil="0" importance="3" modified="1417553958215" notes="" recurrence="" notificationFlags="6" lastNotified="0" notifications="0" snoozeTime="0" repeatUntil="0" timerStart="0" title="Buy milk &amp; eggs" remoteId="870172748511988672">
<metadata created="0" deleted="1417551463966" key="tags-tag" value="Shopping" value2="2800317104257140109" value3="870172748511988672" />
<metadata created="0" deleted="1417553801876" key="tags-tag" value="Groceries" value2="536185249637936431" value3="870172748511988672" />
</task>
<task calendarUri="" completed="0" created="1417551488224" deleted="0" dueDate="1417543200000" elapsedSeconds="0" estimatedSeconds="0" hideUntil="0" importance="3" modified="1417551508877" notes="" recurrence="RRULE:FREQ=DAILY;INTERVAL=1;FROM=COMPLETION" notificationFlags="6" lastNotified="0" notifications="0" snoozeTime="0" repeatUntil="0" timerStart="0" title="Walk the dog" remoteId="341249039803689330" />
<task calendarUri="" completed="0" created="1417551834055" deleted="0" dueDate="1417802400000" elapsedSeconds="0" estimatedSeconds="0" hideUntil="0" importance="0" modified="1417553014480" notes="" recurrence="" notificationFlags="6" lastNotified="0" notifications="0" snoozeTime="0" repeatUntil="0" timerStart="0" title="New TPS coversheets" remoteId="4522800366354368462">
<metadata created="0" deleted="0" key="tags-tag" value="Office" value2="2420148479398577777" value3="4522800366354368462" />
</task>
<task calendarUri="" completed="0" created="1417552986074" deleted="0" dueDate="0" elapsedSeconds="0" estimatedSeconds="0" hideUntil="0" importance="1" modified="1417553001265" notes="" recurrence="" notificationFlags="6" lastNotified="0" notifications="0" snoozeTime="0" repeatUntil="0" timerStart="0" title="Pick up prescription" remoteId="2889554587067625099">
<metadata created="0" deleted="0" key="tags-tag" value="Errands" value2="2897444787088657972" value3="2889554587067625099" />
</task>
<task calendarUri="" completed="0" created="1417553061278" deleted="0" dueDate="0" elapsedSeconds="0" estimatedSeconds="0" hideUntil="0" importance="1" modified="1417553892866" notes="" recurrence="" notificationFlags="6" lastNotified="0" notifications="0" snoozeTime="0" repeatUntil="0" timerStart="0" title="Call Matt re: proposal" remoteId="2222765867738895702">
<metadata created="0" deleted="0" key="tags-tag" value="Office" value2="2420148479398577777" value3="2222765867738895702" />
<metadata created="0" deleted="0" key="tags-tag" value="Calls" value2="2560732460978813501" value3="2222765867738895702" />
</task>
<task calendarUri="" completed="0" created="1417553994222" deleted="0" dueDate="0" elapsedSeconds="0" estimatedSeconds="0" hideUntil="0" importance="0" modified="1417554082065" notes="" recurrence="" notificationFlags="6" lastNotified="0" notifications="0" snoozeTime="0" repeatUntil="0" timerStart="0" title="Book hotel" remoteId="230462949598811989">
<metadata created="0" deleted="1417554082053" key="tags-tag" value="Computer" value2="4219015281807071921" value3="230462949598811989" />
<metadata created="0" deleted="1417554017878" key="tags-tag" value="Projects" value2="4171420469470941389" value3="230462949598811989" />
<metadata created="0" deleted="0" key="tags-tag" value="Office" value2="2420148479398577777" value3="230462949598811989" />
<metadata created="0" deleted="0" key="tags-tag" value="Calls" value2="2560732460978813501" value3="230462949598811989" />
</task>
<task calendarUri="" completed="0" created="1417554042757" deleted="0" dueDate="0" elapsedSeconds="0" estimatedSeconds="0" hideUntil="0" importance="0" modified="1417554077704" notes="" recurrence="" notificationFlags="6" lastNotified="0" notifications="0" snoozeTime="0" repeatUntil="0" timerStart="0" title="Book car rental" remoteId="2160143386302867747">
<metadata created="0" deleted="0" key="tags-tag" value="Office" value2="2420148479398577777" value3="2160143386302867747" />
<metadata created="0" deleted="1417554077692" key="tags-tag" value="Computer" value2="4219015281807071921" value3="2160143386302867747" />
<metadata created="0" deleted="0" key="tags-tag" value="Calls" value2="2560732460978813501" value3="2160143386302867747" />
</task>
<task calendarUri="" completed="0" created="1417554097503" deleted="0" dueDate="0" elapsedSeconds="0" estimatedSeconds="0" hideUntil="0" importance="3" modified="1417554105349" notes="" recurrence="" notificationFlags="6" lastNotified="0" notifications="0" snoozeTime="0" repeatUntil="0" timerStart="0" title="Ski trip" remoteId="2910828546772529065">
<metadata created="0" deleted="0" key="tags-tag" value="Someday" value2="2780234708231068681" value3="2910828546772529065" />
</task>
<tagdata deleted="0" lastAutosync="1417554150117" name="Errands" tagOrdering="[]" remoteId="2897444787088657972" />
<tagdata deleted="0" lastAutosync="1417553624981" name="Office" tagOrdering="[]" remoteId="2420148479398577777" />
<tagdata deleted="0" lastAutosync="1417554146510" name="Calls" tagOrdering="[]" remoteId="2560732460978813501" />
<tagdata deleted="0" lastAutosync="0" name="Home" tagOrdering="[]" remoteId="1625835829806617352" />
<tagdata deleted="0" lastAutosync="1417553757534" name="Agendas" tagOrdering="[]" remoteId="3045974110512512707" />
<tagdata deleted="0" lastAutosync="1417553786777" name="Anywhere" tagOrdering="[]" remoteId="4399444017799786896" />
<tagdata deleted="0" lastAutosync="1417553797183" name="Computer" tagOrdering="[]" remoteId="4219015281807071921" />
<tagdata deleted="0" lastAutosync="1417553818035" name="Waiting For" tagOrdering="[]" remoteId="2462917657773618853" />
<tagdata deleted="0" lastAutosync="1417554098529" name="Someday" tagOrdering="[]" remoteId="2780234708231068681" />
<tagdata deleted="0" lastAutosync="0" name="Projects" tagOrdering="[]" remoteId="4171420469470941389" />
</astrid>

@ -94,6 +94,9 @@ import java.util.List;
import javax.inject.Inject; import javax.inject.Inject;
import butterknife.ButterKnife;
import butterknife.InjectView;
import static org.tasks.files.FileHelper.getPathFromUri; import static org.tasks.files.FileHelper.getPathFromUri;
/** /**
@ -173,14 +176,19 @@ ViewPager.OnPageChangeListener, EditNoteActivity.UpdatesChangedListener {
// --- UI components // --- UI components
private DescriptionControlSet notesControlSet = null; private FilesControlSet filesControlSet;
private FilesControlSet filesControlSet = null;
private TimerActionControlSet timerAction; private TimerActionControlSet timerAction;
private EditText title;
private EditNoteActivity editNotes; private EditNoteActivity editNotes;
private ViewPager mPager;
private HashMap<String, TaskEditControlSet> controlSetMap = new HashMap<>(); private HashMap<String, TaskEditControlSet> controlSetMap = new HashMap<>();
@InjectView(R.id.title) EditText title;
@InjectView(R.id.pager) ViewPager mPager;
@InjectView(R.id.updatesFooter) View commentsBar;
@InjectView(R.id.completeBox) CheckableImageView checkbox;
@InjectView(R.id.timer_container) LinearLayout timerShortcut;
@InjectView(R.id.basic_controls) LinearLayout basicControls;
@InjectView(R.id.edit_scroll) ScrollView scrollView;
private final List<TaskEditControlSet> controls = Collections.synchronizedList(new ArrayList<TaskEditControlSet>()); private final List<TaskEditControlSet> controls = Collections.synchronizedList(new ArrayList<TaskEditControlSet>());
// --- other instance variables // --- other instance variables
@ -201,6 +209,7 @@ ViewPager.OnPageChangeListener, EditNoteActivity.UpdatesChangedListener {
private String uuid = RemoteModel.NO_UUID; private String uuid = RemoteModel.NO_UUID;
private boolean showEditComments; private boolean showEditComments;
private boolean showTimerShortcut;
/* /*
* ====================================================================== * ======================================================================
@ -225,6 +234,7 @@ ViewPager.OnPageChangeListener, EditNoteActivity.UpdatesChangedListener {
} }
showEditComments = preferences.getBoolean(R.string.p_show_task_edit_comments, true); showEditComments = preferences.getBoolean(R.string.p_show_task_edit_comments, true);
showTimerShortcut = preferences.getBoolean(R.string.p_show_timer_shortcut, false);
getActivity().setResult(Activity.RESULT_OK); getActivity().setResult(Activity.RESULT_OK);
} }
@ -238,9 +248,9 @@ ViewPager.OnPageChangeListener, EditNoteActivity.UpdatesChangedListener {
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) { Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState); View view = inflater.inflate(R.layout.task_edit_activity, container, false);
ButterKnife.inject(this, view);
return inflater.inflate(R.layout.task_edit_activity, container, false); return view;
} }
@Override @Override
@ -276,8 +286,6 @@ ViewPager.OnPageChangeListener, EditNoteActivity.UpdatesChangedListener {
} }
private void loadMoreContainer() { private void loadMoreContainer() {
View commentsBar = getView().findViewById(R.id.updatesFooter);
long idParam = getActivity().getIntent().getLongExtra(TOKEN_ID, -1L); long idParam = getActivity().getIntent().getLongExtra(TOKEN_ID, -1L);
int tabStyle = TaskEditViewPager.TAB_SHOW_ACTIVITY; int tabStyle = TaskEditViewPager.TAB_SHOW_ACTIVITY;
@ -308,12 +316,8 @@ ViewPager.OnPageChangeListener, EditNoteActivity.UpdatesChangedListener {
TaskEditViewPager adapter = new TaskEditViewPager(getActivity(), tabStyle); TaskEditViewPager adapter = new TaskEditViewPager(getActivity(), tabStyle);
adapter.parent = this; adapter.parent = this;
mPager = (ViewPager) getView().findViewById(R.id.pager);
mPager.setAdapter(adapter); mPager.setAdapter(adapter);
if (showEditComments) {
commentsBar.setVisibility(View.VISIBLE);
}
setCurrentTab(TAB_VIEW_UPDATES); setCurrentTab(TAB_VIEW_UPDATES);
setPagerHeightForPosition(); setPagerHeightForPosition();
Handler handler = new Handler(); Handler handler = new Handler();
@ -339,12 +343,11 @@ ViewPager.OnPageChangeListener, EditNoteActivity.UpdatesChangedListener {
controlSetMap = new HashMap<>(); controlSetMap = new HashMap<>();
// populate control set // populate control set
title = (EditText) getView().findViewById(R.id.title);
EditTitleControlSet editTitle = new EditTitleControlSet( EditTitleControlSet editTitle = new EditTitleControlSet(
taskService, taskService,
getActivity(), getActivity(),
title, title,
(CheckableImageView) getView().findViewById(R.id.completeBox)); checkbox);
controls.add(editTitle); controls.add(editTitle);
timerAction = new TimerActionControlSet(notificationManager, taskService, getActivity(), getView()); timerAction = new TimerActionControlSet(notificationManager, taskService, getActivity(), getView());
@ -381,9 +384,8 @@ ViewPager.OnPageChangeListener, EditNoteActivity.UpdatesChangedListener {
controlSetMap.put(getString(R.string.TEA_ctrl_importance_pref), controlSetMap.put(getString(R.string.TEA_ctrl_importance_pref),
importanceControl); importanceControl);
notesControlSet = new DescriptionControlSet(preferences, getActivity()); DescriptionControlSet notesControlSet = new DescriptionControlSet(preferences, getActivity());
EditText notesEditText = (EditText) notesControlSet.getView().findViewById( EditText notesEditText = (EditText) notesControlSet.getView().findViewById(R.id.notes);
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),
notesControlSet); notesControlSet);
@ -414,13 +416,18 @@ ViewPager.OnPageChangeListener, EditNoteActivity.UpdatesChangedListener {
loadEditPageOrder(false); loadEditPageOrder(false);
if (!showEditComments) {
commentsBar.setVisibility(View.GONE);
}
if (!showTimerShortcut) {
timerShortcut.setVisibility(View.GONE);
}
// Load task data in background // Load task data in background
new TaskEditBackgroundLoader().start(); new TaskEditBackgroundLoader().start();
} }
private void loadEditPageOrder(boolean removeViews) { private void loadEditPageOrder(boolean removeViews) {
LinearLayout basicControls = (LinearLayout) getView().findViewById(
R.id.basic_controls);
if (removeViews) { if (removeViews) {
basicControls.removeAllViews(); basicControls.removeAllViews();
} }
@ -1032,7 +1039,6 @@ ViewPager.OnPageChangeListener, EditNoteActivity.UpdatesChangedListener {
// Scroll to view in edit task // Scroll to view in edit task
public void scrollToView(View v) { public void scrollToView(View v) {
View child = v; View child = v;
ScrollView scrollView = (ScrollView) getView().findViewById(R.id.edit_scroll);
int top = v.getTop(); int top = v.getTop();
while (!child.equals(scrollView) ) { while (!child.equals(scrollView) ) {
top += child.getTop(); top += child.getTop();

@ -177,8 +177,6 @@ public class EditNoteActivity extends LinearLayout implements TimerActionListene
} }
} }
}); });
} else {
timerView.setVisibility(View.GONE);
} }
commentField.addTextChangedListener(new TextWatcher() { commentField.addTextChangedListener(new TextWatcher() {

@ -65,7 +65,6 @@
android:orientation="horizontal" android:orientation="horizontal"
android:background="?attr/asAbBackgroundColor" android:background="?attr/asAbBackgroundColor"
android:padding="3dip" android:padding="3dip"
android:visibility="gone"
android:paddingBottom="0dip"> android:paddingBottom="0dip">
<!-- Voice Add Button --> <!-- Voice Add Button -->

Loading…
Cancel
Save