Skip to content

Commit

Permalink
Merge pull request #116 from proninyaroslav/master
Browse files Browse the repository at this point in the history
Print support
  • Loading branch information
konradrenner committed Mar 17, 2016
2 parents b7ebc9f + a89cc42 commit 75cb024
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 8 deletions.
1 change: 0 additions & 1 deletion app/app.iml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/release" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,19 @@
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Fragment;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.print.PrintAttributes;
import android.print.PrintDocumentAdapter;
import android.print.PrintJob;
import android.print.PrintManager;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.text.Html;
Expand Down Expand Up @@ -164,7 +170,7 @@ public void onActivityCreated(Bundle savedInstanceState) {
if(useRicheditor) {
editor = (RichEditor) activity.findViewById(R.id.detail_description);
editor.setVisibility(View.VISIBLE);
editor.setBackgroundColor(getResources().getColor(R.color.background_material_light));
editor.setBackgroundColor(Color.TRANSPARENT);
editor.setEditorHeight(300);
editor.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
Expand Down Expand Up @@ -746,11 +752,20 @@ public boolean shareNote(Intent shareIntent) {
if(!TextUtils.isEmpty(descriptionValue)) {
startActivity(Intent.createChooser(shareIntent, getResources().getText(R.string.send_to)));
}else{
Toast.makeText(activity,R.string.empty_note,Toast.LENGTH_LONG).show();
Toast.makeText(activity, R.string.empty_note, Toast.LENGTH_LONG).show();
}
return false;
}

@Override
public void onPrepareOptionsMenu(Menu menu) {
super.onPrepareOptionsMenu(menu);

if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
menu.findItem(R.id.print).setVisible(false);
}
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()){
Expand Down Expand Up @@ -778,6 +793,9 @@ public boolean onOptionsItemSelected(MenuItem item) {
shareIntent.setType("text/html");
shareNote(shareIntent);
break;
case R.id.print:
printNote();
break;
}
return true;
}
Expand Down Expand Up @@ -1327,12 +1345,19 @@ public boolean checkDifferences(){
return differences;
}

private void printNote() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
PrintManager printManager = (PrintManager) activity.getSystemService(Context.PRINT_SERVICE);
String jobName = getString(R.string.app_name) + " Document";
PrintDocumentAdapter printAdapter = editor.createPrintDocumentAdapter();
PrintJob printJob = printManager.print(jobName, printAdapter, new PrintAttributes.Builder().build());
}
}

private void goBack(){
Intent returnIntent = new Intent();
returnIntent.putExtra("selectedNotebookName",givenNotebook);

((OnFragmentCallback)activity).fragmentFinished(returnIntent, OnFragmentCallback.ResultCode.BACK);
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.support.annotation.Nullable;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
Expand All @@ -42,7 +41,6 @@
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.TextView;
import android.widget.Toast;

Expand Down Expand Up @@ -85,7 +83,6 @@
import org.kore.kolabnotes.android.setting.SettingsActivity;

import java.io.File;
import java.io.IOException;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Arrays;
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/menu/detail_toolbar.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,9 @@
app:showAsAction="always"
android:icon="@drawable/ic_action_accept"
android:title="@string/title_ok" />

<item android:id="@+id/print"
app:showAsAction="ifRoom"
android:icon="@drawable/ic_print_white_48dp"
android:title="@string/print"/>
</menu>
1 change: 1 addition & 0 deletions app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -185,4 +185,5 @@
<string name="imported">Noitizbuch importiert</string>
<string name="pref_richeditor">Richtexteditor aktivieren</string>
<string name="pref_desc_richeditor">Aktiviert den Richtexteditor zum Erstellen von formattierten Notizen</string>
<string name="print">Drucken</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -171,4 +171,5 @@
<string name="imported"> Notebook importés</string>
<string name="pref_richeditor"> Activer RichTextEditor</string>
<string name="pref_desc_richeditor"> Active le RichTextEditor pour les notes formatées</string>
<string name="print">Imprimer</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-it/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -188,4 +188,5 @@
<string name="imported">Notebook importati</string>
<string name="pref_richeditor"> Abilita RichTextEditor</string>
<string name="pref_desc_richeditor"> Attiva la RichTextEditor per le note formattati</string>
<string name="print">Stampa</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-ru/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
<string name="account_choose_title">Выберите учетную запись</string>
<string name="select_button">Выбрать</string>
<string name="extended_options" >Другие варианты</string>
<string name="print">Печать</string>

<string name="day">День</string>
<string name="hour">Час</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-vi/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -194,4 +194,5 @@
<string name="imported"> Máy tính xách tay nhập khẩu</string>
<string name="pref_richeditor"> Kích hoạt tính năng RichTextEditor</string>
<string name="pref_desc_richeditor">Cho phép các RichTextEditor cho các ghi chú được định dạng</string>
<string name="print">In</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@
<string name="title_activity_settings">Settings</string>
<string name="snackbar_delete_message">Deleted</string>
<string name="snackbar_undo_delete">Undo</string>
<string name="print">Print</string>

<string name="move_note">Move</string>

Expand Down

0 comments on commit 75cb024

Please sign in to comment.