Skip to content

Commit a0e8c23

Browse files
committed
open project in browser
1 parent e7e97d8 commit a0e8c23

5 files changed

Lines changed: 61 additions & 3 deletions

File tree

app/src/main/java/com/koshsu/githubsearch/ui/details/DetailsFragment.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.koshsu.githubsearch.ui.details
22

3+
import android.content.Intent
4+
import android.net.Uri
35
import android.os.Bundle
46
import android.view.LayoutInflater
57
import android.view.View
@@ -17,6 +19,7 @@ import com.koshsu.githubsearch.ui.interfaces.IProgressBarFragment
1719
import com.koshsu.githubsearch.ui.interfaces.IProgressBarActivity
1820
import com.koshsu.githubsearch.ui.interfaces.ISearchListenerActivity
1921
import com.koshsu.githubsearch.utils.toastS
22+
import kotlinx.android.synthetic.main.fragment_details.*
2023
import org.kodein.di.KodeinAware
2124
import org.kodein.di.android.x.kodein
2225
import org.kodein.di.generic.instance
@@ -79,6 +82,7 @@ class DetailsFragment : Fragment(), KodeinAware,
7982
binding.repo = status.data
8083
viewModel.isWatchersVisible.value = status.data.watchers != null
8184
hideProgressBar()
85+
bindProjectLink(status.data.htmlUrl)
8286
}
8387
is Status.Error -> {
8488
requireContext().toastS(status.errorMessage)
@@ -97,4 +101,12 @@ class DetailsFragment : Fragment(), KodeinAware,
97101
(requireActivity() as ISearchListenerActivity).showSearchView(false)
98102
}
99103

104+
private fun bindProjectLink(url: String) {
105+
project_link_container.setOnClickListener {
106+
val defaultBrowser = Intent.makeMainSelectorActivity(Intent.ACTION_MAIN, Intent.CATEGORY_APP_BROWSER)
107+
defaultBrowser.data = Uri.parse(url)
108+
startActivity(defaultBrowser)
109+
}
110+
}
111+
100112
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="24dp"
3+
android:height="24dp"
4+
android:viewportWidth="24"
5+
android:viewportHeight="24">
6+
<path
7+
android:fillColor="#FF000000"
8+
android:pathData="M12,0c-6.626,0 -12,5.373 -12,12 0,5.302 3.438,9.8 8.207,11.387 0.599,0.111 0.793,-0.261 0.793,-0.577v-2.234c-3.338,0.726 -4.033,-1.416 -4.033,-1.416 -0.546,-1.387 -1.333,-1.756 -1.333,-1.756 -1.089,-0.745 0.083,-0.729 0.083,-0.729 1.205,0.084 1.839,1.237 1.839,1.237 1.07,1.834 2.807,1.304 3.492,0.997 0.107,-0.775 0.418,-1.305 0.762,-1.604 -2.665,-0.305 -5.467,-1.334 -5.467,-5.931 0,-1.311 0.469,-2.381 1.236,-3.221 -0.124,-0.303 -0.535,-1.524 0.117,-3.176 0,0 1.008,-0.322 3.301,1.23 0.957,-0.266 1.983,-0.399 3.003,-0.404 1.02,0.005 2.047,0.138 3.006,0.404 2.291,-1.552 3.297,-1.23 3.297,-1.23 0.653,1.653 0.242,2.874 0.118,3.176 0.77,0.84 1.235,1.911 1.235,3.221 0,4.609 -2.807,5.624 -5.479,5.921 0.43,0.372 0.823,1.102 0.823,2.222v3.293c0,0.319 0.192,0.694 0.801,0.576 4.765,-1.589 8.199,-6.086 8.199,-11.386 0,-6.627 -5.373,-12 -12,-12z"/>
9+
</vector>

app/src/main/res/layout/fragment_details.xml

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@
6767
android:layout_marginEnd="2dp"
6868
android:src="@drawable/ic_watcher"
6969
android:visibility="@{vm.isWatchersVisible() ? view.VISIBLE : view.GONE}" />
70-
<!-- android:visibility="@{repo.watchers == 0 ? view.GONE : view.VISIBLE}" />-->
7170

7271
<TextView
7372
android:id="@+id/watchers"
@@ -126,7 +125,44 @@
126125
app:layout_constraintEnd_toEndOf="parent"
127126
app:layout_constraintStart_toStartOf="parent"
128127
app:layout_constraintTop_toBottomOf="@id/title"
129-
tools:text="@tools:sample/lorem/random" />
128+
tools:text="@tools:sample/lorem" />
129+
130+
<androidx.cardview.widget.CardView
131+
android:id="@+id/project_link_container"
132+
app:layout_constraintTop_toBottomOf="@id/description"
133+
app:layout_constraintStart_toStartOf="parent"
134+
app:layout_constraintEnd_toEndOf="parent"
135+
android:layout_marginTop="@dimen/default_margin"
136+
style="@style/Card.Clickable.Button"
137+
android:layout_width="wrap_content"
138+
android:layout_height="wrap_content">
139+
140+
<LinearLayout
141+
android:layout_width="wrap_content"
142+
android:layout_height="wrap_content"
143+
android:gravity="center_vertical"
144+
android:orientation="horizontal"
145+
android:paddingStart="16dp"
146+
android:paddingTop="8dp"
147+
android:paddingEnd="16dp"
148+
android:paddingBottom="8dp">
149+
150+
<ImageView
151+
android:layout_width="wrap_content"
152+
android:layout_height="wrap_content"
153+
android:layout_marginEnd="8dp"
154+
android:src="@drawable/ic_github"
155+
app:tint="@color/colorTextPrimary" />
156+
157+
<TextView
158+
android:id="@+id/project_link_tv"
159+
style="@style/TextView.Secondary"
160+
android:layout_marginBottom="2dp"
161+
android:text="@string/project_link" />
162+
163+
</LinearLayout>
164+
165+
</androidx.cardview.widget.CardView>
130166

131167

132168
</androidx.constraintlayout.widget.ConstraintLayout>

app/src/main/res/layout/fragment_home.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
android:layout_height="match_parent"
77
tools:context=".ui.home.HomeFragment">
88

9-
<!-- android:layout_marginBottom="?android:attr/actionBarSize"-->
109
<TextView
1110
android:id="@+id/message_welcome"
1211
style="@style/TextView.Secondary.Header.Bold"

app/src/main/res/values/strings.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,6 @@
99

1010
<string name="search_query_hint">Enter repository name</string>
1111

12+
<string name="project_link">Open project in browser</string>
13+
1214
</resources>

0 commit comments

Comments
 (0)