|
@@ -7,10 +7,12 @@ |
7 |
7 |
|
import android.app.Fragment; |
8 |
8 |
|
import android.app.FragmentManager; |
9 |
9 |
|
import android.app.FragmentTransaction; |
|
10 |
+ |
import android.app.Service; |
10 |
11 |
|
import android.content.ActivityNotFoundException; |
11 |
12 |
|
import android.content.Context; |
12 |
13 |
|
import android.content.DialogInterface; |
13 |
14 |
|
import android.content.Intent; |
|
15 |
+ |
import android.content.res.Configuration; |
14 |
16 |
|
import android.graphics.Bitmap; |
15 |
17 |
|
import android.graphics.BitmapFactory; |
16 |
18 |
|
import android.graphics.Canvas; |
|
@@ -26,6 +28,7 @@ |
26 |
28 |
|
import android.view.KeyEvent; |
27 |
29 |
|
import android.view.View; |
28 |
30 |
|
import android.view.ViewGroup; |
|
31 |
+ |
import android.view.ViewTreeObserver; |
29 |
32 |
|
import android.view.inputmethod.EditorInfo; |
30 |
33 |
|
import android.view.inputmethod.InputMethodManager; |
31 |
34 |
|
import android.widget.Button; |
|
@@ -36,6 +39,7 @@ |
36 |
39 |
|
import android.widget.RelativeLayout; |
37 |
40 |
|
import android.widget.ScrollView; |
38 |
41 |
|
import android.widget.TextView; |
|
42 |
+ |
import android.widget.Toast; |
39 |
43 |
|
|
40 |
44 |
|
import com.google.android.gms.maps.CameraUpdate; |
41 |
45 |
|
import com.google.android.gms.maps.CameraUpdateFactory; |
|
@@ -50,6 +54,7 @@ |
50 |
54 |
|
import it.fedeloper.smartcharging.*; |
51 |
55 |
|
import it.fedeloper.smartcharging.Manager.MyLocation; |
52 |
56 |
|
import it.fedeloper.smartcharging.Manager.PrefsManager; |
|
57 |
+ |
|
53 |
58 |
|
import it.fedeloper.smartcharging.Manager.Utils; |
54 |
59 |
|
import it.fedeloper.smartcharging.Service.EndPoint; |
55 |
60 |
|
import it.fedeloper.smartcharging.Service.HttpClient; |
|
@@ -141,24 +146,31 @@ |
141 |
146 |
|
|
142 |
147 |
|
final EditText addressView = (EditText) findViewById(R.id.editText6); |
143 |
148 |
|
addressView.setImeOptions(EditorInfo.IME_ACTION_DONE); |
144 |
|
- |
addressView.setOnEditorActionListener(new TextView.OnEditorActionListener() { |
145 |
|
- |
@Override |
146 |
|
- |
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { |
147 |
|
- |
if (actionId == EditorInfo.IME_ACTION_DONE) { |
148 |
|
- |
searchAddress(v.getText().toString()); |
149 |
|
- |
View view = MapActivity.this.getCurrentFocus(); |
150 |
|
- |
if (view != null) { |
151 |
|
- |
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); |
152 |
|
- |
imm.hideSoftInputFromWindow(view.getWindowToken(), 0); |
|
149 |
+ |
setListenerToRootView(); |
|
150 |
+ |
|
|
151 |
+ |
|
|
152 |
+ |
addressView.setOnEditorActionListener(new TextView.OnEditorActionListener() { |
|
153 |
+ |
@Override |
|
154 |
+ |
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { |
|
155 |
+ |
if (actionId == EditorInfo.IME_ACTION_DONE) { |
|
156 |
+ |
searchAddress(v.getText().toString()); |
|
157 |
+ |
View view = MapActivity.this.getCurrentFocus(); |
|
158 |
+ |
|
|
159 |
+ |
if (view != null) { |
|
160 |
+ |
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); |
|
161 |
+ |
imm.hideSoftInputFromWindow(view.getWindowToken(), 0); |
|
162 |
+ |
|
|
163 |
+ |
} |
|
164 |
+ |
view.clearFocus(); |
|
165 |
+ |
return true; |
|
166 |
+ |
} |
|
167 |
+ |
return false; |
153 |
168 |
|
} |
154 |
|
- |
return true; |
155 |
|
- |
} |
156 |
|
- |
return false; |
157 |
|
- |
} |
158 |
|
- |
}); |
|
169 |
+ |
}); |
159 |
170 |
|
addressView.setOnFocusChangeListener(new View.OnFocusChangeListener() { |
160 |
171 |
|
@Override |
161 |
172 |
|
public void onFocusChange(View v, boolean hasFocus) { |
|
173 |
+ |
|
162 |
174 |
|
if (hasFocus) { |
163 |
175 |
|
otherInfo.setVisibility(View.GONE); |
164 |
176 |
|
} else { |
|
@@ -229,7 +241,24 @@ |
229 |
241 |
|
|
230 |
242 |
|
map.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(41.902285, 12.496975), 5.0f)); |
231 |
243 |
|
} |
|
244 |
+ |
boolean isOpened = false; |
|
245 |
+ |
|
|
246 |
+ |
public void setListenerToRootView(){ |
|
247 |
+ |
final View activityRootView = getWindow().getDecorView().findViewById(android.R.id.content); |
|
248 |
+ |
activityRootView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { |
|
249 |
+ |
@Override |
|
250 |
+ |
public void onGlobalLayout() { |
232 |
251 |
|
|
|
252 |
+ |
int heightDiff = activityRootView.getRootView().getHeight() - activityRootView.getHeight(); |
|
253 |
+ |
if (heightDiff > 100 ) { |
|
254 |
+ |
isOpened = true; |
|
255 |
+ |
}else if(isOpened == true){ |
|
256 |
+ |
(findViewById(R.id.editText6)).clearFocus(); |
|
257 |
+ |
isOpened = false; |
|
258 |
+ |
} |
|
259 |
+ |
} |
|
260 |
+ |
}); |
|
261 |
+ |
} |
233 |
262 |
|
private void initView(){ |
234 |
263 |
|
|
235 |
264 |
|
reviewButton = (Button) findViewById(R.id.button12); |