mirror of
https://github.com/SimpleMobileTools/Simple-Notes.git
synced 2025-04-20 18:27:26 +02:00
show the current note title in a pager strip
This commit is contained in:
parent
910059d8ff
commit
e83c41fa35
@ -3,6 +3,8 @@ package com.simplemobiletools.notes.activities
|
|||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.support.v4.view.ViewPager
|
import android.support.v4.view.ViewPager
|
||||||
|
import android.util.TypedValue
|
||||||
|
import android.view.Gravity
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
import android.view.View
|
import android.view.View
|
||||||
@ -17,6 +19,7 @@ import com.simplemobiletools.notes.dialogs.NewNoteDialog
|
|||||||
import com.simplemobiletools.notes.dialogs.OpenNoteDialog
|
import com.simplemobiletools.notes.dialogs.OpenNoteDialog
|
||||||
import com.simplemobiletools.notes.dialogs.RenameNoteDialog
|
import com.simplemobiletools.notes.dialogs.RenameNoteDialog
|
||||||
import com.simplemobiletools.notes.extensions.dpToPx
|
import com.simplemobiletools.notes.extensions.dpToPx
|
||||||
|
import com.simplemobiletools.notes.extensions.getTextSize
|
||||||
import com.simplemobiletools.notes.models.Note
|
import com.simplemobiletools.notes.models.Note
|
||||||
import kotlinx.android.synthetic.main.activity_main.*
|
import kotlinx.android.synthetic.main.activity_main.*
|
||||||
import kotlinx.android.synthetic.main.fragment_note.*
|
import kotlinx.android.synthetic.main.fragment_note.*
|
||||||
@ -34,6 +37,9 @@ class MainActivity : SimpleActivity(), ViewPager.OnPageChangeListener {
|
|||||||
mDb = DBHelper.newInstance(applicationContext)
|
mDb = DBHelper.newInstance(applicationContext)
|
||||||
initViewPager()
|
initViewPager()
|
||||||
|
|
||||||
|
pager_title_strip.setTextSize(TypedValue.COMPLEX_UNIT_PX, getTextSize())
|
||||||
|
pager_title_strip.layoutParams.height = (pager_title_strip.height + resources.getDimension(R.dimen.activity_margin) * 2).toInt()
|
||||||
|
|
||||||
notes_fab.setOnClickListener { displayNewNoteDialog() }
|
notes_fab.setOnClickListener { displayNewNoteDialog() }
|
||||||
notes_fab.viewTreeObserver.addOnGlobalLayoutListener {
|
notes_fab.viewTreeObserver.addOnGlobalLayoutListener {
|
||||||
val heightDiff = notes_coordinator.rootView.height - notes_coordinator.height
|
val heightDiff = notes_coordinator.rootView.height - notes_coordinator.height
|
||||||
@ -57,6 +63,9 @@ class MainActivity : SimpleActivity(), ViewPager.OnPageChangeListener {
|
|||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
invalidateOptionsMenu()
|
invalidateOptionsMenu()
|
||||||
|
pager_title_strip.setTextSize(TypedValue.COMPLEX_UNIT_PX, getTextSize())
|
||||||
|
pager_title_strip.setGravity(Gravity.CENTER_VERTICAL)
|
||||||
|
pager_title_strip.setNonPrimaryAlpha(0.4f)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
@ -77,6 +86,8 @@ class MainActivity : SimpleActivity(), ViewPager.OnPageChangeListener {
|
|||||||
findItem(R.id.delete_note).isVisible = shouldBeVisible
|
findItem(R.id.delete_note).isVisible = shouldBeVisible
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pager_title_strip.visibility = if (shouldBeVisible) View.VISIBLE else View.GONE
|
||||||
|
|
||||||
return super.onPrepareOptionsMenu(menu)
|
return super.onPrepareOptionsMenu(menu)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,7 +124,6 @@ class MainActivity : SimpleActivity(), ViewPager.OnPageChangeListener {
|
|||||||
private fun displayRenameDialog() {
|
private fun displayRenameDialog() {
|
||||||
RenameNoteDialog(this, mDb, mCurrentNote) {
|
RenameNoteDialog(this, mDb, mCurrentNote) {
|
||||||
mCurrentNote = it
|
mCurrentNote = it
|
||||||
current_note_title.text = it.title
|
|
||||||
initViewPager()
|
initViewPager()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,4 +31,6 @@ class NotesPagerAdapter(fm: FragmentManager, private val notes: List<Note>) : Fr
|
|||||||
fragments.put(position, fragment)
|
fragments.put(position, fragment)
|
||||||
return fragment
|
return fragment
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun getPageTitle(position: Int) = notes[position].title
|
||||||
}
|
}
|
||||||
|
@ -28,8 +28,6 @@ class NoteFragment : Fragment() {
|
|||||||
note = mDb.getNote(noteId) ?: return view
|
note = mDb.getNote(noteId) ?: return view
|
||||||
|
|
||||||
view.notes_view.setText(note.value)
|
view.notes_view.setText(note.value)
|
||||||
view.current_note_title.text = note.title
|
|
||||||
view.notes_view.setTextSize(TypedValue.COMPLEX_UNIT_PX, context.getTextSize())
|
|
||||||
return view
|
return view
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,6 +41,11 @@ class NoteFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onResume() {
|
||||||
|
super.onResume()
|
||||||
|
view.notes_view.setTextSize(TypedValue.COMPLEX_UNIT_PX, context.getTextSize())
|
||||||
|
}
|
||||||
|
|
||||||
override fun onPause() {
|
override fun onPause() {
|
||||||
super.onPause()
|
super.onPause()
|
||||||
saveText()
|
saveText()
|
||||||
|
@ -9,7 +9,16 @@
|
|||||||
<com.simplemobiletools.notes.views.MyViewPager
|
<com.simplemobiletools.notes.views.MyViewPager
|
||||||
android:id="@+id/view_pager"
|
android:id="@+id/view_pager"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"/>
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<android.support.v4.view.PagerTitleStrip
|
||||||
|
android:id="@+id/pager_title_strip"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="top"
|
||||||
|
android:paddingLeft="@dimen/activity_margin"
|
||||||
|
android:paddingRight="@dimen/activity_margin"/>
|
||||||
|
</com.simplemobiletools.notes.views.MyViewPager>
|
||||||
|
|
||||||
<android.support.design.widget.FloatingActionButton
|
<android.support.design.widget.FloatingActionButton
|
||||||
android:id="@+id/notes_fab"
|
android:id="@+id/notes_fab"
|
||||||
|
@ -3,22 +3,12 @@
|
|||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:id="@+id/note_Fragment_holder"
|
android:id="@+id/note_Fragment_holder"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent">
|
||||||
android:paddingTop="@dimen/activity_margin">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/current_note_title"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginLeft="@dimen/activity_margin"
|
|
||||||
android:layout_marginRight="@dimen/activity_margin"
|
|
||||||
android:alpha=".6"/>
|
|
||||||
|
|
||||||
<ScrollView
|
<ScrollView
|
||||||
android:id="@+id/notes_scrollview"
|
android:id="@+id/notes_scrollview"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_below="@+id/current_note_title"
|
|
||||||
android:fillViewport="true">
|
android:fillViewport="true">
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
|
Loading…
x
Reference in New Issue
Block a user