abi {
enable true
reset()
- /* include 'x86', 'x86_64', 'armeabi', 'armeabi-v7a', 'arm64-v8a', 'mips', 'mips64' */
- include 'armeabi-v7a' // OnePlus One
- include 'x86_64' // Emulateur
+ include 'x86', 'x86_64', 'armeabi', 'armeabi-v7a', 'arm64-v8a', 'mips', 'mips64'
+// include 'armeabi-v7a' // OnePlus One
+// include 'x86_64' // Emulateur
universalApk false
}
}
import org.adullact.iparapheur.model.Account;
import org.adullact.iparapheur.model.Action;
import org.adullact.iparapheur.model.Bureau;
-import org.adullact.iparapheur.model.Document;
import org.adullact.iparapheur.model.Dossier;
import org.adullact.iparapheur.utils.CollectionUtils;
import org.adullact.iparapheur.utils.FileUtils;
}
@Override public boolean onPrepareOptionsMenu(Menu menu) {
-
- // Check Share button visibility
-
- 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;
-
- if (menu.findItem(R.id.menu_item_share) != null)
- menu.findItem(R.id.menu_item_share).setVisible(isShareable);
-
- //
-
return false;
}
startActivityForResult(new Intent(this, PreferencesActivity.class), PreferencesActivity.PREFERENCES_ACTIVITY_REQUEST_CODE);
return true;
- case R.id.menu_item_share:
- startShareIntent();
- return true;
-
default:
return super.onOptionsItemSelected(item);
}
}
}
- private void startShareIntent() {
-
- DossierDetailFragment fragment = (DossierDetailFragment) getFragmentManager().findFragmentByTag(DossierDetailFragment.FRAGMENT_TAG);
- Dossier dossier = fragment.getDossier();
- String documentId = fragment.getDocumentId();
- Document document = Dossier.findCurrentDocument(dossier, documentId);
-
- // Default cases
-
- if (document == null)
- return;
-
- File documentFile = new File(document.getPath());
- if (!documentFile.exists())
- return;
-
- // Start share
-
- Intent intentShareFile = new Intent(Intent.ACTION_SEND);
- intentShareFile.setType("application/pdf");
- intentShareFile.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(documentFile));
- intentShareFile.putExtra(Intent.EXTRA_SUBJECT, String.format(getString(R.string.action_share_subject), dossier.getName()));
- // FIXME : uncomment this when Dropbox will fix its API.
- // FIXME : dropboxforum.com/hc/en-us/community/posts/203352359-Dropbox-should-respond-to-Android-Intent-ACTION-SEND
- // intentShareFile.putExtra(Intent.EXTRA_TEXT, String.format(getString(R.string.action_share_text), document.getName(), dossier.getName()));
- startActivity(Intent.createChooser(intentShareFile, getString(R.string.Choose_an_app)));
- }
-
// <editor-fold desc="AccountFragmentListener">
@Override public void onAccountSelected(@NonNull Account account) {
// <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));
}
*/
package org.adullact.iparapheur.controller.dossier;
+import android.content.Intent;
+import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.annotation.NonNull;
docSelectorSubMenu.add(Menu.NONE, R.id.action_document_selected, Menu.NONE, annexe.getName()).setIcon(R.drawable.ic_attachment_black_24dp);
}
+ // Share
+
+ MenuItem shareItem = actions_toolbar.getMenu().findItem(R.id.action_share);
+ shareItem.setVisible((mDossier != null));
+
//
super.onPrepareOptionsMenu(menu);
return true;
+ case R.id.action_share:
+ startShareIntent();
+ return true;
+
default:
return getActivity().onOptionsItemSelected(item);
}
// </editor-fold desc="MuPdfFragment">
- // <editor-fold desc="Getters / Setters">
-
- public Dossier getDossier() {
- return mDossier;
- }
-
- public String getDocumentId() {
- return mDocumentId;
- }
-
- // </editor-fold desc="Getters / Setters">
-
public void update(@Nullable Dossier dossier, @NonNull String bureauId) {
update(dossier, bureauId, null);
}
//Adrien - TODO - Error messages
final Document document = Dossier.findCurrentDocument(mDossier, mDocumentId);
- if (document == null) {
- ((DossierDetailsFragmentListener) getActivity()).onDocumentSelected(mDossier, null);
+ if (document == null)
return;
- }
File documentFile = FileUtils.getFileForDocument(getActivity(), mDossier, document);
- if (!documentFile.exists()) {
- ((DossierDetailsFragmentListener) getActivity()).onDocumentSelected(mDossier, null);
+ if (!documentFile.exists())
return;
- }
openFile(documentFile.getAbsolutePath());
boolean areAnnotationAvailable = document.isMainDocument();
if (getView() != null)
getView().findViewById(R.id.mupdffragment_main_fabbutton_annotation).setVisibility(areAnnotationAvailable ? View.VISIBLE : View.GONE);
-
- // Callback to main activity
-
- ((DossierDetailsFragmentListener) getActivity()).onDocumentSelected(mDossier, document);
}
private void updateCircuitInfoDrawerContent() {
updateReader();
}
+ private void startShareIntent() {
+
+ Document document = Dossier.findCurrentDocument(mDossier, mDocumentId);
+
+ // Default cases
+
+ if (document == null)
+ return;
+
+ File documentFile = new File(document.getPath());
+ if (!documentFile.exists())
+ return;
+
+ // Start share
+
+ Intent intentShareFile = new Intent(Intent.ACTION_SEND);
+ intentShareFile.setType("application/pdf");
+ intentShareFile.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(documentFile));
+ intentShareFile.putExtra(Intent.EXTRA_SUBJECT, String.format(getString(R.string.action_share_subject), mDossier.getName()));
+ // FIXME : uncomment this when Dropbox will fix its API.
+ // FIXME : dropboxforum.com/hc/en-us/community/posts/203352359-Dropbox-should-respond-to-Android-Intent-ACTION-SEND
+ // intentShareFile.putExtra(Intent.EXTRA_TEXT, String.format(getString(R.string.action_share_text), document.getName(), dossier.getName()));
+ startActivity(Intent.createChooser(intentShareFile, getString(R.string.Choose_an_app)));
+ }
+
/**
* Returns the main negative {@link Action} available, by coherent priority.
*/
public interface DossierDetailsFragmentListener {
- void onDocumentSelected(@NonNull Dossier dossier, @Nullable Document document);
-
boolean isAnyDrawerOpened();
void toggleInfoDrawer();
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:iparapheur="http://schemas.android.com/apk/res-auto">
+ xmlns:compat="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/action_document_selection"
android:icon="@drawable/ic_library_books_white_24dp"
android:title="@string/document_selection"
- iparapheur:showAsAction="ifRoom">
- <menu/>
+ compat:showAsAction="ifRoom">
+ <menu />
</item>
<item
android:id="@+id/action_details"
android:icon="@drawable/ic_info_white_24dp"
android:title="@string/action_details"
- iparapheur:showAsAction="ifRoom"/>
+ compat:showAsAction="ifRoom" />
+
+ <item
+ android:id="@+id/action_share"
+ android:icon="@drawable/ic_share_white_24dp"
+ android:title="@string/Share"
+ compat:showAsAction="ifRoom" />
</menu>
\ No newline at end of file
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:compat="http://schemas.android.com/apk/res-auto">
- <item
- android:id="@+id/menu_item_share"
- android:icon="@drawable/ic_share_white_24dp"
- android:title="@string/Share"
- compat:showAsAction="ifRoom" />
-
<item
android:id="@+id/action_settings"
android:title="@string/Settings"