Skip to content

Commit 7d1f08f

Browse files
committed
Updated All Intents classes.
Updated sample.
1 parent 7ca610e commit 7d1f08f

19 files changed

+309
-761
lines changed

Library/src/main/java/com/next/androidintentlibrary/EmailIntents.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,19 @@ public static EmailIntents from(@NonNull Context context)
2828
return new EmailIntents(context);
2929
}
3030

31-
public EmailIntents newEmailIntent(String[] addresses, String subject, String body, Uri attachment)
31+
// TODO: more overloads
32+
public EmailIntents newEmail(String[] addresses, String subject, String body)
3233
{
3334
intent = new Intent(Intent.ACTION_SEND);
34-
if (addresses != null) intent.putExtra(Intent.EXTRA_EMAIL, addresses);
35-
if (body != null) intent.putExtra(Intent.EXTRA_TEXT, body);
36-
if (subject != null) intent.putExtra(Intent.EXTRA_SUBJECT, subject);
37-
if (attachment != null) intent.putExtra(Intent.EXTRA_STREAM, attachment);
35+
intent.putExtra(Intent.EXTRA_EMAIL, addresses);
36+
intent.putExtra(Intent.EXTRA_TEXT, body);
37+
intent.putExtra(Intent.EXTRA_SUBJECT, subject);
38+
// intent.putExtra(Intent.EXTRA_STREAM, attachment);
3839
intent.setType(MIME_TYPE_EMAIL);
3940
return this;
4041
}
4142

42-
public EmailIntents openEmailIntent()
43+
public EmailIntents openEmail()
4344
{
4445
intent = new Intent();
4546
intent.setAction(Intent.ACTION_MAIN);
@@ -63,7 +64,7 @@ public EmailIntents sendEmail(String[] to, String subject, String text)
6364
return this;
6465
}
6566

66-
public EmailIntents composeAnEmailSend(String[] addresses, String[] cc, String[] bcc, String subject, String extraText, Uri attachment)
67+
public EmailIntents composeAnEmailSend(String[] addresses, String[] cc, String[] bcc, String subject, String extraText)
6768
{
6869
intent = new Intent(Intent.ACTION_SEND);
6970
intent.setType("*/*");

Library/src/main/java/com/next/androidintentlibrary/EventIntents.java

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@
55
import android.content.Context;
66
import android.content.Intent;
77
import android.provider.CalendarContract;
8+
89
import androidx.annotation.NonNull;
910

1011
public class EventIntents
1112
{
1213
private Context context;
1314
private Intent intent;
1415

15-
EventIntents(Context context)
16+
private EventIntents(Context context)
1617
{
1718
this.context = context;
1819
}
@@ -22,16 +23,7 @@ public static EventIntents from(@NonNull Context context)
2223
return new EventIntents(context);
2324
}
2425

25-
public EventIntents openIntent(String category)
26-
{
27-
intent = new Intent();
28-
intent.setAction(Intent.ACTION_MAIN);
29-
intent.addCategory(category);
30-
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
31-
return this;
32-
}
33-
34-
public EventIntents openEventIntent(String title, String description, String location, long begin, long end, int color, boolean allDay)
26+
public EventIntents createEvent(String title, String description, String location, long begin, long end, int color, boolean allDay)
3527
{
3628
intent = new Intent(Intent.ACTION_INSERT);
3729
intent.setData(CalendarContract.Events.CONTENT_URI);
@@ -60,16 +52,8 @@ private void startActivity(Intent intent)
6052
context.startActivity(intent);
6153
}
6254

63-
public boolean show()
55+
public void show()
6456
{
65-
Intent eventIntent = build();
66-
try
67-
{
68-
startActivity(eventIntent);
69-
} catch (ActivityNotFoundException e)
70-
{
71-
return false;
72-
}
73-
return true;
57+
startActivity(build());
7458
}
7559
}

Library/src/main/java/com/next/androidintentlibrary/FileIntents.java

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import android.content.Context;
66
import android.content.Intent;
77
import android.os.Build;
8+
89
import androidx.annotation.NonNull;
910
import androidx.annotation.RequiresApi;
1011

@@ -15,7 +16,7 @@ public class FileIntents
1516
private Context context;
1617
private Intent intent;
1718

18-
FileIntents(Context context)
19+
private FileIntents(Context context)
1920
{
2021
this.context = context;
2122
}
@@ -24,6 +25,7 @@ public static FileIntents from(@NonNull Context context)
2425
{
2526
return new FileIntents(context);
2627
}
28+
2729
public FileIntents retrievAnSpecificTypeOfFile(Boolean allowMultiple, Boolean localOnly)
2830
{
2931
intent = new Intent(Intent.ACTION_GET_CONTENT);
@@ -84,16 +86,8 @@ private void startActivity(Intent intent)
8486
context.startActivity(intent);
8587
}
8688

87-
public boolean show()
89+
public void show()
8890
{
89-
Intent fileIntent = build();
90-
try
91-
{
92-
startActivity(fileIntent);
93-
} catch (ActivityNotFoundException e)
94-
{
95-
return false;
96-
}
97-
return true;
91+
startActivity(build());
9892
}
9993
}

Library/src/main/java/com/next/androidintentlibrary/FromModules.java

Lines changed: 0 additions & 205 deletions
This file was deleted.

Library/src/main/java/com/next/androidintentlibrary/GalleryIntents.java

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@
44
import android.content.ActivityNotFoundException;
55
import android.content.Context;
66
import android.content.Intent;
7+
78
import androidx.annotation.NonNull;
89

910
public class GalleryIntents
1011
{
11-
//TODO: make an enu for all Requests
12-
public static final int REQUEST_IMAGE_GET = 7;
12+
public static final int REQUEST_IMAGE_PICK = 7;
1313
public static final int REQUEST_IMAGE_OPEN = 8;
1414
private Context context;
1515
private Intent intent;
1616

17-
GalleryIntents(Context context)
17+
private GalleryIntents(Context context)
1818
{
1919
this.context = context;
2020
}
@@ -24,7 +24,7 @@ public static GalleryIntents from(@NonNull Context context)
2424
return new GalleryIntents(context);
2525
}
2626

27-
public GalleryIntents openGalleryIntent()
27+
public GalleryIntents openGallery()
2828
{
2929
intent = new Intent();
3030
intent.setAction(Intent.ACTION_MAIN);
@@ -33,6 +33,7 @@ public GalleryIntents openGalleryIntent()
3333
return this;
3434
}
3535

36+
// TODO: should only be used with startActivityForResult
3637
public GalleryIntents pickImage()
3738
{
3839
intent = new Intent(Intent.ACTION_PICK);
@@ -54,16 +55,8 @@ private void startActivity(Intent intent)
5455
context.startActivity(intent);
5556
}
5657

57-
public boolean show()
58+
public void show()
5859
{
59-
Intent galleryIntent = build();
60-
try
61-
{
62-
startActivity(galleryIntent);
63-
} catch (ActivityNotFoundException e)
64-
{
65-
return false;
66-
}
67-
return true;
60+
startActivity(build());
6861
}
6962
}

0 commit comments

Comments
 (0)