Updated all logging to verbose and disabled it

This commit is contained in:
2014-09-02 19:54:55 -04:00
parent 5b7ba832f9
commit f077b45477
7 changed files with 90 additions and 53 deletions

View File

@@ -52,7 +52,7 @@ public class Constraints {
/** /**
* Set this boolean to true to enable verbose logging * Set this boolean to true to enable verbose logging
*/ */
public static final boolean VERBOSE = true; public static final boolean VERBOSE = false;
/** /**
* Set this boolean to true to enable warning logging * Set this boolean to true to enable warning logging
@@ -65,7 +65,7 @@ public class Constraints {
public static final boolean WTF = true; public static final boolean WTF = true;
/** /**
* Clears the database everytime it is initialized * Clears the database every time it is initialized
*/ */
public static final boolean DROP_TABLES_EVERY_TIME = false; public static final boolean DROP_TABLES_EVERY_TIME = false;

View File

@@ -76,9 +76,11 @@ public class RingerDatabase {
if (cursor.moveToFirst()) if (cursor.moveToFirst())
do { do {
final ContentValues ringer = new ContentValues(); final ContentValues ringer = new ContentValues();
Log.v(TAG, "Converting: " + cursor.getString(0)); if(Constraints.VERBOSE)
Log.v(TAG, "Converting: " + cursor.getString(0));
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
Log.v(TAG, i + " = " + cursor.getColumnName(i) + " ~ " + cursor.getString(i)); if(Constraints.VERBOSE)
Log.v(TAG, i + " = " + cursor.getColumnName(i) + " ~ " + cursor.getString(i));
switch (i) { switch (i) {
case 0: // ringer name case 0: // ringer name
ringer.put(cursor.getColumnName(i), cursor.getString(0)); ringer.put(cursor.getColumnName(i), cursor.getString(0));
@@ -149,7 +151,8 @@ public class RingerDatabase {
*/ */
@Override @Override
public void onUpgrade(final SQLiteDatabase db, final int oldVersion, final int newVersion) { public void onUpgrade(final SQLiteDatabase db, final int oldVersion, final int newVersion) {
Log.w(TAG, "Upgrading database from version " + oldVersion + " to " + newVersion); if(Constraints.INFO)
Log.i(TAG, "Upgrading database from version " + oldVersion + " to " + newVersion);
if (mListener != null) if (mListener != null)
mListener.onDatabaseUpgrade(); mListener.onDatabaseUpgrade();
@@ -181,7 +184,8 @@ public class RingerDatabase {
c.moveToFirst(); c.moveToFirst();
if (c.moveToFirst()) if (c.moveToFirst())
do { do {
Log.d(TAG, "Moving: " + c.getInt(0) + " " + c.getString(1) + " " + c.getInt(2) + ", " + c.getInt(3) + " @ " + c.getInt(4) + "m"); if(Constraints.VERBOSE)
Log.v(TAG, "Moving: " + c.getInt(0) + " " + c.getString(1) + " " + c.getInt(2) + ", " + c.getInt(3) + " @ " + c.getInt(4) + "m");
final ContentValues ringer = new ContentValues(); final ContentValues ringer = new ContentValues();
final ContentValues info = new ContentValues(); final ContentValues info = new ContentValues();
ringer.put(KEY_RINGER_NAME, c.getString(1)); ringer.put(KEY_RINGER_NAME, c.getString(1));
@@ -566,7 +570,8 @@ public class RingerDatabase {
public boolean isRingerEnabled(final long id) { public boolean isRingerEnabled(final long id) {
final Cursor cursor = mDb.query(RINGER_TABLE, new String[] { KEY_IS_ENABLED }, "id = " + id, null, null, null, null); final Cursor cursor = mDb.query(RINGER_TABLE, new String[] { KEY_IS_ENABLED }, "id = " + id, null, null, null, null);
if (cursor.moveToFirst()) { if (cursor.moveToFirst()) {
Log.d(TAG, "isRingerEnabled(" + id + ") = " + cursor.getString(0)); if(Constraints.VERBOSE)
Log.v(TAG, "isRingerEnabled(" + id + ") = " + cursor.getString(0));
return parseBoolean(cursor.getString(0)); return parseBoolean(cursor.getString(0));
} }
return false; return false;
@@ -604,7 +609,8 @@ public class RingerDatabase {
} }
public int setRingerEnabled(final long id, final boolean enabled) { public int setRingerEnabled(final long id, final boolean enabled) {
Log.d(TAG, "setRingerEnabled(" + id + ") = " + enabled); if(Constraints.VERBOSE)
Log.v(TAG, "setRingerEnabled(" + id + ") = " + enabled);
final ContentValues values = new ContentValues(); final ContentValues values = new ContentValues();
values.put(KEY_IS_ENABLED, enabled); values.put(KEY_IS_ENABLED, enabled);
return mDb.update(RINGER_TABLE, values, "id" + "= " + id, null); return mDb.update(RINGER_TABLE, values, "id" + "= " + id, null);

View File

@@ -28,10 +28,12 @@ public class LocationChangedReceiver extends BaseLocationReceiver {
@Override @Override
public void onLocationUpdate(final Location location) { public void onLocationUpdate(final Location location) {
if (location != null) if (location != null) {
if (location.getAccuracy() <= Constraints.IGNORE) if (location.getAccuracy() <= Constraints.IGNORE)
mContext.startService(new Intent(mContext, RingerProcessingService.class).putExtra(LocationLibraryConstants.INTENT_EXTRA_LOCATION_CHANGED, location)); mContext.startService(new Intent(mContext, RingerProcessingService.class).putExtra(LocationLibraryConstants.INTENT_EXTRA_LOCATION_CHANGED, location));
Log.d(TAG, "location accuracy = " + location.getAccuracy() + " ignoring"); else if (Constraints.VERBOSE)
Log.d(TAG, "location was null"); Log.v(TAG, "location accuracy = " + location.getAccuracy() + " ignoring");
} else if(Constraints.VERBOSE)
Log.v(TAG, "location was null");
} }
} }

View File

@@ -60,7 +60,8 @@ public class RingerProcessingService extends Service {
* @author ricky barrette * @author ricky barrette
*/ */
private void applyRinger(final ContentValues values) { private void applyRinger(final ContentValues values) {
Log.d(TAG, "applyRigner()"); if(Constraints.VERBOSE)
Log.v(TAG, "applyRigner()");
final String name = values.getAsString(RingerDatabase.KEY_RINGER_NAME); final String name = values.getAsString(RingerDatabase.KEY_RINGER_NAME);
@@ -72,7 +73,11 @@ public class RingerProcessingService extends Service {
* ringtone & volume * ringtone & volume
*/ */
if (values.containsKey(RingerDatabase.KEY_RINGTONE_URI)) if (values.containsKey(RingerDatabase.KEY_RINGTONE_URI))
Log.d(TAG, "Ringtone: " + applyRingtone(RingtoneManager.TYPE_RINGTONE, values.getAsString(RingerDatabase.KEY_RINGTONE_URI))); if(Constraints.VERBOSE)
Log.v(TAG, "Ringtone: " + applyRingtone(RingtoneManager.TYPE_RINGTONE, values.getAsString(RingerDatabase.KEY_RINGTONE_URI)));
else
applyRingtone(RingtoneManager.TYPE_RINGTONE, values.getAsString(RingerDatabase.KEY_RINGTONE_URI));
if (values.containsKey(RingerDatabase.KEY_RINGTONE_VOLUME)) if (values.containsKey(RingerDatabase.KEY_RINGTONE_VOLUME))
setStreamVolume(values.getAsInteger(RingerDatabase.KEY_RINGTONE_VOLUME), AudioManager.STREAM_RING); setStreamVolume(values.getAsInteger(RingerDatabase.KEY_RINGTONE_VOLUME), AudioManager.STREAM_RING);
@@ -80,12 +85,18 @@ public class RingerProcessingService extends Service {
* notification ringtone & volume * notification ringtone & volume
*/ */
if (values.containsKey(RingerDatabase.KEY_NOTIFICATION_RINGTONE_URI)) if (values.containsKey(RingerDatabase.KEY_NOTIFICATION_RINGTONE_URI))
Log.d(TAG, "Notification Ringtone: " + applyRingtone(RingtoneManager.TYPE_NOTIFICATION, values.getAsString(RingerDatabase.KEY_NOTIFICATION_RINGTONE_URI))); if(Constraints.VERBOSE)
Log.v(TAG, "Notification Ringtone: " + applyRingtone(RingtoneManager.TYPE_NOTIFICATION, values.getAsString(RingerDatabase.KEY_NOTIFICATION_RINGTONE_URI)));
else
applyRingtone(RingtoneManager.TYPE_NOTIFICATION, values.getAsString(RingerDatabase.KEY_NOTIFICATION_RINGTONE_URI));
if (values.containsKey(RingerDatabase.KEY_NOTIFICATION_RINGTONE_VOLUME)) if (values.containsKey(RingerDatabase.KEY_NOTIFICATION_RINGTONE_VOLUME))
setStreamVolume(values.getAsInteger(RingerDatabase.KEY_NOTIFICATION_RINGTONE_VOLUME), AudioManager.STREAM_NOTIFICATION); setStreamVolume(values.getAsInteger(RingerDatabase.KEY_NOTIFICATION_RINGTONE_VOLUME), AudioManager.STREAM_NOTIFICATION);
Log.d(TAG, "Music " + (mAudioManager.isMusicActive() ? "is playing " : "is not playing")); if(Constraints.VERBOSE) {
Log.d(TAG, "Wired Headset " + (mAudioManager.isWiredHeadsetOn() ? "is on " : "is off")); Log.v(TAG, "Music " + (mAudioManager.isMusicActive() ? "is playing " : "is not playing"));
Log.v(TAG, "Wired Headset " + (mAudioManager.isWiredHeadsetOn() ? "is on " : "is off"));
}
/* /*
* music volume we will set the music volume only if music is not * music volume we will set the music volume only if music is not
@@ -208,7 +219,8 @@ public class RingerProcessingService extends Service {
@Override @Override
public void onCreate() { public void onCreate() {
Thread.setDefaultUncaughtExceptionHandler(new ExceptionHandler(this)); Thread.setDefaultUncaughtExceptionHandler(new ExceptionHandler(this));
Log.d(TAG, "onCreate()"); if(Constraints.VERBOSE)
Log.v(TAG, "onCreate()");
super.onCreate(); super.onCreate();
mDb = new RingerDatabase(this); mDb = new RingerDatabase(this);
mSettings = getSharedPreferences(SettingsActivity.SETTINGS, Constraints.SHARED_PREFS_MODE); mSettings = getSharedPreferences(SettingsActivity.SETTINGS, Constraints.SHARED_PREFS_MODE);
@@ -239,7 +251,9 @@ public class RingerProcessingService extends Service {
*/ */
@Override @Override
public int onStartCommand(final Intent intent, final int flags, final int startId) { public int onStartCommand(final Intent intent, final int flags, final int startId) {
Log.d(TAG, "onStartCommand: " + startId); if(Constraints.VERBOSE)
Log.v(TAG, "onStartCommand: " + startId);
mStartId = startId; mStartId = startId;
/* /*
@@ -278,16 +292,18 @@ public class RingerProcessingService extends Service {
final ContentValues ringer = getRinger(1); final ContentValues ringer = getRinger(1);
final LatLng point = new LatLng(mLocation.getLatitude(), mLocation.getLongitude()); final LatLng point = new LatLng(mLocation.getLatitude(), mLocation.getLongitude());
Log.d(TAG, "Processing ringers");
Log.d(TAG, if(Constraints.VERBOSE) {
"Current location " + (int) (mLocation.getLatitude() * 1E6) + ", " + (int) (mLocation.getLongitude() * 1E6) + " @ " Log.v(TAG, "Processing ringers");
+ Float.valueOf(mLocation.getAccuracy()) / 1000 + "km"); Log.v(TAG, "Current location " + (int) (mLocation.getLatitude() * 1E6) + ", " + (int) (mLocation.getLongitude() * 1E6) + " @ " + Float.valueOf(mLocation.getAccuracy()) / 1000 + "km");
}
final Cursor c = mDb.getAllRingers(); final Cursor c = mDb.getAllRingers();
c.moveToFirst(); c.moveToFirst();
if (c.moveToFirst()) if (c.moveToFirst())
do { do {
Log.d(TAG, "Checking ringer " + c.getString(0)); if(Constraints.VERBOSE)
Log.v(TAG, "Checking ringer " + c.getString(0));
if (RingerDatabase.parseBoolean(c.getString(1))) { if (RingerDatabase.parseBoolean(c.getString(1))) {
final ContentValues info = mDb.getRingerInfo(c.getString(0)); final ContentValues info = mDb.getRingerInfo(c.getString(0));
@@ -310,14 +326,17 @@ public class RingerProcessingService extends Service {
c.close(); c.close();
for (final Entry<String, Object> item : ringer.valueSet())
Log.d(TAG, item.getKey()); if(Constraints.VERBOSE)
for (final Entry<String, Object> item : ringer.valueSet())
Log.v(TAG, item.getKey());
applyRinger(ringer); applyRinger(ringer);
Log.d(TAG, "Finished processing ringers"); if(Constraints.VERBOSE)
Log.v(TAG, "Finished processing ringers");
// store is default // store isDefault
mSettings.edit().putBoolean(SettingsActivity.IS_DEFAULT, isDeafult).commit(); mSettings.edit().putBoolean(SettingsActivity.IS_DEFAULT, isDeafult).commit();
this.stopSelf(mStartId); this.stopSelf(mStartId);

View File

@@ -56,8 +56,9 @@ public class RingerInformationActivity extends FragmentActivity implements OnCon
* @author ricky barrette * @author ricky barrette
*/ */
private void logContentValues(final ContentValues values) { private void logContentValues(final ContentValues values) {
for (final Entry<String, Object> item : values.valueSet()) if(Constraints.VERBOSE)
Log.d(TAG, item.getKey() + " = " + item.getValue()); for (final Entry<String, Object> item : values.valueSet())
Log.v(TAG, item.getKey() + " = " + item.getValue());
} }
/** /**
@@ -153,8 +154,10 @@ public class RingerInformationActivity extends FragmentActivity implements OnCon
*/ */
@Override @Override
public void onInfoContentChanged(final ContentValues values) { public void onInfoContentChanged(final ContentValues values) {
Log.v(TAG, "onInfoContentChanged()"); if(Constraints.VERBOSE) {
logContentValues(values); Log.v(TAG, "onInfoContentChanged()");
logContentValues(values);
}
mInfo.putAll(values); mInfo.putAll(values);
} }
@@ -219,8 +222,10 @@ public class RingerInformationActivity extends FragmentActivity implements OnCon
*/ */
@Override @Override
public void onRingerContentChanged(final ContentValues values) { public void onRingerContentChanged(final ContentValues values) {
Log.v(TAG, "onRingerContentChanged()"); if(Constraints.VERBOSE) {
logContentValues(values); Log.v(TAG, "onRingerContentChanged()");
logContentValues(values);
}
mRinger.putAll(values); mRinger.putAll(values);
} }

View File

@@ -6,12 +6,6 @@
*/ */
package org.RickBarrette.android.LocationRinger.ui; package org.RickBarrette.android.LocationRinger.ui;
import java.util.List;
import org.RickBarrette.android.LocationRinger.Log;
import org.RickBarrette.android.LocationRinger.R;
import org.RickBarrette.android.LocationRinger.db.RingerDatabase;
import android.content.Context; import android.content.Context;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
@@ -21,6 +15,12 @@ import android.widget.CheckBox;
import android.widget.CompoundButton; import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener; import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.TextView; import android.widget.TextView;
import org.RickBarrette.android.LocationRinger.Constraints;
import org.RickBarrette.android.LocationRinger.Log;
import org.RickBarrette.android.LocationRinger.R;
import org.RickBarrette.android.LocationRinger.db.RingerDatabase;
import java.util.List;
/** /**
* This adapter will be used to populate the list view with all the ringers * This adapter will be used to populate the list view with all the ringers
@@ -47,7 +47,6 @@ public class RingerListAdapter extends BaseAdapter {
* Creates a new RingerListAdapter * Creates a new RingerListAdapter
* *
* @param context * @param context
* @param listener
* @param db * @param db
* @author ricky barrette * @author ricky barrette
*/ */
@@ -105,19 +104,22 @@ public class RingerListAdapter extends BaseAdapter {
// and the ImageView. // and the ImageView.
holder = (ViewHolder) convertView.getTag(); holder = (ViewHolder) convertView.getTag();
Log.d(TAG, "postion = " + position); if(Constraints.VERBOSE)
Log.v(TAG, "postion = " + position);
if (convertView == null) if(Constraints.ERROR) {
Log.e(TAG, "convertview is null!!!"); if (convertView == null)
Log.e(TAG, "convertview is null!!!");
if (holder == null) if (holder == null)
Log.e(TAG, "holder is null!!!"); Log.e(TAG, "holder is null!!!");
if (holder.title == null) if (holder.title == null)
Log.e(TAG, "holder.text is null!!!"); Log.e(TAG, "holder.text is null!!!");
if (holder.checkbox == null) if (holder.checkbox == null)
Log.e(TAG, "holder.checkbox is null!!!"); Log.e(TAG, "holder.checkbox is null!!!");
}
/* /*
* Bind the data efficiently with the holder. Remember that you should * Bind the data efficiently with the holder. Remember that you should

View File

@@ -21,6 +21,7 @@ import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener; import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.EditText; import android.widget.EditText;
import android.widget.ToggleButton; import android.widget.ToggleButton;
import org.RickBarrette.android.LocationRinger.Constraints;
import org.RickBarrette.android.LocationRinger.Log; import org.RickBarrette.android.LocationRinger.Log;
import org.RickBarrette.android.LocationRinger.OnContentChangedListener; import org.RickBarrette.android.LocationRinger.OnContentChangedListener;
import org.RickBarrette.android.LocationRinger.R; import org.RickBarrette.android.LocationRinger.R;
@@ -154,11 +155,13 @@ public class AboutRingerFragment extends Fragment implements OnCheckedChangeList
final View view = inflater.inflate(R.layout.ringer_about_fragment, container, false); final View view = inflater.inflate(R.layout.ringer_about_fragment, container, false);
for (final Entry<String, Object> item : mInfo.valueSet()) if(Constraints.VERBOSE) {
Log.d(TAG, item.getKey() + " = " + item.getValue()); for (final Entry<String, Object> item : mInfo.valueSet())
Log.d(TAG, item.getKey() + " = " + item.getValue());
for (final Entry<String, Object> item : mRinger.valueSet()) for (final Entry<String, Object> item : mRinger.valueSet())
Log.d(TAG, item.getKey() + " = " + item.getValue()); Log.d(TAG, item.getKey() + " = " + item.getValue());
}
/* /*
* ringer name * ringer name