Commit c2c2c3c2 by Szénási Dániel

initial commit

parents
Pipeline #97 skipped in 0 seconds
# Auto detect text files and perform LF normalization
* text=auto
# Custom for Visual Studio
*.cs diff=csharp
# Standard to msysgit
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
CircleAndroid2
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<resourceExtensions />
<wildcardResourcePatterns>
<entry name="!?*.java" />
<entry name="!?*.form" />
<entry name="!?*.class" />
<entry name="!?*.groovy" />
<entry name="!?*.scala" />
<entry name="!?*.flex" />
<entry name="!?*.kt" />
<entry name="!?*.clj" />
<entry name="!?*.aj" />
</wildcardResourcePatterns>
<annotationProcessing>
<profile default="true" name="Default" enabled="false">
<processorPath useClasspath="true" />
</profile>
</annotationProcessing>
</component>
</project>
\ No newline at end of file
<component name="CopyrightManager">
<settings default="" />
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="PROJECT" charset="UTF-8" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="distributionType" value="LOCAL" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleHome" value="$APPLICATION_HOME_DIR$/gradle/gradle-2.10" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" />
</set>
</option>
<option name="myModules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" />
</set>
</option>
</GradleProjectSettings>
</option>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="EntryPointsManager">
<entry_points version="2.0" />
</component>
<component name="NullableNotNullManager">
<option name="myDefaultNullable" value="android.support.annotation.Nullable" />
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
<option name="myNullables">
<value>
<list size="4">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
</list>
</value>
</option>
<option name="myNotNulls">
<value>
<list size="4">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
</list>
</value>
</option>
</component>
<component name="ProjectLevelVcsManager" settingsEditedManually="false">
<OptionsSetting value="true" id="Add" />
<OptionsSetting value="true" id="Remove" />
<OptionsSetting value="true" id="Checkout" />
<OptionsSetting value="true" id="Update" />
<OptionsSetting value="true" id="Status" />
<OptionsSetting value="true" id="Edit" />
<ConfirmationsSetting value="0" id="Add" />
<ConfirmationsSetting value="0" id="Remove" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
<option name="id" value="Android" />
</component>
<component name="masterDetails">
<states>
<state key="ProjectJDKs.UI">
<settings>
<last-edited>1.8</last-edited>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
</states>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/CircleAndroid2.iml" filepath="$PROJECT_DIR$/CircleAndroid2.iml" />
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RunConfigurationProducerService">
<option name="ignoredProducers">
<set>
<option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
</set>
</option>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
buildscript {
repositories {
mavenCentral()
maven { url 'https://plugins.gradle.org/m2/' }
maven { url 'http://jcenter.bintray.com/' }
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
}
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "hu.bme.dszenasi.circleandroid"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/maven/com.squareup.retrofit/retrofit/pom.properties'
exclude 'META-INF/maven/com.squareup.retrofit/retrofit/pom.xml'
}
}
repositories {
mavenCentral()
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
apt 'com.google.dagger:dagger-compiler:2.0.2'
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.android.support:design:23.3.0'
compile 'com.android.support:cardview-v7:23.3.0'
compile 'com.google.dagger:dagger:2.0.2'
provided 'org.glassfish:javax.annotation:10.0-b28'
compile ('com.squareup.retrofit2:retrofit:2.0.2') {
exclude module: 'okhttp'
}
compile 'com.squareup.okhttp3:okhttp:3.2.0'
compile 'com.squareup.okhttp3:okhttp-urlconnection:3.2.0'
compile 'com.squareup.retrofit2:adapter-rxjava:2.0.0'
compile 'io.reactivex:rxandroid:1.0.1'
compile 'com.squareup.retrofit2:converter-gson:2.0.0'
compile 'com.squareup.retrofit:converter-jackson:2.0.0-beta2'
}
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in C:\sdk/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 *;
#}
package hu.bme.dszenasi.circleandroid;
import android.app.Application;
import android.test.ApplicationTestCase;
/**
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
*/
public class ApplicationTest extends ApplicationTestCase<Application> {
public ApplicationTest() {
super(Application.class);
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="hu.bme.dszenasi.circleandroid">
<!-- To auto-complete the email text field in the login form with the user's emails -->
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.READ_PROFILE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:name="MyApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".login.ui.LoginActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".vmlist.ui.VmListActivity"
android:label="@string/app_name"
/>
<activity
android:name=".managevm.ui.ManageVmActivity"
android:label="@string/app_name"
/>
<activity
android:name=".createvm.ui.CreateVmActivity"
android:label="@string/app_name"
/>
</application>
</manifest>
\ No newline at end of file
package hu.bme.dszenasi.circleandroid;
import android.app.Application;
import android.content.Context;
import android.preference.PreferenceManager;
import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides;
/**
* Created by danielszenasi on 05/05/16.
*/
@Module
public class AppModule {
Application mApplication;
public AppModule(Application application) {
mApplication = application;
}
@Provides
@Singleton
Application providesApplication() {
return mApplication;
}
@Provides
@Singleton
Context providesContext() {
return mApplication;
}
}
\ No newline at end of file
package hu.bme.dszenasi.circleandroid;
import android.app.Application;
import hu.bme.dszenasi.circleandroid.createvm.module.CreateVmComponent;
import hu.bme.dszenasi.circleandroid.createvm.module.CreateVmModule;
import hu.bme.dszenasi.circleandroid.createvm.module.DaggerCreateVmComponent;
import hu.bme.dszenasi.circleandroid.login.module.DaggerLoginComponent;
import hu.bme.dszenasi.circleandroid.login.module.LoginComponent;
import hu.bme.dszenasi.circleandroid.login.module.LoginModule;
import hu.bme.dszenasi.circleandroid.managevm.module.DaggerManageVmComponent;
import hu.bme.dszenasi.circleandroid.managevm.module.ManageVmComponent;
import hu.bme.dszenasi.circleandroid.managevm.module.ManageVmModule;
import hu.bme.dszenasi.circleandroid.vmlist.module.DaggerVmListComponent;
import hu.bme.dszenasi.circleandroid.vmlist.module.VmListComponent;
import hu.bme.dszenasi.circleandroid.vmlist.module.VmListModule;
/**
* Created by mszenasi on 2016-04-26.
*/
public class MyApplication extends Application {
LoginComponent logincomponent;
VmListComponent vmListComponent;
ManageVmComponent manageVmComponent;
CreateVmComponent createVmComponent;
@Override
public void onCreate() {
super.onCreate();
logincomponent = DaggerLoginComponent.builder()
.appModule(new AppModule(this))
.loginModule(new LoginModule("https://vm.ik.bme.hu:1415/"))
.build();
vmListComponent = DaggerVmListComponent.builder()
.appModule(new AppModule(this))
.vmListModule(new VmListModule("https://vm.ik.bme.hu:1415/"))
.build();
manageVmComponent = DaggerManageVmComponent.builder()
.appModule(new AppModule(this))
.manageVmModule(new ManageVmModule("https://vm.ik.bme.hu:1415/"))
.build();
createVmComponent = DaggerCreateVmComponent.builder()
.appModule(new AppModule(this))
.createVmModule(new CreateVmModule("https://vm.ik.bme.hu:1415/"))
.build();
}
public LoginComponent getloginComponent() {
return logincomponent;
}
public ManageVmComponent getManageVmComponent() {
return manageVmComponent;
}
public CreateVmComponent getCreateVmComponent() {
return createVmComponent;
}
public VmListComponent getVmListComponent() {
return vmListComponent;
}
}
\ No newline at end of file
package hu.bme.dszenasi.circleandroid.core.api;
import hu.bme.dszenasi.circleandroid.occicore.Action;
import hu.bme.dszenasi.circleandroid.occicore.ActionWithAttributes;
import hu.bme.dszenasi.circleandroid.occicore.CreateVmData;
import hu.bme.dszenasi.circleandroid.occicore.LoginData;
import hu.bme.dszenasi.circleandroid.occicore.OCCIComputeResponse;
import hu.bme.dszenasi.circleandroid.occicore.OCCILoginResponse;
import hu.bme.dszenasi.circleandroid.occicore.Resource;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.DELETE;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.PUT;
import retrofit2.http.Path;
/**
* Created by danielszenasi on 03/05/16.
*/
public interface OCCICircleApi {
@GET("/occi/login/")
Call<OCCILoginResponse> loginGet();
@POST("/occi/login/")
Call<OCCILoginResponse> loginPost(@Body LoginData loginData);
@GET("/occi/compute/")
Call<OCCIComputeResponse> allCompute();
@GET("/occi/-/")
Call<OCCILoginResponse> queryInterface();
@DELETE("/occi/compute/{vmid}/")
Call<Resource> deleteCompute(@Path("vmid") int vmid);
@POST("/occi/compute/{vmid}/")
Call<Resource> startCompute(@Path("vmid") int vmid, @Body Action action);
@POST("/occi/compute/{vmid}/")
Call<Resource> startCompute(@Path("vmid") int vmid, @Body ActionWithAttributes action);
@PUT("/occi/compute/{vmid}/")
Call<Resource> createCompute(@Path("vmid") int vmid, @Body CreateVmData data);
}
package hu.bme.dszenasi.circleandroid.core.util;
import android.app.Application;
import android.content.Context;
import android.preference.PreferenceManager;
import android.util.Log;
import java.io.IOException;
import java.util.HashSet;
import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;
/**
* This interceptor put all the Cookies in Preferences in the Request.
* Your implementation on how to get the Preferences MAY VARY.
*/
public class AddCookiesInterceptor implements Interceptor {
public static final String PREF_COOKIES = "PREF_COOKIES";
private Application application;
public AddCookiesInterceptor(Application application) {
this.application = application;
}
@Override
public Response intercept(Chain chain) throws IOException {
Request.Builder builder = chain.request().newBuilder();
String csessidc3c8 = PreferenceManager.getDefaultSharedPreferences(application).getString("csessidc3c8","csessidc3c8isnull");
String csrftoken = PreferenceManager.getDefaultSharedPreferences(application).getString("csrftoken", "csrftokenisnull");
builder.addHeader("Referer", "https://vm.ik.bme.hu:1415/");
if(csrftoken != "csrftokenisnull") {
builder.addHeader("X-CSRFToken", csrftoken);
}
if (csessidc3c8 != "csessidc3c8isnull" && csrftoken != "csrftokenisnull") {
builder.addHeader("Cookie", "csrftoken=" + csrftoken + ";" + "csessidc3c8=" + csessidc3c8);
}
return chain.proceed(builder.build());
}
}
\ No newline at end of file
package hu.bme.dszenasi.circleandroid.core.util;
import java.io.IOException;
import java.lang.annotation.Annotation;
import javax.inject.Inject;
import hu.bme.dszenasi.circleandroid.occicore.OCCILoginResponse;
import okhttp3.ResponseBody;
import retrofit2.Converter;
import retrofit2.Response;
import retrofit2.Retrofit;
/**
* Created by danielszenasi on 09/05/16.
*/
public class ErrorUtil {
private Retrofit retrofit;
public ErrorUtil(Retrofit retrofit) {
this.retrofit = retrofit;
}
public OCCILoginResponse parseError(Response<?> response) {
Converter<ResponseBody, OCCILoginResponse> converter =
retrofit.responseBodyConverter(OCCILoginResponse.class, new Annotation[0]);
OCCILoginResponse error;
try {
error = converter.convert(response.errorBody());
} catch (IOException e) {
return new OCCILoginResponse();
}
return error;
}
}
package hu.bme.dszenasi.circleandroid.core.util;
import android.app.Application;
import android.content.Context;
import android.preference.PreferenceManager;
import android.util.Log;
import java.io.IOException;
import java.util.HashSet;
import java.util.prefs.Preferences;
import okhttp3.Interceptor;
import okhttp3.Response;
/**
* Created by danielszenasi on 09/05/16.
*/
public class ReceivedCookiesInterceptor implements Interceptor {
public static final String PREF_COOKIES = "PREF_COOKIES";
private Application application;
public ReceivedCookiesInterceptor(Application application) {
this.application = application;
}
@Override
public Response intercept(Chain chain) throws IOException {
Response originalResponse = chain.proceed(chain.request());
if (!originalResponse.headers("Set-Cookie").isEmpty()) {
HashSet<String> cookies = new HashSet<>();
for (String cookie : originalResponse.headers("Set-Cookie")) {
for (String possibleSessionCookie : cookie.split(";")) {
if (possibleSessionCookie.startsWith("csessidc3c8") && cookie.contains("=")) {
String csessidc3c8 = possibleSessionCookie.split("=")[1];
PreferenceManager.getDefaultSharedPreferences(application).edit()
.putString("csessidc3c8",csessidc3c8)
.apply();
}
if (possibleSessionCookie.startsWith("csrftoken") && cookie.contains("=")) {
String csrftoken = possibleSessionCookie.split("=")[1];
PreferenceManager.getDefaultSharedPreferences(application).edit()
.putString("csrftoken",csrftoken)
.apply();
}
}
}
}
return originalResponse;
}
}
package hu.bme.dszenasi.circleandroid.core.util;
/**
* Created by danielszenasi on 05/05/16.
*/
import android.app.Application;
import android.content.Context;
import android.content.SharedPreferences;
import java.io.IOException;
import java.io.InputStream;
import java.net.CookieHandler;
import java.security.KeyManagementException;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.security.cert.Certificate;
import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.List;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.TrustManager;
import javax.net.ssl.TrustManagerFactory;
import javax.net.ssl.X509TrustManager;
import hu.bme.dszenasi.circleandroid.R;
import okhttp3.JavaNetCookieJar;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Interceptor;
import okhttp3.Response;
public class SelfSigningClientBuilder {
public static OkHttpClient createClient(Application application) {
final TrustManager[] certs = new TrustManager[]{new X509TrustManager() {
@Override
public X509Certificate[] getAcceptedIssuers() {
return new X509Certificate[0];
}
@Override
public void checkServerTrusted(final X509Certificate[] chain,
final String authType) throws CertificateException {
}
@Override
public void checkClientTrusted(final X509Certificate[] chain,
final String authType) throws CertificateException {
}
}};
SSLContext ctx = null;
try {
ctx = SSLContext.getInstance("TLS");
ctx.init(null, certs, new SecureRandom());
} catch (final java.security.GeneralSecurityException ex) {
}
OkHttpClient.Builder builder = new OkHttpClient.Builder().sslSocketFactory(ctx.getSocketFactory());
builder.hostnameVerifier(new HostnameVerifier() {
@Override
public boolean verify(String hostname, SSLSession session) {
return true;
}
});
//JavaNetCookieJar jncj = new JavaNetCookieJar(CookieHandler.getDefault());
//httpClient.cookieJar(jncj);
builder.addInterceptor(new AddCookiesInterceptor(application));
builder.addInterceptor(new ReceivedCookiesInterceptor(application));
return builder.build();
}
}
package hu.bme.dszenasi.circleandroid.createvm.module;
import javax.inject.Singleton;
import dagger.Component;
import hu.bme.dszenasi.circleandroid.AppModule;
import hu.bme.dszenasi.circleandroid.createvm.ui.CreateVmActivity;
/**
* Created by mszenasi on 2016-04-28.
*/
@Singleton
@Component(modules = {AppModule.class, CreateVmModule.class})
public interface CreateVmComponent {
void inject(CreateVmActivity createVmActivity);
}
\ No newline at end of file
package hu.bme.dszenasi.circleandroid.createvm.module;
import android.app.Application;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides;
import hu.bme.dszenasi.circleandroid.core.util.ErrorUtil;
import hu.bme.dszenasi.circleandroid.core.util.SelfSigningClientBuilder;
import hu.bme.dszenasi.circleandroid.createvm.repository.CreateVmRepository;
import hu.bme.dszenasi.circleandroid.createvm.repository.ICreateVmRepository;
import hu.bme.dszenasi.circleandroid.createvm.ui.CreateVmPresenter;
import hu.bme.dszenasi.circleandroid.createvm.ui.CreateVmPresenterImpl;
import okhttp3.OkHttpClient;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
/**
* Created by mszenasi on 2016-04-28.
*/
@Module
public class CreateVmModule {
String mBaseUrl;
public CreateVmModule(String baseUrl) {
this.mBaseUrl = baseUrl;
}
@Provides
@Singleton
public CreateVmRepository providesCreateVmRepository(Retrofit retrofit) {
return new CreateVmRepository(retrofit);
}
@Provides
@Singleton
public CreateVmPresenter providesCreateVmPresenter(CreateVmRepository createVmRepository, ErrorUtil errorUtil) {
return new CreateVmPresenterImpl(createVmRepository, errorUtil);
}
@Provides
@Singleton
SharedPreferences providesSharedPreferences(Application application) {
return PreferenceManager.getDefaultSharedPreferences(application);
}
@Provides
@Singleton
OkHttpClient provideOkHttpClient(Application application) {
return SelfSigningClientBuilder.createClient(application);
}
@Provides
@Singleton
ErrorUtil provideErrorUtil(Retrofit retrofit) {
return new ErrorUtil(retrofit);
}
//gson
@Provides
@Singleton
Retrofit provideRetrofit(OkHttpClient okHttpClient) {
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(mBaseUrl)
.addConverterFactory(GsonConverterFactory.create())
.client(okHttpClient)
.build();
return retrofit;
}
}
\ No newline at end of file
package hu.bme.dszenasi.circleandroid.createvm.repository;
import java.net.URI;
import hu.bme.dszenasi.circleandroid.core.api.OCCICircleApi;
import hu.bme.dszenasi.circleandroid.occicore.CreateVmData;
import hu.bme.dszenasi.circleandroid.occicore.Resource;
import retrofit2.Callback;
import retrofit2.Retrofit;
/**
* Created by mszenasi on 2016-04-28.
*/
public class CreateVmRepository {
private Retrofit retrofit;
public CreateVmRepository(Retrofit retrofit) {
this.retrofit = retrofit;
}
public void vmCreatVm(Callback<Resource> callback, CreateVmData createVmData, int vmId) {
OCCICircleApi occiCircleApi = retrofit.create(OCCICircleApi.class);
occiCircleApi.createCompute(vmId, createVmData).enqueue(callback);
}
}
package hu.bme.dszenasi.circleandroid.createvm.repository;
/**
* Created by mszenasi on 2016-04-28.
*/
public interface ICreateVmRepository {
}
package hu.bme.dszenasi.circleandroid.createvm.ui;
import android.os.Bundle;
import android.os.PersistableBundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import java.util.ArrayList;
import java.util.List;
import javax.inject.Inject;
import hu.bme.dszenasi.circleandroid.MyApplication;
import hu.bme.dszenasi.circleandroid.R;
import hu.bme.dszenasi.circleandroid.occicore.CreateVmData;
/**
* Created by mszenasi on 2016-04-28.
*/
public class CreateVmActivity extends AppCompatActivity implements CreateVmView{
@Inject
CreateVmPresenter createVmPresenter;
Button createVmButton;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.createvm_activity);
injectDependencies();
createVmPresenter.setView(this);
createVmButton = (Button) findViewById(R.id.createvmbutton);
createVmButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
List<String> mixins = new ArrayList<>();
mixins.add("http://circlecloud.org/occi/templates/os#os_template_1");
CreateVmData createVmData = new CreateVmData(mixins, "may be provided");
createVmPresenter.createVm(createVmData, 1);
}
});
}
@Override
public void onCreate(Bundle savedInstanceState, PersistableBundle persistentState) {
super.onCreate(savedInstanceState, persistentState);
}
@Override
protected void onDestroy() {
createVmPresenter.destroyView();
super.onDestroy();
}
protected void injectDependencies() {
((MyApplication) getApplication()).getCreateVmComponent().inject(this);
}
@Override
public void showSuccess() {
}
}
package hu.bme.dszenasi.circleandroid.createvm.ui;
import hu.bme.dszenasi.circleandroid.occicore.CreateVmData;
/**
* Created by mszenasi on 2016-04-28.
*/
public interface CreateVmPresenter {
void setView(CreateVmView createVmView);
void destroyView();
void createVm(CreateVmData createVmData, int vmId);
}
package hu.bme.dszenasi.circleandroid.createvm.ui;
import hu.bme.dszenasi.circleandroid.core.util.ErrorUtil;
import hu.bme.dszenasi.circleandroid.createvm.repository.CreateVmRepository;
import hu.bme.dszenasi.circleandroid.occicore.CreateVmData;
import hu.bme.dszenasi.circleandroid.occicore.OCCILoginResponse;
import hu.bme.dszenasi.circleandroid.occicore.Resource;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
/**
* Created by mszenasi on 2016-04-28.
*/
public class CreateVmPresenterImpl implements CreateVmPresenter{
CreateVmRepository createVmRepository;
CreateVmView createVmView;
ErrorUtil errorUtil;
public CreateVmPresenterImpl(CreateVmRepository createVmRepository, ErrorUtil errorUtil) {
this.createVmRepository = createVmRepository;
this.errorUtil = errorUtil;
}
@Override
public void setView(CreateVmView createVmView) {
this.createVmView = createVmView;
}
@Override
public void destroyView() {
createVmView = null;
}
@Override
public void createVm(CreateVmData createVmData, int vmId) {
Callback<Resource> callback = new Callback<Resource>() {
@Override
public void onResponse(Call<Resource> call, Response<Resource> response) {
if (response.isSuccessful()) {
createVmView.showSuccess();
} else {
OCCILoginResponse occiLoginResponse = errorUtil.parseError(response);
//loginView.showLoginError(occiLoginResponse.getErrors());
}
}
@Override
public void onFailure(Call<Resource> call, Throwable t) {
// handle execution failures like no internet connectivity
}
};
createVmRepository.vmCreatVm(callback, createVmData, vmId);
}
}
package hu.bme.dszenasi.circleandroid.createvm.ui;
/**
* Created by mszenasi on 2016-04-28.
*/
public interface CreateVmView {
void showSuccess();
}
package hu.bme.dszenasi.circleandroid.login.module;
import android.content.Context;
import javax.inject.Singleton;
import dagger.Component;
import hu.bme.dszenasi.circleandroid.AppModule;
import hu.bme.dszenasi.circleandroid.core.util.ErrorUtil;
import hu.bme.dszenasi.circleandroid.login.ui.LoginActivity;
import hu.bme.dszenasi.circleandroid.login.ui.LoginPresenter;
/**
* Created by mszenasi on 2016-04-26.
*/
@Singleton
@Component(modules = {AppModule.class, LoginModule.class})
public interface LoginComponent {
void inject(LoginActivity baseActivity);
}
package hu.bme.dszenasi.circleandroid.login.module;
import android.app.Application;
import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides;
import hu.bme.dszenasi.circleandroid.core.util.ErrorUtil;
import hu.bme.dszenasi.circleandroid.core.util.SelfSigningClientBuilder;
import hu.bme.dszenasi.circleandroid.login.repository.ILoginRepository;
import hu.bme.dszenasi.circleandroid.login.repository.LoginRepository;
import hu.bme.dszenasi.circleandroid.login.ui.LoginPresenter;
import hu.bme.dszenasi.circleandroid.login.ui.LoginPresenterImpl;
import okhttp3.OkHttpClient;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
/**
* Created by mszenasi on 2016-04-26.
*/
@Module
public class LoginModule {
String mBaseUrl;
public LoginModule(String baseUrl) {
this.mBaseUrl = baseUrl;
}
@Provides
@Singleton
public ILoginRepository providesLoginRepository(Retrofit retrofit) {
return new LoginRepository(retrofit);
}
@Provides
@Singleton
public LoginPresenter providesLoginPresenter(ILoginRepository loginRepository, ErrorUtil errorUtil) {
return new LoginPresenterImpl(loginRepository, errorUtil);
}
@Provides
@Singleton
SharedPreferences providesSharedPreferences(Application application) {
return PreferenceManager.getDefaultSharedPreferences(application);
}
@Provides
@Singleton
OkHttpClient provideOkHttpClient(Application application) {
return SelfSigningClientBuilder.createClient(application);
}
@Provides
@Singleton
ErrorUtil provideErrorUtil(Retrofit retrofit) {
return new ErrorUtil(retrofit);
}
//gson
@Provides
@Singleton
Retrofit provideRetrofit(OkHttpClient okHttpClient) {
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(mBaseUrl)
.addConverterFactory(GsonConverterFactory.create())
.client(okHttpClient)
.build();
return retrofit;
}
}
package hu.bme.dszenasi.circleandroid.login.repository;
import java.io.IOException;
import hu.bme.dszenasi.circleandroid.occicore.LoginData;
import hu.bme.dszenasi.circleandroid.occicore.OCCILoginResponse;
import retrofit2.Callback;
/**
* Created by danielszenasi on 27/04/16.
*/
public interface ILoginRepository {
void login(Callback<OCCILoginResponse> callback, LoginData loginData);
}
package hu.bme.dszenasi.circleandroid.login.repository;
import java.io.IOException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import hu.bme.dszenasi.circleandroid.core.api.OCCICircleApi;
import hu.bme.dszenasi.circleandroid.occicore.LoginData;
import hu.bme.dszenasi.circleandroid.occicore.OCCILoginResponse;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;
/**
* Created by mszenasi on 2016-04-26.
*/
public class LoginRepository implements ILoginRepository {
private Retrofit retrofit;
public LoginRepository(Retrofit retrofit) {
this.retrofit = retrofit;
}
public void login(final Callback<OCCILoginResponse> callback, final LoginData loginData) {
OCCICircleApi occiCircleApi = retrofit.create(OCCICircleApi.class);
Callback<OCCILoginResponse> callback1 = new Callback<OCCILoginResponse>() {
@Override
public void onResponse(Call<OCCILoginResponse> call, Response<OCCILoginResponse> response) {
postLogin(callback, loginData);
}
@Override
public void onFailure(Call<OCCILoginResponse> call, Throwable t) {
System.out.print("asas");
}
};
occiCircleApi.loginGet().enqueue(callback1);
}
private void postLogin(Callback<OCCILoginResponse> callback, LoginData loginData) {
OCCICircleApi occiCircleApi = retrofit.create(OCCICircleApi.class);
occiCircleApi.loginPost(loginData).enqueue(callback);
}
}
package hu.bme.dszenasi.circleandroid.login.ui;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.inputmethod.EditorInfo;
import android.widget.AutoCompleteTextView;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import java.util.List;
import javax.inject.Inject;
import hu.bme.dszenasi.circleandroid.MyApplication;
import hu.bme.dszenasi.circleandroid.R;
import hu.bme.dszenasi.circleandroid.occicore.LoginData;
import hu.bme.dszenasi.circleandroid.vmlist.ui.VmListActivity;
/**
* A login screen that offers login via email/password.
*/
public class LoginActivity extends AppCompatActivity implements LoginView {
@Inject
LoginPresenter loginPresenter;
/**
* Id to identity READ_CONTACTS permission request.
*/
private static final int REQUEST_READ_CONTACTS = 0;
// UI references.
private AutoCompleteTextView mUsernameView;
private EditText mPasswordView;
private TextView errorView;
private Button mConnectButton;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
injectDependencies();
loginPresenter.attachView(this);
setContentView(R.layout.activity_login);
mUsernameView = (AutoCompleteTextView) findViewById(R.id.username);
mPasswordView = (EditText) findViewById(R.id.password);
errorView = (TextView) findViewById(R.id.error);
mPasswordView.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView textView, int id, KeyEvent keyEvent) {
if (id == R.id.login || id == EditorInfo.IME_NULL) {
attemptLogin();
return true;
}
return false;
}
});
mConnectButton = (Button) findViewById(R.id.email_sign_in_button);
mConnectButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
attemptLogin();
}
});
}
@Override
protected void onDestroy() {
loginPresenter.detachView();
super.onDestroy();
}
protected void injectDependencies() {
((MyApplication) getApplication()).getloginComponent().inject(this);
}
private void attemptLogin() {
if (isEmailValid(mUsernameView.getText().toString())) {
LoginData loginData = new LoginData(mUsernameView.getText().toString(), mPasswordView.getText().toString());
loginPresenter.login(loginData);
}
}
private boolean isEmailValid(String email) {
//TODO: Replace this with your own logic
return true;
}
private boolean isPasswordValid(String password) {
//TODO: Replace this with your own logic
return password.length() > 4;
}
@Override
public void onLoginSucces() {
Intent intent = new Intent(this, VmListActivity.class);
startActivity(intent);
}
@Override
public void showLoginError(List<String> errors){
StringBuilder sb = new StringBuilder();
for (String error : errors) {
sb.append(error);
sb.append(System.getProperty("line.separator"));
}
errorView.setText(sb);
errorView.setVisibility(View.VISIBLE);
}
}
package hu.bme.dszenasi.circleandroid.login.ui;
import hu.bme.dszenasi.circleandroid.occicore.LoginData;
/**
* Created by mszenasi on 2016-04-26.
*/
public interface LoginPresenter {
void login(LoginData loginData);
void attachView(LoginView loginView);
void detachView();
}
package hu.bme.dszenasi.circleandroid.login.ui;
import java.io.IOException;
import hu.bme.dszenasi.circleandroid.core.util.ErrorUtil;
import hu.bme.dszenasi.circleandroid.occicore.LoginData;
import hu.bme.dszenasi.circleandroid.occicore.OCCILoginResponse;
import hu.bme.dszenasi.circleandroid.login.repository.ILoginRepository;
import okhttp3.ResponseBody;
import retrofit.JacksonConverterFactory;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Converter;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
/**
* Created by mszenasi on 2016-04-26.
*/
public class LoginPresenterImpl implements LoginPresenter {
ILoginRepository loginRepository;
LoginView loginView;
ErrorUtil errorUtil;
public LoginPresenterImpl(ILoginRepository loginRepository, ErrorUtil errorUtil) {
this.loginRepository = loginRepository;
this.errorUtil = errorUtil;
}
@Override
public void login(LoginData loginData) {
Callback<OCCILoginResponse> callback = new Callback<OCCILoginResponse>() {
@Override
public void onResponse(Call<OCCILoginResponse> call, Response<OCCILoginResponse> response) {
if (response.isSuccessful()) {
loginView.onLoginSucces();
} else {
OCCILoginResponse occiLoginResponse = errorUtil.parseError(response);
loginView.showLoginError(occiLoginResponse.getErrors());
}
}
@Override
public void onFailure(Call<OCCILoginResponse> call, Throwable t) {
// handle execution failures like no internet connectivity
}
};
loginRepository.login(callback, loginData);
}
@Override
public void attachView(LoginView loginView) {
this.loginView = loginView;
}
@Override
public void detachView() {
loginView = null;
}
}
package hu.bme.dszenasi.circleandroid.login.ui;
import java.util.List;
/**
* Created by mszenasi on 2016-04-26.
*/
public interface LoginView {
void onLoginSucces();
void showLoginError(List<String> error);
}
package hu.bme.dszenasi.circleandroid.managevm.module;
import javax.inject.Singleton;
import dagger.Component;
import hu.bme.dszenasi.circleandroid.AppModule;
import hu.bme.dszenasi.circleandroid.managevm.ui.ManageVmActivity;
/**
* Created by mszenasi on 2016-04-28.
*/
@Singleton
@Component(modules = {AppModule.class, ManageVmModule.class})
public interface ManageVmComponent {
void inject(ManageVmActivity baseActivity);
}
package hu.bme.dszenasi.circleandroid.managevm.module;
import android.app.Application;
import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides;
import hu.bme.dszenasi.circleandroid.core.util.ErrorUtil;
import hu.bme.dszenasi.circleandroid.core.util.SelfSigningClientBuilder;
import hu.bme.dszenasi.circleandroid.managevm.repository.ManageVmRepository;
import hu.bme.dszenasi.circleandroid.managevm.ui.ManageVmPresenter;
import hu.bme.dszenasi.circleandroid.managevm.ui.ManageVmPresenterImpl;
import okhttp3.OkHttpClient;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
/**
* Created by mszenasi on 2016-04-28.
*/
@Module
public class ManageVmModule {
String mBaseUrl;
public ManageVmModule(String baseUrl) {
this.mBaseUrl = baseUrl;
}
@Provides
@Singleton
public ManageVmRepository providesManageVmRepository(Retrofit retrofit) {
return new ManageVmRepository(retrofit);
}
@Provides
@Singleton
public ManageVmPresenter providesManageVmPresenter(ManageVmRepository manageVmRepository, ErrorUtil errorUtil) {
return new ManageVmPresenterImpl(manageVmRepository, errorUtil);
}
@Provides
@Singleton
SharedPreferences providesSharedPreferences(Application application) {
return PreferenceManager.getDefaultSharedPreferences(application);
}
@Provides
@Singleton
OkHttpClient provideOkHttpClient(Application application) {
return SelfSigningClientBuilder.createClient(application);
}
@Provides
@Singleton
ErrorUtil provideErrorUtil(Retrofit retrofit) {
return new ErrorUtil(retrofit);
}
//gson
@Provides
@Singleton
Retrofit provideRetrofit(OkHttpClient okHttpClient) {
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(mBaseUrl)
.addConverterFactory(GsonConverterFactory.create())
.client(okHttpClient)
.build();
return retrofit;
}
}
package hu.bme.dszenasi.circleandroid.managevm.repository;
import java.net.URI;
import java.util.List;
import hu.bme.dszenasi.circleandroid.core.api.OCCICircleApi;
import hu.bme.dszenasi.circleandroid.occicore.Action;
import hu.bme.dszenasi.circleandroid.occicore.ActionWithAttributes;
import hu.bme.dszenasi.circleandroid.occicore.LoginData;
import hu.bme.dszenasi.circleandroid.occicore.OCCIComputeResponse;
import hu.bme.dszenasi.circleandroid.occicore.OCCILoginResponse;
import hu.bme.dszenasi.circleandroid.occicore.Resource;
import retrofit2.Callback;
import retrofit2.Retrofit;
/**
* Created by danielszenasi on 29/04/16.
*/
public class ManageVmRepository {
Retrofit retrofit;
public ManageVmRepository(Retrofit retrofit) {
this.retrofit = retrofit;
}
public void vmAction(Callback<Resource> callback, int vmid, Action action) {
OCCICircleApi occiCircleApi = retrofit.create(OCCICircleApi.class);
occiCircleApi.startCompute(vmid, action).enqueue(callback);
}
public void vmAction(Callback<Resource> callback, int vmid, ActionWithAttributes action) {
OCCICircleApi occiCircleApi = retrofit.create(OCCICircleApi.class);
occiCircleApi.startCompute(vmid, action).enqueue(callback);
}
public void vmDelete(Callback<Resource> callback, int vmid) {
OCCICircleApi occiCircleApi = retrofit.create(OCCICircleApi.class);
occiCircleApi.deleteCompute(vmid).enqueue(callback);
}
}
package hu.bme.dszenasi.circleandroid.managevm.ui;
import android.content.Intent;
import android.os.Bundle;
import android.os.PersistableBundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;
import javax.inject.Inject;
import hu.bme.dszenasi.circleandroid.MyApplication;
import hu.bme.dszenasi.circleandroid.R;
import hu.bme.dszenasi.circleandroid.occicore.Action;
import hu.bme.dszenasi.circleandroid.occicore.ActionAttributes;
import hu.bme.dszenasi.circleandroid.occicore.ActionWithAttributes;
import hu.bme.dszenasi.circleandroid.occicore.Resource;
import hu.bme.dszenasi.circleandroid.vmlist.ui.VmListPresenter;
/**
* Created by mszenasi on 2016-04-28.
*/
public class ManageVmActivity extends AppCompatActivity implements ManageVmView {
@Inject
ManageVmPresenter manageVmPresenter;
TextView computeArchitecture;
TextView computeState;
TextView computeStateMessage;
TextView computeMemory;
TextView computeShare;
TextView computeCores;
TextView computeHostname;
TextView credentialsCommand;
TextView credentialsHost;
TextView credentialsPassword;
TextView credentialsPort;
TextView credentialsProtocol;
TextView credentialsUsername;
Button start;
Button restart;
Button suspend;
Button delete;
int id;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.manage_activity);
injectDependencies();
manageVmPresenter.setView(this);
computeArchitecture = (TextView) findViewById(R.id.arhitecture);
computeState = (TextView) findViewById(R.id.state);
computeStateMessage = (TextView) findViewById(R.id.stateMessage);
computeMemory = (TextView) findViewById(R.id.memory);
computeShare = (TextView) findViewById(R.id.share);
computeCores = (TextView) findViewById(R.id.cores);
computeHostname = (TextView) findViewById(R.id.hostname);
credentialsCommand = (TextView) findViewById(R.id.command);
credentialsHost = (TextView) findViewById(R.id.host);
credentialsPassword = (TextView) findViewById(R.id.credentialspassword);
credentialsPort = (TextView) findViewById(R.id.port);
credentialsProtocol = (TextView) findViewById(R.id.protocol);
credentialsUsername = (TextView) findViewById(R.id.username);
start = (Button) findViewById(R.id.start);
restart = (Button) findViewById(R.id.restart);
suspend = (Button) findViewById(R.id.suspend);
delete = (Button) findViewById(R.id.delete);
Resource value;
Bundle bundle = getIntent().getExtras();
if (bundle != null) {
value = bundle.getParcelable("resource");
setResource(value);
}
start.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
manageVmPresenter.startVm(id, new Action("http://schemas.ogf.org/occi/infrastructure/compute/action#start"));
}
});
restart.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
manageVmPresenter.startVm(id, new ActionWithAttributes("http://schemas.ogf.org/occi/infrastructure/compute/action#restart", new ActionAttributes("cold")));
}
});
suspend.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
manageVmPresenter.startVm(id, new ActionWithAttributes("http://schemas.ogf.org/occi/infrastructure/compute/action#suspend", new ActionAttributes("suspend")));
}
});
delete.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
manageVmPresenter.deleteVm(id);
}
});
}
public void setResource(Resource resource){
id = resource.getId();
computeArchitecture.setText(resource.getAttributes().getComputeArchitecture());
computeState.setText(resource.getAttributes().getComputeState());
computeStateMessage.setText(resource.getAttributes().getComputeStateMessage());
computeMemory.setText(String.valueOf(resource.getAttributes().getComputeMemory()));
computeShare.setText(String.valueOf(resource.getAttributes().getComputeShare()));
computeCores.setText(String.valueOf(resource.getAttributes().getComputeCores()));
computeHostname.setText(resource.getAttributes().getComputeHostname());
credentialsCommand.setText(resource.getAttributes().getCredentialsCommand());
credentialsHost.setText(resource.getAttributes().getCredentialsHost());
credentialsPassword.setText(resource.getAttributes().getCredentialsPassword());
credentialsPort.setText(String.valueOf(resource.getAttributes().getCredentialsPort()));
credentialsProtocol.setText(resource.getAttributes().getCredentialsProtocol());
credentialsUsername.setText(resource.getAttributes().getCredentialsUsername());
}
public void finish(){
finish();
}
@Override
public void onCreate(Bundle savedInstanceState, PersistableBundle persistentState) {
super.onCreate(savedInstanceState, persistentState);
}
@Override
protected void onDestroy() {
manageVmPresenter.destroyView();
super.onDestroy();
}
protected void injectDependencies() {
((MyApplication) getApplication()).getManageVmComponent().inject(this);
}
}
package hu.bme.dszenasi.circleandroid.managevm.ui;
import hu.bme.dszenasi.circleandroid.occicore.Action;
import hu.bme.dszenasi.circleandroid.occicore.ActionWithAttributes;
import hu.bme.dszenasi.circleandroid.vmlist.ui.VmListView;
/**
* Created by mszenasi on 2016-04-28.
*/
public interface ManageVmPresenter {
void setView(ManageVmView view);
void destroyView();
void startVm(int vmid, Action action);
void deleteVm(int vmid);
void startVm(int vmid, ActionWithAttributes action);
}
package hu.bme.dszenasi.circleandroid.managevm.ui;
import hu.bme.dszenasi.circleandroid.core.util.ErrorUtil;
import hu.bme.dszenasi.circleandroid.managevm.repository.ManageVmRepository;
import hu.bme.dszenasi.circleandroid.occicore.Action;
import hu.bme.dszenasi.circleandroid.occicore.ActionAttributes;
import hu.bme.dszenasi.circleandroid.occicore.ActionWithAttributes;
import hu.bme.dszenasi.circleandroid.occicore.OCCIComputeResponse;
import hu.bme.dszenasi.circleandroid.occicore.OCCILoginResponse;
import hu.bme.dszenasi.circleandroid.occicore.Resource;
import hu.bme.dszenasi.circleandroid.vmlist.repository.IVmListRepository;
import hu.bme.dszenasi.circleandroid.vmlist.ui.VmListView;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
/**
* Created by mszenasi on 2016-04-28.
*/
public class ManageVmPresenterImpl implements ManageVmPresenter{
ManageVmView view;
ManageVmRepository manageVmRepository;
ErrorUtil errorUtil;
public ManageVmPresenterImpl(ManageVmRepository manageVmRepository, ErrorUtil errorUtil) {
this.manageVmRepository = manageVmRepository;
this.errorUtil = errorUtil;
}
public void destroyView() {
view = null;
}
public void setView(ManageVmView view) {
this.view = view;
}
public void startVm(int vmid, Action action){
Callback<Resource> callback = new Callback<Resource>() {
@Override
public void onResponse(Call<Resource> call, Response<Resource> response) {
if (response.isSuccessful()) {
view.setResource(response.body());
} else {
OCCILoginResponse occiLoginResponse = errorUtil.parseError(response);
//loginView.showLoginError(occiLoginResponse.getErrors());
}
}
@Override
public void onFailure(Call<Resource> call, Throwable t) {
// handle execution failures like no internet connectivity
}
};
manageVmRepository.vmAction(callback, vmid, action);
}
public void deleteVm(int vmid){
Callback<Resource> callback = new Callback<Resource>() {
@Override
public void onResponse(Call<Resource> call, Response<Resource> response) {
if (response.isSuccessful()) {
//view.finish();
} else {
OCCILoginResponse occiLoginResponse = errorUtil.parseError(response);
//loginView.showLoginError(occiLoginResponse.getErrors());
}
}
@Override
public void onFailure(Call<Resource> call, Throwable t) {
// handle execution failures like no internet connectivity
}
};
manageVmRepository.vmDelete(callback, vmid);
}
public void startVm(int vmid, ActionWithAttributes action){
Callback<Resource> callback = new Callback<Resource>() {
@Override
public void onResponse(Call<Resource> call, Response<Resource> response) {
if (response.isSuccessful()) {
view.setResource(response.body());
} else {
OCCILoginResponse occiLoginResponse = errorUtil.parseError(response);
//loginView.showLoginError(occiLoginResponse.getErrors());
}
}
@Override
public void onFailure(Call<Resource> call, Throwable t) {
// handle execution failures like no internet connectivity
}
};
manageVmRepository.vmAction(callback, vmid, action);
}
}
package hu.bme.dszenasi.circleandroid.managevm.ui;
import hu.bme.dszenasi.circleandroid.occicore.Resource;
/**
* Created by mszenasi on 2016-04-28.
*/
public interface ManageVmView {
void setResource(Resource resource);
void finish();
}
package hu.bme.dszenasi.circleandroid.occicore;
/**
* Created by danielszenasi on 10/05/16.
*/
public class Action {
private String action;
public String getAction() {
return action;
}
public Action(String action) {
this.action = action;
}
public void setAction(String action) {
this.action = action;
}
}
package hu.bme.dszenasi.circleandroid.occicore;
/**
* Created by danielszenasi on 10/05/16.
*/
public class ActionAttributes {
private String method;
public ActionAttributes(String method) {
this.method = method;
}
public String getMethod() {
return method;
}
public void setMethod(String method) {
this.method = method;
}
}
package hu.bme.dszenasi.circleandroid.occicore;
/**
* Created by danielszenasi on 10/05/16.
*/
public class ActionWithAttributes {
private String action;
private ActionAttributes attributes;
public ActionWithAttributes(String action, ActionAttributes attributes) {
this.action = action;
this.attributes = attributes;
}
public String getAction() {
return action;
}
public void setAction(String action) {
this.action = action;
}
public ActionAttributes getAttributes() {
return attributes;
}
public void setAttributes(ActionAttributes attributes) {
this.attributes = attributes;
}
}
package hu.bme.dszenasi.circleandroid.occicore;
import android.os.Parcel;
import android.os.Parcelable;
import com.google.gson.annotations.SerializedName;
/**
* Created by danielszenasi on 08/05/16.
*/
public class Attributes implements Parcelable {
@SerializedName("occi.compute.architecture")
private String computeArchitecture;
@SerializedName("occi.compute.state")
private String computeState;
@SerializedName("occi.compute.state.message")
private String computeStateMessage;
@SerializedName("occi.compute.memory")
private double computeMemory;
@SerializedName("occi.compute.share")
private int computeShare;
@SerializedName("occi.compute.cores")
private int computeCores;
@SerializedName("occi.compute.hostname")
private String computeHostname;
@SerializedName("org.circlecloud.occi.credentials.command")
private String credentialsCommand;
@SerializedName("org.circlecloud.occi.credentials.host")
private String credentialsHost;
@SerializedName("org.circlecloud.occi.credentials.password")
private String credentialsPassword;
@SerializedName("org.circlecloud.occi.credentials.port")
private int credentialsPort;
@SerializedName("org.circlecloud.occi.credentials.protocol")
private String credentialsProtocol;
@SerializedName("org.circlecloud.occi.credentials.username")
private String credentialsUsername;
public String getComputeArchitecture() {
return computeArchitecture;
}
public void setComputeArchitecture(String computeArchitecture) {
this.computeArchitecture = computeArchitecture;
}
public String getComputeHostname() {
return computeHostname;
}
public void setComputeHostname(String computeHostname) {
this.computeHostname = computeHostname;
}
public String getComputeState() {
return computeState;
}
public void setComputeState(String computeState) {
this.computeState = computeState;
}
public String getComputeStateMessage() {
return computeStateMessage;
}
public void setComputeStateMessage(String computeStateMessage) {
this.computeStateMessage = computeStateMessage;
}
public double getComputeMemory() {
return computeMemory;
}
public void setComputeMemory(double computeMemory) {
this.computeMemory = computeMemory;
}
public int getComputeShare() {
return computeShare;
}
public void setComputeShare(int computeShare) {
this.computeShare = computeShare;
}
public int getComputeCores() {
return computeCores;
}
public void setComputeCores(int computeCores) {
this.computeCores = computeCores;
}
public String getCredentialsCommand() {
return credentialsCommand;
}
public void setCredentialsCommand(String credentialsCommand) {
credentialsCommand = credentialsCommand;
}
public String getCredentialsHost() {
return credentialsHost;
}
public void setCredentialsHost(String credentialsHost) {
credentialsHost = credentialsHost;
}
public String getCredentialsPassword() {
return credentialsPassword;
}
public void setCredentialsPassword(String credentialsPassword) {
this.credentialsPassword = credentialsPassword;
}
public int getCredentialsPort() {
return credentialsPort;
}
public void setCredentialsPort(int credentialsPort) {
this.credentialsPort = credentialsPort;
}
public String getCredentialsProtocol() {
return credentialsProtocol;
}
public void setCredentialsProtocol(String credentialsProtocol) {
this.credentialsProtocol = credentialsProtocol;
}
public String getCredentialsUsername() {
return credentialsUsername;
}
public void setCredentialsUsername(String credentialsUsername) {
this.credentialsUsername = credentialsUsername;
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel parcel, int i) {
parcel.writeString(computeArchitecture);
parcel.writeString(computeState);
parcel.writeString(computeStateMessage);
parcel.writeDouble(computeMemory);
parcel.writeInt(computeShare);
parcel.writeInt(computeCores);
parcel.writeString(computeHostname);
parcel.writeString(credentialsCommand);
parcel.writeString(credentialsHost);
parcel.writeString(credentialsPassword);
parcel.writeInt(credentialsPort);
parcel.writeString(credentialsProtocol);
parcel.writeString(credentialsUsername);
}
// this is used to regenerate your object. All Parcelables must have a CREATOR that implements these two methods
public static final Parcelable.Creator<Attributes> CREATOR = new Parcelable.Creator<Attributes>() {
public Attributes createFromParcel(Parcel in) {
return new Attributes(in);
}
public Attributes[] newArray(int size) {
return new Attributes[size];
}
};
// example constructor that takes a Parcel and gives you an object populated with it's values
private Attributes(Parcel in) {
computeArchitecture = in.readString();
computeState = in.readString();
computeStateMessage = in.readString();
computeMemory = in.readDouble();
computeShare = in.readInt();
computeCores = in.readInt();
computeHostname = in.readString();
credentialsCommand = in.readString();
credentialsHost = in.readString();
credentialsPassword = in.readString();
credentialsPort = in.readInt();
credentialsProtocol = in.readString();
credentialsUsername = in.readString();
}
}
package hu.bme.dszenasi.circleandroid.occicore;
import java.util.List;
/**
* Created by danielszenasi on 11/05/16.
*/
public class CreateVmData {
private List<String> mixins;
private String other_occi_compute_data;
public CreateVmData(List<String> mixins, String other_occi_compute_data) {
this.mixins = mixins;
this.other_occi_compute_data = other_occi_compute_data;
}
public String getOther_occi_compute_data() {
return other_occi_compute_data;
}
public void setOther_occi_compute_data(String other_occi_compute_data) {
this.other_occi_compute_data = other_occi_compute_data;
}
public List<String> getMixins() {
return mixins;
}
public void setMixins(List<String> mixins) {
this.mixins = mixins;
}
}
package hu.bme.dszenasi.circleandroid.occicore;
/**
* Created by danielszenasi on 05/05/16.
*/
public class LoginData {
private String username;
private String password;
public LoginData(String username, String password) {
this.username = username;
this.password = password;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}
package hu.bme.dszenasi.circleandroid.occicore;
import java.util.List;
import hu.bme.dszenasi.circleandroid.occicore.Resource;
/**
* Created by danielszenasi on 08/05/16.
*/
public class OCCIComputeResponse {
private List<Resource> resources;
public List<Resource> getResources() {
return resources;
}
public void setResources(List<Resource> resources) {
this.resources = resources;
}
}
package hu.bme.dszenasi.circleandroid.occicore;
import java.util.List;
/**
* Created by danielszenasi on 03/05/16.
*/
public class OCCILoginResponse {
private String result;
private List<String> errors;
public List<String> getErrors() {
return errors;
}
public void setErrors(List<String> errors) {
this.errors = errors;
}
public String getResult() {
return result;
}
public void setResult(String result) {
this.result = result;
}
}
package hu.bme.dszenasi.circleandroid.occicore;
import android.os.Parcel;
import android.os.Parcelable;
import java.util.ArrayList;
import java.util.List;
/**
* Created by danielszenasi on 08/05/16.
*/
public class Resource implements Parcelable {
private Attributes attributes;
private String kind;
private int id;
private List<String> actions;
private List<String> mixins;
public Attributes getAttributes() {
return attributes;
}
public void setAttributes(Attributes attributes) {
this.attributes = attributes;
}
public String getKind() {
return kind;
}
public void setKind(String kind) {
this.kind = kind;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public List<String> getActions() {
return actions;
}
public void setActions(List<String> actions) {
this.actions = actions;
}
public List<String> getMixins() {
return mixins;
}
public void setMixins(List<String> mixins) {
this.mixins = mixins;
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel parcel, int i) {
parcel.writeParcelable(attributes, i);
parcel.writeString(kind);
parcel.writeInt(id);
parcel.writeStringList(actions);
parcel.writeStringList(mixins);
}
// this is used to regenerate your object. All Parcelables must have a CREATOR that implements these two methods
public static final Parcelable.Creator<Resource> CREATOR = new Parcelable.Creator<Resource>() {
public Resource createFromParcel(Parcel in) {
return new Resource(in);
}
public Resource[] newArray(int size) {
return new Resource[size];
}
};
// example constructor that takes a Parcel and gives you an object populated with it's values
private Resource(Parcel in) {
attributes = in.readParcelable(Attributes.class.getClassLoader());
kind = in.readString();
id = in.readInt();
actions = new ArrayList<>();
mixins = new ArrayList<>();
in.readStringList(actions);
in.readStringList(mixins);
}
}
package hu.bme.dszenasi.circleandroid.vmlist.adapter;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.view.Display;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.TextView;
import java.util.List;
import hu.bme.dszenasi.circleandroid.R;
import hu.bme.dszenasi.circleandroid.managevm.ui.ManageVmActivity;
import hu.bme.dszenasi.circleandroid.occicore.Resource;
import hu.bme.dszenasi.circleandroid.vmlist.ui.VmListActivity;
/**
* Created by mszenasi on 2016-04-28.
*/
public class VmAdapter extends ArrayAdapter<Resource> {
Context context;
public VmAdapter(Context context, int resource, List<Resource> objects) {
super(context, resource, objects);
this.context=context;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder viewHolder;
if(convertView==null){
LayoutInflater inflater = ((Activity) context).getLayoutInflater();
convertView = inflater.inflate(R.layout.vmlist_item, parent, false);
viewHolder = new ViewHolder();
viewHolder.hostname = (TextView) convertView.findViewById(R.id.hostname);
viewHolder.status = (TextView) convertView.findViewById(R.id.status);
convertView.setTag(viewHolder);
}else{
viewHolder = (ViewHolder) convertView.getTag();
}
final Resource resource = getItem(position);
viewHolder.hostname.setText(resource.getAttributes().getComputeHostname());
viewHolder.status.setText(resource.getAttributes().getComputeState());
return convertView;
}
public class ViewHolder{
TextView hostname;
TextView status;
}
}
package hu.bme.dszenasi.circleandroid.vmlist.module;
import javax.inject.Singleton;
import dagger.Component;
import hu.bme.dszenasi.circleandroid.AppModule;
import hu.bme.dszenasi.circleandroid.login.module.LoginModule;
import hu.bme.dszenasi.circleandroid.login.ui.LoginActivity;
import hu.bme.dszenasi.circleandroid.vmlist.ui.VmListActivity;
/**
* Created by mszenasi on 2016-04-28.
*/
@Singleton
@Component(modules = {AppModule.class, VmListModule.class})
public interface VmListComponent {
void inject(VmListActivity baseActivity);
}
package hu.bme.dszenasi.circleandroid.vmlist.module;
import android.app.Application;
import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides;
import hu.bme.dszenasi.circleandroid.core.util.ErrorUtil;
import hu.bme.dszenasi.circleandroid.core.util.SelfSigningClientBuilder;
import hu.bme.dszenasi.circleandroid.vmlist.repository.IVmListRepository;
import hu.bme.dszenasi.circleandroid.vmlist.repository.VmListRepository;
import hu.bme.dszenasi.circleandroid.vmlist.ui.VmListPresenter;
import hu.bme.dszenasi.circleandroid.vmlist.ui.VmListPresenterImpl;
import okhttp3.OkHttpClient;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
/**
* Created by mszenasi on 2016-04-28.
*/
@Module
public class VmListModule {
String mBaseUrl;
// Constructor needs one parameter to instantiate.
public VmListModule(String baseUrl) {
this.mBaseUrl = baseUrl;
}
@Provides
@Singleton
public IVmListRepository providesVmListRepository(Retrofit retrofit) {
return new VmListRepository(retrofit);
}
@Provides
@Singleton
public VmListPresenter providesVmListPresenter(IVmListRepository repository) {
return new VmListPresenterImpl(repository);
}
@Provides
@Singleton
SharedPreferences providesSharedPreferences(Application application) {
return PreferenceManager.getDefaultSharedPreferences(application);
}
@Provides
@Singleton
OkHttpClient provideOkHttpClient(Application application) {
return SelfSigningClientBuilder.createClient(application);
}
//gson
@Provides
@Singleton
Retrofit provideRetrofit(OkHttpClient okHttpClient) {
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(mBaseUrl)
.addConverterFactory(GsonConverterFactory.create())
.client(okHttpClient)
.build();
return retrofit;
}
}
package hu.bme.dszenasi.circleandroid.vmlist.repository;
import hu.bme.dszenasi.circleandroid.occicore.OCCIComputeResponse;
import retrofit2.Callback;
/**
* Created by danielszenasi on 28/04/16.
*/
public interface IVmListRepository {
void getAllCompute(Callback<OCCIComputeResponse> callback);
}
package hu.bme.dszenasi.circleandroid.vmlist.repository;
import android.content.SharedPreferences;
import hu.bme.dszenasi.circleandroid.core.api.OCCICircleApi;
import hu.bme.dszenasi.circleandroid.occicore.OCCIComputeResponse;
import retrofit2.Callback;
import retrofit2.Retrofit;
/**
* Created by danielszenasi on 28/04/16.
*/
public class VmListRepository implements IVmListRepository {
private Retrofit retrofit;
public VmListRepository(Retrofit retrofit) {
this.retrofit = retrofit;
}
public void getAllCompute(Callback<OCCIComputeResponse> callback) {
OCCICircleApi occiCircleApi = retrofit.create(OCCICircleApi.class);
occiCircleApi.allCompute().enqueue(callback);
}
}
package hu.bme.dszenasi.circleandroid.vmlist.ui;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.PersistableBundle;
import android.support.annotation.Nullable;
import android.support.design.widget.FloatingActionButton;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.ListView;
import java.util.List;
import javax.inject.Inject;
import hu.bme.dszenasi.circleandroid.MyApplication;
import hu.bme.dszenasi.circleandroid.R;
import hu.bme.dszenasi.circleandroid.createvm.ui.CreateVmActivity;
import hu.bme.dszenasi.circleandroid.managevm.ui.ManageVmActivity;
import hu.bme.dszenasi.circleandroid.occicore.Resource;
import hu.bme.dszenasi.circleandroid.vmlist.adapter.VmAdapter;
/**
* Created by mszenasi on 2016-04-26.
*/
public class VmListActivity extends AppCompatActivity implements VmListView {
ListView listView;
VmAdapter vmAdapter;
@Inject
VmListPresenter vmListPresenter;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.vmlist_activity);
injectDependencies();
vmListPresenter.setView(this);
listView = (ListView) findViewById(R.id.listView);
vmListPresenter.getAllCompute();
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> adapterView, View view,
int position, long id) {
Intent intent = new Intent( VmListActivity.this , ManageVmActivity.class );
final Resource item = (Resource) adapterView.getItemAtPosition(position);
intent.putExtra("resource", item);
startActivity(intent);
}
});
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
// Click action
Intent intent = new Intent(VmListActivity.this, CreateVmActivity.class);
startActivity(intent);
}
});
}
@Override
public void onCreate(Bundle savedInstanceState, PersistableBundle persistentState) {
super.onCreate(savedInstanceState, persistentState);
}
@Override
protected void onDestroy() {
vmListPresenter.destroyView();
super.onDestroy();
}
@Override
public void computeLoaded(List<Resource> resources) {
vmAdapter = new VmAdapter(this, R.layout.vmlist_item, resources);
listView.setAdapter(vmAdapter);
}
protected void injectDependencies() {
((MyApplication) getApplication()).getVmListComponent().inject(this);
}
}
package hu.bme.dszenasi.circleandroid.vmlist.ui;
/**
* Created by mszenasi on 2016-04-28.
*/
public interface VmListPresenter {
void setView(VmListView view);
void destroyView();
void getAllCompute();
}
package hu.bme.dszenasi.circleandroid.vmlist.ui;
import hu.bme.dszenasi.circleandroid.occicore.OCCIComputeResponse;
import hu.bme.dszenasi.circleandroid.occicore.OCCILoginResponse;
import hu.bme.dszenasi.circleandroid.vmlist.repository.IVmListRepository;
import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
/**
* Created by danielszenasi on 28/04/16.
*/
public class VmListPresenterImpl implements VmListPresenter {
VmListView view;
IVmListRepository vmListRepository;
public VmListPresenterImpl(IVmListRepository vmListRepository) {
this.vmListRepository = vmListRepository;
}
public void destroyView() {
view = null;
}
public void setView(VmListView view) {
this.view = view;
}
public void getAllCompute() {
Callback<OCCIComputeResponse> callback = new Callback<OCCIComputeResponse>() {
@Override
public void onResponse(Call<OCCIComputeResponse> call, Response<OCCIComputeResponse> response) {
if (response.isSuccessful()) {
view.computeLoaded(response.body().getResources());
} else {
int statusCode = response.code();
ResponseBody errorBody = response.errorBody();
}
}
@Override
public void onFailure(Call<OCCIComputeResponse> call, Throwable t) {
int statusCode = 5;
}
};
vmListRepository.getAllCompute(callback);
}
}
package hu.bme.dszenasi.circleandroid.vmlist.ui;
import java.util.List;
import hu.bme.dszenasi.circleandroid.occicore.Resource;
/**
* Created by mszenasi on 2016-04-28.
*/
public interface VmListView {
void computeLoaded(List<Resource> resources);
}
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".login.ui.LoginActivity">
<!-- Login progress -->
<ProgressBar
android:id="@+id/login_progress"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:visibility="gone" />
<ScrollView
android:id="@+id/login_form"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/email_login_form"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="15dp"
android:text="@string/occiendpointlabel" />
<TextView
android:id="@+id/endpoint"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/occiendpoint" />
</LinearLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<AutoCompleteTextView
android:id="@+id/username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/prompt_username"
android:inputType="text"
android:maxLines="1"
android:singleLine="true" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/prompt_password"
android:imeActionId="@+id/login"
android:imeActionLabel="@string/action_sign_in_short"
android:imeOptions="actionUnspecified"
android:inputType="textPassword"
android:maxLines="1"
android:singleLine="true" />
</android.support.design.widget.TextInputLayout>
<TextView android:id="@+id/error"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#FF0000"
android:visibility="invisible"
/>
<Button
android:id="@+id/email_sign_in_button"
style="?android:textAppearanceSmall"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="@string/action_sign_in"
android:textStyle="bold" />
</LinearLayout>
</ScrollView>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"></LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Template"
android:id="@+id/template" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Create New VM"
android:id="@+id/createvmbutton" />
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"></LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Medium Text"
android:id="@+id/arhitecture" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Medium Text"
android:id="@+id/cores" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Medium Text"
android:id="@+id/hostname" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Medium Text"
android:id="@+id/memory" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Medium Text"
android:id="@+id/share" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Medium Text"
android:id="@+id/state" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Medium Text"
android:id="@+id/stateMessage" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Medium Text"
android:id="@+id/command" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Medium Text"
android:id="@+id/host" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Medium Text"
android:id="@+id/credentialspassword" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Medium Text"
android:id="@+id/port" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Medium Text"
android:id="@+id/protocol" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Medium Text"
android:id="@+id/username" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Start"
android:id="@+id/start" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Restart"
android:id="@+id/restart" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Suspend"
android:id="@+id/suspend" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Delete"
android:id="@+id/delete" />
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="@+id/listView"
android:divider="@null"
android:dividerHeight="0dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"/>
</LinearLayout>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/fab_margin"
android:src="@drawable/ic_plus_black_36dp" />
</android.support.design.widget.CoordinatorLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingBottom="15dp"
android:paddingLeft="30dp"
android:paddingRight="30dp"
android:paddingTop="15dp">
<TextView
android:id="@+id/hostname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16sp"
tools:text="Name" />
<TextView
android:id="@+id/status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:textSize="16sp"
tools:text="Status" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="3">
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
</resources>
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
<dimen name="fab_margin">16dp</dimen>
</resources>
<resources>
<string name="app_name">CircleAndroid</string>
<!-- Strings related to login -->
<string name="prompt_username">Username</string>
<string name="prompt_endpoint">OCCI endpoint</string>
<string name="prompt_password">Password</string>
<string name="action_sign_in">Connect</string>
<string name="action_sign_in_short">Connect</string>
<string name="error_invalid_username">This username is invalid</string>
<string name="error_invalid_password">This password is too short</string>
<string name="error_incorrect_password">This password is incorrect</string>
<string name="error_field_required">This field is required</string>
<string name="permission_rationale">"Contacts permissions are needed for providing email
completions."
</string>
<string name="occiendpoint">vm.ik.bme.hu:1415</string>
<string name="occiendpointlabel">OCCI endpoint:</string>
</resources>
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
</resources>
package hu.bme.dszenasi.circleandroid;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* To work on unit tests, switch the Test Artifact in the Build Variants view.
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() throws Exception {
assertEquals(4, 2 + 2);
}
}
\ No newline at end of file
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
\ No newline at end of file
#Mon Dec 28 10:00:20 PST 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
#!/usr/bin/env bash
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn ( ) {
echo "$*"
}
die ( ) {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
esac
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
JVM_OPTS=("$@")
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windowz variants
if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
goto execute
:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
include ':app'
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment