From ee4d0739db824efb54cd4bad952f8d5aff0da93d Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Sat, 15 Apr 2017 17:52:21 +0200 Subject: [PATCH] Re-enable controls after failed toot --- .../keylesspalace/tusky/ComposeActivity.java | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java b/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java index 5be683a2f..9d68596d0 100644 --- a/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java @@ -122,6 +122,7 @@ public class ComposeActivity extends BaseActivity implements ComposeOptionsFrag private ImageButton pickBtn; private Button nsfwBtn; private ProgressBar postProgress; + private ImageButton visibilityBtn; private static class QueuedMedia { enum Type { @@ -341,15 +342,12 @@ public class ComposeActivity extends BaseActivity implements ComposeOptionsFrag floatingBtn = (Button) findViewById(R.id.floating_btn); pickBtn = (ImageButton) findViewById(R.id.compose_photo_pick); 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() { @Override public void onClick(View v) { - pickBtn.setClickable(false); - nsfwBtn.setClickable(false); - visibilityBtn.setClickable(false); - floatingBtn.setEnabled(false); + disableButtons(); postProgress.setVisibility(View.VISIBLE); sendStatus(); @@ -567,6 +565,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) { statusVisibility = visibility; switch (visibility) { @@ -823,6 +835,7 @@ public class ComposeActivity extends BaseActivity implements ComposeOptionsFrag postProgress.setVisibility(View.INVISIBLE); textEditor.setError(getString(R.string.error_generic)); statusAlreadyInFlight = false; + enableButtons(); } private void readyStatus(final String content, final String visibility, final boolean sensitive,