<commit_before>package plugin.google.maps;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.RectF;
import android.os.Build.VERSION;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsoluteLayout;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.ScrollView;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

@SuppressWarnings("deprecation")
public class MyPluginLayout extends FrameLayout  {
  private View browserView;
  private ViewGroup root;
  private HashMap<String, RectF> drawRects = new HashMap<String, RectF>();
  private Context context;
  private FrontLayerLayout frontLayer;
  private ScrollView scrollView = null;
  private FrameLayout scrollFrameLayout = null;
  private View backgroundView = null;
  private HashMap<String, ViewGroup> mapViews = new HashMap<String, ViewGroup>();
  private HashMap<String, TouchableWrapper> touchableWrappers = new HashMap<String, TouchableWrapper>();
  private boolean isScrolling = false;
  private HashMap<String, ViewGroup.LayoutParams> orgLayoutParams = new HashMap<String, ViewGroup.LayoutParams>();
  private boolean isDebug = false;
  private boolean isClickable = true;
  private HashMap<String, HashMap<String, RectF>> MAP_HTMLNodes = new HashMap<String, HashMap<String, RectF>>();
  private Activity mActivity = null;
  private Paint debugPaint = new Paint();
  
  @SuppressLint("NewApi")
  public MyPluginLayout(View browserView, Activity activity) {
    super(browserView.getContext());
    mActivity = activity;
    this.browserView = browserView;
    this.root = (ViewGroup) browserView.getParent();
    this.context = browserView.getContext();
    if (VERSION.SDK_INT >= 21 || "org.xwalk.core.XWalkView".equals(browserView.getClass().getName())) {
      browserView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
    }
    frontLayer = new FrontLayerLayout(this.context);
    
    scrollView = new ScrollView(this.context);
    scrollView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));

    backgroundView = new View(this.context);
    backgroundView.setBackgroundColor(Color.WHITE);
    backgroundView.setVerticalScrollBarEnabled(false);
    backgroundView.setHorizontalScrollBarEnabled(false);
    backgroundView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, 9999));

    root.removeView(browserView);
    frontLayer.addView(browserView);

    scrollFrameLayout = new FrameLayout(this.context);
    scrollFrameLayout.addView(backgroundView);
    scrollFrameLayout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));

    scrollView.setHorizontalScrollBarEnabled(true);
    scrollView.setVerticalScrollBarEnabled(true);
    scrollView.addView(scrollFrameLayout);



    this.addView(scrollView);
    this.addView(frontLayer);
    root.addView(this);
    mActivity.getWindow().getDecorView().requestFocus();
  }
  
  public void setDrawingRect(String mapId, float left, float top, float right, float bottom) {
    RectF drawRect = drawRects.get(mapId);
    drawRect.left = left;
    drawRect.top = top;
    drawRect.right = right;
    drawRect.bottom = bottom;
  }
  
  public void putHTMLElement(String mapId, String domId, float left, float top, float right, float bottom) {
    //Log.d("MyPluginLayout", "--> putHTMLElement / mapId = " + mapId + ", domId = " + domId);
    //Log.d("MyPluginLayout", "--> putHTMLElement / " + left + ", " + top + " - " + right + ", " + bottom);
    HashMap<String, RectF> HTMLNodes;
    if (MAP_HTMLNodes.containsKey(mapId)) {
      HTMLNodes = MAP_HTMLNodes.get(mapId);
    } else {
      HTMLNodes = new HashMap<String, RectF>();<commit_msg>Follows maps with horizontal scrolls.<commit_after>package plugin.google.maps;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.RectF;
import android.os.Build.VERSION;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsoluteLayout;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.ScrollView;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

@SuppressWarnings("deprecation")
public class MyPluginLayout extends FrameLayout  {
  private View browserView;
  private ViewGroup root;
  private HashMap<String, RectF> drawRects = new HashMap<String, RectF>();
  private Context context;
  private FrontLayerLayout frontLayer;
  private ScrollView scrollView = null;
  private FrameLayout scrollFrameLayout = null;
  private View backgroundView = null;
  private HashMap<String, ViewGroup> mapViews = new HashMap<String, ViewGroup>();
  private HashMap<String, TouchableWrapper> touchableWrappers = new HashMap<String, TouchableWrapper>();
  private boolean isScrolling = false;
  private HashMap<String, ViewGroup.LayoutParams> orgLayoutParams = new HashMap<String, ViewGroup.LayoutParams>();
  private boolean isDebug = false;
  private boolean isClickable = true;
  private HashMap<String, HashMap<String, RectF>> MAP_HTMLNodes = new HashMap<String, HashMap<String, RectF>>();
  private Activity mActivity = null;
  private Paint debugPaint = new Paint();
  
  @SuppressLint("NewApi")
  public MyPluginLayout(View browserView, Activity activity) {
    super(browserView.getContext());
    mActivity = activity;
    this.browserView = browserView;
    this.root = (ViewGroup) browserView.getParent();
    this.context = browserView.getContext();
    if (VERSION.SDK_INT >= 21 || "org.xwalk.core.XWalkView".equals(browserView.getClass().getName())) {
      browserView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
    }
    frontLayer = new FrontLayerLayout(this.context);
    
    scrollView = new ScrollView(this.context);
    scrollView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));

    backgroundView = new View(this.context);
    backgroundView.setBackgroundColor(Color.WHITE);
    backgroundView.setVerticalScrollBarEnabled(false);
    backgroundView.setHorizontalScrollBarEnabled(false);
    backgroundView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, 9999));

    root.removeView(browserView);
    frontLayer.addView(browserView);

    scrollFrameLayout = new FrameLayout(this.context);
    scrollFrameLayout.addView(backgroundView);
    scrollFrameLayout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));

    scrollView.setHorizontalScrollBarEnabled(true);
    scrollView.setVerticalScrollBarEnabled(true);
    scrollView.addView(scrollFrameLayout);



    this.addView(scrollView);
    this.addView(frontLayer);
    root.addView(this);
    mActivity.getWindow().getDecorView().requestFocus();
  }
  
  public void setDrawingRect(String mapId, float left, float top, float right, float bottom) {
    RectF drawRect = drawRects.get(mapId);
    drawRect.left = left;
    drawRect.top = top;
    drawRect.right = right;
    drawRect.bottom = bottom;
    this.updateViewPosition(mapId);
  }
  
  public void putHTMLElement(String mapId, String domId, float left, float top, float right, float bottom) {
    //Log.d("MyPluginLayout", "--> putHTMLElement / mapId = " + mapId + ", domId = " + domId);
    //Log.d("MyPluginLayout", "--> putHTMLElement / " + left + ", " + top + " - " + right + ", " + bottom);
    HashMap<String, RectF> HTMLNodes;
    if (MAP_HTMLNodes.containsKey(mapId)) {
      HTMLNodes = MAP_HTMLNodes.get(mapId);
    } else {
      HTMLNodes = new HashMap<String, RectF>();
{'fraction_non_alphanumeric': 0.10857213438735178, 'fraction_numerical': 0.0014822134387351778, 'mean_word_length': 5.0425373134328355, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '7385590', 'n_tokens_mistral': 2354, 'n_tokens_neox': 2321, 'n_words': 502}