0
0
Fork 0
mirror of https://github.com/YTVanced/VancedManager synced 2024-11-25 04:35:12 +00:00

More UI improvements, added MicroG Settings button and improved code a little bit

This commit is contained in:
X1nto 2020-03-21 15:16:38 +04:00
parent ecb94aac0e
commit 46d1ed3cd6
8 changed files with 339 additions and 173 deletions

View file

@ -1,5 +1,6 @@
package com.vanced.manager
import android.content.ComponentName
import android.net.Uri
import android.os.Bundle
import androidx.fragment.app.Fragment
@ -7,16 +8,11 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Button
import androidx.browser.customtabs.CustomTabsClient
import android.content.pm.PackageManager
import android.content.Intent
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 android.widget.Toast
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.
@ -30,25 +26,54 @@ class HomeFragment : Fragment() {
return inflater.inflate(R.layout.fragment_home, container, false)
}
private fun isMicrogInstalled(packageName:String, packageManager:PackageManager):Boolean {
return try {
packageManager.getPackageInfo(packageName, 0)
true
} catch (e:PackageManager.NameNotFoundException) {
false
}
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
(activity as MainActivity).supportActionBar?.title = getString(R.string.home)
val braveurl = "https://brave.com/van874"
val vancedurl = "vanced.app"
val vancedurl = "https://vanced.app"
val builder = CustomTabsIntent.Builder()
val brave = getView()?.findViewById(R.id.button) as Button
val website = getView()?.findViewById(R.id.button2) as Button
val mgsettings = getView()?.findViewById(R.id.button8) as Button
val pm = activity?.packageManager
val isInstalled = pm?.let { isMicrogInstalled("com.mgoogle.android.gms", it) }
super.onViewCreated(view, savedInstanceState)
brave.setOnClickListener{
builder.setToolbarColor(ContextCompat.getColor(requireContext(), R.color.Vanced))
builder.setToolbarColor(ContextCompat.getColor(requireContext(), R.color.Brave))
val customTabsIntent = builder.build()
customTabsIntent.launchUrl(requireContext(), Uri.parse(braveurl))
}
website.setOnClickListener{
builder.setToolbarColor(ContextCompat.getColor(requireContext(), R.color.Brave))
builder.setToolbarColor(ContextCompat.getColor(requireContext(), R.color.Vanced))
val customTabsIntent = builder.build()
customTabsIntent.launchUrl(requireContext(), Uri.parse(vancedurl))
}
mgsettings.setOnClickListener{
if (isInstalled == true) {
val intent = Intent()
intent.component = ComponentName(
"com.mgoogle.android.gms",
"org.microg.gms.ui.SettingsActivity"
)
startActivity(intent)
}
else {
val toast = Toast.makeText(context, "Install MicroG First!", Toast.LENGTH_SHORT)
toast.show()
}
}
}
}

View file

