-
Notifications
You must be signed in to change notification settings - Fork 169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Shorten Firebase Dynamic Links #719
Closed
Closed
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
57795ea
Shorten share URLs
unstablebrainiac 7e608d2
Add SHORT param
unstablebrainiac a5276fb
Align code with project conventions
unstablebrainiac 5137f04
Make style changes to align with repository conventions
unstablebrainiac 68ef1b4
Fix indentation issues
unstablebrainiac File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
app/src/main/java/org/gdg/frisbee/android/api/FirebaseDynamicLinks.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package org.gdg.frisbee.android.api; | ||
|
||
import org.gdg.frisbee.android.api.model.FirebaseDynamicLinksRequest; | ||
import org.gdg.frisbee.android.api.model.FirebaseDynamicLinksResponse; | ||
|
||
import okhttp3.RequestBody; | ||
import retrofit2.Call; | ||
import retrofit2.http.Body; | ||
import retrofit2.http.FormUrlEncoded; | ||
import retrofit2.http.POST; | ||
import retrofit2.http.Query; | ||
|
||
public interface FirebaseDynamicLinks { | ||
|
||
@POST("/v1/shortLinks") | ||
Call<FirebaseDynamicLinksResponse> shortenUrl(@Query("key") String apiKey, @Body FirebaseDynamicLinksRequest firebaseDynamicLinksRequest); | ||
} |
30 changes: 30 additions & 0 deletions
30
app/src/main/java/org/gdg/frisbee/android/api/FirebaseDynamicLinksFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package org.gdg.frisbee.android.api; | ||
|
||
import com.google.gson.FieldNamingPolicy; | ||
|
||
import org.gdg.frisbee.android.utils.Utils; | ||
|
||
import okhttp3.OkHttpClient; | ||
import retrofit2.Retrofit; | ||
import retrofit2.converter.gson.GsonConverterFactory; | ||
|
||
public final class FirebaseDynamicLinksFactory { | ||
private static final String BASE_URL = "https://firebasedynamiclinks.googleapis.com"; | ||
|
||
private FirebaseDynamicLinksFactory() { | ||
} | ||
|
||
private static Retrofit provideRestAdapter(OkHttpClient okHttpClient) { | ||
return new Retrofit.Builder() | ||
.baseUrl(BASE_URL) | ||
.client(okHttpClient) | ||
.addConverterFactory( | ||
GsonConverterFactory.create(Utils.getGson(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES)) | ||
) | ||
.build(); | ||
} | ||
|
||
public static FirebaseDynamicLinks provideFirebaseDynamicLinksApi(OkHttpClient okHttpClient) { | ||
return provideRestAdapter(okHttpClient).create(FirebaseDynamicLinks.class); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
app/src/main/java/org/gdg/frisbee/android/api/model/FirebaseDynamicLinksRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package org.gdg.frisbee.android.api.model; | ||
|
||
public class FirebaseDynamicLinksRequest { | ||
private String longDynamicLink; | ||
private Suffix suffix; | ||
|
||
public FirebaseDynamicLinksRequest(String longDynamicLink, Suffix suffix) { | ||
this.longDynamicLink = longDynamicLink; | ||
this.suffix = suffix; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
app/src/main/java/org/gdg/frisbee/android/api/model/FirebaseDynamicLinksResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package org.gdg.frisbee.android.api.model; | ||
|
||
public class FirebaseDynamicLinksResponse { | ||
private final String shortLink; | ||
private final String previewLink; | ||
|
||
public FirebaseDynamicLinksResponse(String shortLink, String previewLink) { | ||
this.shortLink = shortLink; | ||
this.previewLink = previewLink; | ||
} | ||
|
||
public String getShortLink() { | ||
return shortLink; | ||
} | ||
|
||
public String getPreviewLink() { | ||
return previewLink; | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
app/src/main/java/org/gdg/frisbee/android/api/model/Suffix.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package org.gdg.frisbee.android.api.model; | ||
|
||
public class Suffix { | ||
private final String option = "SHORT"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's try to decouple the UI concerns and the actual link shortening.
Now the link creation is asynchronous. Ideally we should have a Listener with a possible method
onDynamicLinkReady(String url)
. Listener's method would be called with the shortened link when it is successful.Then the place where we implement this Listener can handle progress show/dismiss.
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved all the other errors but did not understand this very well.
Isn't the Retrofit callback the method that you're talking about? Do you want me to create a separate method and call it from within
onSuccess(FirebaseDynamicLinksResponse response)
? If yes, how do you propose to show theProgressDialog
before making the request?Also, is there anything similar in the codebase that'll probably give me a better idea?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately not. The app doesn't follow any architecture and async handling codes are really old. We didn't have the chance to refactor yet.
Would you be up to pair on this? We can connect via ScreenHero and do it together.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure thing. But Screenhero is not accepting new signups right now so you'll have to send me an invite. My email ID is [email protected] and I am UnstableBrainiac on Slack.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey! Sorry for the delayed response. I've been trying to get Screenhero to work on my system but couldn't. I even re-installed Windows to get it working, but in vain.
I can still contribute though. Let me know what you need me to do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't have time to check the latest version of the PR. Sorry.
Let's schedule some time and talk about it. Can also be a chat or Hangouts video call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will review once more and get back to you.