Skip to content

Commit

Permalink
Get file and URI associations working on Android.
Browse files Browse the repository at this point in the history
  • Loading branch information
wcjohns committed Oct 15, 2022
1 parent 87d8427 commit 94ccb95
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 34 deletions.
9 changes: 7 additions & 2 deletions src/MultimediaDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@
using namespace std;
using namespace Wt;

#if( ANDROID )
// Defined in target/android/android.cpp
extern void android_download_workaround( Wt::WResource *resource, std::string description );
#endif

namespace
{

Expand Down Expand Up @@ -157,8 +162,8 @@ class MultimediaDisplay : public WContainerWidget

#if( ANDROID )
// Using hacked saving to temporary file in Android, instead of via network download of file.
m_download->clicked().connect( std::bind([downloadResource](){
android_download_workaround(downloadResource, "image_from_spec_file");
m_download->clicked().connect( std::bind([this](){
android_download_workaround(m_resource, "image_from_spec_file");
}) );
#endif //ANDROID
#endif
Expand Down
2 changes: 2 additions & 0 deletions target/android/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ set(TRY_TO_STATIC_LINK ON CACHE INTERNAL "" )
set(MAX_SPECTRUM_MEMMORY_SIZE_MB 32 CACHE INTERNAL "" )
set(USE_DB_TO_STORE_SPECTRA ON CACHE INTERNAL "" )
set(USE_SPECRUM_FILE_QUERY_WIDGET OFF CACHE INTERNAL "" )
# Building the RelAct tool currently fails for Android because of erroring finding Eigen (which should be fetched) - I didnt spend time trying to fix.
set(USE_REL_ACT_TOOL OFF CACHE INTERNAL "" )


message( "ANDROID_NDK_SYSROOT=${ANDROID_NDK_SYSROOT}")
Expand Down
110 changes: 80 additions & 30 deletions target/android/InterSpec/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,50 +50,100 @@ ExecutorService myExecutor = Executors.newCachedThreadPool();
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>

<intent-filter
android:icon='@mipmap/ic_launcher'
android:label='Gamma Spectrum File'
android:priority='1'>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.EDIT" />
<action android:name="android.intent.action.PICK" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="file" />
<data android:host="*" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:mimeType="*/*" />
<data android:pathPattern=".*\\.n42" />
<data android:pathPattern=".*\\.spc" />
<data android:pathPattern=".*\\.dat" />
<data android:pathPattern=".*\\.pcf" />
<data android:pathPattern=".*\\.chn" />
<data android:pathPattern=".*\\.iaea" />
<data android:pathPattern=".*\\.cnf" />
<data android:pathPattern=".*\\.spe" />
<data android:pathPattern=".*\\.N42" />
<data android:pathPattern=".*\\.SPC" />
<data android:pathPattern=".*\\.DAT" />
<data android:pathPattern=".*\\.PCF" />
<data android:pathPattern=".*\\.CHN" />
<data android:pathPattern=".*\\.IAEA" />
<data android:pathPattern=".*\\.CNF" />
<data android:pathPattern=".*\\.SPE" />
<data android:scheme="file" android:pathPattern="*.n42" />
<data android:scheme="content" android:pathPattern="*.n42" />

<data android:scheme="file" android:pathPattern="*.spc" />
<data android:scheme="content" android:pathPattern="*.spc" />

<data android:scheme="file" android:pathPattern="*.dat" />
<data android:scheme="content" android:pathPattern="*.dat" />

<data android:scheme="file" android:pathPattern="*.pcf" />
<data android:scheme="content" android:pathPattern="*.pcf" />

<data android:scheme="file" android:pathPattern="*.chn" />
<data android:scheme="content" android:pathPattern="*.chn" />

<data android:scheme="file" android:pathPattern="*.iaea" />
<data android:scheme="content" android:pathPattern="*.iaea" />

<data android:scheme="file" android:pathPattern="*.cnf" />
<data android:scheme="content" android:pathPattern="*.cnf" />

<data android:scheme="file" android:pathPattern="*.spe" />
<data android:scheme="content" android:pathPattern="*.spe" />

<data android:scheme="file" android:pathPattern="*.tka" />
<data android:scheme="content" android:pathPattern="*.tka" />

<data android:scheme="file" android:pathPattern="*.spm" />
<data android:scheme="content" android:pathPattern="*.spm" />

<data android:scheme="file" android:pathPattern="*.mps" />
<data android:scheme="content" android:pathPattern="*.mps" />

<data android:scheme="file" android:pathPattern="*.gam" />
<data android:scheme="content" android:pathPattern="*.gam" />

<data android:scheme="file" android:pathPattern="*.lis" />
<data android:scheme="content" android:pathPattern="*.lis" />

<data android:scheme="file" android:pathPattern="*.mca" />
<data android:scheme="content" android:pathPattern="*.mca" />

<data android:scheme="file" android:pathPattern="*.lzs" />
<data android:scheme="content" android:pathPattern="*.lzs" />

<data android:scheme="file" android:pathPattern="*.icd" />
<data android:scheme="content" android:pathPattern="*.icd" />

<data android:scheme="file" android:pathPattern="*.icd1" />
<data android:scheme="content" android:pathPattern="*.icd1" />
</intent-filter>


<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.EDIT" />
<action android:name="android.intent.action.PICK" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.SELECTED_ALTERNATIVE" />
<data android:scheme="file" />
<data android:host="*" />
<data android:mimeType="*/*" />
<data android:pathPattern=".*\\.txt" />
<data android:pathPattern=".*\\.csv" />
<data android:pathPattern=".*\\.xml" />
<data android:pathPattern=".*\\.TXT" />
<data android:pathPattern=".*\\.CSV" />
<data android:pathPattern=".*\\.XML" />
<data android:pathPattern=".*\\.zip" />

<data android:scheme="file" android:pathPattern="*.txt" />
<data android:scheme="content" android:pathPattern="*.txt" />

<data android:scheme="file" android:pathPattern="*.csv" />
<data android:scheme="content" android:pathPattern="*.csv" />

<data android:scheme="file" android:pathPattern="*.xml" />
<data android:scheme="content" android:pathPattern="*.xml" />

<data android:scheme="file" android:pathPattern="*.zip" />
<data android:scheme="content" android:pathPattern="*.zip" />
</intent-filter>

<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<action android:name="android.intent.action.EDIT" />
<action android:name="android.intent.action.PICK" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="interspec" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="interspec" android:host="drf" android:pathPrefix="/" />
<data android:scheme="interspec" android:host="decay" android:pathPrefix="/" />
</intent-filter>

<!-- Splash screen -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,12 @@ public boolean shouldOverrideUrlLoading(WebView view, String url){



if( Intent.ACTION_VIEW.equals(action) )
if( Intent.ACTION_VIEW.equals(action)
|| Intent.ACTION_EDIT.equals(action)
|| Intent.ACTION_PICK.equals(action)
|| Intent.ACTION_DEFAULT.equals(action)
//|| Intent.ACTION_BROWSABLE.equals(action)
)
{
Log.d("onCreate", "ACTION_VIEW: Will set initial file to load at start");
Uri fileUri = (Uri) intent.getData();
Expand Down Expand Up @@ -759,7 +764,12 @@ protected void onNewIntent( Intent intent )
String action = intent.getAction();
String type = intent.getType();

if( Intent.ACTION_VIEW.equals(action) )
if( Intent.ACTION_VIEW.equals(action)
|| Intent.ACTION_EDIT.equals(action)
|| Intent.ACTION_PICK.equals(action)
|| Intent.ACTION_DEFAULT.equals(action)
//|| Intent.ACTION_BROWSABLE.equals(action)
)
{
Uri fileUri = (Uri) intent.getData();

Expand Down

0 comments on commit 94ccb95

Please sign in to comment.