import android.app.Activity;
import android.app.DialogFragment;
import android.app.Fragment;
-import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.content.Intent;
import android.content.SharedPreferences;
mLeftDrawerToggle = new DossiersActionBarDrawerToggle(this, mLeftDrawerLayout);
mLeftDrawerLayout.addDrawerListener(mLeftDrawerToggle);
mRightDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
+
+ // ContentView Fragment restore
+
+ Fragment contentFragment = getFragmentManager().findFragmentByTag(DossierDetailFragment.FRAGMENT_TAG);
+ if (contentFragment == null)
+ contentFragment = new DossierDetailFragment();
+ contentFragment.setRetainInstance(true);
+
+ FragmentTransaction contenttransaction = getFragmentManager().beginTransaction();
+ contenttransaction.replace(R.id.dossier_detail_layout, contentFragment, DossierDetailFragment.FRAGMENT_TAG);
+ contenttransaction.commit();
+
+ // Menu Fragment restore
+
+ MenuFragment menuFragment = (MenuFragment) getFragmentManager().findFragmentByTag(MenuFragment.FRAGMENT_TAG);
+ if (menuFragment == null)
+ menuFragment = new MenuFragment();
+ menuFragment.setRetainInstance(true);
+
+ FragmentTransaction menuTransaction = getFragmentManager().beginTransaction();
+ menuTransaction.replace(R.id.menu_layout, menuFragment, MenuFragment.FRAGMENT_TAG);
+ menuTransaction.commit();
}
@Override protected void onPostCreate(Bundle savedInstanceState) {
actionDialog.show(getFragmentManager(), ImportCertificatesDialogFragment.FRAGMENT_TAG);
}
- // Clear backStack (wrong backStack can stay after rotation)
-
- FragmentManager fragmentManager = getFragmentManager();
- fragmentManager.popBackStackImmediate(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
-
- // ContentView Fragment restore
-
- Fragment contentFragment = getFragmentManager().findFragmentByTag(DossierDetailFragment.FRAGMENT_TAG);
- if (contentFragment == null)
- contentFragment = new DossierDetailFragment();
-
- FragmentTransaction transaction = getFragmentManager().beginTransaction();
- transaction.replace(R.id.dossier_detail_layout, contentFragment, DossierDetailFragment.FRAGMENT_TAG);
- transaction.commit();
-
- // Right menu Fragment restore
-
- MenuFragment fragmentToDisplay = (MenuFragment) getFragmentManager().findFragmentByTag(MenuFragment.FRAGMENT_TAG);
- if (fragmentToDisplay == null)
- fragmentToDisplay = new MenuFragment();
-
- // Replace whatever is in the fragment_container view with this fragment.
-
- fragmentToDisplay.setRetainInstance(true);
- if (findViewById(R.id.left_fragment) != null)
- replaceLeftFragment(fragmentToDisplay, MenuFragment.FRAGMENT_TAG, false);
-
// Selecting the first account by default, the demo one
Account selectedAccount = MyAccounts.INSTANCE.getSelectedAccount();
@Override public boolean onCreateOptionsMenu(Menu menu) {
- Toolbar actions_toolbar = (Toolbar) findViewById(R.id.actions_toolbar);
- if (actions_toolbar != null) {
+ Toolbar actionsToolbar = (Toolbar) findViewById(R.id.actions_toolbar);
+ if (actionsToolbar != null) {
- actions_toolbar.getMenu().clear();
- actions_toolbar.inflateMenu(R.menu.main_activity);
- actions_toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
+ actionsToolbar.getMenu().clear();
+ actionsToolbar.inflateMenu(R.menu.main_activity);
+ actionsToolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
@Override public boolean onMenuItemClick(MenuItem item) {
return onOptionsItemSelected(item);
}
@Override public boolean onPrepareOptionsMenu(Menu menu) {
- // Show or hide specific menu actions depending on displayed fragment
+ // Check Share button visibility
- // TODO mFiltersSpinner.setVisibility((dossierFragment == null) ? View.GONE : View.VISIBLE);
+ DossierDetailFragment fragment = (DossierDetailFragment) getFragmentManager().findFragmentByTag(DossierDetailFragment.FRAGMENT_TAG);
+ Dossier dossier = fragment.getDossier();
+ String documentId = fragment.getDocumentId();
+ Document document = Dossier.findCurrentDocument(dossier, documentId);
+ boolean isShareable = document != null;
- // Show or hide specific menu actions depending on Drawer state.
+ if (menu.findItem(R.id.menu_item_share) != null)
+ menu.findItem(R.id.menu_item_share).setVisible(isShareable);
-// if ((mLeftDrawerLayout != null) && (mLeftDrawerMenu != null)) {
-// boolean actionsVisibility = !mLeftDrawerLayout.isDrawerVisible(mLeftDrawerMenu) && (MyAccounts.INSTANCE.getSelectedAccount() != null);
-// menu.setGroupVisible(R.id.dossiers_menu_actions, actionsVisibility);
-// return super.onPrepareOptionsMenu(menu);
-// }
+ //
return false;
}
// </editor-fold desc="ActionMode">
- private void replaceLeftFragment(@NonNull Fragment fragment, @NonNull String tag, boolean animated) {
-
- // Bypass and send to the Drawer, if there isn't any left panel
-
- if (findViewById(R.id.left_fragment) == null) {
- replaceDrawerFragment(fragment, tag, animated);
- return;
- }
-
- // Replace whatever is in the fragment_container view with this fragment.
-
- FragmentTransaction transaction = getFragmentManager().beginTransaction();
-
-// int enter = animated ? R.anim.slide_in_right : 0;
-// int exit = animated ? R.anim.slide_out_right : 0;
-// transaction.setCustomAnimations(enter, exit, R.anim.slide_out_left, R.anim.slide_in_left);
- transaction.replace(R.id.left_fragment, fragment, tag);
-
- if (animated)
- transaction.addToBackStack(null);
-
- transaction.commit();
- }
-
- private void replaceDrawerFragment(@NonNull Fragment fragment, @NonNull String tag, boolean animated) {
-
- // Replace whatever is in the fragment_container view with this fragment.
-
- FragmentTransaction transaction = getFragmentManager().beginTransaction();
-
-// int enter = animated ? R.anim.slide_in_right : 0;
-// int exit = animated ? R.anim.slide_out_right : 0;
-// transaction.setCustomAnimations(enter, exit, R.anim.slide_out_left, R.anim.slide_in_left);
- transaction.replace(R.id.drawer_panel, fragment, tag);
-
- if (animated)
- transaction.addToBackStack(null);
-
- transaction.commit();
- }
-
private void importCertificate(@NonNull final String url, @Nullable final String password) {
String certificateFileName = url.substring(url.lastIndexOf('/') + 1);
// <editor-fold desc="DossierDetailsFragmentListener">
+ @Override public void onDocumentSelected(@NonNull Dossier dossier, @Nullable Document document) {
+ invalidateOptionsMenu();
+ }
+
@Override public boolean isAnyDrawerOpened() {
return (mRightDrawerLayout.isDrawerVisible(GravityCompat.END) || mLeftDrawerLayout.isDrawerVisible(GravityCompat.START));
}
+++ /dev/null
-<android.support.v4.widget.DrawerLayout android:id="@+id/activity_dossiers_drawer_layout"
- 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/primary_700"
- android:divider="@android:drawable/divider_horizontal_bright"
- android:elevation="7dp"
- android:orientation="vertical"
- tools:context=".controller.MainActivity"
- tools:ignore="UnusedAttribute">
-
- <!-- The main content view -->
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:fitsSystemWindows="true"
- android:orientation="vertical">
-
- <include layout="@layout/activity_toolbar" />
-
- <android.support.v4.widget.DrawerLayout
- android:id="@+id/activity_dossiers_right_drawer_layout"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:divider="@android:drawable/divider_horizontal_bright"
- android:orientation="vertical">
-
- <FrameLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:baselineAligned="false"
- android:orientation="vertical">
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:baselineAligned="false"
- android:orientation="horizontal">
-
- <FrameLayout
- android:id="@+id/dossier_detail_layout"
- android:layout_width="0dp"
- android:layout_height="match_parent"
- android:layout_weight="3" />
- </LinearLayout>
-
- <ProgressBar
- android:id="@+id/progressBar"
- style="?android:attr/progressBarStyleHorizontal"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:max="100"
- android:visibility="invisible" />
-
- </FrameLayout>
-
- <!-- The right drawer -->
- <!-- For some reason, you can't put it directly in the dossier_detail_fragment... -->
-
- <FrameLayout
- android:id="@+id/activity_dossiers_right_drawer"
- android:layout_width="320dp"
- android:layout_height="match_parent"
- android:layout_gravity="end">
-
- <include layout="@layout/dossiers_info" />
-
- </FrameLayout>
-
- </android.support.v4.widget.DrawerLayout>
- </LinearLayout>
-
- <!-- The navigation drawer -->
-
- <FrameLayout
- android:id="@+id/activity_dossiers_left_drawer"
- android:layout_width="320dp"
- android:layout_height="match_parent"
- android:layout_gravity="start"
- android:background="@android:color/background_light"
- android:baselineAligned="false"
- android:fitsSystemWindows="false"
- android:orientation="horizontal">
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical"
- tools:ignore="UselessParent">
-
- <include layout="@layout/activity_toolbar_header" />
-
- <FrameLayout
- android:id="@+id/left_fragment"
- android:layout_width="match_parent"
- android:layout_height="match_parent">
-
- <fragment
- android:id="@+id/activity_dossiers_bureaux_fragment"
- android:name="org.adullact.iparapheur.controller.account.AccountListFragment"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:tag="account_list_fragment"
- tools:layout="@layout/account_list_fragment" />
-
- </FrameLayout>
-
- </LinearLayout>
-
- </FrameLayout>
-
-</android.support.v4.widget.DrawerLayout>
--- /dev/null
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:baselineAligned="false"
+ android:orientation="vertical">
+
+ <FrameLayout
+ android:id="@+id/menu_layout"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
+</FrameLayout>
\ No newline at end of file
--- /dev/null
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:baselineAligned="false"
+ android:orientation="vertical">
+
+ <FrameLayout
+ android:id="@+id/dossier_detail_layout"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
+
+ <ProgressBar
+ android:id="@+id/progressBar"
+ style="?android:attr/progressBarStyleHorizontal"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:max="100"
+ android:visibility="invisible" />
+
+</FrameLayout>
\ No newline at end of file
android:divider="@android:drawable/divider_horizontal_bright"
android:orientation="vertical">
- <FrameLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:baselineAligned="false"
- android:orientation="vertical">
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:baselineAligned="false"
- android:orientation="horizontal">
-
- <FrameLayout
- android:id="@+id/left_fragment"
- android:layout_width="@dimen/left_menu_size"
- android:layout_height="match_parent"
- android:background="@android:color/background_light"
- android:elevation="2dp" />
-
- <View
- android:layout_width="1dp"
- android:layout_height="match_parent"
- android:background="@color/grey_500" />
-
- <FrameLayout
- android:id="@+id/dossier_detail_layout"
- android:layout_width="match_parent"
- android:layout_height="match_parent" />
- </LinearLayout>
-
- <ProgressBar
- android:id="@+id/progressBar"
- style="?android:attr/progressBarStyleHorizontal"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:max="100"
- android:visibility="invisible" />
-
- </FrameLayout>
+ <include layout="@layout/main_activity_main_content" />
<!-- The right drawer -->
<!-- For some reason, you can't put it directly in the dossier_detail_fragment... -->
android:id="@+id/activity_dossiers_right_drawer"
android:layout_width="320dp"
android:layout_height="match_parent"
- android:layout_gravity="end"
- android:orientation="horizontal">
+ android:layout_gravity="end">
<include layout="@layout/dossiers_info" />
<include layout="@layout/activity_toolbar_header" />
- <FrameLayout
- android:id="@+id/drawer_panel"
- android:layout_width="match_parent"
- android:layout_height="match_parent">
-
- <fragment
- android:id="@+id/activity_dossiers_bureaux_fragment"
- android:name="org.adullact.iparapheur.controller.account.AccountListFragment"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:tag="account_list_fragment"
- tools:layout="@layout/account_list_fragment" />
-
- </FrameLayout>
+ <include layout="@layout/main_activity_drawer_content" />
</LinearLayout>
</FrameLayout>
--- /dev/null
+<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:baselineAligned="false"
+ android:orientation="vertical">
+
+ <fragment
+ android:name="org.adullact.iparapheur.controller.account.AccountListFragment"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:tag="account_list_fragment"
+ tools:layout="@layout/account_list_fragment" />
+
+</FrameLayout>
\ No newline at end of file
--- /dev/null
+<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:baselineAligned="false"
+ android:orientation="vertical">
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:baselineAligned="false"
+ android:orientation="horizontal">
+
+ <FrameLayout
+ android:id="@+id/menu_layout"
+ android:layout_width="@dimen/left_menu_size"
+ android:layout_height="match_parent"
+ android:elevation="2dp"
+ tools:ignore="UnusedAttribute" />
+
+ <View
+ android:layout_width="1dp"
+ android:layout_height="match_parent"
+ android:background="@color/grey_500" />
+
+ <FrameLayout
+ android:id="@+id/dossier_detail_layout"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
+ </LinearLayout>
+
+ <ProgressBar
+ android:id="@+id/progressBar"
+ style="?android:attr/progressBarStyleHorizontal"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:max="100"
+ android:visibility="invisible" />
+</FrameLayout>
\ No newline at end of file