From a33c2597608faabb41e9769440a557ce6e80799b Mon Sep 17 00:00:00 2001 From: Vavassor Date: Mon, 17 Apr 2017 00:29:47 -0400 Subject: [PATCH] Ties composer readying state and control states together. --- .../keylesspalace/tusky/ComposeActivity.java | 26 ++++++++++++------- app/src/main/res/values/strings.xml | 2 +- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java b/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java index 36330bcc1..79547e49c 100644 --- a/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java @@ -348,7 +348,6 @@ public class ComposeActivity extends BaseActivity implements ComposeOptionsFrag floatingBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - postProgress.setVisibility(View.VISIBLE); sendStatus(); } }); @@ -626,6 +625,18 @@ public class ComposeActivity extends BaseActivity implements ComposeOptionsFrag updateVisibleCharactersLeft(); } + void setStateToReadying() { + statusAlreadyInFlight = true; + disableButtons(); + postProgress.setVisibility(View.VISIBLE); + } + + void setStateToNotReadying() { + postProgress.setVisibility(View.INVISIBLE); + statusAlreadyInFlight = false; + enableButtons(); + } + private void sendStatus() { if (statusAlreadyInFlight) { return; @@ -637,8 +648,7 @@ public class ComposeActivity extends BaseActivity implements ComposeOptionsFrag } int characterCount = contentText.length() + spoilerText.length(); if (characterCount > 0 && characterCount <= STATUS_CHARACTER_LIMIT) { - statusAlreadyInFlight = true; - disableButtons(); + setStateToReadying(); readyStatus(contentText, statusVisibility, statusMarkSensitive, spoilerText); } else if (characterCount <= 0) { textEditor.setError(getString(R.string.error_empty)); @@ -836,10 +846,8 @@ public class ComposeActivity extends BaseActivity implements ComposeOptionsFrag } private void onSendFailure() { - postProgress.setVisibility(View.INVISIBLE); textEditor.setError(getString(R.string.error_generic)); - statusAlreadyInFlight = false; - enableButtons(); + setStateToNotReadying(); } private void readyStatus(final String content, final String visibility, final boolean sensitive, @@ -874,8 +882,7 @@ public class ComposeActivity extends BaseActivity implements ComposeOptionsFrag @Override protected void onCancelled() { removeAllMediaFromQueue(); - statusAlreadyInFlight = false; - enableButtons(); + setStateToNotReadying(); super.onCancelled(); } }; @@ -900,8 +907,7 @@ public class ComposeActivity extends BaseActivity implements ComposeOptionsFrag readyStatus(content, visibility, sensitive, spoilerText); } }); - statusAlreadyInFlight = false; - enableButtons(); + setStateToNotReadying(); } private void onMediaPick() { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 345d1c01c..626172dbc 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,7 +1,7 @@ An error occurred. - This can\'t be empty. + This cannot be empty. Invalid domain entered Failed authenticating with that instance. Couldn\'t find a web browser to use.