mirror of
https://github.com/bilde2910/Hauk.git
synced 2026-01-23 02:24:09 +00:00
Merge 00ad4bddb7 into 55d2f8b8fd
This commit is contained in:
commit
82b0fc9b54
7 changed files with 86 additions and 2 deletions
|
|
@ -4,8 +4,11 @@
|
|||
package="info.varden.hauk">
|
||||
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
|
||||
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
|
|
@ -45,7 +48,7 @@
|
|||
</activity>
|
||||
|
||||
<receiver
|
||||
android:name=".global.Receiver"
|
||||
android:name=".global.ExportedReceiver"
|
||||
android:exported="true"
|
||||
tools:ignore="ExportedReceiver">
|
||||
<intent-filter>
|
||||
|
|
@ -53,6 +56,19 @@
|
|||
<action android:name="info.varden.hauk.START_ALONE_THEN_MAKE_TOAST" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<receiver
|
||||
android:name=".global.RebootReceiver"
|
||||
android:permission="android.permission.RECEIVE_BOOT_COMPLETED">
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
||||
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
|
||||
</receiver>
|
||||
|
||||
<receiver
|
||||
android:name=".notify.CopyLinkReceiver"
|
||||
android:exported="false">
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ public enum Constants {
|
|||
public static final Preference<String> PREF_NICKNAME = new Preference.String("nickname", "");
|
||||
public static final Preference<Integer> PREF_DURATION_UNIT = new Preference.Integer("durUnit", Constants.DURATION_UNIT_MINUTES);
|
||||
public static final Preference<Boolean> PREF_ALLOW_ADOPTION = new Preference.Boolean("allowAdoption", true);
|
||||
public static final Preference<Boolean> PREF_RESTART_ON_BOOT = new Preference.Boolean("restartOnBoot", true);
|
||||
public static final Preference<NightModeStyle> PREF_NIGHT_MODE = new Preference.Enum<>("nightMode", NightModeStyle.FOLLOW_SYSTEM);
|
||||
public static final Preference<Boolean> PREF_CONFIRM_STOP = new Preference.Boolean("confirmStop", true);
|
||||
public static final Preference<Boolean> PREF_HIDE_LOGO = new Preference.Boolean("hideLogo", false);
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ import info.varden.hauk.utils.TimeUtils;
|
|||
* @since 1.3
|
||||
* @author Marius Lindvall
|
||||
*/
|
||||
public final class Receiver extends BroadcastReceiver {
|
||||
public final class ExportedReceiver extends BroadcastReceiver {
|
||||
@SuppressWarnings("HardCodedStringLiteral")
|
||||
private static final String ACTION_START_SHARING_ALONE_WITH_MENU = "info.varden.hauk.START_ALONE_THEN_SHARE_VIA";
|
||||
@SuppressWarnings("HardCodedStringLiteral")
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
package info.varden.hauk.global;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.widget.Toast;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.Proxy;
|
||||
import java.net.SocketAddress;
|
||||
|
||||
import info.varden.hauk.Constants;
|
||||
import info.varden.hauk.R;
|
||||
import info.varden.hauk.global.ui.AuthorizationActivity;
|
||||
import info.varden.hauk.global.ui.DisplayShareDialogListener;
|
||||
import info.varden.hauk.global.ui.toast.GNSSStatusUpdateListenerImpl;
|
||||
import info.varden.hauk.global.ui.toast.SessionInitiationResponseHandlerImpl;
|
||||
import info.varden.hauk.global.ui.toast.ShareListenerImpl;
|
||||
import info.varden.hauk.http.ConnectionParameters;
|
||||
import info.varden.hauk.http.SessionInitiationPacket;
|
||||
import info.varden.hauk.http.security.CertificateValidationPolicy;
|
||||
import info.varden.hauk.manager.SessionManager;
|
||||
import info.varden.hauk.struct.AdoptabilityPreference;
|
||||
import info.varden.hauk.system.LocationPermissionsNotGrantedException;
|
||||
import info.varden.hauk.system.LocationServicesDisabledException;
|
||||
import info.varden.hauk.system.preferences.PreferenceManager;
|
||||
import info.varden.hauk.utils.DeprecationMigrator;
|
||||
import info.varden.hauk.utils.Log;
|
||||
import info.varden.hauk.utils.TimeUtils;
|
||||
// Reboot broadcast receiver for Hauk. If enabled resumes a share session if one exists on device restart
|
||||
public final class RebootReceiver extends BroadcastReceiver {
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
// Subsequent calls may result in data being read from preferences. We should ensure that
|
||||
// all deprecated preferences have been migrated before we continue.
|
||||
new DeprecationMigrator(context).migrate();
|
||||
|
||||
PreferenceManager prefs = new PreferenceManager(context);
|
||||
if(prefs.get(Constants.PREF_RESTART_ON_BOOT))
|
||||
resumeShare(context,intent);
|
||||
}
|
||||
private void resumeShare(Context context, Intent intent) {
|
||||
Log.d("Trying to resume shares...");
|
||||
new BroadcastSessionManager(context).resumeShares();
|
||||
}
|
||||
}
|
||||
|
|
@ -206,6 +206,15 @@ public abstract class SessionManager {
|
|||
}
|
||||
}
|
||||
|
||||
public final void resumeShares() {
|
||||
if (pusher != null) {
|
||||
Log.d("Pusher is non-null (%s), stopping and nulling it before calling service relauncher", pusher); //NON-NLS
|
||||
this.ctx.stopService(pusher);
|
||||
pusher = null;
|
||||
}
|
||||
this.resumable.tryResumeShare(new ServiceRelauncher(this, this.resumable));
|
||||
}
|
||||
|
||||
/**
|
||||
* A preparation step for initiating sessions. Checks location services status and instantiates
|
||||
* a response handler for the session initiation packet.
|
||||
|
|
@ -448,6 +457,7 @@ public abstract class SessionManager {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The GNSS status handler that the {@link SessionManager} itself uses to receive status updates
|
||||
* from the GNSS listeners. Used to propagate events further upstream.
|
||||
|
|
|
|||
|
|
@ -155,6 +155,10 @@
|
|||
<string name="tls_validation_no_anchor_onion">Disable trust anchor validation for .onion hosts (not recommended)</string>
|
||||
<string name="tls_validation_none_for_onion">Disable trust anchor and hostname validation for .onion hosts (not recommended)</string>
|
||||
|
||||
<string name="pref_restartOnBoot_title">Resume shares on device restart</string>
|
||||
<string name="pref_restartOnBoot_summaryOn">Resume shares on boot</string>
|
||||
<string name="pref_restartOnBoot_summaryOff">Do not resume shares on boot</string>
|
||||
|
||||
<!-- Appearance settings -->
|
||||
<string name="prefs_header_appearance">Appearance</string>
|
||||
<string name="prefs_nightMode_title">Night mode</string>
|
||||
|
|
|
|||
|
|
@ -104,6 +104,11 @@
|
|||
app:entries="@array/tls_validation_types"
|
||||
app:entryValues="@array/tls_validation_type_values" />
|
||||
|
||||
<SwitchPreference
|
||||
app:key="restartOnBoot"
|
||||
app:title="@string/pref_restartOnBoot_title"
|
||||
app:summaryOff="@string/pref_restartOnBoot_summaryOff"
|
||||
app:summaryOn="@string/pref_restartOnBoot_summaryOn" />
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory app:title="@string/prefs_header_appearance">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue