diff --git a/app/src/main/java/com/vanced/manager/HomeFragment.kt b/app/src/main/java/com/vanced/manager/HomeFragment.kt index 31fffc82..54d581f0 100644 --- a/app/src/main/java/com/vanced/manager/HomeFragment.kt +++ b/app/src/main/java/com/vanced/manager/HomeFragment.kt @@ -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)) + } } } diff --git a/app/src/main/java/com/vanced/manager/MainActivity.kt b/app/src/main/java/com/vanced/manager/MainActivity.kt index 1564dccb..54dc5853 100644 --- a/app/src/main/java/com/vanced/manager/MainActivity.kt +++ b/app/src/main/java/com/vanced/manager/MainActivity.kt @@ -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) } } diff --git a/app/src/main/java/com/vanced/manager/SettingsFragment.kt b/app/src/main/java/com/vanced/manager/SettingsFragment.kt new file mode 100644 index 00000000..0041bed9 --- /dev/null +++ b/app/src/main/java/com/vanced/manager/SettingsFragment.kt @@ -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) + } + } + } +} diff --git a/app/src/main/java/com/vanced/manager/ui/home/HomeFragment.kt b/app/src/main/java/com/vanced/manager/ui/home/HomeFragment.kt index 1dd1bee2..c8821d62 100644 --- a/app/src/main/java/com/vanced/manager/ui/home/HomeFragment.kt +++ b/app/src/main/java/com/vanced/manager/ui/home/HomeFragment.kt @@ -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 } } diff --git a/app/src/main/java/com/vanced/manager/ui/settings/SettingsFragment.kt b/app/src/main/java/com/vanced/manager/ui/settings/SettingsFragment.kt deleted file mode 100644 index 9de3a92c..00000000 --- a/app/src/main/java/com/vanced/manager/ui/settings/SettingsFragment.kt +++ /dev/null @@ -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 - } -} diff --git a/app/src/main/java/com/vanced/manager/ui/settings/SettingsViewModel.kt b/app/src/main/java/com/vanced/manager/ui/settings/SettingsViewModel.kt deleted file mode 100644 index d9e4f563..00000000 --- a/app/src/main/java/com/vanced/manager/ui/settings/SettingsViewModel.kt +++ /dev/null @@ -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().apply { - value = "This is dashboard Fragment" - } - val text: LiveData = _text -} \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 929a295a..95e00c03 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -1,5 +1,5 @@ - + app:layout_constraintBottom_toBottomOf="@+id/frame_layout" + app:menu="@menu/bottom_nav_menu" /> + android:background="@color/white" + app:layout_constraintBottom_toBottomOf="parent"> - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_home.xml b/app/src/main/res/layout/fragment_home.xml index 0eaed668..4716f91e 100644 --- a/app/src/main/res/layout/fragment_home.xml +++ b/app/src/main/res/layout/fragment_home.xml @@ -1,42 +1,21 @@ - - - - - @@ -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" /> @@ -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" />