Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,15 @@ android {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
buildConfigField "String", "DEFAULT_BASE_URL", '"https://api.eventyay.com/v1/"'
buildConfigField "String", "FRONTEND_URL", '"https://eventyay.com/"'
buildConfigField "String", "MAPBOX_KEY", '"'+MAPBOX_KEY+'"'
buildConfigField "String", "STRIPE_API_KEY", '"'+STRIPE_API_TOKEN+'"'
resValue "string", "FRONTEND_HOST", "eventyay.com"
}
debug {
buildConfigField "String", "DEFAULT_BASE_URL", '"https://open-event-api-dev.herokuapp.com/v1/"'
buildConfigField "String", "FRONTEND_URL", '"https://fossasia.github.io/open-event-frontend/"'
buildConfigField "String", "MAPBOX_KEY", '"'+MAPBOX_KEY+'"'
buildConfigField "String", "STRIPE_API_KEY", '"'+STRIPE_API_TOKEN+'"'
resValue "string", "FRONTEND_HOST", "fossasia.github.io/open-event-frontend"
resValue "string", "FRONTEND_HOST", "open-event-fe.netlify.com"
Copy link
Member

@iamareebjamal iamareebjamal Jul 1, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not buildConfigField? It's static, it's constant, requires no context

Copy link
Member Author

@liveHarshit liveHarshit Jul 1, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cannot use in the manifest file for handle app link data.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

}
}

Expand Down
5 changes: 2 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@

<data
android:scheme="https"
android:host="@string/FRONTEND_HOST"
android:pathPrefix="/e/" />
android:host="@string/FRONTEND_HOST"/>
</intent-filter>
</activity>
<provider
Expand All @@ -45,7 +44,7 @@
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_provider"/>
android:resource="@xml/file_provider" />
</provider>
<service
android:name="org.fossasia.openevent.general.order.invoice.DownloadInvoiceService"
Expand Down
12 changes: 10 additions & 2 deletions app/src/main/java/org/fossasia/openevent/general/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ import org.koin.androidx.viewmodel.ext.android.viewModel

const val PLAY_STORE_BUILD_FLAVOR = "playStore"
const val EVENT_IDENTIFIER = "eventIdentifier"
const val VERIFICATION_TOKEN = "verificationToken"
private const val VERIFY = "verify"
private const val TOKEN = "token"

class MainActivity : AppCompatActivity() {
private lateinit var navController: NavController
Expand Down Expand Up @@ -52,8 +55,13 @@ class MainActivity : AppCompatActivity() {
val appLinkData = intent?.data
if (appLinkData != null) {
val bundle = Bundle()
bundle.putString(EVENT_IDENTIFIER, appLinkData.lastPathSegment)
navController.navigate(R.id.eventDetailsFragment, bundle)
if (appLinkData.lastPathSegment == VERIFY) {
bundle.putString(VERIFICATION_TOKEN, appLinkData.getQueryParameter(TOKEN))
navController.navigate(R.id.profileFragment, bundle)
} else {
bundle.putString(EVENT_IDENTIFIER, appLinkData.lastPathSegment)
navController.navigate(R.id.eventDetailsFragment, bundle)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,8 @@ interface AuthApi {
fun checkEmail(@Body email: Email): Single<CheckEmailResponse>

@POST("auth/resend-verification-email")
fun resendVerificationEmail(@Body requestToken: RequestToken): Single<ResendVerificationEmailResponse>
fun resendVerificationEmail(@Body requestToken: RequestToken): Single<EmailVerificationResponse>

@POST("auth/verify-email")
fun verifyEmail(@Body requestEmailVerification: RequestEmailVerification): Single<EmailVerificationResponse>
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,11 @@ class AuthService(
return authApi.checkEmail(Email(email))
}

fun resendVerificationEmail(email: String): Single<ResendVerificationEmailResponse> {
fun resendVerificationEmail(email: String): Single<EmailVerificationResponse> {
return authApi.resendVerificationEmail(RequestToken(Email(email)))
}

fun verifyEmail(token: String): Single<EmailVerificationResponse> {
return authApi.verifyEmail(RequestEmailVerification(Token(token)))
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package org.fossasia.openevent.general.auth

class ResendVerificationEmailResponse(
class EmailVerificationResponse(
val message: String? = null
)
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import org.fossasia.openevent.general.CircleTransform
import org.fossasia.openevent.general.PLAY_STORE_BUILD_FLAVOR
import org.fossasia.openevent.general.R
import org.fossasia.openevent.general.BottomIconDoubleClick
import org.fossasia.openevent.general.VERIFICATION_TOKEN
import org.fossasia.openevent.general.utils.Utils
import org.fossasia.openevent.general.utils.Utils.requireDrawable
import org.fossasia.openevent.general.utils.extensions.nonNull
Expand Down Expand Up @@ -92,6 +93,10 @@ class ProfileFragment : Fragment(), BottomIconDoubleClick {
profileViewModel.syncProfile()
}

val token = arguments?.getString(VERIFICATION_TOKEN)
if (token != null)
profileViewModel.verifyProfile(token)

val progressDialog = progressDialog(context, getString(R.string.loading_message))
profileViewModel.progress
.nonNull()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,22 @@ class ProfileViewModel(private val authService: AuthService, private val resourc
}
}

fun verifyProfile(token: String) {
compositeDisposable += authService.verifyEmail(token)
.withDefaultSchedulers()
.doOnSubscribe {
mutableProgress.value = true
}.doFinally {
mutableProgress.value = false
}.subscribe({
mutableMessage.value = it.message
syncProfile()
}) {
Timber.e(it, "Error in verifying email")
mutableMessage.value = resource.getString(R.string.verification_error_message)
}
}

override fun onCleared() {
super.onCleared()
compositeDisposable.clear()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package org.fossasia.openevent.general.auth

data class RequestEmailVerification(val data: Token)
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package org.fossasia.openevent.general.auth

data class Token(val token: String)
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ package org.fossasia.openevent.general.event
import android.content.Context
import android.content.Intent
import androidx.preference.PreferenceManager
import org.fossasia.openevent.general.BuildConfig
import org.fossasia.openevent.general.OpenEventGeneral
import org.fossasia.openevent.general.R
import org.fossasia.openevent.general.data.Resource
import org.threeten.bp.ZoneId
import org.threeten.bp.ZonedDateTime
import org.threeten.bp.format.DateTimeFormatter
Expand Down Expand Up @@ -192,10 +193,12 @@ object EventUtils {
*/
fun share(event: Event, context: Context) {
val sendIntent = Intent()
val resources = Resource()
sendIntent.action = Intent.ACTION_SEND
sendIntent.type = "text/plain"
sendIntent.putExtra(Intent.EXTRA_SUBJECT, event.name)
sendIntent.putExtra(Intent.EXTRA_TEXT, "${BuildConfig.FRONTEND_URL}e/${event.identifier}")
sendIntent.putExtra(Intent.EXTRA_TEXT,
"https://${resources.getString(R.string.FRONTEND_HOST)}/e/${event.identifier}")
context.startActivity(Intent.createChooser(sendIntent, "Share Event Details"))
}

Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
<string name="profile_photo">Profile Photo</string>
<string name="verified">Verified</string>
<string name="not_verified">Account not verified. Click to verify</string>
<string name="verification_error_message">Error in verifying email</string>

<!--eventyay-->
<string name="eventyay_logo" translatable="false">eventyay</string>
Expand Down