mirror of
https://github.com/SimpleMobileTools/Simple-Notes.git
synced 2025-03-23 20:10:07 +01:00
Added monospaced font to widgets (#292)
This commit is contained in:
parent
8d8ab9554d
commit
f18a223f8b
@ -109,6 +109,7 @@ class SettingsActivity : SimpleActivity() {
|
||||
settings_monospaced_font_holder.setOnClickListener {
|
||||
settings_monospaced_font.toggle()
|
||||
config.monospacedFont = settings_monospaced_font.isChecked
|
||||
updateWidgets()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import android.app.Activity
|
||||
import android.appwidget.AppWidgetManager
|
||||
import android.content.Intent
|
||||
import android.graphics.Color
|
||||
import android.graphics.Typeface
|
||||
import android.graphics.drawable.ColorDrawable
|
||||
import android.os.Bundle
|
||||
import android.util.TypedValue
|
||||
@ -166,6 +167,7 @@ class WidgetConfigureActivity : SimpleActivity() {
|
||||
} else {
|
||||
val sampleValue = if (note.value.isEmpty() || mIsCustomizingColors) getString(R.string.widget_config) else note.value
|
||||
text_note_view.text = sampleValue
|
||||
text_note_view.typeface = if (config.monospacedFont) Typeface.MONOSPACE else Typeface.DEFAULT
|
||||
text_note_view.beVisible()
|
||||
checklist_note_view.beGone()
|
||||
}
|
||||
|
@ -23,7 +23,8 @@ import com.simplemobiletools.notes.pro.models.ChecklistItem
|
||||
import com.simplemobiletools.notes.pro.models.Note
|
||||
|
||||
class WidgetAdapter(val context: Context, val intent: Intent) : RemoteViewsService.RemoteViewsFactory {
|
||||
private val textIds = arrayOf(R.id.widget_text_left, R.id.widget_text_center, R.id.widget_text_right)
|
||||
private val textIds = arrayOf(R.id.widget_text_left, R.id.widget_text_center, R.id.widget_text_right,
|
||||
R.id.widget_text_left_monospace, R.id.widget_text_center_monospace, R.id.widget_text_right_monospace)
|
||||
private var widgetTextColor = DEFAULT_WIDGET_TEXT_COLOR
|
||||
private var note: Note? = null
|
||||
private var checklistItems = ArrayList<ChecklistItem>()
|
||||
@ -75,10 +76,18 @@ class WidgetAdapter(val context: Context, val intent: Intent) : RemoteViewsServi
|
||||
return remoteView
|
||||
}
|
||||
|
||||
private fun getProperTextView(context: Context) = when (context.config.gravity) {
|
||||
GRAVITY_CENTER -> R.id.widget_text_center
|
||||
GRAVITY_RIGHT -> R.id.widget_text_right
|
||||
else -> R.id.widget_text_left
|
||||
private fun getProperTextView(context: Context): Int {
|
||||
val gravity = context.config.gravity
|
||||
val isMonospaced = context.config.monospacedFont
|
||||
|
||||
return when {
|
||||
gravity == GRAVITY_CENTER && isMonospaced -> R.id.widget_text_center_monospace
|
||||
gravity == GRAVITY_CENTER -> R.id.widget_text_center
|
||||
gravity == GRAVITY_RIGHT && isMonospaced -> R.id.widget_text_right_monospace
|
||||
gravity == GRAVITY_RIGHT -> R.id.widget_text_right
|
||||
isMonospaced -> R.id.widget_text_left_monospace
|
||||
else -> R.id.widget_text_left
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreate() {}
|
||||
|
@ -31,4 +31,34 @@
|
||||
android:padding="@dimen/small_margin"
|
||||
android:visibility="gone" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/widget_text_left_monospace"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@null"
|
||||
android:gravity="start"
|
||||
android:fontFamily="monospace"
|
||||
android:padding="@dimen/small_margin"
|
||||
android:visibility="gone" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/widget_text_center_monospace"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@null"
|
||||
android:gravity="center_horizontal"
|
||||
android:fontFamily="monospace"
|
||||
android:padding="@dimen/small_margin"
|
||||
android:visibility="gone" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/widget_text_right_monospace"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@null"
|
||||
android:gravity="end"
|
||||
android:fontFamily="monospace"
|
||||
android:padding="@dimen/small_margin"
|
||||
android:visibility="gone" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
Loading…
x
Reference in New Issue
Block a user