Improve TrustKeysActivity slider responsiveness

Slider used to skip back on drag-and-drop action. The switch doesn't
trigger explicit whole UI refreshes anymore, it now directly adjusts the
"done" button's locked status.
This commit is contained in:
Andreas Straub 2015-08-05 22:22:37 +02:00
parent a1c43d8fdf
commit 34b22dea48

View File

@ -124,9 +124,7 @@ public class TrustKeysActivity extends XmppActivity implements OnKeyStatusUpdate
@Override @Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
ownKeysToTrust.put(identityKey, isChecked); ownKeysToTrust.put(identityKey, isChecked);
refreshUi(); // own fingerprints have no impact on locked status.
xmppConnectionService.updateAccountUi();
xmppConnectionService.updateConversationUi();
} }
}, },
null null
@ -140,9 +138,7 @@ public class TrustKeysActivity extends XmppActivity implements OnKeyStatusUpdate
@Override @Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
foreignKeysToTrust.put(identityKey, isChecked); foreignKeysToTrust.put(identityKey, isChecked);
refreshUi(); lockOrUnlockAsNeeded();
xmppConnectionService.updateAccountUi();
xmppConnectionService.updateConversationUi();
} }
}, },
null null
@ -161,11 +157,7 @@ public class TrustKeysActivity extends XmppActivity implements OnKeyStatusUpdate
setFetching(); setFetching();
lock(); lock();
} else { } else {
if (!hasOtherTrustedKeys && !foreignKeysToTrust.values().contains(true)){ lockOrUnlockAsNeeded();
lock();
} else {
unlock();
}
setDone(); setDone();
} }
} }
@ -245,6 +237,14 @@ public class TrustKeysActivity extends XmppActivity implements OnKeyStatusUpdate
mSaveButton.setTextColor(getSecondaryTextColor()); mSaveButton.setTextColor(getSecondaryTextColor());
} }
private void lockOrUnlockAsNeeded() {
if (!hasOtherTrustedKeys && !foreignKeysToTrust.values().contains(true)){
lock();
} else {
unlock();
}
}
private void setDone() { private void setDone() {
mSaveButton.setText(getString(R.string.done)); mSaveButton.setText(getString(R.string.done));
} }