|
42 | 42 | import java.util.ArrayList; |
43 | 43 |
|
44 | 44 | public class ActionActivity extends AppCompatActivity { |
45 | | - private ArrayList<Plugin> mAvailable = null; |
46 | | - private ListView theList; |
47 | | - |
48 | | - @Override |
49 | | - public void onCreate(Bundle savedInstanceState) { |
50 | | - SharedPreferences themePrefs = getSharedPreferences("THEME", 0); |
51 | | - Boolean isDark = themePrefs.getBoolean("isDark", false); |
52 | | - |
53 | | - if (isDark) |
54 | | - setTheme(R.style.DarkTheme); |
55 | | - else |
56 | | - setTheme(R.style.AppTheme); |
57 | | - super.onCreate(savedInstanceState); |
58 | | - |
59 | | - if (System.getTargets() != null && System.getTargets().size() > 0 && System.getCurrentTarget() != null) { |
60 | | - setTitle("cSploit > " + System.getCurrentTarget()); |
61 | | - setContentView(R.layout.actions_layout); |
62 | | - getSupportActionBar().setDisplayHomeAsUpEnabled(true); |
63 | | - theList = (ListView) findViewById(R.id.android_list); |
64 | | - mAvailable = System.getPluginsForTarget(); |
65 | | - ActionsAdapter mActionsAdapter = new ActionsAdapter(); |
66 | | - theList.setAdapter(mActionsAdapter); |
67 | | - theList.setOnItemClickListener(new ListView.OnItemClickListener() { |
68 | | - @Override |
69 | | - public void onItemClick(AdapterView<?> parent, View view, int position, long id) { |
70 | | - |
71 | | - if (System.checkNetworking(ActionActivity.this)) { |
72 | | - Plugin plugin = mAvailable.get(position); |
73 | | - System.setCurrentPlugin(plugin); |
74 | | - |
75 | | - if (plugin.hasLayoutToShow()) { |
76 | | - Toast.makeText(ActionActivity.this, getString(R.string.selected) + getString(plugin.getName()), Toast.LENGTH_SHORT).show(); |
77 | | - |
78 | | - startActivity(new Intent( |
79 | | - ActionActivity.this, |
80 | | - plugin.getClass() |
81 | | - )); |
82 | | - overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_left); |
83 | | - } else |
84 | | - plugin.onActionClick(getApplicationContext()); |
85 | | - } |
86 | | - } |
87 | | - }); |
88 | | - } else { |
89 | | - new FinishDialog(getString(R.string.warning), getString(R.string.something_went_wrong), this).show(); |
| 45 | + private ArrayList<Plugin> mAvailable = null; |
| 46 | + private ListView theList; |
| 47 | + |
| 48 | + @Override |
| 49 | + public void onCreate(Bundle savedInstanceState) { |
| 50 | + SharedPreferences themePrefs = getSharedPreferences("THEME", 0); |
| 51 | + Boolean isDark = themePrefs.getBoolean("isDark", false); |
| 52 | + |
| 53 | + if (isDark) |
| 54 | + setTheme(R.style.DarkTheme); |
| 55 | + else |
| 56 | + setTheme(R.style.AppTheme); |
| 57 | + super.onCreate(savedInstanceState); |
| 58 | + |
| 59 | + if (System.getTargets() != null && System.getTargets().size() > 0 && System.getCurrentTarget() != null) { |
| 60 | + setTitle("cSploit > " + System.getCurrentTarget()); |
| 61 | + setContentView(R.layout.actions_layout); |
| 62 | + getSupportActionBar().setDisplayHomeAsUpEnabled(true); |
| 63 | + theList = (ListView) findViewById(R.id.android_list); |
| 64 | + mAvailable = System.getPluginsForTarget(); |
| 65 | + ActionsAdapter mActionsAdapter = new ActionsAdapter(); |
| 66 | + theList.setAdapter(mActionsAdapter); |
| 67 | + theList.setOnItemClickListener(new ListView.OnItemClickListener() { |
| 68 | + @Override |
| 69 | + public void onItemClick(AdapterView<?> parent, View view, int position, long id) { |
| 70 | + |
| 71 | + if (System.checkNetworking(ActionActivity.this)) { |
| 72 | + Plugin plugin = mAvailable.get(position); |
| 73 | + System.setCurrentPlugin(plugin); |
| 74 | + |
| 75 | + if (plugin.hasLayoutToShow()) { |
| 76 | + Toast.makeText(ActionActivity.this, getString(R.string.selected) + getString(plugin.getName()), Toast.LENGTH_SHORT).show(); |
| 77 | + |
| 78 | + startActivity(new Intent( |
| 79 | + ActionActivity.this, |
| 80 | + plugin.getClass() |
| 81 | + )); |
| 82 | + overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_left); |
| 83 | + } else |
| 84 | + plugin.onActionClick(getApplicationContext()); |
| 85 | + } |
90 | 86 | } |
| 87 | + }); |
| 88 | + } else { |
| 89 | + new FinishDialog(getString(R.string.warning), getString(R.string.something_went_wrong), this).show(); |
91 | 90 | } |
| 91 | + } |
92 | 92 |
|
93 | 93 |
|
94 | | - @Override |
95 | | - public boolean onOptionsItemSelected(MenuItem item) { |
96 | | - switch (item.getItemId()) { |
97 | | - case android.R.id.home: |
| 94 | + @Override |
| 95 | + public boolean onOptionsItemSelected(MenuItem item) { |
| 96 | + switch (item.getItemId()) { |
| 97 | + case android.R.id.home: |
98 | 98 |
|
99 | | - onBackPressed(); |
| 99 | + onBackPressed(); |
100 | 100 |
|
101 | | - return true; |
| 101 | + return true; |
102 | 102 |
|
103 | | - default: |
104 | | - return super.onOptionsItemSelected(item); |
105 | | - } |
| 103 | + default: |
| 104 | + return super.onOptionsItemSelected(item); |
106 | 105 | } |
| 106 | + } |
107 | 107 |
|
108 | 108 |
|
109 | | - @Override |
110 | | - public void onBackPressed() { |
111 | | - super.onBackPressed(); |
112 | | - overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_left); |
113 | | - } |
| 109 | + @Override |
| 110 | + public void onBackPressed() { |
| 111 | + super.onBackPressed(); |
| 112 | + overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_left); |
| 113 | + } |
114 | 114 |
|
115 | | - public class ActionsAdapter extends ArrayAdapter<Plugin> { |
116 | | - public ActionsAdapter() { |
117 | | - super(ActionActivity.this, R.layout.actions_list_item, mAvailable); |
118 | | - } |
| 115 | + public class ActionsAdapter extends ArrayAdapter<Plugin> { |
| 116 | + public ActionsAdapter() { |
| 117 | + super(ActionActivity.this, R.layout.actions_list_item, mAvailable); |
| 118 | + } |
119 | 119 |
|
120 | | - @SuppressLint("NewApi") |
121 | | - @Override |
122 | | - public View getView(int position, View convertView, ViewGroup parent) { |
123 | | - View row = convertView; |
124 | | - ActionHolder holder; |
| 120 | + @SuppressLint("NewApi") |
| 121 | + @Override |
| 122 | + public View getView(int position, View convertView, ViewGroup parent) { |
| 123 | + View row = convertView; |
| 124 | + ActionHolder holder; |
125 | 125 |
|
126 | | - if (row == null) { |
127 | | - LayoutInflater inflater = (LayoutInflater) ActionActivity.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); |
128 | | - row = inflater.inflate(R.layout.actions_list_item, parent, false); |
129 | | - if (getSharedPreferences("THEME", 0).getBoolean("isDark", false)) |
130 | | - row.setBackground(getResources().getDrawable(R.drawable.card_background_dark)); |
131 | | - holder = new ActionHolder(); |
| 126 | + if (row == null) { |
| 127 | + LayoutInflater inflater = (LayoutInflater) ActionActivity.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); |
| 128 | + row = inflater.inflate(R.layout.actions_list_item, parent, false); |
| 129 | + if (getSharedPreferences("THEME", 0).getBoolean("isDark", false)) |
| 130 | + row.setBackground(getResources().getDrawable(R.drawable.card_background_dark)); |
| 131 | + holder = new ActionHolder(); |
132 | 132 |
|
133 | | - holder.icon = (ImageView) (row != null ? row.findViewById(R.id.actionIcon) : null); |
134 | | - holder.name = (TextView) (row != null ? row.findViewById(R.id.actionName) : null); |
135 | | - holder.description = (TextView) (row != null ? row.findViewById(R.id.actionDescription) : null); |
136 | | - if (row != null) row.setTag(holder); |
| 133 | + holder.icon = (ImageView) (row != null ? row.findViewById(R.id.actionIcon) : null); |
| 134 | + holder.name = (TextView) (row != null ? row.findViewById(R.id.actionName) : null); |
| 135 | + holder.description = (TextView) (row != null ? row.findViewById(R.id.actionDescription) : null); |
| 136 | + if (row != null) row.setTag(holder); |
137 | 137 |
|
138 | | - } else holder = (ActionHolder) row.getTag(); |
| 138 | + } else holder = (ActionHolder) row.getTag(); |
139 | 139 |
|
140 | | - Plugin action = mAvailable.get(position); |
| 140 | + Plugin action = mAvailable.get(position); |
141 | 141 |
|
142 | | - holder.icon.setImageResource(action.getIconResourceId()); |
143 | | - holder.name.setText(getString(action.getName())); |
144 | | - holder.description.setText(getString(action.getDescription())); |
| 142 | + holder.icon.setImageResource(action.getIconResourceId()); |
| 143 | + holder.name.setText(getString(action.getName())); |
| 144 | + holder.description.setText(getString(action.getDescription())); |
145 | 145 |
|
146 | | - return row; |
147 | | - } |
| 146 | + return row; |
| 147 | + } |
148 | 148 |
|
149 | | - public class ActionHolder { |
150 | | - ImageView icon; |
151 | | - TextView name; |
152 | | - TextView description; |
153 | | - } |
| 149 | + public class ActionHolder { |
| 150 | + ImageView icon; |
| 151 | + TextView name; |
| 152 | + TextView description; |
154 | 153 | } |
| 154 | + } |
155 | 155 | } |
0 commit comments