Merge pull request #3731 from nextcloud/ezaquarii/fix-button-disabled-state-in-folder-sync-preferences-2

Fix button disabled state in folder sync preferences
This commit is contained in:
Andy Scherzinger 2019-03-11 14:25:04 +01:00 committed by GitHub
commit 67eec757fb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 2 deletions

View file

@ -195,10 +195,10 @@ public class SyncedFolderPreferencesDialogFragment extends DialogFragment {
mUploadBehaviorSummary = view.findViewById(R.id.setting_instant_behaviour_summary);
mCancel = view.findViewById(R.id.cancel);
mCancel.setTextColor(accentColor);
ThemeUtils.themeDialogActionButton(mCancel);
mSave = view.findViewById(R.id.save);
mSave.setTextColor(accentColor);
ThemeUtils.themeDialogActionButton(mSave);
// Set values
setEnabled(mSyncedFolder.getEnabled());

View file

@ -40,6 +40,7 @@ import android.widget.ProgressBar;
import android.widget.SeekBar;
import android.widget.TextView;
import com.google.android.material.button.MaterialButton;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.snackbar.Snackbar;
import com.google.android.material.textfield.TextInputLayout;
@ -419,6 +420,24 @@ public final class ThemeUtils {
));
}
public static void themeDialogActionButton(MaterialButton button) {
if (button == null ) return;
Context context = button.getContext();
int accentColor = ThemeUtils.primaryAccentColor(button.getContext());
int disabledColor = ContextCompat.getColor(context, R.color.disabled_text);
button.setTextColor(new ColorStateList(
new int[][]{
new int[] { android.R.attr.state_enabled}, // enabled
new int[] {-android.R.attr.state_enabled}, // disabled
},
new int[]{
accentColor,
disabledColor
}
));
}
public static void themeEditText(Context context, EditText editText, boolean themedBackground) {
if (editText == null) { return; }