-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Write a new file anywhere in the android device.
- Loading branch information
1 parent
ae38205
commit 6b05240
Showing
18 changed files
with
657 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# This file is used to ignore files which are generated | ||
# ---------------------------------------------------------------------------- | ||
|
||
*~ | ||
*.autosave | ||
*.a | ||
*.core | ||
*.moc | ||
*.o | ||
*.obj | ||
*.orig | ||
*.rej | ||
*.so | ||
*.so.* | ||
*_pch.h.cpp | ||
*_resource.rc | ||
*.qm | ||
.#* | ||
*.*# | ||
core | ||
!core/ | ||
tags | ||
.DS_Store | ||
*.debug | ||
Makefile* | ||
*.prl | ||
*.app | ||
moc_*.cpp | ||
ui_*.h | ||
qrc_*.cpp | ||
Thumbs.db | ||
*.res | ||
*.rc | ||
/.qmake.cache | ||
/.qmake.stash | ||
|
||
# qtcreator generated files | ||
*.pro.user* | ||
|
||
# xemacs temporary files | ||
*.flc | ||
|
||
# Vim temporary files | ||
.*.swp | ||
|
||
# Visual Studio generated files | ||
*.ib_pdb_index | ||
*.idb | ||
*.ilk | ||
*.pdb | ||
*.sln | ||
*.suo | ||
*.vcproj | ||
*vcproj.*.*.user | ||
*.ncb | ||
*.sdf | ||
*.opensdf | ||
*.vcxproj | ||
*vcxproj.* | ||
|
||
# MinGW generated files | ||
*.Debug | ||
*.Release | ||
|
||
# Python byte code | ||
*.pyc | ||
|
||
# Binaries | ||
# -------- | ||
*.dll | ||
*.exe | ||
|
||
|
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,33 @@ | ||
TEMPLATE = app | ||
TARGET = AndroidUSBAccess | ||
|
||
QT += qml quick network | ||
CONFIG += c++11 | ||
|
||
SOURCES += main.cpp | ||
|
||
android { | ||
QT += androidextras | ||
OTHER_FILES += android/src/fr/jbflamant/androidusbaccess/HardwareUtils.java | ||
ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android | ||
SOURCES += android/HardwareUtils_Android.cpp | ||
HEADERS += android/HardwareUtils_Android.h | ||
} | ||
|
||
RESOURCES += qml.qrc | ||
|
||
# Additional import path used to resolve QML modules in Qt Creator's code model | ||
QML_IMPORT_PATH = | ||
|
||
# Default rules for deployment. | ||
include(deployment.pri) | ||
|
||
DISTFILES += \ | ||
android/AndroidManifest.xml \ | ||
android/gradle/wrapper/gradle-wrapper.jar \ | ||
android/gradlew \ | ||
android/res/values/libs.xml \ | ||
android/build.gradle \ | ||
android/gradle/wrapper/gradle-wrapper.properties \ | ||
android/gradlew.bat | ||
|
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,19 @@ | ||
import QtQuick 2.5 | ||
|
||
Rectangle { | ||
property alias mouseArea: mouseArea | ||
|
||
width: 360 | ||
height: 360 | ||
|
||
MouseArea { | ||
id: mouseArea | ||
anchors.fill: parent | ||
} | ||
|
||
Text { | ||
anchors.centerIn: parent | ||
text: "Hello World" | ||
} | ||
} | ||
|
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,5 @@ | ||
This project is an android application made with Qt. | ||
|
||
It permits to write a file on any external device connected to the Android device. | ||
|
||
|
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,59 @@ | ||
<?xml version="1.0"?> | ||
<manifest package="fr.jbflamant.androidusbaccess" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="1.0" android:versionCode="1" android:installLocation="auto"> | ||
<application android:hardwareAccelerated="true" android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="@string/app_name" android:icon="@drawable/icon"> | ||
<activity android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation" android:name="org.qtproject.qt5.android.bindings.QtActivity" android:label="@string/app_name" android:screenOrientation="unspecified" android:launchMode="singleTop"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN"/> | ||
<category android:name="android.intent.category.LAUNCHER"/> | ||
</intent-filter> | ||
<meta-data android:name="android.app.lib_name" android:value="AndroidUSBAccess"/> | ||
<meta-data android:name="android.app.qt_sources_resource_id" android:resource="@array/qt_sources"/> | ||
<meta-data android:name="android.app.repository" android:value="default"/> | ||
<meta-data android:name="android.app.qt_libs_resource_id" android:resource="@array/qt_libs"/> | ||
<meta-data android:name="android.app.bundled_libs_resource_id" android:resource="@array/bundled_libs"/> | ||
<!-- Deploy Qt libs as part of package --> | ||
<meta-data android:name="android.app.bundle_local_qt_libs" android:value="-- %%BUNDLE_LOCAL_QT_LIBS%% --"/> | ||
<meta-data android:name="android.app.bundled_in_lib_resource_id" android:resource="@array/bundled_in_lib"/> | ||
<meta-data android:name="android.app.bundled_in_assets_resource_id" android:resource="@array/bundled_in_assets"/> | ||
<!-- Run with local libs --> | ||
<meta-data android:name="android.app.use_local_qt_libs" android:value="-- %%USE_LOCAL_QT_LIBS%% --"/> | ||
<meta-data android:name="android.app.libs_prefix" android:value="/data/local/tmp/qt/"/> | ||
<meta-data android:name="android.app.load_local_libs" android:value="-- %%INSERT_LOCAL_LIBS%% --"/> | ||
<meta-data android:name="android.app.load_local_jars" android:value="-- %%INSERT_LOCAL_JARS%% --"/> | ||
<meta-data android:name="android.app.static_init_classes" android:value="-- %%INSERT_INIT_CLASSES%% --"/> | ||
<!-- Messages maps --> | ||
<meta-data android:value="@string/ministro_not_found_msg" android:name="android.app.ministro_not_found_msg"/> | ||
<meta-data android:value="@string/ministro_needed_msg" android:name="android.app.ministro_needed_msg"/> | ||
<meta-data android:value="@string/fatal_error_msg" android:name="android.app.fatal_error_msg"/> | ||
<!-- Messages maps --> | ||
|
||
<!-- Splash screen --> | ||
<!-- | ||
<meta-data android:name="android.app.splash_screen_drawable" android:resource="@drawable/logo"/> | ||
--> | ||
<!-- Splash screen --> | ||
|
||
<!-- Background running --> | ||
<!-- Warning: changing this value to true may cause unexpected crashes if the | ||
application still try to draw after | ||
"applicationStateChanged(Qt::ApplicationSuspended)" | ||
signal is sent! --> | ||
<meta-data android:name="android.app.background_running" android:value="false"/> | ||
<!-- Background running --> | ||
</activity> | ||
</application> | ||
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="14"/> | ||
<supports-screens android:largeScreens="true" android:normalScreens="true" android:anyDensity="true" android:smallScreens="true"/> | ||
|
||
<!-- The following comment will be replaced upon deployment with default permissions based on the dependencies of the application. | ||
Remove the comment if you do not require these default permissions. --> | ||
<!-- %%INSERT_PERMISSIONS --> | ||
|
||
<!-- The following comment will be replaced upon deployment with default features based on the dependencies of the application. | ||
Remove the comment if you do not require these default features. --> | ||
<!-- %%INSERT_FEATURES --> | ||
|
||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> | ||
<uses-permission android:name="android.permission.INTERNET"/> | ||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> | ||
</manifest> |
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,51 @@ | ||
|
||
#include "HardwareUtils_Android.h" | ||
#include <QtAndroid> | ||
#include <jni.h> | ||
|
||
#include <QDebug> | ||
|
||
HardwareUtilsAndroid *HardwareUtilsAndroid::Instance(QObject *parent) { | ||
static HardwareUtilsAndroid *instance = NULL; | ||
|
||
if(!instance) { | ||
instance = new HardwareUtilsAndroid(parent); | ||
} | ||
|
||
return instance; | ||
} | ||
|
||
HardwareUtilsAndroid::HardwareUtilsAndroid(QObject *parent): | ||
QObject(parent) | ||
{ | ||
} | ||
|
||
HardwareUtilsAndroid::~HardwareUtilsAndroid() | ||
{ | ||
} | ||
|
||
bool HardwareUtilsAndroid::writeOnUSB(QString filename) { | ||
m_file.setFileName(filename); | ||
QAndroidJniObject ACTION_CREATE_DOCUMENT = QAndroidJniObject::fromString("android.intent.action.CREATE_DOCUMENT"); | ||
QAndroidJniObject intent("android/content/Intent"); | ||
if (ACTION_CREATE_DOCUMENT.isValid() && intent.isValid()) { | ||
intent.callObjectMethod("setAction", "(Ljava/lang/String;)Landroid/content/Intent;", ACTION_CREATE_DOCUMENT.object<jstring>()); | ||
intent.callObjectMethod("setType", "(Ljava/lang/String;)Landroid/content/Intent;", QAndroidJniObject::fromString("application/*").object<jstring>()); | ||
QtAndroid::startActivity(intent.object<jobject>(), 123, this); | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
} | ||
|
||
void HardwareUtilsAndroid::handleActivityResult(int receiverRequestCode, int resultCode, const QAndroidJniObject & data) { | ||
qDebug() << "Receive activity result"; | ||
|
||
jint RESULT_OK = QAndroidJniObject::getStaticField<jint>("android/app/Activity", "RESULT_OK"); | ||
if (receiverRequestCode == 123 && resultCode == RESULT_OK) { | ||
QString path = data.callObjectMethod("getData", "()Landroid/net/Uri;").callObjectMethod("getPath", "()Ljava/lang/String;").toString(); | ||
qDebug() << "Destination path : " << path; | ||
} else { | ||
qDebug() << "Destination path is empty "; | ||
} | ||
} |
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,26 @@ | ||
#ifndef HARDWAREUTILS_ANDROID_H | ||
#define HARDWAREUTILS_ANDROID_H | ||
|
||
#include <QObject> | ||
#include <QAndroidActivityResultReceiver> | ||
#include <QtAndroidExtras/QAndroidJniObject> | ||
#include <QtAndroidExtras/QAndroidJniEnvironment> | ||
#include <QFile> | ||
|
||
class HardwareUtilsAndroid: public QObject, public QAndroidActivityResultReceiver | ||
{ | ||
private: | ||
HardwareUtilsAndroid(QObject *parent = 0); | ||
|
||
public: | ||
virtual ~HardwareUtilsAndroid(); | ||
static HardwareUtilsAndroid* Instance(QObject *parent = 0); | ||
|
||
virtual void handleActivityResult(int receiverRequestCode, int resultCode, const QAndroidJniObject & data); | ||
virtual bool writeOnUSB(QString filename); | ||
|
||
private: | ||
QFile m_file; | ||
}; | ||
|
||
#endif // HARDWAREUTILS_ANDROID_H |
Binary file not shown.
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,6 @@ | ||
#Wed Apr 10 15:27:10 PDT 2013 | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists | ||
distributionUrl=http\://services.gradle.org/distributions/gradle-1.12-all.zip |
Oops, something went wrong.