23
23
import static it .feio .android .omninotes .BaseActivity .TRANSITION_HORIZONTAL ;
24
24
import static it .feio .android .omninotes .BaseActivity .TRANSITION_VERTICAL ;
25
25
import static it .feio .android .omninotes .MainActivity .FRAGMENT_DETAIL_TAG ;
26
+ import static it .feio .android .omninotes .MainActivity .FRAGMENT_SKETCH_TAG ;
26
27
import static it .feio .android .omninotes .OmniNotes .getAppContext ;
28
+ import static it .feio .android .omninotes .helpers .GeocodeProviderBaseFactory .checkHighAccuracyLocationProvider ;
29
+ import static it .feio .android .omninotes .helpers .GeocodeProviderBaseFactory .getProvider ;
27
30
import static it .feio .android .omninotes .utils .ConstantsBase .ACTION_DISMISS ;
28
31
import static it .feio .android .omninotes .utils .ConstantsBase .ACTION_FAB_TAKE_PHOTO ;
29
32
import static it .feio .android .omninotes .utils .ConstantsBase .ACTION_MERGE ;
116
119
import androidx .fragment .app .FragmentTransaction ;
117
120
import com .afollestad .materialdialogs .DialogAction ;
118
121
import com .afollestad .materialdialogs .MaterialDialog ;
122
+ import com .google .android .gms .common .api .GoogleApiClient ;
123
+ import com .google .android .gms .common .api .PendingResult ;
124
+ import com .google .android .gms .location .LocationRequest ;
125
+ import com .google .android .gms .location .LocationServices ;
126
+ import com .google .android .gms .location .LocationSettingsRequest ;
127
+ import com .google .android .gms .location .LocationSettingsResult ;
128
+ import com .google .android .gms .tasks .Task ;
119
129
import com .neopixl .pixlui .components .edittext .EditText ;
120
130
import com .pixplicity .easyprefs .library .Prefs ;
121
131
import com .pushbullet .android .extension .MessagingExtension ;
122
132
import de .greenrobot .event .EventBus ;
123
133
import de .keyboardsurfer .android .widget .crouton .Style ;
134
+ import io .nlopez .smartlocation .location .LocationProvider ;
124
135
import it .feio .android .checklistview .exceptions .ViewNotSupportedException ;
125
136
import it .feio .android .checklistview .interfaces .CheckListChangedListener ;
126
137
import it .feio .android .checklistview .models .CheckListView ;
149
160
import it .feio .android .omninotes .models .Category ;
150
161
import it .feio .android .omninotes .models .Note ;
151
162
import it .feio .android .omninotes .models .ONStyle ;
163
+ import it .feio .android .omninotes .models .PasswordValidator .Result ;
152
164
import it .feio .android .omninotes .models .Tag ;
153
165
import it .feio .android .omninotes .models .adapters .AttachmentAdapter ;
154
166
import it .feio .android .omninotes .models .adapters .CategoryRecyclerViewAdapter ;
@@ -241,9 +253,9 @@ public class DetailFragment extends BaseFragment implements OnReminderPickedList
241
253
private int contentCursorPosition ;
242
254
private ArrayList <String > mergedNotesIds ;
243
255
private MainActivity mainActivity ;
244
- TextLinkClickListener textLinkClickListener = new TextLinkClickListener () {
245
- @ Override
246
- public void onTextLinkClick ( View view , final String clickedString , final String url ) {
256
+ private boolean activityPausing ;
257
+
258
+ TextLinkClickListener textLinkClickListener = ( view , clickedString , url ) -> {
247
259
new MaterialDialog .Builder (mainActivity )
248
260
.content (clickedString )
249
261
.negativeColorRes (R .color .colorPrimary )
@@ -267,16 +279,15 @@ public void onTextLinkClick(View view, final String clickedString, final String
267
279
clickedString );
268
280
clipboard .setPrimaryClip (clip );
269
281
}).build ().show ();
270
- View clickedView = noteTmp .isChecklist () ? toggleChecklistView : binding .contentWrapper ;
282
+ View clickedView =
283
+ Boolean .TRUE .equals (noteTmp .isChecklist ()) ? toggleChecklistView : binding .contentWrapper ;
271
284
clickedView .clearFocus ();
272
285
KeyboardUtils .hideKeyboard (clickedView );
273
286
new Handler ().post (() -> {
274
- View clickedView1 = noteTmp .isChecklist () ? toggleChecklistView : binding .contentWrapper ;
287
+ View clickedView1 = Boolean . TRUE . equals ( noteTmp .isChecklist () ) ? toggleChecklistView : binding .contentWrapper ;
275
288
KeyboardUtils .hideKeyboard (clickedView1 );
276
289
});
277
- }
278
290
};
279
- private boolean activityPausing ;
280
291
281
292
@ Override
282
293
public void onCreate (Bundle savedInstanceState ) {
@@ -419,7 +430,7 @@ private void init() {
419
430
noteTmp = new Note (note );
420
431
}
421
432
422
- if (noteTmp .isLocked () && !noteTmp .isPasswordChecked ()) {
433
+ if (Boolean . TRUE . equals ( noteTmp .isLocked () ) && !noteTmp .isPasswordChecked ()) {
423
434
checkNoteLock (noteTmp );
424
435
return ;
425
436
}
@@ -432,8 +443,8 @@ private void init() {
432
443
*/
433
444
private void checkNoteLock (Note note ) {
434
445
// If note is locked security password will be requested
435
- if (note .isLocked ()
436
- && Prefs .getString (PREF_PASSWORD , null ) != null
446
+ if (Boolean . TRUE . equals ( note .isLocked ()
447
+ && Prefs .getString (PREF_PASSWORD , null ) != null )
437
448
&& !Prefs .getBoolean ("settings_password_access" , false )) {
438
449
PasswordHelper .requestPassword (mainActivity , passwordConfirmed -> {
439
450
switch (passwordConfirmed ) {
@@ -720,8 +731,7 @@ private void initViewAttachments() {
720
731
mGridView = binding .detailRoot .findViewById (R .id .gridview );
721
732
722
733
// Some fields can be filled by third party application and are always shown
723
- mAttachmentAdapter = new AttachmentAdapter (mainActivity , noteTmp .getAttachmentsList (),
724
- mGridView );
734
+ mAttachmentAdapter = new AttachmentAdapter (mainActivity , noteTmp .getAttachmentsList ());
725
735
726
736
// Initialzation of gridview for images
727
737
mGridView .setAdapter (mAttachmentAdapter );
@@ -855,10 +865,7 @@ private void initViewTitle() {
855
865
binding .detailTitle .gatherLinksForText ();
856
866
binding .detailTitle .setOnTextLinkClickListener (textLinkClickListener );
857
867
// To avoid dropping here the dragged checklist items
858
- binding .detailTitle .setOnDragListener ((v , event ) -> {
859
- // ((View)event.getLocalState()).setVisibility(View.VISIBLE);
860
- return true ;
861
- });
868
+ binding .detailTitle .setOnDragListener ((v , event ) -> true );
862
869
//When editor action is pressed focus is moved to last character in content field
863
870
binding .detailTitle .setOnEditorActionListener ((v , actionId , event ) -> {
864
871
binding .fragmentDetailContent .detailContent .requestFocus ();
@@ -954,6 +961,9 @@ public void onLocationUnavailable() {
954
961
mainActivity .showMessage (R .string .location_not_found , ONStyle .ALERT );
955
962
}
956
963
964
+ public void onLocationNotEnabled (){
965
+ mainActivity .showMessage (R .string .location_not_enabled , ONStyle .ALERT );
966
+ }
957
967
@ Override
958
968
public void onAddressResolved (String address ) {
959
969
if (TextUtils .isEmpty (address )) {
@@ -1364,7 +1374,7 @@ private void takeSketch(Attachment attachment) {
1364
1374
b .putParcelable ("base" , attachment .getUri ());
1365
1375
}
1366
1376
mSketchFragment .setArguments (b );
1367
- transaction .replace (R .id .fragment_container , mSketchFragment , mainActivity . FRAGMENT_SKETCH_TAG )
1377
+ transaction .replace (R .id .fragment_container , mSketchFragment , FRAGMENT_SKETCH_TAG )
1368
1378
.addToBackStack (FRAGMENT_DETAIL_TAG ).commit ();
1369
1379
}
1370
1380
@@ -1632,7 +1642,7 @@ private String getNoteTitle() {
1632
1642
1633
1643
private String getNoteContent () {
1634
1644
String contentText = "" ;
1635
- if (! noteTmp .isChecklist ()) {
1645
+ if (Boolean . FALSE . equals ( noteTmp .isChecklist () )) {
1636
1646
// Due to checklist library introduction the returned EditText class is no more a
1637
1647
// com.neopixl.pixlui.components.edittext.EditText but a standard android.widget.EditText
1638
1648
View contentView = binding .detailRoot .findViewById (R .id .detail_content );
@@ -1681,12 +1691,8 @@ private void lockNote() {
1681
1691
1682
1692
// Password will be requested here
1683
1693
PasswordHelper .requestPassword (mainActivity , passwordConfirmed -> {
1684
- switch (passwordConfirmed ) {
1685
- case SUCCEED :
1686
- lockUnlock ();
1687
- break ;
1688
- default :
1689
- break ;
1694
+ if (passwordConfirmed == Result .SUCCEED ) {
1695
+ lockUnlock ();
1690
1696
}
1691
1697
});
1692
1698
}
@@ -1996,7 +2002,7 @@ private void removeAttachment(int position) {
1996
2002
1997
2003
private void removeAllAttachments () {
1998
2004
noteTmp .setAttachmentsList (new ArrayList <>());
1999
- mAttachmentAdapter = new AttachmentAdapter (mainActivity , new ArrayList <>(), mGridView );
2005
+ mAttachmentAdapter = new AttachmentAdapter (mainActivity , new ArrayList <>());
2000
2006
mGridView .invalidateViews ();
2001
2007
mGridView .setAdapter (mAttachmentAdapter );
2002
2008
}
@@ -2049,7 +2055,7 @@ public void onCheckListChanged() {
2049
2055
}
2050
2056
2051
2057
private void scrollContent () {
2052
- if (noteTmp .isChecklist ()) {
2058
+ if (Boolean . TRUE . equals ( noteTmp .isChecklist () )) {
2053
2059
if (mChecklistManager .getCount () > contentLineCounter ) {
2054
2060
binding .contentWrapper .scrollBy (0 , 60 );
2055
2061
}
@@ -2219,7 +2225,10 @@ public void onCoordinatesResolved(Location location, String address) {
2219
2225
public void onLocationUnavailable () {
2220
2226
mainActivityWeakReference .get ().showMessage (R .string .location_not_found , ONStyle .ALERT );
2221
2227
}
2222
-
2228
+ @ Override
2229
+ public void onLocationNotEnabled (){
2230
+ mainActivityWeakReference .get ().showMessage (R .string .location_not_enabled ,ONStyle .ALERT );
2231
+ }
2223
2232
@ Override
2224
2233
public void onLocationRetrieved (Location location ) {
2225
2234
if (!checkWeakReferences ()) {
0 commit comments