--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2012 Tobias Brunner
+ Hochschule fuer Technik Rapperswil
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the
+ Free Software Foundation; either version 2 of the License, or (at your
+ option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
+
+ 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.
+-->
+<resources>
+ <declare-styleable name="Fragment">
+ <attr name="read_only" format="boolean" />
+ </declare-styleable>
+</resources>
import android.app.Fragment;
import android.content.Context;
import android.content.Intent;
+import android.content.res.TypedArray;
import android.os.Bundle;
+import android.util.AttributeSet;
import android.view.ActionMode;
import android.view.LayoutInflater;
import android.view.Menu;
private VpnProfileAdapter mListAdapter;
private ListView mListView;
private OnVpnProfileSelectedListener mListener;
+ private boolean mReadOnly;
/**
* The activity containing this fragment should implement this interface
public void onVpnProfileSelected(VpnProfile profile);
}
+ @Override
+ public void onInflate(Activity activity, AttributeSet attrs, Bundle savedInstanceState)
+ {
+ super.onInflate(activity, attrs, savedInstanceState);
+ TypedArray a = activity.obtainStyledAttributes(attrs, R.styleable.Fragment);
+ mReadOnly = a.getBoolean(R.styleable.Fragment_read_only, false);
+ a.recycle();
+ }
+
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState)
View view = inflater.inflate(R.layout.profile_list_fragment, null);
mListView = (ListView)view.findViewById(R.id.profile_list);
+ mListView.setAdapter(mListAdapter);
mListView.setEmptyView(view.findViewById(R.id.profile_list_empty));
mListView.setOnItemClickListener(mVpnProfileClicked);
- mListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
- mListView.setMultiChoiceModeListener(mVpnProfileSelected);
- mListView.setAdapter(mListAdapter);
+ if (!mReadOnly)
+ {
+ mListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
+ mListView.setMultiChoiceModeListener(mVpnProfileSelected);
+ }
return view;
}
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
- setHasOptionsMenu(true);
+
+ Bundle args = getArguments();
+ if (args != null)
+ {
+ mReadOnly = args.getBoolean("read_only", mReadOnly);
+ }
+
+ if (!mReadOnly)
+ {
+ setHasOptionsMenu(true);
+ }
Context context = getActivity().getApplicationContext();