Skip to content

Commit

Permalink
Saving MS with empty title logic changed
Browse files Browse the repository at this point in the history
#91 closed
Before: make save button unable
Now: button alwayas able, show toast, cancel saving
Localisation implemented (English & Russian)
  • Loading branch information
UEvgeniy committed Feb 6, 2018
1 parent ae70857 commit 69ccc84
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
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;
Expand Down Expand Up @@ -199,15 +200,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 +242,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 +256,10 @@ public boolean onOptionsItemSelected(MenuItem item) {
finish();
return true;
case R.id.m_apply:
if (etTitle.getText().toString().isEmpty()){
ToastUtils.show(this, R.string.error_empty_title);
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
1 change: 1 addition & 0 deletions app/src/main/res/values-ru/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -358,5 +358,6 @@
<string name="ms_days">дней</string>
<string name="ms_select_issue">Выбрать задачу</string>
<string name="ms_new_milestone">Новая цель</string>
<string name="error_empty_title">Ошибка при сохранении с пустым заголовком</string>

</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
<string name="error_checking_starring_status">Checking starring status failed</string>
<string name="error_rendering_markdown">Rendering markdown failed</string>
<string name="error_users_search">Searching users failed</string>
<string name="error_empty_title">Saving with empty title failed</string>
<!-- -->


Expand Down

0 comments on commit 69ccc84

Please sign in to comment.