@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setDisplayShowHomeEnabled(true); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setHomeButtonEnabled(true); } nightModeSwitch = (AppCompatCheckedTextView) findViewById(R.id.night_mode_switch); nightModeSwitch.setOnClickListener(view -> onNightModeCheckChange()); nightModeSwitch.setChecked(new UserPrefs().isNightMode()); nightModeSwitch.setEnabled(!new UserPrefs().isDayNightMode()); dayNightSwitch = (AppCompatCheckedTextView) findViewById(R.id.auto_theme_switch); dayNightSwitch.setChecked(new UserPrefs().isDayNightMode()); dayNightSwitch.setOnClickListener(view -> onAutoThemeChange()); instructorSwitch = (AppCompatCheckedTextView) findViewById(R.id.instructor_switch); instructorSwitch.setChecked(new UserPrefs().isInstructor()); instructorSwitch.setOnClickListener(view -> onChangeInstructor()); }
@Override public View onCreateView(String name, Context context, AttributeSet attrs) { // Allow super to try and create a view first final View result = super.onCreateView(name, context, attrs); if (result != null) { return result; } if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { switch (name) { case "EditText": return new AppCompatEditText(this,attrs); case "Spinner": return new AppCompatSpinner(this,attrs); case "CheckBox": return new AppCompatCheckBox(this,attrs); case "RadioButton": return new AppCompatRadioButton(this,attrs); case "CheckedTextView": return new AppCompatCheckedTextView(this,attrs); } } return null; }
@Nullable @Override public View onCreateView(String name, Context context, AttributeSet attrs) { final View result = super.onCreateView(name, context, attrs); if (result != null) { return result; } // Provide colorized/tinted widgets on non-Material devices if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { switch (name) { case "EditText": return new AppCompatEditText(this, attrs); case "Spinner": return new AppCompatSpinner(this, attrs); case "CheckBox": return new AppCompatCheckBox(this, attrs); case "RadioButton": return new AppCompatRadioButton(this, attrs); case "CheckedTextView": return new AppCompatCheckedTextView(this, attrs); } } return null; }
@Override public View onCreateView(String name, Context context, AttributeSet attrs) { // Allow super to try and create a view first final View result = super.onCreateView(name, context, attrs); if (result != null) { return result; } if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { // If we're running pre-L, we need to 'inject' our tint aware Views in place of the // standard framework versions switch (name) { case "EditText": return new AppCompatEditText(this, attrs); case "Spinner": return new AppCompatSpinner(this, attrs); case "CheckBox": return new AppCompatCheckBox(this, attrs); case "RadioButton": return new AppCompatRadioButton(this, attrs); case "CheckedTextView": return new AppCompatCheckedTextView(this, attrs); } } return null; }
/** * Change background color, text color */ public void changeTaskNameState(View view, AppCompatCheckedTextView taskNameText, boolean completed) { taskNameText.setChecked(completed); if (completed) { view.setBackgroundColor(ContextCompat.getColor(mContext, R.color.mt_gray5)); taskNameText.setTextColor(ContextCompat.getColor(mContext, R.color.mt_gray6)); } else { view.setBackgroundColor(ContextCompat.getColor(mContext, android.R.color.white)); taskNameText.setTextColor(ContextCompat.getColor(mContext, R.color.mt_black)); } }
@Override public void onClickRecyclerItem(View v, int position) { Task task = mListsTaskListAdapter.getItem(position); AppCompatCheckedTextView taskNameText = (AppCompatCheckedTextView) v.findViewById(R.id.lists_task_name); mListsTaskListAdapter.changeTaskNameState(v, taskNameText, !task.isCompleted()); TaskRepository.updateByCompleted(mUIThreadRealm, task, !task.isCompleted()); }
@SuppressLint({"PrivateResource", "InlinedApi"}) @Override protected int getDefaultViewDefStyleAttr(View view) { if (view instanceof AppCompatRadioButton) { return R.attr.radioButtonStyle; } else if (view instanceof AppCompatCheckBox) { return R.attr.checkboxStyle; } else if (view instanceof AppCompatButton) { return R.attr.buttonStyle; } else if (view instanceof AppCompatMultiAutoCompleteTextView) { return R.attr.autoCompleteTextViewStyle; } else if (view instanceof AppCompatAutoCompleteTextView) { return R.attr.autoCompleteTextViewStyle; } else if (view instanceof AppCompatEditText) { return R.attr.editTextStyle; } else if (view instanceof AppCompatCheckedTextView) { return Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 ? android.R.attr.checkedTextViewStyle : 0; } else if (view instanceof AppCompatTextView) { return android.R.attr.textViewStyle; } else if (view instanceof AppCompatSpinner) { return R.attr.spinnerStyle; } else if (view instanceof AppCompatImageButton) { return R.attr.imageButtonStyle; } else if (view instanceof AppCompatRatingBar) { return R.attr.ratingBarStyle; } else if (view instanceof AppCompatSeekBar) { return R.attr.seekBarStyle; } else { return super.getDefaultViewDefStyleAttr(view); } }
@Override public View onCreateView(String name, Context context, AttributeSet attrs) { // Allow super to try and create a view first final View result = super.onCreateView(name, context, attrs); if (result != null) { return result; } if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { // If we're running pre-L, we need to 'inject' our tint aware Views in place of the // standard framework versions switch (name) { case "EditText": return new AppCompatEditText(this, attrs); case "Spinner": return new AppCompatSpinner(this, attrs); case "CheckBox": return new AppCompatCheckBox(this, attrs); case "RadioButton": return new AppCompatRadioButton(this, attrs); case "CheckedTextView": return new AppCompatCheckedTextView(this, attrs); default: // do nothing break; } } return null; }
/** * Change background color, text color */ public void changeTaskNameState(View view, AppCompatCheckedTextView taskNameText, boolean completed, Resources resources) { taskNameText.setChecked(completed); if (completed) { view.setBackgroundColor(resources.getColor(R.color.mt_gray5)); taskNameText.setTextColor(resources.getColor(R.color.mt_gray6)); } else { view.setBackgroundColor(resources.getColor(android.R.color.white)); taskNameText.setTextColor(resources.getColor(R.color.mt_black)); } }
/** * Change background color, text color */ public void changeTranNameState(View view, AppCompatCheckedTextView tranNameText, String aTranClass, Resources resources) { tranNameText.setChecked(aTranClass.equalsIgnoreCase("支払い")); if (aTranClass.equalsIgnoreCase("支払い")) { tranNameText.setTextColor(resources.getColor(android.R.color.holo_red_light)); view.setBackgroundColor(resources.getColor(android.R.color.background_light)); } else if (aTranClass.equalsIgnoreCase("収入")){ tranNameText.setTextColor(resources.getColor(android.R.color.holo_blue_light)); view.setBackgroundColor(resources.getColor(android.R.color.background_light)); } else { tranNameText.setTextColor(resources.getColor(android.R.color.holo_orange_dark)); view.setBackgroundColor(resources.getColor(android.R.color.background_light)); } }
@Override public void onClickRecyclerItem(View v, int position) { Tran tran = mListsTranListAdapter.getItem(position); AppCompatCheckedTextView tranNameText = (AppCompatCheckedTextView) v.findViewById(R.id.lists_tran_name); mListsTranListAdapter.changeTranNameState(v, tranNameText, "収入", getResources()); TranRepository.update(tran); }
@Override public void onClickRecyclerItem(View v, int position) { Task task = mListsTaskListAdapter.getItem(position); AppCompatCheckedTextView taskNameText = (AppCompatCheckedTextView) v.findViewById(R.id.lists_task_name); mListsTaskListAdapter.changeTaskNameState(v, taskNameText, !task.isCompleted(), getResources()); TaskRepository.updateByCompleted(mUIThreadRealm, task, !task.isCompleted()); }
public AppCompatCheckedTextView getLeftCtv() { return mLeftCtv; }
public AppCompatCheckedTextView getRightCtv() { return mRightCtv; }
public AppCompatCheckedTextView getTitleCtv() { return mTitleCtv; }
@Test public void testCanOpenFromDrawer() { onView(withId(R.id.drawer_V)).perform(DrawerActions.open()); onView(Matchers.allOf(isAssignableFrom(AppCompatCheckedTextView.class), withText(R.string.accounts))).perform(click()); }