mirror of https://github.com/termux/termux-app
52 lines
1.5 KiB
Java
52 lines
1.5 KiB
Java
package com.termux.shared.termux.extrakeys;
|
|
|
|
import com.google.android.material.button.MaterialButton;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
/** The {@link Class} that maintains a state of a {@link SpecialButton} */
|
|
public class SpecialButtonState {
|
|
|
|
/** If special button has been created for the {@link ExtraKeysView}. */
|
|
boolean isCreated = false;
|
|
/** If special button is active. */
|
|
boolean isActive = false;
|
|
/** If special button is locked due to long hold on it and should not be deactivated if its
|
|
* state is read. */
|
|
boolean isLocked = false;
|
|
|
|
List<MaterialButton> buttons = new ArrayList<>();
|
|
|
|
ExtraKeysView mExtraKeysView;
|
|
|
|
/**
|
|
* Initialize a {@link SpecialButtonState} to maintain state of a {@link SpecialButton}.
|
|
*
|
|
* @param extraKeysView The {@link ExtraKeysView} instance in which the {@link SpecialButton}
|
|
* is to be registered.
|
|
*/
|
|
public SpecialButtonState(ExtraKeysView extraKeysView) {
|
|
mExtraKeysView = extraKeysView;
|
|
}
|
|
|
|
/** Set {@link #isCreated}. */
|
|
public void setIsCreated(boolean value) {
|
|
isCreated = value;
|
|
}
|
|
|
|
/** Set {@link #isActive}. */
|
|
public void setIsActive(boolean value) {
|
|
isActive = value;
|
|
for (MaterialButton button : buttons) {
|
|
button.setTextColor(value ? mExtraKeysView.getButtonActiveTextColor() : mExtraKeysView.getButtonTextColor());
|
|
}
|
|
}
|
|
|
|
/** Set {@link #isLocked}. */
|
|
public void setIsLocked(boolean value) {
|
|
isLocked = value;
|
|
}
|
|
|
|
}
|