Skip to content

Style app with material design icons #700

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 18 commits into
base: release
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.4.0-beta6'
classpath 'com.android.tools.build:gradle:1.5.0'
}
}

6 changes: 3 additions & 3 deletions cSploit/build.gradle
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.4.0-beta6'
classpath 'com.android.tools.build:gradle:1.5.0'
}
}

@@ -52,8 +52,8 @@ android {
defaultConfig {
minSdkVersion 9
targetSdkVersion 22
versionCode 3
versionName "1.6.1"
versionCode 6
versionName "1.6.5"
if(System.getenv("NIGHTLY_BUILD")) {
versionName += "+" + System.getenv("NIGHTLY_BUILD_COMMIT").substring(0, 7)
}
30 changes: 17 additions & 13 deletions cSploit/res/layout/plugin_inspector.xml
Original file line number Diff line number Diff line change
@@ -6,19 +6,6 @@
android:paddingTop="16sp"
android:id="@+id/whatever">

<android.support.design.widget.FloatingActionButton
android:id="@+id/inspectToggleButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="20dp"
android:src="@drawable/ic_play_arrow_24dp"
android:checked="false"
android:translationZ="8dp"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_margin="20dp"
android:focusableInTouchMode="true" />

<ProgressBar
android:id="@+id/inspectActivity"
android:layout_width="wrap_content"
@@ -156,4 +143,21 @@
android:gravity="center_vertical"
/>
</ScrollView>

<!--
Later children in a RelativeLayout tend to float over earlier children in a RelativeLayout.
https://www.stackoverflow.com/a/28651543
-->
<android.support.design.widget.FloatingActionButton
android:id="@+id/inspectToggleButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="20dp"
android:src="@drawable/ic_play_arrow_24dp"
android:checked="false"
android:translationZ="8dp"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_margin="20dp"
android:focusableInTouchMode="true" />
</RelativeLayout>
1 change: 1 addition & 0 deletions cSploit/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -529,4 +529,5 @@
<string name="mitm_ss_select_target_prompt">Select %s ?</string>
<string name="github_issues_url" translatable="false">https://github.com/cSploit/android/issues</string>
<string name="issue_message"><![CDATA[<p>Before opening a new issue, please, take the time to read the already <a href="%1$s">open issues</a>, probably it\' s already open. If it\' s not open we\'ll need as much information as you can get, so please, read <a href="%2$s">this guide</a> in order to know how to report a bug properly.</p>]]></string>
<string name="pref_err_empty_or_old">must be empty or an old installation directory.</string>
</resources>
2 changes: 1 addition & 1 deletion cSploit/src/org/csploit/android/MainActivity.java
Original file line number Diff line number Diff line change
@@ -1130,7 +1130,7 @@ public void onReceive(Context context, Intent intent) {
mUpdateStatus.setText(UPDATE_MESSAGE.replace(
"#STATUS#", getString(R.string.no_updates_available)));

if (!System.isCoreInitialized()) {
if (!System.isCoreInstalled()) {
onInitializationError(getString(R.string.no_core_found));
}
break;
107 changes: 80 additions & 27 deletions cSploit/src/org/csploit/android/SettingsActivity.java
Original file line number Diff line number Diff line change
@@ -214,14 +214,84 @@ public void onEnd(int exitCode) {
}
}

private boolean isDirectoryEmptyOrWithVersion(File folder) {
String[] files = folder.list();

if(files.length > 0) {
for(String fname : files) {
if("VERSION".equals(fname)) {
return true;
}
}
return false;
}

return true;
}

private ExecChecker getCheckerForKey(String key) {
switch (key) {
case "RUBY_DIR":
return ExecChecker.ruby();
case "MSF_DIR":
return ExecChecker.msf();
}
return null;
}

private String getCurrentPathForKey(String key) {
switch (key) {
case "RUBY_DIR":
return System.getRubyPath();
case "MSF_DIR":
return System.getMsfPath();
}
return null;
}

private boolean shallAskForDelete(String key) {
return key.equals("RUBY_DIR") || key.equals("MSF_DIR");
}

/**
* check if selected directory is valid for the given key.
* @param key to be updated
* @param path of the chosen directory
* @return true if {@code path} is valid, false otherwise
*/
private boolean canChangeDirectoryTo(String key, String path) {
File folder = new File(path);
ExecChecker checker = getCheckerForKey(key);
String oldPath = getCurrentPathForKey(key);
String toastMessage = null;
boolean valid = false;
boolean checkEmptyOrVersion = shallAskForDelete(key);

if (!folder.exists()) {
toastMessage = getString(R.string.pref_folder) + " " + path + " " + getString(R.string.pref_err_exists);
} else if (!folder.canWrite()) {
toastMessage = getString(R.string.pref_folder) + " " + path + " " + getString(R.string.pref_err_writable);
} else if (checker != null && !checker.canExecuteInDir(path)) {
toastMessage = getString(R.string.pref_folder) + " " + path + " " + getString(R.string.pref_err_executable);
} else if (checkEmptyOrVersion && !isDirectoryEmptyOrWithVersion(folder)) {
toastMessage = getString(R.string.pref_folder) + " " + path + " " + getString(R.string.pref_err_empty_or_old);
} else if (oldPath == null || !oldPath.equals(path)) {
valid = true;
}

if(toastMessage != null) {
Toast.makeText(getContext(), toastMessage, Toast.LENGTH_LONG).show();
}

return valid;
}

@Override
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
if (requestCode == DirectoryPicker.PICK_DIRECTORY && resultCode != RESULT_CANCELED) {
Bundle extras = intent.getExtras();
String path;
String key;
File folder;
String oldPath = null;

if (extras == null) {
Logger.debug("null extra: " + intent);
@@ -236,35 +306,18 @@ public void onActivityResult(int requestCode, int resultCode, Intent intent) {
return;
}

folder = new File(path);
ExecChecker checker = null;


if (key.equals("RUBY_DIR")) {
oldPath = System.getRubyPath();
checker = ExecChecker.ruby();
} else if (key.equals("MSF_DIR")) {
oldPath = System.getMsfPath();
checker = ExecChecker.msf();
}

if (!folder.exists())
Toast.makeText(getActivity(), getString(R.string.pref_folder) + " " + path + " " + getString(R.string.pref_err_exists), Toast.LENGTH_SHORT).show();

else if (!folder.canWrite())
Toast.makeText(getActivity(), getString(R.string.pref_folder) + " " + path + " " + getString(R.string.pref_err_writable), Toast.LENGTH_SHORT).show();
if(canChangeDirectoryTo(key, path)) {

else if (checker != null && !checker.canExecuteInDir(path))
Toast.makeText(getActivity(), getString(R.string.pref_folder) + " " + path + " " + getString(R.string.pref_err_executable), Toast.LENGTH_LONG).show();

else {
//noinspection ConstantConditions
getPreferenceManager().getSharedPreferences().edit().putString(key, path).commit();
if (oldPath != null && !oldPath.equals(path)) {
File current = new File(oldPath);

if (current.exists() && current.isDirectory() && current.listFiles().length > 2) {
wipe_prompt_older(current);
if(shallAskForDelete(key)) {
String oldPath = getCurrentPathForKey(key);
if(oldPath != null) {
File current = new File(oldPath);
if(current.exists() && current.isDirectory() && current.list().length > 0) {
wipe_prompt_older(current);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@

import android.app.Activity;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
@@ -68,16 +69,21 @@ private void showToastForStatus(Context context, MsfRpcdService.Status status) {
}

private void updateNotificationForStatus(Context context, MsfRpcdService.Status status) {
NotificationCompat.Builder mBuilder =
NotificationCompat.Builder builder =
new NotificationCompat.Builder(context)
.setSmallIcon(R.drawable.exploit_msf)
.setContentTitle(context.getString(R.string.msf_status))
.setProgress(0, 0, status.inProgress())
.setContentText(context.getString(status.getText()))
.setColor(ContextCompat.getColor(context, status.getColor()));

PendingIntent pendingIntent = PendingIntent.getActivity(context, 0,
new Intent(), PendingIntent.FLAG_UPDATE_CURRENT);

builder.setContentIntent(pendingIntent);

NotificationManager mNotificationManager =
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.notify(MSF_NOTIFICATION, mBuilder.build());
mNotificationManager.notify(MSF_NOTIFICATION, builder.build());
}
}