mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-08-30 21:55:10 +00:00
Fixed plugin list not reloading after the noti plugin is given permissions
This commit is contained in:
@@ -61,8 +61,6 @@ public class DeviceFragment extends Fragment {
|
||||
static private String mDeviceId; //Static because if we get here by using the back button in the action bar, the extra deviceId will not be set.
|
||||
private Device device;
|
||||
|
||||
public static final int RESULT_NEEDS_RELOAD = Activity.RESULT_FIRST_USER;
|
||||
|
||||
private TextView errorHeader;
|
||||
|
||||
private MaterialActivity mActivity;
|
||||
@@ -94,7 +92,7 @@ public class DeviceFragment extends Fragment {
|
||||
|
||||
setHasOptionsMenu(true);
|
||||
|
||||
Log.e("DeviceFragment","device: " +deviceId);
|
||||
Log.e("DeviceFragment", "device: " + deviceId);
|
||||
|
||||
BackgroundService.RunCommand(mActivity, new BackgroundService.InstanceCallback() {
|
||||
@Override
|
||||
@@ -172,7 +170,12 @@ public class DeviceFragment extends Fragment {
|
||||
if (!failed.isEmpty()) {
|
||||
if (errorHeader == null) {
|
||||
errorHeader = new TextView(mActivity);
|
||||
errorHeader.setPadding(0, 48, 0, 0);
|
||||
errorHeader.setPadding(
|
||||
0,
|
||||
((int)(28 * getResources().getDisplayMetrics().density)),
|
||||
0,
|
||||
((int)(8 * getResources().getDisplayMetrics().density))
|
||||
);
|
||||
errorHeader.setOnClickListener(null);
|
||||
errorHeader.setOnLongClickListener(null);
|
||||
errorHeader.setText(getResources().getString(R.string.plugins_failed_to_load));
|
||||
@@ -266,23 +269,4 @@ public class DeviceFragment extends Fragment {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
switch (requestCode)
|
||||
{
|
||||
case RESULT_NEEDS_RELOAD:
|
||||
BackgroundService.RunCommand(mActivity, new BackgroundService.InstanceCallback() {
|
||||
@Override
|
||||
public void onServiceStart(BackgroundService service) {
|
||||
Device device = service.getDevice(mDeviceId);
|
||||
device.reloadPluginsFromSettings();
|
||||
}
|
||||
});
|
||||
|
||||
break;
|
||||
default:
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,8 +1,10 @@
|
||||
package org.kde.kdeconnect.NewUserInterface;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
@@ -24,6 +26,7 @@ import android.widget.TextView;
|
||||
import org.kde.kdeconnect.BackgroundService;
|
||||
import org.kde.kdeconnect.Device;
|
||||
import org.kde.kdeconnect.Helpers.DeviceHelper;
|
||||
import org.kde.kdeconnect.Plugins.Plugin;
|
||||
import org.kde.kdeconnect_tp.R;
|
||||
|
||||
import java.util.Collection;
|
||||
@@ -33,6 +36,8 @@ public class MaterialActivity extends AppCompatActivity {
|
||||
|
||||
private static final String STATE_SELECTED_DEVICE = "selected_device";
|
||||
|
||||
public static final int RESULT_NEEDS_RELOAD = Activity.RESULT_FIRST_USER;
|
||||
|
||||
private NavigationView mNavigationView;
|
||||
private DrawerLayout mDrawerLayout;
|
||||
|
||||
@@ -202,6 +207,7 @@ public class MaterialActivity extends AppCompatActivity {
|
||||
|
||||
//TODO: Make it accept two parameters, a constant with the type of screen and the device id in
|
||||
//case the screen is for a device, or even three parameters and the third one be the plugin id?
|
||||
//This way we can keep adding more options with null plugin id (eg: about)
|
||||
public void onDeviceSelected(String deviceId) {
|
||||
|
||||
mCurrentDevice = deviceId;
|
||||
@@ -240,4 +246,23 @@ public class MaterialActivity extends AppCompatActivity {
|
||||
onDeviceSelected(savedDevice);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
Log.e("MaterialActivity", "Main Activity onActivityResult" + requestCode);
|
||||
switch (requestCode)
|
||||
{
|
||||
case RESULT_NEEDS_RELOAD:
|
||||
BackgroundService.RunCommand(this, new BackgroundService.InstanceCallback() {
|
||||
@Override
|
||||
public void onServiceStart(BackgroundService service) {
|
||||
Device device = service.getDevice(mCurrentDevice);
|
||||
device.reloadPluginsFromSettings();
|
||||
}
|
||||
});
|
||||
break;
|
||||
default:
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user