From f82f77f94245360c93965b44ef72bfe08849b4c9 Mon Sep 17 00:00:00 2001 From: ayman abdelghany Date: Thu, 12 May 2016 19:21:37 +0200 Subject: [PATCH] Field names should comply with a naming convention --- .../notable/library/MainActivity.java | 104 +++++++++--------- .../notable/library/NotificationService.java | 4 +- .../utils/CursorRecyclerViewAdapter.java | 4 +- .../library/utils/NotificationDataSource.java | 6 +- .../library/utils/NotificationItem.java | 66 +++++------ 5 files changed, 92 insertions(+), 92 deletions(-) diff --git a/notableLibrary/src/main/java/com/icechen1/notable/library/MainActivity.java b/notableLibrary/src/main/java/com/icechen1/notable/library/MainActivity.java index 38c6887..ec28b16 100644 --- a/notableLibrary/src/main/java/com/icechen1/notable/library/MainActivity.java +++ b/notableLibrary/src/main/java/com/icechen1/notable/library/MainActivity.java @@ -74,8 +74,8 @@ public class MainActivity NotificationManager notificationManager; private String icon; - private int saved_id; - private String share_info; + private int savedId; + private String shareInfo; private boolean useAlarm = false; private Calendar reminderCalendar; private Toolbar mToolbar; @@ -113,9 +113,9 @@ public void onCreate(Bundle savedInstanceState){ //EDIT NOTIF try { - saved_id = saved.getInt("id",-1); + savedId = saved.getInt("id",-1); } catch(Exception e){ - saved_id = -1; + savedId = -1; } //RECEIVER INTENT @@ -129,7 +129,7 @@ public void onCreate(Bundle savedInstanceState){ if ("text/plain".equals(type)) { String sharedText = intent.getStringExtra(Intent.EXTRA_TEXT); if (sharedText != null) { - share_info = sharedText; + shareInfo = sharedText; } } } else if(("com.google.android.gm.action.AUTO_SEND").equals(action) && type != null) { @@ -156,9 +156,9 @@ public void onCreate(Bundle savedInstanceState){ } private void autoSaveNote(String sharedText) { - share_info = sharedText; - shareFields(share_info); - icon = "checkmark_gray"; + shareInfo = sharedText; + shareFields(shareInfo); + icon = "checkmarkGray"; addBtn(null); } private void shareFields(String share_info){ @@ -170,7 +170,7 @@ private void updateFields() { // NotificationDataSource datasource = new NotificationDataSource(this); datasource.open(); - NotificationItem item = datasource.getItem(saved_id); + NotificationItem item = datasource.getItem(savedId); datasource.close(); //Log.i(TAG, item.getLongText()); final EditText editText = (EditText) findViewById(R.id.entryText); @@ -185,17 +185,17 @@ private void updateFields() { resetBkg(); icon = item.getIcon(); - if(icon.equals("checkmark_gray")) { - checkmark_gray.setSelected(true); + if(icon.equals("checkmarkGray")) { + checkmarkGray.setSelected(true); } - if(icon.equals("checkmark_orange")) { - checkmark_orange.setSelected(true); + if(icon.equals("checkmarkOrange")) { + checkmarkOrange.setSelected(true); } - if(icon.equals("checkmark_red")) { - checkmark_red.setSelected(true); + if(icon.equals("checkmarkRed")) { + checkmarkRed.setSelected(true); } - if(icon.equals("checkmark_green")) { - checkmark_green.setSelected(true); + if(icon.equals("checkmarkGreen")) { + checkmarkGreen.setSelected(true); } //Create the reminder time calendar object according to last saved time @@ -204,8 +204,8 @@ private void updateFields() { //Show it dateBtn.setText(DateFormat.getDateFormat(this).format(reminderCalendar.getTime())); TimeBtn.setText(DateFormat.getTimeFormat(this).format(reminderCalendar.getTime())); - reminder_set.setVisibility(View.VISIBLE); - reminder_none.setVisibility(View.GONE); + reminderSet.setVisibility(View.VISIBLE); + reminderNone.setVisibility(View.GONE); useAlarm = true; } @@ -232,8 +232,8 @@ public void addBtn(View v) { Log.d(TAG, firstLine); String longText; - if (share_info != null) - longText = share_info; + if (shareInfo != null) + longText = shareInfo; else if (lineBreakPos != -1) longText = inputText.substring(lineBreakPos + 1); else @@ -252,8 +252,8 @@ else if (lineBreakPos != -1) } */ //Delete old notif if editing - if(saved_id != -1){ - mBundle.putInt("old_noif_id", saved_id); + if(savedId != -1){ + mBundle.putInt("old_noif_id", savedId); } if(useAlarm){ //Pass the calendar object to the intent bundle @@ -306,11 +306,11 @@ public boolean onMenuItemClick(MenuItem item) { // Inflate a menu to be displayed in the toolbar mToolbar.inflateMenu(R.menu.activity_main); - //icon = "checkmark_gray"; + //icon = "checkmarkGray"; addBtn.setEnabled(false); addBtn.setClickable(false); - checkmark_gray.setSelected(true); - icon = "checkmark_gray"; + checkmarkGray.setSelected(true); + icon = "checkmarkGray"; // Request focus and show soft keyboard automatically editText.requestFocus(); getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_VISIBLE); @@ -344,9 +344,9 @@ public void onTextChanged(CharSequence s, int start, int before, int count){} }); - if(share_info != null){ + if(shareInfo != null){ Log.i(TAG, "Received an share intent..."); - shareFields(share_info); + shareFields(shareInfo); } //Create the reminder time calendar object @@ -359,8 +359,8 @@ public void onTextChanged(CharSequence s, int start, int before, int count){} dateBtn.setText(DateFormat.getDateFormat(this).format(reminderCalendar.getTime())); TimeBtn.setText(DateFormat.getTimeFormat(this).format(reminderCalendar.getTime())); - if(saved_id != -1){ - Log.i(TAG, "Loading from database: " + saved_id); + if(savedId != -1){ + Log.i(TAG, "Loading from database: " + savedId); updateFields(); } } @@ -432,22 +432,22 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) { @ViewById - ImageButton checkmark_gray; + ImageButton checkmarkGray; @ViewById - ImageButton checkmark_green; + ImageButton checkmarkGreen; @ViewById - ImageButton checkmark_orange; + ImageButton checkmarkOrange; @ViewById - ImageButton checkmark_red; + ImageButton checkmarkRed; @ViewById - RelativeLayout reminder_set; + RelativeLayout reminderSet; @ViewById - RelativeLayout reminder_none; + RelativeLayout reminderNone; @Click void dateBtn(){ @@ -464,48 +464,48 @@ void TimeBtn(){ @Click void reminderAddBtn(){ - reminder_set.setVisibility(View.VISIBLE); - reminder_none.setVisibility(View.GONE); + reminderSet.setVisibility(View.VISIBLE); + reminderNone.setVisibility(View.GONE); useAlarm = true; } @Click void cancelAlarmSet(){ - reminder_set.setVisibility(View.GONE); - reminder_none.setVisibility(View.VISIBLE); + reminderSet.setVisibility(View.GONE); + reminderNone.setVisibility(View.VISIBLE); useAlarm = false; } @Click void checkmark_gray(){ resetBkg(); - checkmark_gray.setSelected(true); - icon = "checkmark_gray"; + checkmarkGray.setSelected(true); + icon = "checkmarkGray"; } @Click void checkmark_green(){ resetBkg(); - checkmark_green.setSelected(true); - icon= "checkmark_green"; + checkmarkGreen.setSelected(true); + icon= "checkmarkGreen"; } @Click void checkmark_orange(){ resetBkg(); - checkmark_orange.setSelected(true); - icon= "checkmark_orange"; + checkmarkOrange.setSelected(true); + icon= "checkmarkOrange"; } @Click void checkmark_red(){ resetBkg(); - checkmark_red.setSelected(true); - icon= "checkmark_red"; + checkmarkRed.setSelected(true); + icon= "checkmarkRed"; } public void resetBkg(){ - checkmark_gray.setSelected(false); - checkmark_green.setSelected(false); - checkmark_orange.setSelected(false); - checkmark_red.setSelected(false); + checkmarkGray.setSelected(false); + checkmarkGreen.setSelected(false); + checkmarkOrange.setSelected(false); + checkmarkRed.setSelected(false); } diff --git a/notableLibrary/src/main/java/com/icechen1/notable/library/NotificationService.java b/notableLibrary/src/main/java/com/icechen1/notable/library/NotificationService.java index 9b5ebe7..c9fe468 100644 --- a/notableLibrary/src/main/java/com/icechen1/notable/library/NotificationService.java +++ b/notableLibrary/src/main/java/com/icechen1/notable/library/NotificationService.java @@ -147,7 +147,7 @@ private void setUpNextRun(NotificationItem notif) { Bundle jBundle = new Bundle(); jBundle.putString("action", "alarm"); - jBundle.putInt("id", notif._id); + jBundle.putInt("id", notif.id); intent.putExtras(jBundle); PendingIntent pendingIntent = @@ -165,7 +165,7 @@ private void setUpNextRun(NotificationItem notif) { } Log.d("Notable", "Created alarm at: " + notif.getReminderTime()); - Log.d("Notable", "with id: " + notif._id); + Log.d("Notable", "with id: " + notif.id); } private void finish() { diff --git a/notableLibrary/src/main/java/com/icechen1/notable/library/utils/CursorRecyclerViewAdapter.java b/notableLibrary/src/main/java/com/icechen1/notable/library/utils/CursorRecyclerViewAdapter.java index 41689f5..9ed3d52 100644 --- a/notableLibrary/src/main/java/com/icechen1/notable/library/utils/CursorRecyclerViewAdapter.java +++ b/notableLibrary/src/main/java/com/icechen1/notable/library/utils/CursorRecyclerViewAdapter.java @@ -42,7 +42,7 @@ public CursorRecyclerViewAdapter(Context context, C cursor) { mContext = context; mCursor = cursor; mDataValid = cursor != null; - mRowIdColumn = mDataValid ? mCursor.getColumnIndex("_id") : -1; + mRowIdColumn = mDataValid ? mCursor.getColumnIndex("id") : -1; mDataSetObserver = new NotifyingDataSetObserver(); if (mCursor != null) { mCursor.registerDataSetObserver(mDataSetObserver); @@ -116,7 +116,7 @@ public Cursor swapCursor(C newCursor) { if (mDataSetObserver != null) { mCursor.registerDataSetObserver(mDataSetObserver); } - mRowIdColumn = newCursor.getColumnIndexOrThrow("_id"); + mRowIdColumn = newCursor.getColumnIndexOrThrow("id"); mDataValid = true; notifyDataSetChanged(); } else { diff --git a/notableLibrary/src/main/java/com/icechen1/notable/library/utils/NotificationDataSource.java b/notableLibrary/src/main/java/com/icechen1/notable/library/utils/NotificationDataSource.java index d358e68..7e719ee 100644 --- a/notableLibrary/src/main/java/com/icechen1/notable/library/utils/NotificationDataSource.java +++ b/notableLibrary/src/main/java/com/icechen1/notable/library/utils/NotificationDataSource.java @@ -70,13 +70,13 @@ public void updateItem(long rowId, String title, String longtext, String icon) { args.put(SQLiteHelper.COLUMN_TIME, Calendar.getInstance().getTimeInMillis()); args.put(SQLiteHelper.COLUMN_ICON, icon); - database.update(SQLiteHelper.TABLE_NOTIFS, args, "_id=" + rowId, null); + database.update(SQLiteHelper.TABLE_NOTIFS, args, "id=" + rowId, null); } public void setDismissed(long rowId, boolean dismissed) { ContentValues args = new ContentValues(); args.put(SQLiteHelper.COLUMN_DISMISSED, dismissed ? 1 : 0); - database.update(SQLiteHelper.TABLE_NOTIFS, args, "_id=" + rowId, null); + database.update(SQLiteHelper.TABLE_NOTIFS, args, "id=" + rowId, null); //broadcast db change Intent intent = new Intent(); @@ -159,7 +159,7 @@ public void dismissItem(int id) { class SQLiteHelper extends SQLiteOpenHelper { public static final String TABLE_NOTIFS = "NOTIF"; - public static final String COLUMN_ID = "_id"; + public static final String COLUMN_ID = "id"; public static final String COLUMN_TITLE = "title"; public static final String COLUMN_LONGTEXT = "longtext"; public static final String COLUMN_ICON = "icon"; diff --git a/notableLibrary/src/main/java/com/icechen1/notable/library/utils/NotificationItem.java b/notableLibrary/src/main/java/com/icechen1/notable/library/utils/NotificationItem.java index 33b5c3a..267dfa6 100644 --- a/notableLibrary/src/main/java/com/icechen1/notable/library/utils/NotificationItem.java +++ b/notableLibrary/src/main/java/com/icechen1/notable/library/utils/NotificationItem.java @@ -3,36 +3,36 @@ public class NotificationItem { //private variables - public int _id; - String _title; - String _icon; - private String _longtext; - long _timestamp; - long _reminder_timestamp; - boolean _dismissed; + public int id; + String title; + String icon; + private String longtext; + long timestamp; + long reminderTimestamp; + boolean dismissed; // constructor public NotificationItem(int id, String title, String longtext, String icon){ - this._id = id; - this._title = title; - this._longtext = longtext; - this._icon = icon; + this.id = id; + this.title = title; + this.longtext = longtext; + this.icon = icon; } // constructor public NotificationItem(int id, String title, String longtext, String icon, long reminder_timestamp){ - this._id = id; - this._title = title; - this._longtext = longtext; - this._icon = icon; - this._reminder_timestamp = reminder_timestamp; + this.id = id; + this.title = title; + this.longtext = longtext; + this.icon = icon; + this.reminderTimestamp = reminder_timestamp; } // constructor public NotificationItem(int id, String title, String icon){ - this._id = id; - this._title = title; - this._icon = icon; + this.id = id; + this.title = title; + this.icon = icon; } public NotificationItem() { @@ -41,72 +41,72 @@ public NotificationItem() { // getting ID public int getID(){ - return this._id; + return this.id; } // setting id public void setID(int l){ - this._id = l; + this.id = l; } // getting name public String getTitle(){ - return this._title; + return this.title; } // setting name public void setTitle(String title){ - this._title = title; + this.title = title; } // getting longtext public String getLongText(){ - return this._longtext; + return this.longtext; } // setting longtext public void setLongText(String text){ - this._longtext = text; + this.longtext = text; } // getting icon public String getIcon(){ - return this._icon; + return this.icon; } // setting icon public void setIcon(String icon){ - this._icon = icon; + this.icon = icon; } // getting time public long getTime(){ - return this._timestamp; + return this.timestamp; } // setting time public void setTime(long time){ - this._timestamp = time; + this.timestamp = time; } // getting reminder time public long getReminderTime(){ - return this._reminder_timestamp; + return this.reminderTimestamp; } // setting reminder time public void setReminderTime(long time){ - this._reminder_timestamp = time; + this.reminderTimestamp = time; } // getting dismissed state public boolean getDismissed(){ - return this._dismissed; + return this.dismissed; } // setting dismissed state public void setDismissed(boolean b){ - this._dismissed = b; + this.dismissed = b; } } \ No newline at end of file