Skip to content
This repository was archived by the owner on Nov 18, 2024. It is now read-only.

Commit 1e59ace

Browse files
committed
Added backup feature
1 parent f00e405 commit 1e59ace

24 files changed

Lines changed: 572 additions & 90 deletions
536 Bytes
Binary file not shown.

.idea/codeStyles/Project.xml

Lines changed: 29 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ android {
77
applicationId "apps.jizzu.simpletodo"
88
minSdkVersion 19
99
targetSdkVersion 27
10-
versionCode 4
11-
versionName "1.0"
10+
versionCode 5
11+
versionName "1.1"
1212
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
1313
}
1414
buildTypes {

app/src/main/AndroidManifest.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
package="apps.jizzu.simpletodo">
44

55
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
6+
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
7+
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
68

79
<application
810
android:allowBackup="true"

app/src/main/java/apps/jizzu/simpletodo/activity/AddTaskActivity.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@
3838
*/
3939
public class AddTaskActivity extends AppCompatActivity implements DatePickerDialog.OnDateSetListener, TimePickerDialog.OnTimeSetListener {
4040

41-
EditText mTitle;
42-
TextInputLayout mTaskTitleLayout;
43-
RelativeLayout mReminderLayout;
44-
Calendar mCalendar;
45-
EditText mDate;
46-
EditText mTime;
47-
SwitchCompat mReminderSwitch;
41+
private EditText mTitle;
42+
private TextInputLayout mTaskTitleLayout;
43+
private RelativeLayout mReminderLayout;
44+
private Calendar mCalendar;
45+
private EditText mDate;
46+
private EditText mTime;
47+
private SwitchCompat mReminderSwitch;
4848

4949
@Override
5050
protected void onCreate(Bundle savedInstanceState) {
@@ -196,6 +196,14 @@ public void onClick(View view) {
196196
});
197197
}
198198

199+
/**
200+
* Method for hiding the soft keyboard.
201+
*/
202+
private void hideKeyboard(EditText editText) {
203+
InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
204+
imm.hideSoftInputFromWindow(editText.getWindowToken(), 0);
205+
}
206+
199207
/**
200208
* Hides the soft keyboard when the user clicks on the home button.
201209
*/
@@ -205,14 +213,6 @@ protected void onStop() {
205213
hideKeyboard(mTitle);
206214
}
207215

208-
/**
209-
* Method for hiding the soft keyboard.
210-
*/
211-
public void hideKeyboard(EditText editText) {
212-
InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
213-
imm.hideSoftInputFromWindow(editText.getWindowToken(), 0);
214-
}
215-
216216
/**
217217
* The handler for clicking the close button in the toolbar.
218218
*/

app/src/main/java/apps/jizzu/simpletodo/activity/EditTaskActivity.java

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import android.content.Context;
99
import android.content.DialogInterface;
1010
import android.content.Intent;
11+
import android.os.Build;
1112
import android.support.design.widget.TextInputLayout;
1213
import android.support.v7.app.AppCompatActivity;
1314
import android.os.Bundle;
@@ -46,18 +47,19 @@
4647
*/
4748
public class EditTaskActivity extends AppCompatActivity implements DatePickerDialog.OnDateSetListener, TimePickerDialog.OnTimeSetListener {
4849

49-
EditText mTitle;
50-
TextInputLayout mTaskTitleLayout;
51-
RelativeLayout mReminderLayout;
52-
Calendar mCalendar;
53-
EditText mDateEditText;
54-
EditText mTimeEditText;
55-
SwitchCompat mReminderSwitch;
56-
RecyclerViewAdapter mAdapter;
57-
long mId;
58-
long mDate;
59-
int mPosition;
60-
long mTimeStamp;
50+
private Context mContext;
51+
private EditText mTitle;
52+
private TextInputLayout mTaskTitleLayout;
53+
private RelativeLayout mReminderLayout;
54+
private Calendar mCalendar;
55+
private EditText mDateEditText;
56+
private EditText mTimeEditText;
57+
private SwitchCompat mReminderSwitch;
58+
private RecyclerViewAdapter mAdapter;
59+
private long mId;
60+
private long mDate;
61+
private int mPosition;
62+
private long mTimeStamp;
6163

6264
@Override
6365
protected void onCreate(Bundle savedInstanceState) {
@@ -87,6 +89,7 @@ protected void onCreate(Bundle savedInstanceState) {
8789
TextView reminderText = findViewById(R.id.tvSetReminder);
8890

8991
MainActivity.mActivityIsShown = true;
92+
mContext = getApplicationContext();
9093

9194
// Get the resolution of the user's screen
9295
Display d = ((WindowManager) this.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
@@ -228,7 +231,7 @@ public void onClick(View view) {
228231
} else if (mTitle.getText().toString().trim().length() == 0) {
229232
mTitle.setError(getString(R.string.error_spaces));
230233
} else {
231-
DBHelper dbHelper = DBHelper.getInstance(MainActivity.mContext);
234+
DBHelper dbHelper = DBHelper.getInstance(mContext);
232235

233236
ModelTask task = new ModelTask(mId, mTitle.getText().toString(), mDate, mPosition, mTimeStamp);
234237

@@ -246,7 +249,7 @@ public void onClick(View view) {
246249

247250
if (task.getDate() != 0 && task.getDate() <= Calendar.getInstance().getTimeInMillis()) {
248251
task.setDate(0);
249-
Toast.makeText(MainActivity.mContext, getString(R.string.toast_incorrect_time), Toast.LENGTH_SHORT).show();
252+
Toast.makeText(mContext, getString(R.string.toast_incorrect_time), Toast.LENGTH_SHORT).show();
250253
} else if (task.getDate() != 0) {
251254
AlarmHelper alarmHelper = AlarmHelper.getInstance();
252255
alarmHelper.setAlarm(task);
@@ -297,7 +300,12 @@ public boolean onOptionsItemSelected(MenuItem item) {
297300
break;
298301

299302
case R.id.action_delete:
300-
AlertDialog.Builder alertDialog = new AlertDialog.Builder(this);
303+
AlertDialog.Builder alertDialog;
304+
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT) {
305+
alertDialog = new AlertDialog.Builder(this);
306+
} else {
307+
alertDialog = new AlertDialog.Builder(this, R.style.DialogTheme);
308+
}
301309
alertDialog.setTitle(R.string.dialog_title);
302310
alertDialog.setMessage(R.string.dialog_message);
303311
alertDialog.setPositiveButton(R.string.action_delete, new DialogInterface.OnClickListener() {

app/src/main/java/apps/jizzu/simpletodo/activity/MainActivity.java

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -56,33 +56,33 @@
5656
import static android.content.ContentValues.TAG;
5757

5858

59-
public class MainActivity extends AppCompatActivity implements RecyclerViewAdapter.UpdateNotificationDataCallback {
59+
public class MainActivity extends AppCompatActivity implements RecyclerViewAdapter.AdapterCallback {
6060

61+
private Context mContext;
6162
private RecyclerViewEmptySupport mRecyclerView;
62-
public RecyclerViewAdapter mAdapter;
63+
private RecyclerViewAdapter mAdapter;
6364
private RelativeLayout mEmptyView;
6465
private DBHelper mHelper;
65-
public static FloatingActionButton mFab;
6666
private PreferenceHelper mPreferenceHelper;
6767
private RecyclerView.LayoutManager mLayoutManager;
68-
public static boolean mSearchViewIsOpen;
6968
private MaterialSearchView mSearchView;
7069
private NotificationManager mNotificationManager;
70+
private FloatingActionButton mFab;
71+
72+
public static boolean mSearchViewIsOpen;
7173
public static boolean mShowAnimation;
7274
public static boolean mActivityIsShown;
7375

74-
// TODO: Find better way to get the MainActivity context.
75-
public static Context mContext;
76-
77-
7876
@Override
7977
protected void onCreate(Bundle savedInstanceState) {
8078
super.onCreate(savedInstanceState);
8179
setContentView(R.layout.activity_main);
8280

8381
// Set up "What's New" screen
8482
WhatsNew whatsNew = WhatsNew.newInstance(
85-
new WhatsNewItem(getString(R.string.whats_new_item_1_title), getString(R.string.whats_new_item_1_text))
83+
new WhatsNewItem(getString(R.string.whats_new_item_1_title), getString(R.string.whats_new_item_1_text)),
84+
new WhatsNewItem(getString(R.string.whats_new_item_2_title), getString(R.string.whats_new_item_2_text)),
85+
new WhatsNewItem(getString(R.string.whats_new_item_3_title), getString(R.string.whats_new_item_3_text))
8686
);
8787
whatsNew.setTitleColor(ContextCompat.getColor(this, R.color.colorAccent));
8888
whatsNew.setTitleText(getString(R.string.whats_new_title));
@@ -92,6 +92,7 @@ protected void onCreate(Bundle savedInstanceState) {
9292
whatsNew.presentAutomatically(MainActivity.this);
9393

9494
mContext = MainActivity.this;
95+
mSearchViewIsOpen = false;
9596
setTitle("");
9697

9798
// Initialize ALARM_SERVICE
@@ -108,6 +109,7 @@ protected void onCreate(Bundle savedInstanceState) {
108109

109110
mEmptyView = findViewById(R.id.empty);
110111

112+
mRecyclerView = new RecyclerViewEmptySupport(mContext);
111113
mRecyclerView = findViewById(R.id.tasksList);
112114
mRecyclerView.setHasFixedSize(true);
113115

@@ -230,7 +232,7 @@ public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
230232
/**
231233
* Finds tasks by the title in the database.
232234
*/
233-
public void findTasks(String title) {
235+
private void findTasks(String title) {
234236
mSearchViewIsOpen = true;
235237
Log.d(TAG, "findTasks: SearchView Title = " + title);
236238
mAdapter.removeAllItems();
@@ -250,7 +252,7 @@ public void findTasks(String title) {
250252
/**
251253
* Reads all tasks from the database and adds them to the RecyclerView list.
252254
*/
253-
public void addTasksFromDB() {
255+
private void addTasksFromDB() {
254256
mAdapter.removeAllItems();
255257
List<ModelTask> taskList = mHelper.getAllTasks();
256258

@@ -272,7 +274,7 @@ private void startEmptyViewAnimation() {
272274
/**
273275
* Updates widget data.
274276
*/
275-
public void updateWidget() {
277+
private void updateWidget() {
276278
Log.d(TAG, "WIDGET IS UPDATED!");
277279
Intent intent = new Intent(this, WidgetProvider.class);
278280
intent.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
@@ -285,7 +287,7 @@ public void updateWidget() {
285287
/**
286288
* Updates general notification data.
287289
*/
288-
public void updateGeneralNotification() {
290+
private void updateGeneralNotification() {
289291
if (mPreferenceHelper.getBoolean(PreferenceHelper.GENERAL_NOTIFICATION_IS_ON)) {
290292
if (mAdapter.getItemCount() != 0) {
291293
showGeneralNotification();
@@ -300,7 +302,7 @@ public void updateGeneralNotification() {
300302
/**
301303
* Set up and show general notification.
302304
*/
303-
public void showGeneralNotification() {
305+
private void showGeneralNotification() {
304306
StringBuilder stringBuilder = new StringBuilder();
305307

306308
Intent resultIntent = new Intent(this, MainActivity.class);
@@ -365,7 +367,7 @@ public void showGeneralNotification() {
365367
/**
366368
* Removes general notification.
367369
*/
368-
public void removeGeneralNotification() {
370+
private void removeGeneralNotification() {
369371
if (mNotificationManager != null) {
370372
mNotificationManager.cancel(1);
371373
}
@@ -379,6 +381,11 @@ public void updateData() {
379381
updateGeneralNotification();
380382
}
381383

384+
@Override
385+
public void showFAB() {
386+
mFab.show();
387+
}
388+
382389
@Override
383390
public boolean onCreateOptionsMenu(Menu menu) {
384391
getMenuInflater().inflate(R.menu.menu, menu);
@@ -428,6 +435,8 @@ protected void onStop() {
428435
@Override
429436
protected void onResume() {
430437
super.onResume();
438+
439+
//addTasksFromDB();
431440
mFab.setVisibility(View.GONE);
432441

433442
if (mPreferenceHelper.getBoolean(PreferenceHelper.ANIMATION_IS_ON)) {

app/src/main/java/apps/jizzu/simpletodo/adapter/ListItemTouchHelper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class ListItemTouchHelper extends ItemTouchHelper.Callback {
1616
/**
1717
* Constructor for mAdapter initialization.
1818
*/
19-
public ListItemTouchHelper(RecyclerViewAdapter adapter, RecyclerView recyclerView) {
19+
protected ListItemTouchHelper(RecyclerViewAdapter adapter, RecyclerView recyclerView) {
2020
mAdapter = adapter;
2121
mRecyclerView = recyclerView;
2222
}

0 commit comments

Comments
 (0)