Skip to content

Commit b7ea08d

Browse files
authored
Merge pull request #79 from NANI-SORE/master
Comments, notes, config sharing...
2 parents 6081753 + b9b2048 commit b7ea08d

108 files changed

Lines changed: 8051 additions & 3535 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

android/app/src/main/AndroidManifest.xml

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
android:label="LoliSnatcher"
1818
android:icon="@mipmap/ic_launcher"
1919
android:requestLegacyExternalStorage="true"
20+
android:resizeableActivity="true"
2021
android:usesCleartextTraffic="true">
2122
<activity
2223
android:name=".MainActivity"
@@ -25,27 +26,18 @@
2526
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
2627
android:hardwareAccelerated="true"
2728
android:windowSoftInputMode="stateVisible">
28-
<!-- Specifies an Android theme to apply to this Activity as soon as
29-
the Android process has started. This theme is visible to the user
30-
while the Flutter UI initializes. After that, this theme continues
31-
to determine the Window background behind the Flutter UI. -->
32-
<meta-data
33-
android:name="io.flutter.embedding.android.NormalTheme"
34-
android:resource="@style/NormalTheme"
35-
/>
36-
<!-- Displays an Android View that continues showing the launch screen
37-
Drawable until Flutter paints its first frame, then this splash
38-
screen fades out. A splash screen is useful to avoid any visual
39-
gap between the end of Android's launch screen and the painting of
40-
Flutter's first frame. -->
41-
<meta-data
42-
android:name="io.flutter.embedding.android.SplashScreenDrawable"
43-
android:resource="@drawable/launch_background"
44-
/>
4529
<intent-filter>
4630
<action android:name="android.intent.action.MAIN"/>
4731
<category android:name="android.intent.category.LAUNCHER"/>
4832
</intent-filter>
33+
34+
<intent-filter>
35+
<action android:name="android.intent.action.VIEW" />
36+
<category android:name="android.intent.category.DEFAULT" />
37+
<category android:name="android.intent.category.BROWSABLE" />
38+
<data android:scheme="https" />
39+
<data android:host="www.loli.snatcher" />
40+
</intent-filter>
4941
</activity>
5042

5143
<provider

