Skip to content

Commit

Permalink
Merge pull request #17 from CCExtractor/master
Browse files Browse the repository at this point in the history
sftp config will reset on accountchange, added client settings option…
  • Loading branch information
Erarshad authored Jul 14, 2021
2 parents 7244041 + bbe700a commit 4ef179a
Show file tree
Hide file tree
Showing 16 changed files with 104 additions and 14 deletions.
Binary file modified android/.gradle/6.7/executionHistory/executionHistory.bin
Binary file not shown.
Binary file modified android/.gradle/6.7/executionHistory/executionHistory.lock
Binary file not shown.
Binary file modified android/.gradle/6.7/fileHashes/fileHashes.bin
Binary file not shown.
Binary file modified android/.gradle/6.7/fileHashes/fileHashes.lock
Binary file not shown.
Binary file modified android/.gradle/6.7/javaCompile/javaCompile.lock
Binary file not shown.
Binary file modified android/.gradle/6.7/javaCompile/taskHistory.bin
Binary file not shown.
Binary file modified android/.gradle/buildOutputCleanup/buildOutputCleanup.lock
Binary file not shown.
Binary file modified android/.gradle/buildOutputCleanup/outputFiles.bin
Binary file not shown.
9 changes: 7 additions & 2 deletions lib/components/accounts.dart
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ class accountsState extends State<accounts> {
leading: Icon(selected_account == accounts[index].id
? Icons.radio_button_checked
: Icons.radio_button_unchecked),
trailing: (accounts.length > 1 && selected_account != accounts[index].id)
trailing: (accounts.length > 1 &&
selected_account != accounts[index].id)
? IconButton(
// if there is more than 1 account then it will visible
icon: Icon(
Expand All @@ -169,7 +170,7 @@ class accountsState extends State<accounts> {
},
)
: new Container(height: 0.0, width: 0.0),
onTap: () {
onTap: () async {
if (this.mounted) {
setState(() {
selected_account = accounts[index].id;
Expand All @@ -179,6 +180,10 @@ class accountsState extends State<accounts> {
}
update_account_selection();
dashboard_state();
//here i will add logic to reset sftp
if (await states.get_sftP_reset_bool()) {
states.reset_sftp_config();
}
Navigator.of(context).pop(); //closing side bar
},
);
Expand Down
2 changes: 1 addition & 1 deletion lib/components/bottom_sheet/ssh_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class _ssh_configState extends State<ssh_config> {
indent: 70.0,
endIndent: 70.0,
),
sftp_settings_fields(),
sftp_settings_fields(selected_account: selected_account,),
Row(
children: [
Padding(
Expand Down
6 changes: 3 additions & 3 deletions lib/components/sidebar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class sidebarState extends State<sidebar> {
sftp_route_dir = await states.get_sftp_route();

if (sftp_host.isNotEmpty &&
sftp_port.isNotEmpty&
sftp_port.isNotEmpty &&
sftp_username.isNotEmpty &&
sftp_password.isNotEmpty &&
sftp_route_dir.isNotEmpty) {
Expand Down Expand Up @@ -606,7 +606,7 @@ class sidebarState extends State<sidebar> {
leading: Icon(Icons.settings_applications_sharp),
onTap: () {
Navigator.push(context,
MaterialPageRoute(builder: (context) => ssh()));
MaterialPageRoute(builder: (context) => ssh(selected_account: selecx)));
},
),
],
Expand All @@ -620,7 +620,7 @@ class sidebarState extends State<sidebar> {
title: Text(
"About",
style: TextStyle(
fontSize: 12.0,
fontSize: 15.0,
fontFamily: theme.font_family,
color: theme_controller.is_it_dark()
? Colors.white
Expand Down
2 changes: 1 addition & 1 deletion lib/screens/auth.dart
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ class _auth_viewState extends State<auth_view> {
filled: true,
hintStyle:
new TextStyle(color: Colors.grey[800]),
hintText: "Location of Deluge",
hintText: "Location of Deluge host",
suffixIcon: InkWell(
child: Icon(Icons.paste),
onTap: () {
Expand Down
29 changes: 25 additions & 4 deletions lib/settings/client/client_setting.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,29 @@ class clt_st extends StatefulWidget {

class _clt_stState extends State<clt_st> {
bool notification = false;
bool sftp_reset = false;
@override
void initState() {
super.initState();

fetch_notification_settings();
fetch_client_settings();
}

void fetch_notification_settings() async {
bool mid = await states.fetch_notification_settings();
void fetch_client_settings() async {
bool mid1 = await states.fetch_notification_settings();
if (this.mounted) {
setState(() {
notification = mid;
notification = mid1;
});
}

bool mid2 = await states.get_sftP_reset_bool();
if (this.mounted) {
setState(() {
sftp_reset = mid2;
});
}

}

@override
Expand Down Expand Up @@ -64,6 +73,18 @@ class _clt_stState extends State<clt_st> {
},
),
),
ListTile(
title: Text("sftp settings reset on account change"),
trailing: Switch(
value: sftp_reset,
onChanged: (val) {
setState(() {
sftp_reset = val;
});
states.set_sftP_reset_bool(val);
},
),
),
],
),
)));
Expand Down
36 changes: 35 additions & 1 deletion lib/settings/deluge/type/sftp_setting_field.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,45 @@ import 'package:fluttertoast/fluttertoast.dart';
import 'package:deluge_client/control_center/theme_controller.dart';

class sftp_settings_fields extends StatefulWidget {
final Bucket selected_account;
sftp_settings_fields({Key key, @required this.selected_account})
: super(key: key);
@override
_sftp_settings_fieldsState createState() => _sftp_settings_fieldsState();
_sftp_settings_fieldsState createState() =>
_sftp_settings_fieldsState(selected_account: selected_account);
}

class _sftp_settings_fieldsState extends State<sftp_settings_fields> {
final Bucket selected_account;
_sftp_settings_fieldsState({@required this.selected_account});

Future<void> handle_streaming_action() async {
String sftp_host = await states.get_sftp_host();
String sftp_port = await states.get_sftp_port();
String sftp_username = await states.get_sftp_username();
String sftp_password = await states.get_sftp_password();
String sftp_route_dir = await states.get_sftp_route();

if (sftp_host.isEmpty &&
sftp_port.isEmpty &&
sftp_username.isEmpty &&
sftp_password.isEmpty &&
sftp_route_dir.isEmpty) {
//-----------------
core_settings.sftp_host.text = selected_account.deluge_url.replaceFirst("https://", "");
core_settings.sftpport.text = "54022";

core_settings.sftp_route_url.text =
selected_account.deluge_url + "/downloads/";
}
}

@override
void initState() {
handle_streaming_action();
super.initState();
}

@override
Widget build(BuildContext context) {
return Container(
Expand Down
8 changes: 6 additions & 2 deletions lib/settings/deluge/type/sftp_streaming_settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,15 @@ import 'package:fluttertoast/fluttertoast.dart';
import 'package:deluge_client/settings/deluge/type/sftp_setting_field.dart';

class ssh extends StatefulWidget {
final Bucket selected_account;
ssh({Key key, @required this.selected_account}) : super(key: key);
@override
_sshState createState() => _sshState();
_sshState createState() => _sshState(selected_account: selected_account);
}

class _sshState extends State<ssh> {
final Bucket selected_account;
_sshState({Key key, @required this.selected_account});
void initiate_setup() async {
core_settings.sftp_host.text = await states.get_sftp_host();
core_settings.sftp_pass.text = await states.get_sftp_password();
Expand Down Expand Up @@ -75,6 +79,6 @@ class _sshState extends State<ssh> {
)
],
),
body: sftp_settings_fields());
body: sftp_settings_fields(selected_account: selected_account,));
}
}
26 changes: 26 additions & 0 deletions lib/state_ware_house/state_ware_house.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class states {
pref.setInt("selected_account", 1);
pref.setInt("selected_theme", 1);
pref.setBool("notification_settings", true);
pref.setBool("sftp_reset",false);
pref.setString("sftp_host","");
pref.setString("sftp_port","");
pref.setString("sftp_username","");
Expand Down Expand Up @@ -135,6 +136,31 @@ class states {
SharedPreferences pf = await SharedPreferences.getInstance();
return pf.getString("sftp_pass");
}
//-------------------------------------------------------------------------
// it should return sftp true false
static Future<bool>get_sftP_reset_bool() async {
SharedPreferences pf = await SharedPreferences.getInstance();
return pf.get("sftp_reset");
}
static Future<void> set_sftP_reset_bool(bool val) async {
SharedPreferences pf = await SharedPreferences.getInstance();
pf.setBool("sftp_reset", val);
}

static Future<void> reset_sftp_config() async{
SharedPreferences pf = await SharedPreferences.getInstance();
pf.setString("sftp_host","");
pf.setString("sftp_port","");
pf.setString("sftp_username", "");
pf.setString("sftp_pass", "");
pf.setString("sftp_dir_route","");


}






}

0 comments on commit 4ef179a

Please sign in to comment.