<commit_before>package com.mapswithme.maps.ugc.routes;

import android.content.Intent;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.TextView;

import com.mapswithme.maps.R;
import com.mapswithme.maps.base.BaseMwmToolbarFragment;
import com.mapswithme.maps.bookmarks.data.BookmarkCategory;
import com.mapswithme.maps.bookmarks.data.BookmarkManager;
import com.mapswithme.util.statistics.Statistics;

import java.util.Objects;

public class UgcRouteEditSettingsFragment extends BaseMwmToolbarFragment
{
  @SuppressWarnings("NullableProblems")
  @NonNull
  private BookmarkCategory mCategory;

  @SuppressWarnings("NullableProblems")
  @NonNull
  private TextView mAccessRulesView;

  @SuppressWarnings("NullableProblems")
  @NonNull
  private EditText mEditDescView;

  @SuppressWarnings("NullableProblems")
  @NonNull
  private EditText mEditCategoryNameView;

  @Override
  public void onCreate(@Nullable Bundle savedInstanceState)
  {
    super.onCreate(savedInstanceState);
    Bundle args = getArguments();
    if (args == null)
      throw new IllegalArgumentException("Args must be not null");
    mCategory = Objects.requireNonNull(args.getParcelable(UgcRouteEditSettingsActivity.EXTRA_BOOKMARK_CATEGORY));
  }

  @Nullable
  @Override
  public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
                           @Nullable Bundle savedInstanceState)
  {
    View root = inflater.inflate(R.layout.fragment_ugc_route_edit, container, false);
    setHasOptionsMenu(true);
    initViews(root);
    return root;
  }

  private void initViews(@NonNull View root)
  {
    mEditCategoryNameView = root.findViewById(R.id.edit_category_name_view);
    mEditCategoryNameView.setText(mCategory.getName());
    mEditCategoryNameView.requestFocus();
    mAccessRulesView = root.findViewById(R.id.sharing_options_desc);
    mAccessRulesView.setText(mCategory.getAccessRules().getNameResId());
    mEditDescView = root.findViewById(R.id.edit_description);
    mEditDescView.setText(mCategory.getDescription());
    View clearNameBtn = root.findViewById(R.id.edit_text_clear_btn);
    clearNameBtn.setOnClickListener(v -> mEditCategoryNameView.getEditableText().clear());
    View sharingOptionsBtn = root.findViewById(R.id.open_sharing_options_screen_btn_container);
    sharingOptionsBtn.setOnClickListener(v -> onSharingOptionsClicked());
    sharingOptionsBtn.setEnabled(mCategory.isSharingOptionsAllowed());
  }

  @Override
  public void onActivityResult(int requestCode, int resultCode, Intent data)
  {
    super.onActivityResult(requestCode, resultCode, data);<commit_msg> [android] Added limit for name of category in edit mode.<commit_after>package com.mapswithme.maps.ugc.routes;

import android.content.Intent;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import android.text.InputFilter;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.TextView;

import com.mapswithme.maps.R;
import com.mapswithme.maps.base.BaseMwmToolbarFragment;
import com.mapswithme.maps.bookmarks.data.BookmarkCategory;
import com.mapswithme.maps.bookmarks.data.BookmarkManager;
import com.mapswithme.util.statistics.Statistics;

import java.util.Objects;

public class UgcRouteEditSettingsFragment extends BaseMwmToolbarFragment
{
  private static final int TEXT_LENGTH_LIMIT = 60;

  @SuppressWarnings("NullableProblems")
  @NonNull
  private BookmarkCategory mCategory;

  @SuppressWarnings("NullableProblems")
  @NonNull
  private TextView mAccessRulesView;

  @SuppressWarnings("NullableProblems")
  @NonNull
  private EditText mEditDescView;

  @SuppressWarnings("NullableProblems")
  @NonNull
  private EditText mEditCategoryNameView;

  @Override
  public void onCreate(@Nullable Bundle savedInstanceState)
  {
    super.onCreate(savedInstanceState);
    Bundle args = getArguments();
    if (args == null)
      throw new IllegalArgumentException("Args must be not null");
    mCategory = Objects.requireNonNull(args.getParcelable(UgcRouteEditSettingsActivity.EXTRA_BOOKMARK_CATEGORY));
  }

  @Nullable
  @Override
  public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
                           @Nullable Bundle savedInstanceState)
  {
    View root = inflater.inflate(R.layout.fragment_ugc_route_edit, container, false);
    setHasOptionsMenu(true);
    initViews(root);
    return root;
  }

  private void initViews(@NonNull View root)
  {
    mEditCategoryNameView = root.findViewById(R.id.edit_category_name_view);
    mEditCategoryNameView.setText(mCategory.getName());
    InputFilter[] f = { new InputFilter.LengthFilter(TEXT_LENGTH_LIMIT) };
    mEditCategoryNameView.setFilters(f);
    mEditCategoryNameView.requestFocus();
    mAccessRulesView = root.findViewById(R.id.sharing_options_desc);
    mAccessRulesView.setText(mCategory.getAccessRules().getNameResId());
    mEditDescView = root.findViewById(R.id.edit_description);
    mEditDescView.setText(mCategory.getDescription());
    View clearNameBtn = root.findViewById(R.id.edit_text_clear_btn);
    clearNameBtn.setOnClickListener(v -> mEditCategoryNameView.getEditableText().clear());
    View sharingOptionsBtn = root.findViewById(R.id.open_sharing_options_screen_btn_container);
    sharingOptionsBtn.setOnClickListener(v -> onSharingOptionsClicked());
    sharingOptionsBtn.setEnabled(mCategory.isSharingOptionsAllowed());
  }

  @Override
  public void onActivityResult(int requestCode, int resultCode, Intent data)
  {
    super.onActivityResult(requestCode, resultCode, data);
{'fraction_non_alphanumeric': 0.09204265791632486, 'fraction_numerical': 0.00032813781788351107, 'mean_word_length': 5.626086956521739, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '6002392', 'n_tokens_mistral': 1799, 'n_tokens_neox': 1753, 'n_words': 314}