forked from kitsunyan/foxy-droid
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main'
- Loading branch information
Showing
9 changed files
with
158 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/main/kotlin/com/revrobotics/RequestInternetDialogFragment.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package com.revrobotics | ||
|
||
import android.app.AlertDialog | ||
import android.app.Dialog | ||
import android.content.Intent | ||
import android.os.Bundle | ||
import android.provider.Settings | ||
import androidx.fragment.app.DialogFragment | ||
|
||
class RequestInternetDialogFragment: DialogFragment() { | ||
companion object { | ||
var instance: RequestInternetDialogFragment? = null | ||
} | ||
|
||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { | ||
instance = this | ||
return activity?.let { | ||
val dialog = AlertDialog.Builder(it) | ||
.setMessage("Please connect to the Internet") | ||
.setNegativeButton("Cancel", null) | ||
.setOnDismissListener { | ||
actionWaitingForInternetConnection = null | ||
instance = null | ||
} | ||
// We use a null listener, and later override the underlying onClickListener, so the dialog doesn't get dismissed | ||
.setPositiveButton("Wi-Fi settings", null) | ||
.create() | ||
|
||
dialog.setOnShowListener { | ||
dialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener { | ||
startActivity(Intent(Settings.ACTION_WIFI_SETTINGS).apply { | ||
putExtra("com.revrobotics.wifiConnectionReason", "Connect to the Internet for software downloads") | ||
}) | ||
} | ||
} | ||
|
||
return dialog | ||
} ?: throw IllegalStateException("Activity cannot be null") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters