diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml
index 2fdf1d1a..8f20481a 100755
--- a/src/main/res/values/strings.xml
+++ b/src/main/res/values/strings.xml
@@ -70,7 +70,7 @@
Loading…
Yes
No
- Remove this profile?
+ Remove this profile: %s ?
Reset
diff --git a/src/main/scala/com/github/shadowsocks/Shadowsocks.scala b/src/main/scala/com/github/shadowsocks/Shadowsocks.scala
index fa8d4ead..da1354cd 100644
--- a/src/main/scala/com/github/shadowsocks/Shadowsocks.scala
+++ b/src/main/scala/com/github/shadowsocks/Shadowsocks.scala
@@ -529,6 +529,7 @@ class Shadowsocks
if (!status.getBoolean(getVersionName, false)) {
status.edit.putBoolean(getVersionName, true).apply()
reset()
+ Shadowsocks.currentProfile = profileManager.create()
}
handler.sendEmptyMessage(MSG_INITIAL_FINISH)
}
@@ -567,14 +568,20 @@ class Shadowsocks
handler.postDelayed(new Runnable {
def run() {
Shadowsocks.currentProfile = profileManager.reload(id)
- updatePreferenceScreen()
profileManager.save()
menuAdapter.updateList(getMenuList, Shadowsocks.currentProfile.id)
+
+ if (!isSinglePane) {
+ sendBroadcast(new Intent(Action.UPDATE_FRAGMENT))
+ } else {
+ updatePreferenceScreen()
+ }
+
h.sendEmptyMessage(0)
+
}
}, 600)
- if (!isSinglePane) sendBroadcast(new Intent(Action.UPDATE_FRAGMENT))
}
def updateProfile(id: Int) {
@@ -585,21 +592,30 @@ class Shadowsocks
handler.postDelayed(new Runnable {
def run() {
Shadowsocks.currentProfile = profileManager.reload(id)
- updatePreferenceScreen()
menuAdapter.setActiveId(id)
menuAdapter.notifyDataSetChanged()
+
+ if (!isSinglePane) {
+ sendBroadcast(new Intent(Action.UPDATE_FRAGMENT))
+ } else {
+ updatePreferenceScreen()
+ }
+
h.sendEmptyMessage(0)
}
}, 600)
- if (!isSinglePane) sendBroadcast(new Intent(Action.UPDATE_FRAGMENT))
}
def delProfile(id: Int): Boolean = {
drawer.closeMenu(true)
+ val profile = profileManager.getProfile(id)
+
+ if (!profile.isDefined) return false
+
new AlertDialog.Builder(this)
- .setMessage(R.string.remove_profile)
+ .setMessage(String.format(getString(R.string.remove_profile), profile.get.name))
.setCancelable(false)
.setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
override def onClick(dialog: DialogInterface, i: Int) = dialog.cancel()
@@ -612,14 +628,18 @@ class Shadowsocks
if (profiles.isEmpty) -1 else profiles(0).id
}
Shadowsocks.currentProfile = profileManager.load(profileId)
- updatePreferenceScreen()
menuAdapter.updateList(getMenuList, Shadowsocks.currentProfile.id)
+
+ if (!isSinglePane) {
+ sendBroadcast(new Intent(Action.UPDATE_FRAGMENT))
+ } else {
+ updatePreferenceScreen()
+ }
+
dialog.dismiss()
}
}).create().show()
- if (!isSinglePane) sendBroadcast(new Intent(Action.UPDATE_FRAGMENT))
-
true
}
@@ -636,7 +656,7 @@ class Shadowsocks
buf ++= getProfileList
- buf += new Item(-1, getString(R.string.add_profile), android.R.drawable.ic_menu_add, addProfile)
+ buf += new Item(-400, getString(R.string.add_profile), android.R.drawable.ic_menu_add, addProfile)
buf += new Category("Settings")
diff --git a/src/main/scala/com/github/shadowsocks/database/Profile.scala b/src/main/scala/com/github/shadowsocks/database/Profile.scala
index 38f7d711..1c40ffeb 100644
--- a/src/main/scala/com/github/shadowsocks/database/Profile.scala
+++ b/src/main/scala/com/github/shadowsocks/database/Profile.scala
@@ -73,10 +73,10 @@ class Profile {
var download: Int = 0
@DatabaseField
- var chnroute: Boolean = false
+ var chnroute: Boolean = true
@DatabaseField
- var global: Boolean = false
+ var global: Boolean = true
@DatabaseField
var bypass: Boolean = false
diff --git a/src/main/scala/com/github/shadowsocks/database/ProfileManager.scala b/src/main/scala/com/github/shadowsocks/database/ProfileManager.scala
index 6bfce5af..7a4f7a29 100644
--- a/src/main/scala/com/github/shadowsocks/database/ProfileManager.scala
+++ b/src/main/scala/com/github/shadowsocks/database/ProfileManager.scala
@@ -133,7 +133,7 @@ class ProfileManager(settings: SharedPreferences, dbHelper: DBHelper) {
profile
}
- def save(): Profile = {
+ private def loadFromPreferences: Profile = {
val profile = new Profile()
profile.id = settings.getInt(Key.profileId, -1)
@@ -162,8 +162,18 @@ class ProfileManager(settings: SharedPreferences, dbHelper: DBHelper) {
}
profile.individual = settings.getString(Key.proxied, "")
- updateProfile(profile)
+ profile
+ }
+ def save(): Profile = {
+ val profile = loadFromPreferences
+ updateProfile(profile)
+ profile
+ }
+
+ def create(): Profile = {
+ val profile = loadFromPreferences
+ createOrUpdateProfile(profile)
profile
}
}