mirror of
https://github.com/SimpleMobileTools/Simple-Notes.git
synced 2025-04-05 11:11:05 +02:00
allow sharing the note
This commit is contained in:
parent
62a05894ce
commit
83c36e38d0
10
app/src/main/java/com/simplemobiletools/notes/Utils.java
Normal file
10
app/src/main/java/com/simplemobiletools/notes/Utils.java
Normal file
@ -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();
|
||||
}
|
||||
}
|
@ -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);
|
||||
|
@ -6,6 +6,11 @@
|
||||
android:icon="@mipmap/save"
|
||||
android:title="@string/save"
|
||||
app:showAsAction="ifRoom"/>
|
||||
<item
|
||||
android:id="@+id/share"
|
||||
android:icon="@mipmap/share"
|
||||
android:title="@string/share"
|
||||
app:showAsAction="ifRoom"/>
|
||||
<item
|
||||
android:id="@+id/about"
|
||||
android:title="@string/about"
|
||||
|
BIN
app/src/main/res/mipmap-hdpi/share.png
Normal file
BIN
app/src/main/res/mipmap-hdpi/share.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 397 B |
BIN
app/src/main/res/mipmap-mdpi/share.png
Normal file
BIN
app/src/main/res/mipmap-mdpi/share.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 268 B |
BIN
app/src/main/res/mipmap-xhdpi/share.png
Normal file
BIN
app/src/main/res/mipmap-xhdpi/share.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 496 B |
BIN
app/src/main/res/mipmap-xxhdpi/share.png
Normal file
BIN
app/src/main/res/mipmap-xxhdpi/share.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 698 B |
BIN
app/src/main/res/mipmap-xxxhdpi/share.png
Normal file
BIN
app/src/main/res/mipmap-xxxhdpi/share.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 938 B |
@ -2,7 +2,11 @@
|
||||
<string name="app_name">Simple Notes</string>
|
||||
<string name="widget_config">Thank you for using Simple Notes.\nFor more simple apps please visit SimpleMobileTools.com.\n</string>
|
||||
<string name="save">Save</string>
|
||||
<string name="share">Share</string>
|
||||
<string name="share_via">Share via</string>
|
||||
<string name="cannot_share_empty_text">Cannot share empty text</string>
|
||||
<string name="text_saved">Text Saved</string>
|
||||
<string name="simple_note">Simple Note</string>
|
||||
|
||||
<!-- About -->
|
||||
<string name="about">About</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user