Skip to content

Commit 6af9076

Browse files
Merge pull request #104 from Omega-R/develop
Develop
2 parents ac22143 + b0eefdc commit 6af9076

54 files changed

Lines changed: 2833 additions & 2720 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

core/build.gradle

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ android {
1010
compileSdkVersion rootProject.ext.sdkVersion
1111

1212
defaultConfig {
13-
minSdkVersion 16
13+
minSdkVersion 14
1414
targetSdkVersion rootProject.ext.sdkVersion
1515
versionCode 1
1616
versionName "1.0"
@@ -35,6 +35,9 @@ android {
3535
dependencies {
3636
implementation fileTree(dir: 'libs', include: ['*.jar'])
3737
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
38+
implementation 'com.github.Omega-R:OmegaLaunchers:1.0.2'
39+
api 'com.github.Omega-R.OmegaTypes:omegatypes:1.0.2'
40+
3841
compileOnly "androidx.appcompat:appcompat:$androidX"
3942
}
4043

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.omega_r.libs.omegaintentbuilder
2+
3+
import android.content.Context
4+
import com.omega_r.libs.omegaintentbuilder.interfaces.IntentBuilder
5+
import com.omegar.libs.omegalaunchers.BaseIntentLauncher
6+
7+
/**
8+
* Created by Anton Knyazev on 2019-08-08.
9+
*/
10+
class IntentBuilderLauncher(private val intentBuilder: IntentBuilder) : BaseIntentLauncher() {
11+
12+
override fun getIntent(context: Context) = intentBuilder.createIntent(context)
13+
14+
}

core/src/main/java/com/omega_r/libs/omegaintentbuilder/OmegaIntentBuilder.kt

Lines changed: 111 additions & 137 deletions
Original file line numberDiff line numberDiff line change
@@ -13,152 +13,126 @@ package com.omega_r.libs.omegaintentbuilder
1313

1414
import android.app.Activity
1515
import android.app.Service
16-
import android.content.Context
1716
import android.net.Uri
1817
import com.omega_r.libs.omegaintentbuilder.builders.*
19-
import com.omega_r.libs.omegaintentbuilder.builders.share.EmailIntentBuilder
20-
import com.omega_r.libs.omegaintentbuilder.builders.PlayStoreBuilder
2118
import com.omega_r.libs.omegaintentbuilder.builders.pick.PickBuilder
19+
import com.omega_r.libs.omegaintentbuilder.builders.share.EmailIntentBuilder
2220
import com.omega_r.libs.omegaintentbuilder.builders.share.ShareIntentBuilder
2321
import com.omega_r.libs.omegaintentbuilder.types.CalendarActionTypes
2422
import com.omega_r.libs.omegaintentbuilder.types.MapTypes
2523

2624
/**
2725
* OmegaIntentBuilder class for creating supports createdIntent builders.
2826
*/
29-
open class OmegaIntentBuilder(private val context: Context) {
30-
31-
companion object {
32-
@JvmStatic
33-
@Suppress("NON_FINAL_MEMBER_IN_OBJECT")
34-
open fun from(context: Context): OmegaIntentBuilder = OmegaIntentBuilder(context)
35-
}
36-
37-
/**
38-
* @param phoneNumber String for calling
39-
* @return CallIntentBuilder for creating call Intent
40-
*/
41-
@JvmOverloads
42-
fun call(phoneNumber: String = ""): CallIntentBuilder {
43-
return CallIntentBuilder(context, phoneNumber)
44-
}
45-
46-
/**
47-
* @return ShareIntentBuilder for creating share Intent
48-
*/
49-
fun share(): ShareIntentBuilder {
50-
return ShareIntentBuilder(context)
51-
}
52-
53-
/**
54-
* @return ShareIntentBuilder for creating email Intent
55-
*/
56-
fun email(): EmailIntentBuilder {
57-
return EmailIntentBuilder(context)
58-
}
59-
60-
/**
61-
* @param urlAddress String
62-
* @return BrowserBuilder for creating intent to start web browser
63-
*/
64-
fun web(urlAddress: String): BrowserBuilder {
65-
return BrowserBuilder(context, urlAddress)
66-
}
67-
68-
/**
69-
* @param uri Uri
70-
* @return BrowserBuilder for creating intent to start web browser
71-
*/
72-
fun web(uri: Uri): BrowserBuilder {
73-
return BrowserBuilder(context, uri)
74-
}
75-
76-
/**
77-
* @return SettingsIntentBuilder for creating intent to start settings
78-
*/
79-
fun settings(): SettingsIntentBuilder {
80-
return SettingsIntentBuilder(context)
81-
}
82-
83-
/**
84-
* @return PlayStoreBuilder for creating intent to open PlayStore
85-
*/
86-
fun playStore(): PlayStoreBuilder {
87-
return PlayStoreBuilder(context)
88-
}
89-
90-
/**
91-
* @param actionType CalendarActionTypes
92-
* @return CalendarIntentBuilder for method chaining
93-
*/
94-
@JvmOverloads
95-
fun calendar(actionType: CalendarActionTypes = CalendarActionTypes.VIEW_DATE): CalendarIntentBuilder {
96-
return CalendarIntentBuilder(context, actionType)
97-
}
98-
99-
/**
100-
* @param addresses Array
101-
* @return SmsIntentBuilder for method chaining
102-
*/
103-
fun sms(vararg addresses: String): SmsIntentBuilder {
104-
return SmsIntentBuilder(addresses.asList(), context)
105-
}
106-
107-
/**
108-
* @param addresses Collection
109-
* @return SmsIntentBuilder for method chaining
110-
*/
111-
fun sms(addresses: Collection<String>): SmsIntentBuilder {
112-
return SmsIntentBuilder(addresses, context)
113-
}
114-
115-
/**
116-
* @return SmsIntentBuilder for method chaining
117-
*/
118-
fun photoCapture(): PhotoCaptureBuilder {
119-
return PhotoCaptureBuilder(context)
120-
}
121-
122-
/**
123-
* @return CropImageIntentBuilder for method chaining
124-
*/
125-
fun cropImage(): CropImageIntentBuilder {
126-
return CropImageIntentBuilder(context)
127-
}
128-
129-
/**
130-
* @return ActivityIntentBuilder for creating activity intent
131-
*/
132-
fun <T: Activity> activity(activity: Class<T>): ActivityIntentBuilder<T> {
133-
return ActivityIntentBuilder(context, activity)
134-
}
135-
136-
/**
137-
* @return ServiceIntentBuilder for creating service intent
138-
*/
139-
fun <T: Service> service(service: Class<T>): ServiceIntentBuilder<T> {
140-
return ServiceIntentBuilder(context, service)
141-
}
142-
143-
/**
144-
* @return MapIntentBuilder for creating intent to open Map application
145-
*/
146-
fun map(vararg types: MapTypes): MapIntentBuilder {
147-
return MapIntentBuilder(context, *types)
148-
}
149-
150-
/**
151-
* @return PickBuilder for pick different files
152-
*/
153-
fun pick(): PickBuilder {
154-
return PickBuilder(context)
155-
}
156-
157-
/**
158-
* @return SpeechToTextBuilder
159-
*/
160-
fun speechToText(): SpeechToTextBuilder {
161-
return SpeechToTextBuilder(context)
162-
}
27+
object OmegaIntentBuilder {
28+
29+
/**
30+
* @param phoneNumber String for calling
31+
* @return CallIntentBuilder for creating call Intent
32+
*/
33+
@JvmStatic
34+
fun call(phoneNumber: String = "") = CallIntentBuilder(phoneNumber)
35+
36+
/**
37+
* @return ShareIntentBuilder for creating share Intent
38+
*/
39+
@JvmStatic
40+
fun share() = ShareIntentBuilder()
41+
42+
/**
43+
* @return ShareIntentBuilder for creating email Intent
44+
*/
45+
@JvmStatic
46+
fun email() = EmailIntentBuilder()
47+
48+
/**
49+
* @param urlAddress String
50+
* @return BrowserBuilder for creating intent to start web browser
51+
*/
52+
@JvmStatic
53+
fun web(urlAddress: String) = BrowserBuilder(urlAddress)
54+
55+
/**
56+
* @param uri Uri
57+
* @return BrowserBuilder for creating intent to start web browser
58+
*/
59+
@JvmStatic
60+
fun web(uri: Uri) = BrowserBuilder(uri)
61+
62+
/**
63+
* @return SettingsIntentBuilder for creating intent to start settings
64+
*/
65+
@JvmStatic
66+
fun settings() = SettingsIntentBuilder()
67+
68+
/**
69+
* @return PlayStoreBuilder for creating intent to open PlayStore
70+
*/
71+
@JvmStatic
72+
fun playStore() = PlayStoreBuilder()
73+
74+
/**
75+
* @param actionType CalendarActionTypes
76+
* @return CalendarIntentBuilder for method chaining
77+
*/
78+
@JvmOverloads
79+
@JvmStatic
80+
fun calendar(actionType: CalendarActionTypes = CalendarActionTypes.VIEW_DATE) = CalendarIntentBuilder(actionType)
81+
82+
/**
83+
* @param addresses Array
84+
* @return SmsIntentBuilder for method chaining
85+
*/
86+
@JvmStatic
87+
fun sms(vararg addresses: String) = SmsIntentBuilder(addresses.asList())
88+
89+
/**
90+
* @param addresses Collection
91+
* @return SmsIntentBuilder for method chaining
92+
*/
93+
@JvmStatic
94+
fun sms(addresses: Collection<String>) = SmsIntentBuilder(addresses)
95+
96+
/**
97+
* @return SmsIntentBuilder for method chaining
98+
*/
99+
@JvmStatic
100+
fun photoCapture() = PhotoCaptureBuilder()
101+
102+
/**
103+
* @return CropImageIntentBuilder for method chaining
104+
*/
105+
@JvmStatic
106+
fun cropImage() = CropImageIntentBuilder()
107+
108+
/**
109+
* @return ActivityIntentBuilder for creating activity intent
110+
*/
111+
@JvmStatic
112+
fun <T : Activity> activity(activity: Class<T>) = ActivityIntentBuilder(activity)
113+
114+
/**
115+
* @return ServiceIntentBuilder for creating service intent
116+
*/
117+
@JvmStatic
118+
fun <T : Service> service(service: Class<T>) = ServiceIntentBuilder(service)
119+
120+
/**
121+
* @return MapIntentBuilder for creating intent to open Map application
122+
*/
123+
@JvmStatic
124+
fun map(vararg types: MapTypes) = MapIntentBuilder(*types)
125+
126+
/**
127+
* @return PickBuilder for pick different files
128+
*/
129+
@JvmStatic
130+
fun pick() = PickBuilder
131+
132+
/**
133+
* @return SpeechToTextBuilder
134+
*/
135+
@JvmStatic
136+
fun speechToText() = SpeechToTextBuilder()
163137

164138
}

core/src/main/java/com/omega_r/libs/omegaintentbuilder/builders/ActivityIntentBuilder.kt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,35 +13,35 @@ package com.omega_r.libs.omegaintentbuilder.builders
1313
import android.app.Activity
1414
import android.app.Fragment
1515
import android.content.Context
16-
import com.omega_r.libs.omegaintentbuilder.interfaces.IntentHandler
1716
import com.omega_r.libs.omegaintentbuilder.handlers.ActivityIntentHandler
1817
import com.omega_r.libs.omegaintentbuilder.handlers.ContextIntentHandler
1918
import com.omega_r.libs.omegaintentbuilder.handlers.FragmentIntentHandler
2019
import com.omega_r.libs.omegaintentbuilder.handlers.SupportFragmentIntentHandler
20+
import com.omega_r.libs.omegaintentbuilder.interfaces.IntentHandler
2121

2222
class ActivityIntentBuilder<T : Activity>(
23-
private val context: Context,
2423
activity: Class<T>
25-
) : BaseIntentBuilder<ActivityIntentBuilder<T>, T>(context, activity), IntentHandler {
24+
) : BaseIntentBuilder<ActivityIntentBuilder<T>, T>(activity), IntentHandler {
2625

27-
override fun createIntentHandler(): ContextIntentHandler {
28-
return ContextIntentHandler(context, createIntent())
26+
override fun createIntentHandler(context: Context): ContextIntentHandler {
27+
return ContextIntentHandler(context, createIntent(context))
2928
}
3029

3130
override fun createIntentHandler(activity: Activity): ActivityIntentHandler {
32-
return ActivityIntentHandler(activity, createIntent())
31+
return ActivityIntentHandler(activity, createIntent(activity))
3332
}
3433

3534
override fun createIntentHandler(fragment: Fragment): FragmentIntentHandler {
36-
return FragmentIntentHandler(fragment, createIntent())
35+
return FragmentIntentHandler(fragment, createIntent(fragment.activity))
3736
}
3837

3938
override fun createIntentHandler(fragment: androidx.fragment.app.Fragment): SupportFragmentIntentHandler {
40-
return SupportFragmentIntentHandler(fragment, createIntent())
39+
return SupportFragmentIntentHandler(fragment, createIntent(fragment.activity!!))
4140
}
4241

43-
override fun startActivity() {
44-
createIntentHandler().startActivity()
42+
override fun startActivity(context: Context) {
43+
createIntentHandler(context)
44+
.startActivity()
4545
}
4646

4747
}

core/src/main/java/com/omega_r/libs/omegaintentbuilder/builders/BaseActivityBuilder.kt

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,32 +13,33 @@ package com.omega_r.libs.omegaintentbuilder.builders
1313
import android.app.Activity
1414
import android.app.Fragment
1515
import android.content.Context
16-
import com.omega_r.libs.omegaintentbuilder.interfaces.IntentHandler
1716
import com.omega_r.libs.omegaintentbuilder.handlers.ActivityIntentHandler
1817
import com.omega_r.libs.omegaintentbuilder.handlers.ContextIntentHandler
1918
import com.omega_r.libs.omegaintentbuilder.handlers.FragmentIntentHandler
2019
import com.omega_r.libs.omegaintentbuilder.handlers.SupportFragmentIntentHandler
20+
import com.omega_r.libs.omegaintentbuilder.interfaces.IntentHandler
2121

22-
abstract class BaseActivityBuilder(private val context: Context): IntentHandler {
22+
abstract class BaseActivityBuilder : IntentHandler {
2323

24-
override fun createIntentHandler(): ContextIntentHandler {
25-
return ContextIntentHandler(context, createIntent())
26-
}
24+
override fun createIntentHandler(context: Context): ContextIntentHandler {
25+
return ContextIntentHandler(context, createIntent(context))
26+
}
2727

28-
override fun createIntentHandler(activity: Activity): ActivityIntentHandler {
29-
return ActivityIntentHandler(activity, createIntent())
30-
}
28+
override fun createIntentHandler(activity: Activity): ActivityIntentHandler {
29+
return ActivityIntentHandler(activity, createIntent(activity))
30+
}
3131

32-
override fun createIntentHandler(fragment: Fragment): FragmentIntentHandler {
33-
return FragmentIntentHandler(fragment, createIntent())
34-
}
32+
override fun createIntentHandler(fragment: Fragment): FragmentIntentHandler {
33+
return FragmentIntentHandler(fragment, createIntent(fragment.activity!!))
34+
}
3535

36-
override fun createIntentHandler(fragment: androidx.fragment.app.Fragment): SupportFragmentIntentHandler {
37-
return SupportFragmentIntentHandler(fragment, createIntent())
38-
}
36+
override fun createIntentHandler(fragment: androidx.fragment.app.Fragment): SupportFragmentIntentHandler {
37+
return SupportFragmentIntentHandler(fragment, createIntent(fragment.activity!!))
38+
}
3939

40-
override fun startActivity() {
41-
createIntentHandler().startActivity()
42-
}
40+
override fun startActivity(context: Context) {
41+
createIntentHandler(context)
42+
.startActivity()
43+
}
4344

4445
}

0 commit comments

Comments
 (0)