From 83c36e38d06a874ae4eb71e7981a87ba07b5a324 Mon Sep 17 00:00:00 2001 From: tibbi Date: Tue, 28 Jun 2016 21:50:53 +0200 Subject: [PATCH] allow sharing the note --- .../com/simplemobiletools/notes/Utils.java | 10 ++++++++ .../notes/activities/MainActivity.java | 22 ++++++++++++++++++ app/src/main/res/menu/menu.xml | 5 ++++ app/src/main/res/mipmap-hdpi/share.png | Bin 0 -> 397 bytes app/src/main/res/mipmap-mdpi/share.png | Bin 0 -> 268 bytes app/src/main/res/mipmap-xhdpi/share.png | Bin 0 -> 496 bytes app/src/main/res/mipmap-xxhdpi/share.png | Bin 0 -> 698 bytes app/src/main/res/mipmap-xxxhdpi/share.png | Bin 0 -> 938 bytes app/src/main/res/values/strings.xml | 4 ++++ 9 files changed, 41 insertions(+) create mode 100644 app/src/main/java/com/simplemobiletools/notes/Utils.java create mode 100644 app/src/main/res/mipmap-hdpi/share.png create mode 100644 app/src/main/res/mipmap-mdpi/share.png create mode 100644 app/src/main/res/mipmap-xhdpi/share.png create mode 100644 app/src/main/res/mipmap-xxhdpi/share.png create mode 100644 app/src/main/res/mipmap-xxxhdpi/share.png diff --git a/app/src/main/java/com/simplemobiletools/notes/Utils.java b/app/src/main/java/com/simplemobiletools/notes/Utils.java new file mode 100644 index 00000000..f855f864 --- /dev/null +++ b/app/src/main/java/com/simplemobiletools/notes/Utils.java @@ -0,0 +1,10 @@ +package com.simplemobiletools.notes; + +import android.content.Context; +import android.widget.Toast; + +public class Utils { + public static void showToast(Context context, int resId) { + Toast.makeText(context, context.getResources().getString(resId), Toast.LENGTH_SHORT).show(); + } +} diff --git a/app/src/main/java/com/simplemobiletools/notes/activities/MainActivity.java b/app/src/main/java/com/simplemobiletools/notes/activities/MainActivity.java index c158d425..3727e954 100644 --- a/app/src/main/java/com/simplemobiletools/notes/activities/MainActivity.java +++ b/app/src/main/java/com/simplemobiletools/notes/activities/MainActivity.java @@ -5,6 +5,7 @@ import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; +import android.content.res.Resources; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.view.Menu; @@ -16,6 +17,7 @@ import android.widget.Toast; import com.simplemobiletools.notes.Constants; import com.simplemobiletools.notes.MyWidgetProvider; import com.simplemobiletools.notes.R; +import com.simplemobiletools.notes.Utils; import butterknife.BindView; import butterknife.ButterKnife; @@ -48,6 +50,9 @@ public class MainActivity extends AppCompatActivity { case R.id.save: saveText(); return true; + case R.id.share: + shareText(); + return true; case R.id.about: final Intent intent = new Intent(getApplicationContext(), AboutActivity.class); startActivity(intent); @@ -66,6 +71,23 @@ public class MainActivity extends AppCompatActivity { updateWidget(); } + private void shareText() { + final String text = mNotesView.getText().toString().trim(); + if (text.isEmpty()) { + Utils.showToast(this, R.string.cannot_share_empty_text); + return; + } + + final Resources res = getResources(); + final String shareTitle = res.getString(R.string.share_via); + final Intent sendIntent = new Intent(); + sendIntent.setAction(Intent.ACTION_SEND); + sendIntent.putExtra(Intent.EXTRA_SUBJECT, res.getString(R.string.simple_note)); + sendIntent.putExtra(Intent.EXTRA_TEXT, text); + sendIntent.setType("text/plain"); + startActivity(Intent.createChooser(sendIntent, shareTitle)); + } + private void hideKeyboard() { final InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(mNotesView.getWindowToken(), 0); diff --git a/app/src/main/res/menu/menu.xml b/app/src/main/res/menu/menu.xml index af94845f..0051c511 100644 --- a/app/src/main/res/menu/menu.xml +++ b/app/src/main/res/menu/menu.xml @@ -6,6 +6,11 @@ android:icon="@mipmap/save" android:title="@string/save" app:showAsAction="ifRoom"/> + >pxai;{B2*!N!D>LzNpR^R2)fik{R2|aH0bP5 z*MdarD7a}-Ez;H;8^R0acFB7?>Nyer70h^N-MY7?BcJR3C~UbFc^uKRQ`h0hp&@lM za=0&bFUnK#Sn5WUrS5~&57j8c2`}{x^lU0@xf-K$z+Gzw`kpzeuI-nfmQ2OyT(N5C zy>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=U>kWUFR#U6!^Dg|IO$GL;Q zdG;$z?BZ=E`Hcb|x0vJv&02@&xrVwOhY7LL@4M9>gD@+_--REpnJm3KuU?nF43nuCUR}5|x-@k1XJG+|9FJHqb%=H!GZ? zR#tEVHz}HB3FEjJmo=nuF(+%t;UXt%$l)REk1CR+@t5HZYGfZVddcE%mgiK277p?u!wk{S zAzEYsZHy7*0=xAuo@I(+(gP_7Qy#3Simple Notes Thank you for using Simple Notes.\nFor more simple apps please visit SimpleMobileTools.com.\n Save + Share + Share via + Cannot share empty text Text Saved + Simple Note About