mirror of
https://github.com/YTVanced/VancedManager
synced 2024-11-22 03:05:11 +00:00
Added working buttons and changed home fragment to RelativeLayout
This commit is contained in:
parent
5b0582a8d6
commit
ecb94aac0e
13 changed files with 198 additions and 98 deletions
|
@ -1,11 +1,22 @@
|
|||
package com.vanced.manager
|
||||
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import androidx.fragment.app.Fragment
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.Button
|
||||
import androidx.browser.customtabs.CustomTabsClient
|
||||
import androidx.browser.customtabs.CustomTabsIntent
|
||||
import androidx.browser.customtabs.CustomTabsCallback
|
||||
import androidx.browser.customtabs.CustomTabsService
|
||||
import androidx.browser.customtabs.CustomTabColorSchemeParams
|
||||
import android.widget.TextView
|
||||
import androidx.core.content.ContextCompat
|
||||
import kotlinx.android.synthetic.*
|
||||
import kotlinx.android.synthetic.main.fragment_home.*
|
||||
import kotlinx.coroutines.flow.DEFAULT_CONCURRENCY
|
||||
|
||||
/**
|
||||
* A simple [Fragment] subclass.
|
||||
|
@ -17,7 +28,27 @@ class HomeFragment : Fragment() {
|
|||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
return inflater.inflate(R.layout.fragment_home, container, false)
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
val braveurl = "https://brave.com/van874"
|
||||
val vancedurl = "vanced.app"
|
||||
val builder = CustomTabsIntent.Builder()
|
||||
val brave = getView()?.findViewById(R.id.button) as Button
|
||||
val website = getView()?.findViewById(R.id.button2) as Button
|
||||
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
brave.setOnClickListener{
|
||||
builder.setToolbarColor(ContextCompat.getColor(requireContext(), R.color.Vanced))
|
||||
val customTabsIntent = builder.build()
|
||||
customTabsIntent.launchUrl(requireContext(), Uri.parse(braveurl))
|
||||
}
|
||||
website.setOnClickListener{
|
||||
builder.setToolbarColor(ContextCompat.getColor(requireContext(), R.color.Brave))
|
||||
val customTabsIntent = builder.build()
|
||||
customTabsIntent.launchUrl(requireContext(), Uri.parse(vancedurl))
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,14 +3,13 @@ package com.vanced.manager
|
|||
import android.os.Bundle
|
||||
import com.google.android.material.bottomnavigation.BottomNavigationView
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.appcompat.widget.Toolbar
|
||||
import androidx.fragment.app.FragmentTransaction
|
||||
import androidx.navigation.findNavController
|
||||
import androidx.navigation.ui.AppBarConfiguration
|
||||
import androidx.navigation.ui.setupActionBarWithNavController
|
||||
|
||||
class MainActivity : AppCompatActivity() {
|
||||
|
||||
lateinit var homeFragment: HomeFragment
|
||||
lateinit var settingsFragment: SettingsFragment
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
@ -24,6 +23,8 @@ class MainActivity : AppCompatActivity() {
|
|||
.replace(R.id.frame_layout, homeFragment)
|
||||
.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
|
||||
.commit()
|
||||
val toolbar = findViewById(R.id.home_toolbar) as Toolbar?
|
||||
setSupportActionBar(toolbar)
|
||||
|
||||
navView.setOnNavigationItemSelectedListener { item ->
|
||||
|
||||
|
@ -37,6 +38,7 @@ class MainActivity : AppCompatActivity() {
|
|||
.replace(R.id.frame_layout, homeFragment)
|
||||
.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
|
||||
.commit()
|
||||
setSupportActionBar(toolbar)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
59
app/src/main/java/com/vanced/manager/SettingsFragment.kt
Normal file
59
app/src/main/java/com/vanced/manager/SettingsFragment.kt
Normal file
|
@ -0,0 +1,59 @@
|
|||
package com.vanced.manager
|
||||
|
||||
import android.os.Bundle
|
||||
import androidx.fragment.app.Fragment
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
|
||||
// TODO: Rename parameter arguments, choose names that match
|
||||
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
|
||||
private const val ARG_PARAM1 = "param1"
|
||||
private const val ARG_PARAM2 = "param2"
|
||||
|
||||
/**
|
||||
* A simple [Fragment] subclass.
|
||||
* Use the [SettingsFragment.newInstance] factory method to
|
||||
* create an instance of this fragment.
|
||||
*/
|
||||
class SettingsFragment : Fragment() {
|
||||
// TODO: Rename and change types of parameters
|
||||
private var param1: String? = null
|
||||
private var param2: String? = null
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
arguments?.let {
|
||||
param1 = it.getString(ARG_PARAM1)
|
||||
param2 = it.getString(ARG_PARAM2)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
// Inflate the layout for this fragment
|
||||
return inflater.inflate(R.layout.fragment_settings, container, false)
|
||||
}
|
||||
|
||||
companion object {
|
||||
/**
|
||||
* Use this factory method to create a new instance of
|
||||
* this fragment using the provided parameters.
|
||||
*
|
||||
* @param param1 Parameter 1.
|
||||
* @param param2 Parameter 2.
|
||||
* @return A new instance of fragment SettingsFragment.
|
||||
*/
|
||||
// TODO: Rename and change types and number of parameters
|
||||
@JvmStatic
|
||||
fun newInstance(param1: String, param2: String) =
|
||||
SettingsFragment().apply {
|
||||
arguments = Bundle().apply {
|
||||
putString(ARG_PARAM1, param1)
|
||||
putString(ARG_PARAM2, param2)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -22,10 +22,6 @@ class HomeFragment : Fragment() {
|
|||
homeViewModel =
|
||||
ViewModelProviders.of(this).get(HomeViewModel::class.java)
|
||||
val root = inflater.inflate(R.layout.fragment_home, container, false)
|
||||
val textView: TextView = root.findViewById(R.id.Home)
|
||||
homeViewModel.text.observe(viewLifecycleOwner, Observer {
|
||||
textView.text = it
|
||||
})
|
||||
return root
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
package com.vanced.manager.ui.dashboard
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.TextView
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.lifecycle.Observer
|
||||
import androidx.lifecycle.ViewModelProviders
|
||||
import com.vanced.manager.R
|
||||
|
||||
class DashboardFragment : Fragment() {
|
||||
|
||||
private lateinit var dashboardViewModel: DashboardViewModel
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
dashboardViewModel =
|
||||
ViewModelProviders.of(this).get(DashboardViewModel::class.java)
|
||||
val root = inflater.inflate(R.layout.fragment_dashboard, container, false)
|
||||
val textView: TextView = root.findViewById(R.id.text_dashboard)
|
||||
dashboardViewModel.text.observe(viewLifecycleOwner, Observer {
|
||||
textView.text = it
|
||||
})
|
||||
return root
|
||||
}
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
package com.vanced.manager.ui.dashboard
|
||||
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
|
||||
class DashboardViewModel : ViewModel() {
|
||||
|
||||
private val _text = MutableLiveData<String>().apply {
|
||||
value = "This is dashboard Fragment"
|
||||
}
|
||||
val text: LiveData<String> = _text
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
|
@ -13,18 +13,18 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="63dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_marginBottom="0dp"
|
||||
android:background="?android:attr/windowBackground"
|
||||
app:menu="@menu/bottom_nav_menu"
|
||||
/>
|
||||
app:layout_constraintBottom_toBottomOf="@+id/frame_layout"
|
||||
app:menu="@menu/bottom_nav_menu" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/frame_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_height="760dp"
|
||||
android:layout_above="@id/bottom_nav"
|
||||
android:background="@color/white">
|
||||
android:background="@color/white"
|
||||
app:layout_constraintBottom_toBottomOf="parent">
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
</RelativeLayout>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -1,42 +1,21 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<RelativeLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".ui.home.HomeFragment">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="0dp"
|
||||
android:layout_marginBottom="620dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_bias="0.0"
|
||||
app:srcCompat="@drawable/rectangle_2" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/Home"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="@font/exo_bold"
|
||||
android:text="@string/home"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="24sp"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/imageView"
|
||||
app:layout_constraintEnd_toEndOf="@+id/imageView"
|
||||
app:layout_constraintHorizontal_bias="0.034"
|
||||
app:layout_constraintStart_toStartOf="@+id/imageView"
|
||||
app:layout_constraintTop_toTopOf="@+id/imageView"
|
||||
app:layout_constraintVertical_bias="0.45" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageView2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignBottom="@+id/imageView3"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_marginEnd="13dp"
|
||||
android:layout_marginBottom="168dp"
|
||||
android:foregroundGravity="center_vertical"
|
||||
app:srcCompat="@drawable/rectangle_3"
|
||||
tools:layout_editor_absoluteX="14dp"
|
||||
tools:layout_editor_absoluteY="67dp" />
|
||||
|
@ -45,16 +24,31 @@
|
|||
android:id="@+id/imageView3"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="14dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_above="@+id/imageView5"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="210dp"
|
||||
android:layout_marginEnd="13dp"
|
||||
android:layout_marginBottom="74dp"
|
||||
android:foregroundGravity="center_vertical"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/imageView2"
|
||||
app:srcCompat="@drawable/rectangle_3" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageView4"
|
||||
android:layout_width="384dp"
|
||||
android:layout_height="454dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="391dp"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_marginStart="12dp"
|
||||
android:layout_marginTop="404dp"
|
||||
android:layout_marginEnd="15dp"
|
||||
android:layout_marginBottom="28dp"
|
||||
app:srcCompat="@drawable/rectangle_4"
|
||||
tools:layout_editor_absoluteX="12dp"
|
||||
tools:layout_editor_absoluteY="306dp" />
|
||||
|
@ -63,6 +57,15 @@
|
|||
android:id="@+id/imageView5"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignStart="@+id/imageView4"
|
||||
android:layout_alignTop="@+id/imageView4"
|
||||
android:layout_alignBottom="@+id/imageView4"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_marginStart="18dp"
|
||||
android:layout_marginTop="49dp"
|
||||
android:layout_marginEnd="33dp"
|
||||
android:layout_marginBottom="233dp"
|
||||
android:foregroundGravity="center_vertical"
|
||||
app:srcCompat="@drawable/rectangle_6"
|
||||
tools:layout_editor_absoluteX="31dp"
|
||||
tools:layout_editor_absoluteY="379dp" />
|
||||
|
@ -84,8 +87,10 @@
|
|||
android:id="@+id/imageView7"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignBottom="@+id/imageView4"
|
||||
android:layout_marginStart="31dp"
|
||||
android:layout_marginBottom="45dp"
|
||||
android:layout_marginBottom="25dp"
|
||||
android:foregroundGravity="center_vertical"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/imageView4"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:srcCompat="@drawable/rectangle_7" />
|
||||
|
@ -94,19 +99,25 @@
|
|||
android:id="@+id/button"
|
||||
android:layout_width="172dp"
|
||||
android:layout_height="96dp"
|
||||
android:layout_alignBottom="@+id/imageView4"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_marginTop="570dp"
|
||||
android:layout_marginEnd="207dp"
|
||||
android:layout_marginBottom="129dp"
|
||||
android:background="@drawable/rectangle_5"
|
||||
android:fontFamily="@font/exo_semibold"
|
||||
android:text="@string/support_us_"
|
||||
android:textAllCaps="false"
|
||||
android:textColor="@android:color/white"
|
||||
tools:layout_editor_absoluteX="31dp"
|
||||
tools:layout_editor_absoluteY="498dp" />
|
||||
android:textColor="@android:color/white" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button2"
|
||||
style="@style/Widget.AppCompat.Button.Borderless.Colored"
|
||||
android:layout_width="172dp"
|
||||
android:layout_height="96dp"
|
||||
android:layout_above="@+id/imageView4"
|
||||
android:layout_marginBottom="308dp"
|
||||
android:background="@drawable/rectangle_8"
|
||||
android:fontFamily="@font/exo_semibold"
|
||||
android:text="@string/website_text"
|
||||
|
@ -132,8 +143,8 @@
|
|||
style="@style/Widget.AppCompat.Button.Borderless"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="15dp"
|
||||
android:layout_marginEnd="9dp"
|
||||
android:layout_marginTop="0dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:fontFamily="@font/exo_semibold"
|
||||
android:text="@string/install"
|
||||
android:textAppearance="@style/install"
|
||||
|
@ -141,7 +152,7 @@
|
|||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.983"
|
||||
app:layout_constraintStart_toEndOf="@+id/imageView9"
|
||||
app:layout_constraintTop_toBottomOf="@+id/imageView"
|
||||
app:layout_constraintTop_toTopOf="@+id/imageView2"
|
||||
app:layout_constraintVertical_bias="0.013" />
|
||||
|
||||
<ImageView
|
||||
|
@ -152,4 +163,4 @@
|
|||
tools:layout_editor_absoluteX="295dp"
|
||||
tools:layout_editor_absoluteY="77dp" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</RelativeLayout>
|
14
app/src/main/res/layout/fragment_settings.xml
Normal file
14
app/src/main/res/layout/fragment_settings.xml
Normal file
|
@ -0,0 +1,14 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".SettingsFragment">
|
||||
|
||||
<!-- TODO: Update blank fragment layout -->
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:text="@string/hello_blank_fragment" />
|
||||
|
||||
</FrameLayout>
|
16
app/src/main/res/layout/home_toolbar.xml
Normal file
16
app/src/main/res/layout/home_toolbar.xml
Normal file
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/home_toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/rectangle_2"
|
||||
android:theme="@style/ThemeOverlay.AppCompat.Dark" />
|
||||
|
||||
</LinearLayout>
|
|
@ -11,4 +11,10 @@
|
|||
android:label="@string/title_home"
|
||||
tools:layout="@layout/fragment_home" />
|
||||
|
||||
<fragment
|
||||
android:id="@+id/navigation_settings"
|
||||
android:name="com.vanced.manager.SettingsFragment"
|
||||
android:label="@string/settings"
|
||||
tools:layout="@layout/fragment_settings" />
|
||||
|
||||
</navigation>
|
||||
|
|
|
@ -4,4 +4,6 @@
|
|||
<color name="colorPrimaryDark">#3700B3</color>
|
||||
<color name="colorAccent">#03DAC5</color>
|
||||
<color name="white">#ffffff</color>
|
||||
<color name="Vanced">#d834eb</color>
|
||||
<color name="Brave">#fa6711</color>
|
||||
</resources>
|
||||
|
|
|
@ -8,6 +8,13 @@
|
|||
<item name="colorAccent">@color/colorAccent</item>
|
||||
</style>
|
||||
|
||||
<style name="HomeToolbarText" parent="TextAppearance.AppCompat.Widget.ActionBar.Title">
|
||||
<item name="android:text">@string/home</item>
|
||||
<item name="android:textColor">#ffffff</item>
|
||||
<item name="android:fontFamily">@font/exo_bold</item>
|
||||
<item name="android:textSize">18sp</item>
|
||||
</style>
|
||||
|
||||
<!--
|
||||
Font family: Exo
|
||||
Line height: 32sp
|
||||
|
|
Loading…
Reference in a new issue