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
*/
public static final boolean VERBOSE = true;
public static final boolean VERBOSE = false;
/**
* Set this boolean to true to enable warning logging

View File

@@ -76,8 +76,10 @@ public class RingerDatabase {
if (cursor.moveToFirst())
do {
final ContentValues ringer = new ContentValues();
if(Constraints.VERBOSE)
Log.v(TAG, "Converting: " + cursor.getString(0));
for (int i = 0; i < count; i++) {
if(Constraints.VERBOSE)
Log.v(TAG, i + " = " + cursor.getColumnName(i) + " ~ " + cursor.getString(i));
switch (i) {
case 0: // ringer name
@@ -149,7 +151,8 @@ public class RingerDatabase {
*/
@Override
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)
mListener.onDatabaseUpgrade();
@@ -181,7 +184,8 @@ public class RingerDatabase {
c.moveToFirst();
if (c.moveToFirst())
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 info = new ContentValues();
ringer.put(KEY_RINGER_NAME, c.getString(1));
@@ -566,7 +570,8 @@ public class RingerDatabase {
public boolean isRingerEnabled(final long id) {
final Cursor cursor = mDb.query(RINGER_TABLE, new String[] { KEY_IS_ENABLED }, "id = " + id, null, null, null, null);
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 false;
@@ -604,7 +609,8 @@ public class RingerDatabase {
}
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();
values.put(KEY_IS_ENABLED, enabled);
return mDb.update(RINGER_TABLE, values, "id" + "= " + id, null);

View File

@@ -28,10 +28,12 @@ public class LocationChangedReceiver extends BaseLocationReceiver {
@Override
public void onLocationUpdate(final Location location) {
if (location != null)
if (location != null) {
if (location.getAccuracy() <= Constraints.IGNORE)
mContext.startService(new Intent(mContext, RingerProcessingService.class).putExtra(LocationLibraryConstants.INTENT_EXTRA_LOCATION_CHANGED, location));
Log.d(TAG, "location accuracy = " + location.getAccuracy() + " ignoring");
Log.d(TAG, "location was null");
else if (Constraints.VERBOSE)
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
*/
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);
@@ -72,7 +73,11 @@ public class RingerProcessingService extends Service {
* ringtone & volume
*/
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))
setStreamVolume(values.getAsInteger(RingerDatabase.KEY_RINGTONE_VOLUME), AudioManager.STREAM_RING);
@@ -80,12 +85,18 @@ public class RingerProcessingService extends Service {
* notification ringtone & volume
*/
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))
setStreamVolume(values.getAsInteger(RingerDatabase.KEY_NOTIFICATION_RINGTONE_VOLUME), AudioManager.STREAM_NOTIFICATION);
Log.d(TAG, "Music " + (mAudioManager.isMusicActive() ? "is playing " : "is not playing"));
Log.d(TAG, "Wired Headset " + (mAudioManager.isWiredHeadsetOn() ? "is on " : "is off"));
if(Constraints.VERBOSE) {
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
@@ -208,7 +219,8 @@ public class RingerProcessingService extends Service {
@Override
public void onCreate() {
Thread.setDefaultUncaughtExceptionHandler(new ExceptionHandler(this));
Log.d(TAG, "onCreate()");
if(Constraints.VERBOSE)
Log.v(TAG, "onCreate()");
super.onCreate();
mDb = new RingerDatabase(this);
mSettings = getSharedPreferences(SettingsActivity.SETTINGS, Constraints.SHARED_PREFS_MODE);
@@ -239,7 +251,9 @@ public class RingerProcessingService extends Service {
*/
@Override
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;
/*
@@ -278,16 +292,18 @@ public class RingerProcessingService extends Service {
final ContentValues ringer = getRinger(1);
final LatLng point = new LatLng(mLocation.getLatitude(), mLocation.getLongitude());
Log.d(TAG, "Processing ringers");
Log.d(TAG,
"Current location " + (int) (mLocation.getLatitude() * 1E6) + ", " + (int) (mLocation.getLongitude() * 1E6) + " @ "
+ Float.valueOf(mLocation.getAccuracy()) / 1000 + "km");
if(Constraints.VERBOSE) {
Log.v(TAG, "Processing ringers");
Log.v(TAG, "Current location " + (int) (mLocation.getLatitude() * 1E6) + ", " + (int) (mLocation.getLongitude() * 1E6) + " @ " + Float.valueOf(mLocation.getAccuracy()) / 1000 + "km");
}
final Cursor c = mDb.getAllRingers();
c.moveToFirst();
if (c.moveToFirst())
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))) {
final ContentValues info = mDb.getRingerInfo(c.getString(0));
@@ -310,14 +326,17 @@ public class RingerProcessingService extends Service {
c.close();
if(Constraints.VERBOSE)
for (final Entry<String, Object> item : ringer.valueSet())
Log.d(TAG, item.getKey());
Log.v(TAG, item.getKey());
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();
this.stopSelf(mStartId);

View File

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

View File

@@ -6,12 +6,6 @@
*/
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.view.LayoutInflater;
import android.view.View;
@@ -21,6 +15,12 @@ import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
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
@@ -47,7 +47,6 @@ public class RingerListAdapter extends BaseAdapter {
* Creates a new RingerListAdapter
*
* @param context
* @param listener
* @param db
* @author ricky barrette
*/
@@ -105,8 +104,10 @@ public class RingerListAdapter extends BaseAdapter {
// and the ImageView.
holder = (ViewHolder) convertView.getTag();
Log.d(TAG, "postion = " + position);
if(Constraints.VERBOSE)
Log.v(TAG, "postion = " + position);
if(Constraints.ERROR) {
if (convertView == null)
Log.e(TAG, "convertview is null!!!");
@@ -118,6 +119,7 @@ public class RingerListAdapter extends BaseAdapter {
if (holder.checkbox == null)
Log.e(TAG, "holder.checkbox is null!!!");
}
/*
* 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.EditText;
import android.widget.ToggleButton;
import org.RickBarrette.android.LocationRinger.Constraints;
import org.RickBarrette.android.LocationRinger.Log;
import org.RickBarrette.android.LocationRinger.OnContentChangedListener;
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);
if(Constraints.VERBOSE) {
for (final Entry<String, Object> item : mInfo.valueSet())
Log.d(TAG, item.getKey() + " = " + item.getValue());
for (final Entry<String, Object> item : mRinger.valueSet())
Log.d(TAG, item.getKey() + " = " + item.getValue());
}
/*
* ringer name