Skip to content

Commit a785099

Browse files
committed
Added #83 : Share Project Feature
1 parent 9a25823 commit a785099

10 files changed

Lines changed: 47 additions & 2 deletions

File tree

source-code/app/src/main/java/org/buildmlearn/toolkit/activity/TemplateEditor.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,13 +397,29 @@ public void onClick(View v) {
397397
new BottomSheet.Builder(this).sheet(R.menu.bottom_sheet_template).listener(new DialogInterface.OnClickListener() {
398398
@Override
399399
public void onClick(DialogInterface dialog, int id) {
400+
String savedFilePath;
400401
switch (id) {
401402
case R.id.save_project:
402403
saveProject();
403404
break;
405+
406+
case R.id.share_project:
407+
savedFilePath = saveProject();
408+
if (savedFilePath == null || savedFilePath.length() == 0) {
409+
return;
410+
}
411+
Uri fileUri = Uri.fromFile(new File(savedFilePath));
412+
ArrayList<Uri> uris = new ArrayList<Uri>();
413+
Intent sendIntent = new Intent(Intent.ACTION_SEND_MULTIPLE);
414+
sendIntent.setType("application/zip");
415+
uris.add(fileUri);
416+
sendIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
417+
startActivity(Intent.createChooser(sendIntent, null));
418+
break;
419+
404420
case R.id.share_apk:
405421

406-
String savedFilePath = saveProject();
422+
savedFilePath = saveProject();
407423
if (savedFilePath == null || savedFilePath.length() == 0) {
408424
return;
409425
}

source-code/app/src/main/java/org/buildmlearn/toolkit/fragment/LoadProjectFragment.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import android.content.Intent;
66
import android.content.res.ColorStateList;
77
import android.graphics.drawable.ColorDrawable;
8+
import android.net.Uri;
89
import android.os.Build;
910
import android.os.Bundle;
1011
import android.support.v4.content.ContextCompat;
@@ -310,6 +311,19 @@ public void onClick(View v) {
310311
});
311312
dialog.show();
312313
break;
314+
case R.id.action_share:
315+
316+
SavedProject project = savedProjects.get(mAdapter.getSelectedPosition());
317+
File file = new File(project.getFile().getPath());
318+
319+
Uri fileUri = Uri.fromFile(file);
320+
ArrayList<Uri> uris = new ArrayList<Uri>();
321+
Intent sendIntent = new Intent(Intent.ACTION_SEND_MULTIPLE);
322+
sendIntent.setType("application/zip");
323+
uris.add(fileUri);
324+
sendIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
325+
startActivity(Intent.createChooser(sendIntent, null));
326+
break;
313327
default: //do nothing
314328
break;
315329
}
1.35 KB
Loading
1.14 KB
Loading
1.44 KB
Loading
1.69 KB
Loading
1.96 KB
Loading

source-code/app/src/main/res/menu/bottom_sheet_template.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,9 @@
1919
android:icon="@drawable/share_apk"
2020
android:title="@string/bottom_sheet_share_apk" />
2121

22+
<item
23+
android:id="@+id/share_project"
24+
android:icon="@drawable/ic_group_work_black_24dp"
25+
android:title="@string/bottom_sheet_share_project" />
26+
2227
</menu>

source-code/app/src/main/res/menu/menu_project_selected.xml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,20 @@
22
xmlns:app="http://schemas.android.com/apk/res-auto"
33
xmlns:tools="http://schemas.android.com/tools"
44
tools:context="org.buildmlearn.toolkit.fragment.LoadProjectFragment">
5+
6+
<item
7+
android:id="@+id/action_share"
8+
android:icon="@drawable/ic_share_white_24dp"
9+
android:orderInCategory="1"
10+
android:title="@string/bottom_sheet_share_apk"
11+
app:showAsAction="ifRoom" />
12+
513
<item
614
android:id="@+id/action_delete"
715
android:icon="@drawable/menu_delete_template_item"
8-
android:orderInCategory="1"
16+
android:orderInCategory="2"
917
android:title="@string/menu_delete_template_item"
1018
app:showAsAction="ifRoom" />
1119

20+
1221
</menu>

source-code/app/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,5 +474,6 @@
474474
<string name="second_list_up_match">Second List Up</string>
475475
<string name="separator_match">Separator</string>
476476
<string name="second_list_down_match">Second List Down</string>
477+
<string name="bottom_sheet_share_project">Share Project</string>
477478

478479
</resources>

0 commit comments

Comments
 (0)