updateBureaux(true);
}
+ @Override public void onResume() {
+ getActivity().invalidateOptionsMenu();
+ super.onResume();
+ }
+
/**
* Called manually from parent Activity.
*
*/
package org.adullact.iparapheur.controller.preferences;
+import android.app.Fragment;
import android.content.Context;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
-import android.app.Fragment;
import android.support.v7.app.AppCompatActivity;
import android.text.Editable;
import android.text.TextUtils;
--- /dev/null
+/*
+ * <p>iParapheur Android<br/>
+ * Copyright (C) 2016 Adullact-Projet.</p>
+ *
+ * <p>This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.</p>
+ *
+ * <p>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 Affero General Public License for more details.</p>
+ *
+ * <p>You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.</p>
+ */
+package org.adullact.iparapheur.controller.preferences;
+
+import android.app.Fragment;
+import android.content.Context;
+import android.os.Bundle;
+import android.support.annotation.NonNull;
+import android.support.v7.app.AppCompatActivity;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ImageButton;
+import android.widget.ListView;
+import android.widget.SimpleAdapter;
+import android.widget.Toast;
+
+import org.adullact.iparapheur.R;
+import org.adullact.iparapheur.controller.dossier.filter.MyFilters;
+import org.adullact.iparapheur.model.Filter;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+
+/**
+ * A simple {@link Fragment} subclass.
+ * Use the {@link PreferencesFiltersFragment#newInstance} factory method to
+ * create an instance of this fragment.
+ */
+public class PreferencesFiltersFragment extends Fragment {
+
+ public static final String FRAGMENT_TAG = "preferences_filters_fragment";
+ public static final String LOG_TAG = "PrefsFiltersFrag";
+
+ private static final String LIST_FIELD_NAME = "list_field_name";
+ private static final String LIST_FIELD_ID = "list_field_id";
+
+ private ListView mFiltersListView;
+ private List<Map<String, Object>> mFiltersData;
+
+ /**
+ * Use this factory method to create a new instance of
+ * this fragment using the provided parameters.
+ *
+ * @return A new instance of fragment PreferencesMenuFragment.
+ */
+ public static PreferencesFiltersFragment newInstance() {
+ return new PreferencesFiltersFragment();
+ }
+
+ public PreferencesFiltersFragment() {
+ // Required empty public constructor
+ }
+
+ // <editor-fold desc="LifeCycle">
+
+ @Override public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setRetainInstance(true);
+
+ mFiltersData = new ArrayList<>();
+ buildFiltersDataMap();
+ }
+
+ @Override public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+ View v = inflater.inflate(R.layout.preferences_certificates_fragment, container, false);
+
+ mFiltersListView = (ListView) v.findViewById(R.id.preferences_certificates_fragment_main_list);
+
+ // Building ListAdapter
+
+ String[] orderedFieldNames = new String[]{LIST_FIELD_NAME};
+ int[] orderedFieldIds = new int[]{R.id.preferences_filters_fragment_cell_title_textview};
+
+ SimpleAdapter filtersAdapter = new FiltersSimpleAdapter(getActivity(),
+ mFiltersData,
+ R.layout.preferences_filters_fragment_cell,
+ orderedFieldNames,
+ orderedFieldIds
+ );
+ mFiltersListView.setAdapter(filtersAdapter);
+
+ //
+
+ return v;
+ }
+
+ @Override public void onResume() {
+ super.onResume();
+
+ if (getActivity() instanceof AppCompatActivity) {
+ AppCompatActivity parentActivity = (AppCompatActivity) getActivity();
+ if (parentActivity.getSupportActionBar() != null)
+ parentActivity.getSupportActionBar().setTitle(R.string.pref_header_filters);
+ }
+ }
+
+ // </editor-fold desc="LifeCycle">
+
+ private void onDeleteButtonClicked(int position) {
+
+ // Delete saved Filter
+
+ String currentFilterId = mFiltersData.get(position).get(LIST_FIELD_ID).toString();
+ Filter currentFilter = MyFilters.INSTANCE.getFilter(currentFilterId);
+ MyFilters.INSTANCE.delete(currentFilter);
+ Log.i(LOG_TAG, "Delete filer " + currentFilter);
+
+ // Refresh UI
+
+ mFiltersData.remove(position);
+ ((SimpleAdapter) mFiltersListView.getAdapter()).notifyDataSetChanged();
+ Toast.makeText(getActivity(), R.string.pref_filters_message_delete_success, Toast.LENGTH_SHORT).show();
+ }
+
+ public void buildFiltersDataMap() {
+
+ mFiltersData.clear();
+
+ List<Filter> filterList = MyFilters.INSTANCE.getFilters();
+ for (Filter filter : filterList) {
+
+ // Mapping results
+
+ Map<String, Object> certificateData = new HashMap<>();
+ certificateData.put(LIST_FIELD_NAME, filter.getName());
+ certificateData.put(LIST_FIELD_ID, filter.getId());
+ mFiltersData.add(certificateData);
+ }
+ }
+
+ private class FiltersSimpleAdapter extends SimpleAdapter {
+
+ /**
+ * Constructor
+ *
+ * @param context The context where the View associated with this SimpleAdapter is running
+ * @param data A List of Maps. Each entry in the List corresponds to one row in the list. The
+ * Maps contain the data for each row, and should include all the entries specified in
+ * "from"
+ * @param resource Resource identifier of a view layout that defines the views for this list
+ * item. The layout file should include at least those named views defined in "to"
+ * @param from A list of column names that will be added to the Map associated with each
+ * item.
+ * @param to The views that should display column in the "from" parameter. These should all be
+ * TextViews. The first N views in this list are given the values of the first N columns
+ */
+ public FiltersSimpleAdapter(Context context, List<? extends Map<String, ?>> data, int resource, String[] from, int[] to) {
+ super(context, data, resource, from, to);
+ }
+
+ @Override public View getView(final int position, View convertView, ViewGroup parent) {
+
+ // We reset the Tag before recycling the view, with super, then reassign it
+ // because we don't want to trigger the EditText TextChangedListeners
+ // when the system recycles the views.
+
+ final View v = super.getView(position, convertView, parent);
+
+ final ImageButton deleteButton = (ImageButton) v.findViewById(R.id.preferences_filters_fragment_cell_delete_imagebutton);
+ deleteButton.setOnClickListener(new View.OnClickListener() {
+ @Override public void onClick(View arg0) {
+ onDeleteButtonClicked(position);
+ }
+ });
+
+ return v;
+ }
+ }
+}
*/
package org.adullact.iparapheur.controller.preferences;
-import android.content.Context;
+import android.app.Fragment;
import android.os.Bundle;
import android.support.annotation.NonNull;
-import android.app.Fragment;
import android.support.v7.app.AppCompatActivity;
import android.view.LayoutInflater;
import android.view.View;
v.findViewById(R.id.preferences_certificates).setOnClickListener(this);
v.findViewById(R.id.preferences_about).setOnClickListener(this);
v.findViewById(R.id.preferences_licenses).setOnClickListener(this);
+ v.findViewById(R.id.preferences_filters).setOnClickListener(this);
return v;
}
case R.id.preferences_licenses:
clickedFragment = PreferencesLicencesFragment.newInstance();
break;
+ case R.id.preferences_filters:
+ clickedFragment = PreferencesFiltersFragment.newInstance();
+ break;
}
// throw exception to parent activity
e.printStackTrace();
}
}
+
}
\ No newline at end of file
android:text="@string/mockup_dossier_title"
android:textAppearance="?android:attr/textAppearanceListItemSmall"
android:textColor="@color/text_black"
+ android:textSize="16sp"
tools:ignore="NestedWeights" />
android:maxLines="1"
android:text="@string/mockup_dossier_title"
android:textAppearance="?android:attr/textAppearanceListItemSmall"
- android:textColor="@color/text_black_secondary" />
+ android:textColor="@color/text_black_secondary"
+ android:textSize="14sp" />
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
-<FrameLayout
+<FrameLayout android:id="@+id/dossiers_list_item_selectable_layout"
xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/dossiers_list_item_selectable_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/list_background_secondary100">
<FrameLayout
android:id="@+id/dossiers_list_item_checkable_layout"
- android:layout_gravity="center_vertical"
- android:layout_width="56dp"
+ android:layout_width="72dp"
android:layout_height="56dp"
- android:duplicateParentState="true">
+ android:layout_gravity="center_vertical"
+ android:duplicateParentState="true"
+ android:paddingEnd="16dp"
+ android:paddingLeft="16dp"
+ android:paddingRight="16dp"
+ android:paddingStart="16dp">
<FrameLayout
android:id="@+id/dossiers_list_item_image_main_container"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:contentDescription="@string/etape_courante"
- android:src="@drawable/ic_sign_24dp"/>
+ android:src="@drawable/ic_sign_24dp" />
</FrameLayout>
<FrameLayout
android:layout_height="wrap_content"
android:layout_gravity="center"
android:contentDescription="@string/etape_courante"
- android:src="@drawable/ic_done_white_24dp"/>
+ android:src="@drawable/ic_done_white_24dp" />
</FrameLayout>
</FrameLayout>
<LinearLayout
- android:orientation="vertical"
- android:layout_marginLeft="56dp"
- android:layout_marginStart="56dp"
- android:layout_marginRight="16dp"
- android:layout_marginEnd="16dp"
android:layout_width="match_parent"
- android:layout_height="wrap_content">
+ android:layout_height="wrap_content"
+ android:layout_marginEnd="16dp"
+ android:layout_marginLeft="72dp"
+ android:layout_marginRight="16dp"
+ android:layout_marginStart="72dp"
+ android:orientation="vertical">
<TextView
android:id="@+id/dossiers_list_item_title"
android:layout_width="match_parent"
android:layout_height="?android:attr/listPreferredItemHeightSmall"
- android:textAppearance="?android:attr/textAppearanceListItemSmall"
+ android:ellipsize="end"
android:gravity="bottom"
android:maxLines="1"
- android:ellipsize="end"
+ android:text="@string/mockup_dossier_title"
+ android:textAppearance="?android:attr/textAppearanceListItemSmall"
android:textColor="@color/text_black"
- android:text="@string/mockup_dossier_title"/>
+ android:textSize="16sp" />
<TextView
android:id="@+id/dossiers_list_item_extras"
android:layout_width="match_parent"
android:layout_height="?android:attr/listPreferredItemHeightSmall"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:maxLines="1"
android:ellipsize="end"
+ android:maxLines="1"
+ android:text="@string/mockup_dossier_subtitle"
+ android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/text_black_secondary"
- android:text="@string/mockup_dossier_subtitle"/>
+ android:textSize="14sp" />
</LinearLayout>
</FrameLayout>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="@color/grey_200"
+ android:clickable="true">
+
+ <ListView
+ android:id="@+id/preferences_accounts_fragment_main_list"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:clipToPadding="false"
+ android:descendantFocusability="afterDescendants"
+ android:divider="@color/grey_200"
+ android:paddingTop="8dp"
+ tools:listitem="@layout/preferences_filters_fragment_cell" />
+
+</FrameLayout>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:card_view="http://schemas.android.com/apk/res-auto"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+
+ <android.support.v7.widget.CardView
+ android:layout_width="360dp"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_horizontal"
+ android:layout_marginBottom="8dp"
+ android:elevation="2dp"
+ card_view:cardCornerRadius="4dp"
+ tools:ignore="UnusedAttribute">
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ android:padding="16dp">
+
+ <TextView
+ android:id="@+id/preferences_filters_fragment_cell_title_textview"
+ android:layout_width="0dp"
+ android:layout_height="match_parent"
+ android:layout_weight="1"
+ android:ellipsize="end"
+ android:gravity="center_vertical"
+ android:maxLines="1"
+ android:text="@string/mockup_filter_name"
+ android:textColor="@color/text_black"
+ android:textSize="16sp" />
+
+ <ImageButton
+ android:id="@+id/preferences_filters_fragment_cell_delete_imagebutton"
+ style="@style/Widget.AppCompat.ImageButton"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical"
+ android:backgroundTint="@android:color/background_light"
+ android:contentDescription="@string/delete"
+ android:src="@drawable/ic_delete_white_24dp"
+ android:tint="@color/settings_primary_500" />
+
+ </LinearLayout>
+
+ </android.support.v7.widget.CardView>
+</FrameLayout>
\ No newline at end of file
android:textColor="@color/text_black"
android:textSize="16sp" />
</LinearLayout>
+
+ <LinearLayout
+ android:id="@+id/preferences_filters"
+ android:layout_width="match_parent"
+ android:layout_height="56dp"
+ android:background="@drawable/list_background_grey100"
+ android:clickable="true"
+ android:orientation="horizontal"
+ tools:ignore="UseCompoundDrawables">
+
+ <ImageView
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:layout_margin="16dp"
+ android:contentDescription="@string/pref_header_filters"
+ android:src="@drawable/ic_filter_list_white_24dp"
+ android:tint="@color/settings_primary_500" />
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="56dp"
+ android:gravity="center_vertical"
+ android:text="@string/pref_header_filters"
+ android:textColor="@color/text_black"
+ android:textSize="16sp" />
+ </LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
<string name="mockup_certificate_name">Certificat.bks</string>
<string name="mockup_certificate_expiration_date">exp. 16/02/15</string>
+ <string name="mockup_filter_name">Mon filtre</string>
+
<!-- Default Account -->
<string name="demo_account_id">AccountTest0</string>
<string name="pref_header_legal">Informations légales</string>
<string name="pref_header_licenses">Licenses tierces</string>
<string name="pref_header_certificates">Certificats</string>
+ <string name="pref_header_filters">Filtres</string>
<!-- Account -->
<string name="pref_certificates_message_delete_failed">Le certificat n\'a pas pu être supprimé</string>
<string name="pref_certificates_expiration_date">exp. -date-</string>
+ <string name="pref_filters_message_delete_success">Filtre supprimé</string>
+
</resources>