Commit df09d391 authored by Max Lv's avatar Max Lv

Add apply-all action

parent 1fe0ab99
addSbtPlugin("org.scala-android" % "sbt-android" % "1.6.5")
addSbtPlugin("org.scala-android" % "sbt-android" % "1.6.6")
addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.1.10")
......
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FFFFFFFF"
android:pathData="M18,7l-1.41,-1.41 -6.34,6.34 1.41,1.41L18,7zM22.24,5.59L11.66,16.17 7.48,12l-1.41,1.41L11.66,19l12,-12 -1.42,-1.41zM0.41,13.41L6,19l1.41,-1.41L1.83,12 0.41,13.41z"/>
</vector>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item android:id="@+id/action_apply_all"
android:title="@string/action_apply_all"
android:icon="@drawable/ic_done_all"
android:alphabeticShortcut="a"
android:numericShortcut="1"
app:showAsAction="always"/>
<item android:id="@+id/action_export"
android:title="@string/action_export"
android:icon="@drawable/ic_content_copy"
app:showAsAction="ifRoom"
android:alphabeticShortcut="e"
android:numericShortcut="1"/>
android:numericShortcut="2"/>
<item android:id="@+id/action_import"
android:title="@string/action_import"
android:icon="@drawable/ic_content_paste"
app:showAsAction="ifRoom"
android:alphabeticShortcut="i"
android:numericShortcut="2"/>
android:numericShortcut="3"/>
</menu>
......@@ -100,6 +100,8 @@
<string name="flush_dnscache_no_root">Очистка кэша DNS не работает без налиичя ROOT прав</string>
<string name="flushing">Очистка</string>
<string name="add_profile">Добавить Профиль</string>
<string name="action_apply_all">Применить настройки для всех профилей</string>
<string name="action_export">Экспортировать в буфер обмена</string>
<string name="action_import">Импортировать из буфера обмена</string>
<string name="action_export_msg">Успешный экспорт!</string>
......
......@@ -113,6 +113,7 @@
<item>绕过局域网及中国大陆地址</item>
</string-array>
<string name="action_apply_all">应用设置到所有配置文件</string>
<string name="action_export">导出至剪贴板</string>
<string name="action_import">从剪贴板导入</string>
<string name="action_export_msg">导出至剪贴板成功</string>
......
......@@ -115,6 +115,7 @@
<item>略過區域網路及中國大陸位址</item>
</string-array>
<string name="action_apply_all">應用設置到所有配置文件</string>
<string name="action_export">匯出至剪貼簿</string>
<string name="action_import">從剪貼簿匯入</string>
<string name="action_export_msg">匯出至剪貼簿成功</string>
......
......@@ -102,6 +102,7 @@
<string name="flush_dnscache_no_root">Flush DNS cache cannot proceed without ROOT permission</string>
<string name="flushing">Flushing</string>
<string name="add_profile">Add Profile</string>
<string name="action_apply_all">Apply Settings to All Profiles</string>
<string name="action_export">Export to Clipboard</string>
<string name="action_import">Import from Clipboard</string>
<string name="action_export_msg">Successfully export!</string>
......
......@@ -157,6 +157,18 @@ class AppManager extends AppCompatActivity with OnMenuItemClickListener {
val clipboard = getSystemService(Context.CLIPBOARD_SERVICE).asInstanceOf[ClipboardManager]
val prefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext)
item.getItemId match {
case R.id.action_apply_all =>
app.profileManager.getAllProfiles match {
case Some(profiles) =>
val proxiedAppString = prefs.getString(Key.proxied, "")
profiles.foreach(profile =>
profile.individual = proxiedAppString
app.profileManager.updateProfile(profile)
)
Toast.makeText(this, R.string.action_apply_all, Toast.LENGTH_SHORT).show
case _ => Toast.makeText(this, R.string.action_export_err, Toast.LENGTH_SHORT).show
}
return true
case R.id.action_export =>
val bypass = prefs.getBoolean(Key.isBypassApps, false)
val proxiedAppString = prefs.getString(Key.proxied, "")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment