2018-02-22 00:50:11 +01:00
|
|
|
/*
|
|
|
|
* Copyright 2015 David Edmundson <david@davidedmundson.co.uk>
|
|
|
|
*
|
|
|
|
* This program 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 2 of
|
|
|
|
* the License or (at your option) version 3 or any later version
|
|
|
|
* accepted by the membership of KDE e.V. (or its successor approved
|
|
|
|
* by the membership of KDE e.V.), which shall act as a proxy
|
|
|
|
* defined in Section 14 of version 3 of the license.
|
|
|
|
*
|
|
|
|
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2015-09-11 16:54:43 +02:00
|
|
|
package org.kde.kdeconnect.Plugins.FindMyPhonePlugin;
|
|
|
|
|
|
|
|
import android.content.Intent;
|
|
|
|
|
2016-06-28 20:00:19 +02:00
|
|
|
import org.kde.kdeconnect.Helpers.DeviceHelper;
|
2018-03-04 11:31:37 +01:00
|
|
|
import org.kde.kdeconnect.NetworkPacket;
|
2015-09-11 16:54:43 +02:00
|
|
|
import org.kde.kdeconnect.Plugins.Plugin;
|
|
|
|
import org.kde.kdeconnect_tp.R;
|
|
|
|
|
|
|
|
public class FindMyPhonePlugin extends Plugin {
|
2016-05-31 17:19:39 +02:00
|
|
|
|
2018-03-04 11:31:37 +01:00
|
|
|
public final static String PACKET_TYPE_FINDMYPHONE_REQUEST = "kdeconnect.findmyphone.request";
|
2016-05-31 17:19:39 +02:00
|
|
|
|
2015-09-11 16:54:43 +02:00
|
|
|
@Override
|
|
|
|
public String getDisplayName() {
|
2018-05-10 12:34:28 +02:00
|
|
|
switch (DeviceHelper.getDeviceType(context)) {
|
|
|
|
case Tv:
|
|
|
|
return context.getString(R.string.findmyphone_title_tv);
|
|
|
|
case Tablet:
|
|
|
|
return context.getString(R.string.findmyphone_title_tablet);
|
|
|
|
case Phone:
|
|
|
|
return context.getString(R.string.findmyphone_title);
|
|
|
|
default:
|
|
|
|
return context.getString(R.string.findmyphone_title);
|
|
|
|
}
|
2015-09-11 16:54:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String getDescription() {
|
|
|
|
return context.getString(R.string.findmyphone_description);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2018-03-04 11:31:37 +01:00
|
|
|
public boolean onPacketReceived(NetworkPacket np) {
|
2015-09-11 16:54:43 +02:00
|
|
|
|
2018-02-22 00:50:11 +01:00
|
|
|
Intent intent = new Intent(context, FindMyPhoneActivity.class);
|
2016-06-02 15:35:44 +02:00
|
|
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
|
|
context.startActivity(intent);
|
|
|
|
return true;
|
2015-09-11 16:54:43 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2018-03-04 11:31:37 +01:00
|
|
|
public String[] getSupportedPacketTypes() {
|
|
|
|
return new String[]{PACKET_TYPE_FINDMYPHONE_REQUEST};
|
2015-09-11 16:54:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2018-03-04 11:31:37 +01:00
|
|
|
public String[] getOutgoingPacketTypes() {
|
2015-09-11 16:54:43 +02:00
|
|
|
return new String[0];
|
|
|
|
}
|
2018-02-22 00:50:11 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean hasSettings() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-09-11 16:54:43 +02:00
|
|
|
}
|