diff --git a/CloudRailTest/.gitignore b/CloudRailTest/.gitignore new file mode 100644 index 00000000..9c4de582 --- /dev/null +++ b/CloudRailTest/.gitignore @@ -0,0 +1,7 @@ +.gradle +/local.properties +/.idea/workspace.xml +/.idea/libraries +.DS_Store +/build +/captures diff --git a/CloudRailTest/.idea/.name b/CloudRailTest/.idea/.name new file mode 100644 index 00000000..81504251 --- /dev/null +++ b/CloudRailTest/.idea/.name @@ -0,0 +1 @@ +CloudRailTest \ No newline at end of file diff --git a/CloudRailTest/.idea/compiler.xml b/CloudRailTest/.idea/compiler.xml new file mode 100644 index 00000000..9a8b7e5c --- /dev/null +++ b/CloudRailTest/.idea/compiler.xml @@ -0,0 +1,22 @@ + + + + + \ No newline at end of file diff --git a/CloudRailTest/.idea/copyright/profiles_settings.xml b/CloudRailTest/.idea/copyright/profiles_settings.xml new file mode 100644 index 00000000..e7bedf33 --- /dev/null +++ b/CloudRailTest/.idea/copyright/profiles_settings.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/CloudRailTest/.idea/encodings.xml b/CloudRailTest/.idea/encodings.xml new file mode 100644 index 00000000..97626ba4 --- /dev/null +++ b/CloudRailTest/.idea/encodings.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/CloudRailTest/.idea/gradle.xml b/CloudRailTest/.idea/gradle.xml new file mode 100644 index 00000000..508b3d9b --- /dev/null +++ b/CloudRailTest/.idea/gradle.xml @@ -0,0 +1,23 @@ + + + + + + \ No newline at end of file diff --git a/CloudRailTest/.idea/misc.xml b/CloudRailTest/.idea/misc.xml new file mode 100644 index 00000000..6a1e020d --- /dev/null +++ b/CloudRailTest/.idea/misc.xml @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/CloudRailTest/.idea/modules.xml b/CloudRailTest/.idea/modules.xml new file mode 100644 index 00000000..10bb27d1 --- /dev/null +++ b/CloudRailTest/.idea/modules.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/CloudRailTest/.idea/runConfigurations.xml b/CloudRailTest/.idea/runConfigurations.xml new file mode 100644 index 00000000..7f68460d --- /dev/null +++ b/CloudRailTest/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/CloudRailTest/CloudRailTest.iml b/CloudRailTest/CloudRailTest.iml new file mode 100644 index 00000000..6ae1beaa --- /dev/null +++ b/CloudRailTest/CloudRailTest.iml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/CloudRailTest/app/.gitignore b/CloudRailTest/app/.gitignore new file mode 100644 index 00000000..796b96d1 --- /dev/null +++ b/CloudRailTest/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/CloudRailTest/app/app.iml b/CloudRailTest/app/app.iml new file mode 100644 index 00000000..4ac4d21a --- /dev/null +++ b/CloudRailTest/app/app.iml @@ -0,0 +1,116 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/CloudRailTest/app/build.gradle b/CloudRailTest/app/build.gradle new file mode 100644 index 00000000..d169dce7 --- /dev/null +++ b/CloudRailTest/app/build.gradle @@ -0,0 +1,35 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 23 + buildToolsVersion "23.0.2" + + defaultConfig { + applicationId "com.survivingwithandroid.cloudrail" + minSdkVersion 19 + targetSdkVersion 23 + versionCode 1 + versionName "1.0" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } +} + +repositories { + maven { + url "http://maven.cloudrail.com" + } +} + +dependencies { + compile fileTree(dir: 'libs', include: ['*.jar']) + testCompile 'junit:junit:4.12' + compile 'com.android.support:appcompat-v7:23.3.0' + compile 'com.android.support:design:23.3.0' + compile 'com.cloudrail:cloudrail-si-android:2.1.0' + compile 'com.nbsp:library:1.08' +} diff --git a/CloudRailTest/app/proguard-rules.pro b/CloudRailTest/app/proguard-rules.pro new file mode 100644 index 00000000..9bab71a9 --- /dev/null +++ b/CloudRailTest/app/proguard-rules.pro @@ -0,0 +1,17 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in /Android/android-sdk-macosx/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the proguardFiles +# directive in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} diff --git a/CloudRailTest/app/src/androidTest/java/com/survivingwithandroid/cloudrail/ApplicationTest.java b/CloudRailTest/app/src/androidTest/java/com/survivingwithandroid/cloudrail/ApplicationTest.java new file mode 100644 index 00000000..4e03dc81 --- /dev/null +++ b/CloudRailTest/app/src/androidTest/java/com/survivingwithandroid/cloudrail/ApplicationTest.java @@ -0,0 +1,13 @@ +package com.survivingwithandroid.cloudrail; + +import android.app.Application; +import android.test.ApplicationTestCase; + +/** + * Testing Fundamentals + */ +public class ApplicationTest extends ApplicationTestCase { + public ApplicationTest() { + super(Application.class); + } +} \ No newline at end of file diff --git a/CloudRailTest/app/src/main/AndroidManifest.xml b/CloudRailTest/app/src/main/AndroidManifest.xml new file mode 100644 index 00000000..0f068ca1 --- /dev/null +++ b/CloudRailTest/app/src/main/AndroidManifest.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/CloudRailTest/app/src/main/java/com/survivingwithandroid/cloudrail/MainActivity.java b/CloudRailTest/app/src/main/java/com/survivingwithandroid/cloudrail/MainActivity.java new file mode 100644 index 00000000..896fcbd1 --- /dev/null +++ b/CloudRailTest/app/src/main/java/com/survivingwithandroid/cloudrail/MainActivity.java @@ -0,0 +1,163 @@ +package com.survivingwithandroid.cloudrail; + +import android.content.Intent; +import android.os.Bundle; +import android.support.design.widget.FloatingActionButton; +import android.support.design.widget.Snackbar; +import android.support.v7.app.AppCompatActivity; +import android.support.v7.widget.Toolbar; +import android.view.View; +import android.view.Menu; +import android.view.MenuItem; +import android.widget.Toast; + +import com.cloudrail.si.interfaces.CloudStorage; +import com.cloudrail.si.services.Box; +import com.cloudrail.si.services.Dropbox; +import com.cloudrail.si.services.GoogleDrive; +import com.nbsp.materialfilepicker.ui.FilePickerActivity; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.regex.Pattern; + +/* + * Copyright (C) 2016 Francesco Azzola + * Surviving with Android (http://www.survivingwithandroid.com) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +public class MainActivity extends AppCompatActivity { + + static int REQUEST_FILE = 10; + private CloudStorage cs; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); + setSupportActionBar(toolbar); + + FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); + fab.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + Intent intent = new Intent(MainActivity.this, FilePickerActivity.class); + intent.putExtra(FilePickerActivity.ARG_FILE_FILTER, Pattern.compile(".*\\.jpg$")); + intent.putExtra(FilePickerActivity.ARG_DIRECTORIES_FILTER, false); + intent.putExtra(FilePickerActivity.ARG_SHOW_HIDDEN, true); + startActivityForResult(intent, 1); + } + }); + + // Let's init dropBox + // cs = getDropBoxStorage(); + + + // Let's init Box + //cs = getBoxStorage(); + + // Let's init Google drive + cs = getGoogleDriveStorage(); + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + // Inflate the menu; this adds items to the action bar if it is present. + getMenuInflater().inflate(R.menu.menu_main, menu); + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + // Handle action bar item clicks here. The action bar will + // automatically handle clicks on the Home/Up button, so long + // as you specify a parent activity in AndroidManifest.xml. + int id = item.getItemId(); + + //noinspection SimplifiableIfStatement + if (id == R.id.action_settings) { + return true; + } + + return super.onOptionsItemSelected(item); + } + + + @Override + public void onActivityResult(int requestCode, int resultCode, Intent data) { + super.onActivityResult(requestCode, resultCode, data); + + if (requestCode == 1 && resultCode == RESULT_OK) { + String filePath = data.getStringExtra(FilePickerActivity.RESULT_FILE_PATH); + Toast.makeText(this, "File path ["+filePath+"]", Toast.LENGTH_LONG).show(); + uploadFile(filePath); + } + } + + private CloudStorage getDropBoxStorage() { + CloudStorage cs = new Dropbox(this, + getResources().getString(R.string.dropBoxClient), + getResources().getString(R.string.dropBoxSecretKey)); + + return cs; + } + + private CloudStorage getBoxStorage() { + CloudStorage cs = new Box(this, getResources().getString(R.string.boxClientId), + getResources().getString(R.string.boxSecretKey)); + + return cs; + } + + private CloudStorage getGoogleDriveStorage() { + CloudStorage cs = new GoogleDrive(this, getResources().getString(R.string.googleClientId), + getResources().getString(R.string.googleSecretKey)); + + return cs; + } + + private void uploadFile(final String path) { + + + new Thread() { + @Override + public void run() { + // Get asset + + InputStream is; + + try { + File f = new File(path); + String name = f.getName(); + is = new FileInputStream(f); + + long size = f.length(); + + + + System.out.println("IS ["+is+"] - Size ["+size+"]"); + cs.upload("/" + name, is, size, true); + + } + catch(IOException ioe) { + ioe.printStackTrace(); + } + } + }.start(); + } +} diff --git a/CloudRailTest/app/src/main/res/drawable-hdpi/ic_add_white_24dp.png b/CloudRailTest/app/src/main/res/drawable-hdpi/ic_add_white_24dp.png new file mode 100644 index 00000000..694179bd Binary files /dev/null and b/CloudRailTest/app/src/main/res/drawable-hdpi/ic_add_white_24dp.png differ diff --git a/CloudRailTest/app/src/main/res/drawable-mdpi/ic_add_white_24dp.png b/CloudRailTest/app/src/main/res/drawable-mdpi/ic_add_white_24dp.png new file mode 100644 index 00000000..3856041d Binary files /dev/null and b/CloudRailTest/app/src/main/res/drawable-mdpi/ic_add_white_24dp.png differ diff --git a/CloudRailTest/app/src/main/res/drawable-xhdpi/ic_add_white_24dp.png b/CloudRailTest/app/src/main/res/drawable-xhdpi/ic_add_white_24dp.png new file mode 100644 index 00000000..67bb598e Binary files /dev/null and b/CloudRailTest/app/src/main/res/drawable-xhdpi/ic_add_white_24dp.png differ diff --git a/CloudRailTest/app/src/main/res/drawable-xxhdpi/ic_add_white_24dp.png b/CloudRailTest/app/src/main/res/drawable-xxhdpi/ic_add_white_24dp.png new file mode 100644 index 00000000..0fdced8f Binary files /dev/null and b/CloudRailTest/app/src/main/res/drawable-xxhdpi/ic_add_white_24dp.png differ diff --git a/CloudRailTest/app/src/main/res/drawable-xxxhdpi/ic_add_white_24dp.png b/CloudRailTest/app/src/main/res/drawable-xxxhdpi/ic_add_white_24dp.png new file mode 100644 index 00000000..d64c22e9 Binary files /dev/null and b/CloudRailTest/app/src/main/res/drawable-xxxhdpi/ic_add_white_24dp.png differ diff --git a/CloudRailTest/app/src/main/res/layout/activity_main.xml b/CloudRailTest/app/src/main/res/layout/activity_main.xml new file mode 100644 index 00000000..04bfe45f --- /dev/null +++ b/CloudRailTest/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + diff --git a/CloudRailTest/app/src/main/res/layout/content_main.xml b/CloudRailTest/app/src/main/res/layout/content_main.xml new file mode 100644 index 00000000..b355ae7a --- /dev/null +++ b/CloudRailTest/app/src/main/res/layout/content_main.xml @@ -0,0 +1,19 @@ + + + + + diff --git a/CloudRailTest/app/src/main/res/menu/menu_main.xml b/CloudRailTest/app/src/main/res/menu/menu_main.xml new file mode 100644 index 00000000..a47007dd --- /dev/null +++ b/CloudRailTest/app/src/main/res/menu/menu_main.xml @@ -0,0 +1,10 @@ + + + diff --git a/CloudRailTest/app/src/main/res/mipmap-hdpi/ic_launcher.png b/CloudRailTest/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 00000000..cde69bcc Binary files /dev/null and b/CloudRailTest/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/CloudRailTest/app/src/main/res/mipmap-mdpi/ic_launcher.png b/CloudRailTest/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 00000000..c133a0cb Binary files /dev/null and b/CloudRailTest/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/CloudRailTest/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/CloudRailTest/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 00000000..bfa42f0e Binary files /dev/null and b/CloudRailTest/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/CloudRailTest/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/CloudRailTest/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 00000000..324e72cd Binary files /dev/null and b/CloudRailTest/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/CloudRailTest/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/CloudRailTest/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 00000000..aee44e13 Binary files /dev/null and b/CloudRailTest/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/CloudRailTest/app/src/main/res/values-v21/styles.xml b/CloudRailTest/app/src/main/res/values-v21/styles.xml new file mode 100644 index 00000000..dbbdd40f --- /dev/null +++ b/CloudRailTest/app/src/main/res/values-v21/styles.xml @@ -0,0 +1,9 @@ + + + + diff --git a/CloudRailTest/app/src/main/res/values-w820dp/dimens.xml b/CloudRailTest/app/src/main/res/values-w820dp/dimens.xml new file mode 100644 index 00000000..63fc8164 --- /dev/null +++ b/CloudRailTest/app/src/main/res/values-w820dp/dimens.xml @@ -0,0 +1,6 @@ + + + 64dp + diff --git a/CloudRailTest/app/src/main/res/values/colors.xml b/CloudRailTest/app/src/main/res/values/colors.xml new file mode 100644 index 00000000..3ab3e9cb --- /dev/null +++ b/CloudRailTest/app/src/main/res/values/colors.xml @@ -0,0 +1,6 @@ + + + #3F51B5 + #303F9F + #FF4081 + diff --git a/CloudRailTest/app/src/main/res/values/dimens.xml b/CloudRailTest/app/src/main/res/values/dimens.xml new file mode 100644 index 00000000..812cb7be --- /dev/null +++ b/CloudRailTest/app/src/main/res/values/dimens.xml @@ -0,0 +1,6 @@ + + + 16dp + 16dp + 16dp + diff --git a/CloudRailTest/app/src/main/res/values/strings.xml b/CloudRailTest/app/src/main/res/values/strings.xml new file mode 100644 index 00000000..d2716dcd --- /dev/null +++ b/CloudRailTest/app/src/main/res/values/strings.xml @@ -0,0 +1,13 @@ + + CloudRailTest + Settings + + 97yiz4w3x42ve8i + 677e6fp5s6prqp8 + + 612951681764-nqp1bstmjo7blq0e68155a6rpqodrg8i.apps.googleusercontent.com + Ni_HPkQiyrDFS2nHAWg6fk5_ + + 260b9kel607r45mgxmc236b2mmyltsx8 + ilUKNOx7QmHfMUVvMe2t6dk2ciS1xxr6 + diff --git a/CloudRailTest/app/src/main/res/values/styles.xml b/CloudRailTest/app/src/main/res/values/styles.xml new file mode 100644 index 00000000..545b9c6d --- /dev/null +++ b/CloudRailTest/app/src/main/res/values/styles.xml @@ -0,0 +1,20 @@ + + + + + + + +