Skip to content

Commit

Permalink
Merge pull request #79 from NANI-SORE/master
Browse files Browse the repository at this point in the history
Comments, notes, config sharing...
  • Loading branch information
NO-ob committed Jan 3, 2022
2 parents 6081753 + b9b2048 commit b7ea08d
Show file tree
Hide file tree
Showing 108 changed files with 8,051 additions and 3,535 deletions.
26 changes: 9 additions & 17 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
android:label="LoliSnatcher"
android:icon="@mipmap/ic_launcher"
android:requestLegacyExternalStorage="true"
android:resizeableActivity="true"
android:usesCleartextTraffic="true">
<activity
android:name=".MainActivity"
Expand All @@ -25,27 +26,18 @@
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="stateVisible">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
<!-- Displays an Android View that continues showing the launch screen
Drawable until Flutter paints its first frame, then this splash
screen fades out. A splash screen is useful to avoid any visual
gap between the end of Android's launch screen and the painting of
Flutter's first frame. -->
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="@drawable/launch_background"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>

<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https" />
<data android:host="www.loli.snatcher" />
</intent-filter>
</activity>

<provider
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,12 @@ import java.net.NetworkInterface
class MainActivity: FlutterActivity() {
private val CHANNEL = "com.noaisu.loliSnatcher/services"
private val VOLUME_CHANNEL = "com.noaisu.loliSnatcher/volume"
private var sink: EventChannel.EventSink? = null
private var volumeSink: EventChannel.EventSink? = null
private var isSinkingVolume: Boolean = false
private var audioManager: AudioManager? = null
private var SAFUri: String? = "";
private var methodResult: MethodChannel.Result? = null

@SuppressLint("WrongThread")
override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {
super.configureFlutterEngine(flutterEngine)
Expand Down Expand Up @@ -239,7 +240,7 @@ class MainActivity: FlutterActivity() {

EventChannel(flutterEngine.dartExecutor, VOLUME_CHANNEL).setStreamHandler(object : EventChannel.StreamHandler {
override fun onListen(arguments: Any?, eventSink: EventChannel.EventSink?) {
sink = eventSink;
volumeSink = eventSink;
}

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

private fun getImageAccess(){
private fun getImageAccess() {
val intent = Intent(Intent.ACTION_OPEN_DOCUMENT)
val mimeTypes = arrayOf("image/png", "image/jpeg","image/jpg","image/gif")
intent.type = "*/*"
Expand Down Expand Up @@ -324,7 +325,7 @@ class MainActivity: FlutterActivity() {
override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean {
if ((keyCode == KeyEvent.KEYCODE_VOLUME_DOWN || keyCode == KeyEvent.KEYCODE_VOLUME_UP) && isSinkingVolume)
{
sink?.success(if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) "down" else "up")
volumeSink?.success(if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) "down" else "up")
return true;
}

Expand All @@ -349,7 +350,7 @@ class MainActivity: FlutterActivity() {
}

@Throws(IOException::class)
private fun writeImage(fileBytes: ByteArray, name: String, mediaType: String, fileExt: String,extPathOverride: String?) {
private fun writeImage(fileBytes: ByteArray, name: String, mediaType: String, fileExt: String, extPathOverride: String?) {
val fos: OutputStream?
val resolver = contentResolver
val contentValues = ContentValues()
Expand Down
2 changes: 1 addition & 1 deletion android/app/src/main/res/drawable/launch_background.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Modify this file to customize your launch splash screen -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@android:color/white" />
<item android:drawable="@android:color/black" />

<!-- You can insert your own image assets here -->
<!-- <item>
Expand Down
132 changes: 46 additions & 86 deletions lib/DesktopHome.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,11 @@ import 'package:LoliSnatcher/pages/SettingsPage.dart';
import 'package:LoliSnatcher/SnatchHandler.dart';
import 'package:LoliSnatcher/pages/SnatcherPage.dart';
import 'package:LoliSnatcher/getPerms.dart';
import 'package:LoliSnatcher/libBooru/BooruItem.dart';
import 'package:LoliSnatcher/widgets/FlashElements.dart';
import 'package:LoliSnatcher/widgets/TagSearchButton.dart';
import 'package:LoliSnatcher/widgets/ResizableSplitView.dart';

class DesktopHome extends StatefulWidget {
@override
_DesktopHomeState createState() => _DesktopHomeState();
DesktopHome();
}

class _DesktopHomeState extends State<DesktopHome> {
class DesktopHome extends StatelessWidget {
final SnatchHandler snatchHandler = Get.find<SnatchHandler>();
final SettingsHandler settingsHandler = Get.find<SettingsHandler>();
final SearchHandler searchHandler = Get.find<SearchHandler>();
Expand All @@ -36,6 +30,7 @@ class _DesktopHomeState extends State<DesktopHome> {
resizeToAvoidBottomInset: false,
appBar: AppBar(
toolbarHeight: 60,
backgroundColor: Get.theme.colorScheme.background,
actions: <Widget>[
Obx(() {
if (settingsHandler.booruList.isNotEmpty && searchHandler.list.isNotEmpty) {
Expand All @@ -56,71 +51,57 @@ class _DesktopHomeState extends State<DesktopHome> {
return const SizedBox();
}
}),

Obx(() {
if (settingsHandler.booruList.isNotEmpty && searchHandler.list.isNotEmpty) {
return SettingsButton(
name: 'Snatcher',
icon: Icon(Icons.download),
icon: Icon(Icons.download, color: Get.theme.colorScheme.onBackground),
iconOnly: true,
page: () => SnatcherPage(),
);
} else {
return const SizedBox();
}
}),

Obx(() {
if (settingsHandler.booruList.isEmpty || searchHandler.list.isEmpty) {
return Center(child: Text('Add Boorus in Settings'));
} else {
return const SizedBox();
}
}),

SettingsButton(
name: 'Settings',
icon: Icon(Icons.settings),
icon: Icon(Icons.settings, color: Get.theme.colorScheme.onBackground),
iconOnly: true,
page: () => SettingsPage(),
),

Obx(() {
if(searchHandler.list.isNotEmpty) {
if (searchHandler.list.isNotEmpty) {
return Stack(
alignment: Alignment.center,
children: [
SettingsButton(
name: 'Save',
icon: Icon(Icons.save),
icon: Icon(Icons.save, color: Get.theme.colorScheme.onBackground),
iconOnly: true,
action: () {
getPerms();
// call a function to save the currently viewed image when the save button is pressed
if (searchHandler.currentTab.selected.length > 0){
if (searchHandler.currentTab.selected.length > 0) {
snatchHandler.queue(
searchHandler.currentTab.getSelected(),
searchHandler.currentTab.selectedBooru.value,
settingsHandler.snatchCooldown
);
searchHandler.currentTab.getSelected(), searchHandler.currentTab.selectedBooru.value, settingsHandler.snatchCooldown);
searchHandler.currentTab.selected.value = [];
} else {
FlashElements.showSnackbar(
context: context,
title: Text(
"No items selected",
style: TextStyle(fontSize: 20)
),
overrideLeadingIconWidget: Text(
" (」°ロ°)」 ",
style: TextStyle(fontSize: 18)
),
title: Text("No items selected", style: TextStyle(fontSize: 20)),
overrideLeadingIconWidget: Text(" (」°ロ°)」 ", style: TextStyle(fontSize: 18)),
);
}
},
),

if(searchHandler.currentTab.selected.isNotEmpty)
if (searchHandler.currentTab.selected.isNotEmpty)
Positioned(
child: Container(
width: 20,
Expand All @@ -132,87 +113,66 @@ class _DesktopHomeState extends State<DesktopHome> {
),
child: Center(
child: FittedBox(
child: Text(
'${searchHandler.currentTab.selected.length}',
style: TextStyle(color: Get.theme.colorScheme.onSecondary)
),
)
)
child: Text('${searchHandler.currentTab.selected.length}', style: TextStyle(color: Get.theme.colorScheme.onSecondary)),
),
),
),
right: 2,
bottom: 5,
)
]
),
],
);
} else {
return const SizedBox();
}
}),

],
),
body: Center(
child: Row(
children: [
Expanded(
flex: 1,
child: Column(
children: [
Expanded(
child: Center(child: ImagePreviews()),
flex: 2,
),
Expanded(
flex: 1,
child: DesktopTagListener(),
),
],
),
),
Expanded(
flex: 2,
child: Obx(() => searchHandler.list.isEmpty ? const SizedBox() : DesktopImageListener(searchHandler.currentTab)),
),
]
)
child: ResizableSplitView(
firstChild: ResizableSplitView(
firstChild: ImagePreviews(),
secondChild: DesktopTagListener(),
startRatio: 0.66,
minRatio: 0.33,
maxRatio: 1,
direction: SplitDirection.vertical,
onRatioChange: (double newRatio) {
// print('ratioChanged1 $newRatio');
// TODO save to settings, but debounce the saving to file
},
),
secondChild: Obx(() => searchHandler.list.isEmpty ? const SizedBox() : DesktopImageListener(searchHandler.currentTab)),
startRatio: 0.33,
minRatio: 0.2,
maxRatio: 0.8,
onRatioChange: (double newRatio) {
// print('ratioChanged2 $newRatio');
// TODO save to settings, but debounce the saving to file
},
),
),
);
}
}


class DesktopTagListener extends StatefulWidget {
DesktopTagListener();
@override
_DesktopTagListenerState createState() => _DesktopTagListenerState();
}

class _DesktopTagListenerState extends State<DesktopTagListener> {
SearchHandler searchHandler = Get.find<SearchHandler>();
class DesktopTagListener extends StatelessWidget {
final SearchHandler searchHandler = Get.find<SearchHandler>();

@override
Widget build(BuildContext context) {
return Obx(() {
if(searchHandler.list.isEmpty) {
return Center(
child: CircularProgressIndicator(
valueColor: AlwaysStoppedAnimation(Get.theme.colorScheme.secondary)
)
);
if (searchHandler.list.isEmpty) {
return Center(child: CircularProgressIndicator(valueColor: AlwaysStoppedAnimation(Get.theme.colorScheme.secondary)));
}

BooruItem item = searchHandler.currentTab.currentItem.value;

return Container(
child: TagView(item),
padding: EdgeInsets.all(5),
child: TagView(),
padding: EdgeInsets.all(2),
decoration: BoxDecoration(
border: Border.all(color: Get.theme.colorScheme.secondary,width: 2),
border: Border.all(color: Get.theme.colorScheme.secondary, width: 1),
),
);
});
}
}



Loading

0 comments on commit b7ea08d

Please sign in to comment.