Commit cb477cc2 authored by Mathias Stanger's avatar Mathias Stanger

Release V3: ssh-Key-Auswahl kommt nun mit mehrer FileChoosern klar + Tasten skalieren nun mit

parent 36fa2f0c
......@@ -3,20 +3,16 @@
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="distributionType" value="LOCAL" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleHome" value="C:\Program Files\Android\Android Studio\gradle\gradle-2.14.1" />
<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>
<option name="resolveModulePerSourceSet" value="false" />
</GradleProjectSettings>
</option>
</component>
......
<?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" />
......@@ -27,17 +24,7 @@
</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.7" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
......
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "de.matsta.sshclient"
minSdkVersion 17
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
jcenter()
maven { url "https://jitpack.io" }
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.jcraft:jsch:0.1.53'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.redmadrobot:chronos:1.0.5'
compile 'com.github.dmytrodanylyk:android-morphing-button:98a4986e56'
}
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "de.matsta.sshclient"
minSdkVersion 17
targetSdkVersion 23
versionCode 3
versionName "3.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
jcenter()
maven { url "https://jitpack.io" }
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.jcraft:jsch:0.1.53'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.redmadrobot:chronos:1.0.5'
compile 'com.github.dmytrodanylyk:android-morphing-button:98a4986e56'
}
This diff is collapsed.
package de.matsta.yasc.fragments;
import android.Manifest;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import com.dd.morphingbutton.MorphingButton;
import com.redmadrobot.chronos.gui.fragment.ChronosFragment;
import com.redmadrobot.chronos.gui.fragment.ChronosSupportFragment;
import butterknife.Bind;
import butterknife.ButterKnife;
import de.matsta.yasc.R;
import de.matsta.yasc.SharedPrefsTools;
import de.matsta.yasc.SshOperation;
import de.matsta.yasc.Utils;
public class ControlFragment extends ChronosFragment {
@Bind(R.id.btnBuzz)
MorphingButton mBtnBuzz;
@Bind(R.id.btnUnlock)
MorphingButton mBtnUnlock;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.control_fragment, container, false);
ButterKnife.bind(this, view);
setHasOptionsMenu(true);
mBtnBuzz.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View v) {
Utils.morphToSquare(mBtnBuzz, 100);
executeRemote("buzz");
}
}
);
mBtnUnlock.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Utils.morphToSquare(mBtnUnlock, 100);
executeRemote("unlock");
}
});
Utils.morphToButton(mBtnBuzz, "Buzz");
Utils.morphToButton(mBtnUnlock, "Unlock");
return view;
}
private void executeRemote(String command) {
SharedPrefsTools sharedPrefsTools = new SharedPrefsTools(getActivity().getApplicationContext());
runOperation(new SshOperation(
sharedPrefsTools.getHost(), sharedPrefsTools.getUsername(), sharedPrefsTools.getKey(), sharedPrefsTools.getKeyPwd(), sharedPrefsTools.getPort(), command
));
}
@Override
public void onCreateOptionsMenu(
Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.control_fragment_menu, menu);
super.onCreateOptionsMenu(menu, inflater);
}
public void onOperationFinished(final SshOperation.Result result) {
// TODO Rückgabe besser parsen
if (result.isSuccessful()) {
if (result.getOutput().contains("buzz executed")) {
// Buzz hat funktioniert.
Toast.makeText(getActivity(), "Buzz wurde ausgelöst", Toast.LENGTH_SHORT).show();
} else if (result.getOutput().contains("")) {
// Unlock hat funktioniert.
Toast.makeText(getActivity(), "Tür wurde entsperrt", Toast.LENGTH_SHORT).show();
} else {
// Fallback
Toast.makeText(getActivity(), result.getOutput(), Toast.LENGTH_LONG).show();
}
// Buttons wieder zurücksetzen
Utils.morphToButton(mBtnBuzz, "Buzz");
Utils.morphToButton(mBtnUnlock, "Unlock");
} else {
Toast.makeText(getActivity(), result.getErrorMessage(), Toast.LENGTH_LONG).show();
Log.d(this.getClass().getSimpleName(), result.getErrorMessage());
}
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.action_config:
// Einstellungen anzeigen
SettingsFragment fragment = new SettingsFragment();
getActivity().getFragmentManager().beginTransaction().replace(R.id.fragment_container, fragment, getString(R.string.config)).addToBackStack(null).commit();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
}
package de.matsta.yasc.fragments;
import android.Manifest;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import com.dd.morphingbutton.MorphingButton;
import com.redmadrobot.chronos.gui.fragment.ChronosFragment;
import com.redmadrobot.chronos.gui.fragment.ChronosSupportFragment;
import butterknife.Bind;
import butterknife.ButterKnife;
import de.matsta.yasc.R;
import de.matsta.yasc.SharedPrefsTools;
import de.matsta.yasc.SshOperation;
import de.matsta.yasc.Utils;
public class ControlFragment extends ChronosFragment {
@Bind(R.id.btnBuzz)
MorphingButton mBtnBuzz;
@Bind(R.id.btnUnlock)
MorphingButton mBtnUnlock;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.control_fragment, container, false);
ButterKnife.bind(this, view);
setHasOptionsMenu(true);
mBtnBuzz.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View v) {
Utils.morphToSquare(mBtnBuzz, 100, getResources());
executeRemote("buzz");
}
}
);
mBtnUnlock.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Utils.morphToSquare(mBtnUnlock, 100, getResources());
executeRemote("unlock");
}
});
Utils.morphToButton(mBtnBuzz, "Buzz", getResources());
Utils.morphToButton(mBtnUnlock, "Unlock", getResources());
return view;
}
private void executeRemote(String command) {
SharedPrefsTools sharedPrefsTools = new SharedPrefsTools(getActivity().getApplicationContext());
runOperation(new SshOperation(
sharedPrefsTools.getHost(), sharedPrefsTools.getUsername(), sharedPrefsTools.getKey(), sharedPrefsTools.getKeyPwd(), sharedPrefsTools.getPort(), command
));
}
@Override
public void onCreateOptionsMenu(
Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.control_fragment_menu, menu);
super.onCreateOptionsMenu(menu, inflater);
}
public void onOperationFinished(final SshOperation.Result result) {
// TODO Rückgabe besser parsen
if (result.isSuccessful()) {
if (result.getOutput().contains("buzz executed")) {
// Buzz hat funktioniert.
Toast.makeText(getActivity(), "Buzz wurde ausgelöst", Toast.LENGTH_SHORT).show();
} else if (result.getOutput().contains("")) {
// Unlock hat funktioniert.
Toast.makeText(getActivity(), "Tür wurde entsperrt", Toast.LENGTH_SHORT).show();
} else {
// Fallback
Toast.makeText(getActivity(), result.getOutput(), Toast.LENGTH_LONG).show();
}
// Buttons wieder zurücksetzen
Utils.morphToButton(mBtnBuzz, "Buzz", getResources());
Utils.morphToButton(mBtnUnlock, "Unlock", getResources());
} else {
Toast.makeText(getActivity(), result.getErrorMessage(), Toast.LENGTH_LONG).show();
Log.d(this.getClass().getSimpleName(), result.getErrorMessage());
}
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.action_config:
// Einstellungen anzeigen
SettingsFragment fragment = new SettingsFragment();
getActivity().getFragmentManager().beginTransaction().replace(R.id.fragment_container, fragment, getString(R.string.config)).addToBackStack(null).commit();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
}
package de.matsta.yasc.fragments;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.PreferenceFragment;
import android.util.Log;
import android.widget.Toast;
import java.net.URISyntaxException;
import de.matsta.yasc.R;
import de.matsta.yasc.SharedPrefsTools;
import de.matsta.yasc.Utils;
public class SettingsFragment extends PreferenceFragment {
private static final int FILE_SELECT_CODE = 0;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preferences);
Preference keyPref = (Preference) findPreference(SharedPrefsTools.KEY_KEY);
keyPref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
public boolean onPreferenceClick(Preference preference) {
showFileChooser();
return false;
}
});
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (requestCode) {
case FILE_SELECT_CODE:
if (resultCode == Activity.RESULT_OK) {
// Wir erhalten eine URI um auf die Datei zuzugreifen
Uri uri = data.getData();
// Wir wollen aber keine Uri sondern den Pfad
try {
String path = Utils.getPath(getActivity(), uri);
if (path == null) {
throw new Exception(getString(R.string.exceptionPathNotParseable));
}
new SharedPrefsTools(getActivity()).setKey(path);
} catch (Exception e) {
Log.e(this.getClass().getSimpleName(), e.getLocalizedMessage());
}
}
break;
}
super.onActivityResult(requestCode, resultCode, data);
}
private void showFileChooser() {
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("*/*");
intent.addCategory(Intent.CATEGORY_OPENABLE);
try {
startActivityForResult(
Intent.createChooser(intent, getString(R.string.selectPrivateKey)),
FILE_SELECT_CODE);
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(getActivity(), R.string.installFilebrowser,
Toast.LENGTH_SHORT).show();
}
}
}
package de.matsta.yasc.fragments;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.PreferenceFragment;
import android.util.Log;
import android.widget.Toast;
import java.net.URISyntaxException;
import de.matsta.yasc.R;
import de.matsta.yasc.SharedPrefsTools;
import de.matsta.yasc.Utils;
public class SettingsFragment extends PreferenceFragment {
private static final int FILE_SELECT_CODE = 0;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preferences);
Preference keyPref = (Preference) findPreference(SharedPrefsTools.KEY_KEY);
keyPref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
public boolean onPreferenceClick(Preference preference) {
showFileChooser();
return false;
}
});
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (requestCode) {
case FILE_SELECT_CODE:
if (resultCode == Activity.RESULT_OK) {
// Wir erhalten eine URI um auf die Datei zuzugreifen
Uri uri = data.getData();
// Wir wollen aber keine Uri sondern den Pfad
try {
String path = Utils.getPath(getActivity(), uri);
if (path == null) {
throw new Exception(getString(R.string.exceptionPathNotParseable));
}
new SharedPrefsTools(getActivity()).setKey(path);
} catch (Exception e) {
Log.e(this.getClass().getSimpleName(), e.getLocalizedMessage());
}
}
break;
}
super.onActivityResult(requestCode, resultCode, data);
}
private void showFileChooser() {
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("*/*");
intent.addCategory(Intent.CATEGORY_OPENABLE);
try {
startActivityForResult(
Intent.createChooser(intent, getString(R.string.selectPrivateKey)),
FILE_SELECT_CODE);
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(getActivity(), R.string.installFilebrowser,
Toast.LENGTH_SHORT).show();
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="buttonHight">70dp</dimen>
<dimen name="buttonWidth">400dp</dimen>
<dimen name="buttonCornerRadius">2dp</dimen>
<dimen name="buttonSuccessHight">80dp</dimen>
<dimen name="buttonSuccessWidth">80dp</dimen>
<dimen name="buttonSuccessCornerRadius">80dp</dimen>
<dimen name="buttonFailureHight">80dp</dimen>
<dimen name="buttonFailureWidth">80dp</dimen>
<dimen name="buttonFailureCornerRadius">80dp</dimen>
<dimen name="buttonSquareHight">70dp</dimen>
<dimen name="buttonSquareWidth">400dp</dimen>
<dimen name="buttonSquareCornerRadius">2dp</dimen>
</resources>
// 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.2'
// 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
}
// 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.2.2'
// 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
}
#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
#Wed Oct 05 22:04:37 CEST 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
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 to comment