Merge branch 'error_handling_bug' of https://github.com/raphaelm/Tusky into raphaelm-error_handling_bug

This commit is contained in:
Vavassor 2017-04-17 00:09:16 -04:00
commit 962bd79d3f

View file

@ -123,6 +123,7 @@ public class ComposeActivity extends BaseActivity implements ComposeOptionsFrag
private ImageButton pickBtn; private ImageButton pickBtn;
private Button nsfwBtn; private Button nsfwBtn;
private ProgressBar postProgress; private ProgressBar postProgress;
private ImageButton visibilityBtn;
private static class QueuedMedia { private static class QueuedMedia {
enum Type { enum Type {
@ -342,15 +343,12 @@ public class ComposeActivity extends BaseActivity implements ComposeOptionsFrag
floatingBtn = (Button) findViewById(R.id.floating_btn); floatingBtn = (Button) findViewById(R.id.floating_btn);
pickBtn = (ImageButton) findViewById(R.id.compose_photo_pick); pickBtn = (ImageButton) findViewById(R.id.compose_photo_pick);
nsfwBtn = (Button) findViewById(R.id.action_toggle_nsfw); nsfwBtn = (Button) findViewById(R.id.action_toggle_nsfw);
final ImageButton visibilityBtn = (ImageButton) findViewById(R.id.action_toggle_visibility); visibilityBtn = (ImageButton) findViewById(R.id.action_toggle_visibility);
floatingBtn.setOnClickListener(new View.OnClickListener() { floatingBtn.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
pickBtn.setClickable(false); disableButtons();
nsfwBtn.setClickable(false);
visibilityBtn.setClickable(false);
floatingBtn.setEnabled(false);
postProgress.setVisibility(View.VISIBLE); postProgress.setVisibility(View.VISIBLE);
sendStatus(); sendStatus();
@ -568,6 +566,20 @@ public class ComposeActivity extends BaseActivity implements ComposeOptionsFrag
} }
} }
private void disableButtons() {
pickBtn.setClickable(false);
nsfwBtn.setClickable(false);
visibilityBtn.setClickable(false);
floatingBtn.setEnabled(false);
}
private void enableButtons() {
pickBtn.setClickable(true);
nsfwBtn.setClickable(true);
visibilityBtn.setClickable(true);
floatingBtn.setEnabled(true);
}
private void setStatusVisibility(String visibility) { private void setStatusVisibility(String visibility) {
statusVisibility = visibility; statusVisibility = visibility;
switch (visibility) { switch (visibility) {
@ -825,6 +837,7 @@ public class ComposeActivity extends BaseActivity implements ComposeOptionsFrag
postProgress.setVisibility(View.INVISIBLE); postProgress.setVisibility(View.INVISIBLE);
textEditor.setError(getString(R.string.error_generic)); textEditor.setError(getString(R.string.error_generic));
statusAlreadyInFlight = false; statusAlreadyInFlight = false;
enableButtons();
} }
private void readyStatus(final String content, final String visibility, final boolean sensitive, private void readyStatus(final String content, final String visibility, final boolean sensitive,