-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support scanning QR Code for receiving files
QR Codes can be generated from the wormwhole-william cli tool via the `--qr` flag. The code embeds the relay url, but currently we are ignoring that and just using the relay set in the config. Closes: #7 [via git-merge-pr]
- Loading branch information
Showing
7 changed files
with
196 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
android/src/main/java/io/sanford/wormholewilliam/Scan.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package io.sanford.wormholewilliam; | ||
|
||
import android.app.Activity; | ||
import android.app.Fragment; | ||
import android.app.FragmentTransaction; | ||
import android.content.Context; | ||
import android.content.Intent; | ||
import android.os.Handler; | ||
import android.util.Log; | ||
import android.view.View; | ||
import com.google.zxing.integration.android.IntentIntegrator; | ||
import com.google.zxing.integration.android.IntentResult; | ||
import java.lang.String; | ||
|
||
public class Scan extends Fragment { | ||
public Scan() { | ||
} | ||
|
||
public void register(View view) { | ||
Context ctx = view.getContext(); | ||
Handler handler = new Handler(ctx.getMainLooper()); | ||
Scan inst = this; | ||
handler.post(new Runnable() { | ||
public void run() { | ||
Activity act = (Activity)ctx; | ||
FragmentTransaction ft = act.getFragmentManager().beginTransaction(); | ||
ft.add(inst, "Scan"); | ||
ft.commitNow(); | ||
} | ||
}); | ||
} | ||
|
||
@Override public void onAttach(Context ctx) { | ||
super.onAttach(ctx); | ||
|
||
IntentIntegrator integrator = IntentIntegrator.forFragment(this); | ||
integrator.setDesiredBarcodeFormats(IntentIntegrator.QR_CODE_TYPES); | ||
integrator.setPrompt("Scan"); | ||
integrator.setCameraId(0); | ||
integrator.setBeepEnabled(false); | ||
integrator.setBarcodeImageEnabled(false); | ||
integrator.initiateScan(); | ||
} | ||
|
||
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { | ||
IntentResult result = IntentIntegrator.parseActivityResult(requestCode, resultCode, data); | ||
if(result != null) { | ||
Log.d("wormhole", "Scan.onActivityResult() " + result.getContents()); | ||
scanResult(result.getContents()); | ||
} | ||
} | ||
|
||
static private native void scanResult(String contents); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters