Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
com.ccwangluo.accelerator
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sheteng
com.ccwangluo.accelerator
Commits
096a8ba0
Commit
096a8ba0
authored
Jan 23, 2020
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prevent DialogFragment.show crash
parent
7f8ff169
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
45 additions
and
12 deletions
+45
-12
core/src/main/java/com/github/shadowsocks/UrlImportActivity.kt
...src/main/java/com/github/shadowsocks/UrlImportActivity.kt
+2
-1
mobile/src/main/java/com/github/shadowsocks/GlobalSettingsPreferenceFragment.kt
...om/github/shadowsocks/GlobalSettingsPreferenceFragment.kt
+2
-1
mobile/src/main/java/com/github/shadowsocks/ProfileConfigFragment.kt
...main/java/com/github/shadowsocks/ProfileConfigFragment.kt
+2
-2
mobile/src/main/java/com/github/shadowsocks/ProfilesFragment.kt
.../src/main/java/com/github/shadowsocks/ProfilesFragment.kt
+2
-3
plugin/src/main/java/com/github/shadowsocks/plugin/AlertDialogFragment.kt
...java/com/github/shadowsocks/plugin/AlertDialogFragment.kt
+1
-5
plugin/src/main/java/com/github/shadowsocks/plugin/Utils.kt
plugin/src/main/java/com/github/shadowsocks/plugin/Utils.kt
+36
-0
No files found.
core/src/main/java/com/github/shadowsocks/UrlImportActivity.kt
View file @
096a8ba0
...
@@ -31,6 +31,7 @@ import com.github.shadowsocks.database.Profile
...
@@ -31,6 +31,7 @@ import com.github.shadowsocks.database.Profile
import
com.github.shadowsocks.database.ProfileManager
import
com.github.shadowsocks.database.ProfileManager
import
com.github.shadowsocks.plugin.AlertDialogFragment
import
com.github.shadowsocks.plugin.AlertDialogFragment
import
com.github.shadowsocks.plugin.Empty
import
com.github.shadowsocks.plugin.Empty
import
com.github.shadowsocks.plugin.showAllowingStateLoss
import
kotlinx.android.parcel.Parcelize
import
kotlinx.android.parcel.Parcelize
class
UrlImportActivity
:
AppCompatActivity
()
{
class
UrlImportActivity
:
AppCompatActivity
()
{
...
@@ -61,7 +62,7 @@ class UrlImportActivity : AppCompatActivity() {
...
@@ -61,7 +62,7 @@ class UrlImportActivity : AppCompatActivity() {
Toast
.
makeText
(
this
,
R
.
string
.
profile_invalid_input
,
Toast
.
LENGTH_SHORT
).
show
()
Toast
.
makeText
(
this
,
R
.
string
.
profile_invalid_input
,
Toast
.
LENGTH_SHORT
).
show
()
finish
()
finish
()
}
}
else
->
dialog
.
show
(
supportFragmentManager
,
null
)
else
->
dialog
.
show
AllowingStateLoss
(
supportFragmentManager
)
}
}
}
}
...
...
mobile/src/main/java/com/github/shadowsocks/GlobalSettingsPreferenceFragment.kt
View file @
096a8ba0
...
@@ -34,6 +34,7 @@ import com.github.shadowsocks.preference.DataStore
...
@@ -34,6 +34,7 @@ import com.github.shadowsocks.preference.DataStore
import
com.github.shadowsocks.utils.DirectBoot
import
com.github.shadowsocks.utils.DirectBoot
import
com.github.shadowsocks.utils.Key
import
com.github.shadowsocks.utils.Key
import
com.github.shadowsocks.net.TcpFastOpen
import
com.github.shadowsocks.net.TcpFastOpen
import
com.github.shadowsocks.plugin.showAllowingStateLoss
import
com.github.shadowsocks.preference.BrowsableEditTextPreferenceDialogFragment
import
com.github.shadowsocks.preference.BrowsableEditTextPreferenceDialogFragment
import
com.github.shadowsocks.preference.EditTextPreferenceModifiers
import
com.github.shadowsocks.preference.EditTextPreferenceModifiers
import
com.github.shadowsocks.preference.HostsSummaryProvider
import
com.github.shadowsocks.preference.HostsSummaryProvider
...
@@ -126,7 +127,7 @@ class GlobalSettingsPreferenceFragment : PreferenceFragmentCompat() {
...
@@ -126,7 +127,7 @@ class GlobalSettingsPreferenceFragment : PreferenceFragmentCompat() {
if
(
preference
==
hosts
)
BrowsableEditTextPreferenceDialogFragment
().
apply
{
if
(
preference
==
hosts
)
BrowsableEditTextPreferenceDialogFragment
().
apply
{
setKey
(
hosts
.
key
)
setKey
(
hosts
.
key
)
setTargetFragment
(
this
@GlobalSettingsPreferenceFragment
,
REQUEST_BROWSE
)
setTargetFragment
(
this
@GlobalSettingsPreferenceFragment
,
REQUEST_BROWSE
)
}.
show
(
parentFragmentManager
,
hosts
.
key
)
else
super
.
onDisplayPreferenceDialog
(
preference
)
}.
show
AllowingStateLoss
(
parentFragmentManager
,
hosts
.
key
)
else
super
.
onDisplayPreferenceDialog
(
preference
)
}
}
override
fun
onActivityResult
(
requestCode
:
Int
,
resultCode
:
Int
,
data
:
Intent
?)
{
override
fun
onActivityResult
(
requestCode
:
Int
,
resultCode
:
Int
,
data
:
Intent
?)
{
...
...
mobile/src/main/java/com/github/shadowsocks/ProfileConfigFragment.kt
View file @
096a8ba0
...
@@ -155,7 +155,7 @@ class ProfileConfigFragment : PreferenceFragmentCompat(),
...
@@ -155,7 +155,7 @@ class ProfileConfigFragment : PreferenceFragmentCompat(),
PluginConfigurationDialogFragment
().
apply
{
PluginConfigurationDialogFragment
().
apply
{
setArg
(
Key
.
pluginConfigure
,
pluginConfiguration
.
selected
)
setArg
(
Key
.
pluginConfigure
,
pluginConfiguration
.
selected
)
setTargetFragment
(
this
@ProfileConfigFragment
,
0
)
setTargetFragment
(
this
@ProfileConfigFragment
,
0
)
}.
show
(
parentFragmentManager
,
Key
.
pluginConfigure
)
}.
show
AllowingStateLoss
(
parentFragmentManager
,
Key
.
pluginConfigure
)
}
}
private
fun
saveAndExit
()
{
private
fun
saveAndExit
()
{
...
@@ -206,7 +206,7 @@ class ProfileConfigFragment : PreferenceFragmentCompat(),
...
@@ -206,7 +206,7 @@ class ProfileConfigFragment : PreferenceFragmentCompat(),
Key
.
plugin
->
BottomSheetPreferenceDialogFragment
().
apply
{
Key
.
plugin
->
BottomSheetPreferenceDialogFragment
().
apply
{
setArg
(
Key
.
plugin
)
setArg
(
Key
.
plugin
)
setTargetFragment
(
this
@ProfileConfigFragment
,
0
)
setTargetFragment
(
this
@ProfileConfigFragment
,
0
)
}.
show
(
parentFragmentManager
,
Key
.
plugin
)
}.
show
AllowingStateLoss
(
parentFragmentManager
,
Key
.
plugin
)
Key
.
pluginConfigure
->
{
Key
.
pluginConfigure
->
{
val
intent
=
PluginManager
.
buildIntent
(
pluginConfiguration
.
selected
,
PluginContract
.
ACTION_CONFIGURE
)
val
intent
=
PluginManager
.
buildIntent
(
pluginConfiguration
.
selected
,
PluginContract
.
ACTION_CONFIGURE
)
if
(
intent
.
resolveActivity
(
requireContext
().
packageManager
)
==
null
)
showPluginEditor
()
else
{
if
(
intent
.
resolveActivity
(
requireContext
().
packageManager
)
==
null
)
showPluginEditor
()
else
{
...
...
mobile/src/main/java/com/github/shadowsocks/ProfilesFragment.kt
View file @
096a8ba0
...
@@ -50,6 +50,7 @@ import com.github.shadowsocks.bg.BaseService
...
@@ -50,6 +50,7 @@ import com.github.shadowsocks.bg.BaseService
import
com.github.shadowsocks.database.Profile
import
com.github.shadowsocks.database.Profile
import
com.github.shadowsocks.database.ProfileManager
import
com.github.shadowsocks.database.ProfileManager
import
com.github.shadowsocks.plugin.PluginConfiguration
import
com.github.shadowsocks.plugin.PluginConfiguration
import
com.github.shadowsocks.plugin.showAllowingStateLoss
import
com.github.shadowsocks.preference.DataStore
import
com.github.shadowsocks.preference.DataStore
import
com.github.shadowsocks.utils.Action
import
com.github.shadowsocks.utils.Action
import
com.github.shadowsocks.utils.datas
import
com.github.shadowsocks.utils.datas
...
@@ -331,9 +332,7 @@ class ProfilesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener {
...
@@ -331,9 +332,7 @@ class ProfilesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener {
override
fun
onMenuItemClick
(
item
:
MenuItem
):
Boolean
=
when
(
item
.
itemId
)
{
override
fun
onMenuItemClick
(
item
:
MenuItem
):
Boolean
=
when
(
item
.
itemId
)
{
R
.
id
.
action_qr_code
->
{
R
.
id
.
action_qr_code
->
{
if
(!
parentFragmentManager
.
isStateSaved
)
{
QRCodeDialog
(
this
.
item
.
toString
()).
showAllowingStateLoss
(
parentFragmentManager
)
QRCodeDialog
(
this
.
item
.
toString
()).
show
(
parentFragmentManager
,
""
)
}
true
true
}
}
R
.
id
.
action_export_clipboard
->
{
R
.
id
.
action_export_clipboard
->
{
...
...
plugin/src/main/java/com/github/shadowsocks/plugin/AlertDialogFragment.kt
View file @
096a8ba0
...
@@ -28,7 +28,6 @@ import android.os.Parcelable
...
@@ -28,7 +28,6 @@ import android.os.Parcelable
import
androidx.appcompat.app.AlertDialog
import
androidx.appcompat.app.AlertDialog
import
androidx.appcompat.app.AppCompatDialogFragment
import
androidx.appcompat.app.AppCompatDialogFragment
import
androidx.fragment.app.Fragment
import
androidx.fragment.app.Fragment
import
kotlinx.android.parcel.Parcelize
/**
/**
* Based on: https://android.googlesource.com/platform/packages/apps/ExactCalculator/+/8c43f06/src/com/android/calculator2/AlertDialogFragment.java
* Based on: https://android.googlesource.com/platform/packages/apps/ExactCalculator/+/8c43f06/src/com/android/calculator2/AlertDialogFragment.java
...
@@ -62,9 +61,6 @@ abstract class AlertDialogFragment<Arg : Parcelable, Ret : Parcelable> :
...
@@ -62,9 +61,6 @@ abstract class AlertDialogFragment<Arg : Parcelable, Ret : Parcelable> :
fun
show
(
target
:
Fragment
,
requestCode
:
Int
=
0
,
tag
:
String
=
javaClass
.
simpleName
)
{
fun
show
(
target
:
Fragment
,
requestCode
:
Int
=
0
,
tag
:
String
=
javaClass
.
simpleName
)
{
setTargetFragment
(
target
,
requestCode
)
setTargetFragment
(
target
,
requestCode
)
show
(
target
.
fragmentManager
?:
return
,
tag
)
show
AllowingStateLoss
(
target
.
fragmentManager
?:
return
,
tag
)
}
}
}
}
@Parcelize
class
Empty
:
Parcelable
plugin/src/main/java/com/github/shadowsocks/plugin/Utils.kt
0 → 100644
View file @
096a8ba0
/*******************************************************************************
* *
* Copyright (C) 2020 by Max Lv <max.c.lv@gmail.com> *
* Copyright (C) 2020 by Mygod Studio <contact-shadowsocks-android@mygod.be> *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* *
*******************************************************************************/
@
file
:
JvmName
(
"Utils"
)
package
com.github.shadowsocks.plugin
import
android.os.Parcelable
import
androidx.fragment.app.DialogFragment
import
androidx.fragment.app.FragmentManager
import
kotlinx.android.parcel.Parcelize
@Parcelize
class
Empty
:
Parcelable
@JvmOverloads
fun
DialogFragment
.
showAllowingStateLoss
(
fragmentManager
:
FragmentManager
,
tag
:
String
?
=
null
)
{
if
(!
fragmentManager
.
isStateSaved
)
show
(
fragmentManager
,
tag
)
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment