Fixed some lint errors
Signed-off-by: Ricky Barrette <rickbarrette@gmail.com>
This commit is contained in:
@@ -40,8 +40,28 @@ public class RingerDatabase {
|
||||
private static final String TAG = "RingerDatabase";
|
||||
private final Context mContext;
|
||||
private SQLiteDatabase mDb;
|
||||
private final DatabaseListener mListener;
|
||||
private static DatabaseListener mListener;
|
||||
public boolean isUpgrading = false;
|
||||
private final static Handler mHandler;
|
||||
protected static final int DELETIONCOMPLETE = 0;
|
||||
protected static final int DATABASEUPGRADECOMPLETE = 1;
|
||||
|
||||
static{
|
||||
mHandler = new Handler(){
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
if(mListener != null)
|
||||
switch(msg.what){
|
||||
case DELETIONCOMPLETE:
|
||||
mListener.onRingerDeletionComplete();
|
||||
break;
|
||||
case DATABASEUPGRADECOMPLETE:
|
||||
mListener.onDatabaseUpgradeComplete();
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/*
|
||||
* database information values
|
||||
@@ -212,19 +232,11 @@ public class RingerDatabase {
|
||||
public void onUpgrade(final SQLiteDatabase db, final int oldVersion, int newVersion) {
|
||||
Log.w(TAG, "Upgrading database from version "+oldVersion+" to "+newVersion);
|
||||
|
||||
if(RingerDatabase.this.mListener != null)
|
||||
RingerDatabase.this.mListener.onDatabaseUpgrade();
|
||||
if(mListener != null)
|
||||
mListener.onDatabaseUpgrade();
|
||||
|
||||
RingerDatabase.this.isUpgrading = true;
|
||||
|
||||
final Handler handler = new Handler(){
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
if(RingerDatabase.this.mListener != null)
|
||||
RingerDatabase.this.mListener.onDatabaseUpgradeComplete();
|
||||
}
|
||||
};
|
||||
|
||||
//upgrade thread
|
||||
new Thread( new Runnable(){
|
||||
@Override
|
||||
@@ -269,7 +281,7 @@ public class RingerDatabase {
|
||||
db.execSQL("ALTER TABLE ringers_new RENAME TO "+ RINGER_TABLE);
|
||||
|
||||
}
|
||||
handler.sendEmptyMessage(0);
|
||||
mHandler.sendEmptyMessage(DATABASEUPGRADECOMPLETE);
|
||||
RingerDatabase.this.isUpgrading = false;
|
||||
}
|
||||
}).start();
|
||||
@@ -292,7 +304,7 @@ public class RingerDatabase {
|
||||
* @author ricky barrette
|
||||
*/
|
||||
public RingerDatabase(Context context, DatabaseListener listener){
|
||||
this.mListener = listener;
|
||||
mListener = listener;
|
||||
this.mContext = context;
|
||||
this.mDb = new OpenHelper(this.mContext).getWritableDatabase();
|
||||
}
|
||||
@@ -384,15 +396,7 @@ public class RingerDatabase {
|
||||
public void deleteRinger(final long id) {
|
||||
|
||||
final ProgressDialog progress = ProgressDialog.show(RingerDatabase.this.mContext, "", RingerDatabase.this.mContext.getText(R.string.deleteing), true, true);
|
||||
|
||||
final Handler handler = new Handler(){
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
if(RingerDatabase.this.mListener != null)
|
||||
RingerDatabase.this.mListener.onRingerDeletionComplete();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//ringer deleting thread
|
||||
new Thread( new Runnable(){
|
||||
@Override
|
||||
@@ -409,7 +413,7 @@ public class RingerDatabase {
|
||||
*/
|
||||
RingerDatabase.this.mDb.delete(RINGER_TABLE, "id = "+ id, null);
|
||||
updateRowIds(id +1);
|
||||
handler.sendEmptyMessage(0);
|
||||
mHandler.sendEmptyMessage(DELETIONCOMPLETE);
|
||||
progress.dismiss();
|
||||
}
|
||||
}).start();
|
||||
@@ -585,8 +589,8 @@ public class RingerDatabase {
|
||||
this.mDb.close();
|
||||
this.mDb = new OpenHelper(this.mContext).getWritableDatabase();
|
||||
if(this.mDb.isOpen() && ! this.isUpgrading)
|
||||
if(this.mListener != null)
|
||||
this.mListener.onRestoreComplete();
|
||||
if(mListener != null)
|
||||
mListener.onRestoreComplete();
|
||||
}
|
||||
|
||||
public int setRingerEnabled(final long id, final boolean enabled) {
|
||||
@@ -667,7 +671,7 @@ public class RingerDatabase {
|
||||
*/
|
||||
private void updateRowIds(long id) {
|
||||
long currentRow;
|
||||
ContentValues values = new ContentValues();
|
||||
final ContentValues values = new ContentValues();
|
||||
final Cursor cursor = this.mDb.query(RINGER_TABLE, new String[] { "id" },null, null, null, null, null);
|
||||
if (cursor.moveToFirst()) {
|
||||
do {
|
||||
|
||||
@@ -48,7 +48,7 @@ public final String TAG = "GetLocationWidget";
|
||||
int appWidgetId = appWidgetIds[i];
|
||||
|
||||
Intent intent = new Intent(context, LocationService.class)
|
||||
.putExtra(LocationService.INTENT_EXTRA_REQUIRED_ACCURACY, Integer.parseInt(context.getSharedPreferences(SettingsActivity.SETTINGS, Context.MODE_WORLD_READABLE).getString(SettingsActivity.ACCURACY , "50")))
|
||||
.putExtra(LocationService.INTENT_EXTRA_REQUIRED_ACCURACY, Integer.parseInt(context.getSharedPreferences(SettingsActivity.SETTINGS, Debug.SHARED_PREFS_MODE).getString(SettingsActivity.ACCURACY , "50")))
|
||||
.setAction(LocationLibraryConstants.INTENT_ACTION_UPDATE);
|
||||
|
||||
//create a pending intent to start the post activity
|
||||
|
||||
@@ -15,6 +15,7 @@ import android.content.SharedPreferences;
|
||||
|
||||
import com.TwentyCodes.android.LocationRinger.LocationRinger;
|
||||
import com.TwentyCodes.android.LocationRinger.R;
|
||||
import com.TwentyCodes.android.LocationRinger.debug.Debug;
|
||||
import com.TwentyCodes.android.LocationRinger.ui.SettingsActivity;
|
||||
import com.TwentyCodes.android.SkyHook.SkyHookService;
|
||||
import com.TwentyCodes.android.exception.ExceptionHandler;
|
||||
@@ -57,7 +58,7 @@ public class LocationService extends SkyHookService {
|
||||
@Override
|
||||
public void onCreate() {
|
||||
Thread.setDefaultUncaughtExceptionHandler(new ExceptionHandler(this));
|
||||
this.mSettings = this.getSharedPreferences(SettingsActivity.SETTINGS, Context.MODE_WORLD_WRITEABLE);
|
||||
this.mSettings = this.getSharedPreferences(SettingsActivity.SETTINGS, Debug.SHARED_PREFS_MODE);
|
||||
this.mSettings.edit().putBoolean(SettingsActivity.IS_SERVICE_STARTED, true).commit();
|
||||
startOnGoingNotification();
|
||||
super.onCreate();
|
||||
|
||||
@@ -332,7 +332,7 @@ public class RingerProcessingService extends Service {
|
||||
final ContentValues info = this.mDb.getRingerInfo(c.getString(0));
|
||||
if(info.containsKey(RingerDatabase.KEY_LOCATION) && info.containsKey(RingerDatabase.KEY_RADIUS)){
|
||||
final String[] pointInfo = info.getAsString(RingerDatabase.KEY_LOCATION).split(",");
|
||||
if(GeoUtils.isIntersecting(point, Float.valueOf(mLocation.getAccuracy()) / 1000, new GeoPoint(Integer.parseInt(pointInfo[0]), Integer.parseInt(pointInfo[1])), new Float(info.getAsInteger(RingerDatabase.KEY_RADIUS)) / 1000, Debug.FUDGE_FACTOR)){
|
||||
if(GeoUtils.isIntersecting(point, Float.valueOf(mLocation.getAccuracy()) / 1000, new GeoPoint(Integer.parseInt(pointInfo[0]), Integer.parseInt(pointInfo[1])), Float.valueOf(info.getAsInteger(RingerDatabase.KEY_RADIUS)) / 1000, Debug.FUDGE_FACTOR)){
|
||||
c.close();
|
||||
getRinger(ringer, index);
|
||||
isDeafult = false;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
package com.TwentyCodes.android.LocationRinger.ui;
|
||||
|
||||
import com.TwentyCodes.android.LocationRinger.R;
|
||||
import com.TwentyCodes.android.LocationRinger.debug.Debug;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
@@ -71,7 +72,7 @@ public class FirstBootDialog extends Dialog implements android.view.View.OnClick
|
||||
*/
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
this.getContext().getSharedPreferences(SettingsActivity.SETTINGS, Context.MODE_WORLD_WRITEABLE).edit().putBoolean(SettingsActivity.IS_FIRST_BOOT, false).commit();
|
||||
this.getContext().getSharedPreferences(SettingsActivity.SETTINGS, Debug.SHARED_PREFS_MODE).edit().putBoolean(SettingsActivity.IS_FIRST_BOOT, false).commit();
|
||||
this.dismiss();
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ import android.os.Bundle;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import com.TwentyCodes.android.LocationRinger.R;
|
||||
import com.TwentyCodes.android.LocationRinger.debug.Debug;
|
||||
import com.TwentyCodes.android.LocationRinger.services.LocationService;
|
||||
import com.TwentyCodes.android.debug.LocationLibraryConstants;
|
||||
|
||||
@@ -78,7 +79,7 @@ public class LauncherShortcuts extends Activity {
|
||||
* start the location service in single shot mode
|
||||
*/
|
||||
Intent service = new Intent(this, LocationService.class)
|
||||
.putExtra(LocationService.INTENT_EXTRA_REQUIRED_ACCURACY, Integer.parseInt(this.getSharedPreferences(SettingsActivity.SETTINGS, Context.MODE_WORLD_READABLE).getString(SettingsActivity.ACCURACY , "50")))
|
||||
.putExtra(LocationService.INTENT_EXTRA_REQUIRED_ACCURACY, Integer.parseInt(this.getSharedPreferences(SettingsActivity.SETTINGS, Debug.SHARED_PREFS_MODE).getString(SettingsActivity.ACCURACY , "50")))
|
||||
.setAction(LocationLibraryConstants.INTENT_ACTION_UPDATE);
|
||||
this.startService(service);
|
||||
|
||||
|
||||
@@ -7,14 +7,16 @@
|
||||
|
||||
package com.TwentyCodes.android.LocationRinger.ui;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.database.Cursor;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.view.ContextMenu;
|
||||
import android.view.ContextMenu.ContextMenuInfo;
|
||||
@@ -36,19 +38,20 @@ import com.TwentyCodes.android.LocationRinger.debug.Debug;
|
||||
import com.TwentyCodes.android.LocationRinger.receivers.PassiveLocationChangedReceiver;
|
||||
import com.TwentyCodes.android.LocationRinger.services.LocationService;
|
||||
import com.TwentyCodes.android.SkyHook.SkyHookRegistration;
|
||||
import com.TwentyCodes.android.SkyHook.Splash;
|
||||
import com.TwentyCodes.android.debug.LocationLibraryConstants;
|
||||
import com.TwentyCodes.android.location.PassiveLocationListener;
|
||||
import com.skyhookwireless.wps.RegistrationCallback;
|
||||
import com.skyhookwireless.wps.WPSContinuation;
|
||||
import com.skyhookwireless.wps.WPSReturnCode;
|
||||
|
||||
@SuppressLint("Registered")
|
||||
public class ListActivity extends Activity implements OnItemClickListener, OnClickListener, DatabaseListener, RegistrationCallback {
|
||||
|
||||
private RingerDatabase mDb;
|
||||
private ListView mListView;
|
||||
private SharedPreferences mSettings;
|
||||
private ProgressDialog mProgress;
|
||||
private Dialog mSplashDialog;
|
||||
|
||||
public static final String NO_SPLASH = "no splash";
|
||||
public static final String KEY_RINGER = "key_ringer";
|
||||
@@ -153,7 +156,7 @@ public class ListActivity extends Activity implements OnItemClickListener, OnCli
|
||||
this.mListView.setEmptyView(findViewById(android.R.id.empty));
|
||||
findViewById(R.id.add_ringer_button).setOnClickListener(this);
|
||||
populate();
|
||||
this.mSettings = this.getSharedPreferences(SettingsActivity.SETTINGS, Context.MODE_WORLD_WRITEABLE);
|
||||
this.mSettings = this.getSharedPreferences(SettingsActivity.SETTINGS, Debug.SHARED_PREFS_MODE);
|
||||
|
||||
if(this.mSettings.getBoolean(SettingsActivity.IS_FIRST_BOOT, true))
|
||||
new FirstBootDialog(this).show();
|
||||
@@ -163,10 +166,10 @@ public class ListActivity extends Activity implements OnItemClickListener, OnCli
|
||||
}
|
||||
|
||||
if(!this.getIntent().hasExtra(NO_SPLASH))
|
||||
this.startActivity(new Intent(this, Splash.class));
|
||||
showSplashScreen();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* called when the activity is first created, creates a context menu
|
||||
* @param menu
|
||||
* @param v
|
||||
@@ -193,8 +196,8 @@ public class ListActivity extends Activity implements OnItemClickListener, OnCli
|
||||
return super.onCreateOptionsMenu(menu);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* Called when a database is being upgraded
|
||||
* @author ricky barrette
|
||||
*/
|
||||
@@ -202,7 +205,7 @@ public class ListActivity extends Activity implements OnItemClickListener, OnCli
|
||||
public void onDatabaseUpgrade() {
|
||||
this.mProgress = ProgressDialog.show(this, "", this.getText(R.string.upgrading), true, true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* called when a database upgrade is finished
|
||||
* @author ricky barrette
|
||||
@@ -213,8 +216,8 @@ public class ListActivity extends Activity implements OnItemClickListener, OnCli
|
||||
if(this.mProgress != null)
|
||||
this.mProgress.dismiss();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see android.app.Activity#onDestroy()
|
||||
* @author ricky barrette
|
||||
*/
|
||||
@@ -224,8 +227,8 @@ public class ListActivity extends Activity implements OnItemClickListener, OnCli
|
||||
PassiveLocationListener.requestPassiveLocationUpdates(this, new Intent(this, PassiveLocationChangedReceiver.class));
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* called when an item in the list view has been clicked,
|
||||
* this will open the note edit dialog for the selected note
|
||||
* (non-Javadoc)
|
||||
@@ -278,7 +281,7 @@ public class ListActivity extends Activity implements OnItemClickListener, OnCli
|
||||
}).start();
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* called when an option is selected form the menu
|
||||
* (non-Javadoc)
|
||||
* @see android.app.Activity#onOptionsItemSelected(android.view.MenuItem)
|
||||
@@ -304,7 +307,17 @@ public class ListActivity extends Activity implements OnItemClickListener, OnCli
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* (non-Javadoc)
|
||||
* @see android.app.Activity#onPause()
|
||||
*/
|
||||
@Override
|
||||
protected void onPause() {
|
||||
removeSplashScreen();
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the database is restored
|
||||
*/
|
||||
@Override
|
||||
@@ -320,7 +333,7 @@ public class ListActivity extends Activity implements OnItemClickListener, OnCli
|
||||
populate();
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* populates the list view from the data base
|
||||
* @author ricky barrette
|
||||
*/
|
||||
@@ -329,6 +342,16 @@ public class ListActivity extends Activity implements OnItemClickListener, OnCli
|
||||
mListView.setAdapter(new RingerListAdapter(this, mDb));
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the Dialog that displays the splash screen
|
||||
*/
|
||||
protected void removeSplashScreen() {
|
||||
if (mSplashDialog != null) {
|
||||
mSplashDialog.dismiss();
|
||||
mSplashDialog = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Restarts the service if its not already running.
|
||||
* @author ricky barrette
|
||||
@@ -345,4 +368,33 @@ public class ListActivity extends Activity implements OnItemClickListener, OnCli
|
||||
this.startService(i);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows the splash screen over the full Activity
|
||||
*/
|
||||
protected void showSplashScreen() {
|
||||
// mMap.setGPSDialogEnabled(false);
|
||||
mSplashDialog = new Dialog(this, android.R.style.Theme_Translucent);
|
||||
mSplashDialog.setContentView(R.layout.powered_by_skyhook);
|
||||
mSplashDialog.setCancelable(false);
|
||||
mSplashDialog.show();
|
||||
|
||||
// Set Runnable to remove splash screen just in case
|
||||
final Handler handler = new Handler();
|
||||
handler.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
removeSplashScreen();
|
||||
|
||||
/*
|
||||
* uncomment the following to display the eula
|
||||
*/
|
||||
// //loads first boot dialog if this is the first boot
|
||||
// if (! mSettings.getBoolean(Settings.ACCEPTED, false) || Debug.FORCE_FIRSTBOOT_DIALOG)
|
||||
// eulaAlert();
|
||||
// else
|
||||
// update();
|
||||
}
|
||||
}, 2000);
|
||||
}
|
||||
}
|
||||
@@ -44,6 +44,7 @@ public class AboutRingerFragment extends Fragment implements OnCheckedChangeList
|
||||
private final ContentValues mRinger;
|
||||
|
||||
public AboutRingerFragment(final ContentValues ringer, final ContentValues info, final OnContentChangedListener listener){
|
||||
super();
|
||||
this.mInfo = info;
|
||||
this.mRinger = ringer;
|
||||
this.mListener = listener;
|
||||
|
||||
Reference in New Issue
Block a user