mirror of
https://github.com/syncthing/syncthing-android.git
synced 2024-11-26 22:31:16 +00:00
This commit is contained in:
parent
eb1266508f
commit
9ecc9d79d8
1 changed files with 21 additions and 9 deletions
|
@ -4,6 +4,7 @@ import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
@ -38,6 +39,8 @@ import java.util.TimerTask;
|
||||||
*/
|
*/
|
||||||
public class DrawerFragment extends Fragment implements View.OnClickListener {
|
public class DrawerFragment extends Fragment implements View.OnClickListener {
|
||||||
|
|
||||||
|
private static final String TAG = "DrawerFragment";
|
||||||
|
|
||||||
private TextView mCpuUsage;
|
private TextView mCpuUsage;
|
||||||
private TextView mRamUsage;
|
private TextView mRamUsage;
|
||||||
private TextView mDownload;
|
private TextView mDownload;
|
||||||
|
@ -206,15 +209,24 @@ public class DrawerFragment extends Fragment implements View.OnClickListener {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private void showQrCode() {
|
private void showQrCode() {
|
||||||
//The QRCode request takes one paramteer called "text", which is the text to be converted to a QRCode.
|
RestApi restApi = mActivity.getApi();
|
||||||
String apiKey = mActivity.getApi().getGui().apiKey;
|
if (restApi == null) {
|
||||||
String deviceId = mActivity.getApi().getLocalDevice().deviceID;
|
Toast.makeText(mActivity, R.string.syncthing_terminated, Toast.LENGTH_SHORT).show();
|
||||||
URL url = mActivity.getApi().getUrl();
|
return;
|
||||||
new ImageGetRequest(mActivity, url, ImageGetRequest.QR_CODE_GENERATOR, apiKey,
|
}
|
||||||
ImmutableMap.of("text", deviceId),qrCodeBitmap -> {
|
try {
|
||||||
mActivity.showQrCodeDialog(deviceId, qrCodeBitmap);
|
String apiKey = restApi.getGui().apiKey;
|
||||||
mActivity.closeDrawer();
|
String deviceId = restApi.getLocalDevice().deviceID;
|
||||||
}, error -> Toast.makeText(mActivity, R.string.could_not_access_deviceid, Toast.LENGTH_SHORT).show());
|
URL url = restApi.getUrl();
|
||||||
|
//The QRCode request takes one paramteer called "text", which is the text to be converted to a QRCode.
|
||||||
|
new ImageGetRequest(mActivity, url, ImageGetRequest.QR_CODE_GENERATOR, apiKey,
|
||||||
|
ImmutableMap.of("text", deviceId),qrCodeBitmap -> {
|
||||||
|
mActivity.showQrCodeDialog(deviceId, qrCodeBitmap);
|
||||||
|
mActivity.closeDrawer();
|
||||||
|
}, error -> Toast.makeText(mActivity, R.string.could_not_access_deviceid, Toast.LENGTH_SHORT).show());
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.e(TAG, "showQrCode", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue