tools/android/checkxmlstyle/checkxmlstyle.py
def _CheckButtonCompatWidgetUsage(input_api, output_api):
  """Encourage using ButtonCompat rather than Button, AppButtonCompat"""
  warnings = []

  for f in IncludedFiles(input_api):
    # layout resource files
    for line_number, line in f.ChangedContents():
      if (re.search(r'<Button$', line) or
          re.search(r'<android.support.v7.widget.AppCompatButton$', line)):
        warnings.append(
            '  %s:%d\n    \t%s' % (f.LocalPath(), line_number, line.strip()))

  if warnings:
    return [
        output_api.PresubmitPromptWarning(
            '''
  Android Widget Check warning:
    Your new code is using Button or AppCompatButton, listed below.

    Use org.chromium.ui.widget.ButtonCompat instead of Button and
    AppCompatButton if possible; ButtonCompat is a Material-styled button with a
    customizable background color. On L devices, this is a true Material button.
    On earlier devices, the button is similar but lacks ripples and a shadow.

    See https://crbug.com/775198 and https://crbug.com/908651 for
    more information.
  ''', warnings)
    ]

  return []
Encourage using ButtonCompat rather than Button, AppButtonCompat
Encourage using ButtonCompat rather than Button, AppButtonCompat
Encourage using ButtonCompat rather than Button AppButtonCompat
def _CheckButtonCompatWidgetUsage(input_api, output_api):
  warnings = []
  for f in IncludedFiles(input_api):
    for line_number, line in f.ChangedContents():
      if (re.search(r'<Button$', line) or
          re.search(r'<android.support.v7.widget.AppCompatButton$', line)):
        warnings.append(
            '  %s:%d\n    \t%s' % (f.LocalPath(), line_number, line.strip()))
  if warnings:
    return [
        output_api.PresubmitPromptWarning(
            '''
  Android Widget Check warning:
    Your new code is using Button or AppCompatButton, listed below.
    Use org.chromium.ui.widget.ButtonCompat instead of Button and
    AppCompatButton if possible; ButtonCompat is a Material-styled button with a
    customizable background color. On L devices, this is a true Material button.
    On earlier devices, the button is similar but lacks ripples and a shadow.
    See https://crbug.com/775198 and https://crbug.com/908651 for
    more information.
  ''', warnings)
    ]
  return []
def _CheckButtonCompatWidgetUsage ( input_api , output_api ) : warnings = [ ] for f in IncludedFiles ( input_api ) : for line_number , line in f . ChangedContents ( ) : if ( re . search ( r'<Button$' , line ) or re . search ( r'<android.support.v7.widget.AppCompatButton$' , line ) ) : warnings . append ( '  %s:%d\n    \t%s' % ( f . LocalPath ( ) , line_number , line . strip ( ) ) ) if warnings : return [ output_api . PresubmitPromptWarning ( '''
  Android Widget Check warning:
    Your new code is using Button or AppCompatButton, listed below.

    Use org.chromium.ui.widget.ButtonCompat instead of Button and
    AppCompatButton if possible; ButtonCompat is a Material-styled button with a
    customizable background color. On L devices, this is a true Material button.
    On earlier devices, the button is similar but lacks ripples and a shadow.

    See https://crbug.com/775198 and https://crbug.com/908651 for
    more information.
  ''' , warnings ) ] return [ ]
Encourage using ButtonCompat rather than Button, AppButtonCompat
Encourage using ButtonCompat rather than Button AppButtonCompat
"""Encourage using ButtonCompat rather than Button, AppButtonCompat""" # layout resource files
input_api
output_api