+++ /dev/null
-/**
- * ownCloud Android client application
- *
- * @author masensio
- * Copyright (C) 2015 ownCloud Inc.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-package com.owncloud.android.ui.fragment;
-
-import android.accounts.Account;
-import android.app.Activity;
-import android.app.SearchManager;
-import android.content.Context;
-import android.net.Uri;
-import android.os.Bundle;
-import android.support.v4.app.Fragment;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.SearchView;
-
-import com.owncloud.android.R;
-import com.owncloud.android.datamodel.OCFile;
-
-/**
- * Fragment for Searching users and groups
- *
- * A simple {@link Fragment} subclass.
- * Activities that contain this fragment must implement the
- * {@link SearchFragment.OnSearchFragmentInteractionListener} interface
- * to handle interaction events.
- * Use the {@link SearchFragment#newInstance} factory method to
- * create an instance of this fragment.
- */
-public class SearchFragment extends Fragment {
- private static final String TAG = SearchFragment.class.getSimpleName();
-
- // the fragment initialization parameters
- private static final String ARG_FILE = "FILE";
- private static final String ARG_ACCOUNT = "ACCOUNT";
-
- // Parameters
- private OCFile mFile;
- private Account mAccount;
-
- private OnSearchFragmentInteractionListener mListener;
-
- /**
- * Public factory method to create new SearchFragment instances.
- *
- * @param fileToShare An {@link OCFile} to show in the fragment
- * @param account An ownCloud account
- * @return A new instance of fragment SearchFragment.
- */
- // TODO: Rename and change types and number of parameters
- public static SearchFragment newInstance(OCFile fileToShare, Account account) {
- SearchFragment fragment = new SearchFragment();
- Bundle args = new Bundle();
- args.putParcelable(ARG_FILE, fileToShare);
- args.putParcelable(ARG_ACCOUNT, account);
- fragment.setArguments(args);
- return fragment;
- }
-
- public SearchFragment() {
- // Required empty public constructor
- }
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- if (getArguments() != null) {
- mFile = getArguments().getParcelable(ARG_FILE);
- mAccount = getArguments().getParcelable(ARG_ACCOUNT);
- }
-
- }
-
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- // Inflate the layout for this fragment
- View view = inflater.inflate(R.layout.search_users_groups_layout, container, false);
-
- // Get the SearchView and set the searchable configuration
- SearchView searchView = (SearchView) view.findViewById(R.id.searchView);
- SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE);
- searchView.setSearchableInfo(searchManager.getSearchableInfo(
- getActivity().getComponentName()) // assumes parent activity is the searchable activity
- );
- searchView.setIconifiedByDefault(false); // do not iconify the widget; expand it by default
-
- return view;
- }
-
- // TODO: Rename method, update argument and hook method into UI event
- public void onButtonPressed(Uri uri) {
- if (mListener != null) {
- mListener.onSearchFragmentInteraction(uri);
- }
- }
-
- @Override
- public void onAttach(Activity activity) {
- super.onAttach(activity);
- try {
- mListener = (OnSearchFragmentInteractionListener) activity;
- } catch (ClassCastException e) {
- throw new ClassCastException(activity.toString()
- + " must implement OnFragmentInteractionListener");
- }
- }
-
- @Override
- public void onDetach() {
- super.onDetach();
- mListener = null;
- }
-
- // TODO: review if it is necessary
- /**
- * This interface must be implemented by activities that contain this
- * fragment to allow an interaction in this fragment to be communicated
- * to the activity and potentially other fragments contained in that
- * activity.
- * <p/>
- * See the Android Training lesson <a href=
- * "http://developer.android.com/training/basics/fragments/communicating.html"
- * >Communicating with Other Fragments</a> for more information.
- */
- public interface OnSearchFragmentInteractionListener {
- // TODO: Update argument type and name
- public void onSearchFragmentInteraction(Uri uri);
- }
-
-}