Refactoring
10
README.md
|
@ -1,8 +1,8 @@
|
||||||
NoWOL
|
### NoWOL
|
||||||
|
|
||||||
|
![License](https://img.shields.io/badge/License-GPLv3-blue.svg)
|
||||||
|
|
||||||
Android application to rule PC power management. A part of NoWOL project.
|
Android application to rule PC power management. A part of NoWOL project.
|
||||||
[https://developersu.blogspot.com/2018/04/nowol-2.html](https://developersu.blogspot.com/2018/04/nowol-2.html)
|
[https://developersu.blogspot.com/2018/04/nowol-2.html](https://developersu.blogspot.com/2018/04/nowol-2.html)
|
||||||
|
|
||||||
License: GNU GPL v.3.
|
2017-2020, Russia
|
||||||
|
|
||||||
Dmitry Isaenko
|
|
||||||
2017, Russia
|
|
||||||
|
|
|
@ -4,11 +4,11 @@ android {
|
||||||
compileSdkVersion 29
|
compileSdkVersion 29
|
||||||
buildToolsVersion "29.0.2"
|
buildToolsVersion "29.0.2"
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "com.blogspot.developersu.nowol.nowol"
|
applicationId "com.blogspot.developersu.nowol"
|
||||||
minSdkVersion 14
|
minSdkVersion 14
|
||||||
targetSdkVersion 29
|
targetSdkVersion 29
|
||||||
versionCode 4
|
versionCode 5
|
||||||
versionName "4.0"
|
versionName "5.0"
|
||||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||||
vectorDrawables.useSupportLibrary = true
|
vectorDrawables.useSupportLibrary = true
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,10 @@ android {
|
||||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
compileOptions {
|
||||||
|
sourceCompatibility JavaVersion.VERSION_1_8
|
||||||
|
targetCompatibility JavaVersion.VERSION_1_8
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="com.blogspot.developersu.nowol.nowol">
|
package="com.blogspot.developersu.nowol">
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
<permission android:name="com.blogspot.developersu.nowol.nowol"
|
<permission android:name="com.blogspot.developersu.nowol.nowol"
|
||||||
|
@ -12,12 +12,11 @@
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
android:icon="@mipmap/ic_launcher"
|
android:icon="@mipmap/ic_launcher"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:supportsRtl="true"
|
|
||||||
android:resizeableActivity="true"
|
android:resizeableActivity="true"
|
||||||
android:supportsPictureInPicture="true"
|
android:supportsPictureInPicture="true"
|
||||||
android:usesCleartextTraffic="true"
|
android:supportsRtl="true"
|
||||||
android:theme="@style/AppTheme">
|
android:theme="@style/AppTheme"
|
||||||
|
android:usesCleartextTraffic="true">
|
||||||
|
|
||||||
<activity android:name=".MainActivity">
|
<activity android:name=".MainActivity">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
|
@ -26,8 +25,8 @@
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
<!---->
|
|
||||||
<receiver android:name=".com.blogspot.developersu.nowol.nowol.widget.NoWolWidget">
|
<receiver android:name=".widget.NoWolWidget">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
|
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
@ -41,7 +40,7 @@
|
||||||
android:name=".SendRequestService"
|
android:name=".SendRequestService"
|
||||||
android:exported="false" />
|
android:exported="false" />
|
||||||
|
|
||||||
<activity android:name=".com.blogspot.developersu.nowol.nowol.widget.WidgetConfigurator">
|
<activity android:name=".widget.WidgetConfigurator">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />
|
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
|
BIN
app/src/main/ic_launcher-web.png
Normal file
After Width: | Height: | Size: 4.9 KiB |
|
@ -0,0 +1,218 @@
|
||||||
|
/*
|
||||||
|
Copyright 2017-2020 Dmitry Isaenko
|
||||||
|
|
||||||
|
This file is part of NoWOL.
|
||||||
|
|
||||||
|
NoWOL 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.
|
||||||
|
|
||||||
|
NoWOL 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 NoWOL. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package com.blogspot.developersu.nowol;
|
||||||
|
|
||||||
|
import android.app.Dialog;
|
||||||
|
import android.appwidget.AppWidgetManager;
|
||||||
|
import android.content.ComponentName;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.ResultReceiver;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.text.Editable;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.MenuInflater;
|
||||||
|
import android.view.MenuItem;
|
||||||
|
import android.view.WindowManager;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.appcompat.widget.Toolbar;
|
||||||
|
import androidx.core.content.ContextCompat;
|
||||||
|
import com.blogspot.developersu.nowol.widget.NoWolWidget;
|
||||||
|
import com.google.android.material.snackbar.Snackbar;
|
||||||
|
|
||||||
|
import static com.blogspot.developersu.nowol.ServerReplies.*;
|
||||||
|
|
||||||
|
public class MainActivity extends AppCompatActivity {
|
||||||
|
private TextView hostAddress,
|
||||||
|
statusLbl;
|
||||||
|
|
||||||
|
private Intent SendRequestIntent;
|
||||||
|
|
||||||
|
private int status = -2;
|
||||||
|
|
||||||
|
private SharedPreferences settings;
|
||||||
|
|
||||||
|
private class MyResultReciever extends ResultReceiver{
|
||||||
|
|
||||||
|
MyResultReciever(Handler handler) {
|
||||||
|
super(handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onReceiveResult(int resultCode, Bundle resultData) {
|
||||||
|
super.onReceiveResult(resultCode, resultData);
|
||||||
|
status = resultCode;
|
||||||
|
updateServerStatusText(resultCode);
|
||||||
|
showSnackBarNotice(resultCode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void doRequest(String url) {
|
||||||
|
SendRequestIntent.putExtra("url", url);
|
||||||
|
startService(SendRequestIntent);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void inform(String textToShow){
|
||||||
|
Snackbar.make(findViewById(android.R.id.content), textToShow, Snackbar.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
|
||||||
|
// provide toolbar options
|
||||||
|
@Override
|
||||||
|
public boolean onCreateOptionsMenu(Menu menu){
|
||||||
|
MenuInflater infMenu = getMenuInflater();
|
||||||
|
infMenu.inflate(R.menu.toolbar_main, menu);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onSaveInstanceState(Bundle outState) {
|
||||||
|
super.onSaveInstanceState(outState);
|
||||||
|
outState.putInt("STATE", status);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(final Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_main);
|
||||||
|
|
||||||
|
MyResultReciever myReciever = new MyResultReciever(null);
|
||||||
|
SendRequestIntent = new Intent(this, SendRequestService.class);
|
||||||
|
SendRequestIntent.putExtra("receiver", myReciever);
|
||||||
|
|
||||||
|
// toolbar setup start
|
||||||
|
Toolbar toolBar = findViewById(R.id.toolbar);
|
||||||
|
setSupportActionBar(toolBar);
|
||||||
|
getSupportActionBar();
|
||||||
|
// toolbar setup end
|
||||||
|
|
||||||
|
hostAddress = findViewById(R.id.hostNameStaticMain);
|
||||||
|
statusLbl = findViewById(R.id.statusTxtMainAct);
|
||||||
|
|
||||||
|
if (savedInstanceState != null){
|
||||||
|
status = savedInstanceState.getInt("STATE");
|
||||||
|
updateServerStatusText(status);
|
||||||
|
}
|
||||||
|
|
||||||
|
Button powerBtn = findViewById(R.id.pwrBntMainAct);
|
||||||
|
Button power5Btn = findViewById(R.id.pwr5BntMainAct);
|
||||||
|
Button resetBtn = findViewById(R.id.resBntMainAct);
|
||||||
|
// Set request queue for Volley
|
||||||
|
|
||||||
|
settings = getSharedPreferences("NoWolPreferences", MODE_PRIVATE);
|
||||||
|
hostAddress.setText(settings.getString("Host", getResources().getString(R.string.hostNameDefault)));
|
||||||
|
|
||||||
|
final Button.OnClickListener ActionButtonsListener = event -> {
|
||||||
|
switch (event.getId()) {
|
||||||
|
case R.id.pwrBntMainAct:
|
||||||
|
doRequest(hostAddress.getText().toString() + "/?POWER0=on");
|
||||||
|
break;
|
||||||
|
case R.id.pwr5BntMainAct:
|
||||||
|
doRequest(hostAddress.getText().toString() + "/?POWER1=on");
|
||||||
|
break;
|
||||||
|
case R.id.resBntMainAct:
|
||||||
|
doRequest(hostAddress.getText().toString() + "/?RESET=on");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
// RequestQueue
|
||||||
|
powerBtn.setOnClickListener(ActionButtonsListener);
|
||||||
|
power5Btn.setOnClickListener(ActionButtonsListener);
|
||||||
|
resetBtn.setOnClickListener(ActionButtonsListener);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateServerStatusText(int status){
|
||||||
|
switch (status) {
|
||||||
|
case STATE_ON:
|
||||||
|
statusLbl.setText(getResources().getString(R.string.statusOnline));
|
||||||
|
statusLbl.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.colorPrimaryDark));
|
||||||
|
break;
|
||||||
|
case STATE_OFF:
|
||||||
|
statusLbl.setText(getResources().getString(R.string.statusOffline));
|
||||||
|
statusLbl.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.colorRed));
|
||||||
|
break;
|
||||||
|
case STATE_UNKNOWN:
|
||||||
|
statusLbl.setText(getResources().getString(R.string.noResponse));
|
||||||
|
statusLbl.setTextColor(hostAddress.getTextColors());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void showSnackBarNotice(int status) {
|
||||||
|
switch (status) {
|
||||||
|
case STATE_ON:
|
||||||
|
inform(getResources().getString(R.string.statusOnline));
|
||||||
|
break;
|
||||||
|
case STATE_OFF:
|
||||||
|
inform(getResources().getString(R.string.statusOffline));
|
||||||
|
break;
|
||||||
|
case STATE_UNKNOWN:
|
||||||
|
inform(getResources().getString(R.string.noResponse) + hostAddress.getText().toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(MenuItem item){
|
||||||
|
switch (item.getItemId()){
|
||||||
|
case R.id.refreshMenu: /* Button requests status */
|
||||||
|
doRequest(hostAddress.getText().toString());
|
||||||
|
break;
|
||||||
|
case R.id.changeHostMenu: /* Button requests pop-up window */
|
||||||
|
showSettingsDialog();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showSettingsDialog(){
|
||||||
|
final Dialog dialog = new Dialog(this);
|
||||||
|
dialog.setContentView(R.layout.settings_popup);
|
||||||
|
dialog.setTitle(getString(R.string.popupTitle));
|
||||||
|
EditText input = (EditText) dialog.findViewById(R.id.input);
|
||||||
|
input.setText(hostAddress.getText());
|
||||||
|
Button confirmButton = (Button) dialog.findViewById(R.id.confirm);
|
||||||
|
confirmButton.setOnClickListener(event -> {
|
||||||
|
updateAllUsingNewIp(input.getText());
|
||||||
|
dialog.dismiss();
|
||||||
|
});
|
||||||
|
dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
|
||||||
|
dialog.show();
|
||||||
|
}
|
||||||
|
private void updateAllUsingNewIp(Editable newIpAddress){
|
||||||
|
hostAddress.setText(newIpAddress);
|
||||||
|
// TODO:fix
|
||||||
|
inform(getResources().getString(R.string.hostLblMain) + newIpAddress);
|
||||||
|
settings.edit().putString("Host", newIpAddress.toString()).apply();
|
||||||
|
|
||||||
|
/* Update widgets by sending broadcast intent */
|
||||||
|
Intent updateWidgetIntent = new Intent(this, NoWolWidget.class);
|
||||||
|
updateWidgetIntent.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
|
||||||
|
|
||||||
|
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(this);
|
||||||
|
int[] appWidgetIds = appWidgetManager.getAppWidgetIds(new ComponentName(this, NoWolWidget.class));
|
||||||
|
updateWidgetIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, appWidgetIds);
|
||||||
|
sendBroadcast(updateWidgetIntent);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDestroy() {
|
||||||
|
super.onDestroy();
|
||||||
|
stopService(SendRequestIntent); // just in case
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,98 @@
|
||||||
|
/*
|
||||||
|
Copyright 2017-2020 Dmitry Isaenko
|
||||||
|
|
||||||
|
This file is part of NoWOL.
|
||||||
|
|
||||||
|
NoWOL 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.
|
||||||
|
|
||||||
|
NoWOL 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 NoWOL. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package com.blogspot.developersu.nowol;
|
||||||
|
|
||||||
|
import android.app.IntentService;
|
||||||
|
import android.appwidget.AppWidgetManager;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.ResultReceiver;
|
||||||
|
import android.widget.RemoteViews;
|
||||||
|
import androidx.core.content.ContextCompat;
|
||||||
|
import com.android.volley.Request;
|
||||||
|
import com.android.volley.RequestQueue;
|
||||||
|
import com.android.volley.toolbox.StringRequest;
|
||||||
|
import com.android.volley.toolbox.Volley;
|
||||||
|
|
||||||
|
import static com.blogspot.developersu.nowol.ServerReplies.*;
|
||||||
|
|
||||||
|
public class SendRequestService extends IntentService {
|
||||||
|
|
||||||
|
private ResultReceiver resReceiver;
|
||||||
|
|
||||||
|
public SendRequestService() {
|
||||||
|
super("MyIntentService");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onHandleIntent(Intent intent) {
|
||||||
|
Bundle bundle = intent.getExtras();
|
||||||
|
|
||||||
|
if (bundle == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
String url = bundle.getString("url");
|
||||||
|
resReceiver = bundle.getParcelable("receiver");
|
||||||
|
final int appWidgetId = bundle.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID);
|
||||||
|
|
||||||
|
RequestQueue queueStd = Volley.newRequestQueue(this);
|
||||||
|
|
||||||
|
StringRequest strRequest = new StringRequest(Request.Method.GET, url, //will be 4 requests
|
||||||
|
response -> {
|
||||||
|
if (response.contains("00c600"))
|
||||||
|
sendData(STATE_ON, appWidgetId);
|
||||||
|
else
|
||||||
|
sendData(STATE_OFF, appWidgetId);
|
||||||
|
}, error -> sendData(STATE_UNKNOWN, appWidgetId));
|
||||||
|
|
||||||
|
queueStd.add(strRequest);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sendData(int state, int widgetId){
|
||||||
|
final int greenColor = ContextCompat.getColor(this, R.color.colorPrimary);
|
||||||
|
final int redColor = ContextCompat.getColor(this, R.color.colorRed);
|
||||||
|
final int orangeColor = ContextCompat.getColor(this, R.color.colorOrange);
|
||||||
|
|
||||||
|
// MainActivity requested
|
||||||
|
if (widgetId == 0){
|
||||||
|
resReceiver.send(state, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (state){
|
||||||
|
case STATE_ON:
|
||||||
|
setWidgetTextColorIndication(widgetId, getResources().getString(R.string.statusOnline), greenColor);
|
||||||
|
break;
|
||||||
|
case STATE_OFF:
|
||||||
|
setWidgetTextColorIndication(widgetId, getResources().getString(R.string.statusOffline), redColor);
|
||||||
|
break;
|
||||||
|
case STATE_UNKNOWN:
|
||||||
|
setWidgetTextColorIndication(widgetId, getResources().getString(R.string.noResponse), orangeColor);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void setWidgetTextColorIndication(int widgetId, String text, int color){
|
||||||
|
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(this);
|
||||||
|
RemoteViews remoteViews = new RemoteViews(getPackageName(), R.layout.no_wol_widget);
|
||||||
|
|
||||||
|
remoteViews.setTextViewText(R.id.widgetStatusText, text);
|
||||||
|
remoteViews.setInt(R.id.widgetHeaderLayout, "setBackgroundColor", color);
|
||||||
|
|
||||||
|
appWidgetManager.updateAppWidget(widgetId, remoteViews);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
/*
|
||||||
|
Copyright 2017-2020 Dmitry Isaenko
|
||||||
|
|
||||||
|
This file is part of NoWOL.
|
||||||
|
|
||||||
|
NoWOL 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.
|
||||||
|
|
||||||
|
NoWOL 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 NoWOL. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package com.blogspot.developersu.nowol;
|
||||||
|
|
||||||
|
public class ServerReplies {
|
||||||
|
public static final int STATE_ON = 1;
|
||||||
|
public static final int STATE_OFF = 0;
|
||||||
|
public static final int STATE_UNKNOWN = -1;
|
||||||
|
}
|
|
@ -1,205 +0,0 @@
|
||||||
package com.blogspot.developersu.nowol.nowol;
|
|
||||||
|
|
||||||
import android.appwidget.AppWidgetManager;
|
|
||||||
import android.content.ComponentName;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.os.Handler;
|
|
||||||
import android.os.ResultReceiver;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.view.Menu;
|
|
||||||
import android.view.MenuInflater;
|
|
||||||
import android.view.MenuItem;
|
|
||||||
import android.view.View;
|
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.TextView;
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
|
||||||
import androidx.appcompat.widget.Toolbar;
|
|
||||||
import androidx.core.content.ContextCompat;
|
|
||||||
import com.blogspot.developersu.nowol.nowol.com.blogspot.developersu.nowol.nowol.widget.NoWolWidget;
|
|
||||||
import com.google.android.material.snackbar.Snackbar;
|
|
||||||
|
|
||||||
public class MainActivity extends AppCompatActivity implements popUp.pupUpRetuningValueListener {
|
|
||||||
private TextView hostAddress;
|
|
||||||
private TextView statusLbl;
|
|
||||||
|
|
||||||
Intent SendRequestIntent;
|
|
||||||
|
|
||||||
private int status = -2;
|
|
||||||
|
|
||||||
SharedPreferences.Editor settingsEditor;
|
|
||||||
// define reciever for the data we got from service
|
|
||||||
private class MyResultReciever extends ResultReceiver{
|
|
||||||
|
|
||||||
MyResultReciever(Handler handler) {
|
|
||||||
super(handler);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onReceiveResult(int resultCode, Bundle resultData) {
|
|
||||||
super.onReceiveResult(resultCode, resultData);
|
|
||||||
switch (resultCode) {
|
|
||||||
case 1:
|
|
||||||
inform(getResources().getString(R.string.statusOnline));
|
|
||||||
statusLbl.setText(getResources().getString(R.string.statusOnline));
|
|
||||||
statusLbl.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.colorPrimaryDark));
|
|
||||||
break;
|
|
||||||
case 0:
|
|
||||||
inform(getResources().getString(R.string.statusOffline));
|
|
||||||
statusLbl.setText(getResources().getString(R.string.statusOffline));
|
|
||||||
statusLbl.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.colorRed));
|
|
||||||
break;
|
|
||||||
case -1:
|
|
||||||
inform(getResources().getString(R.string.noResponse) + hostAddress.getText().toString());
|
|
||||||
statusLbl.setText(getResources().getString(R.string.noResponse));
|
|
||||||
statusLbl.setTextColor(hostAddress.getTextColors());
|
|
||||||
break;
|
|
||||||
default: break;
|
|
||||||
}
|
|
||||||
status = resultCode;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//reciever end
|
|
||||||
private void doRequest(String url) {
|
|
||||||
SendRequestIntent.putExtra("url", url);
|
|
||||||
startService(SendRequestIntent);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void inform(String textToShow){
|
|
||||||
//Toast.makeText(this, textToShow, Toast.LENGTH_SHORT).show();
|
|
||||||
// .setGravity(Gravity.TOP|Gravity.BOTTOM,0,0)
|
|
||||||
Snackbar.make(findViewById(android.R.id.content), textToShow, Snackbar.LENGTH_SHORT).show();
|
|
||||||
// SOME GOODS APPEARS SUDDENLY android.R.id.content gives you the root element of a view, without having to know its actual name/type/ID.
|
|
||||||
}
|
|
||||||
|
|
||||||
// provide toolbar options
|
|
||||||
@Override
|
|
||||||
public boolean onCreateOptionsMenu(Menu menu){
|
|
||||||
MenuInflater infMenu = getMenuInflater();
|
|
||||||
infMenu.inflate(R.menu.toolbar_main, menu);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onSaveInstanceState(Bundle outState) {
|
|
||||||
super.onSaveInstanceState(outState);
|
|
||||||
outState.putInt("STATE", status);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onCreate(final Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
setContentView(R.layout.activity_main);
|
|
||||||
|
|
||||||
MyResultReciever myReciever = new MyResultReciever(null);
|
|
||||||
SendRequestIntent = new Intent(this, SendRequestService.class);
|
|
||||||
SendRequestIntent.putExtra("reciever", myReciever);
|
|
||||||
|
|
||||||
// toolbar setup start
|
|
||||||
Toolbar toolBar = findViewById(R.id.toolbar);
|
|
||||||
setSupportActionBar(toolBar);
|
|
||||||
getSupportActionBar();
|
|
||||||
// toolbar setup end
|
|
||||||
|
|
||||||
hostAddress = findViewById(R.id.hostNameStaticMain);
|
|
||||||
statusLbl = findViewById(R.id.statusTxtMainAct);
|
|
||||||
|
|
||||||
if (savedInstanceState != null){
|
|
||||||
status = savedInstanceState.getInt("STATE");
|
|
||||||
switch (status) {
|
|
||||||
case 1:
|
|
||||||
inform(getResources().getString(R.string.statusOnline));
|
|
||||||
statusLbl.setText(getResources().getString(R.string.statusOnline));
|
|
||||||
statusLbl.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.colorPrimaryDark));
|
|
||||||
break;
|
|
||||||
case 0:
|
|
||||||
inform(getResources().getString(R.string.statusOffline));
|
|
||||||
statusLbl.setText(getResources().getString(R.string.statusOffline));
|
|
||||||
statusLbl.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.colorRed));
|
|
||||||
break;
|
|
||||||
case -1:
|
|
||||||
inform(getResources().getString(R.string.noResponse) + hostAddress.getText().toString());
|
|
||||||
statusLbl.setText(getResources().getString(R.string.noResponse));
|
|
||||||
statusLbl.setTextColor(hostAddress.getTextColors());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Button powerBtn = findViewById(R.id.pwrBntMainAct);
|
|
||||||
Button power5Btn = findViewById(R.id.pwr5BntMainAct);
|
|
||||||
Button resetBtn = findViewById(R.id.resBntMainAct);
|
|
||||||
// Set request queue for Volley
|
|
||||||
|
|
||||||
|
|
||||||
SharedPreferences settings = getSharedPreferences("NoWolPreferences", MODE_PRIVATE);
|
|
||||||
hostAddress.setText(settings.getString("Host", getResources().getString(R.string.hostNameDefault)));
|
|
||||||
settingsEditor = settings.edit();
|
|
||||||
|
|
||||||
final Button.OnClickListener ActionButtonsListener = new Button.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
switch (v.getId()) {
|
|
||||||
case R.id.pwrBntMainAct:
|
|
||||||
doRequest(hostAddress.getText().toString() + "/?POWER0=on");
|
|
||||||
break;
|
|
||||||
case R.id.pwr5BntMainAct:
|
|
||||||
doRequest(hostAddress.getText().toString() + "/?POWER1=on");
|
|
||||||
break;
|
|
||||||
case R.id.resBntMainAct:
|
|
||||||
doRequest(hostAddress.getText().toString() + "/?RESET=on");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
// RequestQueue
|
|
||||||
powerBtn.setOnClickListener(ActionButtonsListener);
|
|
||||||
power5Btn.setOnClickListener(ActionButtonsListener);
|
|
||||||
resetBtn.setOnClickListener(ActionButtonsListener);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFinishEdit (String hostNameReSet){
|
|
||||||
hostAddress.setText(hostNameReSet);
|
|
||||||
inform(getResources().getString(R.string.hostLblMain) + hostNameReSet);
|
|
||||||
settingsEditor.putString("Host", hostNameReSet);
|
|
||||||
settingsEditor.commit();
|
|
||||||
/*
|
|
||||||
Update widgets by sending broadcast intent
|
|
||||||
*/
|
|
||||||
Intent updateWidgetIntent = new Intent(this, NoWolWidget.class);
|
|
||||||
updateWidgetIntent.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
|
|
||||||
|
|
||||||
AppWidgetManager awm = AppWidgetManager.getInstance(this);
|
|
||||||
int[] IDs = awm.getAppWidgetIds(new ComponentName(this, NoWolWidget.class));
|
|
||||||
updateWidgetIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, IDs);
|
|
||||||
getApplicationContext().sendBroadcast(updateWidgetIntent);
|
|
||||||
/*
|
|
||||||
broadcast end
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onOptionsItemSelected(MenuItem item){
|
|
||||||
switch (item.getItemId()){
|
|
||||||
case R.id.refreshMenu: /* Button requests status */
|
|
||||||
doRequest(hostAddress.getText().toString());
|
|
||||||
break;
|
|
||||||
case R.id.changeHostMenu: /* Button requests pop-up window */
|
|
||||||
popUp N = popUp.newInstance(hostAddress.getText());
|
|
||||||
N.show(this.getSupportFragmentManager(), "tst");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
//onOptionsItemSelected(item);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onDestroy() {
|
|
||||||
super.onDestroy();
|
|
||||||
stopService(SendRequestIntent); // just in case
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,92 +0,0 @@
|
||||||
package com.blogspot.developersu.nowol.nowol;
|
|
||||||
|
|
||||||
import android.app.IntentService;
|
|
||||||
import android.appwidget.AppWidgetManager;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.os.ResultReceiver;
|
|
||||||
import android.widget.RemoteViews;
|
|
||||||
import androidx.core.content.ContextCompat;
|
|
||||||
import com.android.volley.Request;
|
|
||||||
import com.android.volley.RequestQueue;
|
|
||||||
import com.android.volley.Response;
|
|
||||||
import com.android.volley.VolleyError;
|
|
||||||
import com.android.volley.toolbox.StringRequest;
|
|
||||||
import com.android.volley.toolbox.Volley;
|
|
||||||
|
|
||||||
|
|
||||||
public class SendRequestService extends IntentService {
|
|
||||||
|
|
||||||
private static final int STATE_ON = 1;
|
|
||||||
private static final int STATE_OFF = 0;
|
|
||||||
private static final int STATE_UNKNOWN = -1;
|
|
||||||
|
|
||||||
private ResultReceiver resReceiver;
|
|
||||||
|
|
||||||
public SendRequestService() {
|
|
||||||
super("MyIntentService");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void sendData(int state, int awID){
|
|
||||||
// MainActivity requested
|
|
||||||
if (awID == 0) {
|
|
||||||
// Log.d("qwerty1212", "MainActivity case. Status = " + Integer.toString(state) + " awID = " + Integer.toString(awID));
|
|
||||||
resReceiver.send(state, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
RemoteViews rv = new RemoteViews(getPackageName(), R.layout.no_wol_widget);
|
|
||||||
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(this);
|
|
||||||
|
|
||||||
switch (state){
|
|
||||||
case STATE_ON:
|
|
||||||
rv.setTextViewText(R.id.widgetStatusText, getResources().getString(R.string.statusOnline));
|
|
||||||
rv.setInt(R.id.widgetHeaderLayout, "setBackgroundColor", ContextCompat.getColor(this, R.color.colorPrimary));
|
|
||||||
// Log.d("qwerty1212", "case 1 widget");
|
|
||||||
break;
|
|
||||||
case STATE_OFF:
|
|
||||||
rv.setTextViewText(R.id.widgetStatusText, getResources().getString(R.string.statusOffline));
|
|
||||||
rv.setInt(R.id.widgetHeaderLayout, "setBackgroundColor", ContextCompat.getColor(this, R.color.colorRed));
|
|
||||||
// Log.d("qwerty1212", "case 0 widget");
|
|
||||||
break;
|
|
||||||
case STATE_UNKNOWN:
|
|
||||||
rv.setTextViewText(R.id.widgetStatusText, getResources().getString(R.string.noResponse));
|
|
||||||
rv.setInt(R.id.widgetHeaderLayout, "setBackgroundColor", ContextCompat.getColor(this, R.color.colorOrange));
|
|
||||||
// Log.d("qwerty1212", "case -1 widget");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
appWidgetManager.updateAppWidget(awID, rv);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onHandleIntent(Intent intent) {
|
|
||||||
if (intent == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Log.d("service", "Got intent");
|
|
||||||
Bundle bndle = intent.getExtras();
|
|
||||||
String url = bndle.getString("url");
|
|
||||||
resReceiver = bndle.getParcelable("reciever");
|
|
||||||
final int awID = bndle.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID);
|
|
||||||
|
|
||||||
// Log.d("qwerty1212", "got from " + Integer.toString(awID) +" "+ url);
|
|
||||||
|
|
||||||
RequestQueue queueStd = Volley.newRequestQueue(this);
|
|
||||||
StringRequest strRequest = new StringRequest(Request.Method.GET, url, //will be 4 requests
|
|
||||||
new Response.Listener<String>() {
|
|
||||||
@Override
|
|
||||||
public void onResponse(String response) {
|
|
||||||
if (response.contains("00c600")){
|
|
||||||
sendData(STATE_ON, awID);
|
|
||||||
} else {
|
|
||||||
sendData(STATE_OFF, awID);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, new Response.ErrorListener() {
|
|
||||||
@Override
|
|
||||||
public void onErrorResponse(VolleyError error) {
|
|
||||||
sendData(STATE_UNKNOWN, awID);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
queueStd.add(strRequest);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,93 +0,0 @@
|
||||||
package com.blogspot.developersu.nowol.nowol.com.blogspot.developersu.nowol.nowol.widget;
|
|
||||||
|
|
||||||
import android.app.PendingIntent;
|
|
||||||
import android.appwidget.AppWidgetManager;
|
|
||||||
import android.appwidget.AppWidgetProvider;
|
|
||||||
import android.content.ComponentName;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.graphics.Color;
|
|
||||||
import android.widget.RemoteViews;
|
|
||||||
|
|
||||||
import com.blogspot.developersu.nowol.nowol.R;
|
|
||||||
import com.blogspot.developersu.nowol.nowol.SendRequestService;
|
|
||||||
|
|
||||||
|
|
||||||
public class NoWolWidget extends AppWidgetProvider {
|
|
||||||
|
|
||||||
private void setRequests(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIDs){
|
|
||||||
SharedPreferences sharedSettings = context.getSharedPreferences("NoWolPreferences", Context.MODE_PRIVATE);
|
|
||||||
String hostIP = sharedSettings.getString("Host", context.getResources().getString(R.string.hostNameDefault));
|
|
||||||
int bgColor = sharedSettings.getInt("WidgetBgColor", Color.BLACK);
|
|
||||||
|
|
||||||
RemoteViews rv = new RemoteViews(context.getPackageName(), R.layout.no_wol_widget);
|
|
||||||
|
|
||||||
rv.setInt(R.id.widgetBasicLayout, "setBackgroundColor", bgColor);
|
|
||||||
|
|
||||||
for (int appWidgetId : appWidgetIDs) {
|
|
||||||
//refresh
|
|
||||||
Intent refreshIntent = new Intent(context, SendRequestService.class);
|
|
||||||
refreshIntent.putExtra("url", hostIP);
|
|
||||||
refreshIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
|
|
||||||
PendingIntent refreshPendingIntent = PendingIntent.getService(context, appWidgetId+1, refreshIntent, PendingIntent.FLAG_UPDATE_CURRENT);
|
|
||||||
rv.setOnClickPendingIntent(R.id.widgetBntRefresh, refreshPendingIntent);
|
|
||||||
//reset
|
|
||||||
Intent resetIntent = new Intent(context, SendRequestService.class);
|
|
||||||
resetIntent.putExtra("url", hostIP + "/?RESET=on");
|
|
||||||
resetIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
|
|
||||||
PendingIntent resetPendingIntent = PendingIntent.getService(context, appWidgetId+2, resetIntent, PendingIntent.FLAG_UPDATE_CURRENT);
|
|
||||||
rv.setOnClickPendingIntent(R.id.widgetBtnReset, resetPendingIntent);
|
|
||||||
//power
|
|
||||||
Intent powerIntent = new Intent(context, SendRequestService.class);
|
|
||||||
powerIntent.putExtra("url", hostIP + "/?POWER0=on");
|
|
||||||
powerIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
|
|
||||||
PendingIntent powerPendingIntent = PendingIntent.getService(context, appWidgetId+3, powerIntent, PendingIntent.FLAG_UPDATE_CURRENT);
|
|
||||||
rv.setOnClickPendingIntent(R.id.widgetBtnPwr, powerPendingIntent);
|
|
||||||
//power5
|
|
||||||
Intent power5Intent = new Intent(context, SendRequestService.class);
|
|
||||||
power5Intent.putExtra("url", hostIP + "/?POWER1=on");
|
|
||||||
power5Intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
|
|
||||||
PendingIntent power5PendingIntent = PendingIntent.getService(context, appWidgetId+4, power5Intent, PendingIntent.FLAG_UPDATE_CURRENT);
|
|
||||||
rv.setOnClickPendingIntent(R.id.widgetBtnPwr5, power5PendingIntent);
|
|
||||||
|
|
||||||
appWidgetManager.updateAppWidget(appWidgetId, rv);
|
|
||||||
|
|
||||||
context.startService(refreshIntent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
|
|
||||||
super.onUpdate(context, appWidgetManager, appWidgetIds);
|
|
||||||
|
|
||||||
setRequests(context, appWidgetManager, appWidgetIds);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onEnabled(Context context) {
|
|
||||||
super.onEnabled(context);
|
|
||||||
|
|
||||||
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
|
|
||||||
int[] appWidgetIds = appWidgetManager.getAppWidgetIds(new ComponentName(context, NoWolWidget.class));
|
|
||||||
|
|
||||||
setRequests(context, appWidgetManager, appWidgetIds);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onReceive(Context context, Intent intent) {
|
|
||||||
super.onReceive(context, intent);
|
|
||||||
|
|
||||||
onEnabled(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDeleted(Context context, int[] appWidgetIds) {
|
|
||||||
super.onDeleted(context, appWidgetIds);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDisabled(Context context) {
|
|
||||||
super.onDisabled(context);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,131 +0,0 @@
|
||||||
package com.blogspot.developersu.nowol.nowol.com.blogspot.developersu.nowol.nowol.widget;
|
|
||||||
|
|
||||||
import android.app.PendingIntent;
|
|
||||||
import android.appwidget.AppWidgetManager;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.graphics.Color;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.view.View;
|
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.RemoteViews;
|
|
||||||
import android.widget.SeekBar;
|
|
||||||
import android.widget.TextView;
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
|
||||||
import com.blogspot.developersu.nowol.nowol.R;
|
|
||||||
import com.blogspot.developersu.nowol.nowol.SendRequestService;
|
|
||||||
import com.google.android.material.switchmaterial.SwitchMaterial;
|
|
||||||
|
|
||||||
public class WidgetConfigurator extends AppCompatActivity {
|
|
||||||
|
|
||||||
private SeekBar opacityBar;
|
|
||||||
private SwitchMaterial bkgoundSwitch;
|
|
||||||
|
|
||||||
private void generateWidgetAndDie(int awID, Context context){
|
|
||||||
SharedPreferences.Editor settingsEditor;
|
|
||||||
|
|
||||||
RemoteViews rv = new RemoteViews(this.getPackageName(), R.layout.no_wol_widget);
|
|
||||||
AppWidgetManager awm = AppWidgetManager.getInstance(this);
|
|
||||||
|
|
||||||
// get shared preferences
|
|
||||||
SharedPreferences sharedSettings = context.getSharedPreferences("NoWolPreferences", Context.MODE_PRIVATE);
|
|
||||||
String hostIP = sharedSettings.getString("Host", context.getResources().getString(R.string.hostNameDefault));
|
|
||||||
// set setting editor to store background color set for all our widgets
|
|
||||||
settingsEditor = sharedSettings.edit();
|
|
||||||
|
|
||||||
// @TODO set pending intents linkage to buttons
|
|
||||||
Intent refreshIntent = new Intent(context, SendRequestService.class);
|
|
||||||
refreshIntent.putExtra("url", hostIP);
|
|
||||||
refreshIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, awID);
|
|
||||||
PendingIntent refreshPendingIntent = PendingIntent.getService(context, awID+1, refreshIntent, PendingIntent.FLAG_UPDATE_CURRENT);
|
|
||||||
rv.setOnClickPendingIntent(R.id.widgetBntRefresh, refreshPendingIntent);
|
|
||||||
//reset
|
|
||||||
Intent resetIntent = new Intent(context, SendRequestService.class);
|
|
||||||
resetIntent.putExtra("url", hostIP + "/?RESET=on");
|
|
||||||
resetIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, awID);
|
|
||||||
PendingIntent resetPendingIntent = PendingIntent.getService(context, awID+2, resetIntent, PendingIntent.FLAG_UPDATE_CURRENT);
|
|
||||||
rv.setOnClickPendingIntent(R.id.widgetBtnReset, resetPendingIntent);
|
|
||||||
//power
|
|
||||||
Intent powerIntent = new Intent(context, SendRequestService.class);
|
|
||||||
powerIntent.putExtra("url", hostIP + "/?POWER0=on");
|
|
||||||
powerIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, awID);
|
|
||||||
PendingIntent powerPendingIntent = PendingIntent.getService(context, awID+3, powerIntent, PendingIntent.FLAG_UPDATE_CURRENT);
|
|
||||||
rv.setOnClickPendingIntent(R.id.widgetBtnPwr, powerPendingIntent);
|
|
||||||
//power5
|
|
||||||
Intent power5Intent = new Intent(context, SendRequestService.class);
|
|
||||||
power5Intent.putExtra("url", hostIP + "/?POWER1=on");
|
|
||||||
power5Intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, awID);
|
|
||||||
PendingIntent power5PendingIntent = PendingIntent.getService(context, awID+4, power5Intent, PendingIntent.FLAG_UPDATE_CURRENT);
|
|
||||||
rv.setOnClickPendingIntent(R.id.widgetBtnPwr5, power5PendingIntent);
|
|
||||||
|
|
||||||
if (bkgoundSwitch.isChecked()){
|
|
||||||
rv.setInt(R.id.widgetBasicLayout, "setBackgroundColor", Color.argb(255-opacityBar.getProgress()*255/100, 0xff,0xff,0xff));
|
|
||||||
settingsEditor.putInt("WidgetBgColor", Color.argb(255-opacityBar.getProgress()*255/100, 0xff,0xff,0xff));
|
|
||||||
Log.d("qwerty1212", Integer.toString(Color.argb(255-opacityBar.getProgress()*255/100, 0xff,0xff,0xff)));
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
rv.setInt(R.id.widgetBasicLayout, "setBackgroundColor", Color.argb(255-opacityBar.getProgress()*255/100, 0x00,0x00,0x00));
|
|
||||||
settingsEditor.putInt("WidgetBgColor", Color.argb(255-opacityBar.getProgress()*255/100, 0x00,0x00,0x00));
|
|
||||||
Log.d("qwerty1212", Integer.toString(Color.argb(255-opacityBar.getProgress()*255/100, 0x00,0x00,0x00)));
|
|
||||||
}
|
|
||||||
settingsEditor.apply();
|
|
||||||
|
|
||||||
awm.updateAppWidget(awID,rv);
|
|
||||||
// Send intent to widget
|
|
||||||
Intent resultIntent = new Intent();
|
|
||||||
resultIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, awID);
|
|
||||||
setResult(RESULT_OK, resultIntent);
|
|
||||||
|
|
||||||
//send intent to service to request widget status
|
|
||||||
startService(refreshIntent);
|
|
||||||
|
|
||||||
finish();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
setContentView(R.layout.activity_widget_configurator);
|
|
||||||
|
|
||||||
Button submitBtn = findViewById(R.id.configBtnSubmit);
|
|
||||||
opacityBar = findViewById(R.id.configSeekBar);
|
|
||||||
bkgoundSwitch = findViewById(R.id.configSwitch);
|
|
||||||
final TextView opacityLbl = findViewById(R.id.configOpacityLbl);
|
|
||||||
|
|
||||||
// Prepare seekBar element
|
|
||||||
opacityLbl.setText(getString(R.string.confOpacity) + " " + opacityBar.getProgress()+"%");
|
|
||||||
opacityBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
|
|
||||||
@Override
|
|
||||||
public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
|
|
||||||
opacityLbl.setText(getString(R.string.confOpacity) + " " + i + "%");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onStartTrackingTouch(SeekBar seekBar) {}
|
|
||||||
@Override
|
|
||||||
public void onStopTrackingTouch(SeekBar seekBar) {}
|
|
||||||
});
|
|
||||||
bkgoundSwitch.setText(getString(R.string.confWhite));
|
|
||||||
|
|
||||||
// Cover widget intent
|
|
||||||
Intent initialConfIntent = getIntent();
|
|
||||||
Bundle initialConfIntentBundle = initialConfIntent.getExtras();
|
|
||||||
|
|
||||||
// Set logic
|
|
||||||
if (initialConfIntentBundle != null){
|
|
||||||
final int awID = initialConfIntentBundle.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
|
|
||||||
|
|
||||||
submitBtn.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
//Log.d("qwerty1212", Integer.toString(opacityBar.getProgress()*255/100));
|
|
||||||
generateWidgetAndDie(awID, getApplicationContext());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
} else
|
|
||||||
finish();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,58 +0,0 @@
|
||||||
package com.blogspot.developersu.nowol.nowol;
|
|
||||||
|
|
||||||
import android.app.Dialog;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.view.Window;
|
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.EditText;
|
|
||||||
import androidx.fragment.app.DialogFragment;
|
|
||||||
|
|
||||||
public class popUp extends DialogFragment {
|
|
||||||
|
|
||||||
private EditText hostName;
|
|
||||||
private Button submit;
|
|
||||||
|
|
||||||
public interface pupUpRetuningValueListener{
|
|
||||||
void onFinishEdit(String hostNameReSet);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static popUp newInstance(CharSequence ipRecieved){
|
|
||||||
popUp f = new popUp();
|
|
||||||
Bundle myBundle = new Bundle();
|
|
||||||
myBundle.putCharSequence("ipRec", ipRecieved);
|
|
||||||
f.setArguments(myBundle);
|
|
||||||
return f;
|
|
||||||
}
|
|
||||||
|
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
|
||||||
//getDialog().setTitle(R.string.hostChBntMain);
|
|
||||||
|
|
||||||
View v = inflater.inflate(R.layout.popup, container, false);
|
|
||||||
submit = (Button) v.findViewById(R.id.popupHostBtn);
|
|
||||||
hostName = (EditText) v.findViewById(R.id.popUpHostText);
|
|
||||||
|
|
||||||
|
|
||||||
hostName.setText(getArguments().getCharSequence("ipRec"));
|
|
||||||
|
|
||||||
submit.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
pupUpRetuningValueListener retLs = (pupUpRetuningValueListener)getActivity();
|
|
||||||
retLs.onFinishEdit(hostName.getText().toString());
|
|
||||||
dismiss();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return v;
|
|
||||||
}
|
|
||||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
|
||||||
Dialog dialog = super.onCreateDialog(savedInstanceState);
|
|
||||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
|
||||||
return dialog;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -0,0 +1,101 @@
|
||||||
|
/*
|
||||||
|
Copyright 2017-2020 Dmitry Isaenko
|
||||||
|
|
||||||
|
This file is part of NoWOL.
|
||||||
|
|
||||||
|
NoWOL 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.
|
||||||
|
|
||||||
|
NoWOL 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 NoWOL. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package com.blogspot.developersu.nowol.widget;
|
||||||
|
|
||||||
|
import android.app.PendingIntent;
|
||||||
|
import android.appwidget.AppWidgetManager;
|
||||||
|
import android.appwidget.AppWidgetProvider;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.widget.RemoteViews;
|
||||||
|
|
||||||
|
import com.blogspot.developersu.nowol.R;
|
||||||
|
import com.blogspot.developersu.nowol.SendRequestService;
|
||||||
|
|
||||||
|
|
||||||
|
public class NoWolWidget extends AppWidgetProvider {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
|
||||||
|
for (int appWidgetId : appWidgetIds) {
|
||||||
|
updateAppWidget(context, appWidgetManager, appWidgetId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
if (intent.hasExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS)){
|
||||||
|
int[] widgetIDs = intent.getExtras().getIntArray(AppWidgetManager.EXTRA_APPWIDGET_IDS);
|
||||||
|
for (int widgetID : widgetIDs){
|
||||||
|
updateAppWidget(context, AppWidgetManager.getInstance(context), widgetID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
super.onReceive(context, intent);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEnabled(Context context) {
|
||||||
|
super.onEnabled(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDeleted(Context context, int[] appWidgetIds) {
|
||||||
|
for (int appWidgetId : appWidgetIds) {
|
||||||
|
WidgetConfigurator.deleteBgColorPref(context, appWidgetId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void updateAppWidget(Context context, AppWidgetManager appWidgetManager,
|
||||||
|
int appWidgetId) {
|
||||||
|
int widgetBgColor = WidgetConfigurator.loadBgColorPref(context, appWidgetId);
|
||||||
|
RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.no_wol_widget);
|
||||||
|
|
||||||
|
remoteViews.setInt(R.id.widgetBodyLayout, "setBackgroundColor", widgetBgColor);
|
||||||
|
//
|
||||||
|
SharedPreferences sharedSettings = context.getSharedPreferences("NoWolPreferences", Context.MODE_PRIVATE);
|
||||||
|
String hostIP = sharedSettings.getString("Host", context.getResources().getString(R.string.hostNameDefault));
|
||||||
|
|
||||||
|
remoteViews.setOnClickPendingIntent(R.id.widgetBntRefresh,
|
||||||
|
createPendingIntent(context, appWidgetId, hostIP, appWidgetId+1)); // Refresh
|
||||||
|
remoteViews.setOnClickPendingIntent(R.id.widgetBtnReset,
|
||||||
|
createPendingIntent(context, appWidgetId, hostIP + "/?RESET=on", appWidgetId+2));
|
||||||
|
remoteViews.setOnClickPendingIntent(R.id.widgetBtnPwr,
|
||||||
|
createPendingIntent(context, appWidgetId, hostIP + "/?POWER0=on", appWidgetId+3));
|
||||||
|
remoteViews.setOnClickPendingIntent(R.id.widgetBtnPwr5,
|
||||||
|
createPendingIntent(context, appWidgetId, hostIP + "/?POWER1=on", appWidgetId+4));
|
||||||
|
|
||||||
|
appWidgetManager.updateAppWidget(appWidgetId, remoteViews);
|
||||||
|
// Ping serv TODO: FIX
|
||||||
|
Intent refreshIntent = new Intent(context, SendRequestService.class);
|
||||||
|
refreshIntent.putExtra("url", hostIP);
|
||||||
|
refreshIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
|
||||||
|
context.startService(refreshIntent);
|
||||||
|
// Instruct the widget manager to update the widget
|
||||||
|
appWidgetManager.updateAppWidget(appWidgetId, remoteViews);
|
||||||
|
}
|
||||||
|
private static PendingIntent createPendingIntent(Context context, int widgetId, String linkAddress, int code){
|
||||||
|
Intent intent = new Intent(context, SendRequestService.class);
|
||||||
|
intent.putExtra("url", linkAddress);
|
||||||
|
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, widgetId);
|
||||||
|
return PendingIntent.getService(context, code, intent, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,140 @@
|
||||||
|
/*
|
||||||
|
Copyright 2017-2020 Dmitry Isaenko
|
||||||
|
|
||||||
|
This file is part of NoWOL.
|
||||||
|
|
||||||
|
NoWOL 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.
|
||||||
|
|
||||||
|
NoWOL 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 NoWOL. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package com.blogspot.developersu.nowol.widget;
|
||||||
|
|
||||||
|
import android.app.PendingIntent;
|
||||||
|
import android.appwidget.AppWidgetManager;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.RemoteViews;
|
||||||
|
import android.widget.SeekBar;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import com.blogspot.developersu.nowol.R;
|
||||||
|
import com.blogspot.developersu.nowol.SendRequestService;
|
||||||
|
import com.google.android.material.switchmaterial.SwitchMaterial;
|
||||||
|
|
||||||
|
public class WidgetConfigurator extends AppCompatActivity {
|
||||||
|
|
||||||
|
private SeekBar opacityBar;
|
||||||
|
private SwitchMaterial bgColorSwitch;
|
||||||
|
private Context context;
|
||||||
|
|
||||||
|
private int appWidgetId = AppWidgetManager.INVALID_APPWIDGET_ID;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
setResult(RESULT_CANCELED);
|
||||||
|
|
||||||
|
setContentView(R.layout.activity_widget_configurator);
|
||||||
|
|
||||||
|
Button submitBtn = findViewById(R.id.configBtnSubmit);
|
||||||
|
opacityBar = findViewById(R.id.configSeekBar);
|
||||||
|
bgColorSwitch = findViewById(R.id.configSwitch);
|
||||||
|
final TextView opacityLbl = findViewById(R.id.configOpacityLbl);
|
||||||
|
opacityLbl.setText(getString(R.string.confOpacity, 0));
|
||||||
|
opacityBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
|
||||||
|
opacityLbl.setText(getString(R.string.confOpacity, i));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStartTrackingTouch(SeekBar seekBar) {}
|
||||||
|
@Override
|
||||||
|
public void onStopTrackingTouch(SeekBar seekBar) {}
|
||||||
|
});
|
||||||
|
|
||||||
|
this.context = getApplicationContext();
|
||||||
|
|
||||||
|
// Cover widget intent
|
||||||
|
Intent initialConfIntent = getIntent();
|
||||||
|
Bundle initialConfBundle = initialConfIntent.getExtras();
|
||||||
|
|
||||||
|
if (initialConfBundle != null) {
|
||||||
|
appWidgetId = initialConfBundle.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID,
|
||||||
|
AppWidgetManager.INVALID_APPWIDGET_ID);
|
||||||
|
}
|
||||||
|
if (appWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID) {
|
||||||
|
finish();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
submitBtn.setOnClickListener(view -> createWidget());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createWidget(){
|
||||||
|
RemoteViews remoteViews = new RemoteViews(this.getPackageName(), R.layout.no_wol_widget);
|
||||||
|
|
||||||
|
SharedPreferences sharedSettings = context.getSharedPreferences("NoWolPreferences", Context.MODE_PRIVATE);
|
||||||
|
String hostIP = sharedSettings.getString("Host", context.getResources().getString(R.string.hostNameDefault));
|
||||||
|
|
||||||
|
SharedPreferences.Editor settingsEditor = sharedSettings.edit();
|
||||||
|
|
||||||
|
remoteViews.setOnClickPendingIntent(R.id.widgetBntRefresh,
|
||||||
|
createPendingIntent(hostIP, appWidgetId+1)); // Refresh
|
||||||
|
remoteViews.setOnClickPendingIntent(R.id.widgetBtnReset,
|
||||||
|
createPendingIntent(hostIP + "/?RESET=on", appWidgetId+2));
|
||||||
|
remoteViews.setOnClickPendingIntent(R.id.widgetBtnPwr,
|
||||||
|
createPendingIntent(hostIP + "/?POWER0=on", appWidgetId+3));
|
||||||
|
remoteViews.setOnClickPendingIntent(R.id.widgetBtnPwr5,
|
||||||
|
createPendingIntent(hostIP + "/?POWER1=on", appWidgetId+4));
|
||||||
|
int bgColor = getBackgoundColor();
|
||||||
|
remoteViews.setInt(R.id.widgetBodyLayout, "setBackgroundColor", bgColor);
|
||||||
|
settingsEditor.putInt("WidgetBgColor" + appWidgetId, bgColor).apply();
|
||||||
|
|
||||||
|
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(this);
|
||||||
|
appWidgetManager.updateAppWidget(appWidgetId, remoteViews);
|
||||||
|
// Send intent to widget
|
||||||
|
Intent resultIntent = new Intent();
|
||||||
|
resultIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
|
||||||
|
setResult(RESULT_OK, resultIntent);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
private PendingIntent createPendingIntent(String linkAddress, int code){
|
||||||
|
Intent intent = new Intent(context, SendRequestService.class);
|
||||||
|
intent.putExtra("url", linkAddress);
|
||||||
|
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
|
||||||
|
return PendingIntent.getService(context, code, intent, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||||
|
}
|
||||||
|
private int getBackgoundColor(){
|
||||||
|
if (bgColorSwitch.isChecked())
|
||||||
|
return Color.argb(255-opacityBar.getProgress()*255/100, 0xff,0xff,0xff);
|
||||||
|
else
|
||||||
|
return Color.argb(255-opacityBar.getProgress()*255/100, 0x00,0x00,0x00);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int loadBgColorPref(Context context, int appWidgetId) {
|
||||||
|
SharedPreferences prefs = context.getSharedPreferences("NoWolPreferences", Context.MODE_PRIVATE);
|
||||||
|
return prefs.getInt("WidgetBgColor" + appWidgetId, Color.argb(255, 0x00,0x00,0x00));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void deleteBgColorPref(Context context, int appWidgetId) {
|
||||||
|
SharedPreferences.Editor prefs = context.getSharedPreferences("NoWolPreferences", Context.MODE_PRIVATE).edit();
|
||||||
|
prefs.remove("WidgetBgColor" + appWidgetId);
|
||||||
|
prefs.apply();
|
||||||
|
}
|
||||||
|
}
|
Before Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 20 KiB |
BIN
app/src/main/res/drawable-anydpi-v21/ic_launcher.png
Normal file
After Width: | Height: | Size: 4.9 KiB |
5
app/src/main/res/drawable-anydpi-v21/w_power.xml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
<vector android:height="48dp" android:tint="#FFFFFF"
|
||||||
|
android:viewportHeight="24" android:viewportWidth="24"
|
||||||
|
android:width="48dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<path android:fillColor="@android:color/white" android:pathData="M13,3h-2v10h2L13,3zM17.83,5.17l-1.42,1.42C17.99,7.86 19,9.81 19,12c0,3.87 -3.13,7 -7,7s-7,-3.13 -7,-7c0,-2.19 1.01,-4.14 2.58,-5.42L6.17,5.17C4.23,6.82 3,9.26 3,12c0,4.97 4.03,9 9,9s9,-4.03 9,-9c0,-2.74 -1.23,-5.18 -3.17,-6.83z"/>
|
||||||
|
</vector>
|
4
app/src/main/res/drawable-anydpi-v21/w_power5.xml
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
<vector android:height="48dp" android:viewportHeight="24"
|
||||||
|
android:viewportWidth="24" android:width="48dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<path android:fillColor="@android:color/white" android:pathData="m11,3v3.5898h2L13,3ZM6.1699,5.1699c-3.79,3.22 -4.2493,8.8995 -1.0293,12.6895 3.22,3.78 8.8995,4.2415 12.6895,1.0215C19.8501,17.1709 21,14.65 21,12 21,9.37 19.8401,6.8699 17.8301,5.1699L16.4102,6.5898C18.0502,7.9098 19,9.9 19,12a7,7 0,0 1,-7 7C8.14,19 5,15.88 5,12 5,9.91 5.9501,7.9101 7.5801,6.5801ZM9.7039,7.4786h4.6758v1.0514h-3.5378v2.2699q0.266,-0.099 0.5319,-0.1423 0.2721,-0.0495 0.5443,-0.0495 1.4349,0 2.276,0.8473 0.8411,0.8473 0.8411,2.2946 0,1.4596 -0.8844,2.3008 -0.8783,0.8411 -2.4059,0.8411 -0.736,0 -1.3483,-0.099 -0.6061,-0.099 -1.0885,-0.2969L9.3081,15.2283q0.569,0.3092 1.1442,0.4639 0.5752,0.1484 1.1751,0.1484 1.0329,0 1.5895,-0.5443 0.5628,-0.5443 0.5628,-1.5462 0,-0.9896 -0.5814,-1.54 -0.5752,-0.5505 -1.6081,-0.5505 -0.501,0 -0.9772,0.1175 -0.4762,0.1113 -0.9092,0.3402z"/>
|
||||||
|
</vector>
|
4
app/src/main/res/drawable-anydpi-v21/w_power5_press.xml
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
<vector android:height="48dp" android:viewportHeight="24"
|
||||||
|
android:viewportWidth="24" android:width="48dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<path android:fillColor="@android:color/holo_green_dark" android:pathData="m11,3v3.5898h2L13,3ZM6.1699,5.1699c-3.79,3.22 -4.2493,8.8995 -1.0293,12.6895 3.22,3.78 8.8995,4.2415 12.6895,1.0215C19.8501,17.1709 21,14.65 21,12 21,9.37 19.8401,6.8699 17.8301,5.1699L16.4102,6.5898C18.0502,7.9098 19,9.9 19,12a7,7 0,0 1,-7 7C8.14,19 5,15.88 5,12 5,9.91 5.9501,7.9101 7.5801,6.5801ZM9.7039,7.4786h4.6758v1.0514h-3.5378v2.2699q0.266,-0.099 0.5319,-0.1423 0.2721,-0.0495 0.5443,-0.0495 1.4349,0 2.276,0.8473 0.8411,0.8473 0.8411,2.2946 0,1.4596 -0.8844,2.3008 -0.8783,0.8411 -2.4059,0.8411 -0.736,0 -1.3483,-0.099 -0.6061,-0.099 -1.0885,-0.2969L9.3081,15.2283q0.569,0.3092 1.1442,0.4639 0.5752,0.1484 1.1751,0.1484 1.0329,0 1.5895,-0.5443 0.5628,-0.5443 0.5628,-1.5462 0,-0.9896 -0.5814,-1.54 -0.5752,-0.5505 -1.6081,-0.5505 -0.501,0 -0.9772,0.1175 -0.4762,0.1113 -0.9092,0.3402z"/>
|
||||||
|
</vector>
|
5
app/src/main/res/drawable-anydpi-v21/w_power_press.xml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
<vector android:height="48dp"
|
||||||
|
android:viewportHeight="24" android:viewportWidth="24"
|
||||||
|
android:width="48dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<path android:fillColor="@android:color/holo_green_dark" android:pathData="M13,3h-2v10h2L13,3zM17.83,5.17l-1.42,1.42C17.99,7.86 19,9.81 19,12c0,3.87 -3.13,7 -7,7s-7,-3.13 -7,-7c0,-2.19 1.01,-4.14 2.58,-5.42L6.17,5.17C4.23,6.82 3,9.26 3,12c0,4.97 4.03,9 9,9s9,-4.03 9,-9c0,-2.74 -1.23,-5.18 -3.17,-6.83z"/>
|
||||||
|
</vector>
|
5
app/src/main/res/drawable-anydpi-v21/w_refresh.xml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
<vector android:height="14dp" android:viewportHeight="1000"
|
||||||
|
android:viewportWidth="1000" android:width="14dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<path android:fillColor="@android:color/white" android:pathData="M174,535.4c-23.5,-147 57.2,-295.5 201.4,-351.7c106.8,-41.7 222,-21.7 303.6,37.8L609.6,334l311.3,-1.2L809.6,10l-57,92.3C632.4,24.5 468.6,-1 325.1,54.9C126.4,132.4 12,332.8 34.5,535.4H174L174,535.4z"/>
|
||||||
|
<path android:fillColor="@android:color/white" android:pathData="M826.1,455c23.5,147 -57.2,295.5 -201.4,351.7c-98.3,38.3 -206.6,23.9 -289.9,-27.8c15.9,-25.7 62.7,-101.6 62.7,-101.6L62.8,657.6L204.5,990l59.4,-96.2c120.2,77.8 267.6,97.6 411,41.7C873.6,858 988,657.6 965.5,455L826.1,455L826.1,455z"/>
|
||||||
|
</vector>
|
5
app/src/main/res/drawable-anydpi-v21/w_refresh_press.xml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
<vector android:height="14dp" android:viewportHeight="1000"
|
||||||
|
android:viewportWidth="1000" android:width="14dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<path android:fillColor="@android:color/black" android:pathData="M174,535.4c-23.5,-147 57.2,-295.5 201.4,-351.7c106.8,-41.7 222,-21.7 303.6,37.8L609.6,334l311.3,-1.2L809.6,10l-57,92.3C632.4,24.5 468.6,-1 325.1,54.9C126.4,132.4 12,332.8 34.5,535.4H174L174,535.4z"/>
|
||||||
|
<path android:fillColor="@android:color/black" android:pathData="M826.1,455c23.5,147 -57.2,295.5 -201.4,351.7c-98.3,38.3 -206.6,23.9 -289.9,-27.8c15.9,-25.7 62.7,-101.6 62.7,-101.6L62.8,657.6L204.5,990l59.4,-96.2c120.2,77.8 267.6,97.6 411,41.7C873.6,858 988,657.6 965.5,455L826.1,455L826.1,455z"/>
|
||||||
|
</vector>
|
5
app/src/main/res/drawable-anydpi-v21/w_reset.xml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
<vector android:height="48dp" android:tint="#FFFFFF"
|
||||||
|
android:viewportHeight="24" android:viewportWidth="24"
|
||||||
|
android:width="48dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<path android:fillColor="@android:color/white" android:pathData="M17.65,6.35C16.2,4.9 14.21,4 12,4c-4.42,0 -7.99,3.58 -7.99,8s3.57,8 7.99,8c3.73,0 6.84,-2.55 7.73,-6h-2.08c-0.82,2.33 -3.04,4 -5.65,4 -3.31,0 -6,-2.69 -6,-6s2.69,-6 6,-6c1.66,0 3.14,0.69 4.22,1.78L13,11h7V4l-2.35,2.35z"/>
|
||||||
|
</vector>
|
5
app/src/main/res/drawable-anydpi-v21/w_reset_press.xml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
<vector android:height="48dp"
|
||||||
|
android:viewportHeight="24" android:viewportWidth="24"
|
||||||
|
android:width="48dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<path android:fillColor="@android:color/holo_green_dark" android:pathData="M17.65,6.35C16.2,4.9 14.21,4 12,4c-4.42,0 -7.99,3.58 -7.99,8s3.57,8 7.99,8c3.73,0 6.84,-2.55 7.73,-6h-2.08c-0.82,2.33 -3.04,4 -5.65,4 -3.31,0 -6,-2.69 -6,-6s2.69,-6 6,-6c1.66,0 3.14,0.69 4.22,1.78L13,11h7V4l-2.35,2.35z"/>
|
||||||
|
</vector>
|
|
@ -1,4 +0,0 @@
|
||||||
[Dolphin]
|
|
||||||
PreviewsShown=true
|
|
||||||
Timestamp=2017,8,6,16,39,33
|
|
||||||
Version=3
|
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.3 KiB |
Before Width: | Height: | Size: 5.6 KiB After Width: | Height: | Size: 5.6 KiB |
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 4.6 KiB |
Before Width: | Height: | Size: 965 B After Width: | Height: | Size: 965 B |
Before Width: | Height: | Size: 821 B After Width: | Height: | Size: 821 B |
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
Before Width: | Height: | Size: 4.5 KiB After Width: | Height: | Size: 4.5 KiB |
|
@ -1,4 +0,0 @@
|
||||||
[Dolphin]
|
|
||||||
PreviewsShown=true
|
|
||||||
Timestamp=2017,8,6,16,39,9
|
|
||||||
Version=3
|
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 3.5 KiB |
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 657 B After Width: | Height: | Size: 657 B |
Before Width: | Height: | Size: 583 B After Width: | Height: | Size: 583 B |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 34 KiB |
|
@ -1,4 +0,0 @@
|
||||||
[Dolphin]
|
|
||||||
PreviewsShown=true
|
|
||||||
Timestamp=2017,8,6,16,37,31
|
|
||||||
Version=3
|
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.2 KiB |
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
Before Width: | Height: | Size: 7.2 KiB After Width: | Height: | Size: 7.2 KiB |
Before Width: | Height: | Size: 5.9 KiB After Width: | Height: | Size: 5.9 KiB |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 940 B After Width: | Height: | Size: 940 B |
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.2 KiB |
Before Width: | Height: | Size: 5.7 KiB After Width: | Height: | Size: 5.7 KiB |
|
@ -1,4 +0,0 @@
|
||||||
[Dolphin]
|
|
||||||
PreviewsShown=true
|
|
||||||
Timestamp=2017,8,6,16,36,41
|
|
||||||
Version=3
|
|
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 3.4 KiB |
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 4.2 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 9.2 KiB After Width: | Height: | Size: 9.2 KiB |
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 3.4 KiB |
Before Width: | Height: | Size: 8.9 KiB After Width: | Height: | Size: 8.9 KiB |
|
@ -1,4 +0,0 @@
|
||||||
[Dolphin]
|
|
||||||
PreviewsShown=true
|
|
||||||
Timestamp=2017,8,6,15,33,9
|
|
||||||
Version=3
|
|
Before Width: | Height: | Size: 4 KiB After Width: | Height: | Size: 4 KiB |
Before Width: | Height: | Size: 4.9 KiB After Width: | Height: | Size: 4.9 KiB |
Before Width: | Height: | Size: 7.9 KiB After Width: | Height: | Size: 7.9 KiB |
Before Width: | Height: | Size: 6.6 KiB After Width: | Height: | Size: 6.6 KiB |
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 3.9 KiB |
Before Width: | Height: | Size: 6.5 KiB After Width: | Height: | Size: 6.5 KiB |
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<item android:state_pressed="true"
|
<item android:state_pressed="true"
|
||||||
android:drawable="@drawable/pwr5_widget_pressed"/> <!-- pressed -->
|
android:drawable="@drawable/w_power5_press"/> <!-- pressed -->
|
||||||
<item android:drawable="@drawable/pwr5_widget_normal" /> <!-- default -->
|
<item android:drawable="@drawable/w_power5" /> <!-- default -->
|
||||||
|
|
||||||
</selector>
|
</selector>
|
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<item android:state_pressed="true"
|
<item android:state_pressed="true"
|
||||||
android:drawable="@drawable/pwr_widget_pressed"/> <!-- pressed -->
|
android:drawable="@drawable/w_power_press"/> <!-- pressed -->
|
||||||
<item android:drawable="@drawable/pwr_widget_normal" /> <!-- default -->
|
<item android:drawable="@drawable/w_power" /> <!-- default -->
|
||||||
|
|
||||||
</selector>
|
</selector>
|
|
@ -1,8 +1,6 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<!-- pressed -->
|
<item android:state_pressed="true"
|
||||||
<!-- default -->
|
android:drawable="@drawable/w_refresh_press" />
|
||||||
|
<item android:drawable="@drawable/w_refresh" />
|
||||||
<item android:state_pressed="true" android:drawable="@drawable/refresh_widget_pressed" />
|
|
||||||
<item android:drawable="@drawable/refresh_widget" />
|
|
||||||
</selector>
|
</selector>
|
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<item android:state_pressed="true"
|
<item android:state_pressed="true"
|
||||||
android:drawable="@drawable/rst_widget_pressed"/> <!-- pressed -->
|
android:drawable="@drawable/w_reset_press"/> <!-- pressed -->
|
||||||
<item android:drawable="@drawable/rst_widget_normal" /> <!-- default -->
|
<item android:drawable="@drawable/w_reset" /> <!-- default -->
|
||||||
|
|
||||||
</selector>
|
</selector>
|
|
@ -10,6 +10,7 @@
|
||||||
>
|
>
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
|
android:id="@+id/relativeLayout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
@ -18,18 +19,18 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="?attr/actionBarSize"
|
android:layout_height="?attr/actionBarSize"
|
||||||
android:background="?attr/colorPrimary"
|
android:background="?attr/colorPrimary"
|
||||||
app:elevation="4dp"
|
|
||||||
android:minHeight="?attr/actionBarSize"
|
android:minHeight="?attr/actionBarSize"
|
||||||
android:theme="?attr/actionBarTheme"
|
android:theme="?attr/actionBarTheme"
|
||||||
|
app:elevation="4dp"
|
||||||
app:titleTextColor="@android:color/background_light" />
|
app:titleTextColor="@android:color/background_light" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/textView"
|
android:id="@+id/textView"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignLeft="@+id/hostLblMain"
|
|
||||||
android:layout_alignStart="@+id/hostLblMain"
|
|
||||||
android:layout_below="@+id/hostLblMain"
|
android:layout_below="@+id/hostLblMain"
|
||||||
|
android:layout_alignStart="@+id/hostLblMain"
|
||||||
|
android:layout_alignLeft="@+id/hostLblMain"
|
||||||
android:layout_marginTop="13dp"
|
android:layout_marginTop="13dp"
|
||||||
android:text="@string/statusLabelMain"
|
android:text="@string/statusLabelMain"
|
||||||
android:textColor="@android:color/black"
|
android:textColor="@android:color/black"
|
||||||
|
@ -45,44 +46,44 @@
|
||||||
android:layout_alignBottom="@+id/pwr5BntMainAct"
|
android:layout_alignBottom="@+id/pwr5BntMainAct"
|
||||||
android:layout_alignParentEnd="true"
|
android:layout_alignParentEnd="true"
|
||||||
android:layout_alignParentRight="true"
|
android:layout_alignParentRight="true"
|
||||||
|
android:layout_marginEnd="10dp"
|
||||||
android:layout_marginRight="10dp"
|
android:layout_marginRight="10dp"
|
||||||
|
android:layout_toEndOf="@+id/pwr5BntMainAct"
|
||||||
|
android:layout_toRightOf="@+id/pwr5BntMainAct"
|
||||||
android:height="110dp"
|
android:height="110dp"
|
||||||
android:text="@string/powerBntMain"
|
android:text="@string/powerBntMain"
|
||||||
android:drawableTop="@drawable/pwr_widget_button"
|
app:drawableTopCompat="@drawable/w_power"
|
||||||
tools:layout_editor_absoluteX="16dp"
|
tools:layout_editor_absoluteX="16dp"
|
||||||
tools:layout_editor_absoluteY="98dp"
|
tools:layout_editor_absoluteY="98dp" />
|
||||||
android:layout_toRightOf="@+id/pwr5BntMainAct"
|
|
||||||
android:layout_toEndOf="@+id/pwr5BntMainAct"
|
|
||||||
android:layout_marginEnd="10dp" />
|
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/resBntMainAct"
|
android:id="@+id/resBntMainAct"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentLeft="true"
|
|
||||||
android:layout_alignParentStart="true"
|
|
||||||
android:layout_below="@+id/textView"
|
android:layout_below="@+id/textView"
|
||||||
android:layout_marginTop="19dp"
|
android:layout_alignParentStart="true"
|
||||||
|
android:layout_alignParentLeft="true"
|
||||||
|
android:layout_marginStart="10dp"
|
||||||
android:layout_marginLeft="10dp"
|
android:layout_marginLeft="10dp"
|
||||||
android:layout_toLeftOf="@+id/pwr5BntMainAct"
|
android:layout_marginTop="19dp"
|
||||||
android:layout_toStartOf="@+id/pwr5BntMainAct"
|
android:layout_toStartOf="@+id/pwr5BntMainAct"
|
||||||
|
android:layout_toLeftOf="@+id/pwr5BntMainAct"
|
||||||
android:height="110dp"
|
android:height="110dp"
|
||||||
android:text="@string/resetBtnMain"
|
android:text="@string/resetBtnMain"
|
||||||
android:drawableTop="@drawable/reset_widget_button"
|
app:drawableTopCompat="@drawable/w_reset"
|
||||||
tools:layout_editor_absoluteX="148dp"
|
tools:layout_editor_absoluteX="148dp"
|
||||||
tools:layout_editor_absoluteY="98dp"
|
tools:layout_editor_absoluteY="98dp" />
|
||||||
android:layout_marginStart="10dp" />
|
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/pwr5BntMainAct"
|
android:id="@+id/pwr5BntMainAct"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignBottom="@+id/resBntMainAct"
|
|
||||||
android:layout_alignTop="@+id/resBntMainAct"
|
android:layout_alignTop="@+id/resBntMainAct"
|
||||||
|
android:layout_alignBottom="@+id/resBntMainAct"
|
||||||
android:layout_centerHorizontal="true"
|
android:layout_centerHorizontal="true"
|
||||||
android:height="110dp"
|
android:height="110dp"
|
||||||
android:text="@string/pwr5BntMain"
|
android:text="@string/pwr5BntMain"
|
||||||
android:drawableTop="@drawable/pwr5_widget_button"
|
app:drawableTopCompat="@drawable/w_power5"
|
||||||
tools:layout_editor_absoluteX="259dp"
|
tools:layout_editor_absoluteX="259dp"
|
||||||
tools:layout_editor_absoluteY="98dp" />
|
tools:layout_editor_absoluteY="98dp" />
|
||||||
|
|
||||||
|
@ -104,17 +105,17 @@
|
||||||
android:id="@+id/hostLblMain"
|
android:id="@+id/hostLblMain"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="15dp"
|
android:layout_below="@+id/toolbar"
|
||||||
|
android:layout_alignParentStart="true"
|
||||||
|
android:layout_alignParentLeft="true"
|
||||||
android:layout_marginStart="15dp"
|
android:layout_marginStart="15dp"
|
||||||
|
android:layout_marginLeft="15dp"
|
||||||
|
android:layout_marginTop="12dp"
|
||||||
android:text="@string/hostLblMain"
|
android:text="@string/hostLblMain"
|
||||||
android:textColor="@android:color/black"
|
android:textColor="@android:color/black"
|
||||||
android:textSize="18sp"
|
android:textSize="18sp"
|
||||||
tools:layout_editor_absoluteX="16dp"
|
tools:layout_editor_absoluteX="16dp"
|
||||||
tools:layout_editor_absoluteY="16dp"
|
tools:layout_editor_absoluteY="16dp" />
|
||||||
android:layout_below="@+id/toolbar"
|
|
||||||
android:layout_alignParentLeft="true"
|
|
||||||
android:layout_alignParentStart="true"
|
|
||||||
android:layout_marginTop="12dp" />
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/hostNameStaticMain"
|
android:id="@+id/hostNameStaticMain"
|
||||||
|
@ -126,6 +127,7 @@
|
||||||
android:layout_toRightOf="@+id/hostLblMain"
|
android:layout_toRightOf="@+id/hostLblMain"
|
||||||
android:textColor="@android:color/black"
|
android:textColor="@android:color/black"
|
||||||
android:textSize="18sp" />
|
android:textSize="18sp" />
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
|
@ -1,11 +1,13 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="10dp"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:padding="@dimen/widget_margin"
|
android:padding="@dimen/widget_margin"
|
||||||
tools:context="com.blogspot.developersu.nowol.nowol.com.blogspot.developersu.nowol.nowol.widget.WidgetConfigurator">
|
tools:context="com.blogspot.developersu.nowol.widget.WidgetConfigurator">
|
||||||
|
|
||||||
<Space
|
<Space
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
|
@ -1,16 +1,14 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<RelativeLayout
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:id="@+id/widgetBasicLayout"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="@android:color/black"
|
android:padding="@dimen/widget_margin">
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/widgetHeaderLayout"
|
android:id="@+id/widgetHeaderLayout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="@color/colorPrimary"
|
android:background="@color/colorOrange"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:paddingLeft="@dimen/widget_margin"
|
android:paddingLeft="@dimen/widget_margin"
|
||||||
android:paddingRight="@dimen/widget_margin"
|
android:paddingRight="@dimen/widget_margin"
|
||||||
|
@ -20,45 +18,74 @@
|
||||||
android:id="@+id/widgetStatusText"
|
android:id="@+id/widgetStatusText"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="2dp"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:shadowColor="@android:color/black"
|
android:shadowColor="@android:color/black"
|
||||||
android:shadowDx="2"
|
android:shadowDx="2"
|
||||||
android:shadowDy="2"
|
android:shadowDy="2"
|
||||||
android:shadowRadius="2"
|
android:shadowRadius="2"
|
||||||
android:text="@string/statusTxtMain"
|
android:text="@string/statusTxtMain"
|
||||||
android:textColor="@android:color/background_light" />
|
android:textColor="@android:color/background_light"
|
||||||
|
android:layout_marginStart="2dp" />
|
||||||
|
|
||||||
<ImageButton
|
<ImageButton
|
||||||
android:id="@+id/widgetBntRefresh"
|
android:id="@+id/widgetBntRefresh"
|
||||||
|
style="@android:style/Widget.Holo.ImageButton"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="1dp"
|
||||||
|
android:layout_marginTop="1dp"
|
||||||
|
android:layout_marginRight="2dp"
|
||||||
|
android:layout_marginBottom="1dp"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:background="@android:color/transparent"
|
android:background="@android:color/transparent"
|
||||||
android:contentDescription="@string/refreshBnt"
|
android:contentDescription="@string/refreshBnt"
|
||||||
android:padding="0dp"
|
android:padding="0dp"
|
||||||
android:scaleType="fitEnd"
|
android:scaleType="fitEnd"
|
||||||
android:src="@drawable/refresh_widget_button" />
|
android:src="@drawable/refresh_widget_button"
|
||||||
|
android:layout_marginStart="1dp"
|
||||||
|
android:layout_marginEnd="2dp" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
android:id="@+id/widgetBodyLayout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal"
|
android:layout_below="@+id/widgetHeaderLayout"
|
||||||
android:padding="@dimen/widget_margin">
|
android:layout_alignParentBottom="true"
|
||||||
|
android:layout_marginTop="0dp"
|
||||||
|
android:layout_marginBottom="0dp"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<ImageButton
|
<ImageButton
|
||||||
android:id="@+id/widgetBtnReset"
|
android:id="@+id/widgetBtnReset"
|
||||||
|
style="@android:style/Widget.Holo.ImageButton"
|
||||||
|
android:src="@drawable/reset_widget_button"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:background="@android:color/transparent"
|
|
||||||
android:contentDescription="@string/resetBtnMain"
|
android:contentDescription="@string/resetBtnMain"
|
||||||
android:padding="0dp"
|
android:background="@android:color/transparent"
|
||||||
android:src="@drawable/reset_widget_button" />
|
android:padding="0dp" />
|
||||||
|
|
||||||
<ImageButton
|
<ImageButton
|
||||||
android:id="@+id/widgetBtnPwr5"
|
android:id="@+id/widgetBtnPwr5"
|
||||||
|
style="@android:style/Widget.Holo.ImageButton"
|
||||||
|
android:src="@drawable/pwr5_widget_button"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:contentDescription="@string/pwr5BntMain"
|
||||||
|
android:padding="0dp"
|
||||||
|
android:background="@android:color/transparent"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/widgetBtnPwr"
|
||||||
|
style="@android:style/Widget.Holo.ImageButton"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
|
@ -66,20 +93,8 @@
|
||||||
android:background="@android:color/transparent"
|
android:background="@android:color/transparent"
|
||||||
android:contentDescription="@string/pwr5BntMain"
|
android:contentDescription="@string/pwr5BntMain"
|
||||||
android:padding="0dp"
|
android:padding="0dp"
|
||||||
android:src="@drawable/pwr5_widget_button" />
|
|
||||||
|
|
||||||
<ImageButton
|
|
||||||
android:id="@+id/widgetBtnPwr"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center_vertical"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:background="@android:color/transparent"
|
|
||||||
android:contentDescription="@string/powerBntMain"
|
|
||||||
android:padding="0dp"
|
|
||||||
android:src="@drawable/pwr_widget_button" />
|
android:src="@drawable/pwr_widget_button" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
</LinearLayout>
|
|
|
@ -6,25 +6,18 @@
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/popUpHostText"
|
android:id="@+id/input"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:ems="10"
|
android:ems="10"
|
||||||
|
android:hint="http://192.168.X.X"
|
||||||
android:inputType="textPersonName" />
|
android:inputType="textPersonName" />
|
||||||
|
|
||||||
<LinearLayout
|
<Button
|
||||||
android:layout_width="fill_parent"
|
android:id="@+id/confirm"
|
||||||
|
style="@style/Widget.AppCompat.ButtonBar.AlertDialog"
|
||||||
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:gravity="end"
|
android:text="@android:string/ok" />
|
||||||
android:orientation="horizontal"
|
|
||||||
>
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/popupHostBtn"
|
|
||||||
style="@style/Widget.AppCompat.ButtonBar.AlertDialog"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="@string/pupUpHostBtn" />
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
|
@ -17,13 +17,13 @@
|
||||||
<string name="updateBtnMain">Обновить статус системы</string>
|
<string name="updateBtnMain">Обновить статус системы</string>
|
||||||
<string name="hostNameDefault">http://192.168.1.3</string>
|
<string name="hostNameDefault">http://192.168.1.3</string>
|
||||||
<string name="hostChBntMain">Изменить адрес хоста</string>
|
<string name="hostChBntMain">Изменить адрес хоста</string>
|
||||||
<string name="pupUpHostBtn">Применить</string>
|
|
||||||
<string name="statusOnline">Онлайн</string>
|
<string name="statusOnline">Онлайн</string>
|
||||||
<string name="statusOffline">Офлайн</string>
|
<string name="statusOffline">Офлайн</string>
|
||||||
<string name="noResponse">"Нет ответа "</string>
|
<string name="noResponse">"Нет ответа "</string>
|
||||||
|
|
||||||
<string name="confCreateWidget">"Создать виджет"</string>
|
<string name="confCreateWidget">"Создать виджет"</string>
|
||||||
<string name="confOpacity">"Прозрачность"</string>
|
<string name="confOpacity" formatted="true">Прозрачность %d</string>
|
||||||
<string name="confWhite">"Белый фон"</string>
|
<string name="confWhite">"Белый фон"</string>
|
||||||
|
<string name="popupTitle">Новый адрес хоста</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
Refer to App Widget Documentation for margin information
|
Refer to App Widget Documentation for margin information
|
||||||
http://developer.android.com/guide/topics/appwidgets/index.html#CreatingLayout
|
http://developer.android.com/guide/topics/appwidgets/index.html#CreatingLayout
|
||||||
-->
|
-->
|
||||||
<dimen name="widget_margin">3dp</dimen>
|
<dimen name="widget_margin">0dp</dimen>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
|
@ -1,10 +1,8 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
Refer to App Widget Documentation for margin information
|
Refer to App Widget Documentation for margin information
|
||||||
http://developer.android.com/guide/topics/appwidgets/index.html#CreatingLayout
|
http://developer.android.com/guide/topics/appwidgets/index.html#CreatingLayout
|
||||||
-->
|
-->
|
||||||
<dimen name="widget_margin">3dp</dimen>
|
<dimen name="widget_margin">8dp</dimen>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
|
@ -17,13 +17,13 @@
|
||||||
<string name="updateBtnMain">Update system status</string>
|
<string name="updateBtnMain">Update system status</string>
|
||||||
<string name="hostNameDefault">http://192.168.1.3</string>
|
<string name="hostNameDefault">http://192.168.1.3</string>
|
||||||
<string name="hostChBntMain">Change host address</string>
|
<string name="hostChBntMain">Change host address</string>
|
||||||
<string name="pupUpHostBtn">Submit</string>
|
|
||||||
<string name="statusOnline">Online</string>
|
<string name="statusOnline">Online</string>
|
||||||
<string name="statusOffline">Offline</string>
|
<string name="statusOffline">Offline</string>
|
||||||
<string name="noResponse">"No response "</string>
|
<string name="noResponse">"No response "</string>
|
||||||
|
|
||||||
<string name="confCreateWidget">"Create widget"</string>
|
<string name="confCreateWidget">"Create widget"</string>
|
||||||
<string name="confOpacity">"Opacity"</string>
|
<string name="confOpacity" formatted="true">Opacity %d</string>
|
||||||
<string name="confWhite">"White background"</string>
|
<string name="confWhite">"White background"</string>
|
||||||
|
<string name="popupTitle">New host address</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -2,9 +2,12 @@
|
||||||
<appwidget-provider
|
<appwidget-provider
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:previewImage="@drawable/widget_preview"
|
android:previewImage="@drawable/widget_preview"
|
||||||
|
android:minWidth="110dp"
|
||||||
android:minHeight="40dp"
|
android:minHeight="40dp"
|
||||||
android:minWidth="80dp"
|
|
||||||
android:updatePeriodMillis="6400000"
|
android:updatePeriodMillis="6400000"
|
||||||
android:resizeMode="none"
|
android:resizeMode="none"
|
||||||
android:configure="com.blogspot.developersu.nowol.nowol.com.blogspot.developersu.nowol.nowol.widget.WidgetConfigurator"
|
android:configure="com.blogspot.developersu.nowol.widget.WidgetConfigurator"
|
||||||
/>
|
android:initialLayout="@layout/no_wol_widget"
|
||||||
|
android:initialKeyguardLayout="@layout/no_wol_widget"
|
||||||
|
android:widgetCategory="home_screen"
|
||||||
|
/>
|
||||||
|
|
Before Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 15 KiB |