diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 92078a9..81b3985 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -21,7 +21,10 @@ android:theme="@android:style/Theme.Holo.Light.DarkActionBar" android:usesCleartextTraffic="true"> - @@ -33,6 +36,7 @@ android:value="true" /> + list = getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); + if (list.size() > 0) { + startActivity(intent); + } + } catch (Exception e) { + Log.e("exceptionAutostarti2pd" , String.valueOf(e)); + } + + } + //@Override + private void requestPermission() { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + if (!Settings.canDrawOverlays(this)) { + Intent intent = new Intent( + Settings.ACTION_MANAGE_OVERLAY_PERMISSION, + Uri.parse("package:" + getPackageName()) + ); + startActivityForResult(intent, 232); + } else { + //Permission Granted-System will work + } + } + } + public void onCreate(Bundle savedInstanceState) { + Log.i(TAG, "onCreate"); + super.onCreate(savedInstanceState); + cacheDir = getApplicationContext().getCacheDir(); + setContentView(R.layout.activity_settings); + Switch autostart_switch = findViewById(R.id.autostart_enable); + File onBoot= new File( cacheDir.getAbsolutePath()+onBootFileName); + autostart_switch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + // do something, the isChecked will be + // true if the switch is in the On position + if(isChecked){ + if( !onBoot.exists() ) { + requestPermission(); + addAutoStartupswitch(); + try { + if( !onBoot.createNewFile()) Log.d(TAG, "Cant create new wile on: "+onBoot.getAbsolutePath()); + } catch (Exception e) { + Log.d(TAG, "error: " + e.toString()); + } + } + }else{ + if( onBoot.exists() ) + onBoot.delete(); + } + } + }); + if(onBoot.exists()) autostart_switch.setChecked(true); + } +} diff --git a/app/src/main/java/org/purplei2p/i2pd/receivers/BootUpReceiver.java b/app/src/main/java/org/purplei2p/i2pd/receivers/BootUpReceiver.java index 08a0688..2a4078f 100644 --- a/app/src/main/java/org/purplei2p/i2pd/receivers/BootUpReceiver.java +++ b/app/src/main/java/org/purplei2p/i2pd/receivers/BootUpReceiver.java @@ -4,16 +4,28 @@ package org.purplei2p.i2pd.receivers; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; - +//import org.purplei2p.i2pd.ForegroundService; +//ToDo:* fix^^^ change to service, not on window on start. import org.purplei2p.i2pd.I2PDPermsAskerActivity; +import java.io.File; + +import static org.purplei2p.i2pd.SettingsActivity.onBootFileName; + public class BootUpReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { /* todo: disable the autostart? */ - Intent i = new Intent(context, I2PDPermsAskerActivity.class); - i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - context.startActivity(i); + File onBoot = + new File( + context.getApplicationContext().getCacheDir().getAbsolutePath() + + onBootFileName); + if(onBoot.exists()) { + Intent i = new Intent(context, I2PDPermsAskerActivity.class); + i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + context.startActivity(i); + } + } } diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml new file mode 100644 index 0000000..21f3ff4 --- /dev/null +++ b/app/src/main/res/layout/activity_settings.xml @@ -0,0 +1,62 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/menu/options_main.xml b/app/src/main/res/menu/options_main.xml index f5ea62a..292821c 100644 --- a/app/src/main/res/menu/options_main.xml +++ b/app/src/main/res/menu/options_main.xml @@ -23,6 +23,9 @@ android:id="@+id/action_graceful_stop" android:orderInCategory="98" android:title="@string/action_graceful_stop" /> + i2pd + Invisible Internet Protocol: + Сеть без границ + Запустить Остановить Корректная остановка Отменить корректную остановку Перезагрузить туннели Открыть Веб Консоль + Настройки Корректная остановка уже запущена Корректная остановка запущена @@ -37,7 +41,14 @@ Плановая остановка отменена Перезагрузка конфигурации туннелей... - Invisible Internet Protocol: - Запустить - Сеть без границ + + Автозагрузка при запуске телефона + + Основные настройки + Туннели + + Добавить + Добавление туннелей + + Удалить diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 7a0d7ea..d66a64e 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -10,6 +10,7 @@ Cancel Graceful Stop Reload tunnels Open Web Console + Settings Graceful stop is already in progress Graceful stop is in progress @@ -41,4 +42,14 @@ Planned shutdown canceled Reloading tunnels config... + + Common settings + Tunnels + + AutoStart on boot + Add tunnel + Tunnels adding + + Del tunnel +