@ -25,12 +25,14 @@ class MainActivity : AppCompatActivity() {
.commit()
val toolbar = findViewById(R.id.home_toolbar) as Toolbar?
setSupportActionBar(toolbar)
supportActionBar?.setDisplayHomeAsUpEnabled(true)
supportActionBar?.setDisplayShowHomeEnabled(true)
navView.setOnNavigationItemSelectedListener { item ->
when (item.itemId) {
R.id.home -> {
R.id.navigation_home -> {
homeFragment = HomeFragment()
supportFragmentManager
@ -40,6 +42,15 @@ class MainActivity : AppCompatActivity() {
.commit()
setSupportActionBar(toolbar)
}
R.id.navigation_settings -> {
settingsFragment = SettingsFragment()
supportFragmentManager
.beginTransaction()
.replace(R.id.frame_layout, settingsFragment)
.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
.commit()
}
}

View file

@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#1490D7"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M19.1,12.9a2.8,2.8 0,0 0,0.1 -0.9,2.8 2.8,0 0,0 -0.1,-0.9l2.1,-1.6a0.7,0.7 0,0 0,0.1 -0.6L19.4,5.5a0.7,0.7 0,0 0,-0.6 -0.2l-2.4,1a6.5,6.5 0,0 0,-1.6 -0.9l-0.4,-2.6a0.5,0.5 0,0 0,-0.5 -0.4H10.1a0.5,0.5 0,0 0,-0.5 0.4L9.3,5.4a5.6,5.6 0,0 0,-1.7 0.9l-2.4,-1a0.4,0.4 0,0 0,-0.5 0.2l-2,3.4c-0.1,0.2 0,0.4 0.2,0.6l2,1.6a2.8,2.8 0,0 0,-0.1 0.9,2.8 2.8,0 0,0 0.1,0.9L2.8,14.5a0.7,0.7 0,0 0,-0.1 0.6l1.9,3.4a0.7,0.7 0,0 0,0.6 0.2l2.4,-1a6.5,6.5 0,0 0,1.6 0.9l0.4,2.6a0.5,0.5 0,0 0,0.5 0.4h3.8a0.5,0.5 0,0 0,0.5 -0.4l0.3,-2.6a5.6,5.6 0,0 0,1.7 -0.9l2.4,1a0.4,0.4 0,0 0,0.5 -0.2l2,-3.4c0.1,-0.2 0,-0.4 -0.2,-0.6ZM12,15.6A3.6,3.6 0,1 1,15.6 12,3.6 3.6,0 0,1 12,15.6Z"/>
</vector>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
<androidx.core.widget.NestedScrollView
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"
@ -7,160 +7,293 @@
android:layout_height="match_parent"
tools:context=".ui.home.HomeFragment">
<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" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/imageView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
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="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/imageView2"
android:layout_alignParentStart="true"
android:layout_alignParentEnd="true"
android:layout_marginStart="15dp"
android:layout_marginTop="32dp"
android:layout_marginEnd="15dp"
android:src="@drawable/rectangle_3" />
<ImageView
android:id="@+id/imageView4"
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" />
<ImageView
android:id="@+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_marginStart="15dp"
android:layout_marginTop="36dp"
android:layout_marginEnd="15dp"
android:src="@drawable/rectangle_3" />
<ImageView
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" />
<ImageView
android:id="@+id/imageView6"
android:layout_width="wrap_content"
android:layout_height="382dp"
android:layout_below="@+id/imageView4"
android:layout_alignParentStart="true"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginStart="15dp"
android:layout_marginTop="32dp"
android:layout_marginEnd="14dp"
android:layout_marginBottom="9dp"
android:src="@drawable/rectangle_4" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="10dp"
android:fontFamily="@font/exo_semibold"
android:text="@string/vanced_medias"
android:textColor="#FFFFFF"
android:textSize="18sp"
app:layout_constraintStart_toStartOf="@+id/imageView5"
app:layout_constraintTop_toTopOf="@+id/imageView5" />
<ImageView
android:id="@+id/imageView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/imageView6"
android:layout_alignEnd="@+id/imageView6"
android:layout_alignParentStart="true"
android:layout_marginStart="23dp"
android:layout_marginTop="48dp"
android:layout_marginEnd="7dp"
android:src="@drawable/rectangle_6" />
<ImageView
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="25dp"
android:foregroundGravity="center_vertical"
app:layout_constraintBottom_toBottomOf="@+id/imageView4"
app:layout_constraintStart_toStartOf="parent"
app:srcCompat="@drawable/rectangle_7" />
<TextView
android:id="@+id/textView"
android:layout_width="141dp"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/imageView6"
android:layout_alignParentStart="true"
android:layout_alignParentEnd="true"
android:layout_marginStart="27dp"
android:layout_marginTop="12dp"
android:layout_marginEnd="243dp"
android:fontFamily="@font/exo_bold"
android:text="@string/useful_links"
android:textSize="22sp" />
<Button
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" />
<Button
android:id="@+id/button"
style="@style/Widget.AppCompat.Button.Borderless.Colored"
android:layout_width="165dp"
android:layout_height="wrap_content"
android:layout_above="@+id/imageView8"
android:layout_below="@+id/imageView7"
android:layout_alignStart="@+id/imageView6"
android:layout_marginStart="17dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="9dp"
android:background="@drawable/rectangle_5"
android:text="@string/support_us_"
android:textAllCaps="false"
android:textColor="#ffffff" />
<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"
android:textAllCaps="false"
android:textColor="#FFFFFF"
tools:layout_editor_absoluteX="208dp"
tools:layout_editor_absoluteY="498dp" />
<Button
android:id="@+id/button2"
android:layout_width="165dp"
android:layout_height="wrap_content"
android:layout_above="@+id/imageView8"
android:layout_below="@+id/imageView7"
android:layout_alignEnd="@+id/imageView6"
android:layout_marginStart="10dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="17dp"
android:layout_marginBottom="10dp"
android:layout_toEndOf="@+id/button"
android:background="@drawable/rectangle_8"
android:text="@string/website_text"
android:textAllCaps="false"
android:textColor="#ffffff" />
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="11dp"
android:layout_marginTop="4dp"
android:fontFamily="@font/exo_bold"
android:text="@string/website"
android:textColor="#FFFFFF"
app:layout_constraintStart_toStartOf="@+id/button"
app:layout_constraintTop_toTopOf="@+id/button" />
<ImageView
android:id="@+id/imageView8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/imageView6"
android:layout_alignParentStart="true"
android:layout_alignParentEnd="true"
android:layout_marginStart="31dp"
android:layout_marginEnd="32dp"
android:layout_marginBottom="14dp"
android:src="@drawable/rectangle_7" />
<Button
android:id="@+id/button3"
style="@style/Widget.AppCompat.Button.Borderless"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="0dp"
android:layout_marginEnd="8dp"
android:fontFamily="@font/exo_semibold"
android:text="@string/install"
android:textAppearance="@style/install"
app:layout_constraintBottom_toBottomOf="@+id/imageView2"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.983"
app:layout_constraintStart_toEndOf="@+id/imageView9"
app:layout_constraintTop_toTopOf="@+id/imageView2"
app:layout_constraintVertical_bias="0.013" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="32dp"
android:layout_alignTop="@+id/imageView2"
android:layout_alignBottom="@+id/imageView2"
android:layout_marginTop="7dp"
android:layout_marginEnd="103dp"
android:layout_marginBottom="81dp"
android:layout_toStartOf="@+id/imageView9"
android:fontFamily="@font/exo_bold"
android:text="@string/vanced"
android:textColor="#1490D7"
android:textSize="24sp" />
<ImageView
android:id="@+id/imageView9"
android:layout_width="36dp"
android:layout_height="29dp"
app:srcCompat="@drawable/outline_cloud_download_black_18"
tools:layout_editor_absoluteX="295dp"
tools:layout_editor_absoluteY="77dp" />
<TextView
android:id="@+id/textView11"
android:layout_width="88dp"
android:layout_height="wrap_content"
android:layout_alignStart="@+id/imageView2"
android:layout_alignEnd="@+id/imageView2"
android:layout_alignBottom="@+id/imageView2"
android:layout_marginStart="12dp"
android:layout_marginEnd="281dp"
android:layout_marginBottom="46dp"
android:fontFamily="@font/exo_semibold"
android:text="@string/latest"
android:textSize="22sp" />
</RelativeLayout>
<TextView
android:id="@+id/textView12"
android:layout_width="99dp"
android:layout_height="34dp"
android:layout_alignStart="@+id/imageView2"
android:layout_alignEnd="@+id/imageView2"
android:layout_alignBottom="@+id/imageView2"
android:layout_marginStart="12dp"
android:layout_marginEnd="270dp"
android:layout_marginBottom="16dp"
android:fontFamily="@font/exo_semibold"
android:text="@string/installed"
android:textSize="22sp" />
<Button
android:id="@+id/button3"
style="@style/Widget.AppCompat.Button.Borderless.Colored"
android:layout_width="101dp"
android:layout_height="51dp"
android:layout_alignTop="@+id/imageView2"
android:layout_alignEnd="@+id/imageView2"
android:layout_alignBottom="@+id/imageView2"
android:layout_marginTop="2dp"
android:layout_marginEnd="22dp"
android:layout_marginBottom="70dp"
android:fontFamily="@font/exo_semibold"
android:text="@string/install"
android:textAllCaps="false"
android:textColor="#1490D7"
android:textSize="22sp" />
<ImageView
android:id="@+id/imageView9"
android:layout_width="42dp"
android:layout_height="34dp"
android:layout_alignTop="@+id/imageView2"
android:layout_alignBottom="@+id/imageView2"
android:layout_marginTop="11dp"
android:layout_marginEnd="-18dp"
android:layout_marginBottom="75dp"
android:layout_toStartOf="@+id/button3"
android:src="@drawable/outline_cloud_download_24" />
<ImageView
android:id="@+id/imageView10"
android:layout_width="42dp"
android:layout_height="34dp"
android:layout_alignTop="@+id/imageView4"
android:layout_alignBottom="@+id/imageView4"
android:layout_marginTop="12dp"
android:layout_marginEnd="-9dp"
android:layout_marginBottom="74dp"
android:layout_toStartOf="@+id/button7"
android:src="@drawable/outline_cloud_download_24" />
<TextView
android:id="@+id/textView13"
android:layout_width="wrap_content"
android:layout_height="34dp"
android:layout_alignTop="@+id/imageView4"
android:layout_alignEnd="@+id/imageView4"
android:layout_alignBottom="@+id/imageView4"
android:layout_marginTop="7dp"
android:layout_marginEnd="252dp"
android:layout_marginBottom="79dp"
android:fontFamily="@font/exo_bold"
android:text="@string/microg"
android:textColor="@color/colorAccent"
android:textSize="24sp" />
<TextView
android:id="@+id/textView14"
android:layout_width="78dp"
android:layout_height="wrap_content"
android:layout_alignStart="@+id/imageView4"
android:layout_alignEnd="@+id/imageView4"
android:layout_alignBottom="@+id/imageView4"
android:layout_marginStart="12dp"
android:layout_marginEnd="286dp"
android:layout_marginBottom="41dp"
android:fontFamily="@font/exo_semibold"
android:text="@string/latest"
android:textSize="22sp" />
<TextView
android:id="@+id/textView15"
android:layout_width="91dp"
android:layout_height="wrap_content"
android:layout_alignEnd="@+id/imageView4"
android:layout_alignBottom="@+id/imageView4"
android:layout_alignParentStart="true"
android:layout_marginStart="28dp"
android:layout_marginEnd="255dp"
android:layout_marginBottom="11dp"
android:fontFamily="@font/exo_semibold"
android:text="@string/installed"
android:textSize="22sp" />
<Button
android:id="@+id/button7"
style="@style/Widget.AppCompat.Button.Borderless.Colored"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/imageView4"
android:layout_alignEnd="@+id/imageView4"
android:layout_alignBottom="@+id/imageView4"
android:layout_marginTop="1dp"
android:layout_marginEnd="27dp"
android:layout_marginBottom="63dp"
android:fontFamily="@font/exo_semibold"
android:text="@string/install"
android:textAllCaps="false"
android:textSize="22sp" />
<Button
android:id="@+id/button8"
style="@style/Widget.AppCompat.Button.Borderless.Colored"
android:layout_width="wrap_content"
android:layout_height="60dp"
android:layout_alignTop="@+id/imageView4"
android:layout_alignEnd="@+id/imageView4"
android:layout_alignBottom="@+id/imageView4"
android:layout_marginTop="34dp"
android:layout_marginEnd="10dp"
android:layout_marginBottom="26dp"
android:fontFamily="@font/exo_semibold"
android:text="@string/settings"
android:textAllCaps="false"
android:textSize="22sp" />
<ImageView
android:id="@+id/imageView11"
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_alignTop="@+id/imageView4"
android:layout_alignBottom="@+id/imageView4"
android:layout_marginTop="46dp"
android:layout_marginEnd="-7dp"
android:layout_marginBottom="38dp"
android:layout_toStartOf="@+id/button8"
android:src="@drawable/ic_settings_black_24dp" />
</RelativeLayout>
</androidx.core.widget.NestedScrollView>

View file

@ -5,10 +5,11 @@
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" />
android:textSize="40sp"
android:text="WIP" />
</FrameLayout>

View file

@ -2,7 +2,7 @@
<resources>
<color name="colorPrimary">#6200EE</color>
<color name="colorPrimaryDark">#3700B3</color>
<color name="colorAccent">#03DAC5</color>
<color name="colorAccent">#1490D7</color>
<color name="white">#ffffff</color>
<color name="Vanced">#d834eb</color>
<color name="Brave">#fa6711</color>

View file

@ -4,7 +4,8 @@
<string name="home">Home</string>
<string name="vanced">Vanced</string>
<string name="install">Install</string>
<string name="latest_inst">Latest\nInstalled</string>
<string name="latest">Latest:</string>
<string name="installed">Installed:</string>
<string name="n_a">N/A</string>
<string name="microg">MicroG</string>
<string name="settings">Settings</string>
@ -22,7 +23,4 @@
<string name="github_manager">Manager</string>
<string name="github_bot">Bot</string>
<string name="github_website">Website</string>
<!-- TODO: Remove or change this placeholder text -->
<string name="hello_blank_fragment">Hello blank fragment</string>
</resources>

View file

@ -8,13 +8,6 @@
<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