diff --git a/src/main/AndroidManifest.xml b/src/main/AndroidManifest.xml index 7238022b..ea9f5bbe 100644 --- a/src/main/AndroidManifest.xml +++ b/src/main/AndroidManifest.xml @@ -98,18 +98,6 @@ - - - - - - - - - - if (profiles.length > 1) - builder.addAction(R.drawable.ic_action_settings, service.getString(R.string.quick_switch), - PendingIntent.getActivity(service, 0, new Intent(Action.QUICK_SWITCH), 0)) - case _ => - } private lazy val style = new BigTextStyle(builder) private var isVisible = true update(if (service.getSystemService(Context.POWER_SERVICE).asInstanceOf[PowerManager].isScreenOn) diff --git a/src/main/scala/com/github/shadowsocks/ShadowsocksQuickSwitchActivity.scala b/src/main/scala/com/github/shadowsocks/ShadowsocksQuickSwitchActivity.scala deleted file mode 100644 index 391c2d99..00000000 --- a/src/main/scala/com/github/shadowsocks/ShadowsocksQuickSwitchActivity.scala +++ /dev/null @@ -1,96 +0,0 @@ -/*******************************************************************************/ -/* */ -/* Copyright (C) 2016 by Max Lv */ -/* Copyright (C) 2016 by Mygod Studio */ -/* */ -/* 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 . */ -/* */ -/*******************************************************************************/ - -package com.github.shadowsocks - -import android.content.pm.ShortcutManager -import android.content.res.Resources -import android.os.{Build, Bundle} -import android.support.v7.app.AppCompatActivity -import android.support.v7.widget.{DefaultItemAnimator, LinearLayoutManager, RecyclerView, Toolbar} -import android.view.{LayoutInflater, View, ViewGroup} -import android.widget.CheckedTextView -import com.github.shadowsocks.database.Profile -import com.github.shadowsocks.utils.Utils -import com.github.shadowsocks.ShadowsocksApplication.app - -/** - * Created by Lucas on 3/10/16. - */ -class ShadowsocksQuickSwitchActivity extends AppCompatActivity { - - private class ProfileViewHolder(val view: View) extends RecyclerView.ViewHolder(view) with View.OnClickListener { - { - val typedArray = obtainStyledAttributes(Array(android.R.attr.selectableItemBackground)) - view.setBackgroundResource(typedArray.getResourceId(0, 0)) - typedArray.recycle() - } - private var item: Profile = _ - private val text = itemView.findViewById(android.R.id.text1).asInstanceOf[CheckedTextView] - itemView.setOnClickListener(this) - - def bind(item: Profile) { - this.item = item - text.setText(item.name) - text.setChecked(item.id == app.profileId) - } - - def onClick(v: View) { - app.switchProfile(item.id) - Utils.startSsService(ShadowsocksQuickSwitchActivity.this) - finish() - } - } - - private class ProfilesAdapter extends RecyclerView.Adapter[ProfileViewHolder] { - val profiles: List[Profile] = app.profileManager.getAllProfiles.getOrElse(List.empty[Profile]) - - def getItemCount: Int = profiles.length - - def onBindViewHolder(vh: ProfileViewHolder, i: Int): Unit = i match { - case _ => vh.bind(profiles(i)) - } - - private val name = "select_dialog_singlechoice_" + (if (Build.VERSION.SDK_INT >= 21) "material" else "holo") - - def onCreateViewHolder(vg: ViewGroup, i: Int) = new ProfileViewHolder(LayoutInflater.from(vg.getContext) - .inflate(Resources.getSystem.getIdentifier(name, "layout", "android"), vg, false)) - } - - private val profilesAdapter = new ProfilesAdapter - - override def onCreate(savedInstanceState: Bundle) { - super.onCreate(savedInstanceState) - setContentView(R.layout.layout_quick_switch) - - val toolbar = findViewById(R.id.toolbar).asInstanceOf[Toolbar] - toolbar.setTitle(R.string.quick_switch) - - val profilesList = findViewById(R.id.profilesList).asInstanceOf[RecyclerView] - val lm = new LinearLayoutManager(this) - profilesList.setLayoutManager(lm) - profilesList.setItemAnimator(new DefaultItemAnimator) - profilesList.setAdapter(profilesAdapter) - if (app.profileId >= 0) lm.scrollToPosition(profilesAdapter.profiles.zipWithIndex.collectFirst { - case (profile, i) if profile.id == app.profileId => i - }.getOrElse(0)) - if (Build.VERSION.SDK_INT >= 25) getSystemService(classOf[ShortcutManager]).reportShortcutUsed("switch") - } -} diff --git a/src/main/scala/com/github/shadowsocks/utils/Constants.scala b/src/main/scala/com/github/shadowsocks/utils/Constants.scala index 00489c41..3e8bfbfc 100644 --- a/src/main/scala/com/github/shadowsocks/utils/Constants.scala +++ b/src/main/scala/com/github/shadowsocks/utils/Constants.scala @@ -173,7 +173,6 @@ object Action { final val CONNECTED = "com.github.shadowsocks.CONNECTED" // TODO final val PROFILE_CHANGED = "com.github.shadowsocks.PROFILE_CHANGED" final val PROFILE_REMOVED = "com.github.shadowsocks.PROFILE_REMOVED" - final val QUICK_SWITCH = "com.github.shadowsocks.QUICK_SWITCH" final val EXTRA_PROFILE_ID = "com.github.shadowsocks.EXTRA_PROFILE_ID" }