comparison src/com/five_ten_sg/connectbot/HostListActivity.java @ 34:75d86b7fd3f0 tn5250

make hostlist and pubkeylist consistent
author Carl Byington <carl@five-ten-sg.com>
date Tue, 10 Jun 2014 15:18:04 -0700
parents 0ce5cc452d02
children 9925ea1aa279
comparison
equal deleted inserted replaced
33:2a8b52dbc104 34:75d86b7fd3f0
95 95
96 private ServiceConnection connection = new ServiceConnection() { 96 private ServiceConnection connection = new ServiceConnection() {
97 public void onServiceConnected(ComponentName className, IBinder service) { 97 public void onServiceConnected(ComponentName className, IBinder service) {
98 bound = ((TerminalManager.TerminalBinder) service).getService(); 98 bound = ((TerminalManager.TerminalBinder) service).getService();
99 // update our listview binder to find the service 99 // update our listview binder to find the service
100 HostListActivity.this.updateList(); 100 updateList();
101 } 101 }
102 public void onServiceDisconnected(ComponentName className) { 102 public void onServiceDisconnected(ComponentName className) {
103 bound = null; 103 bound = null;
104 HostListActivity.this.updateList(); 104 updateList();
105 } 105 }
106 }; 106 };
107 107
108 @Override 108 @Override
109 public void onStart() { 109 public void onStart() {
144 // user didnt agree, so close 144 // user didnt agree, so close
145 this.finish(); 145 this.finish();
146 } 146 }
147 } 147 }
148 else if (requestCode == REQUEST_EDIT) { 148 else if (requestCode == REQUEST_EDIT) {
149 this.updateList(); 149 updateList();
150 } 150 }
151 } 151 }
152 152
153 @Override 153 @Override
154 public void onCreate(Bundle icicle) { 154 public void onCreate(Bundle icicle) {
172 172
173 // check for eula agreement 173 // check for eula agreement
174 boolean agreed = prefs.getBoolean(PreferenceConstants.EULA, false); 174 boolean agreed = prefs.getBoolean(PreferenceConstants.EULA, false);
175 175
176 if (!agreed) { 176 if (!agreed) {
177 this.startActivityForResult(new Intent(this, WizardActivity.class), REQUEST_EULA); 177 startActivityForResult(new Intent(this, WizardActivity.class), REQUEST_EULA);
178 } 178 }
179 179
180 this.makingShortcut = Intent.ACTION_CREATE_SHORTCUT.equals(getIntent().getAction()) 180 makingShortcut = Intent.ACTION_CREATE_SHORTCUT.equals(getIntent().getAction())
181 || Intent.ACTION_PICK.equals(getIntent().getAction()); 181 || Intent.ACTION_PICK.equals(getIntent().getAction());
182 // connect with hosts database and populate list 182 // connect with hosts database and populate list
183 this.hostdb = new HostDatabase(this); 183 hostdb = new HostDatabase(this);
184 ListView list = this.getListView(); 184 updateList();
185 this.sortedByColor = prefs.getBoolean(PreferenceConstants.SORT_BY_COLOR, false); 185 sortedByColor = prefs.getBoolean(PreferenceConstants.SORT_BY_COLOR, false);
186 //this.list.setSelector(R.drawable.highlight_disabled_pressed); 186 registerForContextMenu(getListView());
187 list.setOnItemClickListener(new OnItemClickListener() { 187 getListView().setOnItemClickListener(new OnItemClickListener() {
188 188
189 public synchronized void onItemClick(AdapterView<?> parent, View view, int position, long id) { 189 public synchronized void onItemClick(AdapterView<?> parent, View view, int position, long id) {
190 // launch off to console details 190 // launch off to console details
191 HostBean host = (HostBean) parent.getAdapter().getItem(position); 191 HostBean host = (HostBean) getListView().getItemAtPosition(position);
192 Uri uri = host.getUri(); 192 Uri uri = host.getUri();
193 Intent contents = new Intent(Intent.ACTION_VIEW, uri); 193 Intent contents = new Intent(Intent.ACTION_VIEW, uri);
194 contents.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 194 contents.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
195 195
196 if (makingShortcut) { 196 if (makingShortcut) {
203 setResult(RESULT_OK, intent); 203 setResult(RESULT_OK, intent);
204 finish(); 204 finish();
205 } 205 }
206 else { 206 else {
207 // otherwise just launch activity to show this host 207 // otherwise just launch activity to show this host
208 HostListActivity.this.startActivity(contents); 208 startActivity(contents);
209 } 209 }
210 } 210 }
211 }); 211 });
212 this.registerForContextMenu(list);
213 quickconnect = (TextView) this.findViewById(R.id.front_quickconnect); 212 quickconnect = (TextView) this.findViewById(R.id.front_quickconnect);
214 quickconnect.setVisibility(makingShortcut ? View.GONE : View.VISIBLE); 213 quickconnect.setVisibility(makingShortcut ? View.GONE : View.VISIBLE);
215 quickconnect.setOnKeyListener(new OnKeyListener() { 214 quickconnect.setOnKeyListener(new OnKeyListener() {
216 public boolean onKey(View v, int keyCode, KeyEvent event) { 215 public boolean onKey(View v, int keyCode, KeyEvent event) {
217 if (event.getAction() == KeyEvent.ACTION_UP) return false; 216 if (event.getAction() == KeyEvent.ACTION_UP) return false;