android/app/src/main/kotlin/com/noaisu/loliSnatcher/MainActivity.kt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,12 @@ import java.net.NetworkInterface
4343
class MainActivity: FlutterActivity() {
4444
private val CHANNEL = "com.noaisu.loliSnatcher/services"
4545
private val VOLUME_CHANNEL = "com.noaisu.loliSnatcher/volume"
46-
private var sink: EventChannel.EventSink? = null
46+
private var volumeSink: EventChannel.EventSink? = null
4747
private var isSinkingVolume: Boolean = false
4848
private var audioManager: AudioManager? = null
4949
private var SAFUri: String? = "";
5050
private var methodResult: MethodChannel.Result? = null
51+
5152
@SuppressLint("WrongThread")
5253
override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {
5354
super.configureFlutterEngine(flutterEngine)
@@ -239,7 +240,7 @@ class MainActivity: FlutterActivity() {
239240

240241
EventChannel(flutterEngine.dartExecutor, VOLUME_CHANNEL).setStreamHandler(object : EventChannel.StreamHandler {
241242
override fun onListen(arguments: Any?, eventSink: EventChannel.EventSink?) {
242-
sink = eventSink;
243+
volumeSink = eventSink;
243244
}
244245

245246
override fun onCancel(arguments: Any?) {
@@ -256,7 +257,7 @@ class MainActivity: FlutterActivity() {
256257
//return intent.data.toString();
257258
}
258259

259-
private fun getImageAccess(){
260+
private fun getImageAccess() {
260261
val intent = Intent(Intent.ACTION_OPEN_DOCUMENT)
261262
val mimeTypes = arrayOf("image/png", "image/jpeg","image/jpg","image/gif")
262263
intent.type = "*/*"
@@ -324,7 +325,7 @@ class MainActivity: FlutterActivity() {
324325
override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean {
325326
if ((keyCode == KeyEvent.KEYCODE_VOLUME_DOWN || keyCode == KeyEvent.KEYCODE_VOLUME_UP) && isSinkingVolume)
326327
{
327-
sink?.success(if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) "down" else "up")
328+
volumeSink?.success(if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) "down" else "up")
328329
return true;
329330
}
330331

@@ -349,7 +350,7 @@ class MainActivity: FlutterActivity() {
349350
}
350351

351352
@Throws(IOException::class)
352-
private fun writeImage(fileBytes: ByteArray, name: String, mediaType: String, fileExt: String,extPathOverride: String?) {
353+
private fun writeImage(fileBytes: ByteArray, name: String, mediaType: String, fileExt: String, extPathOverride: String?) {
353354
val fos: OutputStream?
354355
val resolver = contentResolver
355356
val contentValues = ContentValues()

android/app/src/main/res/drawable/launch_background.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<!-- Modify this file to customize your launch splash screen -->
33
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
4-
<item android:drawable="@android:color/white" />
4+
<item android:drawable="@android:color/black" />
55

66
<!-- You can insert your own image assets here -->
77
<!-- <item>

lib/DesktopHome.dart

Lines changed: 46 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,11 @@ import 'package:LoliSnatcher/pages/SettingsPage.dart';
1515
import 'package:LoliSnatcher/SnatchHandler.dart';
1616
import 'package:LoliSnatcher/pages/SnatcherPage.dart';
1717
import 'package:LoliSnatcher/getPerms.dart';
18-
import 'package:LoliSnatcher/libBooru/BooruItem.dart';
1918
import 'package:LoliSnatcher/widgets/FlashElements.dart';
2019
import 'package:LoliSnatcher/widgets/TagSearchButton.dart';
20+
import 'package:LoliSnatcher/widgets/ResizableSplitView.dart';
2121

22-
class DesktopHome extends StatefulWidget {
23-
@override
24-
_DesktopHomeState createState() => _DesktopHomeState();
25-
DesktopHome();
26-
}
27-
28-
class _DesktopHomeState extends State<DesktopHome> {
22+
class DesktopHome extends StatelessWidget {
2923
final SnatchHandler snatchHandler = Get.find<SnatchHandler>();
3024
final SettingsHandler settingsHandler = Get.find<SettingsHandler>();
3125
final SearchHandler searchHandler = Get.find<SearchHandler>();
@@ -36,6 +30,7 @@ class _DesktopHomeState extends State<DesktopHome> {
3630
resizeToAvoidBottomInset: false,
3731
appBar: AppBar(
3832
toolbarHeight: 60,
33+
backgroundColor: Get.theme.colorScheme.background,
3934
actions: <Widget>[
4035
Obx(() {
4136
if (settingsHandler.booruList.isNotEmpty && searchHandler.list.isNotEmpty) {
@@ -56,71 +51,57 @@ class _DesktopHomeState extends State<DesktopHome> {
5651
return const SizedBox();
5752
}
5853
}),
59-
6054
Obx(() {
6155
if (settingsHandler.booruList.isNotEmpty && searchHandler.list.isNotEmpty) {
6256
return SettingsButton(
6357
name: 'Snatcher',
64-
icon: Icon(Icons.download),
58+
icon: Icon(Icons.download, color: Get.theme.colorScheme.onBackground),
6559
iconOnly: true,
6660
page: () => SnatcherPage(),
6761
);
6862
} else {
6963
return const SizedBox();
7064
}
7165
}),
72-
7366
Obx(() {
7467
if (settingsHandler.booruList.isEmpty || searchHandler.list.isEmpty) {
7568
return Center(child: Text('Add Boorus in Settings'));
7669
} else {
7770
return const SizedBox();
7871
}
7972
}),
80-
8173
SettingsButton(
8274
name: 'Settings',
83-
icon: Icon(Icons.settings),
75+
icon: Icon(Icons.settings, color: Get.theme.colorScheme.onBackground),
8476
iconOnly: true,
8577
page: () => SettingsPage(),
8678
),
87-
8879
Obx(() {
89-
if(searchHandler.list.isNotEmpty) {
80+
if (searchHandler.list.isNotEmpty) {
9081
return Stack(
9182
alignment: Alignment.center,
9283
children: [
9384
SettingsButton(
9485
name: 'Save',
95-
icon: Icon(Icons.save),
86+
icon: Icon(Icons.save, color: Get.theme.colorScheme.onBackground),
9687
iconOnly: true,
9788
action: () {
9889
getPerms();
9990
// call a function to save the currently viewed image when the save button is pressed
100-
if (searchHandler.currentTab.selected.length > 0){
91+
if (searchHandler.currentTab.selected.length > 0) {
10192
snatchHandler.queue(
102-
searchHandler.currentTab.getSelected(),
103-
searchHandler.currentTab.selectedBooru.value,
104-
settingsHandler.snatchCooldown
105-
);
93+
searchHandler.currentTab.getSelected(), searchHandler.currentTab.selectedBooru.value, settingsHandler.snatchCooldown);
10694
searchHandler.currentTab.selected.value = [];
10795
} else {
10896
FlashElements.showSnackbar(
10997
context: context,
110-
title: Text(
111-
"No items selected",
112-
style: TextStyle(fontSize: 20)
113-
),
114-
overrideLeadingIconWidget: Text(
115-
" (」°ロ°)」 ",
116-
style: TextStyle(fontSize: 18)
117-
),
98+
title: Text("No items selected", style: TextStyle(fontSize: 20)),
99+
overrideLeadingIconWidget: Text(" (」°ロ°)」 ", style: TextStyle(fontSize: 18)),
118100
);
119101
}
120102
},
121103
),
122-
123-
if(searchHandler.currentTab.selected.isNotEmpty)
104+
if (searchHandler.currentTab.selected.isNotEmpty)
124105
Positioned(
125106
child: Container(
126107
width: 20,
@@ -132,87 +113,66 @@ class _DesktopHomeState extends State<DesktopHome> {
132113
),
133114
child: Center(
134115
child: FittedBox(
135-
child: Text(
136-
'${searchHandler.currentTab.selected.length}',
137-
style: TextStyle(color: Get.theme.colorScheme.onSecondary)
138-
),
139-
)
140-
)
116+
child: Text('${searchHandler.currentTab.selected.length}', style: TextStyle(color: Get.theme.colorScheme.onSecondary)),
117+
),
118+
),
141119
),
142120
right: 2,
143121
bottom: 5,
144-
)
145-
]
122+
),
123+
],
146124
);
147125
} else {
148126
return const SizedBox();
149127
}
150128
}),
151-
152129
],
153130
),
154131
body: Center(
155-
child: Row(
156-
children: [
157-
Expanded(
158-
flex: 1,
159-
child: Column(
160-
children: [
161-
Expanded(
162-
child: Center(child: ImagePreviews()),
163-
flex: 2,
164-
),
165-
Expanded(
166-
flex: 1,
167-
child: DesktopTagListener(),
168-
),
169-
],
170-
),
171-
),
172-
Expanded(
173-
flex: 2,
174-
child: Obx(() => searchHandler.list.isEmpty ? const SizedBox() : DesktopImageListener(searchHandler.currentTab)),
175-
),
176-
]
177-
)
132+
child: ResizableSplitView(
133+
firstChild: ResizableSplitView(
134+
firstChild: ImagePreviews(),
135+
secondChild: DesktopTagListener(),
136+
startRatio: 0.66,
137+
minRatio: 0.33,
138+
maxRatio: 1,
139+
direction: SplitDirection.vertical,
140+
onRatioChange: (double newRatio) {
141+
// print('ratioChanged1 $newRatio');
142+
// TODO save to settings, but debounce the saving to file
143+
},
144+
),
145+
secondChild: Obx(() => searchHandler.list.isEmpty ? const SizedBox() : DesktopImageListener(searchHandler.currentTab)),
146+
startRatio: 0.33,
147+
minRatio: 0.2,
148+
maxRatio: 0.8,
149+
onRatioChange: (double newRatio) {
150+
// print('ratioChanged2 $newRatio');
151+
// TODO save to settings, but debounce the saving to file
152+
},
153+
),
178154
),
179155
);
180156
}
181157
}
182158

183-
184-
class DesktopTagListener extends StatefulWidget {
185-
DesktopTagListener();
186-
@override
187-
_DesktopTagListenerState createState() => _DesktopTagListenerState();
188-
}
189-
190-
class _DesktopTagListenerState extends State<DesktopTagListener> {
191-
SearchHandler searchHandler = Get.find<SearchHandler>();
159+
class DesktopTagListener extends StatelessWidget {
160+
final SearchHandler searchHandler = Get.find<SearchHandler>();
192161

193162
@override
194163
Widget build(BuildContext context) {
195164
return Obx(() {
196-
if(searchHandler.list.isEmpty) {
197-
return Center(
198-
child: CircularProgressIndicator(
199-
valueColor: AlwaysStoppedAnimation(Get.theme.colorScheme.secondary)
200-
)
201-
);
165+
if (searchHandler.list.isEmpty) {
166+
return Center(child: CircularProgressIndicator(valueColor: AlwaysStoppedAnimation(Get.theme.colorScheme.secondary)));
202167
}
203168

204-
BooruItem item = searchHandler.currentTab.currentItem.value;
205-
206169
return Container(
207-
child: TagView(item),
208-
padding: EdgeInsets.all(5),
170+
child: TagView(),
171+
padding: EdgeInsets.all(2),
209172
decoration: BoxDecoration(
210-
border: Border.all(color: Get.theme.colorScheme.secondary,width: 2),
173+
border: Border.all(color: Get.theme.colorScheme.secondary, width: 1),
211174
),
212175
);
213176
});
214177
}
215178
}
216-
217-
218-

0 commit comments

Comments
 (0)