#55: Android: Export PDF dialog

This commit is contained in:
jendib 2016-01-14 00:19:31 +01:00
parent 0f4e5a8f6d
commit b9a4f0f1e0
8 changed files with 112 additions and 1 deletions

View File

@ -44,6 +44,7 @@ import com.sismics.docs.event.DocumentEditEvent;
import com.sismics.docs.event.DocumentFullscreenEvent; import com.sismics.docs.event.DocumentFullscreenEvent;
import com.sismics.docs.event.FileAddEvent; import com.sismics.docs.event.FileAddEvent;
import com.sismics.docs.event.FileDeleteEvent; import com.sismics.docs.event.FileDeleteEvent;
import com.sismics.docs.fragment.DocExportPdfFragment;
import com.sismics.docs.fragment.DocShareFragment; import com.sismics.docs.fragment.DocShareFragment;
import com.sismics.docs.listener.JsonHttpResponseHandler; import com.sismics.docs.listener.JsonHttpResponseHandler;
import com.sismics.docs.model.application.ApplicationContext; import com.sismics.docs.model.application.ApplicationContext;
@ -244,6 +245,16 @@ public class DocumentViewActivity extends AppCompatActivity {
} }
}); });
// Action export PDF
button = (Button) findViewById(R.id.actionExportPdf);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
DialogFragment dialog = DocExportPdfFragment.newInstance(DocumentViewActivity.this.document.optString("id"));
dialog.show(getSupportFragmentManager(), "DocExportPdfFragment");
}
});
// Action share // Action share
button = (Button) findViewById(R.id.actionSharing); button = (Button) findViewById(R.id.actionSharing);
button.setOnClickListener(new View.OnClickListener() { button.setOnClickListener(new View.OnClickListener() {

View File

@ -0,0 +1,56 @@
package com.sismics.docs.fragment;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.DialogFragment;
import android.view.LayoutInflater;
import android.view.View;
import com.sismics.docs.R;
/**
* Export PDF dialog fragment.
*
* @author bgamard.
*/
public class DocExportPdfFragment extends DialogFragment {
/**
* Export PDF dialog fragment.
*
* @param id Document ID
*/
public static DocExportPdfFragment newInstance(String id) {
DocExportPdfFragment fragment = new DocExportPdfFragment();
Bundle args = new Bundle();
args.putString("id", id);
fragment.setArguments(args);
return fragment;
}
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
// Setup the view
LayoutInflater inflater = getActivity().getLayoutInflater();
View view = inflater.inflate(R.layout.document_export_pdf_dialog, null);
// Build the dialog
builder.setView(view)
.setPositiveButton(R.string.download, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
getDialog().cancel();
}
})
.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
getDialog().cancel();
}
});
return builder.create();
}
}

View File

@ -44,7 +44,8 @@ public class DocShareFragment extends DialogFragment {
private JSONObject document; private JSONObject document;
/** /**
* Document sharing dialog fragment * Document sharing dialog fragment.
*
* @param id Document ID * @param id Document ID
*/ */
public static DocShareFragment newInstance(String id) { public static DocShareFragment newInstance(String id) {

Binary file not shown.

After

Width:  |  Height:  |  Size: 353 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 461 B

View File

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="12dp">
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Export metadata"
android:id="@+id/checkBox" />
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Export comments"
android:id="@+id/checkBox2" />
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Fit image to page"
android:id="@+id/checkBox3" />
<SeekBar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/seekBar" />
</LinearLayout>

View File

@ -207,6 +207,17 @@
android:orientation="horizontal" android:orientation="horizontal"
style="?android:buttonBarStyle"> style="?android:buttonBarStyle">
<Button
android:id="@+id/actionExportPdf"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableTop="@drawable/ic_description_grey600_24dp"
style="?android:buttonBarButtonStyle"
android:text="@string/export_pdf"
android:textColor="@color/button_material_dark"
android:textAllCaps="false"
android:layout_margin="8dp"/>
<Button <Button
android:id="@+id/actionSharing" android:id="@+id/actionSharing"
android:layout_width="wrap_content" android:layout_width="wrap_content"

View File

@ -117,6 +117,8 @@
<string name="comment_delete">Delete comment</string> <string name="comment_delete">Delete comment</string>
<string name="deleting_comment">Deleting comment</string> <string name="deleting_comment">Deleting comment</string>
<string name="error_deleting_comment">Error deleting comment</string> <string name="error_deleting_comment">Error deleting comment</string>
<string name="export_pdf">Export PDF</string>
<string name="download">Download</string>
</resources> </resources>