Create Fragments for settings

One fragment for every tab, openable with a swipe. The middle tab 
'theme' still has to be filled.
This commit is contained in:
Finn M Glas 2020-05-21 08:59:21 +02:00
parent abd7a44874
commit 716839e1b9
No known key found for this signature in database
GPG key ID: 25037A2E81AB459C
9 changed files with 347 additions and 2 deletions

View file

@ -31,6 +31,7 @@ dependencies {
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

View file

@ -0,0 +1,20 @@
package com.finnmglas.launcher
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
/** The 'Apps' Tab associated Fragment in Settings */
class SettingsFragmentApps : Fragment() {
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.fragment_settings_apps, container, false)
}
}

View file

@ -0,0 +1,20 @@
package com.finnmglas.launcher
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
/** The 'Launcher' Tab associated Fragment in Settings */
class SettingsFragmentLauncher : Fragment() {
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.fragment_settings_launcher, container, false)
}
}

View file

@ -0,0 +1,20 @@
package com.finnmglas.launcher
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
/** The 'Theme' Tab associated Fragment in Settings */
class SettingsFragmentTheme : Fragment() {
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.fragment_settings_theme, container, false)
}
}

View file

@ -18,6 +18,9 @@ class SectionsPagerAdapter(private val context: Context, fm: FragmentManager)
override fun getItem(position: Int): Fragment {
return when (position){
0 -> SettingsFragmentApps()
1 -> SettingsFragmentTheme()
2 -> SettingsFragmentLauncher()
else -> Fragment()
}
}

View file

@ -2,6 +2,7 @@
<androidx.coordinatorlayout.widget.CoordinatorLayout 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:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".SettingsActivity">
@ -25,7 +26,8 @@
android:minHeight="?actionBarSize"
android:padding="@dimen/appbar_padding"
android:text="@string/settings_title"
android:textAppearance="@style/TextAppearance.Widget.AppCompat.Toolbar.Title" />
android:textAppearance="@style/TextAppearance.Widget.AppCompat.Toolbar.Title"
android:textSize="30sp" />
<com.finnmglas.launcher.FontAwesomeSolid
android:layout_width="match_parent"
@ -51,6 +53,5 @@
android:id="@+id/view_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorPrimary"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View file

@ -0,0 +1,188 @@
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/colorPrimaryDark"
android:gravity="center|top"
android:orientation="vertical"
android:padding="32sp"
tools:context=".SettingsActivity">
<TableLayout
android:id="@+id/actionschooser"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="32sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<TextView
android:id="@+id/text_up"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="10sp"
android:paddingRight="10sp"
android:text="@string/settings_choose_up"
android:textColor="#ccc"
android:textSize="20sp" />
<Button
android:id="@+id/btn_choose_up"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="chooseUpApp"
android:text="@string/settings_choose_btn"
android:textAllCaps="false" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<TextView
android:id="@+id/text_down"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="10sp"
android:paddingRight="10sp"
android:text="@string/settings_choose_down"
android:textColor="#ccc"
android:textSize="20sp" />
<Button
android:id="@+id/btn_choose_down"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="chooseDownApp"
android:text="@string/settings_choose_btn"
android:textAllCaps="false" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<TextView
android:id="@+id/text_left"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="10sp"
android:paddingRight="10sp"
android:text="@string/settings_choose_left"
android:textColor="#ccc"
android:textSize="20sp" />
<Button
android:id="@+id/btn_choose_left"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="chooseLeftApp"
android:text="@string/settings_choose_btn"
android:textAllCaps="false" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<TextView
android:id="@+id/text_right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="10sp"
android:paddingRight="10sp"
android:text="@string/settings_choose_right"
android:textColor="#ccc"
android:textSize="20sp" />
<Button
android:id="@+id/btn_choose_right"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="chooseRightApp"
android:text="@string/settings_choose_btn"
android:textAllCaps="false" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<TextView
android:id="@+id/text_vol_up"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="10sp"
android:paddingRight="10sp"
android:text="@string/settings_choose_vol_up"
android:textColor="#ccc"
android:textSize="20sp" />
<Button
android:id="@+id/btn_choose_volume_up"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="chooseVolumeUpApp"
android:text="@string/settings_choose_btn"
android:textAllCaps="false" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<TextView
android:id="@+id/text_vol_down"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="10sp"
android:paddingRight="10sp"
android:text="@string/settings_choose_vol_down"
android:textColor="#ccc"
android:textSize="20sp" />
<Button
android:id="@+id/btn_choose_volume_down"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="chooseVolumeDownApp"
android:text="@string/settings_choose_btn"
android:textAllCaps="false" />
</TableRow>
</TableLayout>
<Button
style="@style/Widget.AppCompat.Button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="chooseLaunchApp"
android:text="@string/settings_launch"
android:textAllCaps="false" />
<Button
style="@style/Widget.AppCompat.Button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="chooseUninstallApp"
android:text="@string/settings_uninstall"
android:textAllCaps="false" />
</LinearLayout>

View file

@ -0,0 +1,69 @@
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/colorPrimaryDark"
android:gravity="center|top"
android:orientation="vertical"
android:padding="32sp"
tools:context=".SettingsActivity">
<Button
style="@style/Widget.AppCompat.Button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="setLauncher"
android:text="@string/settings_select_launcher"
android:textAllCaps="false" />
<Button
style="@style/Widget.AppCompat.Button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="resetSettingsClick"
android:text="@string/settings_reset"
android:textAllCaps="false" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="32sp"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/settings_footer_by"
android:textColor="#999"
android:textSize="18sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="openFinnWebsite"
android:text=" Finn M Glas"
android:textColor="?attr/colorAccent"
android:textSize="18sp"
tools:ignore="HardcodedText" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" | "
android:textColor="#999"
android:textSize="18sp"
tools:ignore="HardcodedText" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="openGithubRepo"
android:text="Open Source"
android:textColor="?attr/colorAccent"
android:textSize="18sp"
tools:ignore="HardcodedText" />
</LinearLayout>
</LinearLayout>

View file

@ -0,0 +1,23 @@
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/colorPrimaryDark"
android:gravity="center|top"
android:orientation="vertical"
android:padding="32sp"
tools:context=".SettingsActivity">
<!--Button
style="@style/Widget.AppCompat.Button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="setLauncher"
android:text="@string/settings_select_launcher"
android:textAllCaps="false" /-->
</LinearLayout>