<commit_before>/*
 * Copyright 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.google.android.material.shape;

import com.google.android.material.R;

import static android.support.annotation.RestrictTo.Scope.LIBRARY_GROUP;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.RectF;
import android.support.annotation.AttrRes;
import android.support.annotation.Dimension;
import android.support.annotation.RestrictTo;
import android.support.annotation.StyleRes;
import com.google.android.material.internal.Experimental;
import com.google.android.material.internal.ThemeEnforcement;
import android.util.AttributeSet;
import android.view.ContextThemeWrapper;

/**
 * This class models the edges and corners of a shape, which are used by {@link
 * MaterialShapeDrawable} to generate and render the shape for a view's background.
 */
@Experimental("The shapes API is currently experimental and subject to change")
public class ShapeAppearanceModel {
  private CornerTreatment topLeftCorner;
  private CornerTreatment topRightCorner;
  private CornerTreatment bottomRightCorner;
  private CornerTreatment bottomLeftCorner;
  private EdgeTreatment topEdge;
  private EdgeTreatment rightEdge;
  private EdgeTreatment bottomEdge;
  private EdgeTreatment leftEdge;

  /** Constructs a default path generator with default edge and corner treatments. */
  public ShapeAppearanceModel() {
    setTopLeftCorner(MaterialShapeUtils.createDefaultCornerTreatment());
    setTopRightCorner(MaterialShapeUtils.createDefaultCornerTreatment());
    setBottomRightCorner(MaterialShapeUtils.createDefaultCornerTreatment());
    setBottomLeftCorner(MaterialShapeUtils.createDefaultCornerTreatment());

    setTopEdge(MaterialShapeUtils.createDefaultEdgeTreatment());
    setRightEdge(MaterialShapeUtils.createDefaultEdgeTreatment());
    setBottomEdge(MaterialShapeUtils.createDefaultEdgeTreatment());
    setLeftEdge(MaterialShapeUtils.createDefaultEdgeTreatment());
  }

  public ShapeAppearanceModel(ShapeAppearanceModel shapeAppearanceModel) {
    topLeftCorner = shapeAppearanceModel.getTopLeftCorner().clone();
    topRightCorner = shapeAppearanceModel.getTopRightCorner().clone();
    bottomRightCorner = shapeAppearanceModel.getBottomRightCorner().clone();
    bottomLeftCorner = shapeAppearanceModel.getBottomLeftCorner().clone();

    topEdge = shapeAppearanceModel.getTopEdge().clone();
    rightEdge = shapeAppearanceModel.getRightEdge().clone();
    leftEdge = shapeAppearanceModel.getLeftEdge().clone();
    bottomEdge = shapeAppearanceModel.getBottomEdge().clone();
  }

  public ShapeAppearanceModel(
      Context context, AttributeSet attrs, @AttrRes int defStyleAttr, @StyleRes int defStyleRes) {
    this(context, attrs, defStyleAttr, defStyleRes, 0);
  }

