diff --git a/res/layout/activity_notification_filter.xml b/res/layout/activity_notification_filter.xml
index 9e8c63cb..3867b6e7 100644
--- a/res/layout/activity_notification_filter.xml
+++ b/res/layout/activity_notification_filter.xml
@@ -1,31 +1,31 @@
diff --git a/res/values/strings.xml b/res/values/strings.xml
index ee6ac2ac..30b6f4b8 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1,287 +1,288 @@
Telephony notifier
Send notifications for incoming calls
Battery report
Periodically report battery status
Filesystem expose
Allows to browse this device\'s filesystem remotely
Clipboard sync
Share the clipboard content
Remote input
Use your phone or tablet as a touchpad and keyboard
Presentation remote
Use your device to change slides in a presentation
Receive remote keypresses
Receive keypress events from remote devices
Multimedia controls
Provides a remote control for your media player
Run Command
Trigger remote commands from your phone or tablet
Contacts Synchronizer
Allow synchronizing the device\'s contacts book
Ping
Send and receive pings
Notification sync
Access your notifications from other devices
Receive notifications
Receive notifications from the other device and display them on Android
Share and receive
Share files and URLs between devices
This feature is not available in your Android version
No devices
OK
Cancel
Open settings
You need to grant permission to access notifications
To be able to control your media players you need to grant access to the notifications
Send ping
Multimedia control
remotekeyboard_editing_only
Handle remote keys only when editing
There is no active remote keyboard connection, establish one in kdeconnect
Remote keyboard connection is active
There is more than one remote keyboard connection, select the device to configure
Remote input
Move a finger on the screen to move the mouse cursor. Tap for a click, and use two/three fingers for right and middle buttons. Use 2 fingers to scroll. Use a long press to drag\'n drop.
Set two finger tap action
Set three finger tap action
Set touchpad sensitivity
Set pointer acceleration
mousepad_double_tap_key
mousepad_triple_tap_key
mousepad_sensitivity_key
mousepad_acceleration_profile_key
Reverse Scrolling Direction
mousepad_scroll_direction
- Right click
- Middle click
- Nothing
right
middle
default
medium
- right
- middle
- none
- Slowest
- Above Slowest
- Default
- Above Default
- Fastest
- No Acceleration
- Weakest
- Weaker
- Medium
- Stronger
- Strongest
- slowest
- aboveSlowest
- default
- aboveDefault
- fastest
- noacceleration
- weaker
- weak
- medium
- strong
- stronger
Connected devices
Available devices
Remembered devices
Plugins failed to load (tap for more info):
Plugin settings
Unpair
Paired device not reachable
Pair new device
Unknown device
Device not reachable
Pairing already requested
Device already paired
Could not send package
Timed out
Canceled by user
Canceled by other peer
Invalid key received
Encryption Info
The other device doesn\'t use a recent version of KDE Connect, using the legacy encryption method.
SHA1 fingerprint of your device certificate is:
SHA1 fingerprint of remote device certificate is:
Pair requested
Pairing request from %1s
Received link from %1s
Tap to open \'%1s\'
Incoming file from %1s
%1s
Sending file to %1s
Sending files to %1s
- Sent %1$d file
- Sent %1$d out of %2$d files
Received file from %1s
Failed receiving file from %1s
Tap to open \'%1s\'
Sent file to %1s
%1s
Failed to send file to %1s
%1s
Tap to answer
Reconnect
Send Right Click
Send Middle Click
Show Keyboard
Device not paired
Request pairing
Accept
Reject
Device
Pair device
Remote control
KDE Connect Settings
Play
Pause
Previous
Rewind
Fast-forward
Next
Volume
Multimedia Settings
Forward/rewind buttons
Adjust the time to fast forward/rewind when pressed
mpris_interval_time
- 10 seconds
- 20 seconds
- 30 seconds
- 1 minute
- 2 minutes
10000000
- 10000000
- 20000000
- 30000000
- 60000000
- 120000000
Show media control notification
Allow controlling your media players without opening KDE Connect
mpris_notification_enabled
Share To...
This device uses an old protocol version
This device uses a newer protocol version
General Settings
Settings
%s settings
Device name
%s
Invalid device name
Received text, saved to clipboard
Custom device list
Pair a new device
Unpair %s
Add devices by IP
Noisy notifications
Vibrate and play a sound when receiving a file
Customize destination directory
Received files will appear in Downloads
Files will be stored in the directory below
Destination directory
Share
Share \"%s\"
Notification filter
Notifications will be synchronized for the selected apps.
Internal storage
All files
SD card %d
SD card
(read only)
Camera pictures
Add host/IP
Hostname or IP
No players found
Use this option only if your device is not automatically detected. Enter IP address or hostname below and touch the button to add it to the list. Touch an existing item to remove it from the list.
%1$s on %2$s
Send files
KDE Connect Devices
Other devices running KDE Connect in your same network should appear here.
Device paired
Rename device
Rename
Refresh
This paired device is not reachable. Make sure it is connected to your same network.
It looks like you are on a mobile data connection. KDE Connect only works on local networks.
There are no file browsers installed.
Send SMS
Send text messages from your desktop
This plugin is not supported by the device
Find my phone
Find my tablet
Find my TV
Rings this device so you can find it
Found
Open
Close
You need to grant permissions to access the storage
Some Plugins need permissions to work (tap for more info):
This plugin needs permissions to work
You need to grant extra permissions to enable all functions
Some plugins have features disabled because of lack of permission (tap for more info):
To access your files from your PC the app needs permission to access your phone\'s storage
To share files between your phone and your desktop you need to give access to the phone\'s storage
To read and write SMS from your desktop you need to give permission to SMS
To see phone calls and SMS from the desktop you need to give permission to phone calls and SMS
To see a contact name instead of a phone number you need to give access to the phone\'s contacts
To share your contacts book with the desktop, you need to give contacts permission
Select a ringtone
Blocked numbers
Don\'t show calls and SMS from these numbers. Please specify one number per line
Cover art of current media
Device icon
Settings icon
Fullscreen
Exit presentation
You can lock your device to use the volume keys as previous/next buttons
Add a command
There are no commands registered
You can add new commands in the KDE Connect System Settings
You can add commands on the desktop
Media Player Control
Control your phones media players from another device
Dark theme
Stop the current player
Copy URL to clipboard
Copied to clipboard
Device is not reachable
Device is not paired
There is no such device
This device does not have the Run Command Plugin enabled
Find remote device
Ring your remote device
Ring
System volume
Control the system volume of the remote device
Mute
+ All
diff --git a/src/org/kde/kdeconnect/Plugins/NotificationsPlugin/AppDatabase.java b/src/org/kde/kdeconnect/Plugins/NotificationsPlugin/AppDatabase.java
index 977b4713..6bfc6137 100644
--- a/src/org/kde/kdeconnect/Plugins/NotificationsPlugin/AppDatabase.java
+++ b/src/org/kde/kdeconnect/Plugins/NotificationsPlugin/AppDatabase.java
@@ -1,116 +1,120 @@
/*
* Copyright 2015 Vineet Garg
*
* 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 .
-*/
+ * along with this program. If not, see .
+ */
package org.kde.kdeconnect.Plugins.NotificationsPlugin;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import java.util.HashSet;
class AppDatabase {
static final private HashSet disabledByDefault = new HashSet<>();
static {
disabledByDefault.add("com.google.android.googlequicksearchbox"); //Google Now notifications re-spawn every few minutes
}
private static final String KEY_PACKAGE_NAME = "packageName";
private static final String KEY_IS_ENABLED = "isEnabled";
private static final String DATABASE_NAME = "Applications";
private static final String DATABASE_TABLE = "Applications";
private static final int DATABASE_VERSION = 2;
private SQLiteDatabase ourDatabase;
private DbHelper ourHelper;
AppDatabase(Context context, boolean readonly) {
ourHelper = new DbHelper(context);
if (readonly) {
ourDatabase = ourHelper.getReadableDatabase();
} else {
ourDatabase = ourHelper.getWritableDatabase();
}
}
@Override
protected void finalize() throws Throwable {
ourHelper.close();
super.finalize();
}
private static class DbHelper extends SQLiteOpenHelper {
DbHelper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL("CREATE TABLE " + DATABASE_TABLE + "(" + KEY_PACKAGE_NAME + " TEXT PRIMARY KEY NOT NULL, " + KEY_IS_ENABLED + " TEXT NOT NULL); ");
}
@Override
public void onUpgrade(SQLiteDatabase db, int i, int i2) {
db.execSQL("DROP TABLE IF EXISTS " + DATABASE_TABLE);
onCreate(db);
}
}
void setEnabled(String packageName, boolean isEnabled) {
String[] columns = new String[]{KEY_IS_ENABLED};
Cursor res = ourDatabase.query(DATABASE_TABLE, columns, KEY_PACKAGE_NAME + " =? ", new String[]{packageName}, null, null, null);
ContentValues cv = new ContentValues();
cv.put(KEY_IS_ENABLED, isEnabled ? "true" : "false");
if (res.getCount() > 0) {
ourDatabase.update(DATABASE_TABLE, cv, KEY_PACKAGE_NAME + "=?", new String[]{packageName});
} else {
cv.put(KEY_PACKAGE_NAME, packageName);
ourDatabase.insert(DATABASE_TABLE, null, cv);
}
res.close();
}
+ void setAllEnabled(boolean enabled) {
+ ourDatabase.execSQL("UPDATE " + DATABASE_TABLE + " SET " + KEY_IS_ENABLED + "='" + enabled + "'");
+ }
+
boolean isEnabled(String packageName) {
String[] columns = new String[]{KEY_IS_ENABLED};
Cursor res = ourDatabase.query(DATABASE_TABLE, columns, KEY_PACKAGE_NAME + " =? ", new String[]{packageName}, null, null, null);
boolean result;
if (res.getCount() > 0) {
res.moveToFirst();
result = (res.getString(res.getColumnIndex(KEY_IS_ENABLED))).equals("true");
} else {
result = getDefaultStatus(packageName);
}
res.close();
return result;
}
private boolean getDefaultStatus(String packageName) {
return !disabledByDefault.contains(packageName);
}
}
diff --git a/src/org/kde/kdeconnect/Plugins/NotificationsPlugin/NotificationFilterActivity.java b/src/org/kde/kdeconnect/Plugins/NotificationsPlugin/NotificationFilterActivity.java
index fa4fc6ef..8c0615dd 100644
--- a/src/org/kde/kdeconnect/Plugins/NotificationsPlugin/NotificationFilterActivity.java
+++ b/src/org/kde/kdeconnect/Plugins/NotificationsPlugin/NotificationFilterActivity.java
@@ -1,170 +1,187 @@
/*
* Copyright 2015 Vineet Garg
*
* 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 .
-*/
+ * along with this program. If not, see .
+ */
package org.kde.kdeconnect.Plugins.NotificationsPlugin;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
+import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.CheckedTextView;
import android.widget.ListView;
import org.kde.kdeconnect.BackgroundService;
import org.kde.kdeconnect.Helpers.StringsHelper;
import org.kde.kdeconnect.UserInterface.ThemeUtil;
import org.kde.kdeconnect_tp.R;
import java.util.Arrays;
import java.util.List;
public class NotificationFilterActivity extends AppCompatActivity {
private AppDatabase appDatabase;
+ private ListView listView;
static class AppListInfo {
+
String pkg;
String name;
Drawable icon;
boolean isEnabled;
}
private AppListInfo[] apps;
class AppListAdapter extends BaseAdapter {
@Override
public int getCount() {
- return apps.length;
+ return apps.length + 1;
}
@Override
public AppListInfo getItem(int position) {
- return apps[position];
+ return apps[position - 1];
}
@Override
public long getItemId(int position) {
- return position;
+ return position - 1;
}
public View getView(int position, View view, ViewGroup parent) {
if (view == null) {
LayoutInflater inflater = getLayoutInflater();
view = inflater.inflate(android.R.layout.simple_list_item_multiple_choice, null, true);
}
CheckedTextView checkedTextView = (CheckedTextView) view;
- checkedTextView.setText(apps[position].name);
- checkedTextView.setCompoundDrawablesWithIntrinsicBounds(apps[position].icon, null, null, null);
- checkedTextView.setCompoundDrawablePadding((int) (8 * getResources().getDisplayMetrics().density));
+ if (position == 0) {
+ checkedTextView.setText(R.string.all);
+ checkedTextView.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
+ } else {
+ checkedTextView.setText(apps[position - 1].name);
+ checkedTextView.setCompoundDrawablesWithIntrinsicBounds(apps[position - 1].icon, null, null, null);
+ checkedTextView.setCompoundDrawablePadding((int) (8 * getResources().getDisplayMetrics().density));
+ }
return view;
}
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ThemeUtil.setUserPreferredTheme(this);
setContentView(R.layout.activity_notification_filter);
appDatabase = new AppDatabase(NotificationFilterActivity.this, false);
new Thread(() -> {
PackageManager packageManager = getPackageManager();
List appList = packageManager.getInstalledApplications(0);
int count = appList.size();
apps = new AppListInfo[count];
for (int i = 0; i < count; i++) {
ApplicationInfo appInfo = appList.get(i);
apps[i] = new AppListInfo();
apps[i].pkg = appInfo.packageName;
apps[i].name = appInfo.loadLabel(packageManager).toString();
apps[i].icon = resizeIcon(appInfo.loadIcon(packageManager), 48);
apps[i].isEnabled = appDatabase.isEnabled(appInfo.packageName);
}
Arrays.sort(apps, (lhs, rhs) -> StringsHelper.compare(lhs.name, rhs.name));
runOnUiThread(this::displayAppList);
}).start();
}
private void displayAppList() {
- final ListView listView = (ListView) findViewById(R.id.lvFilterApps);
+ listView = (ListView) findViewById(R.id.lvFilterApps);
AppListAdapter adapter = new AppListAdapter();
listView.setAdapter(adapter);
listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
listView.setOnItemClickListener((adapterView, view, i, l) -> {
- boolean checked = listView.isItemChecked(i);
- appDatabase.setEnabled(apps[i].pkg, checked);
- apps[i].isEnabled = checked;
+
+ if (i == 0) {
+
+ boolean enabled = listView.isItemChecked(0);
+ for (int j = 0; j < apps.length; j++) {
+ listView.setItemChecked(j, enabled);
+ }
+ appDatabase.setAllEnabled(enabled);
+ } else {
+ boolean checked = listView.isItemChecked(i);
+ appDatabase.setEnabled(apps[i - 1].pkg, checked);
+ apps[i - 1].isEnabled = checked;
+ }
});
for (int i = 0; i < apps.length; i++) {
- listView.setItemChecked(i, apps[i].isEnabled);
+ listView.setItemChecked(i + 1, apps[i].isEnabled);
}
listView.setVisibility(View.VISIBLE);
findViewById(R.id.spinner).setVisibility(View.GONE);
}
@Override
protected void onStart() {
super.onStart();
BackgroundService.addGuiInUseCounter(this);
}
@Override
protected void onStop() {
super.onStop();
BackgroundService.removeGuiInUseCounter(this);
}
private Drawable resizeIcon(Drawable icon, int maxSize) {
Resources res = getResources();
//Convert to display pixels
maxSize = (int) (maxSize * res.getDisplayMetrics().density);
Bitmap bitmap = Bitmap.createBitmap(maxSize, maxSize, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
icon.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
icon.draw(canvas);
return new BitmapDrawable(res, bitmap);
-
}
}