/*
 * Copyright 2020 Google LLC
 *
 * 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
 *
 *     https://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.gnd.ui.settings;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout.LayoutParams;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.preference.PreferenceFragmentCompat;
import com.google.android.gnd.MainActivity;
import com.google.android.gnd.R;
import com.google.android.gnd.databinding.SettingsFragBinding;

public class SettingsFragment extends PreferenceFragmentCompat {

  @Override
  public View onCreateView(
      @NonNull LayoutInflater inflater,
      @Nullable ViewGroup container,
      @Nullable Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    SettingsFragBinding binding = SettingsFragBinding.inflate(inflater, container, true);
    binding.setLifecycleOwner(this);
    ((MainActivity) getActivity()).setActionBar(binding.settingsToolbar, true);
    return super.onCreateView(inflater, container, savedInstanceState);
  }

  @Override
  public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    // TODO: Set dynamically by calculating the actual height of toolbar
    int topMargin = 108;

    LayoutParams params = (LayoutParams) getListView().getLayoutParams();
    params.setMargins(0, topMargin, 0, 0);
    getListView().setLayoutParams(params);
  }

  @Override
  public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
    setPreferencesFromResource(R.xml.preferences, rootKey);
  }
}

@@ -1068,16 +1068,366 @@
 nding;%0A%0A
+/**%0A * Fragment containing app preferences saved as shared preferences.%0A *%0A * %3Cp%3ENOTE: It uses %7B@link PreferenceFragmentCompat%7D instead of %7B@link%0A * com.google.android.gnd.ui.common.AbstractFragment%7D, so dagger can't inject into it like it does%0A * in other fragments.%0A *%0A * %3Cp%3ETODO: Create dagger module and support injection into this fragment.%0A */%0A
 public c

Add javadoc