mirror of
https://git.sr.ht/~oppen/ariane
synced 2024-12-21 23:44:30 +00:00
full screen dialog... for add bookmark
This commit is contained in:
parent
4eebeba37b
commit
1a3fc1083a
12 changed files with 122 additions and 21 deletions
|
@ -1,6 +1,22 @@
|
|||
<component name="ProjectCodeStyleConfiguration">
|
||||
<code_scheme name="Project" version="173">
|
||||
<JetCodeStyleSettings>
|
||||
<option name="PACKAGES_TO_USE_STAR_IMPORTS">
|
||||
<value>
|
||||
<package name="java.util" alias="false" withSubpackages="false" />
|
||||
<package name="kotlinx.android.synthetic" alias="false" withSubpackages="true" />
|
||||
<package name="io.ktor" alias="false" withSubpackages="true" />
|
||||
</value>
|
||||
</option>
|
||||
<option name="PACKAGES_IMPORT_LAYOUT">
|
||||
<value>
|
||||
<package name="" alias="false" withSubpackages="true" />
|
||||
<package name="java" alias="false" withSubpackages="true" />
|
||||
<package name="javax" alias="false" withSubpackages="true" />
|
||||
<package name="kotlin" alias="false" withSubpackages="true" />
|
||||
<package name="" alias="true" withSubpackages="true" />
|
||||
</value>
|
||||
</option>
|
||||
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
|
||||
</JetCodeStyleSettings>
|
||||
<codeStyleSettings language="XML">
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
|
||||
<application
|
||||
android:name=".Tva"
|
||||
android:name=".Gem"
|
||||
android:allowBackup="true"
|
||||
android:icon="@drawable/vector_app_icon"
|
||||
android:label="@string/app_name"
|
||||
|
@ -14,7 +14,7 @@
|
|||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme"
|
||||
android:networkSecurityConfig="@xml/network_security_config">
|
||||
<activity android:name=".ui.TvaActivity">
|
||||
<activity android:name=".ui.GemActivity">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
|
|
|
@ -2,7 +2,7 @@ package oppen.tva
|
|||
|
||||
import android.app.Application
|
||||
|
||||
class Tva: Application() {
|
||||
class Gem: Application() {
|
||||
|
||||
companion object{
|
||||
const val DEFAULT_HOME_CAPSULE = "gemini://gemini.circumlunar.space/~oppen/gem/index.gmi"
|
|
@ -9,13 +9,14 @@ import android.view.inputmethod.EditorInfo
|
|||
import androidx.activity.viewModels
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.appcompat.app.AppCompatDialog
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
import oppen.hideKeyboard
|
||||
import oppen.tva.R
|
||||
import oppen.tva.Tva
|
||||
import oppen.tva.databinding.ActivityTvaBinding
|
||||
import oppen.tva.Gem
|
||||
import oppen.tva.databinding.ActivityGemBinding
|
||||
import oppen.tva.io.GemState
|
||||
import oppen.tva.io.bookmarks.BookmarksDatasource
|
||||
import oppen.tva.io.gemini.Datasource
|
||||
|
@ -23,6 +24,7 @@ import oppen.tva.io.gemini.GeminiResponse
|
|||
import oppen.tva.io.gemini.RuntimeCache
|
||||
import oppen.tva.io.history.uris.HistoryInterface
|
||||
import oppen.tva.ui.audio_player.AudioPlayer
|
||||
import oppen.tva.ui.bookmarks.BookmarkDialog
|
||||
import oppen.tva.ui.content_image.ImageDialog
|
||||
import oppen.tva.ui.content_text.TextDialog
|
||||
import oppen.tva.ui.modals_menus.about.AboutDialog
|
||||
|
@ -40,14 +42,14 @@ import java.net.URLEncoder
|
|||
const val CREATE_IMAGE_FILE_REQ = 628
|
||||
const val CREATE_AUDIO_FILE_REQ = 629
|
||||
|
||||
class TvaActivity : AppCompatActivity() {
|
||||
class GemActivity : AppCompatActivity() {
|
||||
|
||||
private var inSearch = false
|
||||
|
||||
private val mediaPlayer = MediaPlayer()
|
||||
|
||||
private val model by viewModels<TvaViewModel>()
|
||||
private lateinit var binding: ActivityTvaBinding
|
||||
private val model by viewModels<GemViewModel>()
|
||||
private lateinit var binding: ActivityGemBinding
|
||||
private lateinit var history: HistoryInterface
|
||||
private val adapter = GemtextAdapter { uri, longTap, view ->
|
||||
if(longTap){
|
||||
|
@ -75,7 +77,7 @@ class TvaActivity : AppCompatActivity() {
|
|||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
binding = DataBindingUtil.setContentView(this, R.layout.activity_tva)
|
||||
binding = DataBindingUtil.setContentView(this, R.layout.activity_gem)
|
||||
binding.viewmodel = model
|
||||
binding.lifecycleOwner = this
|
||||
|
||||
|
@ -117,7 +119,7 @@ class TvaActivity : AppCompatActivity() {
|
|||
if(input.startsWith("gemini://")){
|
||||
model.request(input)
|
||||
}else{
|
||||
model.request("${Tva.GEMINI_USER_SEARCH_BASE}${URLEncoder.encode(input, "UTF-8")}")
|
||||
model.request("${Gem.GEMINI_USER_SEARCH_BASE}${URLEncoder.encode(input, "UTF-8")}")
|
||||
}
|
||||
|
||||
binding.addressEdit.hideKeyboard()
|
||||
|
@ -138,14 +140,14 @@ class TvaActivity : AppCompatActivity() {
|
|||
inSearch = true
|
||||
}
|
||||
R.id.overflow_menu_bookmark -> {
|
||||
//todo
|
||||
BookmarkDialog(this, "test", "test").show()
|
||||
}
|
||||
R.id.overflow_menu_bookmarks -> {
|
||||
//todo
|
||||
}
|
||||
R.id.overflow_menu_backlinks -> {
|
||||
val currentAddress = binding.addressEdit.text.toString()
|
||||
val backlinkAddress = "${Tva.GEMINI_BACKLINK_BASE}$currentAddress"
|
||||
val backlinkAddress = "${Gem.GEMINI_BACKLINK_BASE}$currentAddress"
|
||||
model.request(backlinkAddress)
|
||||
}
|
||||
R.id.overflow_menu_share -> {
|
||||
|
@ -175,7 +177,7 @@ class TvaActivity : AppCompatActivity() {
|
|||
}
|
||||
binding.home.setOnClickListener {
|
||||
val prefs = getSharedPreferences("oppen.tva.ui.dialogs.set_home", Context.MODE_PRIVATE)
|
||||
val home = prefs.getString("home", Tva.DEFAULT_HOME_CAPSULE)
|
||||
val home = prefs.getString("home", Gem.DEFAULT_HOME_CAPSULE)
|
||||
model.request(home!!)
|
||||
}
|
||||
}
|
|
@ -1,13 +1,13 @@
|
|||
package oppen.tva.ui
|
||||
|
||||
import androidx.lifecycle.ViewModel
|
||||
import oppen.tva.Tva
|
||||
import oppen.tva.Gem
|
||||
import oppen.tva.io.gemini.Datasource
|
||||
import oppen.tva.io.GemState
|
||||
import oppen.tva.io.bookmarks.BookmarksDatasource
|
||||
import java.net.URI
|
||||
|
||||
class TvaViewModel: ViewModel() {
|
||||
class GemViewModel: ViewModel() {
|
||||
|
||||
private lateinit var gemini: Datasource
|
||||
private lateinit var bookmarks: BookmarksDatasource
|
||||
|
@ -20,7 +20,7 @@ class TvaViewModel: ViewModel() {
|
|||
this.bookmarks = bookmarks
|
||||
this.onState = onState
|
||||
|
||||
request(URI.create(Tva.DEFAULT_HOME_CAPSULE))//todo - regression: should check prefs...
|
||||
request(URI.create(Gem.DEFAULT_HOME_CAPSULE))//todo - regression: should check prefs...
|
||||
onState(GemState.TabChange(1))
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,6 @@ class TvaViewModel: ViewModel() {
|
|||
@ExperimentalStdlibApi
|
||||
fun goBack(){
|
||||
when {
|
||||
|
||||
history.size >= 2 -> {
|
||||
logHistory()
|
||||
val previous = history[history.size - 2]
|
|
@ -7,14 +7,14 @@ import android.view.MenuInflater
|
|||
import androidx.appcompat.widget.PopupMenu
|
||||
import androidx.core.view.MenuCompat
|
||||
import oppen.tva.R
|
||||
import oppen.tva.databinding.ActivityTvaBinding
|
||||
import oppen.tva.databinding.ActivityGemBinding
|
||||
import oppen.tva.io.GemState
|
||||
import oppen.visible
|
||||
|
||||
object AudioPlayer {
|
||||
|
||||
fun play(context: Context,
|
||||
binding: ActivityTvaBinding,
|
||||
binding: ActivityGemBinding,
|
||||
mediaPlayer: MediaPlayer,
|
||||
state: GemState.ResponseAudio,
|
||||
onSaveAudio: (state: GemState.ResponseAudio) -> Unit){
|
||||
|
|
30
app/src/main/java/oppen/tva/ui/bookmarks/BookmarkDialog.kt
Normal file
30
app/src/main/java/oppen/tva/ui/bookmarks/BookmarkDialog.kt
Normal file
|
@ -0,0 +1,30 @@
|
|||
package oppen.tva.ui.bookmarks
|
||||
|
||||
import android.app.Dialog
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.WindowManager
|
||||
import androidx.appcompat.app.AppCompatDialog
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import kotlinx.android.synthetic.main.fragment_bookmark_dialog.view.*
|
||||
import oppen.tva.R
|
||||
|
||||
|
||||
class BookmarkDialog(context: Context, val uri: String, val name: String): AppCompatDialog(context, R.style.FSDialog) {
|
||||
|
||||
init {
|
||||
setContentView(R.layout.fragment_bookmark_dialog)
|
||||
//getWindow()?.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
}
|
||||
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
6
app/src/main/res/anim/fade_in.xml
Normal file
6
app/src/main/res/anim/fade_in.xml
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:fromAlpha="1.0"
|
||||
android:toAlpha="0.0"
|
||||
android:duration="1000"
|
||||
/>
|
|
@ -1,7 +1,7 @@
|
|||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<data>
|
||||
<variable name="viewmodel" type="oppen.tva.ui.TvaViewModel" />
|
||||
<variable name="viewmodel" type="oppen.tva.ui.GemViewModel" />
|
||||
</data>
|
||||
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
|
@ -9,7 +9,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true"
|
||||
tools:context=".ui.TvaActivity">
|
||||
tools:context=".ui.GemActivity">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:id="@+id/app_bar"
|
43
app/src/main/res/layout/fragment_bookmark_dialog.xml
Normal file
43
app/src/main/res/layout/fragment_bookmark_dialog.xml
Normal file
|
@ -0,0 +1,43 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/bookmark_toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?actionBarSize"
|
||||
app:title="Add Bookmark"/>
|
||||
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/bookmark_toolbar"
|
||||
android:padding="@dimen/default_margin_big"
|
||||
android:orientation="vertical">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/name" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatEditText
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxLines="1"/>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/gemini_uri" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatEditText
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxLines="1"/>
|
||||
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
||||
|
||||
</RelativeLayout>
|
|
@ -29,4 +29,6 @@
|
|||
<string name="page_backlinks">Backlinks</string>
|
||||
<string name="add_bookmark">Add Bookmark</string>
|
||||
<string name="bookmarks">Bookmarks</string>
|
||||
<string name="name">Name</string>
|
||||
<string name="gemini_uri">Gemini URL</string>
|
||||
</resources>
|
|
@ -10,6 +10,9 @@
|
|||
<item name="android:windowLightStatusBar" tools:targetApi="m">true</item>
|
||||
</style>
|
||||
|
||||
<style name="FSDialog" parent="@style/AppTheme">
|
||||
|
||||
</style>
|
||||
|
||||
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
|
||||
|
||||
|
|
Loading…
Reference in a new issue