| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- /******************************************************************************
- * *
- * Copyright (C) 2021 by nekohasekai <[email protected]> *
- * Copyright (C) 2021 by Max Lv <[email protected]> *
- * Copyright (C) 2021 by Mygod Studio <[email protected]> *
- * *
- * 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/>. *
- * *
- ******************************************************************************/
- package com.github.shadowsocks.plugin
- import android.app.Activity
- import android.content.Intent
- /**
- * Base class for configuration activity. A configuration activity is started when user wishes to configure the
- * selected plugin. To create a configuration activity, extend this class, implement abstract methods, invoke
- * `saveChanges(options)` and `discardChanges()` when appropriate, and add it to your manifest like this:
- *
- * <pre class="prettyprint"><manifest>
- * ...
- * <application>
- * ...
- * <activity android:name=".ConfigureActivity">
- * <intent-filter>
- * <action android:name="com.github.shadowsocks.plugin.ACTION_CONFIGURE"/>
- * <category android:name="android.intent.category.DEFAULT"/>
- * <data android:scheme="plugin"
- * android:host="com.github.shadowsocks"
- * android:path="/$PLUGIN_ID"/>
- * </intent-filter>
- * </activity>
- * ...
- * </application>
- *</manifest></pre>
- */
- abstract class ConfigurationActivity : OptionsCapableActivity() {
- /**
- * Equivalent to setResult(RESULT_CANCELED).
- */
- fun discardChanges() = setResult(Activity.RESULT_CANCELED)
- /**
- * Equivalent to setResult(RESULT_OK, args_with_correct_format).
- *
- * @param options PluginOptions to save.
- */
- fun saveChanges(options: PluginOptions) =
- setResult(Activity.RESULT_OK, Intent().putExtra(PluginContract.EXTRA_OPTIONS, options.toString()))
- /**
- * Finish this activity and request manual editor to pop up instead.
- */
- fun fallbackToManualEditor() {
- setResult(PluginContract.RESULT_FALLBACK)
- finish()
- }
- }
|