[Pull] Feature Request: Open Repo in browser #32

Closed
opened 2020-06-03 13:46:18 +00:00 by 6543 · 9 comments
Member
Issue: https://gitea.com/mmarif/GitNex/issues/26 --- Original Pull att :https://gitea.com/gitnex/GitNex/pulls/32 Merged with: 1ec7ac4f9ff6fd6ef23bf4aded9d919f931e4add
6543 added this to the 2.0.0 milestone 2020-06-03 13:46:18 +00:00
6543 added the
🎉 Feature
Major-release
labels 2020-06-03 13:46:18 +00:00
6543 closed this issue 2020-06-03 13:46:18 +00:00
Owner

Thanks for the PR.

Adding it to the bottomsheet in repo detail is one way of dong it.

Another one which I am currently exploring(wip) is to add it to repo recyclerview with new menu which will have watchers, stars for the repo too.

But I will accept this PR as is to provide more flexibility.

Thanks for the PR. Adding it to the bottomsheet in repo detail is one way of dong it. Another one which I am currently exploring(wip) is to add it to repo recyclerview with new menu which will have watchers, stars for the repo too. But I will accept this PR as is to provide more flexibility.
Author
Member

@mmarif where can i read how bmListener contect event handler with a function?

83e3564c13 is a try but i dont get it jet ...

@mmarif where can i read how bmListener contect event handler with a function? https://gitea.com/6543/GitNex/commit/83e3564c136d4ee1e947c11951680aff3b834526 is a try but i dont get it jet ...
Owner

Thank you @6543. I will check it out.

Thank you @6543. I will check it out.
Owner

To make this PR work, here are the working updates.

You can safely remove OpenWebRepoActivity.java activity file.

Add the following in RepoDetailActivity.java activity file in onButtonClicked function.

case "openWebRepo":
                TinyDB tinyDb = new TinyDB(getApplicationContext());
                String repoFullName = tinyDb.getString("repoFullName");
                String instanceUrlWithProtocol = "https://" + tinyDb.getString("instanceUrlRaw");
                if(!tinyDb.getString("instanceUrlWithProtocol").isEmpty()) {
                    instanceUrlWithProtocol = tinyDb.getString("instanceUrlWithProtocol");
                }
                Uri url = Uri.parse(instanceUrlWithProtocol + "/" + repoFullName);
                Intent i = new Intent(Intent.ACTION_VIEW, url);
                startActivity(i);
                break;

And in LoginActivity.java file,

String instanceUrlWithProtocol;
        if(protocol.toLowerCase().equals("https")) {
            instanceUrl = "https://" + instanceHost + "/api/v1/";
            instanceUrlWithProtocol = "https://" + instanceHost;
        }
        else {
            instanceUrl = "http://" + instanceHost + "/api/v1/";
            instanceUrlWithProtocol = "http://" + instanceHost;
        }

        tinyDb.putString("instanceUrlWithProtocol", instanceUrlWithProtocol);

Do let me know if you need any help with it.

To make this PR work, here are the working updates. You can safely remove `OpenWebRepoActivity.java` activity file. Add the following in `RepoDetailActivity.java` activity file in `onButtonClicked` function. ``` case "openWebRepo": TinyDB tinyDb = new TinyDB(getApplicationContext()); String repoFullName = tinyDb.getString("repoFullName"); String instanceUrlWithProtocol = "https://" + tinyDb.getString("instanceUrlRaw"); if(!tinyDb.getString("instanceUrlWithProtocol").isEmpty()) { instanceUrlWithProtocol = tinyDb.getString("instanceUrlWithProtocol"); } Uri url = Uri.parse(instanceUrlWithProtocol + "/" + repoFullName); Intent i = new Intent(Intent.ACTION_VIEW, url); startActivity(i); break; ``` And in `LoginActivity.java` file, ``` String instanceUrlWithProtocol; if(protocol.toLowerCase().equals("https")) { instanceUrl = "https://" + instanceHost + "/api/v1/"; instanceUrlWithProtocol = "https://" + instanceHost; } else { instanceUrl = "http://" + instanceHost + "/api/v1/"; instanceUrlWithProtocol = "http://" + instanceHost; } tinyDb.putString("instanceUrlWithProtocol", instanceUrlWithProtocol); ``` Do let me know if you need any help with it.
Author
Member

i got the message twice is this a bug of gitea?

-> thanks, couldn't find the right locations where i have to change it. I'll try and push :D

i got the message twice is this a bug of gitea? -> thanks, couldn't find the right locations where i have to change it. I'll try and push :D
Owner

i got the message twice is this a bug of gitea?

gitea.com sometime has "content corruption error", that happened just now. So I refreshed the page, that's why two messages.

This will help.

https://gitea.com/mmarif/GitNex/src/branch/master/app/src/main/java/org/mian/gitnex/activities/LoginActivity.java#L196

https://gitea.com/mmarif/GitNex/src/branch/master/app/src/main/java/org/mian/gitnex/activities/RepoDetailActivity.java#L155

> i got the message twice is this a bug of gitea? gitea.com sometime has "content corruption error", that happened just now. So I refreshed the page, that's why two messages. This will help. https://gitea.com/mmarif/GitNex/src/branch/master/app/src/main/java/org/mian/gitnex/activities/LoginActivity.java#L196 https://gitea.com/mmarif/GitNex/src/branch/master/app/src/main/java/org/mian/gitnex/activities/RepoDetailActivity.java#L155
Author
Member

got time to add, test worked fine - thanks

got time to add, test worked fine - thanks
Author
Member

@mmarif now it is ready? 🚀

@mmarif now it is ready? :rocket:
Owner

@6543 yes, time to merge.

@6543 yes, time to merge.
Sign in to join this conversation.
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: gitnex/GitNex#32
No description provided.