Move settings to activity, remove upper bar
This commit is contained in:
parent
a6bdaf4044
commit
1d13b5e621
@ -69,7 +69,7 @@ dependencies {
|
||||
implementation 'com.google.android.material:material:1.1.0'
|
||||
|
||||
|
||||
implementation ("com.github.bumptech.glide:glide:4.11.0") {
|
||||
implementation("com.github.bumptech.glide:glide:4.11.0") {
|
||||
exclude group: "com.android.support"
|
||||
}
|
||||
implementation "com.github.bumptech.glide:okhttp-integration:4.11.0"
|
||||
|
@ -1,7 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.h.pixeldroid">
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
@ -9,11 +11,19 @@
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme">
|
||||
<activity
|
||||
android:name=".SettingsActivity"
|
||||
android:label="@string/title_activity_settings2">
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".MainActivity"/>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:theme="@style/AppTheme.NoActionBar">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
@ -22,6 +32,7 @@
|
||||
android:windowSoftInputMode="adjustResize">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
|
||||
@ -29,7 +40,8 @@
|
||||
android:host="${applicationId}"
|
||||
android:scheme="@string/auth_scheme" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity android:name=".ProfileActivity"></activity>
|
||||
</activity>
|
||||
<activity android:name=".ProfileActivity" />
|
||||
</application>
|
||||
|
||||
</manifest>
|
@ -3,26 +3,13 @@ package com.h.pixeldroid
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.view.MenuItem
|
||||
import androidx.annotation.NonNull
|
||||
import androidx.appcompat.app.ActionBarDrawerToggle
|
||||
import androidx.appcompat.widget.Toolbar
|
||||
import androidx.core.view.GravityCompat
|
||||
import androidx.drawerlayout.widget.DrawerLayout
|
||||
import androidx.fragment.app.Fragment
|
||||
import com.google.android.material.navigation.NavigationView
|
||||
import com.h.pixeldroid.settings.ui.*
|
||||
import android.util.Log
|
||||
import com.h.pixeldroid.api.PixelfedAPI
|
||||
import com.h.pixeldroid.objects.Status
|
||||
import retrofit2.Call
|
||||
import retrofit2.Callback
|
||||
import retrofit2.Response
|
||||
import retrofit2.Retrofit
|
||||
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory
|
||||
import retrofit2.converter.gson.GsonConverterFactory
|
||||
import android.view.View
|
||||
import android.widget.Button
|
||||
import androidx.annotation.NonNull
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.view.GravityCompat
|
||||
import androidx.drawerlayout.widget.DrawerLayout
|
||||
import com.google.android.material.navigation.NavigationView
|
||||
|
||||
class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelectedListener {
|
||||
|
||||
@ -32,28 +19,13 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_main)
|
||||
|
||||
// setup the top toolbar
|
||||
val toolbar : Toolbar = findViewById(R.id.toolbar)
|
||||
setSupportActionBar(toolbar)
|
||||
|
||||
// Setup the drawer
|
||||
drawerLayout = findViewById(R.id.drawer_layout)
|
||||
val navigationView: NavigationView = findViewById(R.id.nav_view)
|
||||
navigationView.setNavigationItemSelectedListener(this)
|
||||
|
||||
val toggle = ActionBarDrawerToggle(this, drawerLayout, toolbar,
|
||||
R.string.navigation_drawer_open, R.string.navigation_drawer_close)
|
||||
drawerLayout.addDrawerListener(toggle)
|
||||
toggle.syncState()
|
||||
|
||||
// On startup ONLY, start at the account settings
|
||||
if(savedInstanceState == null) {
|
||||
launchFragment(AccountFragment())
|
||||
navigationView.setCheckedItem(R.id.nav_account)
|
||||
}
|
||||
|
||||
val button_login = findViewById<Button>(R.id.button_start_login)
|
||||
button_login.setOnClickListener((View.OnClickListener {
|
||||
val buttonLogin = findViewById<Button>(R.id.button_start_login)
|
||||
buttonLogin.setOnClickListener((View.OnClickListener {
|
||||
val intent = Intent(this, LoginActivity::class.java)
|
||||
startActivity(intent) }))
|
||||
|
||||
@ -68,9 +40,8 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
|
||||
*/
|
||||
override fun onNavigationItemSelected(@NonNull item: MenuItem): Boolean {
|
||||
when (item.itemId){
|
||||
R.id.nav_account -> launchFragment(AccountFragment())
|
||||
R.id.nav_accessibility -> launchFragment(AccessibilityFragment())
|
||||
R.id.nav_settings -> launchFragment(SettingsFragment())
|
||||
R.id.nav_settings -> launchActivity(SettingsActivity())
|
||||
R.id.nav_account -> launchActivity(ProfileActivity())
|
||||
}
|
||||
|
||||
drawerLayout.closeDrawer(GravityCompat.START)
|
||||
@ -81,8 +52,9 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
|
||||
/*
|
||||
Launches the given fragment and put it as the current "activity"
|
||||
*/
|
||||
private fun launchFragment(fragment: Fragment) {
|
||||
supportFragmentManager.beginTransaction().replace(R.id.fragment_container, fragment).commit()
|
||||
private fun launchActivity(activity: AppCompatActivity) {
|
||||
val intent = Intent(this, activity::class.java)
|
||||
startActivity(intent)
|
||||
}
|
||||
|
||||
/*
|
||||
|
25
app/src/main/java/com/h/pixeldroid/SettingsActivity.kt
Normal file
25
app/src/main/java/com/h/pixeldroid/SettingsActivity.kt
Normal file
@ -0,0 +1,25 @@
|
||||
package com.h.pixeldroid
|
||||
|
||||
import android.os.Bundle
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.preference.PreferenceFragmentCompat
|
||||
import com.h.pixeldroid.R
|
||||
|
||||
class SettingsActivity : AppCompatActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.settings)
|
||||
supportFragmentManager
|
||||
.beginTransaction()
|
||||
.replace(R.id.settings, SettingsFragment())
|
||||
.commit()
|
||||
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
||||
}
|
||||
|
||||
class SettingsFragment : PreferenceFragmentCompat() {
|
||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||
setPreferencesFromResource(R.xml.root_preferences, rootKey)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
package com.h.pixeldroid.settings.ui
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.fragment.app.Fragment
|
||||
import com.h.pixeldroid.R
|
||||
|
||||
class AccessibilityFragment : Fragment() {
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
return inflater.inflate(R.layout.fragment_accessibility, container, false)
|
||||
}
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
package com.h.pixeldroid.settings.ui
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.fragment.app.Fragment
|
||||
import com.h.pixeldroid.R
|
||||
|
||||
class AccountFragment : Fragment() {
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
return inflater.inflate(R.layout.fragment_account, container, false)
|
||||
}
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
package com.h.pixeldroid.settings.ui
|
||||
|
||||
import android.os.Bundle
|
||||
import androidx.preference.PreferenceFragmentCompat
|
||||
import com.h.pixeldroid.R
|
||||
|
||||
class SettingsFragment : PreferenceFragmentCompat() {
|
||||
|
||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||
setPreferencesFromResource(R.xml.settings_screen, rootKey)
|
||||
}
|
||||
|
||||
}
|
@ -31,26 +31,6 @@
|
||||
android:text="Show a profile" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:background="@color/colorPrimary"
|
||||
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
|
||||
app:popupTheme="@style/Theme.AppCompat.Light"
|
||||
android:elevation="4dp"/>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/fragment_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"/>
|
||||
</LinearLayout>
|
||||
|
||||
<com.google.android.material.navigation.NavigationView
|
||||
android:id="@+id/nav_view"
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -1,23 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<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"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".settings.ui.AccessibilityFragment">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text_accessibility"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:textAlignment="center"
|
||||
android:textSize="20sp"
|
||||
android:text="@string/menu_accessibility"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -1,23 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<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"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".settings.ui.AccountFragment">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text_account"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:textAlignment="center"
|
||||
android:textSize="20sp"
|
||||
android:text="@string/menu_account"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
9
app/src/main/res/layout/settings.xml
Normal file
9
app/src/main/res/layout/settings.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/settings"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
</LinearLayout>
|
12
app/src/main/res/values/arrays.xml
Normal file
12
app/src/main/res/values/arrays.xml
Normal file
@ -0,0 +1,12 @@
|
||||
<resources>
|
||||
<!-- Reply Preference -->
|
||||
<string-array name="reply_entries">
|
||||
<item>Reply</item>
|
||||
<item>Reply to all</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="reply_values">
|
||||
<item>reply</item>
|
||||
<item>reply_all</item>
|
||||
</string-array>
|
||||
</resources>
|
@ -37,4 +37,20 @@
|
||||
<string name="browser_launch_failed">"Could not launch a browser, do you have one?"</string>
|
||||
<string name="auth_failed">"Could not authenticate"</string>
|
||||
<string name="token_error">"Error getting token"</string>
|
||||
<string name="title_activity_settings2">Settings</string>
|
||||
|
||||
<!-- Preference Titles -->
|
||||
<string name="messages_header">Messages</string>
|
||||
<string name="sync_header">Sync</string>
|
||||
|
||||
<!-- Messages Preferences -->
|
||||
<string name="signature_title">Your signature</string>
|
||||
<string name="reply_title">Default reply action</string>
|
||||
|
||||
<!-- Sync Preferences -->
|
||||
<string name="sync_title">Sync email periodically</string>
|
||||
<string name="attachment_title">Download incoming attachments</string>
|
||||
<string name="attachment_summary_on">Automatically download attachments for incoming emails
|
||||
</string>
|
||||
<string name="attachment_summary_off">Only download attachments when manually requested</string>
|
||||
</resources>
|
||||
|
35
app/src/main/res/xml/root_preferences.xml
Normal file
35
app/src/main/res/xml/root_preferences.xml
Normal file
@ -0,0 +1,35 @@
|
||||
<PreferenceScreen xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<PreferenceCategory app:title="@string/messages_header">
|
||||
|
||||
<EditTextPreference
|
||||
app:key="signature"
|
||||
app:title="@string/signature_title"
|
||||
app:useSimpleSummaryProvider="true" />
|
||||
|
||||
<ListPreference
|
||||
app:defaultValue="reply"
|
||||
app:entries="@array/reply_entries"
|
||||
app:entryValues="@array/reply_values"
|
||||
app:key="reply"
|
||||
app:title="@string/reply_title"
|
||||
app:useSimpleSummaryProvider="true" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory app:title="@string/sync_header">
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
app:key="sync"
|
||||
app:title="@string/sync_title" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
app:dependency="sync"
|
||||
app:key="attachment"
|
||||
app:summaryOff="@string/attachment_summary_off"
|
||||
app:summaryOn="@string/attachment_summary_on"
|
||||
app:title="@string/attachment_title" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
</PreferenceScreen>
|
@ -1,43 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<SwitchPreference
|
||||
android:key="show_time"
|
||||
android:title="Show time"
|
||||
android:icon="@drawable/ic_time"
|
||||
android:defaultValue="true"/>
|
||||
|
||||
<SwitchPreference
|
||||
android:key="night_mode"
|
||||
android:title="Night mode"/>
|
||||
|
||||
<ListPreference
|
||||
android:key="list_languages"
|
||||
android:title="Language"
|
||||
android:icon="@drawable/ic_translate"
|
||||
android:entries="@array/list_languages"
|
||||
android:entryValues="@array/list_languages"
|
||||
android:defaultValue="English"
|
||||
android:summary="%s"/>
|
||||
|
||||
<ListPreference
|
||||
android:key="list_font_size"
|
||||
android:title="Text size"
|
||||
android:icon="@drawable/ic_font_size"
|
||||
android:entries="@array/list_font_size"
|
||||
android:entryValues="@array/list_font_size"
|
||||
android:defaultValue="Medium"
|
||||
android:summary="%s"/>
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:key="bluetooth_settings"
|
||||
android:title="Activate bluetooth connection"
|
||||
android:icon="@drawable/ic_bluetooth"
|
||||
android:defaultValue="false"/>
|
||||
|
||||
<Preference
|
||||
android:key="feedback"
|
||||
android:title="Give feedback"
|
||||
android:summary="To give feedback on features or new ideas" />
|
||||
|
||||
</PreferenceScreen>
|
Loading…
x
Reference in New Issue
Block a user