Skip to content

Commit

Permalink
Merge pull request dkim0419#42 from andrewgaul/share-intent
Browse files Browse the repository at this point in the history
Add sharing intent
  • Loading branch information
dkim0419 authored Oct 9, 2016
2 parents 64493db + e621a19 commit cc1180c
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 1 deletion.
9 changes: 9 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="com.danielkim.soundrecorder.fileprovider"
android:grantUriPermissions="true"
android:exported="false">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/filepaths" />
</provider>
<service android:name=".RecordingService" />
</application>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Environment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentTransaction;
Expand Down Expand Up @@ -95,6 +97,7 @@ public void onClick(View view) {
public boolean onLongClick(View v) {

ArrayList<String> entrys = new ArrayList<String>();
entrys.add(mContext.getString(R.string.dialog_file_share));
entrys.add(mContext.getString(R.string.dialog_file_rename));
entrys.add(mContext.getString(R.string.dialog_file_delete));

Expand All @@ -107,8 +110,10 @@ public boolean onLongClick(View v) {
builder.setItems(items, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
if (item == 0) {
shareFileDialog(holder.getPosition());
} if (item == 1) {
renameFileDialog(holder.getPosition());
} else if (item == 1) {
} else if (item == 2) {
deleteFileDialog(holder.getPosition());
}
}
Expand Down Expand Up @@ -225,6 +230,14 @@ public void rename(int position, String name) {
}
}

public void shareFileDialog(int position) {
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(getItem(position).getFilePath())));
shareIntent.setType("audio/mp4");
mContext.startActivity(Intent.createChooser(shareIntent, mContext.getText(R.string.send_to)));
}

public void renameFileDialog (final int position) {
// File rename dialog
AlertDialog.Builder renameFileBuilder = new AlertDialog.Builder(mContext);
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@
<string name="dialog_title_delete">Löschen bestätigen...</string>
<string name="dialog_text_delete">Möchtest du diese Datei wirklich löschen?</string>
<string name="dialog_title_licenses">Open-Source-Lizenzen</string>
<string name="dialog_title_share">Datei teilen</string>
<string name="dialog_title_rename">Datei umbenennen</string>
<string name="dialog_title_options">Optionen</string>

<string name="dialog_file_share">Datei teilen</string>
<string name="dialog_file_rename">Datei umbenennen</string>
<string name="dialog_file_delete">Datei löschen</string>
<string name="dialog_action_cancel">Abbrechen</string>
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@
<string name="dialog_title_delete">Confirm Delete...</string>
<string name="dialog_text_delete">Are you sure you would like to delete this file?</string>
<string name="dialog_title_licenses">Open Source Licenses</string>
<string name="dialog_title_share">Share File</string>
<string name="dialog_title_rename">Rename File</string>
<string name="dialog_title_options">Options</string>

<string name="dialog_file_share">Share File</string>
<string name="dialog_file_rename">Rename File</string>
<string name="dialog_file_delete">Delete File</string>
<string name="dialog_action_cancel">Cancel</string>
Expand All @@ -38,4 +40,6 @@
<string name="record_prompt">Tap the button to start recording</string>
<string name="record_in_progress">Recording</string>

<string name="send_to">Send to</string>

</resources>
3 changes: 3 additions & 0 deletions app/src/main/res/xml/filepaths.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<paths>
<external-path path="SoundRecorder/" name="SoundRecorder" />
</paths>

0 comments on commit cc1180c

Please sign in to comment.