forked from cSploit/android
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathActionActivity.java
More file actions
159 lines (132 loc) · 5.22 KB
/
Copy pathActionActivity.java
File metadata and controls
159 lines (132 loc) · 5.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
/*
* This file is part of the dSploit.
*
* Copyleft of Simone Margaritelli aka evilsocket <evilsocket@gmail.com>
*
* dSploit is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* dSploit is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with dSploit. If not, see <http://www.gnu.org/licenses/>.
*/
package org.csploit.android;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import org.csploit.android.core.Plugin;
import org.csploit.android.core.System;
import org.csploit.android.gui.dialogs.FinishDialog;
import org.csploit.android.net.Target;
import java.util.ArrayList;
public class ActionActivity extends AppCompatActivity {
private ArrayList<Plugin> mAvailable = null;
private ListView theList;
private Target mTarget;
@Override
public void onCreate(Bundle savedInstanceState) {
SharedPreferences themePrefs = getSharedPreferences("THEME", 0);
Boolean isDark = themePrefs.getBoolean("isDark", false);
if (isDark)
setTheme(R.style.DarkTheme);
else
setTheme(R.style.AppTheme);
super.onCreate(savedInstanceState);
mTarget = System.getCurrentTarget();
if (mTarget != null) {
setTitle("cSploit > " + mTarget);
setContentView(R.layout.actions_layout);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
theList = (ListView) findViewById(R.id.android_list);
mAvailable = System.getPluginsForTarget();
ActionsAdapter mActionsAdapter = new ActionsAdapter();
theList.setAdapter(mActionsAdapter);
theList.setOnItemClickListener(new ListView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
if (System.checkNetworking(ActionActivity.this)) {
Plugin plugin = mAvailable.get(position);
System.setCurrentPlugin(plugin);
if (plugin.hasLayoutToShow()) {
Toast.makeText(ActionActivity.this, getString(R.string.selected) + getString(plugin.getName()), Toast.LENGTH_SHORT).show();
startActivity(new Intent(
ActionActivity.this,
plugin.getClass()
));
overridePendingTransition(R.anim.fadeout, R.anim.fadein);
} else
plugin.onActionClick(getApplicationContext());
}
}
});
} else {
new FinishDialog(getString(R.string.warning), getString(R.string.something_went_wrong), this).show();
}
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
onBackPressed();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
@Override
public void onBackPressed() {
super.onBackPressed();
overridePendingTransition(R.anim.fadeout, R.anim.fadein);
}
public class ActionsAdapter extends ArrayAdapter<Plugin> {
public ActionsAdapter() {
super(ActionActivity.this, R.layout.actions_list_item, mAvailable);
}
@SuppressLint("NewApi")
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View row = convertView;
ActionHolder holder;
if (row == null) {
LayoutInflater inflater = (LayoutInflater) ActionActivity.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
row = inflater.inflate(R.layout.actions_list_item, parent, false);
if (getSharedPreferences("THEME", 0).getBoolean("isDark", false))
row.setBackgroundResource(R.drawable.card_background_dark);
holder = new ActionHolder();
holder.icon = (ImageView) (row != null ? row.findViewById(R.id.actionIcon) : null);
holder.name = (TextView) (row != null ? row.findViewById(R.id.actionName) : null);
holder.description = (TextView) (row != null ? row.findViewById(R.id.actionDescription) : null);
if (row != null) row.setTag(holder);
} else holder = (ActionHolder) row.getTag();
Plugin action = mAvailable.get(position);
holder.icon.setImageResource(action.getIconResourceId());
holder.name.setText(getString(action.getName()));
holder.description.setText(getString(action.getDescription()));
return row;
}
public class ActionHolder {
ImageView icon;
TextView name;
TextView description;
}
}
}