Skip to content

Commit

Permalink
bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
Francesco committed May 22, 2016
1 parent fdbe7be commit ae55d1a
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 20 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ android {
supportBuildNumber = true
buildNumberPrefix = 'b'

fileNameFormat = 't-ui-vrs_$versionName-build_$versionCode'
fileNameFormat = 't-ui-vrs_$versionName'
}

compileOptions {
Expand All @@ -41,7 +41,7 @@ android {

dependencies {
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.github.Andre1299:CompareString:1.4.1'
compile 'com.github.Andre1299:CompareString:1.4.2'
compile 'commons-io:commons-io:2.4'
}

Expand Down
14 changes: 13 additions & 1 deletion app/src/main/java/ohi/andre/consolelauncher/MainManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -103,19 +104,30 @@ public void onCommand(String input, int id) {
lastCommands.add(input);
lastCommandIndex = lastCommands.size() - 1;

Log.e("andre", "5");

input = input.trim();
input = Tuils.removeUnncesarySpaces(input);

Log.e("andre", "6");
Log.e("andre", input);

for (CmdTrigger trigger : triggers) {
Log.e("andre", trigger.toString());
boolean r;
try {
r = trigger.trigger(info, out, input, id);
} catch (Exception e) {
out.onOutput(Tuils.getStackTrace(e), id);
return;
}
if (r)
Log.e("andre", String.valueOf(r));
if (r) {
Log.e("andre", trigger.toString());
return;
} else {
Log.e("andre", trigger.toString());
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/ohi/andre/consolelauncher/UIManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,8 @@ public TextView getSuggestionView(Context context) {
mTerminalAdapter.setInputListener(new OnNewInputListener() {
@Override
public void onNewInput(String input) {
trigger.exec(input, mTerminalAdapter.getCurrentOutputId());
suggestionsView.removeAllViews();
trigger.exec(input, mTerminalAdapter.getCurrentOutputId());
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,9 +296,14 @@ public int getCurrentOutputId() {
}

public void clear() {
mTerminalView.setText(Tuils.EMPTYSTRING);
mInputView.setText(Tuils.EMPTYSTRING);
mCurrentOutputId = 0;
((Activity) mTerminalView.getContext()).runOnUiThread(new Runnable() {
@Override
public void run() {
mTerminalView.setText(Tuils.EMPTYSTRING);
mInputView.setText(Tuils.EMPTYSTRING);
mCurrentOutputId = 0;
}
});
}

}
23 changes: 10 additions & 13 deletions app/src/main/java/ohi/andre/consolelauncher/tuils/Tuils.java
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,15 @@ public static List<String> getClassesOfPackage(String packageName, Context c)
}

@SuppressWarnings("unchecked")
public static CommandAbstraction getCommandInstance(String cmdName) throws Exception {
Class<CommandAbstraction> clazz = (Class<CommandAbstraction>) Class.forName(cmdName);
Constructor<?> ctor = clazz.getConstructor();
return (CommandAbstraction) ctor.newInstance();
public static CommandAbstraction getCommandInstance(String cmdName) {
Class<CommandAbstraction> clazz;
try {
clazz = (Class<CommandAbstraction>) Class.forName(cmdName);
Constructor<?> constructor = clazz.getConstructor();
return (CommandAbstraction) constructor.newInstance();
} catch (Exception e) {
return null;
}
}

public static int findPrefix(List<String> list, String prefix) {
Expand All @@ -163,14 +168,6 @@ public static int findPrefix(List<String> list, String prefix) {
return -1;
}

public static int count(String string, String toCount) {
return string.length() - string.replaceAll(toCount, "").length();
}

public static int count(CharSequence[] sequences, String toCount) {
return count(toPlanSequence(sequences).toString(), toCount);
}

public static boolean verifyRoot() {
Process p;
try {
Expand Down Expand Up @@ -232,7 +229,7 @@ public static String toPlanString(String[] strings, String separator) {
}

public static String toPlanString(String[] strings) {
return Tuils.toPlanString(strings, "\n");
return Tuils.toPlanString(strings, Tuils.NEWLINE);
}

public static String toPlanString(List<String> strings, String separator) {
Expand Down

0 comments on commit ae55d1a

Please sign in to comment.