Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ public void onCreate(Bundle savedInstanceState) {
general.addPreference(createDirectoryPreference(R.string.activity_settings_pref_transfer_directory, Settings.Key.TRANSFER_DIRECTORY));
general.addPreference(createCheckBoxPreference(R.string.activity_settings_pref_behavior_receive, R.string.activity_settings_pref_behavior_receive_summary, Settings.Key.BEHAVIOR_RECEIVE));
general.addPreference(createCheckBoxPreference(R.string.activity_settings_pref_behavior_overwrite, R.string.activity_settings_pref_behavior_overwrite_summary, Settings.Key.BEHAVIOR_OVERWRITE));
general.addPreference(createCheckBoxPreference(R.string.activity_settings_pref_behavior_autostart, R.string.activity_settings_pref_behavior_autostart_summary, Settings.Key.BEHAVIOR_AUTOSTART));
appearance.addPreference(createCheckBoxPreference(R.string.activity_settings_darkTheme, R.string.activity_settings_darkTheme_summary, Settings.Key.UI_DARK));
notifications.addPreference(createCheckBoxPreference(R.string.activity_settings_pref_notification_sound, R.string.activity_settings_pref_notification_sound_summary, Settings.Key.TRANSFER_NOTIFICATION));

Expand Down
3 changes: 3 additions & 0 deletions app/src/main/java/net/nitroshare/android/util/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class Settings {
public enum Key {
BEHAVIOR_RECEIVE, // Listen for incoming transfers
BEHAVIOR_OVERWRITE, // Overwrite files with identical names
BEHAVIOR_AUTOSTART, // Run at device startup
DEVICE_NAME, // Device name broadcast via mDNS
DEVICE_UUID, // Unique identifier for the device
INTRO_SHOWN, // Intro has been shown to user?
Expand Down Expand Up @@ -51,6 +52,8 @@ public Object getDefault(Key key) {
return true;
case BEHAVIOR_OVERWRITE:
return false;
case BEHAVIOR_AUTOSTART:
return true;
case DEVICE_NAME:
return Build.MODEL;
case DEVICE_UUID:
Expand Down
17 changes: 16 additions & 1 deletion app/src/main/java/net/nitroshare/android/util/StartReceiver.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,23 @@ public class StartReceiver extends BroadcastReceiver {

@Override
public void onReceive(Context context, Intent intent) {
if (new Settings(context).getBoolean(Settings.Key.BEHAVIOR_RECEIVE)) {
if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)
&& startServiceOnBoot(context)
&& receiveTransferAllowed(context)) {
TransferService.startStopService(context, true);
}
}

private static boolean getBooleanFromSettings(Context context, Settings.Key key) {
Settings s = new Settings(context);
return s.getBoolean(key);
}

private static boolean receiveTransferAllowed(Context context) {
return getBooleanFromSettings(context, Settings.Key.BEHAVIOR_RECEIVE);
}

private static boolean startServiceOnBoot(Context context) {
return getBooleanFromSettings(context, Settings.Key.BEHAVIOR_AUTOSTART);
}
}
2 changes: 2 additions & 0 deletions app/src/main/res/values-de-rDE/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,6 @@
<string name="adapter_transfer_bytes">%1$s / %2$s</string>
<string name="adapter_transfer_stop">Stopp</string>
<string name="adapter_transfer_retry">Erneut versuchen</string>
<string name="activity_settings_pref_behavior_autostart">Automatisch starten</string>
<string name="activity_settings_pref_behavior_autostart_summary">Nach dem Systemstart starten</string>
</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@
<string name="activity_settings_pref_behavior_receive_summary">Accept incoming transfers from other devices</string>
<string name="activity_settings_pref_behavior_overwrite">Overwrite</string>
<string name="activity_settings_pref_behavior_overwrite_summary">Replace existing files with the same name</string>
<string name="activity_settings_pref_behavior_autostart">Auto start</string>
<string name="activity_settings_pref_behavior_autostart_summary">Auto start when device starts</string>
<string name="activity_settings_category_notifications">Notifications</string>
<string name="activity_settings_pref_notification_sound">Notification Sound</string>
<string name="activity_settings_pref_notification_sound_summary">Play sound when a transfer completes</string>
Expand Down