Skip to content

Commit

Permalink
improve ssr sub delete
Browse files Browse the repository at this point in the history
  • Loading branch information
esdeathlove committed Jun 15, 2017
1 parent 7c812f2 commit 259c704
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/main/res/values-ja/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@
<string name="ssrsub_toast_fail">サブスクリップションの更新に失敗しました!</string>
<string name="group_name">グループ名</string>
<string name="proxy_click">アドレスを表示し、編集するときにクリックします</string>
<string name="ssrsub_remove_tip_title">削除</string>
<string name="ssrsub_remove_tip">あなたはそれを削除したい、あるいは同じ名前およびサブスクリプションノードそれでグループを削除したいですか?</string>
<string name="ssrsub_remove_tip_direct">削除</string>
<string name="ssrsub_remove_tip_delete">ノードと一緒に削除されました</string>

<!-- status -->
<string name="sent">送信済み:</string>
Expand Down
4 changes: 4 additions & 0 deletions src/main/res/values-ru/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@
<string name="ssrsub_toast_fail">Ошибка обновления подписки!</string>
<string name="group_name">Название группы</string>
<string name="proxy_click">Нажмите для просмотра и редактирования адреса</string>
<string name="ssrsub_remove_tip_title">удалять</string>
<string name="ssrsub_remove_tip">Вы хотите, чтобы удалить его, или даже хотите удалить группу с тем же именем и узлом подписки это?</string>
<string name="ssrsub_remove_tip_direct">удалять</string>
<string name="ssrsub_remove_tip_delete">Удаляется вместе с узлом</string>


<string name="scan_qrcode_install_title">Сканирование подсказки кода</string>
Expand Down
4 changes: 4 additions & 0 deletions src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,10 @@
<string name="ssrsub_toast_fail">更新订阅失败!</string>
<string name="group_name">群组名</string>
<string name="proxy_click">点击查看和编辑地址</string>
<string name="ssrsub_remove_tip_title">删除</string>
<string name="ssrsub_remove_tip">您是想直接删除呢,还是想连带着删除群组和这个订阅名一样的节点呢?</string>
<string name="ssrsub_remove_tip_direct">直接删除</string>
<string name="ssrsub_remove_tip_delete">与节点一起删除</string>



Expand Down
4 changes: 4 additions & 0 deletions src/main/res/values-zh-rTW/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,10 @@
<string name="ssrsub_toast_fail">更新訂閱失敗!</string>
<string name="group_name">群組名</string>
<string name="proxy_click">點擊查看和編輯地址</string>
<string name="ssrsub_remove_tip_title">删除</string>
<string name="ssrsub_remove_tip">您是想直接刪除呢,還是想連帶著刪除群組和這個訂閱名一樣的節點呢?</string>
<string name="ssrsub_remove_tip_direct">直接刪除</string>
<string name="ssrsub_remove_tip_delete">與節點一起刪除</string>


<!-- status -->
Expand Down
4 changes: 4 additions & 0 deletions src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@
<string name="ssrsub_toast_fail">Update subscription fail!</string>
<string name="group_name">Group Name</string>
<string name="proxy_click">Click to view and edit the address</string>
<string name="ssrsub_remove_tip_title">Remove</string>
<string name="ssrsub_remove_tip">Do you want to delete this subscription directly without remove the nodes which has the same node name with it or not?</string>
<string name="ssrsub_remove_tip_direct">Delete directly</string>
<string name="ssrsub_remove_tip_delete">Delete with it\'s nodes</string>


<string name="scan_qrcode_install_title">Scan tips</string>
Expand Down
35 changes: 33 additions & 2 deletions src/main/scala/com/github/shadowsocks/ProfileManagerActivity.scala
Original file line number Diff line number Diff line change
Expand Up @@ -660,8 +660,39 @@ final class ProfileManagerActivity extends AppCompatActivity with OnMenuItemClic
ItemTouchHelper.START | ItemTouchHelper.END) {
def onSwiped(viewHolder: ViewHolder, direction: Int) = {
val index = viewHolder.getAdapterPosition
ssrsubAdapter.remove(index)
app.ssrsubManager.delSSRSub(viewHolder.asInstanceOf[SSRSubViewHolder].item.id)
new AlertDialog.Builder(ProfileManagerActivity.this)
.setTitle(getString(R.string.ssrsub_remove_tip_title))
.setPositiveButton(R.string.ssrsub_remove_tip_direct, ((_, _) => {
ssrsubAdapter.remove(index)
app.ssrsubManager.delSSRSub(viewHolder.asInstanceOf[SSRSubViewHolder].item.id)
}): DialogInterface.OnClickListener)
.setNegativeButton(android.R.string.no, ((_, _) => {
ssrsubAdapter.notifyDataSetChanged()
}): DialogInterface.OnClickListener)
.setNeutralButton(R.string.ssrsub_remove_tip_delete, ((_, _) => {
var delete_profiles = app.profileManager.getAllProfilesByGroup(viewHolder.asInstanceOf[SSRSubViewHolder].item.url_group) match {
case Some(profiles) =>
profiles
case _ => null
}

delete_profiles.foreach((profile: Profile) => {
if (profile.id != app.profileId) {
app.profileManager.delProfile(profile.id)
}
})

val index = viewHolder.getAdapterPosition
ssrsubAdapter.remove(index)
app.ssrsubManager.delSSRSub(viewHolder.asInstanceOf[SSRSubViewHolder].item.id)

finish()
startActivity(new Intent(getIntent()))
}): DialogInterface.OnClickListener)
.setMessage(getString(R.string.ssrsub_remove_tip))
.setCancelable(false)
.create()
.show()
}
def onMove(recyclerView: RecyclerView, viewHolder: ViewHolder, target: ViewHolder) = {
true
Expand Down

0 comments on commit 259c704

Please sign in to comment.