mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-08-22 09:58:08 +00:00
Merge branch 'stable'
This commit is contained in:
commit
80026f6d62
@ -1,7 +1,7 @@
|
|||||||
<?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="org.kde.kdeconnect_tp"
|
package="org.kde.kdeconnect_tp"
|
||||||
android:versionCode="904"
|
android:versionCode="905"
|
||||||
android:versionName="0.9">
|
android:versionName="0.9">
|
||||||
|
|
||||||
<uses-sdk android:minSdkVersion="9"
|
<uses-sdk android:minSdkVersion="9"
|
||||||
|
@ -2,7 +2,8 @@
|
|||||||
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="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:padding="16dip"
|
android:paddingLeft="16dip"
|
||||||
|
android:paddingRight="16dip"
|
||||||
tools:context=".MainActivity"
|
tools:context=".MainActivity"
|
||||||
android:id="@+id/listView1"
|
android:id="@+id/listView1"
|
||||||
android:addStatesFromChildren="true"
|
android:addStatesFromChildren="true"
|
||||||
|
@ -77,11 +77,11 @@ public class BackgroundService extends Service {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void addGuiInUseCounter(Activity activity) {
|
public static void addGuiInUseCounter(Context activity) {
|
||||||
addGuiInUseCounter(activity, false);
|
addGuiInUseCounter(activity, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void addGuiInUseCounter(final Activity activity, final boolean forceNetworkRefresh) {
|
public static void addGuiInUseCounter(final Context activity, final boolean forceNetworkRefresh) {
|
||||||
BackgroundService.RunCommand(activity, new BackgroundService.InstanceCallback() {
|
BackgroundService.RunCommand(activity, new BackgroundService.InstanceCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onServiceStart(BackgroundService service) {
|
public void onServiceStart(BackgroundService service) {
|
||||||
@ -93,7 +93,7 @@ public class BackgroundService extends Service {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void removeGuiInUseCounter(final Activity activity) {
|
public static void removeGuiInUseCounter(final Context activity) {
|
||||||
BackgroundService.RunCommand(activity, new BackgroundService.InstanceCallback() {
|
BackgroundService.RunCommand(activity, new BackgroundService.InstanceCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onServiceStart(BackgroundService service) {
|
public void onServiceStart(BackgroundService service) {
|
||||||
@ -162,7 +162,7 @@ public class BackgroundService extends Service {
|
|||||||
|
|
||||||
private void cleanDevices() {
|
private void cleanDevices() {
|
||||||
for(Device d : devices.values()) {
|
for(Device d : devices.values()) {
|
||||||
if (!d.isPaired()) {
|
if (!d.isPaired() && !d.isPairRequested() && !d.isPairRequestedByOtherEnd() && d.getConnectionSource() == BaseLink.ConnectionStarted.Remotely) {
|
||||||
d.disconnect();
|
d.disconnect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -182,9 +182,14 @@ public class BackgroundService extends Service {
|
|||||||
} else {
|
} else {
|
||||||
Log.i("KDE/BackgroundService", "addLink,unknown device: " + deviceId);
|
Log.i("KDE/BackgroundService", "addLink,unknown device: " + deviceId);
|
||||||
device = new Device(BackgroundService.this, identityPackage, link);
|
device = new Device(BackgroundService.this, identityPackage, link);
|
||||||
if (device.isPaired() || !discoveryModeAcquisitions.isEmpty()) {
|
if (device.isPaired() || device.isPairRequested() || device.isPairRequestedByOtherEnd()
|
||||||
|
|| link.getConnectionSource() == BaseLink.ConnectionStarted.Locally
|
||||||
|
||!discoveryModeAcquisitions.isEmpty() )
|
||||||
|
{
|
||||||
devices.put(deviceId, device);
|
devices.put(deviceId, device);
|
||||||
device.addPairingCallback(devicePairingCallback);
|
device.addPairingCallback(devicePairingCallback);
|
||||||
|
} else {
|
||||||
|
device.disconnect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -197,7 +202,7 @@ public class BackgroundService extends Service {
|
|||||||
Log.i("KDE/onConnectionLost", "removeLink, deviceId: " + link.getDeviceId());
|
Log.i("KDE/onConnectionLost", "removeLink, deviceId: " + link.getDeviceId());
|
||||||
if (d != null) {
|
if (d != null) {
|
||||||
d.removeLink(link);
|
d.removeLink(link);
|
||||||
if (!d.isReachable() && !d.isPaired() && (link.getConnectionSource() == BaseLink.ConnectionStarted.Locally)) {
|
if (!d.isReachable() && !d.isPaired()) {
|
||||||
//Log.e("onConnectionLost","Removing connection device because it was not paired");
|
//Log.e("onConnectionLost","Removing connection device because it was not paired");
|
||||||
devices.remove(link.getDeviceId());
|
devices.remove(link.getDeviceId());
|
||||||
d.removePairingCallback(devicePairingCallback);
|
d.removePairingCallback(devicePairingCallback);
|
||||||
|
@ -216,11 +216,12 @@ public class Device implements BaseLink.PackageReceiver {
|
|||||||
return pairStatus == PairStatus.Requested;
|
return pairStatus == PairStatus.Requested;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isPairRequestedByOtherEnd() {
|
||||||
|
return pairStatus == PairStatus.RequestedByPeer;
|
||||||
|
}
|
||||||
|
|
||||||
public void addPairingCallback(PairingCallback callback) {
|
public void addPairingCallback(PairingCallback callback) {
|
||||||
pairingCallback.add(callback);
|
pairingCallback.add(callback);
|
||||||
if (pairStatus == PairStatus.RequestedByPeer) {
|
|
||||||
callback.incomingRequest();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
public void removePairingCallback(PairingCallback callback) {
|
public void removePairingCallback(PairingCallback callback) {
|
||||||
pairingCallback.remove(callback);
|
pairingCallback.remove(callback);
|
||||||
@ -258,10 +259,10 @@ public class Device implements BaseLink.PackageReceiver {
|
|||||||
|
|
||||||
//Send our own public key
|
//Send our own public key
|
||||||
NetworkPackage np = NetworkPackage.createPublicKeyPackage(context);
|
NetworkPackage np = NetworkPackage.createPublicKeyPackage(context);
|
||||||
sendPackage(np, new SendPackageStatusCallback(){
|
sendPackage(np, new SendPackageStatusCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess() {
|
public void onSuccess() {
|
||||||
if (pairingTimer != null) pairingTimer.cancel();
|
hidePairingNotification(); //Will stop the pairingTimer if it was running
|
||||||
pairingTimer = new Timer();
|
pairingTimer = new Timer();
|
||||||
pairingTimer.schedule(new TimerTask() {
|
pairingTimer.schedule(new TimerTask() {
|
||||||
@Override
|
@Override
|
||||||
@ -269,10 +270,10 @@ public class Device implements BaseLink.PackageReceiver {
|
|||||||
for (PairingCallback cb : pairingCallback) {
|
for (PairingCallback cb : pairingCallback) {
|
||||||
cb.pairingFailed(context.getString(R.string.error_timed_out));
|
cb.pairingFailed(context.getString(R.string.error_timed_out));
|
||||||
}
|
}
|
||||||
Log.e("KDE/Device","Unpairing (timeout A)");
|
Log.e("KDE/Device", "Unpairing (timeout A)");
|
||||||
pairStatus = PairStatus.NotPaired;
|
pairStatus = PairStatus.NotPaired;
|
||||||
}
|
}
|
||||||
}, 30*1000); //Time to wait for the other to accept
|
}, 30 * 1000); //Time to wait for the other to accept
|
||||||
pairStatus = PairStatus.Requested;
|
pairStatus = PairStatus.Requested;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -281,7 +282,7 @@ public class Device implements BaseLink.PackageReceiver {
|
|||||||
for (PairingCallback cb : pairingCallback) {
|
for (PairingCallback cb : pairingCallback) {
|
||||||
cb.pairingFailed(context.getString(R.string.error_could_not_send_package));
|
cb.pairingFailed(context.getString(R.string.error_could_not_send_package));
|
||||||
}
|
}
|
||||||
Log.e("KDE/Device","Unpairing (sendFailed A)");
|
Log.e("KDE/Device", "Unpairing (sendFailed A)");
|
||||||
pairStatus = PairStatus.NotPaired;
|
pairStatus = PairStatus.NotPaired;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -289,8 +290,13 @@ public class Device implements BaseLink.PackageReceiver {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getNotificationId() {
|
public void hidePairingNotification() {
|
||||||
return notificationId;
|
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
|
notificationManager.cancel(notificationId);
|
||||||
|
if (pairingTimer != null) {
|
||||||
|
pairingTimer.cancel();
|
||||||
|
}
|
||||||
|
BackgroundService.removeGuiInUseCounter(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void unpair() {
|
public void unpair() {
|
||||||
@ -315,7 +321,7 @@ public class Device implements BaseLink.PackageReceiver {
|
|||||||
|
|
||||||
//Log.e("Device", "Storing as trusted, deviceId: "+deviceId);
|
//Log.e("Device", "Storing as trusted, deviceId: "+deviceId);
|
||||||
|
|
||||||
if (pairingTimer != null) pairingTimer.cancel();
|
hidePairingNotification();
|
||||||
|
|
||||||
pairStatus = PairStatus.Paired;
|
pairStatus = PairStatus.Paired;
|
||||||
|
|
||||||
@ -463,7 +469,7 @@ public class Device implements BaseLink.PackageReceiver {
|
|||||||
if (pairStatus == PairStatus.Requested) {
|
if (pairStatus == PairStatus.Requested) {
|
||||||
//Log.e("Device","Unpairing (pair rejected)");
|
//Log.e("Device","Unpairing (pair rejected)");
|
||||||
pairStatus = PairStatus.NotPaired;
|
pairStatus = PairStatus.NotPaired;
|
||||||
if (pairingTimer != null) pairingTimer.cancel();
|
hidePairingNotification();
|
||||||
for (PairingCallback cb : pairingCallback) {
|
for (PairingCallback cb : pairingCallback) {
|
||||||
cb.pairingFailed(context.getString(R.string.error_canceled_by_other_peer));
|
cb.pairingFailed(context.getString(R.string.error_canceled_by_other_peer));
|
||||||
}
|
}
|
||||||
@ -491,7 +497,7 @@ public class Device implements BaseLink.PackageReceiver {
|
|||||||
|
|
||||||
Log.i("KDE/Pairing","Pair answer");
|
Log.i("KDE/Pairing","Pair answer");
|
||||||
|
|
||||||
if (pairingTimer != null) pairingTimer.cancel();
|
hidePairingNotification();
|
||||||
|
|
||||||
pairingDone();
|
pairingDone();
|
||||||
|
|
||||||
@ -505,6 +511,8 @@ public class Device implements BaseLink.PackageReceiver {
|
|||||||
|
|
||||||
Resources res = context.getResources();
|
Resources res = context.getResources();
|
||||||
|
|
||||||
|
hidePairingNotification();
|
||||||
|
|
||||||
Notification noti = new NotificationCompat.Builder(context)
|
Notification noti = new NotificationCompat.Builder(context)
|
||||||
.setContentTitle(res.getString(R.string.pairing_request_from, getName()))
|
.setContentTitle(res.getString(R.string.pairing_request_from, getName()))
|
||||||
.setContentText(res.getString(R.string.tap_to_answer))
|
.setContentText(res.getString(R.string.tap_to_answer))
|
||||||
@ -519,21 +527,20 @@ public class Device implements BaseLink.PackageReceiver {
|
|||||||
final NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
final NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
notificationId = (int)System.currentTimeMillis();
|
notificationId = (int)System.currentTimeMillis();
|
||||||
try {
|
try {
|
||||||
|
BackgroundService.addGuiInUseCounter(context);
|
||||||
notificationManager.notify(notificationId, noti);
|
notificationManager.notify(notificationId, noti);
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
//4.1 will throw an exception about not having the VIBRATE permission, ignore it.
|
//4.1 will throw an exception about not having the VIBRATE permission, ignore it.
|
||||||
//https://android.googlesource.com/platform/frameworks/base/+/android-4.2.1_r1.2%5E%5E!/
|
//https://android.googlesource.com/platform/frameworks/base/+/android-4.2.1_r1.2%5E%5E!/
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pairingTimer != null) pairingTimer.cancel();
|
|
||||||
pairingTimer = new Timer();
|
pairingTimer = new Timer();
|
||||||
|
|
||||||
pairingTimer.schedule(new TimerTask() {
|
pairingTimer.schedule(new TimerTask() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
Log.e("KDE/Device","Unpairing (timeout B)");
|
Log.e("KDE/Device","Unpairing (timeout B)");
|
||||||
|
hidePairingNotification();
|
||||||
pairStatus = PairStatus.NotPaired;
|
pairStatus = PairStatus.NotPaired;
|
||||||
notificationManager.cancel(notificationId);
|
|
||||||
}
|
}
|
||||||
}, 25*1000); //Time to show notification, waiting for user to accept (peer will timeout in 30 seconds)
|
}, 25*1000); //Time to show notification, waiting for user to accept (peer will timeout in 30 seconds)
|
||||||
pairStatus = PairStatus.RequestedByPeer;
|
pairStatus = PairStatus.RequestedByPeer;
|
||||||
@ -544,7 +551,7 @@ public class Device implements BaseLink.PackageReceiver {
|
|||||||
Log.i("KDE/Pairing","Unpair request");
|
Log.i("KDE/Pairing","Unpair request");
|
||||||
|
|
||||||
if (pairStatus == PairStatus.Requested) {
|
if (pairStatus == PairStatus.Requested) {
|
||||||
pairingTimer.cancel();
|
hidePairingNotification();
|
||||||
for (PairingCallback cb : pairingCallback) {
|
for (PairingCallback cb : pairingCallback) {
|
||||||
cb.pairingFailed(context.getString(R.string.error_canceled_by_other_peer));
|
cb.pairingFailed(context.getString(R.string.error_canceled_by_other_peer));
|
||||||
}
|
}
|
||||||
@ -891,4 +898,14 @@ public class Device implements BaseLink.PackageReceiver {
|
|||||||
link.disconnect();
|
link.disconnect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BaseLink.ConnectionStarted getConnectionSource() {
|
||||||
|
for(BaseLink l : links) {
|
||||||
|
if (l.getConnectionSource() == BaseLink.ConnectionStarted.Locally) {
|
||||||
|
return BaseLink.ConnectionStarted.Locally;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return BaseLink.ConnectionStarted.Remotely;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -294,78 +294,90 @@ public class DeviceFragment extends Fragment {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Once in-app, there is no point in keep displaying the notification if any
|
||||||
|
device.hidePairingNotification();
|
||||||
|
|
||||||
mActivity.runOnUiThread(new Runnable() {
|
mActivity.runOnUiThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
||||||
boolean paired = device.isPaired();
|
Log.e("DEVICE",device.getName() + device.isPairRequestedByOtherEnd() + device.isPairRequested());
|
||||||
boolean reachable = device.isReachable();
|
if (device.isPairRequestedByOtherEnd()) {
|
||||||
|
((TextView) rootView.findViewById(R.id.pair_message)).setText(R.string.pair_requested);
|
||||||
|
rootView.findViewById(R.id.pair_progress).setVisibility(View.GONE);
|
||||||
|
rootView.findViewById(R.id.pair_button).setVisibility(View.GONE);
|
||||||
|
rootView.findViewById(R.id.pair_request).setVisibility(View.VISIBLE);
|
||||||
|
} else {
|
||||||
|
|
||||||
rootView.findViewById(R.id.pairing_buttons).setVisibility(paired ? View.GONE : View.VISIBLE);
|
boolean paired = device.isPaired();
|
||||||
rootView.findViewById(R.id.unpair_message).setVisibility((paired && !reachable) ? View.VISIBLE : View.GONE);
|
boolean reachable = device.isReachable();
|
||||||
|
|
||||||
try {
|
rootView.findViewById(R.id.pairing_buttons).setVisibility(paired ? View.GONE : View.VISIBLE);
|
||||||
ArrayList<ListAdapter.Item> items = new ArrayList<>();
|
rootView.findViewById(R.id.unpair_message).setVisibility((paired && !reachable) ? View.VISIBLE : View.GONE);
|
||||||
|
|
||||||
//Plugins button list
|
try {
|
||||||
final Collection<Plugin> plugins = device.getLoadedPlugins().values();
|
ArrayList<ListAdapter.Item> items = new ArrayList<>();
|
||||||
for (final Plugin p : plugins) {
|
|
||||||
if (!p.hasMainActivity()) continue;
|
|
||||||
if (p.displayInContextMenu()) continue;
|
|
||||||
|
|
||||||
items.add(new PluginItem(p, new View.OnClickListener() {
|
//Plugins button list
|
||||||
@Override
|
final Collection<Plugin> plugins = device.getLoadedPlugins().values();
|
||||||
public void onClick(View v) {
|
for (final Plugin p : plugins) {
|
||||||
p.startMainActivity(mActivity);
|
if (!p.hasMainActivity()) continue;
|
||||||
}
|
if (p.displayInContextMenu()) continue;
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
//Failed plugins List
|
items.add(new PluginItem(p, new View.OnClickListener() {
|
||||||
final HashMap<String, Plugin> failed = device.getFailedPlugins();
|
|
||||||
if (!failed.isEmpty()) {
|
|
||||||
if (errorHeader == null) {
|
|
||||||
errorHeader = new TextView(mActivity);
|
|
||||||
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));
|
|
||||||
}
|
|
||||||
items.add(new CustomItem(errorHeader));
|
|
||||||
for (String s : failed.keySet()) {
|
|
||||||
final Plugin p = failed.get(s);
|
|
||||||
if (p == null) {
|
|
||||||
items.add(new SmallEntryItem(s));
|
|
||||||
} else {
|
|
||||||
items.add(new SmallEntryItem(p.getDisplayName(), new View.OnClickListener() {
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
p.getErrorDialog(mActivity).show();
|
p.startMainActivity(mActivity);
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Failed plugins List
|
||||||
|
final HashMap<String, Plugin> failed = device.getFailedPlugins();
|
||||||
|
if (!failed.isEmpty()) {
|
||||||
|
if (errorHeader == null) {
|
||||||
|
errorHeader = new TextView(mActivity);
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
items.add(new CustomItem(errorHeader));
|
||||||
|
for (String s : failed.keySet()) {
|
||||||
|
final Plugin p = failed.get(s);
|
||||||
|
if (p == null) {
|
||||||
|
items.add(new SmallEntryItem(s));
|
||||||
|
} else {
|
||||||
|
items.add(new SmallEntryItem(p.getDisplayName(), new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
p.getErrorDialog(mActivity).show();
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ListView buttonsList = (ListView) rootView.findViewById(R.id.buttons_list);
|
||||||
|
ListAdapter adapter = new ListAdapter(mActivity, items);
|
||||||
|
buttonsList.setAdapter(adapter);
|
||||||
|
|
||||||
|
mActivity.invalidateOptionsMenu();
|
||||||
|
|
||||||
|
} catch (IllegalStateException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
//Ignore: The activity was closed while we were trying to update it
|
||||||
|
} catch (ConcurrentModificationException e) {
|
||||||
|
Log.e("DeviceActivity", "ConcurrentModificationException");
|
||||||
|
this.run(); //Try again
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ListView buttonsList = (ListView) rootView.findViewById(R.id.buttons_list);
|
|
||||||
ListAdapter adapter = new ListAdapter(mActivity, items);
|
|
||||||
buttonsList.setAdapter(adapter);
|
|
||||||
|
|
||||||
mActivity.invalidateOptionsMenu();
|
|
||||||
|
|
||||||
} catch (IllegalStateException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
//Ignore: The activity was closed while we were trying to update it
|
|
||||||
} catch (ConcurrentModificationException e) {
|
|
||||||
Log.e("DeviceActivity", "ConcurrentModificationException");
|
|
||||||
this.run(); //Try again
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -375,17 +387,7 @@ public class DeviceFragment extends Fragment {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void incomingRequest() {
|
public void incomingRequest() {
|
||||||
mActivity.runOnUiThread(new Runnable() {
|
refreshUI();
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
((TextView) rootView.findViewById(R.id.pair_message)).setText(R.string.pair_requested);
|
|
||||||
rootView.findViewById(R.id.pair_progress).setVisibility(View.GONE);
|
|
||||||
rootView.findViewById(R.id.pair_button).setVisibility(View.GONE);
|
|
||||||
rootView.findViewById(R.id.pair_request).setVisibility(View.VISIBLE);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
NotificationManager notificationManager = (NotificationManager) mActivity.getSystemService(Context.NOTIFICATION_SERVICE);
|
|
||||||
notificationManager.cancel(device.getNotificationId());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -77,7 +77,7 @@ public class PairingFragment extends Fragment implements PairingDeviceItem.Callb
|
|||||||
|
|
||||||
TextView text = new TextView(inflater.getContext());
|
TextView text = new TextView(inflater.getContext());
|
||||||
text.setText(getString(R.string.pairing_description));
|
text.setText(getString(R.string.pairing_description));
|
||||||
text.setPadding(0, 0, 0, (int) (12 * getResources().getDisplayMetrics().density));
|
text.setPadding(0, (int) (16 * getResources().getDisplayMetrics().density), 0, (int) (12 * getResources().getDisplayMetrics().density));
|
||||||
((ListView) rootView).addHeaderView(text);
|
((ListView) rootView).addHeaderView(text);
|
||||||
|
|
||||||
return rootView;
|
return rootView;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user