Skip to content

Commit

Permalink
Merge pull request #1440 from TranceLove/bugfix/issue1253
Browse files Browse the repository at this point in the history
Check if screen is locked before processing tile's click event (#1253)
  • Loading branch information
EmmanuelMess committed Sep 27, 2018
1 parent fb4efaa commit f87fc2c
Showing 1 changed file with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,21 @@ public void onStopListening() {

@Override
public void onClick() {
super.onClick();

if (getQsTile().getState() == Tile.STATE_ACTIVE) {
getApplicationContext().sendBroadcast(new Intent(FtpService.ACTION_STOP_FTPSERVER).setPackage(getPackageName()));
} else {
if (FtpService.isConnectedToWifi(getApplicationContext())
|| FtpService.isConnectedToLocalNetwork(getApplicationContext())
|| FtpService.isEnabledWifiHotspot(getApplicationContext())) {
Intent i = new Intent(FtpService.ACTION_START_FTPSERVER).setPackage(getPackageName());
i.putExtra(FtpService.TAG_STARTED_BY_TILE, true);
getApplicationContext().sendBroadcast(i);
unlockAndRun(()->{
if (FtpService.isRunning()) {
getApplicationContext().sendBroadcast(new Intent(FtpService.ACTION_STOP_FTPSERVER).setPackage(getPackageName()));
} else {
Toast.makeText(getApplicationContext(), getString(R.string.ftp_no_wifi), Toast.LENGTH_LONG).show();
if (FtpService.isConnectedToWifi(getApplicationContext())
|| FtpService.isConnectedToLocalNetwork(getApplicationContext())
|| FtpService.isEnabledWifiHotspot(getApplicationContext())) {
Intent i = new Intent(FtpService.ACTION_START_FTPSERVER).setPackage(getPackageName());
i.putExtra(FtpService.TAG_STARTED_BY_TILE, true);
getApplicationContext().sendBroadcast(i);
} else {
Toast.makeText(getApplicationContext(), getString(R.string.ftp_no_wifi), Toast.LENGTH_LONG).show();
}
}
}
});
}

private void updateTileState() {
Expand Down

0 comments on commit f87fc2c

Please sign in to comment.