Skip to content

Commit

Permalink
Merge pull request #99 from AndreySBer/enhancement-91
Browse files Browse the repository at this point in the history
Saving MS with empty title logic changed
  • Loading branch information
phansier committed Feb 7, 2018
2 parents ae70857 + ed44be6 commit d61237d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
import android.content.Intent;
import android.support.v7.app.ActionBar;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextUtils;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
Expand All @@ -25,17 +23,16 @@
import com.github.mobile.core.milestone.CreateMilestoneTask;
import com.github.mobile.core.milestone.EditMilestoneTask;
import com.github.mobile.ui.DialogFragmentActivity;
import com.github.mobile.ui.TextWatcherAdapter;
import com.github.mobile.ui.issue.MilestoneDialog;
import com.github.mobile.ui.repo.RepositoryMilestonesActivity;
import com.github.mobile.util.ToastUtils;
import com.google.inject.Inject;

import org.eclipse.egit.github.core.Repository;
import org.eclipse.egit.github.core.RepositoryId;
import org.eclipse.egit.github.core.service.CollaboratorService;
import org.eclipse.egit.github.core.service.MilestoneService;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
Expand Down Expand Up @@ -199,15 +196,6 @@ public void onClick(View v) {
actionBar.setTitle(R.string.ms_new_milestone);
actionBar.setSubtitle(repositoryId.generateId());

etTitle.addTextChangedListener(new TextWatcherAdapter() {

@Override
public void afterTextChanged(Editable s) {
updateSaveMenu(s);
}
});

updateSaveMenu();
etTitle.setText(milestone.title);
etDescription.setText(milestone.description);
}
Expand Down Expand Up @@ -250,21 +238,10 @@ protected void onSaveInstanceState(Bundle outState) {
outState.putSerializable(EXTRA_MILESTONE, milestone);
}

private void updateSaveMenu() {
if (etTitle != null)
updateSaveMenu(etTitle.getText());
}

private void updateSaveMenu(final CharSequence text) {
if (saveItem != null)
saveItem.setEnabled(!TextUtils.isEmpty(text));
}

@Override
public boolean onCreateOptionsMenu(Menu options) {
getMenuInflater().inflate(R.menu.milestone_edit, options);
saveItem = options.findItem(R.id.m_apply);
updateSaveMenu();
return true;
}

Expand All @@ -275,6 +252,10 @@ public boolean onOptionsItemSelected(MenuItem item) {
finish();
return true;
case R.id.m_apply:
if (etTitle.getText().toString().isEmpty()){
ToastUtils.show(this, R.string.ms_empty_title_error);
return false;
}
ActionBar actionBar = getSupportActionBar();
actionBar.setTitle(milestone.title);
milestone.title = etTitle.getText().toString();
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/menu/milestone_edit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<item
android:id="@+id/m_apply"
android:enabled="false"
android:enabled="true"
android:icon="@drawable/ic_send_white_24dp"
app:showAsAction="ifRoom"
android:title="@string/save"/>
Expand Down
6 changes: 4 additions & 2 deletions app/src/main/res/values-ru/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,9 @@
<string name="render_markdown">Отобразить Markdown</string>
<string name="copy_hash">Копировать хэш</string>
<string name="toast_msg_copied">Скопировано в буфер обмена</string>
<!-- -->
<string name="issues_display_closed">Показать закрытые</string>
<string name="issues_display_opened">Показать открытые</string>

<string name="ms_closed_issues">"Закрытые: "</string>
<string name="ms_due_by">"До "</string>
Expand All @@ -352,11 +355,10 @@
<string name="ms_date_2_weeks">2 недели</string>
<string name="ms_date_month">Месяц</string>
<string name="ms_percent_completed">% завершено</string>
<string name="issues_display_closed">Показать закрытые</string>
<string name="issues_display_opened">Показать открытые</string>
<string name="ms_time_past">Просрочен</string>
<string name="ms_days">дней</string>
<string name="ms_select_issue">Выбрать задачу</string>
<string name="ms_new_milestone">Новая цель</string>
<string name="ms_empty_title_error">Ошибка при сохранении с пустым заголовком</string>

</resources>
8 changes: 6 additions & 2 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,10 @@
<string name="copy_hash">Copy hash</string>
<string name="toast_msg_copied">Copied to clipboard</string>
<string name="parent_repo">Parent repository</string>
<!-- -->
<string name="issues_display_closed">Display closed</string>
<string name="issues_display_opened">Display opened</string>

<string name="ms_due_by">Due by </string>
<string name="ms_opened_issues">Opened:</string>
<string name="ms_closed_issues">Closed:</string>
Expand All @@ -356,11 +360,11 @@
<string name="ms_date_month">month</string>
<string name="ms_choose_date">Choose date</string>
<string name="ms_percent_completed">% completed</string>
<string name="issues_display_closed">Display closed</string>
<string name="issues_display_opened">Display opened</string>
<string name="ms_time_past">past due by</string>
<string name="ms_days">days</string>
<string name="ms_date_format">dd MMM yyyy</string>
<string name="ms_select_issue">Select Issue</string>
<string name="ms_empty_title_error">Saving with empty title failed</string>


</resources>

0 comments on commit d61237d

Please sign in to comment.