Ties composer readying state and control states together.
This commit is contained in:
parent
cc0aaf6162
commit
a33c259760
|
@ -348,7 +348,6 @@ public class ComposeActivity extends BaseActivity implements ComposeOptionsFrag
|
||||||
floatingBtn.setOnClickListener(new View.OnClickListener() {
|
floatingBtn.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
postProgress.setVisibility(View.VISIBLE);
|
|
||||||
sendStatus();
|
sendStatus();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -626,6 +625,18 @@ public class ComposeActivity extends BaseActivity implements ComposeOptionsFrag
|
||||||
updateVisibleCharactersLeft();
|
updateVisibleCharactersLeft();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setStateToReadying() {
|
||||||
|
statusAlreadyInFlight = true;
|
||||||
|
disableButtons();
|
||||||
|
postProgress.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setStateToNotReadying() {
|
||||||
|
postProgress.setVisibility(View.INVISIBLE);
|
||||||
|
statusAlreadyInFlight = false;
|
||||||
|
enableButtons();
|
||||||
|
}
|
||||||
|
|
||||||
private void sendStatus() {
|
private void sendStatus() {
|
||||||
if (statusAlreadyInFlight) {
|
if (statusAlreadyInFlight) {
|
||||||
return;
|
return;
|
||||||
|
@ -637,8 +648,7 @@ public class ComposeActivity extends BaseActivity implements ComposeOptionsFrag
|
||||||
}
|
}
|
||||||
int characterCount = contentText.length() + spoilerText.length();
|
int characterCount = contentText.length() + spoilerText.length();
|
||||||
if (characterCount > 0 && characterCount <= STATUS_CHARACTER_LIMIT) {
|
if (characterCount > 0 && characterCount <= STATUS_CHARACTER_LIMIT) {
|
||||||
statusAlreadyInFlight = true;
|
setStateToReadying();
|
||||||
disableButtons();
|
|
||||||
readyStatus(contentText, statusVisibility, statusMarkSensitive, spoilerText);
|
readyStatus(contentText, statusVisibility, statusMarkSensitive, spoilerText);
|
||||||
} else if (characterCount <= 0) {
|
} else if (characterCount <= 0) {
|
||||||
textEditor.setError(getString(R.string.error_empty));
|
textEditor.setError(getString(R.string.error_empty));
|
||||||
|
@ -836,10 +846,8 @@ public class ComposeActivity extends BaseActivity implements ComposeOptionsFrag
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onSendFailure() {
|
private void onSendFailure() {
|
||||||
postProgress.setVisibility(View.INVISIBLE);
|
|
||||||
textEditor.setError(getString(R.string.error_generic));
|
textEditor.setError(getString(R.string.error_generic));
|
||||||
statusAlreadyInFlight = false;
|
setStateToNotReadying();
|
||||||
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,
|
||||||
|
@ -874,8 +882,7 @@ public class ComposeActivity extends BaseActivity implements ComposeOptionsFrag
|
||||||
@Override
|
@Override
|
||||||
protected void onCancelled() {
|
protected void onCancelled() {
|
||||||
removeAllMediaFromQueue();
|
removeAllMediaFromQueue();
|
||||||
statusAlreadyInFlight = false;
|
setStateToNotReadying();
|
||||||
enableButtons();
|
|
||||||
super.onCancelled();
|
super.onCancelled();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -900,8 +907,7 @@ public class ComposeActivity extends BaseActivity implements ComposeOptionsFrag
|
||||||
readyStatus(content, visibility, sensitive, spoilerText);
|
readyStatus(content, visibility, sensitive, spoilerText);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
statusAlreadyInFlight = false;
|
setStateToNotReadying();
|
||||||
enableButtons();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onMediaPick() {
|
private void onMediaPick() {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<resources>
|
<resources>
|
||||||
|
|
||||||
<string name="error_generic">An error occurred.</string>
|
<string name="error_generic">An error occurred.</string>
|
||||||
<string name="error_empty">This can\'t be empty.</string>
|
<string name="error_empty">This cannot be empty.</string>
|
||||||
<string name="error_invalid_domain">Invalid domain entered</string>
|
<string name="error_invalid_domain">Invalid domain entered</string>
|
||||||
<string name="error_failed_app_registration">Failed authenticating with that instance.</string>
|
<string name="error_failed_app_registration">Failed authenticating with that instance.</string>
|
||||||
<string name="error_no_web_browser_found">Couldn\'t find a web browser to use.</string>
|
<string name="error_no_web_browser_found">Couldn\'t find a web browser to use.</string>
|
||||||
|
|
Loading…
Reference in New Issue