20
20
import android .widget .ArrayAdapter ;
21
21
import android .widget .ListView ;
22
22
import android .widget .Toast ;
23
+
24
+ import com .google .android .material .floatingactionbutton .FloatingActionButton ;
23
25
import com .gun0912 .tedpermission .PermissionListener ;
24
26
import com .gun0912 .tedpermission .TedPermission ;
25
27
import java .util .ArrayList ;
@@ -32,6 +34,7 @@ public class MainActivity extends AppCompatActivity {
32
34
static ArrayAdapter <String > arrayAdapter ;
33
35
ListView listView ;
34
36
37
+
35
38
@ Override
36
39
public boolean onCreateOptionsMenu (Menu menu ) {
37
40
@@ -46,21 +49,30 @@ public boolean onCreateOptionsMenu(Menu menu) {
46
49
public boolean onOptionsItemSelected (@ NonNull MenuItem item ) {
47
50
super .onOptionsItemSelected (item );
48
51
49
- if (item .getItemId () == R .id .add_note ) {
50
- Intent intent = new Intent (getApplicationContext (), NoteEditorActivity .class );
51
- startActivity (intent );
52
+ if (item .getItemId () == R .id .share ) {
53
+ Intent sendIntent = new Intent ();
54
+ sendIntent .setAction (Intent .ACTION_SEND );
55
+ sendIntent .putExtra (Intent .EXTRA_TEXT , "Hey!! Want to take notes? Try this amazing app now. Link: https://play.google.com/store/apps/details?id=" + BuildConfig .APPLICATION_ID );
56
+ sendIntent .setType ("text/plain" );
57
+
58
+ Intent shareIntent = Intent .createChooser (sendIntent , null );
59
+ startActivity (shareIntent );
60
+
61
+ return true ;
62
+ }
63
+
64
+ else if (item .getItemId () == R .id .rate ){
65
+ Toast .makeText (this , "Please wait" , Toast .LENGTH_LONG ).show ();
52
66
53
- Toast . makeText ( getApplicationContext (), "Hey! New Note is Created, Tap the screen to edit." , Toast . LENGTH_LONG ). show ( );
67
+ startActivity ( new Intent ( Intent . ACTION_VIEW , Uri . parse ( "https://play.google.com/store/apps/details?id=" + BuildConfig . APPLICATION_ID )) );
54
68
55
69
return true ;
56
70
}
57
71
58
- else if (item .getItemId () == R .id .share ){
59
- Intent sharingIntent = new Intent (Intent .ACTION_SEND );
60
- sharingIntent .setType ("text/plain" );
61
- sharingIntent .putExtra (android .content .Intent .EXTRA_TEXT , "Text" );
62
- sharingIntent .putExtra (android .content .Intent .EXTRA_SUBJECT , "Subject" );
63
- startActivity (Intent .createChooser (sharingIntent , "Share using" ));
72
+ else if (item .getItemId () == R .id .about_us ){
73
+ aboutDialog ();
74
+
75
+ return true ;
64
76
}
65
77
66
78
return false ;
@@ -74,6 +86,7 @@ protected void onCreate(Bundle savedInstanceState) {
74
86
setContentView (R .layout .activity_main );
75
87
76
88
listView = findViewById (R .id .listView );
89
+ FloatingActionButton fab = findViewById (R .id .fab );
77
90
78
91
SharedPreferences sharedPreferences = getApplicationContext ().getSharedPreferences ("com.rubancreation.notes" , Context .MODE_PRIVATE );
79
92
HashSet <String > set = (HashSet <String >) sharedPreferences .getStringSet ("notes" , null );
@@ -84,10 +97,11 @@ protected void onCreate(Bundle savedInstanceState) {
84
97
else {
85
98
notes = new ArrayList (set );
86
99
}
87
-
100
+
88
101
89
102
arrayAdapter = new ArrayAdapter (this , android .R .layout .simple_list_item_1 , notes );
90
103
listView .setAdapter (arrayAdapter );
104
+ listView .setDividerHeight (2 );
91
105
listView .setOnItemClickListener (new AdapterView .OnItemClickListener () {
92
106
93
107
@ Override
@@ -96,8 +110,6 @@ public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
96
110
Intent intent = new Intent (getApplicationContext (), NoteEditorActivity .class );
97
111
intent .putExtra ("noteId" , i );
98
112
startActivity (intent );
99
-
100
-
101
113
}
102
114
103
115
});
@@ -139,10 +151,26 @@ public void onClick(DialogInterface dialogInterface, int i) {
139
151
140
152
});
141
153
154
+ fab .setOnClickListener (new View .OnClickListener () {
155
+ @ Override
156
+ public void onClick (View view ) {
157
+ Intent intent = new Intent (getApplicationContext (), NoteEditorActivity .class );
158
+ startActivity (intent );
159
+
160
+ Toast .makeText (getApplicationContext (), "Hey! New Note is Created, Tap the screen to edit." , Toast .LENGTH_LONG ).show ();
161
+ }
162
+ });
163
+
164
+ SharedPreferences preferences = getSharedPreferences ("preferences" , MODE_PRIVATE );
165
+ boolean firstStart = preferences .getBoolean ("firstStart" , true );
166
+ if (firstStart ) {
167
+ showStartDialog ();
168
+ }
142
169
}
143
170
144
171
//for Exit menu Item
145
- public void exit (MenuItem item ) {
172
+ public void exit (MenuItem item ){
173
+ Toast .makeText (this , "Thanks for using NOTES" , Toast .LENGTH_LONG ).show ();
146
174
finish ();
147
175
}
148
176
@@ -154,29 +182,23 @@ public void checkPermission(MenuItem item) {
154
182
public void onPermissionGranted () {
155
183
Toast .makeText (MainActivity .this , "Please wait.." , Toast .LENGTH_SHORT ).show ();
156
184
157
- Log .d (" " , "send email: " );
158
-
159
- String [] TO_EMAILS = {"rubancreations22@gmail.com" };
160
- //these CC and BCC
161
- String [] CC = {"rubancreations22@gmail.com" };
162
- String [] BCC = {"rubancreations22@gmail.com" };
185
+ Log .d (" " , "Send Email: " );
186
+ String [] TO_EMAILS = {"app.feedback.rubancreations@gmail.com" };
163
187
164
- Intent intent = new Intent (Intent .ACTION_SENDTO );
165
- intent .setData (Uri .parse ("mailto:" ));
166
- intent .putExtra (Intent .EXTRA_EMAIL , TO_EMAILS );
167
- intent .putExtra (Intent .EXTRA_CC , CC );
168
- intent .putExtra (Intent .EXTRA_BCC , BCC );
188
+ Intent intent = new Intent (Intent .ACTION_SENDTO );
189
+ intent .setData (Uri .parse ("mailto:" ));
190
+ intent .putExtra (Intent .EXTRA_EMAIL , TO_EMAILS );
169
191
170
- intent .putExtra (Intent .EXTRA_SUBJECT , "This is a Subject " );
171
- intent .putExtra (Intent .EXTRA_TEXT , "This is the body of the Email " );
192
+ intent .putExtra (Intent .EXTRA_SUBJECT , "Reported Problem " );
193
+ intent .putExtra (Intent .EXTRA_TEXT , "Hey Ruban Creations I've found a Bug/Problem inside your app. \n Problem Explanation: \n " );
172
194
173
- startActivity (Intent .createChooser (intent , "Choose your mail client.. " ));
195
+ startActivity (Intent .createChooser (intent , "Choose your mail client: " ));
174
196
175
197
}
176
198
177
199
@ Override
178
200
public void onPermissionDenied (ArrayList <String > deniedPermissions ) {
179
- Toast .makeText (MainActivity .this , "Click allow to access Permission ." , Toast .LENGTH_SHORT ).show ();
201
+ Toast .makeText (MainActivity .this , "Check your internet connection ." , Toast .LENGTH_SHORT ).show ();
180
202
}
181
203
};
182
204
@@ -202,12 +224,46 @@ public void onPermissionDenied(ArrayList<String> deniedPermissions) {
202
224
Toast .makeText (MainActivity .this , "Check Connection Settings" , Toast .LENGTH_LONG ).show ();
203
225
}
204
226
};
205
-
206
-
207
-
208
227
TedPermission .with (MainActivity .this )
209
228
.setPermissionListener (privacyPolicy )
210
229
.setPermissions (Manifest .permission .INTERNET )
211
230
.check ();
212
231
}
232
+
233
+ private void showStartDialog (){
234
+ new AlertDialog .Builder (this )
235
+ .setTitle ("We are Updated!" )
236
+ .setMessage ("Hello Buddies, We are updated our app This update includes \n Bug Fixes \n Fixed add button not working problem \n Upgraded performance \n Added some menus to know about us \n Rate us on google playstore :)" )
237
+ .setPositiveButton ("Continue" , new DialogInterface .OnClickListener () {
238
+ @ Override
239
+ public void onClick (DialogInterface dialogInterface , int i ) {
240
+ dialogInterface .dismiss ();
241
+ }
242
+ })
243
+ .create ().show ();
244
+
245
+ SharedPreferences preferences = getSharedPreferences ("preferences" , MODE_PRIVATE );
246
+ SharedPreferences .Editor editor = preferences .edit ();
247
+ editor .putBoolean ("firstStart" , false );
248
+ editor .apply ();
249
+ }
250
+
251
+ private void aboutDialog (){
252
+ new AlertDialog .Builder (this )
253
+ .setTitle ("NOTES - Writing Master" )
254
+ .setMessage ("Hello users, NOTES - Writing Master." +
255
+ "One of our first development on PlayStore has surpassed 500+ users around the world" +
256
+ "Users can write notes in our app" +
257
+ "An User friendly application. We designed everything, what they expected. " +
258
+ "We made it more. \n " +
259
+ "\n " +
260
+ "Version Name: 1.3" )
261
+ .setPositiveButton ("Ok" , new DialogInterface .OnClickListener () {
262
+ @ Override
263
+ public void onClick (DialogInterface dialogInterface , int i ) {
264
+ dialogInterface .dismiss ();
265
+ }
266
+ })
267
+ .create ().show ();
268
+ }
213
269
}
0 commit comments