fix: various bugs for android
This commit is contained in:
parent
91f0baf75c
commit
117968bd17
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,6 +1,5 @@
|
|||||||
/target
|
/target
|
||||||
/lock.mdb
|
/ndb
|
||||||
/data.mdb
|
|
||||||
/.idea
|
/.idea
|
||||||
/cache
|
/cache
|
||||||
/ffmpeg-kit
|
/ffmpeg-kit
|
26
android.sh
26
android.sh
@ -2,27 +2,27 @@
|
|||||||
|
|
||||||
git clone https://github.com/v0l/ffmpeg-kit.git
|
git clone https://github.com/v0l/ffmpeg-kit.git
|
||||||
export ANDROID_SDK_ROOT=$ANDROID_HOME
|
export ANDROID_SDK_ROOT=$ANDROID_HOME
|
||||||
#cd ffmpeg-kit && ./android.sh \
|
cd ffmpeg-kit && ./android.sh \
|
||||||
# --disable-x86 \
|
--disable-x86 \
|
||||||
# --disable-x86-64 \
|
--disable-x86-64 \
|
||||||
# --disable-arm-v7a \
|
--disable-arm-v7a \
|
||||||
# --disable-arm-v7a-neon \
|
--disable-arm-v7a-neon \
|
||||||
# --no-ffmpeg-kit-protocols \
|
--enable-openssl \
|
||||||
# --no-archive
|
--api-level=28 \
|
||||||
|
--no-ffmpeg-kit-protocols \
|
||||||
if [[ $? -ne 0 ]]; then
|
--no-archive
|
||||||
exit 1;
|
|
||||||
fi
|
|
||||||
|
|
||||||
NDK_VER="28.0.12433566"
|
NDK_VER="28.0.12433566"
|
||||||
ARCH="arm64"
|
ARCH="arm64"
|
||||||
PLATFORM="android"
|
PLATFORM="android"
|
||||||
TRIPLET="aarch64-linux-android"
|
TRIPLET="aarch64-linux-android"
|
||||||
export PKG_CONFIG_SYSROOT_DIR="/"
|
|
||||||
export FFMPEG_DIR="$(pwd)/ffmpeg-kit/prebuilt/$PLATFORM-$ARCH/ffmpeg"
|
export FFMPEG_DIR="$(pwd)/ffmpeg-kit/prebuilt/$PLATFORM-$ARCH/ffmpeg"
|
||||||
|
export PKG_CONFIG_SYSROOT_DIR="$(pwd)/ffmpeg-kit/prebuilt/$PLATFORM-$ARCH/pkgconfig"
|
||||||
|
|
||||||
# DIRTY HACK !!
|
# DIRTY HACK !!
|
||||||
cp "$ANDROID_HOME/ndk/$NDK_VER/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/$TRIPLET/35/libcamera2ndk.so" \
|
cp "$ANDROID_HOME/ndk/$NDK_VER/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/$TRIPLET/35/libcamera2ndk.so" \
|
||||||
./target/x/debug/android/$ARCH/cargo/$TRIPLET/debug/deps
|
./target/x/debug/android/$ARCH/cargo/$TRIPLET/debug/deps
|
||||||
|
cp "$ANDROID_HOME/ndk/$NDK_VER/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/$TRIPLET/35/libcamera2ndk.so" \
|
||||||
|
./target/x/release/android/$ARCH/cargo/$TRIPLET/release/deps
|
||||||
|
|
||||||
x build --arch $ARCH --platform $PLATFORM --verbose
|
x build --arch $ARCH --platform $PLATFORM --verbose --release
|
||||||
|
@ -58,6 +58,10 @@ impl ImageCache {
|
|||||||
if let Err(e) = tokio::fs::write(path, data.bytes().await.unwrap()).await {
|
if let Err(e) = tokio::fs::write(path, data.bytes().await.unwrap()).await {
|
||||||
error!("Failed to write file: {}", e);
|
error!("Failed to write file: {}", e);
|
||||||
}
|
}
|
||||||
|
// forget cached url
|
||||||
|
for t in ctx.loaders().texture.lock().iter() {
|
||||||
|
t.forget(&u);
|
||||||
|
}
|
||||||
ctx.request_repaint();
|
ctx.request_repaint();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ use crate::services::query::QueryManager;
|
|||||||
use egui::CursorIcon::Default;
|
use egui::CursorIcon::Default;
|
||||||
use log::{info, warn};
|
use log::{info, warn};
|
||||||
use nostr_sdk::secp256k1::Context;
|
use nostr_sdk::secp256k1::Context;
|
||||||
use nostr_sdk::{Client, JsonUtil, Kind, RelayPoolNotification};
|
use nostr_sdk::{nostr, Client, JsonUtil, Kind, PublicKey, RelayPoolNotification};
|
||||||
use nostrdb::{
|
use nostrdb::{
|
||||||
Error, Filter, Ndb, NdbProfile, Note, NoteKey, ProfileRecord, QueryResult, Subscription,
|
Error, Filter, Ndb, NdbProfile, Note, NoteKey, ProfileRecord, QueryResult, Subscription,
|
||||||
Transaction,
|
Transaction,
|
||||||
@ -142,6 +142,14 @@ impl NDBWrapper {
|
|||||||
.get_profile_by_pubkey(tx, pubkey)
|
.get_profile_by_pubkey(tx, pubkey)
|
||||||
.map_or(None, |p| p.record().profile());
|
.map_or(None, |p| p.record().profile());
|
||||||
|
|
||||||
|
// TODO: fix this shit
|
||||||
|
if p.is_none() {
|
||||||
|
self.query_manager.queue_query("profile", &[
|
||||||
|
nostr::Filter::new()
|
||||||
|
.kinds([Kind::Metadata])
|
||||||
|
.authors([PublicKey::from_slice(pubkey).unwrap()])
|
||||||
|
])
|
||||||
|
}
|
||||||
let sub = None;
|
let sub = None;
|
||||||
(p, sub)
|
(p, sub)
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ use chrono::Utc;
|
|||||||
use log::{error, info};
|
use log::{error, info};
|
||||||
use nostr_sdk::prelude::StreamExt;
|
use nostr_sdk::prelude::StreamExt;
|
||||||
use nostr_sdk::Kind::Metadata;
|
use nostr_sdk::Kind::Metadata;
|
||||||
use nostr_sdk::{Client, Filter, SubscriptionId};
|
use nostr_sdk::{Client, Filter, SubscribeAutoCloseOptions, SubscriptionId};
|
||||||
use std::collections::{HashMap, HashSet, VecDeque};
|
use std::collections::{HashMap, HashSet, VecDeque};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
@ -75,6 +75,16 @@ impl Query {
|
|||||||
.authors(next.iter().flat_map(|f| f.authors.as_ref().unwrap().clone()))
|
.authors(next.iter().flat_map(|f| f.authors.as_ref().unwrap().clone()))
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// remove filters already sent
|
||||||
|
next = next
|
||||||
|
.into_iter()
|
||||||
|
.filter(|f| !self.traces.iter().all(|y| y.filters.iter().any(|z| z.eq(f))))
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
if next.len() == 0 {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
Some(QueryTrace {
|
Some(QueryTrace {
|
||||||
id,
|
id,
|
||||||
filters: next,
|
filters: next,
|
||||||
@ -168,7 +178,7 @@ where
|
|||||||
#[async_trait::async_trait]
|
#[async_trait::async_trait]
|
||||||
impl QueryClient for Client {
|
impl QueryClient for Client {
|
||||||
async fn subscribe(&self, id: &str, filters: &[QueryFilter]) -> Result<(), Error> {
|
async fn subscribe(&self, id: &str, filters: &[QueryFilter]) -> Result<(), Error> {
|
||||||
self.subscribe_with_id(SubscriptionId::new(id), filters.into(), None)
|
self.subscribe_with_id(SubscriptionId::new(id), filters.into(), Some(SubscribeAutoCloseOptions::default()))
|
||||||
.await?;
|
.await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
use crate::route::RouteServices;
|
use crate::services::image_cache::ImageCache;
|
||||||
use crate::services::ndb_wrapper::SubWrapper;
|
use crate::services::ndb_wrapper::SubWrapper;
|
||||||
use egui::{Color32, Image, Pos2, Response, Rounding, Sense, Ui, Vec2, Widget};
|
use egui::{Color32, Image, Pos2, Response, Rounding, Sense, Ui, Vec2, Widget};
|
||||||
|
use nostrdb::NdbProfile;
|
||||||
|
|
||||||
pub struct Avatar<'a> {
|
pub struct Avatar<'a> {
|
||||||
image: Option<Image<'a>>,
|
image: Option<Image<'a>>,
|
||||||
@ -25,13 +26,12 @@ impl<'a> Avatar<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn pubkey(pk: &[u8; 32], svc: &RouteServices<'a>) -> Self {
|
pub fn from_profile(p: Option<NdbProfile<'a>>, svc: &'a ImageCache) -> Self {
|
||||||
let (img, sub) = svc.ndb.fetch_profile(svc.tx, pk);
|
let img = p
|
||||||
|
.map_or(None, |f| f.picture().map(|f| svc.load(f)));
|
||||||
Self {
|
Self {
|
||||||
image: img
|
image: img,
|
||||||
.map_or(None, |p| p.picture())
|
sub: None,
|
||||||
.map(|p| svc.img_cache.load(p)),
|
|
||||||
sub,
|
|
||||||
size: None,
|
size: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,9 +30,6 @@ impl<'a> Widget for ChatMessage<'a> {
|
|||||||
let name = self
|
let name = self
|
||||||
.profile.0
|
.profile.0
|
||||||
.map_or("Nostrich", |f| f.name().map_or("Nostrich", |f| f));
|
.map_or("Nostrich", |f| f.name().map_or("Nostrich", |f| f));
|
||||||
let img = self
|
|
||||||
.profile.0
|
|
||||||
.map_or(None, |f| f.picture().map(|f| self.services.img_cache.load(f)));
|
|
||||||
|
|
||||||
let name_color = if is_host {
|
let name_color = if is_host {
|
||||||
PRIMARY
|
PRIMARY
|
||||||
@ -49,7 +46,7 @@ impl<'a> Widget for ChatMessage<'a> {
|
|||||||
format.color = Color32::WHITE;
|
format.color = Color32::WHITE;
|
||||||
job.append(self.ev.content(), 5.0, format.clone());
|
job.append(self.ev.content(), 5.0, format.clone());
|
||||||
|
|
||||||
ui.add(Avatar::new_optional(img).size(24.));
|
ui.add(Avatar::from_profile(self.profile.0, self.services.img_cache).size(24.));
|
||||||
ui.add(Label::new(job)
|
ui.add(Label::new(job)
|
||||||
.wrap_mode(TextWrapMode::Wrap)
|
.wrap_mode(TextWrapMode::Wrap)
|
||||||
);
|
);
|
||||||
|
@ -25,7 +25,7 @@ impl NostrWidget for Header {
|
|||||||
|ui| {
|
|ui| {
|
||||||
ui.style_mut().spacing.item_spacing.x = 16.;
|
ui.style_mut().spacing.item_spacing.x = 16.;
|
||||||
if Image::from_bytes("logo.svg", logo_bytes)
|
if Image::from_bytes("logo.svg", logo_bytes)
|
||||||
.max_height(22.62)
|
.max_height(24.)
|
||||||
.sense(Sense::click())
|
.sense(Sense::click())
|
||||||
.ui(ui)
|
.ui(ui)
|
||||||
.clicked()
|
.clicked()
|
||||||
@ -33,7 +33,7 @@ impl NostrWidget for Header {
|
|||||||
services.navigate(Routes::HomePage);
|
services.navigate(Routes::HomePage);
|
||||||
}
|
}
|
||||||
if let Some(pk) = services.login {
|
if let Some(pk) = services.login {
|
||||||
ui.add(Avatar::pubkey(pk, services));
|
//ui.add(Avatar::pubkey(pk, services));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
@ -12,6 +12,7 @@ impl StreamPlayer {
|
|||||||
let mut audio = AudioDevice::new().unwrap();
|
let mut audio = AudioDevice::new().unwrap();
|
||||||
Self {
|
Self {
|
||||||
player: Player::new(ctx, url).map_or(None, |mut f| {
|
player: Player::new(ctx, url).map_or(None, |mut f| {
|
||||||
|
f.add_audio(&mut audio).expect("Failed to add audio");
|
||||||
f.start();
|
f.start();
|
||||||
Some(f)
|
Some(f)
|
||||||
}),
|
}),
|
||||||
@ -27,7 +28,6 @@ impl Widget for &mut StreamPlayer {
|
|||||||
let size = Vec2::new(w, h);
|
let size = Vec2::new(w, h);
|
||||||
|
|
||||||
if let Some(mut p) = self.player.as_mut() {
|
if let Some(mut p) = self.player.as_mut() {
|
||||||
p.add_audio(&mut self.audio).expect("Failed to add audio to stream player");
|
|
||||||
p.ui(ui, size)
|
p.ui(ui, size)
|
||||||
} else {
|
} else {
|
||||||
VideoPlaceholder.ui(ui)
|
VideoPlaceholder.ui(ui)
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
use crate::link::NostrLink;
|
use crate::link::NostrLink;
|
||||||
use crate::note_util::NoteUtil;
|
use crate::note_util::NoteUtil;
|
||||||
use crate::route::{RouteServices, Routes};
|
use crate::route::{RouteServices, Routes};
|
||||||
|
use crate::stream_info::StreamInfo;
|
||||||
use crate::widgets::avatar::Avatar;
|
use crate::widgets::avatar::Avatar;
|
||||||
use crate::widgets::VideoPlaceholder;
|
use crate::widgets::VideoPlaceholder;
|
||||||
use eframe::epaint::Vec2;
|
use eframe::epaint::Vec2;
|
||||||
use egui::{Color32, Image, Label, Response, RichText, Rounding, Sense, TextWrapMode, Ui, Widget};
|
use egui::{Color32, Image, Label, Response, RichText, Rounding, Sense, TextWrapMode, Ui, Widget};
|
||||||
use nostrdb::{NdbStrVariant, Note};
|
use nostrdb::{NdbProfile, Note};
|
||||||
use crate::stream_info::StreamInfo;
|
|
||||||
|
|
||||||
pub struct StreamEvent<'a> {
|
pub struct StreamEvent<'a> {
|
||||||
event: &'a Note<'a>,
|
event: &'a Note<'a>,
|
||||||
@ -56,7 +56,7 @@ impl Widget for StreamEvent<'_> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
ui.horizontal(|ui| {
|
ui.horizontal(|ui| {
|
||||||
ui.add(Avatar::pubkey(&host, self.services).size(40.));
|
ui.add(Avatar::from_profile(None, self.services.img_cache).size(40.));
|
||||||
let title = RichText::new(self.event.title().unwrap_or("Untitled"))
|
let title = RichText::new(self.event.title().unwrap_or("Untitled"))
|
||||||
.size(16.)
|
.size(16.)
|
||||||
.color(Color32::WHITE);
|
.color(Color32::WHITE);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user