  public ShapeAppearanceModel(
      Context context,
      AttributeSet attrs,
      @AttrRes int defStyleAttr,
      @StyleRes int defStyleRes,
      int defaultCornerSize) {
    TypedArray a =
        ThemeEnforcement.obtainStyledAttributes(
            context, attrs, R.styleable.MaterialShape, defStyleAttr, defStyleRes);

    int shapeAppearanceResId = a.getResourceId(R.styleable.MaterialShape_shapeAppearance, 0);
    int shapeAppearanceOverlayResId =
        a.getResourceId(R.styleable.MaterialShape_shapeAppearanceOverlay, 0);
    a.recycle();

    // The attributes in shapeAppearanceOverlay should be applied on top of shapeAppearance.
    if (shapeAppearanceOverlayResId != 0) {
      context = new ContextThemeWrapper(context, shapeAppearanceResId);
      shapeAppearanceResId = shapeAppearanceOverlayResId;
    }
<commit_msg>Turn off theme enforcement for ShapeAppearanceModel.<commit_after>/*
 * Copyright 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.google.android.material.shape;

import com.google.android.material.R;

import static android.support.annotation.RestrictTo.Scope.LIBRARY_GROUP;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.RectF;
import android.support.annotation.AttrRes;
import android.support.annotation.Dimension;
import android.support.annotation.RestrictTo;
import android.support.annotation.StyleRes;
import com.google.android.material.internal.Experimental;
import android.util.AttributeSet;
import android.view.ContextThemeWrapper;

/**
 * This class models the edges and corners of a shape, which are used by {@link
 * MaterialShapeDrawable} to generate and render the shape for a view's background.
 */
@Experimental("The shapes API is currently experimental and subject to change")
public class ShapeAppearanceModel {
  private CornerTreatment topLeftCorner;
  private CornerTreatment topRightCorner;
  private CornerTreatment bottomRightCorner;
  private CornerTreatment bottomLeftCorner;
  private EdgeTreatment topEdge;
  private EdgeTreatment rightEdge;
  private EdgeTreatment bottomEdge;
  private EdgeTreatment leftEdge;

  /** Constructs a default path generator with default edge and corner treatments. */
  public ShapeAppearanceModel() {
    setTopLeftCorner(MaterialShapeUtils.createDefaultCornerTreatment());
    setTopRightCorner(MaterialShapeUtils.createDefaultCornerTreatment());
    setBottomRightCorner(MaterialShapeUtils.createDefaultCornerTreatment());
    setBottomLeftCorner(MaterialShapeUtils.createDefaultCornerTreatment());

    setTopEdge(MaterialShapeUtils.createDefaultEdgeTreatment());
    setRightEdge(MaterialShapeUtils.createDefaultEdgeTreatment());
    setBottomEdge(MaterialShapeUtils.createDefaultEdgeTreatment());
    setLeftEdge(MaterialShapeUtils.createDefaultEdgeTreatment());
  }

  public ShapeAppearanceModel(ShapeAppearanceModel shapeAppearanceModel) {
    topLeftCorner = shapeAppearanceModel.getTopLeftCorner().clone();
    topRightCorner = shapeAppearanceModel.getTopRightCorner().clone();
    bottomRightCorner = shapeAppearanceModel.getBottomRightCorner().clone();
    bottomLeftCorner = shapeAppearanceModel.getBottomLeftCorner().clone();

    topEdge = shapeAppearanceModel.getTopEdge().clone();
    rightEdge = shapeAppearanceModel.getRightEdge().clone();
    leftEdge = shapeAppearanceModel.getLeftEdge().clone();
    bottomEdge = shapeAppearanceModel.getBottomEdge().clone();
  }

  public ShapeAppearanceModel(
      Context context, AttributeSet attrs, @AttrRes int defStyleAttr, @StyleRes int defStyleRes) {
    this(context, attrs, defStyleAttr, defStyleRes, 0);
  }

  public ShapeAppearanceModel(
      Context context,
      AttributeSet attrs,
      @AttrRes int defStyleAttr,
      @StyleRes int defStyleRes,
      int defaultCornerSize) {
    TypedArray a =
        context.obtainStyledAttributes(attrs, R.styleable.MaterialShape, defStyleAttr, defStyleRes);

    int shapeAppearanceResId = a.getResourceId(R.styleable.MaterialShape_shapeAppearance, 0);
    int shapeAppearanceOverlayResId =
        a.getResourceId(R.styleable.MaterialShape_shapeAppearanceOverlay, 0);
    a.recycle();

    // The attributes in shapeAppearanceOverlay should be applied on top of shapeAppearance.
    if (shapeAppearanceOverlayResId != 0) {
      context = new ContextThemeWrapper(context, shapeAppearanceResId);
      shapeAppearanceResId = shapeAppearanceOverlayResId;
    }

{'fraction_non_alphanumeric': 0.07835732829832429, 'fraction_numerical': 0.0028321925890960587, 'mean_word_length': 5.2964338781575035, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2144014', 'n_tokens_mistral': 2229, 'n_tokens_neox': 2173, 'n_words': 581}