Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class ConfigureWidgetActivity : LockedActivity<ActivityConfigureWidgetBinding>()
BaseNoteAdapter(
Collections.emptySet(),
dateFormat.value,
notesSorting.value.first,
textSize.value,
maxItems,
maxLines,
Expand Down Expand Up @@ -83,6 +84,10 @@ class ConfigureWidgetActivity : LockedActivity<ActivityConfigureWidgetBinding>()
adapter.submitList(notes)
}
}

preferences.notesSorting.observe(this) { (sortBy, sortDirection) ->
adapter.setSorting(sortBy, sortDirection)
}
}

override fun onClick(position: Int) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ abstract class NotallyFragment : Fragment(), ListItemListener {
BaseNoteAdapter(
model.actionMode.selectedIds,
dateFormat.value,
notesSorting.value.first,
textSize.value,
maxItems,
maxLines,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ import com.philkes.notallyx.databinding.ActivityEditBinding
import com.philkes.notallyx.databinding.DialogProgressBinding
import com.philkes.notallyx.presentation.activity.LockedActivity
import com.philkes.notallyx.presentation.view.Constants
import com.philkes.notallyx.presentation.view.misc.NotesSorting.autoSortByCreationDate
import com.philkes.notallyx.presentation.view.misc.NotesSorting.autoSortByModifiedDate
import com.philkes.notallyx.presentation.view.misc.TextSize
import com.philkes.notallyx.presentation.view.note.ErrorAdapter
import com.philkes.notallyx.presentation.view.note.audio.AudioAdapter
Expand Down Expand Up @@ -249,7 +251,14 @@ abstract class EditActivity(private val type: Type) : LockedActivity<ActivityEdi
}

open fun setStateFromModel() {
binding.DateCreated.displayFormattedTimestamp(model.timestamp, preferences.dateFormat.value)
val (date, datePrefixResId) =
when (preferences.notesSorting.value.first) {
autoSortByCreationDate -> Pair(model.timestamp, R.string.creation_date)
autoSortByModifiedDate -> Pair(model.modifiedTimestamp, R.string.modified_date)
else -> Pair(null, null)
}
binding.Date.displayFormattedTimestamp(date, preferences.dateFormat.value, datePrefixResId)

updateEnterTitle()
Operations.bindLabels(binding.LabelGroup, model.labels, model.textSize)

Expand Down Expand Up @@ -594,7 +603,7 @@ abstract class EditActivity(private val type: Type) : LockedActivity<ActivityEdi
val body = TextSize.getEditBodySize(model.textSize)

binding.EnterTitle.setTextSize(TypedValue.COMPLEX_UNIT_SP, title)
binding.DateCreated.setTextSize(TypedValue.COMPLEX_UNIT_SP, date)
binding.Date.setTextSize(TypedValue.COMPLEX_UNIT_SP, date)
binding.EnterBody.setTextSize(TypedValue.COMPLEX_UNIT_SP, body)

setupImages()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import java.io.File
class BaseNoteAdapter(
private val selectedIds: Set<Long>,
private val dateFormat: String,
private val sortedBy: String,
private val textSize: String,
private val maxItems: Int,
private val maxLines: Int,
Expand All @@ -48,7 +49,12 @@ class BaseNoteAdapter(
when (val item = list[position]) {
is Header -> (holder as HeaderVH).bind(item)
is BaseNote ->
(holder as BaseNoteVH).bind(item, imageRoot, selectedIds.contains(item.id))
(holder as BaseNoteVH).bind(
item,
imageRoot,
selectedIds.contains(item.id),
sortedBy,
)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import com.philkes.notallyx.data.model.ListItem
import com.philkes.notallyx.data.model.SpanRepresentation
import com.philkes.notallyx.data.model.Type
import com.philkes.notallyx.databinding.RecyclerBaseNoteBinding
import com.philkes.notallyx.presentation.view.misc.NotesSorting.autoSortByCreationDate
import com.philkes.notallyx.presentation.view.misc.NotesSorting.autoSortByModifiedDate
import com.philkes.notallyx.presentation.view.misc.TextSize
import com.philkes.notallyx.presentation.view.note.listitem.ListItemListener
import com.philkes.notallyx.utils.Operations
Expand Down Expand Up @@ -73,15 +75,21 @@ class BaseNoteVH(
binding.root.isChecked = checked
}

fun bind(baseNote: BaseNote, imageRoot: File?, checked: Boolean) {
fun bind(baseNote: BaseNote, imageRoot: File?, checked: Boolean, sortBy: String) {
updateCheck(checked)

when (baseNote.type) {
Type.NOTE -> bindNote(baseNote.body, baseNote.spans)
Type.LIST -> bindList(baseNote.items)
}
val (date, datePrefixResId) =
when (sortBy) {
autoSortByCreationDate -> Pair(baseNote.timestamp, R.string.creation_date)
autoSortByModifiedDate -> Pair(baseNote.modifiedTimestamp, R.string.modified_date)
else -> Pair(null, null)
}
binding.Date.displayFormattedTimestamp(date, dateFormat, datePrefixResId)

binding.Date.displayFormattedTimestamp(baseNote.timestamp, dateFormat)
setColor(baseNote.color)
setImages(baseNote.images, imageRoot)
setFiles(baseNote.files)
Expand Down Expand Up @@ -220,7 +228,7 @@ class BaseNoteVH(
private fun setFiles(files: List<FileAttachment>) {
binding.apply {
if (files.isNotEmpty()) {
FileView.visibility = View.VISIBLE
FileViewLayout.visibility = View.VISIBLE
FileView.text = files[0].originalName
if (files.size > 1) {
FileViewMore.apply {
Expand All @@ -231,8 +239,7 @@ class BaseNoteVH(
FileViewMore.visibility = View.GONE
}
} else {
FileView.visibility = View.GONE
FileViewMore.visibility = View.GONE
FileViewLayout.visibility = View.GONE
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ object DateFormat : ListInfo {
const val relative = "relative"
const val absolute = "absolute"

override val title = R.string.creation_date_format
override val title = R.string.date_format
override val key = "dateFormat"
override val defaultValue = relative

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import com.philkes.notallyx.data.model.BaseNote
import com.philkes.notallyx.data.model.Type
import com.philkes.notallyx.presentation.view.misc.TextSize
import com.philkes.notallyx.presentation.widget.WidgetProvider.Companion.getSelectNoteIntent
import com.philkes.notallyx.utils.displayFormattedTimestamp

class WidgetFactory(private val app: Application, private val id: Long, private val widgetId: Int) :
RemoteViewsService.RemoteViewsFactory {
Expand Down Expand Up @@ -71,9 +70,6 @@ class WidgetFactory(private val app: Application, private val id: Long, private

val bodyTextSize = TextSize.getDisplayBodySize(preferences.textSize.value)

setTextViewTextSize(R.id.Date, TypedValue.COMPLEX_UNIT_SP, bodyTextSize)
displayFormattedTimestamp(R.id.Date, note.timestamp, preferences.dateFormat.value)

setTextViewTextSize(R.id.Note, TypedValue.COMPLEX_UNIT_SP, bodyTextSize)
if (note.body.isNotEmpty()) {
setTextViewText(R.id.Note, note.body)
Expand All @@ -96,11 +92,6 @@ class WidgetFactory(private val app: Application, private val id: Long, private
)
setTextViewText(R.id.Title, list.title)

val bodyTextSize = TextSize.getDisplayBodySize(preferences.textSize.value)

setTextViewTextSize(R.id.Date, TypedValue.COMPLEX_UNIT_SP, bodyTextSize)
displayFormattedTimestamp(R.id.Date, list.timestamp, preferences.dateFormat.value)

val intent = Intent(WidgetProvider.ACTION_OPEN_LIST)
setOnClickFillInIntent(R.id.LinearLayout, intent)

Expand Down
23 changes: 10 additions & 13 deletions app/src/main/java/com/philkes/notallyx/utils/Extensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import android.view.inputmethod.InputMethodManager
import android.widget.EditText
import android.widget.RadioButton
import android.widget.RadioGroup
import android.widget.RemoteViews
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity.INPUT_METHOD_SERVICE
import androidx.appcompat.app.AppCompatActivity.KEYGUARD_SERVICE
Expand Down Expand Up @@ -183,20 +182,18 @@ fun Menu.add(
return menuItem
}

fun TextView.displayFormattedTimestamp(timestamp: Long, dateFormat: String) {
if (dateFormat != DateFormat.none) {
fun TextView.displayFormattedTimestamp(
timestamp: Long?,
dateFormat: String,
prefixResId: Int? = null,
) {
if (dateFormat != DateFormat.none && timestamp != null) {
visibility = View.VISIBLE
text = formatTimestamp(timestamp, dateFormat)
text =
"${prefixResId?.let { getString(it) } ?: ""} ${formatTimestamp(timestamp, dateFormat)}"
} else visibility = View.GONE
}

fun RemoteViews.displayFormattedTimestamp(id: Int, timestamp: Long, dateFormat: String) {
if (dateFormat != DateFormat.none) {
setViewVisibility(id, View.VISIBLE)
setTextViewText(id, formatTimestamp(timestamp, dateFormat))
} else setViewVisibility(id, View.GONE)
}

val Int.dp: Int
get() = (this / Resources.getSystem().displayMetrics.density).roundToInt()

Expand Down Expand Up @@ -264,8 +261,8 @@ fun EditText.createTextWatcherWithHistory(

fun Editable.clone(): Editable = Editable.Factory.getInstance().newEditable(this)

fun View.getQuantityString(id: Int, quantity: Int): String {
return context.resources.getQuantityString(id, quantity, quantity)
fun View.getString(id: Int, vararg formatArgs: String): String {
return context.resources.getString(id, *formatArgs)
}

fun View.getQuantityString(id: Int, quantity: Int, vararg formatArgs: Any): String {
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/com/philkes/notallyx/utils/backup/Import.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ import net.lingala.zip4j.exception.ZipException
object Import {

/**
* We only import the images/files referenced in notes. e.g If someone has added garbage to the ZIP
* file, like a 100 MB image, ignore it.
* We only import the images/files referenced in notes. e.g If someone has added garbage to the
* ZIP file, like a 100 MB image, ignore it.
*/
suspend fun importZip(
app: Application,
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_edit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
android:textAppearance="?attr/textAppearanceHeadline6" />

<TextView
android:id="@+id/DateCreated"
android:id="@+id/Date"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="24dp"
Expand Down
6 changes: 4 additions & 2 deletions app/src/main/res/layout/recycler_base_note.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
<Space
android:id="@+id/Space"
android:layout_width="match_parent"
android:layout_height="16dp"
android:layout_height="14dp"
app:layout_constraintTop_toBottomOf="@id/Message" />

<TextView
Expand All @@ -76,6 +76,7 @@
android:fontFamily="sans-serif-medium"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:paddingBottom="8dp"
android:textAppearance="?attr/textAppearanceBody1"
android:textColor="?attr/colorOnSurface"
app:layout_constraintTop_toBottomOf="@id/Space" />
Expand All @@ -87,14 +88,15 @@
android:layout_height="wrap_content"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:paddingBottom="2dp"
android:paddingBottom="6dp"
app:layout_constraintTop_toBottomOf="@id/Title" />

<LinearLayout
android:id="@+id/FileViewLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingTop="0dp"
android:paddingBottom="4dp"
app:layout_constraintTop_toBottomOf="@id/Date"
>
Expand Down
10 changes: 0 additions & 10 deletions app/src/main/res/layout/widget_list_header.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,4 @@

</LinearLayout>



<TextView
android:id="@+id/Date"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="16dp"
android:textAppearance="?attr/textAppearanceBody2"
android:textColor="?android:textColorSecondary" />

</LinearLayout>
8 changes: 0 additions & 8 deletions app/src/main/res/layout/widget_note.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,6 @@
android:drawableLeft="@drawable/document_scanner" />
</LinearLayout>

<TextView
android:id="@+id/Date"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="16dp"
android:textAppearance="@style/TextAppearance.MaterialComponents.Body2"
android:textColor="?android:textColorSecondary" />

<TextView
android:id="@+id/Note"
android:layout_width="match_parent"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-cs/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
<string name="light">Světlé</string>
<string name="follow_system">Podle systému</string>

<string name="creation_date_format">Formát data</string>
<string name="date_format">Formát data</string>
<string name="none">Žádné</string>

<string name="text_size">Velikost písma</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
<string name="light">Hell</string>
<string name="follow_system">Systemeinstellung folgen</string>

<string name="creation_date_format">Datumsformat</string>
<string name="date_format">Datumsformat</string>
<string name="none">Keines</string>

<string name="text_size">Textgröße</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-el/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
<string name="light">Φωτεινό</string>
<string name="follow_system">Ακολούθηση συστήματος</string>

<string name="creation_date_format">Μορφή ημερομηνίας</string>
<string name="date_format">Μορφή ημερομηνίας</string>
<string name="none">Καμία</string>

<string name="content_density">Πυκνότητα περιεχομένου</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
<string name="list">Lista</string>
<string name="grid">Cuadrícula</string>

<string name="creation_date_format">Formato de fecha</string>
<string name="date_format">Formato de fecha</string>
<string name="none">Ninguno</string>

<string name="text_size">Tamaño de texto</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
<string name="light">Lumineux</string>
<string name="follow_system">En fonction du système</string>

<string name="creation_date_format">Format de la date</string>
<string name="date_format">Format de la date</string>
<string name="none">Aucun</string>

<string name="text_size">Taille du texte</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-in/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
<string name="light">Terang</string>
<string name="follow_system">Ikuti sistem</string>

<string name="creation_date_format">Format tanggal</string>
<string name="date_format">Format tanggal</string>
<string name="none">Tidak ada</string>

<string name="content_density">Kerapatan konten</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-it/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
<string name="light">Chiaro</string>
<string name="follow_system">Tema di Sistema</string>

<string name="creation_date_format">Formato data</string>
<string name="date_format">Formato data</string>
<string name="none">Nessuno</string>

<string name="content_density">Densità del contenuto</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-ja/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
<string name="light">ライト</string>
<string name="follow_system">システムのテーマを使用</string>

<string name="creation_date_format">日付の表示</string>
<string name="date_format">日付の表示</string>
<string name="none">表示しない</string>

<string name="content_density">プレビュー</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-my/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
<string name="light">အလင်း</string>
<string name="follow_system">ဖုန်းအတိုင်း</string>

<string name="creation_date_format">နေ့ရက်ပုံစံ</string>
<string name="date_format">နေ့ရက်ပုံစံ</string>
<string name="none">ဘာမှမရှိ</string>

<string name="text_size">စာလလုံးအရွယ်အစား</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-nb/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
<string name="light">Lyst</string>
<string name="follow_system">Følg systemet</string>

<string name="creation_date_format">Datoformat</string>
<string name="date_format">Datoformat</string>
<string name="none">Ikke vis</string>

<string name="text_size">Skriftstørrelse</string>
Expand Down
Loading