Skip to content

Commit

Permalink
Merge branch 'release/1.8.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Florianisme committed May 23, 2023
2 parents 033f84e + c819f89 commit 5883266
Show file tree
Hide file tree
Showing 27 changed files with 188 additions and 30 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Java CI

on: [push]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'adopt'
- name: Build
run: chmod +x ./gradlew && ./gradlew --parallel --max-workers=8 clean bundleDebug assembleDebug
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@ The companion app for Wear OS let's you control your devices directly from the w
<tr>
<td><img src="screenshots/Device_Overview.png" alt="1"></td>
<td><img src="screenshots/Device_Quick_Settings.png" alt="2"></td>
<td><img src="screenshots/Wear_OS.png" alt="3"></td>
</tr>
<tr>
<td><img src="screenshots/Wear_OS.png" alt="3"></td>
<td><img src="screenshots/Device_Color_Theme.png" alt="4"></td>
</tr>
<tr>
<td><img src="screenshots/Device_Quick_Access.png" alt="5"></td>
<td><img src="screenshots/Device_Shortcut.png" alt="5"></td>
<td><img src="screenshots/Device_Quick_Access.png" alt="6"></td>
</tr>
</table>
9 changes: 6 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apply from: "$rootProject.projectDir/shared-build.gradle"

android {
defaultConfig {
versionCode 69
versionCode 71
wearAppUnbundled true
}
buildFeatures {
Expand All @@ -12,8 +12,8 @@ android {
}

dependencies {
implementation 'androidx.appcompat:appcompat:1.6.0'
implementation 'com.google.android.material:material:1.7.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.8.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.navigation:navigation-fragment:2.5.3'
implementation 'androidx.navigation:navigation-ui:2.5.3'
Expand All @@ -22,6 +22,9 @@ dependencies {
implementation 'io.reactivex.rxjava2:rxjava:2.2.9'
implementation 'android.arch.lifecycle:livedata:1.1.1'

implementation "androidx.core:core:1.9.0"
implementation 'androidx.core:core-google-shortcuts:1.1.0'

def room_version = "2.5.0"
implementation "androidx.room:room-runtime:$room_version"
annotationProcessor "androidx.room:room-compiler:$room_version"
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
android:label="@string/title_activity_add_device"
android:theme="@style/Theme.WakeOnLan.NoDrawerActivity" />

<activity android:name=".shortcuts.WakeDeviceActivity" />

<service
android:name=".quicksettings.DeviceOneTileService"
android:label="@string/tile_name_device_one"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package de.florianisme.wakeonlan.shortcuts;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.core.content.pm.ShortcutInfoCompat;
import androidx.core.graphics.drawable.IconCompat;

import de.florianisme.wakeonlan.R;
import de.florianisme.wakeonlan.persistence.models.Device;

public class DeviceShortcutMapper {

public static ShortcutInfoCompat buildShortcut(Device device, Context context) {
return new ShortcutInfoCompat.Builder(context, String.valueOf(device.id))
.setShortLabel(device.name)
.setIntent(buildIntent(device, context))
.setIcon(IconCompat.createWithResource(context, R.drawable.device_shortcut))
.build();
}

@NonNull
private static Intent buildIntent(Device device, Context context) {
Intent wakeDeviceIntent = new Intent(context, WakeDeviceActivity.class);
wakeDeviceIntent.setAction(Intent.ACTION_VIEW);
Bundle bundle = new Bundle();
bundle.putInt(WakeDeviceActivity.DEVICE_ID_KEY, device.id);
wakeDeviceIntent.putExtras(bundle);
return wakeDeviceIntent;
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package de.florianisme.wakeonlan.shortcuts;

import android.content.Context;
import android.os.Build;

import androidx.core.content.pm.ShortcutManagerCompat;

import java.util.List;

import de.florianisme.wakeonlan.persistence.models.Device;

public class DynamicShortcutManager {

public void updateShortcuts(Context context, List<Device> devices) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N_MR1) {
return;
}

removeOldShortcuts(context);
publishShortcuts(context, devices);
}

private void publishShortcuts(Context context, List<Device> devices) {
devices.stream()
.sorted((device1, device2) -> Integer.compare(device2.id, device1.id))
.map(device -> DeviceShortcutMapper.buildShortcut(device, context))
.forEach(shortcut -> ShortcutManagerCompat.pushDynamicShortcut(context, shortcut));
}

private void removeOldShortcuts(Context context) {
ShortcutManagerCompat.removeAllDynamicShortcuts(context);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package de.florianisme.wakeonlan.shortcuts;

import android.os.Bundle;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

import com.google.common.base.Strings;

import de.florianisme.wakeonlan.R;
import de.florianisme.wakeonlan.persistence.models.Device;
import de.florianisme.wakeonlan.persistence.repository.DeviceRepository;
import de.florianisme.wakeonlan.wol.WolSender;

public class WakeDeviceActivity extends AppCompatActivity {

public static final String DEVICE_ID_KEY = "deviceId";

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

wakeDevice();
finish();
}

private void wakeDevice() {
Bundle extras = getIntent().getExtras();
if (extras != null) {
int machineId = extras.getInt(DEVICE_ID_KEY, -1);
if (machineId == -1) {
Toast.makeText(this, R.string.shortcut_wake_device_error, Toast.LENGTH_SHORT).show();
finish();
return;
}

Device device = DeviceRepository.getInstance(this).getById(machineId);

if (!Strings.isNullOrEmpty(device.macAddress)) {
WolSender.sendWolPacket(device);
Toast.makeText(this, getString(R.string.wol_toast_sending_packet, device.name), Toast.LENGTH_LONG).show();
} else {
Toast.makeText(this, R.string.shortcut_wake_device_error, Toast.LENGTH_SHORT).show();
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import de.florianisme.wakeonlan.R;
import de.florianisme.wakeonlan.databinding.ActivityMainBinding;
import de.florianisme.wakeonlan.persistence.repository.DeviceRepository;
import de.florianisme.wakeonlan.shortcuts.DynamicShortcutManager;
import de.florianisme.wakeonlan.wear.WearClient;

public class MainActivity extends AppCompatActivity {
Expand All @@ -37,6 +38,7 @@ protected void onCreate(Bundle savedInstanceState) {

initializeNavController();
initializeWearClient();
initializeShortcuts();
}

private void initializeWearClient() {
Expand All @@ -53,6 +55,13 @@ private void initializeNavController() {
NavigationUI.setupWithNavController(binding.navigationView, navController);
}

private void initializeShortcuts() {
DynamicShortcutManager dynamicShortcutManager = new DynamicShortcutManager();
DeviceRepository.getInstance(this)
.getAllAsObservable()
.observe(this, devices -> dynamicShortcutManager.updateShortcuts(this, devices));
}

private Set<Integer> getMenuIds() {
return Sets.newHashSet(R.id.deviceListFragment, R.id.backupFragment, R.id.networkScanFragment);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import de.florianisme.wakeonlan.persistence.repository.DeviceRepository;
import de.florianisme.wakeonlan.ui.modify.watcher.autocomplete.MacAddressAutocomplete;
import de.florianisme.wakeonlan.ui.modify.watcher.validator.InputNotEmptyValidator;
import de.florianisme.wakeonlan.ui.modify.watcher.validator.IpAddressValidator;
import de.florianisme.wakeonlan.ui.modify.watcher.validator.MacValidator;
import de.florianisme.wakeonlan.ui.modify.watcher.validator.SecureOnPasswordValidator;

Expand Down Expand Up @@ -84,7 +83,7 @@ private void addValidators() {
deviceMacInput.addTextChangedListener(new MacAddressAutocomplete());

deviceNameInput.addTextChangedListener(new InputNotEmptyValidator(deviceNameInput));
deviceBroadcastInput.addTextChangedListener(new IpAddressValidator(deviceBroadcastInput));
deviceBroadcastInput.addTextChangedListener(new InputNotEmptyValidator(deviceBroadcastInput));
deviceSecureOnPassword.addTextChangedListener(new SecureOnPasswordValidator(deviceSecureOnPassword));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.recyclerview.widget.RecyclerView;

import de.florianisme.wakeonlan.databinding.FragmentNetworkScanBinding;
Expand Down Expand Up @@ -71,16 +72,17 @@ public void onDeviceFound(String ip, String hostName) {
}

private void runOnUiThread(Runnable runnable) {
if (getActivity() == null) {
FragmentActivity activity = getActivity();
if (activity == null) {
// Activity has already finished, Threads were still running. Do nothing
return;
}
getActivity().runOnUiThread(runnable);
activity.runOnUiThread(runnable);
}

@Override
public void onTaskEnd() {
binding.swipeRefresh.setRefreshing(false);
runOnUiThread(() -> binding.swipeRefresh.setRefreshing(false));
}
};
}
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/res/drawable/device_shortcut.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector android:height="24dp"
android:tint="#000000"
android:viewportHeight="24"
android:viewportWidth="24"
android:width="24dp"
xmlns:android="http://schemas.android.com/apk/res/android">
<path
android:fillColor="@android:color/white"
android:pathData="M4,6h18L22,4L4,4c-1.1,0 -2,0.9 -2,2v11L0,17v3h14v-3L4,17L4,6zM23,8h-6c-0.55,0 -1,0.45 -1,1v10c0,0.55 0.45,1 1,1h6c0.55,0 1,-0.45 1,-1L24,9c0,-0.55 -0.45,-1 -1,-1zM22,17h-4v-7h4v7z" />
</vector>
1 change: 1 addition & 0 deletions app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,5 @@
<string name="add_device_secure_on">SecureOn Passwort (optional)</string>
<string name="add_device_error_secure_on_password_invalid">Passwort muss entweder leer oder eine gültige MAC oder IP Adresse sein</string>
<string name="quick_access_device_subtitle">Gerät einschalten</string>
<string name="shortcut_wake_device_error">Gerät kann nicht geweckt werden</string>
</resources>
3 changes: 3 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,7 @@

<!-- Quick Access -->
<string name="quick_access_device_subtitle">Wake device</string>

<!-- Shortcut Wake Device Activity -->
<string name="shortcut_wake_device_error">Could not wake device</string>
</resources>
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.4.0'
classpath 'com.android.tools.build:gradle:7.4.2'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
Binary file added screenshots/Device_Shortcut.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 5 additions & 5 deletions shared-build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ android {

signingConfigs {
release {
storeFile file(project.property('UPLOAD_KEYSTORE_PATH'))
storePassword project.property('KEYSTORE_PASSWORD')
keyAlias project.property('KEY_ALIAS')
keyPassword project.property('KEY_PASSWORD')
storeFile file(project.findProperty('UPLOAD_KEYSTORE_PATH') ?: " ")
storePassword project.findProperty('KEYSTORE_PASSWORD') ?: ""
keyAlias project.findProperty('KEY_ALIAS') ?: ""
keyPassword project.findProperty('KEY_PASSWORD') ?: ""

v1SigningEnabled true
v2SigningEnabled true
Expand All @@ -18,7 +18,7 @@ android {
applicationId "de.florianisme.wakeonlan"
minSdk 24
targetSdk 33
versionName "1.7.3"
versionName "1.8.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down
3 changes: 1 addition & 2 deletions wear/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ apply from: "$rootProject.projectDir/shared-build.gradle"

android {
defaultConfig {
versionCode 68
versionCode 70
}
}

dependencies {
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.2.1'

implementation 'androidx.wear:wear:1.2.0'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,9 @@ public void setDeviceName(String name) {
}

public void setOnClickHandler(DeviceDto device, OnDeviceClickedListener onDeviceClickedListener) {
deviceButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
onDeviceClickedListener.onDeviceClicked(device);
Toast.makeText(view.getContext(), view.getContext().getString(R.string.sending_magic_packet) + deviceButton.getText(), Toast.LENGTH_LONG).show();
}
deviceButton.setOnClickListener(view -> {
onDeviceClickedListener.onDeviceClicked(device);
Toast.makeText(view.getContext(), view.getContext().getString(R.string.sending_magic_packet, deviceButton.getText()), Toast.LENGTH_SHORT).show();
});
}

Expand Down
2 changes: 1 addition & 1 deletion wear/src/main/res/layout/activity_device_list.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
android:id="@+id/device_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="56dp"
android:paddingTop="24dp"
android:paddingBottom="56dp"
android:scrollbars="vertical" />
1 change: 1 addition & 0 deletions wear/src/main/res/layout/device_list_empty.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="32dp"
android:gravity="center">

<TextView
Expand Down
Binary file modified wear/src/main/res/mipmap-hdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified wear/src/main/res/mipmap-mdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified wear/src/main/res/mipmap-xhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified wear/src/main/res/mipmap-xxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified wear/src/main/res/mipmap-xxxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions wear/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Wake on Lan</string>
<string name="sending_magic_packet">"Magic Paket wird gesendet an "</string>
<string name="device_list_empty_description">Bitte konfigurieren Sie ihre Geräte in der \"Wake on Lan\" App auf ihrem Telefon</string>
<string name="sending_magic_packet">Magic Paket wird an %1$s gesendet</string>
<string name="device_list_empty_description">Bitte konfigurieren Sie Ihre Geräte in der \"Wake on Lan\" App auf Ihrem Telefon</string>
<string name="device_list_empty_title">Keine Geräte gefunden</string>
<string name="device_list_title">Alle Geräte</string>
<string name="device_list_no_data">Keine Daten empfangen</string>
Expand Down
2 changes: 1 addition & 1 deletion wear/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<resources>
<string name="app_name">Wake on Lan</string>
<string name="sending_magic_packet">"Sending Magic Packet to "</string>
<string name="sending_magic_packet">Sending Magic Packet to %1$s</string>

<string name="device_list_empty_description">Please configure your devices through the \"Wake on Lan\" app on your phone</string>
<string name="device_list_empty_title">No devices found</string>
Expand Down

0 comments on commit 5883266

Please sign in to comment.