первая версия которая СОБИРАЕТСЯ братья!!
15
.gitignore
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
*.iml
|
||||
.gradle
|
||||
/local.properties
|
||||
/.idea/caches
|
||||
/.idea/libraries
|
||||
/.idea/modules.xml
|
||||
/.idea/workspace.xml
|
||||
/.idea/navEditor.xml
|
||||
/.idea/assetWizardSettings.xml
|
||||
.DS_Store
|
||||
/build
|
||||
/captures
|
||||
.externalNativeBuild
|
||||
.cxx
|
||||
local.properties
|
||||
3
.idea/.gitignore
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
607
.idea/misc.xml
generated
Normal file
@ -0,0 +1,607 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="DeviceStreaming">
|
||||
<option name="deviceSelectionList">
|
||||
<list>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="27" />
|
||||
<option name="brand" value="DOCOMO" />
|
||||
<option name="codename" value="F01L" />
|
||||
<option name="id" value="F01L" />
|
||||
<option name="labId" value="google" />
|
||||
<option name="manufacturer" value="FUJITSU" />
|
||||
<option name="name" value="F-01L" />
|
||||
<option name="screenDensity" value="360" />
|
||||
<option name="screenX" value="720" />
|
||||
<option name="screenY" value="1280" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="34" />
|
||||
<option name="brand" value="OnePlus" />
|
||||
<option name="codename" value="OP5552L1" />
|
||||
<option name="id" value="OP5552L1" />
|
||||
<option name="labId" value="google" />
|
||||
<option name="manufacturer" value="OnePlus" />
|
||||
<option name="name" value="CPH2415" />
|
||||
<option name="screenDensity" value="480" />
|
||||
<option name="screenX" value="1080" />
|
||||
<option name="screenY" value="2412" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="34" />
|
||||
<option name="brand" value="OPPO" />
|
||||
<option name="codename" value="OP573DL1" />
|
||||
<option name="id" value="OP573DL1" />
|
||||
<option name="labId" value="google" />
|
||||
<option name="manufacturer" value="OPPO" />
|
||||
<option name="name" value="CPH2557" />
|
||||
<option name="screenDensity" value="480" />
|
||||
<option name="screenX" value="1080" />
|
||||
<option name="screenY" value="2400" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="28" />
|
||||
<option name="brand" value="DOCOMO" />
|
||||
<option name="codename" value="SH-01L" />
|
||||
<option name="id" value="SH-01L" />
|
||||
<option name="labId" value="google" />
|
||||
<option name="manufacturer" value="SHARP" />
|
||||
<option name="name" value="AQUOS sense2 SH-01L" />
|
||||
<option name="screenDensity" value="480" />
|
||||
<option name="screenX" value="1080" />
|
||||
<option name="screenY" value="2160" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="34" />
|
||||
<option name="brand" value="Lenovo" />
|
||||
<option name="codename" value="TB370FU" />
|
||||
<option name="formFactor" value="Tablet" />
|
||||
<option name="id" value="TB370FU" />
|
||||
<option name="labId" value="google" />
|
||||
<option name="manufacturer" value="Lenovo" />
|
||||
<option name="name" value="Tab P12" />
|
||||
<option name="screenDensity" value="340" />
|
||||
<option name="screenX" value="1840" />
|
||||
<option name="screenY" value="2944" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="34" />
|
||||
<option name="brand" value="samsung" />
|
||||
<option name="codename" value="a15" />
|
||||
<option name="id" value="a15" />
|
||||
<option name="labId" value="google" />
|
||||
<option name="manufacturer" value="Samsung" />
|
||||
<option name="name" value="A15" />
|
||||
<option name="screenDensity" value="450" />
|
||||
<option name="screenX" value="1080" />
|
||||
<option name="screenY" value="2340" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="34" />
|
||||
<option name="brand" value="samsung" />
|
||||
<option name="codename" value="a35x" />
|
||||
<option name="id" value="a35x" />
|
||||
<option name="labId" value="google" />
|
||||
<option name="manufacturer" value="Samsung" />
|
||||
<option name="name" value="A35" />
|
||||
<option name="screenDensity" value="450" />
|
||||
<option name="screenX" value="1080" />
|
||||
<option name="screenY" value="2340" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="31" />
|
||||
<option name="brand" value="samsung" />
|
||||
<option name="codename" value="a51" />
|
||||
<option name="id" value="a51" />
|
||||
<option name="labId" value="google" />
|
||||
<option name="manufacturer" value="Samsung" />
|
||||
<option name="name" value="Galaxy A51" />
|
||||
<option name="screenDensity" value="420" />
|
||||
<option name="screenX" value="1080" />
|
||||
<option name="screenY" value="2400" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="34" />
|
||||
<option name="brand" value="google" />
|
||||
<option name="codename" value="akita" />
|
||||
<option name="id" value="akita" />
|
||||
<option name="labId" value="google" />
|
||||
<option name="manufacturer" value="Google" />
|
||||
<option name="name" value="Pixel 8a" />
|
||||
<option name="screenDensity" value="420" />
|
||||
<option name="screenX" value="1080" />
|
||||
<option name="screenY" value="2400" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="34" />
|
||||
<option name="brand" value="motorola" />
|
||||
<option name="codename" value="arcfox" />
|
||||
<option name="id" value="arcfox" />
|
||||
<option name="labId" value="google" />
|
||||
<option name="manufacturer" value="Motorola" />
|
||||
<option name="name" value="razr plus 2024" />
|
||||
<option name="screenDensity" value="360" />
|
||||
<option name="screenX" value="1080" />
|
||||
<option name="screenY" value="1272" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="33" />
|
||||
<option name="brand" value="motorola" />
|
||||
<option name="codename" value="austin" />
|
||||
<option name="id" value="austin" />
|
||||
<option name="labId" value="google" />
|
||||
<option name="manufacturer" value="Motorola" />
|
||||
<option name="name" value="moto g 5G (2022)" />
|
||||
<option name="screenDensity" value="280" />
|
||||
<option name="screenX" value="720" />
|
||||
<option name="screenY" value="1600" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="33" />
|
||||
<option name="brand" value="samsung" />
|
||||
<option name="codename" value="b0q" />
|
||||
<option name="id" value="b0q" />
|
||||
<option name="labId" value="google" />
|
||||
<option name="manufacturer" value="Samsung" />
|
||||
<option name="name" value="Galaxy S22 Ultra" />
|
||||
<option name="screenDensity" value="600" />
|
||||
<option name="screenX" value="1440" />
|
||||
<option name="screenY" value="3088" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="32" />
|
||||
<option name="brand" value="google" />
|
||||
<option name="codename" value="bluejay" />
|
||||
<option name="id" value="bluejay" />
|
||||
<option name="labId" value="google" />
|
||||
<option name="manufacturer" value="Google" />
|
||||
<option name="name" value="Pixel 6a" />
|
||||
<option name="screenDensity" value="420" />
|
||||
<option name="screenX" value="1080" />
|
||||
<option name="screenY" value="2400" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="34" />
|
||||
<option name="brand" value="google" />
|
||||
<option name="codename" value="caiman" />
|
||||
<option name="id" value="caiman" />
|
||||
<option name="labId" value="google" />
|
||||
<option name="manufacturer" value="Google" />
|
||||
<option name="name" value="Pixel 9 Pro" />
|
||||
<option name="screenDensity" value="360" />
|
||||
<option name="screenX" value="960" />
|
||||
<option name="screenY" value="2142" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="34" />
|
||||
<option name="brand" value="google" />
|
||||
<option name="codename" value="comet" />
|
||||
<option name="default" value="true" />
|
||||
<option name="id" value="comet" />
|
||||
<option name="labId" value="google" />
|
||||
<option name="manufacturer" value="Google" />
|
||||
<option name="name" value="Pixel 9 Pro Fold" />
|
||||
<option name="screenDensity" value="390" />
|
||||
<option name="screenX" value="2076" />
|
||||
<option name="screenY" value="2152" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="29" />
|
||||
<option name="brand" value="samsung" />
|
||||
<option name="codename" value="crownqlteue" />
|
||||
<option name="id" value="crownqlteue" />
|
||||
<option name="labId" value="google" />
|
||||
<option name="manufacturer" value="Samsung" />
|
||||
<option name="name" value="Galaxy Note9" />
|
||||
<option name="screenDensity" value="420" />
|
||||
<option name="screenX" value="2220" />
|
||||
<option name="screenY" value="1080" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="34" />
|
||||
<option name="brand" value="samsung" />
|
||||
<option name="codename" value="dm2q" />
|
||||
<option name="id" value="dm2q" />
|
||||
<option name="labId" value="google" />
|
||||
<option name="manufacturer" value="Samsung" />
|
||||
<option name="name" value="S23 Plus" />
|
||||
<option name="screenDensity" value="450" />
|
||||
<option name="screenX" value="1080" />
|
||||
<option name="screenY" value="2340" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="34" />
|
||||
<option name="brand" value="samsung" />
|
||||
<option name="codename" value="dm3q" />
|
||||
<option name="id" value="dm3q" />
|
||||
<option name="labId" value="google" />
|
||||
<option name="manufacturer" value="Samsung" />
|
||||
<option name="name" value="Galaxy S23 Ultra" />
|
||||
<option name="screenDensity" value="600" />
|
||||
<option name="screenX" value="1440" />
|
||||
<option name="screenY" value="3088" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="34" />
|
||||
<option name="brand" value="samsung" />
|
||||
<option name="codename" value="e1q" />
|
||||
<option name="default" value="true" />
|
||||
<option name="id" value="e1q" />
|
||||
<option name="labId" value="google" />
|
||||
<option name="manufacturer" value="Samsung" />
|
||||
<option name="name" value="Galaxy S24" />
|
||||
<option name="screenDensity" value="480" />
|
||||
<option name="screenX" value="1080" />
|
||||
<option name="screenY" value="2340" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="34" />
|
||||
<option name="brand" value="samsung" />
|
||||
<option name="codename" value="e3q" />
|
||||
<option name="id" value="e3q" />
|
||||
<option name="labId" value="google" />
|
||||
<option name="manufacturer" value="Samsung" />
|
||||
<option name="name" value="Galaxy S24 Ultra" />
|
||||
<option name="screenDensity" value="450" />
|
||||
<option name="screenX" value="1440" />
|
||||
<option name="screenY" value="3120" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="33" />
|
||||
<option name="brand" value="google" />
|
||||
<option name="codename" value="eos" />
|
||||
<option name="id" value="eos" />
|
||||
<option name="labId" value="google" />
|
||||
<option name="manufacturer" value="Google" />
|
||||
<option name="name" value="Eos" />
|
||||
<option name="screenDensity" value="320" />
|
||||
<option name="screenX" value="384" />
|
||||
<option name="screenY" value="384" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="33" />
|
||||
<option name="brand" value="google" />
|
||||
<option name="codename" value="felix" />
|
||||
<option name="id" value="felix" />
|
||||
<option name="labId" value="google" />
|
||||
<option name="manufacturer" value="Google" />
|
||||
<option name="name" value="Pixel Fold" />
|
||||
<option name="screenDensity" value="420" />
|
||||
<option name="screenX" value="2208" />
|
||||
<option name="screenY" value="1840" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="34" />
|
||||
<option name="brand" value="google" />
|
||||
<option name="codename" value="felix" />
|
||||
<option name="id" value="felix" />
|
||||
<option name="labId" value="google" />
|
||||
<option name="manufacturer" value="Google" />
|
||||
<option name="name" value="Pixel Fold" />
|
||||
<option name="screenDensity" value="420" />
|
||||
<option name="screenX" value="2208" />
|
||||
<option name="screenY" value="1840" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="33" />
|
||||
<option name="brand" value="google" />
|
||||
<option name="codename" value="felix_camera" />
|
||||
<option name="id" value="felix_camera" />
|
||||
<option name="labId" value="google" />
|
||||
<option name="manufacturer" value="Google" />
|
||||
<option name="name" value="Pixel Fold (Camera-enabled)" />
|
||||
<option name="screenDensity" value="420" />
|
||||
<option name="screenX" value="2208" />
|
||||
<option name="screenY" value="1840" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="34" />
|
||||
<option name="brand" value="motorola" />
|
||||
<option name="codename" value="fogona" />
|
||||
<option name="id" value="fogona" />
|
||||
<option name="labId" value="google" />
|
||||
<option name="manufacturer" value="Motorola" />
|
||||
<option name="name" value="moto g play - 2024" />
|
||||
<option name="screenDensity" value="280" />
|
||||
<option name="screenX" value="720" />
|
||||
<option name="screenY" value="1600" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="34" />
|
||||
<option name="brand" value="samsung" />
|
||||
<option name="codename" value="g0q" />
|
||||
<option name="id" value="g0q" />
|
||||
<option name="labId" value="google" />
|
||||
<option name="manufacturer" value="Samsung" />
|
||||
<option name="name" value="SM-S906U1" />
|
||||
<option name="screenDensity" value="450" />
|
||||
<option name="screenX" value="1080" />
|
||||
<option name="screenY" value="2340" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="34" />
|
||||
<option name="brand" value="samsung" />
|
||||
<option name="codename" value="gta9pwifi" />
|
||||
<option name="id" value="gta9pwifi" />
|
||||
<option name="labId" value="google" />
|
||||
<option name="manufacturer" value="Samsung" />
|
||||
<option name="name" value="SM-X210" />
|
||||
<option name="screenDensity" value="240" />
|
||||
<option name="screenX" value="1200" />
|
||||
<option name="screenY" value="1920" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="34" />
|
||||
<option name="brand" value="samsung" />
|
||||
<option name="codename" value="gts7xllite" />
|
||||
<option name="id" value="gts7xllite" />
|
||||
<option name="labId" value="google" />
|
||||
<option name="manufacturer" value="Samsung" />
|
||||
<option name="name" value="SM-T738U" />
|
||||
<option name="screenDensity" value="340" />
|
||||
<option name="screenX" value="1600" />
|
||||
<option name="screenY" value="2560" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="33" />
|
||||
<option name="brand" value="samsung" />
|
||||
<option name="codename" value="gts8uwifi" />
|
||||
<option name="formFactor" value="Tablet" />
|
||||
<option name="id" value="gts8uwifi" />
|
||||
<option name="labId" value="google" />
|
||||
<option name="manufacturer" value="Samsung" />
|
||||
<option name="name" value="Galaxy Tab S8 Ultra" />
|
||||
<option name="screenDensity" value="320" />
|
||||
<option name="screenX" value="1848" />
|
||||
<option name="screenY" value="2960" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="34" />
|
||||
<option name="brand" value="samsung" />
|
||||
<option name="codename" value="gts8wifi" />
|
||||
<option name="formFactor" value="Tablet" />
|
||||
<option name="id" value="gts8wifi" />
|
||||
<option name="labId" value="google" />
|
||||
<option name="manufacturer" value="Samsung" />
|
||||
<option name="name" value="Galaxy Tab S8" />
|
||||
<option name="screenDensity" value="274" />
|
||||
<option name="screenX" value="1600" />
|
||||
<option name="screenY" value="2560" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="34" />
|
||||
<option name="brand" value="samsung" />
|
||||
<option name="codename" value="gts9fe" />
|
||||
<option name="id" value="gts9fe" />
|
||||
<option name="labId" value="google" />
|
||||
<option name="manufacturer" value="Samsung" />
|
||||
<option name="name" value="Galaxy Tab S9 FE 5G" />
|
||||
<option name="screenDensity" value="280" />
|
||||
<option name="screenX" value="1440" />
|
||||
<option name="screenY" value="2304" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="34" />
|
||||
<option name="brand" value="google" />
|
||||
<option name="codename" value="husky" />
|
||||
<option name="id" value="husky" />
|
||||
<option name="labId" value="google" />
|
||||
<option name="manufacturer" value="Google" />
|
||||
<option name="name" value="Pixel 8 Pro" />
|
||||
<option name="screenDensity" value="390" />
|
||||
<option name="screenX" value="1008" />
|
||||
<option name="screenY" value="2244" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="30" />
|
||||
<option name="brand" value="motorola" />
|
||||
<option name="codename" value="java" />
|
||||
<option name="id" value="java" />
|
||||
<option name="labId" value="google" />
|
||||
<option name="manufacturer" value="Motorola" />
|
||||
<option name="name" value="G20" />
|
||||
<option name="screenDensity" value="280" />
|
||||
<option name="screenX" value="720" />
|
||||
<option name="screenY" value="1600" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="34" />
|
||||
<option name="brand" value="google" />
|
||||
<option name="codename" value="komodo" />
|
||||
<option name="id" value="komodo" />
|
||||
<option name="labId" value="google" />
|
||||
<option name="manufacturer" value="Google" />
|
||||
<option name="name" value="Pixel 9 Pro XL" />
|
||||
<option name="screenDensity" value="360" />
|
||||
<option name="screenX" value="1008" />
|
||||
<option name="screenY" value="2244" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="33" />
|
||||
<option name="brand" value="google" />
|
||||
<option name="codename" value="lynx" />
|
||||
<option name="id" value="lynx" />
|
||||
<option name="labId" value="google" />
|
||||
<option name="manufacturer" value="Google" />
|
||||
<option name="name" value="Pixel 7a" />
|
||||
<option name="screenDensity" value="420" />
|
||||
<option name="screenX" value="1080" />
|
||||
<option name="screenY" value="2400" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="33" />
|
||||
<option name="brand" value="motorola" />
|
||||
<option name="codename" value="maui" />
|
||||
<option name="id" value="maui" />
|
||||
<option name="labId" value="google" />
|
||||
<option name="manufacturer" value="Motorola" />
|
||||
<option name="name" value="moto g play - 2023" />
|
||||
<option name="screenDensity" value="280" />
|
||||
<option name="screenX" value="720" />
|
||||
<option name="screenY" value="1600" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="34" />
|
||||
<option name="brand" value="samsung" />
|
||||
<option name="codename" value="o1q" />
|
||||
<option name="id" value="o1q" />
|
||||
<option name="labId" value="google" />
|
||||
<option name="manufacturer" value="Samsung" />
|
||||
<option name="name" value="Galaxy S21" />
|
||||
<option name="screenDensity" value="421" />
|
||||
<option name="screenX" value="1080" />
|
||||
<option name="screenY" value="2400" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="31" />
|
||||
<option name="brand" value="google" />
|
||||
<option name="codename" value="oriole" />
|
||||
<option name="id" value="oriole" />
|
||||
<option name="labId" value="google" />
|
||||
<option name="manufacturer" value="Google" />
|
||||
<option name="name" value="Pixel 6" />
|
||||
<option name="screenDensity" value="420" />
|
||||
<option name="screenX" value="1080" />
|
||||
<option name="screenY" value="2400" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="33" />
|
||||
<option name="brand" value="google" />
|
||||
<option name="codename" value="panther" />
|
||||
<option name="id" value="panther" />
|
||||
<option name="labId" value="google" />
|
||||
<option name="manufacturer" value="Google" />
|
||||
<option name="name" value="Pixel 7" />
|
||||
<option name="screenDensity" value="420" />
|
||||
<option name="screenX" value="1080" />
|
||||
<option name="screenY" value="2400" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="34" />
|
||||
<option name="brand" value="samsung" />
|
||||
<option name="codename" value="q5q" />
|
||||
<option name="id" value="q5q" />
|
||||
<option name="labId" value="google" />
|
||||
<option name="manufacturer" value="Samsung" />
|
||||
<option name="name" value="Galaxy Z Fold5" />
|
||||
<option name="screenDensity" value="420" />
|
||||
<option name="screenX" value="1812" />
|
||||
<option name="screenY" value="2176" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="34" />
|
||||
<option name="brand" value="samsung" />
|
||||
<option name="codename" value="q6q" />
|
||||
<option name="id" value="q6q" />
|
||||
<option name="labId" value="google" />
|
||||
<option name="manufacturer" value="Samsung" />
|
||||
<option name="name" value="Galaxy Z Fold6" />
|
||||
<option name="screenDensity" value="420" />
|
||||
<option name="screenX" value="1856" />
|
||||
<option name="screenY" value="2160" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="30" />
|
||||
<option name="brand" value="google" />
|
||||
<option name="codename" value="r11" />
|
||||
<option name="formFactor" value="Wear OS" />
|
||||
<option name="id" value="r11" />
|
||||
<option name="labId" value="google" />
|
||||
<option name="manufacturer" value="Google" />
|
||||
<option name="name" value="Pixel Watch" />
|
||||
<option name="screenDensity" value="320" />
|
||||
<option name="screenX" value="384" />
|
||||
<option name="screenY" value="384" />
|
||||
<option name="type" value="WEAR_OS" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="34" />
|
||||
<option name="brand" value="samsung" />
|
||||
<option name="codename" value="r11q" />
|
||||
<option name="id" value="r11q" />
|
||||
<option name="labId" value="google" />
|
||||
<option name="manufacturer" value="Samsung" />
|
||||
<option name="name" value="SM-S711U" />
|
||||
<option name="screenDensity" value="450" />
|
||||
<option name="screenX" value="1080" />
|
||||
<option name="screenY" value="2340" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="30" />
|
||||
<option name="brand" value="google" />
|
||||
<option name="codename" value="redfin" />
|
||||
<option name="id" value="redfin" />
|
||||
<option name="labId" value="google" />
|
||||
<option name="manufacturer" value="Google" />
|
||||
<option name="name" value="Pixel 5" />
|
||||
<option name="screenDensity" value="440" />
|
||||
<option name="screenX" value="1080" />
|
||||
<option name="screenY" value="2340" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="34" />
|
||||
<option name="brand" value="google" />
|
||||
<option name="codename" value="shiba" />
|
||||
<option name="id" value="shiba" />
|
||||
<option name="labId" value="google" />
|
||||
<option name="manufacturer" value="Google" />
|
||||
<option name="name" value="Pixel 8" />
|
||||
<option name="screenDensity" value="420" />
|
||||
<option name="screenX" value="1080" />
|
||||
<option name="screenY" value="2400" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="34" />
|
||||
<option name="brand" value="samsung" />
|
||||
<option name="codename" value="t2q" />
|
||||
<option name="id" value="t2q" />
|
||||
<option name="labId" value="google" />
|
||||
<option name="manufacturer" value="Samsung" />
|
||||
<option name="name" value="Galaxy S21 Plus" />
|
||||
<option name="screenDensity" value="394" />
|
||||
<option name="screenX" value="1080" />
|
||||
<option name="screenY" value="2400" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="33" />
|
||||
<option name="brand" value="google" />
|
||||
<option name="codename" value="tangorpro" />
|
||||
<option name="formFactor" value="Tablet" />
|
||||
<option name="id" value="tangorpro" />
|
||||
<option name="labId" value="google" />
|
||||
<option name="manufacturer" value="Google" />
|
||||
<option name="name" value="Pixel Tablet" />
|
||||
<option name="screenDensity" value="320" />
|
||||
<option name="screenX" value="1600" />
|
||||
<option name="screenY" value="2560" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="34" />
|
||||
<option name="brand" value="google" />
|
||||
<option name="codename" value="tokay" />
|
||||
<option name="default" value="true" />
|
||||
<option name="id" value="tokay" />
|
||||
<option name="labId" value="google" />
|
||||
<option name="manufacturer" value="Google" />
|
||||
<option name="name" value="Pixel 9" />
|
||||
<option name="screenDensity" value="420" />
|
||||
<option name="screenX" value="1080" />
|
||||
<option name="screenY" value="2424" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="35" />
|
||||
<option name="brand" value="google" />
|
||||
<option name="codename" value="tokay" />
|
||||
<option name="default" value="true" />
|
||||
<option name="id" value="tokay" />
|
||||
<option name="labId" value="google" />
|
||||
<option name="manufacturer" value="Google" />
|
||||
<option name="name" value="Pixel 9" />
|
||||
<option name="screenDensity" value="420" />
|
||||
<option name="screenX" value="1080" />
|
||||
<option name="screenY" value="2424" />
|
||||
</PersistentDeviceSelectionData>
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
4
.idea/vcs.xml
generated
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings" defaultProject="true" />
|
||||
</project>
|
||||
1
app/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/build
|
||||
74
app/build.gradle.kts
Normal file
@ -0,0 +1,74 @@
|
||||
plugins {
|
||||
alias(libs.plugins.android.application)
|
||||
alias(libs.plugins.kotlin.android)
|
||||
alias(libs.plugins.serialization)
|
||||
alias(libs.plugins.kotlin.compose)
|
||||
}
|
||||
|
||||
android {
|
||||
namespace = "com.mkfunproj.mobilemkch"
|
||||
compileSdk = 35
|
||||
|
||||
defaultConfig {
|
||||
applicationId = "com.mkfunproj.mobilemkch"
|
||||
minSdk = 31
|
||||
targetSdk = 35
|
||||
versionCode = 1
|
||||
versionName = "1.0"
|
||||
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
isMinifyEnabled = false
|
||||
proguardFiles(
|
||||
getDefaultProguardFile("proguard-android-optimize.txt"),
|
||||
"proguard-rules.pro"
|
||||
)
|
||||
}
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility = JavaVersion.VERSION_17
|
||||
targetCompatibility = JavaVersion.VERSION_17
|
||||
}
|
||||
kotlinOptions {
|
||||
jvmTarget = "17"
|
||||
}
|
||||
|
||||
buildFeatures {
|
||||
compose = true
|
||||
}
|
||||
composeOptions {
|
||||
kotlinCompilerExtensionVersion = "1.6.11"
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(libs.androidx.core.ktx)
|
||||
implementation(libs.androidx.appcompat)
|
||||
implementation(libs.material)
|
||||
implementation(platform(libs.compose.bom))
|
||||
implementation(libs.compose.ui)
|
||||
implementation(libs.compose.ui.tooling.preview)
|
||||
implementation(libs.compose.material3)
|
||||
implementation(libs.compose.foundation)
|
||||
implementation(libs.compose.material)
|
||||
implementation(libs.compose.material.icons.extended)
|
||||
implementation(libs.activity.compose)
|
||||
implementation(libs.navigation.compose)
|
||||
implementation(libs.lifecycle.runtime.ktx)
|
||||
implementation(libs.lifecycle.viewmodel.ktx)
|
||||
implementation(libs.lifecycle.viewmodel.compose)
|
||||
implementation(libs.retrofit)
|
||||
implementation(libs.retrofit.converter.scalars)
|
||||
implementation(libs.okhttp)
|
||||
implementation(libs.okhttp.logging)
|
||||
implementation(libs.serialization.json)
|
||||
implementation(libs.coil.compose)
|
||||
implementation(libs.datastore.preferences)
|
||||
implementation(libs.work.runtime.ktx)
|
||||
testImplementation(libs.junit)
|
||||
androidTestImplementation(libs.androidx.junit)
|
||||
androidTestImplementation(libs.androidx.espresso.core)
|
||||
}
|
||||
21
app/proguard-rules.pro
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
||||
@ -0,0 +1,24 @@
|
||||
package com.mkfunproj.mobilemkch
|
||||
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
import org.junit.Assert.*
|
||||
|
||||
/**
|
||||
* Instrumented test, which will execute on an Android device.
|
||||
*
|
||||
* See [testing documentation](http://d.android.com/tools/testing).
|
||||
*/
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class ExampleInstrumentedTest {
|
||||
@Test
|
||||
fun useAppContext() {
|
||||
// Context of the app under test.
|
||||
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
|
||||
assertEquals("com.mkfunproj.mobilemkch", appContext.packageName)
|
||||
}
|
||||
}
|
||||
39
app/src/main/AndroidManifest.xml
Normal file
@ -0,0 +1,39 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" tools:targetApi="33" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:dataExtractionRules="@xml/data_extraction_rules"
|
||||
android:fullBackupContent="@xml/backup_rules"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:enableOnBackInvokedCallback="true"
|
||||
android:theme="@style/Theme.MobileMkchNewAndroid"
|
||||
tools:targetApi="31">
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:exported="true"
|
||||
android:theme="@style/Theme.MobileMkchNewAndroid">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<service
|
||||
android:name="androidx.work.impl.foreground.SystemForegroundService"
|
||||
android:exported="false"
|
||||
android:foregroundServiceType="dataSync" />
|
||||
<service
|
||||
android:name=".workers.ThreadsCheckWorker"
|
||||
android:exported="false"
|
||||
android:foregroundServiceType="dataSync" />
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
37
app/src/main/java/com/mkfunproj/mobilemkch/MainActivity.kt
Normal file
@ -0,0 +1,37 @@
|
||||
package com.mkfunproj.mobilemkch
|
||||
|
||||
import android.os.Bundle
|
||||
import androidx.work.ExistingPeriodicWorkPolicy
|
||||
import androidx.work.PeriodicWorkRequestBuilder
|
||||
import androidx.work.WorkManager
|
||||
import androidx.activity.ComponentActivity
|
||||
import androidx.activity.compose.setContent
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.collectAsState
|
||||
import androidx.compose.ui.Modifier
|
||||
import com.mkfunproj.mobilemkch.ui.AppRoot
|
||||
import com.mkfunproj.mobilemkch.ui.theme.MobileMkchTheme
|
||||
import com.mkfunproj.mobilemkch.workers.ThreadsCheckWorker
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
class MainActivity : ComponentActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
val request = PeriodicWorkRequestBuilder<ThreadsCheckWorker>(15, TimeUnit.MINUTES).build()
|
||||
WorkManager.getInstance(this).enqueueUniquePeriodicWork("mkch_threads_check", ExistingPeriodicWorkPolicy.UPDATE, request)
|
||||
setContent {
|
||||
val settingsStore = com.mkfunproj.mobilemkch.data.SettingsStore(this)
|
||||
val settings by settingsStore.data.collectAsState(initial = com.mkfunproj.mobilemkch.data.SettingsData())
|
||||
MobileMkchTheme(darkTheme = settings.theme == "dark" || settings.theme == "oled", oled = settings.theme == "oled") {
|
||||
Surface(color = MaterialTheme.colorScheme.background) {
|
||||
AppRoot()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
199
app/src/main/java/com/mkfunproj/mobilemkch/data/ApiClient.kt
Normal file
@ -0,0 +1,199 @@
|
||||
package com.mkfunproj.mobilemkch.data
|
||||
|
||||
import android.content.Context
|
||||
import kotlinx.serialization.json.Json
|
||||
import kotlinx.serialization.encodeToString
|
||||
import okhttp3.Interceptor
|
||||
import okhttp3.MediaType.Companion.toMediaType
|
||||
import okhttp3.MultipartBody
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.Request
|
||||
import okhttp3.RequestBody
|
||||
import okhttp3.RequestBody.Companion.asRequestBody
|
||||
import okhttp3.RequestBody.Companion.toRequestBody
|
||||
import okhttp3.logging.HttpLoggingInterceptor
|
||||
import retrofit2.Retrofit
|
||||
import retrofit2.converter.scalars.ScalarsConverterFactory
|
||||
import java.io.File
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
class ApiClient(context: Context) {
|
||||
private val baseUrl = "https://mkch.pooziqo.xyz"
|
||||
private val apiUrl = "$baseUrl/api/"
|
||||
private val userAgent = "MobileMkch/1.0-android-alpha"
|
||||
|
||||
private val json = Json { ignoreUnknownKeys = true }
|
||||
private val prefs = context.getSharedPreferences("api_prefs", Context.MODE_PRIVATE)
|
||||
|
||||
private val userAgentInterceptor = Interceptor { chain ->
|
||||
val request = chain.request().newBuilder()
|
||||
.header("Accept", "application/json")
|
||||
.header("Accept-Language", java.util.Locale.getDefault().toLanguageTag())
|
||||
.header("User-Agent", userAgent)
|
||||
.build()
|
||||
chain.proceed(request)
|
||||
}
|
||||
|
||||
private val httpClient: OkHttpClient = OkHttpClient.Builder()
|
||||
.addInterceptor(userAgentInterceptor)
|
||||
.addInterceptor(HttpLoggingInterceptor().apply { level = HttpLoggingInterceptor.Level.BASIC })
|
||||
.cookieJar(PersistentCookieJar(context))
|
||||
.connectTimeout(20, TimeUnit.SECONDS)
|
||||
.readTimeout(40, TimeUnit.SECONDS)
|
||||
.build()
|
||||
|
||||
private val retrofit: Retrofit = Retrofit.Builder()
|
||||
.baseUrl(apiUrl)
|
||||
.addConverterFactory(ScalarsConverterFactory.create())
|
||||
.client(httpClient)
|
||||
.build()
|
||||
|
||||
private fun parseBoards(body: String): List<Board> = json.decodeFromString(body)
|
||||
private fun parseThreads(body: String): List<ThreadItem> = json.decodeFromString(body)
|
||||
private fun parseThreadDetail(body: String): ThreadDetail = json.decodeFromString(body)
|
||||
private fun parseComments(body: String): List<Comment> = json.decodeFromString(body)
|
||||
|
||||
private fun get(url: String): String {
|
||||
val req = Request.Builder().url(url).get().build()
|
||||
httpClient.newCall(req).execute().use { resp ->
|
||||
if (!resp.isSuccessful) throw RuntimeException("HTTP ${'$'}{resp.code}")
|
||||
return resp.body?.string() ?: throw RuntimeException("empty body")
|
||||
}
|
||||
}
|
||||
|
||||
fun getBoards(): List<Board> = parseBoards(get("${apiUrl}boards/"))
|
||||
|
||||
fun getThreads(boardCode: String): List<ThreadItem> = parseThreads(get("${apiUrl}board/$boardCode"))
|
||||
|
||||
fun getThreadDetail(boardCode: String, threadId: Int): ThreadDetail =
|
||||
parseThreadDetail(get("${apiUrl}board/$boardCode/thread/$threadId"))
|
||||
|
||||
fun getComments(boardCode: String, threadId: Int): List<Comment> =
|
||||
parseComments(get("${apiUrl}board/$boardCode/thread/$threadId/comments"))
|
||||
|
||||
fun getFullThread(boardCode: String, threadId: Int): Pair<ThreadDetail, List<Comment>> {
|
||||
val detail = getThreadDetail(boardCode, threadId)
|
||||
val comments = getComments(boardCode, threadId)
|
||||
return detail to comments
|
||||
}
|
||||
|
||||
fun authenticate(authKey: String) {
|
||||
if (authKey.isEmpty()) return
|
||||
val url = "$baseUrl/key/auth/"
|
||||
val formHtml = get(url)
|
||||
val csrf = extractCsrf(formHtml)
|
||||
val body = "csrfmiddlewaretoken=${'$'}csrf&key=${'$'}authKey"
|
||||
.toRequestBody("application/x-www-form-urlencoded".toMediaType())
|
||||
val req = Request.Builder().url(url)
|
||||
.post(body)
|
||||
.header("Referer", url)
|
||||
.build()
|
||||
httpClient.newCall(req).execute().use { resp ->
|
||||
if (!(resp.code == 200 || resp.code == 302)) throw RuntimeException("auth failed ${'$'}{resp.code}")
|
||||
}
|
||||
}
|
||||
|
||||
fun loginWithPasscode(passcode: String) {
|
||||
if (passcode.isEmpty()) return
|
||||
val url = "$baseUrl/passcode/enter/"
|
||||
val formHtml = get(url)
|
||||
val csrf = extractCsrf(formHtml)
|
||||
val body = "csrfmiddlewaretoken=${'$'}csrf&passcode=${'$'}passcode"
|
||||
.toRequestBody("application/x-www-form-urlencoded".toMediaType())
|
||||
val req = Request.Builder().url(url)
|
||||
.post(body)
|
||||
.header("Referer", url)
|
||||
.build()
|
||||
httpClient.newCall(req).execute().use { resp ->
|
||||
if (!(resp.code == 200 || resp.code == 302)) throw RuntimeException("passcode failed ${'$'}{resp.code}")
|
||||
}
|
||||
}
|
||||
|
||||
fun createThread(boardCode: String, title: String, text: String, files: List<File> = emptyList(), passcode: String = "", authKey: String = "") {
|
||||
if (authKey.isNotEmpty()) authenticate(authKey)
|
||||
if (passcode.isNotEmpty()) loginWithPasscode(passcode)
|
||||
val formUrl = "$baseUrl/boards/board/$boardCode/new"
|
||||
val csrf = fetchCsrf(formUrl)
|
||||
val req = if (files.isEmpty()) {
|
||||
val body = "csrfmiddlewaretoken=$csrf&title=$title&text=$text"
|
||||
.toRequestBody("application/x-www-form-urlencoded".toMediaType())
|
||||
Request.Builder().url(formUrl).post(body)
|
||||
} else {
|
||||
val builder = MultipartBody.Builder().setType(MultipartBody.FORM)
|
||||
.addFormDataPart("csrfmiddlewaretoken", csrf)
|
||||
.addFormDataPart("title", title)
|
||||
.addFormDataPart("text", text)
|
||||
files.forEachIndexed { idx, file ->
|
||||
val rb: RequestBody = file.asRequestBody("image/jpeg".toMediaType())
|
||||
builder.addFormDataPart("files", "photo_${idx + 1}.jpg", rb)
|
||||
}
|
||||
Request.Builder().url(formUrl).post(builder.build())
|
||||
}
|
||||
.header("Referer", formUrl)
|
||||
.build()
|
||||
httpClient.newCall(req).execute().use { resp ->
|
||||
if (!(resp.code == 200 || resp.code == 302)) throw RuntimeException("createThread failed ${resp.code}")
|
||||
}
|
||||
}
|
||||
|
||||
fun addComment(boardCode: String, threadId: Int, text: String, files: List<File> = emptyList(), passcode: String = "", authKey: String = "") {
|
||||
if (authKey.isNotEmpty()) authenticate(authKey)
|
||||
if (passcode.isNotEmpty()) loginWithPasscode(passcode)
|
||||
val formUrl = "$baseUrl/boards/board/$boardCode/thread/$threadId/comment"
|
||||
val csrf = fetchCsrf(formUrl)
|
||||
val req = if (files.isEmpty()) {
|
||||
val body = "csrfmiddlewaretoken=$csrf&text=$text"
|
||||
.toRequestBody("application/x-www-form-urlencoded".toMediaType())
|
||||
Request.Builder().url(formUrl).post(body)
|
||||
} else {
|
||||
val builder = MultipartBody.Builder().setType(MultipartBody.FORM)
|
||||
.addFormDataPart("csrfmiddlewaretoken", csrf)
|
||||
.addFormDataPart("text", text)
|
||||
files.forEachIndexed { idx, file ->
|
||||
val rb: RequestBody = file.asRequestBody("image/jpeg".toMediaType())
|
||||
builder.addFormDataPart("files", "photo_${idx + 1}.jpg", rb)
|
||||
}
|
||||
Request.Builder().url(formUrl).post(builder.build())
|
||||
}
|
||||
.header("Referer", formUrl)
|
||||
.build()
|
||||
httpClient.newCall(req).execute().use { resp ->
|
||||
if (!(resp.code == 200 || resp.code == 302)) throw RuntimeException("addComment failed ${resp.code}")
|
||||
}
|
||||
}
|
||||
|
||||
private fun fetchCsrf(url: String): String {
|
||||
val req = Request.Builder().url(url).get().build()
|
||||
httpClient.newCall(req).execute().use { resp ->
|
||||
if (!resp.isSuccessful) throw RuntimeException("HTTP ${resp.code}")
|
||||
val html = resp.body?.string().orEmpty()
|
||||
val regex = Regex("name=['\"]csrfmiddlewaretoken['\"]\\s+value=['\"]([^'\"]+)['\"]")
|
||||
val match = regex.find(html) ?: throw RuntimeException("csrf not found")
|
||||
return match.groupValues[1]
|
||||
}
|
||||
}
|
||||
|
||||
fun checkNewThreads(boardCode: String): List<ThreadItem> {
|
||||
val current = getThreads(boardCode)
|
||||
val key = "savedThreads_${'$'}boardCode"
|
||||
val savedRaw = prefs.getString(key, null)
|
||||
return if (savedRaw != null) {
|
||||
val saved = runCatching { json.decodeFromString<List<ThreadItem>>(savedRaw) }.getOrElse { emptyList() }
|
||||
val savedIds = saved.map { it.id }.toSet()
|
||||
val newOnes = current.filter { it.id !in savedIds }
|
||||
prefs.edit().putString(key, json.encodeToString(current)).apply()
|
||||
newOnes
|
||||
} else {
|
||||
prefs.edit().putString(key, json.encodeToString(current)).apply()
|
||||
emptyList()
|
||||
}
|
||||
}
|
||||
|
||||
private fun extractCsrf(html: String): String {
|
||||
val regex = Regex("name=['\"]csrfmiddlewaretoken['\"]\\s+value=['\"]([^'\"]+)['\"]")
|
||||
val match = regex.find(html) ?: throw RuntimeException("csrf not found")
|
||||
return match.groupValues[1]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
52
app/src/main/java/com/mkfunproj/mobilemkch/data/Cache.kt
Normal file
@ -0,0 +1,52 @@
|
||||
package com.mkfunproj.mobilemkch.data
|
||||
|
||||
import android.content.Context
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
import kotlinx.serialization.encodeToString
|
||||
import kotlinx.serialization.json.Json
|
||||
import java.io.File
|
||||
|
||||
class Cache(private val context: Context) {
|
||||
private val json = Json
|
||||
private val dir: File by lazy { File(context.cacheDir, "mkch_cache").apply { mkdirs() } }
|
||||
|
||||
suspend fun <T> set(key: String, value: T, encoder: (T) -> String, ttlSeconds: Long) = withContext(Dispatchers.IO) {
|
||||
val file = File(dir, safeName(key))
|
||||
val wrapper = CacheWrapper(System.currentTimeMillis(), ttlSeconds, encoder(value))
|
||||
file.writeText(json.encodeToString(wrapper))
|
||||
}
|
||||
|
||||
suspend fun <T> get(key: String, decoder: (String) -> T): T? = withContext(Dispatchers.IO) {
|
||||
val file = File(dir, safeName(key))
|
||||
if (!file.exists()) return@withContext null
|
||||
val wrapper = runCatching { json.decodeFromString(CacheWrapper.serializer(), file.readText()) }.getOrNull()
|
||||
?: return@withContext null
|
||||
val ageSec = (System.currentTimeMillis() - wrapper.timestampMs) / 1000
|
||||
if (ageSec > wrapper.ttlSeconds) return@withContext null
|
||||
return@withContext decoder(wrapper.payload)
|
||||
}
|
||||
|
||||
suspend fun <T> getStale(key: String, decoder: (String) -> T): T? = withContext(Dispatchers.IO) {
|
||||
val file = File(dir, safeName(key))
|
||||
if (!file.exists()) return@withContext null
|
||||
val wrapper = runCatching { json.decodeFromString(CacheWrapper.serializer(), file.readText()) }.getOrNull()
|
||||
?: return@withContext null
|
||||
return@withContext decoder(wrapper.payload)
|
||||
}
|
||||
|
||||
suspend fun delete(key: String) = withContext(Dispatchers.IO) {
|
||||
File(dir, safeName(key)).delete()
|
||||
}
|
||||
|
||||
private fun safeName(key: String) = key.hashCode().toString(16) + ".json"
|
||||
}
|
||||
|
||||
@kotlinx.serialization.Serializable
|
||||
private data class CacheWrapper(
|
||||
val timestampMs: Long,
|
||||
val ttlSeconds: Long,
|
||||
val payload: String
|
||||
)
|
||||
|
||||
|
||||
27
app/src/main/java/com/mkfunproj/mobilemkch/data/Cookies.kt
Normal file
@ -0,0 +1,27 @@
|
||||
package com.mkfunproj.mobilemkch.data
|
||||
|
||||
import android.content.Context
|
||||
import okhttp3.Cookie
|
||||
import okhttp3.CookieJar
|
||||
import okhttp3.HttpUrl
|
||||
|
||||
class PersistentCookieJar(context: Context) : CookieJar {
|
||||
private val prefs = context.getSharedPreferences("cookies", Context.MODE_PRIVATE)
|
||||
|
||||
override fun saveFromResponse(url: HttpUrl, cookies: List<Cookie>) {
|
||||
val key = url.host
|
||||
val existing = loadForRequest(url).toMutableList()
|
||||
existing.removeAll { e -> cookies.any { it.name == e.name } }
|
||||
existing.addAll(cookies)
|
||||
val serialized = existing.joinToString(";") { it.toString() }
|
||||
prefs.edit().putString(key, serialized).apply()
|
||||
}
|
||||
|
||||
override fun loadForRequest(url: HttpUrl): List<Cookie> {
|
||||
val key = url.host
|
||||
val stored = prefs.getString(key, null) ?: return emptyList()
|
||||
return stored.split(";").mapNotNull { Cookie.parse(url, it) }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,43 @@
|
||||
package com.mkfunproj.mobilemkch.data
|
||||
|
||||
import android.content.Context
|
||||
import androidx.datastore.preferences.core.Preferences
|
||||
import androidx.datastore.preferences.core.edit
|
||||
import androidx.datastore.preferences.core.stringPreferencesKey
|
||||
import androidx.datastore.preferences.preferencesDataStore
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.serialization.encodeToString
|
||||
import kotlinx.serialization.json.Json
|
||||
|
||||
private val Context.favDataStore by preferencesDataStore(name = "favorites")
|
||||
|
||||
class FavoritesStore(private val context: Context) {
|
||||
private object Keys { val list = stringPreferencesKey("list") }
|
||||
|
||||
val flow: Flow<List<FavoriteThread>> = context.favDataStore.data.map { prefs ->
|
||||
val raw = prefs[Keys.list] ?: "[]"
|
||||
runCatching { Json.decodeFromString<List<FavoriteThread>>(raw) }.getOrElse { emptyList() }
|
||||
}
|
||||
|
||||
suspend fun add(item: FavoriteThread) {
|
||||
context.favDataStore.edit { prefs ->
|
||||
val current = prefs[Keys.list]?.let { runCatching { Json.decodeFromString<List<FavoriteThread>>(it) }.getOrNull() } ?: emptyList()
|
||||
if (current.any { it.id == item.id && it.board == item.board }) return@edit
|
||||
val next = current + item
|
||||
prefs[Keys.list] = Json.encodeToString(next)
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun remove(threadId: Int, board: String) {
|
||||
context.favDataStore.edit { prefs ->
|
||||
val current = prefs[Keys.list]?.let { runCatching { Json.decodeFromString<List<FavoriteThread>>(it) }.getOrNull() } ?: emptyList()
|
||||
val next = current.filterNot { it.id == threadId && it.board == board }
|
||||
prefs[Keys.list] = Json.encodeToString(next)
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun clear() { context.favDataStore.edit { it.remove(Keys.list) } }
|
||||
}
|
||||
|
||||
|
||||
50
app/src/main/java/com/mkfunproj/mobilemkch/data/Models.kt
Normal file
@ -0,0 +1,50 @@
|
||||
package com.mkfunproj.mobilemkch.data
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class Board(
|
||||
val code: String,
|
||||
val description: String
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class ThreadItem(
|
||||
val id: Int,
|
||||
val title: String,
|
||||
val text: String,
|
||||
val creation: String,
|
||||
val board: String,
|
||||
val rating: Int? = null,
|
||||
val pinned: Boolean? = null,
|
||||
val files: List<String> = emptyList()
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class ThreadDetail(
|
||||
val id: Int,
|
||||
val creation: String,
|
||||
val title: String,
|
||||
val text: String,
|
||||
val board: String,
|
||||
val files: List<String> = emptyList()
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class Comment(
|
||||
val id: Int,
|
||||
val text: String,
|
||||
val creation: String,
|
||||
val files: List<String> = emptyList()
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class FavoriteThread(
|
||||
val id: Int,
|
||||
val title: String,
|
||||
val board: String,
|
||||
val boardDescription: String,
|
||||
val addedDate: Long
|
||||
)
|
||||
|
||||
|
||||
@ -0,0 +1,29 @@
|
||||
package com.mkfunproj.mobilemkch.data
|
||||
|
||||
import android.content.Context
|
||||
import android.net.ConnectivityManager
|
||||
import android.net.Network
|
||||
import android.net.NetworkCapabilities
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
|
||||
class NetworkMonitor(context: Context) {
|
||||
private val cm = context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
|
||||
private val _connected = MutableStateFlow(isCurrentlyConnected())
|
||||
val isConnected: StateFlow<Boolean> = _connected
|
||||
|
||||
init {
|
||||
cm.registerDefaultNetworkCallback(object : ConnectivityManager.NetworkCallback() {
|
||||
override fun onAvailable(network: Network) { _connected.value = true }
|
||||
override fun onLost(network: Network) { _connected.value = isCurrentlyConnected() }
|
||||
})
|
||||
}
|
||||
|
||||
private fun isCurrentlyConnected(): Boolean {
|
||||
val n = cm.activeNetwork ?: return false
|
||||
val caps = cm.getNetworkCapabilities(n) ?: return false
|
||||
return caps.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,61 @@
|
||||
package com.mkfunproj.mobilemkch.data
|
||||
|
||||
import android.content.Context
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
import kotlinx.serialization.encodeToString
|
||||
import kotlinx.serialization.json.Json
|
||||
|
||||
class Repository(context: Context) {
|
||||
private val api = ApiClient(context)
|
||||
private val cache = Cache(context)
|
||||
private val json = Json
|
||||
|
||||
suspend fun getBoards(offline: Boolean): List<Board> = withContext(Dispatchers.IO) {
|
||||
if (offline) {
|
||||
cache.getStale("boards") { json.decodeFromString(it) } ?: emptyList()
|
||||
} else {
|
||||
val cached = cache.get("boards") { json.decodeFromString<List<Board>>(it) }
|
||||
if (cached != null) return@withContext cached
|
||||
val boards = api.getBoards()
|
||||
cache.set("boards", boards, { json.encodeToString(it) }, ttlSeconds = 600)
|
||||
boards
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun getThreads(board: String, offline: Boolean): List<ThreadItem> = withContext(Dispatchers.IO) {
|
||||
if (offline) {
|
||||
cache.getStale("threads_$board") { json.decodeFromString(it) } ?: emptyList()
|
||||
} else {
|
||||
val cached = cache.get("threads_$board") { json.decodeFromString<List<ThreadItem>>(it) }
|
||||
if (cached != null) return@withContext cached
|
||||
val list = api.getThreads(board)
|
||||
cache.set("threads_$board", list, { json.encodeToString(it) }, ttlSeconds = 300)
|
||||
list
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun getThread(board: String, id: Int, offline: Boolean): ThreadDetail? = withContext(Dispatchers.IO) {
|
||||
if (offline) {
|
||||
cache.getStale("thread_$id") { json.decodeFromString(it) }
|
||||
} else {
|
||||
cache.get("thread_$id") { json.decodeFromString<ThreadDetail>(it) } ?: api.getThreadDetail(board, id).also {
|
||||
cache.set("thread_$id", it, { json.encodeToString(it) }, ttlSeconds = 180)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun getComments(board: String, id: Int, offline: Boolean): List<Comment> = withContext(Dispatchers.IO) {
|
||||
if (offline) {
|
||||
cache.getStale("comments_$id") { json.decodeFromString(it) } ?: emptyList()
|
||||
} else {
|
||||
val cached = cache.get("comments_$id") { json.decodeFromString<List<Comment>>(it) }
|
||||
if (cached != null) return@withContext cached
|
||||
val list = api.getComments(board, id)
|
||||
cache.set("comments_$id", list, { json.encodeToString(it) }, ttlSeconds = 180)
|
||||
list
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,87 @@
|
||||
package com.mkfunproj.mobilemkch.data
|
||||
|
||||
import android.content.Context
|
||||
import androidx.datastore.preferences.core.Preferences
|
||||
import androidx.datastore.preferences.core.edit
|
||||
import androidx.datastore.preferences.core.booleanPreferencesKey
|
||||
import androidx.datastore.preferences.core.intPreferencesKey
|
||||
import androidx.datastore.preferences.core.stringPreferencesKey
|
||||
import androidx.datastore.preferences.preferencesDataStore
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.map
|
||||
|
||||
private val Context.dataStore by preferencesDataStore(name = "settings")
|
||||
|
||||
data class SettingsData(
|
||||
val theme: String = "dark",
|
||||
val lastBoard: String = "",
|
||||
val autoRefresh: Boolean = true,
|
||||
val showFiles: Boolean = true,
|
||||
val compactMode: Boolean = false,
|
||||
val pageSize: Int = 10,
|
||||
val enablePagination: Boolean = false,
|
||||
val enableUnstableFeatures: Boolean = false,
|
||||
val passcode: String = "",
|
||||
val key: String = "",
|
||||
val notificationsEnabled: Boolean = false,
|
||||
val notificationInterval: Int = 900,
|
||||
val offlineMode: Boolean = false
|
||||
)
|
||||
|
||||
class SettingsStore(private val context: Context) {
|
||||
private object Keys {
|
||||
val theme = stringPreferencesKey("theme")
|
||||
val lastBoard = stringPreferencesKey("lastBoard")
|
||||
val autoRefresh = booleanPreferencesKey("autoRefresh")
|
||||
val showFiles = booleanPreferencesKey("showFiles")
|
||||
val compactMode = booleanPreferencesKey("compactMode")
|
||||
val pageSize = intPreferencesKey("pageSize")
|
||||
val enablePagination = booleanPreferencesKey("enablePagination")
|
||||
val enableUnstable = booleanPreferencesKey("enableUnstableFeatures")
|
||||
val passcode = stringPreferencesKey("passcode")
|
||||
val key = stringPreferencesKey("key")
|
||||
val notificationsEnabled = booleanPreferencesKey("notificationsEnabled")
|
||||
val notificationInterval = intPreferencesKey("notificationInterval")
|
||||
val offlineMode = booleanPreferencesKey("offlineMode")
|
||||
}
|
||||
|
||||
val data: Flow<SettingsData> = context.dataStore.data.map { p -> p.toSettings() }
|
||||
|
||||
suspend fun update(transform: (SettingsData) -> SettingsData) {
|
||||
context.dataStore.edit { prefs ->
|
||||
val current = prefs.toSettings()
|
||||
val next = transform(current)
|
||||
prefs[Keys.theme] = next.theme
|
||||
prefs[Keys.lastBoard] = next.lastBoard
|
||||
prefs[Keys.autoRefresh] = next.autoRefresh
|
||||
prefs[Keys.showFiles] = next.showFiles
|
||||
prefs[Keys.compactMode] = next.compactMode
|
||||
prefs[Keys.pageSize] = next.pageSize
|
||||
prefs[Keys.enablePagination] = next.enablePagination
|
||||
prefs[Keys.enableUnstable] = next.enableUnstableFeatures
|
||||
prefs[Keys.passcode] = next.passcode
|
||||
prefs[Keys.key] = next.key
|
||||
prefs[Keys.notificationsEnabled] = next.notificationsEnabled
|
||||
prefs[Keys.notificationInterval] = next.notificationInterval
|
||||
prefs[Keys.offlineMode] = next.offlineMode
|
||||
}
|
||||
}
|
||||
|
||||
private fun Preferences.toSettings(): SettingsData = SettingsData(
|
||||
theme = this[Keys.theme] ?: "dark",
|
||||
lastBoard = this[Keys.lastBoard] ?: "",
|
||||
autoRefresh = this[Keys.autoRefresh] ?: true,
|
||||
showFiles = this[Keys.showFiles] ?: true,
|
||||
compactMode = this[Keys.compactMode] ?: false,
|
||||
pageSize = this[Keys.pageSize] ?: 10,
|
||||
enablePagination = this[Keys.enablePagination] ?: false,
|
||||
enableUnstableFeatures = this[Keys.enableUnstable] ?: false,
|
||||
passcode = this[Keys.passcode] ?: "",
|
||||
key = this[Keys.key] ?: "",
|
||||
notificationsEnabled = this[Keys.notificationsEnabled] ?: false,
|
||||
notificationInterval = this[Keys.notificationInterval] ?: 300,
|
||||
offlineMode = this[Keys.offlineMode] ?: false
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,44 @@
|
||||
package com.mkfunproj.mobilemkch.data
|
||||
|
||||
import android.content.Context
|
||||
import androidx.datastore.preferences.core.edit
|
||||
import androidx.datastore.preferences.core.stringPreferencesKey
|
||||
import androidx.datastore.preferences.preferencesDataStore
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.first
|
||||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.serialization.encodeToString
|
||||
import kotlinx.serialization.json.Json
|
||||
|
||||
private val Context.subsDataStore by preferencesDataStore(name = "subscriptions")
|
||||
|
||||
class SubscriptionsStore(private val context: Context) {
|
||||
private object Keys { val boards = stringPreferencesKey("boards") }
|
||||
|
||||
val flow: Flow<Set<String>> = context.subsDataStore.data.map { prefs ->
|
||||
val raw = prefs[Keys.boards] ?: "[]"
|
||||
runCatching { Json.decodeFromString<List<String>>(raw).toSet() }.getOrElse { emptySet() }
|
||||
}
|
||||
|
||||
suspend fun add(board: String) {
|
||||
context.subsDataStore.edit { prefs ->
|
||||
val current = prefs[Keys.boards]?.let { runCatching { Json.decodeFromString<List<String>>(it) }.getOrNull() }?.toMutableSet() ?: mutableSetOf()
|
||||
current.add(board)
|
||||
prefs[Keys.boards] = Json.encodeToString(current.toList())
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun remove(board: String) {
|
||||
context.subsDataStore.edit { prefs ->
|
||||
val current = prefs[Keys.boards]?.let { runCatching { Json.decodeFromString<List<String>>(it) }.getOrNull() }?.toMutableSet() ?: mutableSetOf()
|
||||
current.remove(board)
|
||||
prefs[Keys.boards] = Json.encodeToString(current.toList())
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun clear() { context.subsDataStore.edit { it.remove(Keys.boards) } }
|
||||
|
||||
suspend fun getNow(): Set<String> = flow.first()
|
||||
}
|
||||
|
||||
|
||||
118
app/src/main/java/com/mkfunproj/mobilemkch/ui/AppRoot.kt
Normal file
@ -0,0 +1,118 @@
|
||||
package com.mkfunproj.mobilemkch.ui
|
||||
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.NavigationBar
|
||||
import androidx.compose.material3.NavigationBarItem
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Favorite
|
||||
import androidx.compose.material.icons.filled.List
|
||||
import androidx.compose.material.icons.filled.Settings
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.navigation.compose.NavHost
|
||||
import androidx.navigation.compose.composable
|
||||
import androidx.navigation.compose.currentBackStackEntryAsState
|
||||
import androidx.navigation.compose.rememberNavController
|
||||
import com.mkfunproj.mobilemkch.ui.screens.BoardsScreen
|
||||
import com.mkfunproj.mobilemkch.ui.screens.ThreadDetailScreen
|
||||
import com.mkfunproj.mobilemkch.ui.screens.FavoritesScreen
|
||||
import com.mkfunproj.mobilemkch.ui.screens.SettingsScreen
|
||||
import com.mkfunproj.mobilemkch.ui.screens.ThreadsScreen
|
||||
import com.mkfunproj.mobilemkch.ui.screens.AddCommentScreen
|
||||
import com.mkfunproj.mobilemkch.ui.screens.CreateThreadScreen
|
||||
|
||||
@Composable
|
||||
fun AppRoot() {
|
||||
val navController = rememberNavController()
|
||||
val navBackStackEntry by navController.currentBackStackEntryAsState()
|
||||
val currentRoute = navBackStackEntry?.destination?.route ?: "boards"
|
||||
Scaffold(
|
||||
bottomBar = {
|
||||
NavigationBar {
|
||||
NavigationBarItem(
|
||||
selected = currentRoute.startsWith("favorites"),
|
||||
onClick = {
|
||||
navController.navigate("favorites") {
|
||||
popUpTo(navController.graph.startDestinationId) { saveState = true }
|
||||
launchSingleTop = true
|
||||
restoreState = true
|
||||
}
|
||||
},
|
||||
icon = { Icon(Icons.Default.Favorite, contentDescription = null) },
|
||||
label = { Text("Избранное") }
|
||||
)
|
||||
NavigationBarItem(
|
||||
selected = currentRoute.startsWith("boards"),
|
||||
onClick = {
|
||||
navController.navigate("boards") {
|
||||
popUpTo(navController.graph.startDestinationId) { saveState = true }
|
||||
launchSingleTop = true
|
||||
restoreState = true
|
||||
}
|
||||
},
|
||||
icon = { Icon(Icons.Default.List, contentDescription = null) },
|
||||
label = { Text("Доски") }
|
||||
)
|
||||
NavigationBarItem(
|
||||
selected = currentRoute.startsWith("settings"),
|
||||
onClick = {
|
||||
navController.navigate("settings") {
|
||||
popUpTo(navController.graph.startDestinationId) { saveState = true }
|
||||
launchSingleTop = true
|
||||
restoreState = true
|
||||
}
|
||||
},
|
||||
icon = { Icon(Icons.Default.Settings, contentDescription = null) },
|
||||
label = { Text("Настройки") }
|
||||
)
|
||||
}
|
||||
}
|
||||
) { padding ->
|
||||
NavHost(
|
||||
navController = navController,
|
||||
startDestination = "boards",
|
||||
modifier = Modifier.fillMaxSize().padding(padding)
|
||||
) {
|
||||
composable("boards") {
|
||||
BoardsScreen(
|
||||
onOpenThreads = { boardCode, boardDesc ->
|
||||
navController.navigate("threads/$boardCode/$boardDesc")
|
||||
}
|
||||
)
|
||||
}
|
||||
composable("favorites") { FavoritesScreen(onOpen = { board, id -> navController.navigate("thread/$board/$id") }) }
|
||||
composable("settings") { SettingsScreen() }
|
||||
composable("threads/{board}/{desc}") { backStack ->
|
||||
val board = backStack.arguments?.getString("board").orEmpty()
|
||||
val desc = backStack.arguments?.getString("desc").orEmpty()
|
||||
ThreadsScreen(
|
||||
boardCode = board,
|
||||
boardDescription = desc,
|
||||
onOpenThread = { threadId -> navController.navigate("thread/$board/$threadId") },
|
||||
onCreateThread = { navController.navigate("threads/$board/new") }
|
||||
)
|
||||
}
|
||||
composable("thread/{board}/{id}") { backStack ->
|
||||
val board = backStack.arguments?.getString("board").orEmpty()
|
||||
val id = backStack.arguments?.getString("id")?.toIntOrNull() ?: 0
|
||||
ThreadDetailScreen(boardCode = board, threadId = id, onAddComment = { navController.navigate("thread/$board/$id/comment") })
|
||||
}
|
||||
composable("thread/{board}/{id}/comment") { backStack ->
|
||||
val board = backStack.arguments?.getString("board").orEmpty()
|
||||
val id = backStack.arguments?.getString("id")?.toIntOrNull() ?: 0
|
||||
AddCommentScreen(boardCode = board, threadId = id)
|
||||
}
|
||||
composable("threads/{board}/new") { backStack ->
|
||||
val board = backStack.arguments?.getString("board").orEmpty()
|
||||
CreateThreadScreen(boardCode = board)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,97 @@
|
||||
package com.mkfunproj.mobilemkch.ui.screens
|
||||
|
||||
import android.app.Application
|
||||
import android.content.ContentResolver
|
||||
import android.content.Context
|
||||
import android.net.Uri
|
||||
import androidx.activity.compose.rememberLauncherForActivityResult
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.lazy.LazyRow
|
||||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.OutlinedTextField
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TopAppBar
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.lifecycle.AndroidViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||
import coil.compose.AsyncImage
|
||||
import com.mkfunproj.mobilemkch.data.ApiClient
|
||||
import com.mkfunproj.mobilemkch.data.SettingsStore
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.flow.first
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import java.io.File
|
||||
import java.io.FileOutputStream
|
||||
import com.mkfunproj.mobilemkch.util.ImageUtil
|
||||
import java.io.InputStream
|
||||
|
||||
class AddCommentVm(app: Application) : AndroidViewModel(app) {
|
||||
private val api = ApiClient(app)
|
||||
var isLoading by mutableStateOf(false)
|
||||
var error by mutableStateOf<String?>(null)
|
||||
fun send(context: Context, board: String, id: Int, text: String, uris: List<Uri>, onDone: () -> Unit) {
|
||||
isLoading = true
|
||||
error = null
|
||||
viewModelScope.launch {
|
||||
val settings = SettingsStore(getApplication()).data.first()
|
||||
val files = withContext(Dispatchers.IO) { uris.mapNotNull { uri -> ImageUtil.downscaleJpeg(context, uri) } }
|
||||
runCatching { api.addComment(board, id, text, files, passcode = settings.passcode, authKey = settings.key) }
|
||||
.onSuccess { onDone() }
|
||||
.onFailure { error = it.message }
|
||||
isLoading = false
|
||||
withContext(Dispatchers.IO) { files.forEach { it.delete() } }
|
||||
}
|
||||
}
|
||||
private fun copyUriToTemp(context: Context, uri: Uri): File? = ImageUtil.downscaleJpeg(context, uri)
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun AddCommentScreen(boardCode: String, threadId: Int, vm: AddCommentVm = viewModel()) {
|
||||
val context = androidx.compose.ui.platform.LocalContext.current
|
||||
var text by remember { mutableStateOf("") }
|
||||
var picked by remember { mutableStateOf<List<Uri>>(emptyList()) }
|
||||
val launcher = rememberLauncherForActivityResult(ActivityResultContracts.GetMultipleContents()) { result ->
|
||||
picked = result.take(4)
|
||||
}
|
||||
Scaffold(topBar = { TopAppBar(title = { Text("#$threadId Коммент") }) }) { padding ->
|
||||
Column(Modifier.fillMaxSize().padding(padding).padding(16.dp)) {
|
||||
OutlinedTextField(value = text, onValueChange = { text = it }, label = { Text("Текст") }, modifier = Modifier.fillMaxSize().weight(1f))
|
||||
Spacer(Modifier.height(8.dp))
|
||||
Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
Button(onClick = { launcher.launch("image/*") }) { Text("Фото") }
|
||||
}
|
||||
if (picked.isNotEmpty()) {
|
||||
LazyRow(horizontalArrangement = Arrangement.spacedBy(8.dp), modifier = Modifier.padding(top = 8.dp)) {
|
||||
items(picked) { uri ->
|
||||
AsyncImage(model = uri, contentDescription = null, modifier = Modifier.size(64.dp))
|
||||
}
|
||||
}
|
||||
}
|
||||
if (vm.error != null) Text(vm.error ?: "")
|
||||
Button(onClick = { vm.send(context, boardCode, threadId, text, picked) {} }, enabled = text.isNotEmpty() && !vm.isLoading, modifier = Modifier.padding(top = 8.dp)) { Text(if (vm.isLoading) "Отправка..." else "Добавить") }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,116 @@
|
||||
package com.mkfunproj.mobilemkch.ui.screens
|
||||
|
||||
import android.app.Application
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.material3.Card
|
||||
import androidx.compose.material3.CardDefaults
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.material3.CircularProgressIndicator
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.SnackbarHost
|
||||
import androidx.compose.material3.SnackbarHostState
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TopAppBar
|
||||
import androidx.compose.material3.TextButton
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.lifecycle.AndroidViewModel
|
||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||
import com.mkfunproj.mobilemkch.data.Board
|
||||
import com.mkfunproj.mobilemkch.data.Repository
|
||||
import com.mkfunproj.mobilemkch.data.SettingsStore
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.delay
|
||||
|
||||
class BoardsVm(app: Application) : AndroidViewModel(app) {
|
||||
private val repo = Repository(app)
|
||||
private val settings = SettingsStore(app)
|
||||
var isLoading by mutableStateOf(false)
|
||||
var error by mutableStateOf<String?>(null)
|
||||
var boards by mutableStateOf<List<Board>>(emptyList())
|
||||
var offline by mutableStateOf(false)
|
||||
|
||||
init {
|
||||
viewModelScope.launch { settings.data.collect { offline = it.offlineMode } }
|
||||
}
|
||||
|
||||
suspend fun load() {
|
||||
isLoading = true
|
||||
error = null
|
||||
runCatching { repo.getBoards(offline) }
|
||||
.onSuccess { boards = it }
|
||||
.onFailure { error = it.message }
|
||||
isLoading = false
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun BoardsScreen(
|
||||
onOpenThreads: (boardCode: String, boardDesc: String) -> Unit,
|
||||
vm: BoardsVm = viewModel()
|
||||
) {
|
||||
val snackbar = remember { SnackbarHostState() }
|
||||
val scope = androidx.compose.runtime.rememberCoroutineScope()
|
||||
LaunchedEffect(Unit) { vm.load() }
|
||||
Scaffold(topBar = {
|
||||
TopAppBar(title = { Text("Доски mkch") }, actions = {
|
||||
TextButton(onClick = { scope.launch { vm.load() } }) { Text("Обновить") }
|
||||
})
|
||||
}, snackbarHost = { SnackbarHost(snackbar) }) { padding ->
|
||||
Column(Modifier.fillMaxSize().padding(padding)) {
|
||||
if (vm.offline) {
|
||||
Text("Оффлайн режим. Показаны сохранённые данные", color = MaterialTheme.colorScheme.secondary, modifier = Modifier.padding(12.dp))
|
||||
}
|
||||
when {
|
||||
vm.isLoading -> CircularProgressIndicator(Modifier.padding(16.dp))
|
||||
vm.error != null -> Column(Modifier.padding(16.dp)) {
|
||||
Text(vm.error ?: "", color = MaterialTheme.colorScheme.error)
|
||||
TextButton(onClick = { scope.launch { vm.load() } }) { Text("Повторить") }
|
||||
}
|
||||
else -> BoardsList(PaddingValues(12.dp), vm.boards) { onOpenThreads(it.code, it.description) }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun BoardsList(padding: PaddingValues, itemsList: List<Board>, onClick: (Board) -> Unit) {
|
||||
LazyColumn(
|
||||
contentPadding = padding,
|
||||
verticalArrangement = Arrangement.spacedBy(8.dp),
|
||||
modifier = Modifier.fillMaxSize().padding(12.dp)
|
||||
) {
|
||||
items(itemsList) { board ->
|
||||
val desc = if (board.description.isEmpty()) "Без описания" else board.description
|
||||
Card(colors = CardDefaults.cardColors(), modifier = Modifier.fillMaxWidth().clickable { onClick(board) }) {
|
||||
Column(Modifier.padding(12.dp)) {
|
||||
Text(text = "/${board.code}/", style = MaterialTheme.typography.titleMedium, color = MaterialTheme.colorScheme.primary)
|
||||
Spacer(Modifier.height(2.dp))
|
||||
Text(text = desc, style = MaterialTheme.typography.bodyMedium, maxLines = 2)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,102 @@
|
||||
package com.mkfunproj.mobilemkch.ui.screens
|
||||
|
||||
import android.app.Application
|
||||
import android.content.Context
|
||||
import android.net.Uri
|
||||
import androidx.activity.compose.rememberLauncherForActivityResult
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.lazy.LazyRow
|
||||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.OutlinedTextField
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TopAppBar
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.lifecycle.AndroidViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||
import coil.compose.AsyncImage
|
||||
import com.mkfunproj.mobilemkch.data.ApiClient
|
||||
import com.mkfunproj.mobilemkch.data.SettingsStore
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.flow.first
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import java.io.File
|
||||
import java.io.FileOutputStream
|
||||
import com.mkfunproj.mobilemkch.util.ImageUtil
|
||||
|
||||
class CreateThreadVm(app: Application) : AndroidViewModel(app) {
|
||||
private val api = ApiClient(app)
|
||||
var isLoading by mutableStateOf(false)
|
||||
var error by mutableStateOf<String?>(null)
|
||||
fun create(context: Context, board: String, title: String, text: String, uris: List<Uri>, onDone: () -> Unit) {
|
||||
isLoading = true
|
||||
error = null
|
||||
viewModelScope.launch {
|
||||
val settings = SettingsStore(getApplication()).data.first()
|
||||
val files = withContext(Dispatchers.IO) { uris.mapNotNull { uri -> ImageUtil.downscaleJpeg(context, uri) } }
|
||||
runCatching { api.createThread(board, title, text, files, passcode = settings.passcode, authKey = settings.key) }
|
||||
.onSuccess { onDone() }
|
||||
.onFailure { error = it.message }
|
||||
isLoading = false
|
||||
withContext(Dispatchers.IO) { files.forEach { it.delete() } }
|
||||
}
|
||||
}
|
||||
private fun copyUriToTemp(context: Context, uri: Uri): File? = ImageUtil.downscaleJpeg(context, uri)
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun CreateThreadScreen(boardCode: String, vm: CreateThreadVm = viewModel()) {
|
||||
val context = androidx.compose.ui.platform.LocalContext.current
|
||||
var title by remember { mutableStateOf("") }
|
||||
var text by remember { mutableStateOf("") }
|
||||
var picked by remember { mutableStateOf<List<Uri>>(emptyList()) }
|
||||
val launcher = rememberLauncherForActivityResult(ActivityResultContracts.GetMultipleContents()) { result ->
|
||||
picked = result.take(4)
|
||||
}
|
||||
Scaffold(topBar = { TopAppBar(title = { Text("/$boardCode/ Новый тред") }) }) { padding ->
|
||||
Column(Modifier.fillMaxSize().padding(padding).padding(16.dp)) {
|
||||
OutlinedTextField(value = title, onValueChange = { title = it }, label = { Text("Заголовок") }, modifier = Modifier.fillMaxWidth().padding(bottom = 8.dp))
|
||||
OutlinedTextField(
|
||||
value = text,
|
||||
onValueChange = { text = it },
|
||||
label = { Text("Текст") },
|
||||
modifier = Modifier.fillMaxWidth().weight(1f),
|
||||
minLines = 6,
|
||||
maxLines = 12
|
||||
)
|
||||
Spacer(Modifier.height(8.dp))
|
||||
Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
Button(onClick = { launcher.launch("image/*") }) { Text("Фото") }
|
||||
}
|
||||
if (picked.isNotEmpty()) {
|
||||
LazyRow(horizontalArrangement = Arrangement.spacedBy(8.dp), modifier = Modifier.padding(top = 8.dp)) {
|
||||
items(picked) { uri -> AsyncImage(model = uri, contentDescription = null, modifier = Modifier.size(64.dp)) }
|
||||
}
|
||||
}
|
||||
if (vm.error != null) Text(vm.error ?: "")
|
||||
Button(onClick = { vm.create(context, boardCode, title, text, picked) {} }, enabled = title.isNotEmpty() && text.isNotEmpty() && !vm.isLoading, modifier = Modifier.padding(top = 8.dp)) { Text(if (vm.isLoading) "Отправка..." else "Создать") }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,67 @@
|
||||
package com.mkfunproj.mobilemkch.ui.screens
|
||||
|
||||
import android.app.Application
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.Card
|
||||
import androidx.compose.material3.CardDefaults
|
||||
import androidx.compose.material3.TopAppBar
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.lifecycle.AndroidViewModel
|
||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||
import com.mkfunproj.mobilemkch.data.FavoriteThread
|
||||
import com.mkfunproj.mobilemkch.data.FavoritesStore
|
||||
|
||||
class FavoritesVm(app: Application) : AndroidViewModel(app) {
|
||||
private val store = FavoritesStore(app)
|
||||
var items by mutableStateOf<List<FavoriteThread>>(emptyList())
|
||||
suspend fun observe() { store.flow.collect { items = it } }
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun FavoritesScreen(vm: FavoritesVm = viewModel(), onOpen: (board: String, id: Int) -> Unit = { _, _ -> }) {
|
||||
LaunchedEffect(Unit) { vm.observe() }
|
||||
Scaffold(topBar = { TopAppBar(title = { Text("Избранное") }) }) { padding ->
|
||||
LazyColumn(
|
||||
contentPadding = padding,
|
||||
verticalArrangement = Arrangement.spacedBy(8.dp),
|
||||
modifier = Modifier.fillMaxSize().padding(12.dp)
|
||||
) {
|
||||
if (vm.items.isEmpty()) {
|
||||
item { Text("Пока пусто") }
|
||||
} else {
|
||||
items(vm.items) { fav ->
|
||||
Card(colors = CardDefaults.cardColors()) {
|
||||
Column(Modifier.padding(12.dp).clickable { onOpen(fav.board, fav.id) }) {
|
||||
Text(fav.title, style = androidx.compose.material3.MaterialTheme.typography.titleMedium, maxLines = 2)
|
||||
Row {
|
||||
Text("/${fav.board}/", color = androidx.compose.material3.MaterialTheme.colorScheme.primary)
|
||||
Spacer(Modifier.weight(1f))
|
||||
Text(java.text.SimpleDateFormat("yyyy-MM-dd").format(java.util.Date(fav.addedDate)))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,149 @@
|
||||
package com.mkfunproj.mobilemkch.ui.screens
|
||||
|
||||
import android.app.Application
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material3.Checkbox
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.OutlinedTextField
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TopAppBar
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.mkfunproj.mobilemkch.data.Board
|
||||
import com.mkfunproj.mobilemkch.data.Repository
|
||||
import com.mkfunproj.mobilemkch.data.SubscriptionsStore
|
||||
import kotlinx.coroutines.launch
|
||||
import com.mkfunproj.mobilemkch.util.NotificationHelper
|
||||
import androidx.work.ExistingWorkPolicy
|
||||
import androidx.work.OneTimeWorkRequestBuilder
|
||||
import androidx.work.WorkManager
|
||||
import com.mkfunproj.mobilemkch.workers.ThreadsCheckWorker
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.collectAsState
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.lifecycle.AndroidViewModel
|
||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||
import com.mkfunproj.mobilemkch.data.SettingsData
|
||||
import com.mkfunproj.mobilemkch.data.SettingsStore
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
class SettingsVm(app: Application) : AndroidViewModel(app) {
|
||||
private val store = SettingsStore(app)
|
||||
private val subs = SubscriptionsStore(app)
|
||||
private val repo = Repository(app)
|
||||
val flow = store.data
|
||||
val subsFlow = subs.flow
|
||||
var boards by mutableStateOf<List<Board>>(emptyList())
|
||||
fun update(transform: (SettingsData) -> SettingsData) {
|
||||
viewModelScope.launch { store.update(transform) }
|
||||
}
|
||||
fun toggleSub(board: String, enabled: Boolean) { viewModelScope.launch { if (enabled) subs.add(board) else subs.remove(board) } }
|
||||
fun loadBoards() { viewModelScope.launch { boards = runCatching { repo.getBoards(offline = false) }.getOrElse { emptyList() } } }
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun SettingsScreen(vm: SettingsVm = viewModel()) {
|
||||
val settings by vm.flow.collectAsState(initial = SettingsData())
|
||||
val subs by vm.subsFlow.collectAsState(initial = emptySet())
|
||||
LaunchedEffect(Unit) { vm.loadBoards() }
|
||||
Scaffold(topBar = { TopAppBar(title = { Text("Настройки") }) }) { padding ->
|
||||
Column(Modifier.fillMaxSize().padding(padding).padding(16.dp), verticalArrangement = Arrangement.spacedBy(12.dp)) {
|
||||
Row(Modifier.fillMaxWidth()) {
|
||||
Text("Показывать файлы", modifier = Modifier.weight(1f))
|
||||
Checkbox(checked = settings.showFiles, onCheckedChange = { vm.update { it.copy(showFiles = it.showFiles.not()) } })
|
||||
}
|
||||
Row(Modifier.fillMaxWidth()) {
|
||||
Text("Компактный режим", modifier = Modifier.weight(1f))
|
||||
Checkbox(checked = settings.compactMode, onCheckedChange = { vm.update { it.copy(compactMode = it.compactMode.not()) } })
|
||||
}
|
||||
Row(Modifier.fillMaxWidth()) {
|
||||
Text("Разстраничивание", modifier = Modifier.weight(1f))
|
||||
Checkbox(checked = settings.enablePagination, onCheckedChange = { vm.update { it.copy(enablePagination = it.enablePagination.not()) } })
|
||||
}
|
||||
Row(Modifier.fillMaxWidth()) {
|
||||
Text("Тема", modifier = Modifier.weight(1f))
|
||||
val themeLabel = if(settings.theme=="oled") "OLED" else "Тёмная"
|
||||
Button(onClick = {
|
||||
val next = if(settings.theme=="oled") "dark" else "oled"
|
||||
vm.update { it.copy(theme = next) }
|
||||
}) { Text(themeLabel) }
|
||||
}
|
||||
OutlinedTextField(
|
||||
value = settings.passcode,
|
||||
onValueChange = { v -> vm.update { it.copy(passcode = v) } },
|
||||
label = { Text("Passcode для постинга") },
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
)
|
||||
OutlinedTextField(
|
||||
value = settings.key,
|
||||
onValueChange = { v -> vm.update { it.copy(key = v) } },
|
||||
label = { Text("Ключ аутентификации") },
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
)
|
||||
Row(Modifier.fillMaxWidth()) {
|
||||
Text("Уведомления (beta)", modifier = Modifier.weight(1f))
|
||||
Checkbox(checked = settings.notificationsEnabled, onCheckedChange = { vm.update { it.copy(notificationsEnabled = it.notificationsEnabled.not()) } })
|
||||
}
|
||||
if (settings.notificationsEnabled) {
|
||||
Text("Подписки на доски")
|
||||
if (vm.boards.isEmpty()) {
|
||||
Text("Загрузка...")
|
||||
} else {
|
||||
LazyColumn(verticalArrangement = Arrangement.spacedBy(8.dp), modifier = Modifier.weight(1f)) {
|
||||
items(vm.boards) { b ->
|
||||
Row(Modifier.fillMaxWidth()) {
|
||||
Text("/${'$'}{b.code}/ ${'$'}{b.description}", modifier = Modifier.weight(1f))
|
||||
val on = subs.contains(b.code)
|
||||
Checkbox(checked = on, onCheckedChange = { vm.toggleSub(b.code, !on) })
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
val ctx = androidx.compose.ui.platform.LocalContext.current
|
||||
Row(Modifier.fillMaxWidth()) {
|
||||
Button(onClick = { NotificationHelper.notifyTest(ctx) }) { Text("Тест-уведомление") }
|
||||
Spacer(Modifier.weight(1f))
|
||||
Button(onClick = {
|
||||
val req = OneTimeWorkRequestBuilder<ThreadsCheckWorker>().build()
|
||||
WorkManager.getInstance(ctx).enqueueUniqueWork("mkch_threads_check_now", ExistingWorkPolicy.REPLACE, req)
|
||||
}) { Text("Проверить сейчас") }
|
||||
}
|
||||
Row(Modifier.fillMaxWidth()) {
|
||||
Text("Интервал проверки", modifier = Modifier.weight(1f))
|
||||
val options = listOf(300 to "5 мин", 900 to "15 мин", 1800 to "30 мин", 3600 to "1 час")
|
||||
androidx.compose.material3.TextButton(onClick = {
|
||||
val idx = options.indexOfFirst { it.first == settings.notificationInterval }.let { if (it == -1) 1 else it }
|
||||
val next = options[(idx + 1) % options.size].first
|
||||
vm.update { it.copy(notificationInterval = next) }
|
||||
val req = OneTimeWorkRequestBuilder<ThreadsCheckWorker>().build()
|
||||
WorkManager.getInstance(ctx).enqueueUniqueWork("mkch_threads_check_now", ExistingWorkPolicy.REPLACE, req)
|
||||
}) { Text(options.find { it.first == settings.notificationInterval }?.second ?: "15 мин") }
|
||||
}
|
||||
}
|
||||
Row(Modifier.fillMaxWidth()) {
|
||||
Text("Принудительно оффлайн", modifier = Modifier.weight(1f))
|
||||
Checkbox(checked = settings.offlineMode, onCheckedChange = { vm.update { it.copy(offlineMode = it.offlineMode.not()) } })
|
||||
}
|
||||
Spacer(Modifier.weight(1f))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,130 @@
|
||||
package com.mkfunproj.mobilemkch.ui.screens
|
||||
|
||||
import android.app.Application
|
||||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.material3.CircularProgressIndicator
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.FloatingActionButton
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Add
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.TopAppBar
|
||||
import androidx.compose.material3.Card
|
||||
import androidx.compose.material3.CardDefaults
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.lifecycle.AndroidViewModel
|
||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||
import com.mkfunproj.mobilemkch.data.Comment
|
||||
import com.mkfunproj.mobilemkch.data.Repository
|
||||
import com.mkfunproj.mobilemkch.data.ThreadDetail
|
||||
import coil.compose.AsyncImage
|
||||
import com.mkfunproj.mobilemkch.data.SettingsStore
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
class ThreadDetailVm(app: Application) : AndroidViewModel(app) {
|
||||
private val repo = Repository(app)
|
||||
private val settings = SettingsStore(app)
|
||||
var isLoading by mutableStateOf(false)
|
||||
var error by mutableStateOf<String?>(null)
|
||||
var detail by mutableStateOf<ThreadDetail?>(null)
|
||||
var comments by mutableStateOf<List<Comment>>(emptyList())
|
||||
var offline by mutableStateOf(false)
|
||||
|
||||
init { viewModelScope.launch { settings.data.collect { offline = it.offlineMode } } }
|
||||
|
||||
suspend fun load(board: String, id: Int) {
|
||||
isLoading = true
|
||||
error = null
|
||||
runCatching {
|
||||
val d = repo.getThread(board, id, offline)
|
||||
val c = repo.getComments(board, id, offline)
|
||||
d to c
|
||||
}.onSuccess { (d, c) ->
|
||||
detail = d
|
||||
comments = c
|
||||
}.onFailure { error = it.message }
|
||||
isLoading = false
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun ThreadDetailScreen(
|
||||
boardCode: String,
|
||||
threadId: Int,
|
||||
vm: ThreadDetailVm = viewModel(),
|
||||
onAddComment: () -> Unit = {}
|
||||
) {
|
||||
val scope = androidx.compose.runtime.rememberCoroutineScope()
|
||||
LaunchedEffect(threadId) { vm.load(boardCode, threadId) }
|
||||
Scaffold(
|
||||
topBar = { TopAppBar(title = { Text("#$threadId") }, actions = { androidx.compose.material3.TextButton(onClick = { scope.launch { vm.load(boardCode, threadId) } }) { Text("Обновить") } }) },
|
||||
floatingActionButton = { FloatingActionButton(onClick = onAddComment) { Icon(Icons.Default.Add, contentDescription = "Add") } }
|
||||
) { padding ->
|
||||
when {
|
||||
vm.isLoading -> CircularProgressIndicator(Modifier.padding(16.dp))
|
||||
vm.error != null -> Text(vm.error ?: "", color = MaterialTheme.colorScheme.error, modifier = Modifier.padding(16.dp))
|
||||
else -> Content(padding, vm.detail, vm.comments)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun Content(padding: PaddingValues, detail: ThreadDetail?, comments: List<Comment>) {
|
||||
LazyColumn(
|
||||
contentPadding = PaddingValues(
|
||||
top = padding.calculateTopPadding(),
|
||||
bottom = padding.calculateBottomPadding(),
|
||||
start = 12.dp,
|
||||
end = 12.dp
|
||||
),
|
||||
verticalArrangement = Arrangement.spacedBy(12.dp),
|
||||
modifier = Modifier.fillMaxSize()
|
||||
) {
|
||||
if (detail != null) {
|
||||
item {
|
||||
Card(colors = CardDefaults.cardColors()) {
|
||||
androidx.compose.foundation.layout.Column(Modifier.padding(12.dp)) {
|
||||
Text(detail.title, style = MaterialTheme.typography.titleLarge)
|
||||
Text("/${detail.board}/", style = MaterialTheme.typography.labelSmall, color = MaterialTheme.colorScheme.primary)
|
||||
if (detail.files.isNotEmpty()) { detail.files.forEach { f -> AsyncImage(model = "https://mkch.pooziqo.xyz$f", contentDescription = null) } }
|
||||
if (detail.text.isNotEmpty()) Text(detail.text, style = MaterialTheme.typography.bodyMedium)
|
||||
}
|
||||
}
|
||||
}
|
||||
item { androidx.compose.material3.Divider() }
|
||||
item { Text("Комментарии (${comments.size})", style = MaterialTheme.typography.titleMedium) }
|
||||
}
|
||||
items(comments) { c ->
|
||||
Card(colors = CardDefaults.cardColors()) {
|
||||
androidx.compose.foundation.layout.Column(Modifier.padding(12.dp)) {
|
||||
androidx.compose.foundation.layout.Row {
|
||||
Text("ID: ${c.id}", style = MaterialTheme.typography.labelSmall, color = MaterialTheme.colorScheme.secondary)
|
||||
androidx.compose.foundation.layout.Spacer(Modifier.weight(1f))
|
||||
Text(c.creation.take(10), style = MaterialTheme.typography.labelSmall, color = MaterialTheme.colorScheme.secondary)
|
||||
}
|
||||
if (c.files.isNotEmpty()) { c.files.forEach { f -> AsyncImage(model = "https://mkch.pooziqo.xyz$f", contentDescription = null) } }
|
||||
if (c.text.isNotEmpty()) Text(c.text.replace("#", ">>"), style = MaterialTheme.typography.bodyMedium)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,199 @@
|
||||
package com.mkfunproj.mobilemkch.ui.screens
|
||||
|
||||
import android.app.Application
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.material3.CircularProgressIndicator
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.TopAppBar
|
||||
import androidx.compose.material3.Divider
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Favorite
|
||||
import androidx.compose.material.icons.outlined.FavoriteBorder
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material.icons.filled.Star
|
||||
import androidx.compose.material.icons.filled.PushPin
|
||||
import androidx.compose.material.icons.filled.AttachFile
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.lifecycle.AndroidViewModel
|
||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||
import com.mkfunproj.mobilemkch.data.Repository
|
||||
import coil.compose.AsyncImage
|
||||
import com.mkfunproj.mobilemkch.data.SettingsStore
|
||||
import com.mkfunproj.mobilemkch.data.FavoriteThread
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import kotlinx.coroutines.launch
|
||||
import com.mkfunproj.mobilemkch.data.ThreadItem
|
||||
|
||||
class ThreadsVm(app: Application) : AndroidViewModel(app) {
|
||||
private val repo = Repository(app)
|
||||
private val settings = SettingsStore(app)
|
||||
private val favStore = com.mkfunproj.mobilemkch.data.FavoritesStore(app)
|
||||
var isLoading by mutableStateOf(false)
|
||||
var error by mutableStateOf<String?>(null)
|
||||
var items by mutableStateOf<List<ThreadItem>>(emptyList())
|
||||
var offline by mutableStateOf(false)
|
||||
var enablePagination by mutableStateOf(false)
|
||||
var pageSize by mutableStateOf(10)
|
||||
var compactMode by mutableStateOf(false)
|
||||
var showFiles by mutableStateOf(true)
|
||||
var favorites by mutableStateOf<List<FavoriteThread>>(emptyList())
|
||||
|
||||
init {
|
||||
viewModelScope.launch { settings.data.collect {
|
||||
offline = it.offlineMode
|
||||
enablePagination = it.enablePagination
|
||||
pageSize = it.pageSize
|
||||
compactMode = it.compactMode
|
||||
showFiles = it.showFiles
|
||||
} }
|
||||
viewModelScope.launch { favStore.flow.collect { favorites = it } }
|
||||
}
|
||||
|
||||
fun isFavorite(board: String, id: Int): Boolean = favorites.any { it.board == board && it.id == id }
|
||||
fun addFavorite(id: Int, title: String, board: String, boardDesc: String) {
|
||||
val fav = FavoriteThread(id = id, title = title, board = board, boardDescription = boardDesc, addedDate = System.currentTimeMillis())
|
||||
viewModelScope.launch { favStore.add(fav) }
|
||||
}
|
||||
fun removeFavorite(id: Int, board: String) { viewModelScope.launch { favStore.remove(id, board) } }
|
||||
|
||||
suspend fun load(board: String) {
|
||||
isLoading = true
|
||||
error = null
|
||||
runCatching { repo.getThreads(board, offline) }
|
||||
.onSuccess { items = it }
|
||||
.onFailure { error = it.message }
|
||||
isLoading = false
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun ThreadsScreen(
|
||||
boardCode: String,
|
||||
boardDescription: String,
|
||||
onOpenThread: (threadId: Int) -> Unit,
|
||||
onCreateThread: (boardCode: String) -> Unit = {},
|
||||
vm: ThreadsVm = viewModel()
|
||||
) {
|
||||
LaunchedEffect(boardCode) { vm.load(boardCode) }
|
||||
var currentPage by androidx.compose.runtime.remember { mutableStateOf(0) }
|
||||
val scope = androidx.compose.runtime.rememberCoroutineScope()
|
||||
Scaffold(topBar = { TopAppBar(title = { Text("/$boardCode/ — $boardDescription") }, actions = {
|
||||
androidx.compose.material3.TextButton(onClick = { scope.launch { vm.load(boardCode) } }) { Text("Обновить") }
|
||||
androidx.compose.material3.TextButton(onClick = { onCreateThread(boardCode) }) { Text("Создать") }
|
||||
}) }) { padding ->
|
||||
when {
|
||||
vm.isLoading -> CircularProgressIndicator(Modifier.padding(16.dp))
|
||||
vm.error != null -> Text(vm.error ?: "", color = MaterialTheme.colorScheme.error, modifier = Modifier.padding(16.dp))
|
||||
else -> {
|
||||
val list = if (vm.enablePagination) {
|
||||
val totalPages = (vm.items.size + vm.pageSize - 1) / vm.pageSize
|
||||
val page = currentPage.coerceIn(0, (totalPages - 1).coerceAtLeast(0))
|
||||
val start = page * vm.pageSize
|
||||
val end = kotlin.math.min(start + vm.pageSize, vm.items.size)
|
||||
vm.items.subList(start, end)
|
||||
} else vm.items
|
||||
ThreadList(padding, vm, boardCode, boardDescription, onOpenThread, list)
|
||||
if (vm.enablePagination) {
|
||||
val totalPages = (vm.items.size + vm.pageSize - 1) / vm.pageSize
|
||||
if (totalPages > 1) {
|
||||
androidx.compose.foundation.layout.Row(Modifier.fillMaxWidth().padding(12.dp)) {
|
||||
androidx.compose.material3.TextButton(onClick = { if (currentPage > 0) currentPage -= 1 }, enabled = currentPage > 0) { Text("<-") }
|
||||
androidx.compose.foundation.layout.Spacer(Modifier.weight(1f))
|
||||
Text("Страница ${currentPage + 1} из $totalPages")
|
||||
androidx.compose.foundation.layout.Spacer(Modifier.weight(1f))
|
||||
androidx.compose.material3.TextButton(onClick = { if (currentPage < totalPages - 1) currentPage += 1 }, enabled = currentPage < totalPages - 1) { Text("->") }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun ThreadList(padding: PaddingValues, vm: ThreadsVm, boardCode: String, boardDescription: String, onOpen: (Int) -> Unit, itemsList: List<ThreadItem>) {
|
||||
LazyColumn(
|
||||
contentPadding = padding,
|
||||
verticalArrangement = Arrangement.spacedBy(8.dp),
|
||||
modifier = Modifier.fillMaxSize().padding(12.dp)
|
||||
) {
|
||||
if (vm.offline) {
|
||||
item { Text("Оффлайн режим. Показаны сохранённые данные", color = MaterialTheme.colorScheme.secondary) }
|
||||
}
|
||||
items(itemsList) { t ->
|
||||
if (vm.compactMode) {
|
||||
Row(Modifier.fillMaxWidth().clickable { onOpen(t.id) }) {
|
||||
Text("#${t.id}", style = MaterialTheme.typography.labelSmall)
|
||||
Spacer(Modifier.width(8.dp))
|
||||
Text(t.title, style = MaterialTheme.typography.bodyMedium, modifier = Modifier.weight(1f), maxLines = 1)
|
||||
val fav = vm.isFavorite(boardCode, t.id)
|
||||
Icon(
|
||||
imageVector = if (fav) Icons.Filled.Favorite else Icons.Outlined.FavoriteBorder,
|
||||
contentDescription = null,
|
||||
tint = if (fav) MaterialTheme.colorScheme.error else MaterialTheme.colorScheme.onBackground,
|
||||
modifier = Modifier.clickable { if (fav) vm.removeFavorite(t.id, boardCode) else vm.addFavorite(t.id, t.title, boardCode, boardDescription) }
|
||||
)
|
||||
}
|
||||
Row {
|
||||
Text(t.creation, style = MaterialTheme.typography.labelSmall, color = MaterialTheme.colorScheme.secondary)
|
||||
Spacer(Modifier.width(8.dp))
|
||||
if ((t.rating ?: 0) > 0) {
|
||||
Icon(Icons.Filled.Star, contentDescription = null, tint = MaterialTheme.colorScheme.primary)
|
||||
Text(" ${(t.rating ?: 0)}", style = MaterialTheme.typography.labelSmall)
|
||||
Spacer(Modifier.width(8.dp))
|
||||
}
|
||||
if (t.pinned == true) {
|
||||
Icon(Icons.Filled.PushPin, contentDescription = null, tint = MaterialTheme.colorScheme.tertiary)
|
||||
Spacer(Modifier.width(8.dp))
|
||||
}
|
||||
if (vm.showFiles && t.files.isNotEmpty()) {
|
||||
Icon(Icons.Filled.AttachFile, contentDescription = null, tint = MaterialTheme.colorScheme.primary)
|
||||
Text(" ${t.files.size}", style = MaterialTheme.typography.labelSmall)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Row(Modifier.fillMaxWidth().clickable { onOpen(t.id) }) {
|
||||
Text("#${t.id}: ${t.title}", style = MaterialTheme.typography.titleMedium, modifier = Modifier.weight(1f), maxLines = 2)
|
||||
val fav = vm.isFavorite(boardCode, t.id)
|
||||
Icon(
|
||||
imageVector = if (fav) Icons.Filled.Favorite else Icons.Outlined.FavoriteBorder,
|
||||
contentDescription = null,
|
||||
tint = if (fav) MaterialTheme.colorScheme.error else MaterialTheme.colorScheme.onBackground,
|
||||
modifier = Modifier.clickable { if (fav) vm.removeFavorite(t.id, boardCode) else vm.addFavorite(t.id, t.title, boardCode, boardDescription) }
|
||||
)
|
||||
if (t.pinned == true) { Spacer(Modifier.width(8.dp)); Icon(Icons.Filled.PushPin, contentDescription = null, tint = MaterialTheme.colorScheme.tertiary) }
|
||||
}
|
||||
Row {
|
||||
if ((t.rating ?: 0) > 0) { Icon(Icons.Filled.Star, contentDescription = null, tint = MaterialTheme.colorScheme.primary); Spacer(Modifier.width(4.dp)); Text("${t.rating ?: 0}", style = MaterialTheme.typography.labelSmall); Spacer(Modifier.width(12.dp)) }
|
||||
if (vm.showFiles && t.files.isNotEmpty()) { Icon(Icons.Filled.AttachFile, contentDescription = null, tint = MaterialTheme.colorScheme.primary); Spacer(Modifier.width(4.dp)); Text("${t.files.size}", style = MaterialTheme.typography.labelSmall) }
|
||||
}
|
||||
if (t.text.isNotEmpty()) Text(t.text, style = MaterialTheme.typography.bodyMedium, maxLines = 3)
|
||||
if (vm.showFiles && t.files.isNotEmpty()) { Spacer(Modifier.height(4.dp)); t.files.forEach { f -> AsyncImage(model = "https://mkch.pooziqo.xyz$f", contentDescription = null) } }
|
||||
}
|
||||
Divider(Modifier.padding(top = 8.dp))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,7 @@
|
||||
package com.mkfunproj.mobilemkch.ui.theme
|
||||
|
||||
import androidx.compose.material3.Shapes
|
||||
|
||||
val Shapes = Shapes()
|
||||
|
||||
|
||||
31
app/src/main/java/com/mkfunproj/mobilemkch/ui/theme/Theme.kt
Normal file
@ -0,0 +1,31 @@
|
||||
package com.mkfunproj.mobilemkch.ui.theme
|
||||
|
||||
import androidx.compose.foundation.isSystemInDarkTheme
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.darkColorScheme
|
||||
import androidx.compose.material3.lightColorScheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.graphics.Color
|
||||
|
||||
private val DarkColors = darkColorScheme()
|
||||
private val OledColors = darkColorScheme(
|
||||
background = Color.Black,
|
||||
surface = Color.Black
|
||||
)
|
||||
|
||||
@Composable
|
||||
fun MobileMkchTheme(
|
||||
darkTheme: Boolean = isSystemInDarkTheme(),
|
||||
oled: Boolean = false,
|
||||
content: @Composable () -> Unit
|
||||
) {
|
||||
val colors = if (oled) OledColors else DarkColors
|
||||
MaterialTheme(
|
||||
colorScheme = colors,
|
||||
typography = Typography,
|
||||
shapes = Shapes,
|
||||
content = content
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,5 @@
|
||||
package com.mkfunproj.mobilemkch.ui.theme
|
||||
|
||||
import androidx.compose.material3.Typography
|
||||
|
||||
val Typography = Typography()
|
||||
39
app/src/main/java/com/mkfunproj/mobilemkch/util/ImageUtil.kt
Normal file
@ -0,0 +1,39 @@
|
||||
package com.mkfunproj.mobilemkch.util
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.ImageDecoder
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.provider.MediaStore
|
||||
import java.io.File
|
||||
import java.io.FileOutputStream
|
||||
|
||||
object ImageUtil {
|
||||
fun downscaleJpeg(context: Context, uri: Uri, maxDim: Int = 1600, quality: Int = 85): File? {
|
||||
return runCatching {
|
||||
val source = if (Build.VERSION.SDK_INT >= 28) {
|
||||
ImageDecoder.createSource(context.contentResolver, uri)
|
||||
} else null
|
||||
val bmp: Bitmap = if (source != null) ImageDecoder.decodeBitmap(source) else MediaStore.Images.Media.getBitmap(context.contentResolver, uri)
|
||||
val ratio = bmp.width.toFloat() / bmp.height
|
||||
val (w, h) = if (bmp.width >= bmp.height) {
|
||||
val w = maxDim
|
||||
val h = (w / ratio).toInt()
|
||||
w to h
|
||||
} else {
|
||||
val h = maxDim
|
||||
val w = (h * ratio).toInt()
|
||||
w to h
|
||||
}
|
||||
val scaled = Bitmap.createScaledBitmap(bmp, w, h, true)
|
||||
val out = File(context.cacheDir, "scaled_${System.currentTimeMillis()}.jpg")
|
||||
FileOutputStream(out).use { fos ->
|
||||
scaled.compress(Bitmap.CompressFormat.JPEG, quality, fos)
|
||||
}
|
||||
out
|
||||
}.getOrNull()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,45 @@
|
||||
package com.mkfunproj.mobilemkch.util
|
||||
|
||||
import android.app.NotificationChannel
|
||||
import android.app.NotificationManager
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import androidx.core.app.NotificationCompat
|
||||
import com.mkfunproj.mobilemkch.R
|
||||
|
||||
object NotificationHelper {
|
||||
private const val CHANNEL_ID = "mkch_threads"
|
||||
|
||||
private fun ensureChannel(nm: NotificationManager) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
val ch = NotificationChannel(CHANNEL_ID, "Новые треды", NotificationManager.IMPORTANCE_DEFAULT)
|
||||
nm.createNotificationChannel(ch)
|
||||
}
|
||||
}
|
||||
|
||||
fun notifyThread(context: Context, board: String, threadId: Int, title: String) {
|
||||
val nm = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
||||
ensureChannel(nm)
|
||||
val notif = NotificationCompat.Builder(context, CHANNEL_ID)
|
||||
.setSmallIcon(R.drawable.ic_notification)
|
||||
.setContentTitle("Новый тред /" + board + "/")
|
||||
.setContentText(title)
|
||||
.setAutoCancel(true)
|
||||
.build()
|
||||
nm.notify((board.hashCode() xor threadId), notif)
|
||||
}
|
||||
|
||||
fun notifyTest(context: Context) {
|
||||
val nm = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
||||
ensureChannel(nm)
|
||||
val notif = NotificationCompat.Builder(context, CHANNEL_ID)
|
||||
.setSmallIcon(R.drawable.ic_notification)
|
||||
.setContentTitle("Тестовое уведомление")
|
||||
.setContentText("Новый тред: Тестовый тред в /test/")
|
||||
.setAutoCancel(true)
|
||||
.build()
|
||||
nm.notify(0x777777, notif)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,32 @@
|
||||
package com.mkfunproj.mobilemkch.workers
|
||||
|
||||
import android.content.Context
|
||||
import androidx.work.CoroutineWorker
|
||||
import androidx.work.WorkerParameters
|
||||
import com.mkfunproj.mobilemkch.data.ApiClient
|
||||
import com.mkfunproj.mobilemkch.data.SettingsStore
|
||||
import com.mkfunproj.mobilemkch.data.SubscriptionsStore
|
||||
import com.mkfunproj.mobilemkch.util.NotificationHelper
|
||||
import kotlinx.coroutines.flow.first
|
||||
|
||||
class ThreadsCheckWorker(appContext: Context, workerParams: WorkerParameters) : CoroutineWorker(appContext, workerParams) {
|
||||
override suspend fun doWork(): Result {
|
||||
val settings = SettingsStore(applicationContext).data.first()
|
||||
if (!settings.notificationsEnabled) return Result.success()
|
||||
val subs = SubscriptionsStore(applicationContext).flow.first()
|
||||
if (subs.isEmpty()) return Result.success()
|
||||
val api = ApiClient(applicationContext)
|
||||
var notified = 0
|
||||
subs.forEach { board ->
|
||||
runCatching { api.checkNewThreads(board) }.onSuccess { list ->
|
||||
list.forEach { t ->
|
||||
NotificationHelper.notifyThread(applicationContext, board, t.id, t.title)
|
||||
notified += 1
|
||||
}
|
||||
}
|
||||
}
|
||||
return Result.success()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
170
app/src/main/res/drawable/ic_launcher_background.xml
Normal file
@ -0,0 +1,170 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="108"
|
||||
android:viewportHeight="108">
|
||||
<path
|
||||
android:fillColor="#3DDC84"
|
||||
android:pathData="M0,0h108v108h-108z" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M9,0L9,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,0L19,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M29,0L29,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M39,0L39,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M49,0L49,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M59,0L59,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M69,0L69,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M79,0L79,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M89,0L89,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M99,0L99,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,9L108,9"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,19L108,19"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,29L108,29"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,39L108,39"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,49L108,49"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,59L108,59"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,69L108,69"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,79L108,79"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,89L108,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,99L108,99"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,29L89,29"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,39L89,39"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,49L89,49"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,59L89,59"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,69L89,69"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,79L89,79"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M29,19L29,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M39,19L39,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M49,19L49,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M59,19L59,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M69,19L69,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M79,19L79,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
</vector>
|
||||
30
app/src/main/res/drawable/ic_launcher_foreground.xml
Normal file
@ -0,0 +1,30 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:aapt="http://schemas.android.com/aapt"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="108"
|
||||
android:viewportHeight="108">
|
||||
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
|
||||
<aapt:attr name="android:fillColor">
|
||||
<gradient
|
||||
android:endX="85.84757"
|
||||
android:endY="92.4963"
|
||||
android:startX="42.9492"
|
||||
android:startY="49.59793"
|
||||
android:type="linear">
|
||||
<item
|
||||
android:color="#44000000"
|
||||
android:offset="0.0" />
|
||||
<item
|
||||
android:color="#00000000"
|
||||
android:offset="1.0" />
|
||||
</gradient>
|
||||
</aapt:attr>
|
||||
</path>
|
||||
<path
|
||||
android:fillColor="#FFFFFF"
|
||||
android:fillType="nonZero"
|
||||
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
|
||||
android:strokeWidth="1"
|
||||
android:strokeColor="#00000000" />
|
||||
</vector>
|
||||
10
app/src/main/res/drawable/ic_notification.xml
Normal file
@ -0,0 +1,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="#FFFFFF"
|
||||
android:pathData="M12,22a2,2 0 0,0 2,-2H10a2,2 0 0,0 2,2zM18,16v-5c0,-3.07 -1.63,-5.64 -4.5,-6.32V4a1.5,1.5 0 0,0 -3,0v0.68C7.63,5.36 6,7.92 6,11v5l-2,2v1h16v-1l-2,-2z"/>
|
||||
</vector>
|
||||
|
||||
6
app/src/main/res/mipmap-anydpi/ic_launcher.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@drawable/ic_launcher_background" />
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||
<monochrome android:drawable="@drawable/ic_launcher_foreground" />
|
||||
</adaptive-icon>
|
||||
6
app/src/main/res/mipmap-anydpi/ic_launcher_round.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@drawable/ic_launcher_background" />
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||
<monochrome android:drawable="@drawable/ic_launcher_foreground" />
|
||||
</adaptive-icon>
|
||||
BIN
app/src/main/res/mipmap-hdpi/ic_launcher.webp
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
app/src/main/res/mipmap-hdpi/ic_launcher_round.webp
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
app/src/main/res/mipmap-mdpi/ic_launcher.webp
Normal file
|
After Width: | Height: | Size: 982 B |
BIN
app/src/main/res/mipmap-mdpi/ic_launcher_round.webp
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
app/src/main/res/mipmap-xhdpi/ic_launcher.webp
Normal file
|
After Width: | Height: | Size: 1.9 KiB |
BIN
app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
Normal file
|
After Width: | Height: | Size: 3.8 KiB |
BIN
app/src/main/res/mipmap-xxhdpi/ic_launcher.webp
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp
Normal file
|
After Width: | Height: | Size: 5.8 KiB |
BIN
app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
Normal file
|
After Width: | Height: | Size: 3.8 KiB |
BIN
app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp
Normal file
|
After Width: | Height: | Size: 7.6 KiB |
4
app/src/main/res/values-night/themes.xml
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<style name="Theme.MobileMkchNewAndroid" parent="Theme.Material3.DayNight.NoActionBar" />
|
||||
</resources>
|
||||
10
app/src/main/res/values/colors.xml
Normal file
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="purple_200">#FFBB86FC</color>
|
||||
<color name="purple_500">#FF6200EE</color>
|
||||
<color name="purple_700">#FF3700B3</color>
|
||||
<color name="teal_200">#FF03DAC5</color>
|
||||
<color name="teal_700">#FF018786</color>
|
||||
<color name="black">#FF000000</color>
|
||||
<color name="white">#FFFFFFFF</color>
|
||||
</resources>
|
||||
4
app/src/main/res/values/strings.xml
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name">MobileMkch</string>
|
||||
</resources>
|
||||
4
app/src/main/res/values/themes.xml
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<style name="Theme.MobileMkchNewAndroid" parent="Theme.Material3.DayNight.NoActionBar" />
|
||||
</resources>
|
||||
13
app/src/main/res/xml/backup_rules.xml
Normal file
@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Sample backup rules file; uncomment and customize as necessary.
|
||||
See https://developer.android.com/guide/topics/data/autobackup
|
||||
for details.
|
||||
Note: This file is ignored for devices older than API 31
|
||||
See https://developer.android.com/about/versions/12/backup-restore
|
||||
-->
|
||||
<full-backup-content>
|
||||
<!--
|
||||
<include domain="sharedpref" path="."/>
|
||||
<exclude domain="sharedpref" path="device.xml"/>
|
||||
-->
|
||||
</full-backup-content>
|
||||
19
app/src/main/res/xml/data_extraction_rules.xml
Normal file
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Sample data extraction rules file; uncomment and customize as necessary.
|
||||
See https://developer.android.com/about/versions/12/backup-restore#xml-changes
|
||||
for details.
|
||||
-->
|
||||
<data-extraction-rules>
|
||||
<cloud-backup>
|
||||
<!-- TODO: Use <include> and <exclude> to control what is backed up.
|
||||
<include .../>
|
||||
<exclude .../>
|
||||
-->
|
||||
</cloud-backup>
|
||||
<!--
|
||||
<device-transfer>
|
||||
<include .../>
|
||||
<exclude .../>
|
||||
</device-transfer>
|
||||
-->
|
||||
</data-extraction-rules>
|
||||
@ -0,0 +1,17 @@
|
||||
package com.mkfunproj.mobilemkch
|
||||
|
||||
import org.junit.Test
|
||||
|
||||
import org.junit.Assert.*
|
||||
|
||||
/**
|
||||
* Example local unit test, which will execute on the development machine (host).
|
||||
*
|
||||
* See [testing documentation](http://d.android.com/tools/testing).
|
||||
*/
|
||||
class ExampleUnitTest {
|
||||
@Test
|
||||
fun addition_isCorrect() {
|
||||
assertEquals(4, 2 + 2)
|
||||
}
|
||||
}
|
||||
5
build.gradle.kts
Normal file
@ -0,0 +1,5 @@
|
||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
plugins {
|
||||
alias(libs.plugins.android.application) apply false
|
||||
alias(libs.plugins.kotlin.android) apply false
|
||||
}
|
||||
23
gradle.properties
Normal file
@ -0,0 +1,23 @@
|
||||
# Project-wide Gradle settings.
|
||||
# IDE (e.g. Android Studio) users:
|
||||
# Gradle settings configured through the IDE *will override*
|
||||
# any settings specified in this file.
|
||||
# For more details on how to configure your build environment visit
|
||||
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
||||
# Specifies the JVM arguments used for the daemon process.
|
||||
# The setting is particularly useful for tweaking memory settings.
|
||||
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
|
||||
# When configured, Gradle will run in incubating parallel mode.
|
||||
# This option should only be used with decoupled projects. For more details, visit
|
||||
# https://developer.android.com/r/tools/gradle-multi-project-decoupled-projects
|
||||
# org.gradle.parallel=true
|
||||
# AndroidX package structure to make it clearer which packages are bundled with the
|
||||
# Android operating system, and which are packaged with your app's APK
|
||||
# https://developer.android.com/topic/libraries/support-library/androidx-rn
|
||||
android.useAndroidX=true
|
||||
# Kotlin code style for this project: "official" or "obsolete":
|
||||
kotlin.code.style=official
|
||||
# Enables namespacing of each library's R class so that its R class includes only the
|
||||
# resources declared in the library itself and none from the library's dependencies,
|
||||
# thereby reducing the size of the R class for that library
|
||||
android.nonTransitiveRClass=true
|
||||
57
gradle/libs.versions.toml
Normal file
@ -0,0 +1,57 @@
|
||||
[versions]
|
||||
agp = "8.9.1"
|
||||
kotlin = "2.0.21"
|
||||
coreKtx = "1.10.1"
|
||||
junit = "4.13.2"
|
||||
junitVersion = "1.1.5"
|
||||
espressoCore = "3.5.1"
|
||||
appcompat = "1.6.1"
|
||||
material = "1.10.0"
|
||||
composeBom = "2025.01.00"
|
||||
activityCompose = "1.9.3"
|
||||
navigationCompose = "2.8.4"
|
||||
lifecycle = "2.8.6"
|
||||
retrofit = "2.11.0"
|
||||
okhttp = "4.12.0"
|
||||
serialization = "1.7.3"
|
||||
coil = "2.7.0"
|
||||
datastore = "1.1.1"
|
||||
work = "2.10.0"
|
||||
|
||||
[libraries]
|
||||
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
|
||||
junit = { group = "junit", name = "junit", version.ref = "junit" }
|
||||
androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" }
|
||||
androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" }
|
||||
androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" }
|
||||
material = { group = "com.google.android.material", name = "material", version.ref = "material" }
|
||||
compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "composeBom" }
|
||||
compose-ui = { group = "androidx.compose.ui", name = "ui" }
|
||||
compose-ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling" }
|
||||
compose-ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-tooling-preview" }
|
||||
compose-material3 = { group = "androidx.compose.material3", name = "material3" }
|
||||
compose-material = { group = "androidx.compose.material", name = "material" }
|
||||
compose-material-icons-extended = { group = "androidx.compose.material", name = "material-icons-extended" }
|
||||
compose-foundation = { group = "androidx.compose.foundation", name = "foundation" }
|
||||
compose-runtime = { group = "androidx.compose.runtime", name = "runtime" }
|
||||
compose-runtime-livedata = { group = "androidx.compose.runtime", name = "runtime-livedata" }
|
||||
activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "activityCompose" }
|
||||
navigation-compose = { group = "androidx.navigation", name = "navigation-compose", version.ref = "navigationCompose" }
|
||||
lifecycle-runtime-ktx = { group = "androidx.lifecycle", name = "lifecycle-runtime-ktx", version.ref = "lifecycle" }
|
||||
lifecycle-viewmodel-ktx = { group = "androidx.lifecycle", name = "lifecycle-viewmodel-ktx", version.ref = "lifecycle" }
|
||||
lifecycle-viewmodel-compose = { group = "androidx.lifecycle", name = "lifecycle-viewmodel-compose", version.ref = "lifecycle" }
|
||||
retrofit = { group = "com.squareup.retrofit2", name = "retrofit", version.ref = "retrofit" }
|
||||
retrofit-converter-scalars = { group = "com.squareup.retrofit2", name = "converter-scalars", version.ref = "retrofit" }
|
||||
okhttp = { group = "com.squareup.okhttp3", name = "okhttp", version.ref = "okhttp" }
|
||||
okhttp-logging = { group = "com.squareup.okhttp3", name = "logging-interceptor", version.ref = "okhttp" }
|
||||
serialization-json = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-json", version.ref = "serialization" }
|
||||
coil-compose = { group = "io.coil-kt", name = "coil-compose", version.ref = "coil" }
|
||||
datastore-preferences = { group = "androidx.datastore", name = "datastore-preferences", version.ref = "datastore" }
|
||||
work-runtime-ktx = { group = "androidx.work", name = "work-runtime-ktx", version.ref = "work" }
|
||||
|
||||
[plugins]
|
||||
android-application = { id = "com.android.application", version.ref = "agp" }
|
||||
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
|
||||
serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
|
||||
kotlin-compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
|
||||
|
||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
6
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
#Sat Aug 09 15:39:47 MSK 2025
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
185
gradlew
vendored
Executable file
@ -0,0 +1,185 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
#
|
||||
# Copyright 2015 the original author or authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >/dev/null
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
}
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
NONSTOP* )
|
||||
nonstop=true
|
||||
;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD="java"
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock
|
||||
if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
|
||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
SEP=""
|
||||
for dir in $ROOTDIRSRAW ; do
|
||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||
SEP="|"
|
||||
done
|
||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||
# Add a user-defined pattern to the cygpath arguments
|
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||
fi
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
i=0
|
||||
for arg in "$@" ; do
|
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=`expr $i + 1`
|
||||
done
|
||||
case $i in
|
||||
0) set -- ;;
|
||||
1) set -- "$args0" ;;
|
||||
2) set -- "$args0" "$args1" ;;
|
||||
3) set -- "$args0" "$args1" "$args2" ;;
|
||||
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Escape application args
|
||||
save () {
|
||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||
echo " "
|
||||
}
|
||||
APP_ARGS=`save "$@"`
|
||||
|
||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||
|
||||
exec "$JAVACMD" "$@"
|
||||
89
gradlew.bat
vendored
Normal file
@ -0,0 +1,89 @@
|
||||
@rem
|
||||
@rem Copyright 2015 the original author or authors.
|
||||
@rem
|
||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@rem you may not use this file except in compliance with the License.
|
||||
@rem You may obtain a copy of the License at
|
||||
@rem
|
||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||
@rem
|
||||
@rem Unless required by applicable law or agreed to in writing, software
|
||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
23
settings.gradle.kts
Normal file
@ -0,0 +1,23 @@
|
||||
pluginManagement {
|
||||
repositories {
|
||||
google {
|
||||
content {
|
||||
includeGroupByRegex("com\\.android.*")
|
||||
includeGroupByRegex("com\\.google.*")
|
||||
includeGroupByRegex("androidx.*")
|
||||
}
|
||||
}
|
||||
mavenCentral()
|
||||
gradlePluginPortal()
|
||||
}
|
||||
}
|
||||
dependencyResolutionManagement {
|
||||
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.name = "MobileMkch-NewAndroid"
|
||||
include(":app")
|
||||