Compare commits
10 Commits
c6c6f1819b
...
aa69f23600
| Author | SHA1 | Date | |
|---|---|---|---|
| aa69f23600 | |||
| 6f42994da5 | |||
| f077b45477 | |||
| 5b7ba832f9 | |||
| c09a043d00 | |||
| b1e553b436 | |||
| b2e1d24aa0 | |||
| 29c8cb61e4 | |||
| d196950b92 | |||
| 00b90b4331 |
@@ -2,8 +2,8 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="org.RickBarrette.android.LocationRinger"
|
||||
android:installLocation="internalOnly"
|
||||
android:versionCode="248"
|
||||
android:versionName="8cc52de" >
|
||||
android:versionCode="249"
|
||||
android:versionName="d196950" >
|
||||
|
||||
<uses-sdk android:minSdkVersion="17" />
|
||||
|
||||
|
||||
@@ -47,14 +47,27 @@
|
||||
layout="@layout/ringer_info_button_bar"
|
||||
android:visibility="gone" />
|
||||
|
||||
<fragment
|
||||
android:id="@+id/map"
|
||||
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_above="@id/buttons"
|
||||
android:layout_below="@id/map_controls"
|
||||
class="com.google.android.gms.maps.SupportMapFragment" >
|
||||
</fragment>
|
||||
android:layout_below="@id/map_controls">
|
||||
|
||||
<fragment
|
||||
android:id="@+id/map"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
class="com.google.android.gms.maps.SupportMapFragment" />
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/map_progress"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:visibility="invisible"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/radius_textview"
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical" >
|
||||
android:orientation="vertical"
|
||||
android:id="@+id/ringtone_fragment">
|
||||
|
||||
<include
|
||||
android:id="@+id/title_bar"
|
||||
|
||||
@@ -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
|
||||
@@ -65,7 +65,7 @@ public class Constraints {
|
||||
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;
|
||||
|
||||
|
||||
@@ -76,9 +76,11 @@ public class RingerDatabase {
|
||||
if (cursor.moveToFirst())
|
||||
do {
|
||||
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++) {
|
||||
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) {
|
||||
case 0: // ringer name
|
||||
ringer.put(cursor.getColumnName(i), cursor.getString(0));
|
||||
@@ -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);
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
}
|
||||
@@ -42,8 +42,7 @@ public class LocationService extends com.TwentyCodes.android.location.LocationSe
|
||||
* @author ricky barrette
|
||||
*/
|
||||
public static Intent getSingleShotServiceIntent(final Context context) {
|
||||
return new Intent(context, LocationService.class).putExtra(LocationLibraryConstants.INTENT_EXTRA_REQUIRED_ACCURACY, Constraints.ACCURACY).setAction(
|
||||
LocationLibraryConstants.INTENT_ACTION_UPDATE);
|
||||
return new Intent(context, LocationService.class).putExtra(LocationLibraryConstants.INTENT_EXTRA_REQUIRED_ACCURACY, Constraints.ACCURACY).setAction( LocationLibraryConstants.INTENT_ACTION_UPDATE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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();
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
@@ -6,19 +6,6 @@
|
||||
*/
|
||||
package org.RickBarrette.android.LocationRinger.ui;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.RickBarrette.android.LocationRinger.Constraints;
|
||||
import org.RickBarrette.android.LocationRinger.EnableScrollingListener;
|
||||
import org.RickBarrette.android.LocationRinger.Log;
|
||||
import org.RickBarrette.android.LocationRinger.OnContentChangedListener;
|
||||
import org.RickBarrette.android.LocationRinger.R;
|
||||
import org.RickBarrette.android.LocationRinger.db.RingerDatabase;
|
||||
import org.RickBarrette.android.LocationRinger.ui.fragments.AboutRingerFragment;
|
||||
import org.RickBarrette.android.LocationRinger.ui.fragments.FeatureListFragment;
|
||||
import org.RickBarrette.android.LocationRinger.ui.fragments.LocationInformationFragment;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.app.ProgressDialog;
|
||||
@@ -34,10 +21,18 @@ import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
|
||||
import com.TwentyCodes.android.exception.ExceptionHandler;
|
||||
import com.jakewharton.android.viewpagerindicator.TitlePageIndicator;
|
||||
import com.jakewharton.android.viewpagerindicator.TitledFragmentAdapter;
|
||||
import org.RickBarrette.android.LocationRinger.*;
|
||||
import org.RickBarrette.android.LocationRinger.db.RingerDatabase;
|
||||
import org.RickBarrette.android.LocationRinger.ui.fragments.AboutRingerFragment;
|
||||
import org.RickBarrette.android.LocationRinger.ui.fragments.FeatureListFragment;
|
||||
import org.RickBarrette.android.LocationRinger.ui.fragments.LocationInformationFragment;
|
||||
import org.RickBarrette.android.LocationRinger.ui.fragments.RingtoneFragment;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
/**
|
||||
* This activity will handle displaying ringer options
|
||||
@@ -52,6 +47,7 @@ public class RingerInformationActivity extends FragmentActivity implements OnCon
|
||||
private Intent mData;
|
||||
private ViewPager mPager;
|
||||
private LocationInformationFragment mLocationInfomationFragment;
|
||||
private Fragment mFragmentCallBack;
|
||||
|
||||
/**
|
||||
* Logs the content values
|
||||
@@ -60,8 +56,9 @@ public class RingerInformationActivity extends FragmentActivity implements OnCon
|
||||
* @author ricky barrette
|
||||
*/
|
||||
private void logContentValues(final ContentValues values) {
|
||||
for (final Entry<String, Object> item : values.valueSet())
|
||||
Log.d(TAG, item.getKey() + " = " + item.getValue());
|
||||
if(Constraints.VERBOSE)
|
||||
for (final Entry<String, Object> item : values.valueSet())
|
||||
Log.v(TAG, item.getKey() + " = " + item.getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -157,8 +154,10 @@ public class RingerInformationActivity extends FragmentActivity implements OnCon
|
||||
*/
|
||||
@Override
|
||||
public void onInfoContentChanged(final ContentValues values) {
|
||||
Log.v(TAG, "onInfoContentChanged()");
|
||||
logContentValues(values);
|
||||
if(Constraints.VERBOSE) {
|
||||
Log.v(TAG, "onInfoContentChanged()");
|
||||
logContentValues(values);
|
||||
}
|
||||
mInfo.putAll(values);
|
||||
}
|
||||
|
||||
@@ -223,8 +222,10 @@ public class RingerInformationActivity extends FragmentActivity implements OnCon
|
||||
*/
|
||||
@Override
|
||||
public void onRingerContentChanged(final ContentValues values) {
|
||||
Log.v(TAG, "onRingerContentChanged()");
|
||||
logContentValues(values);
|
||||
if(Constraints.VERBOSE) {
|
||||
Log.v(TAG, "onRingerContentChanged()");
|
||||
logContentValues(values);
|
||||
}
|
||||
mRinger.putAll(values);
|
||||
}
|
||||
|
||||
@@ -274,4 +275,26 @@ public class RingerInformationActivity extends FragmentActivity implements OnCon
|
||||
mPager.setScrollEnabled(enabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles results from activities. checks for a call back
|
||||
* @param requestCode
|
||||
* @param resultCode
|
||||
* @param data
|
||||
*/
|
||||
@Override
|
||||
public void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
|
||||
if(mFragmentCallBack != null) {
|
||||
mFragmentCallBack.onActivityResult(requestCode, resultCode, data);
|
||||
mFragmentCallBack = null;
|
||||
} else
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up a call back for a fragment
|
||||
* @param fragmentCallBack
|
||||
*/
|
||||
public void setFragmentCallBack(RingtoneFragment fragmentCallBack) {
|
||||
mFragmentCallBack = fragmentCallBack;
|
||||
}
|
||||
}
|
||||
@@ -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,19 +104,22 @@ 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 (convertView == null)
|
||||
Log.e(TAG, "convertview is null!!!");
|
||||
if(Constraints.ERROR) {
|
||||
if (convertView == null)
|
||||
Log.e(TAG, "convertview is null!!!");
|
||||
|
||||
if (holder == null)
|
||||
Log.e(TAG, "holder is null!!!");
|
||||
if (holder == null)
|
||||
Log.e(TAG, "holder is null!!!");
|
||||
|
||||
if (holder.title == null)
|
||||
Log.e(TAG, "holder.text is null!!!");
|
||||
if (holder.title == null)
|
||||
Log.e(TAG, "holder.text is null!!!");
|
||||
|
||||
if (holder.checkbox == null)
|
||||
Log.e(TAG, "holder.checkbox is null!!!");
|
||||
if (holder.checkbox == null)
|
||||
Log.e(TAG, "holder.checkbox is null!!!");
|
||||
}
|
||||
|
||||
/*
|
||||
* Bind the data efficiently with the holder. Remember that you should
|
||||
|
||||
@@ -23,6 +23,7 @@ import org.RickBarrette.android.LocationRinger.Log;
|
||||
import org.RickBarrette.android.LocationRinger.R;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
@@ -77,7 +78,7 @@ public class SearchDialog extends Dialog implements android.view.View.OnClickLis
|
||||
final ArrayList<String> list = new ArrayList<String>();
|
||||
try {
|
||||
for (int i = 0; i < mResults.length(); i++)
|
||||
list.add(mResults.getJSONObject(i).getString("address"));
|
||||
list.add(mResults.getJSONObject(i).getString("formatted_address"));
|
||||
} catch (final JSONException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
@@ -96,8 +97,8 @@ public class SearchDialog extends Dialog implements android.view.View.OnClickLis
|
||||
private LatLng getCoords(final int index) {
|
||||
Log.d(TAG, "getCoords()");
|
||||
try {
|
||||
final JSONArray coords = mResults.getJSONObject(index).getJSONObject("Point").getJSONArray("coordinates");
|
||||
return new LatLng(coords.getDouble(1), coords.getDouble(0));
|
||||
final JSONObject coords = mResults.getJSONObject(index).getJSONObject("geometry").getJSONObject("location");
|
||||
return new LatLng(coords.getDouble("lat"), coords.getDouble("lng"));
|
||||
} catch (final JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
for (final Entry<String, Object> item : mInfo.valueSet())
|
||||
Log.d(TAG, item.getKey() + " = " + item.getValue());
|
||||
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());
|
||||
for (final Entry<String, Object> item : mRinger.valueSet())
|
||||
Log.d(TAG, item.getKey() + " = " + item.getValue());
|
||||
}
|
||||
|
||||
/*
|
||||
* ringer name
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
package org.RickBarrette.android.LocationRinger.ui.fragments;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
@@ -30,6 +31,7 @@ public class BaseFeatureFragment extends Fragment implements OnClickListener {
|
||||
private final int mIconRes;
|
||||
private final int mLayout;
|
||||
private ImageView mIcon;
|
||||
private Activity mActivity;
|
||||
|
||||
/**
|
||||
* Creates a new Feature Fragment
|
||||
@@ -105,6 +107,12 @@ public class BaseFeatureFragment extends Fragment implements OnClickListener {
|
||||
* @author ricky barrette
|
||||
*/
|
||||
public void setIcon(final int icon) {
|
||||
mIcon.setImageDrawable(getActivity().getResources().getDrawable(icon));
|
||||
mIcon.setImageDrawable(mActivity.getResources().getDrawable(icon));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(Activity activity) {
|
||||
super.onAttach(activity);
|
||||
mActivity = activity;
|
||||
}
|
||||
}
|
||||
@@ -6,11 +6,6 @@
|
||||
*/
|
||||
package org.RickBarrette.android.LocationRinger.ui.fragments;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.RickBarrette.android.LocationRinger.Log;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
@@ -18,6 +13,10 @@ import android.support.v4.app.FragmentTransaction;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import org.RickBarrette.android.LocationRinger.Log;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
||||
|
||||
/**
|
||||
@@ -89,7 +88,7 @@ public abstract class BaseFragmentListFragment extends Fragment {
|
||||
* Adds a collection ofs fragments to the list, but doesn't preform any
|
||||
* transactions
|
||||
*
|
||||
* @param fragment
|
||||
* @param fragments
|
||||
* @author ricky barrette
|
||||
*/
|
||||
protected void addAllInit(final ArrayList<Fragment> fragments) {
|
||||
|
||||
@@ -25,9 +25,7 @@ import com.TwentyCodes.android.location.OnLocationSelectedListener;
|
||||
import com.google.android.gms.maps.CameraUpdateFactory;
|
||||
import com.google.android.gms.maps.GoogleMap;
|
||||
import com.google.android.gms.maps.SupportMapFragment;
|
||||
import com.google.android.gms.maps.model.Circle;
|
||||
import com.google.android.gms.maps.model.CircleOptions;
|
||||
import com.google.android.gms.maps.model.LatLng;
|
||||
import com.google.android.gms.maps.model.*;
|
||||
import org.RickBarrette.android.LocationRinger.*;
|
||||
import org.RickBarrette.android.LocationRinger.db.RingerDatabase;
|
||||
import org.RickBarrette.android.LocationRinger.ui.SearchDialog;
|
||||
@@ -39,7 +37,7 @@ import org.RickBarrette.android.LocationRinger.ui.SearchDialog;
|
||||
* @author ricky
|
||||
*/
|
||||
@SuppressLint("ValidFragment")
|
||||
public class LocationInformationFragment extends Fragment implements LatLngListener, OnClickListener, OnCheckedChangeListener, OnSeekBarChangeListener, SearchRequestedListener, GoogleMap.OnMapClickListener, OnLocationSelectedListener {
|
||||
public class LocationInformationFragment extends Fragment implements LatLngListener, OnClickListener, OnCheckedChangeListener, OnSeekBarChangeListener, SearchRequestedListener, GoogleMap.OnMapClickListener, OnLocationSelectedListener, GoogleMap.OnMarkerDragListener {
|
||||
|
||||
private static final String TAG = "RingerInformationHowActivity";
|
||||
private final ContentValues mInfo;
|
||||
@@ -53,6 +51,9 @@ public class LocationInformationFragment extends Fragment implements LatLngListe
|
||||
private View view;
|
||||
private TextView mRadiusTextView;
|
||||
private Circle mCircle;
|
||||
private ProgressBar mProgress;
|
||||
private Marker mMarker;
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new MapFragment
|
||||
@@ -79,18 +80,15 @@ public class LocationInformationFragment extends Fragment implements LatLngListe
|
||||
|
||||
if (isChecked) {
|
||||
mGPS.enableLocationUpdates(this);
|
||||
// mMap.enableGPSProgess();
|
||||
mProgress.setVisibility(View.VISIBLE);
|
||||
mMap.setOnMapClickListener(this);
|
||||
} else {
|
||||
mGPS.disableLocationUpdates();
|
||||
// mMap.disableGPSProgess();
|
||||
mProgress.setVisibility(View.INVISIBLE);
|
||||
mMap.setOnMapClickListener(null);
|
||||
}
|
||||
|
||||
// mMap.setDoubleTapZoonEnabled(isChecked);
|
||||
// // buttons
|
||||
// mMap.setBuiltInZoomControls(isChecked);
|
||||
// mMap.setClickable(isChecked);*/
|
||||
enableMap(isChecked);
|
||||
mRadius.setEnabled(isChecked);
|
||||
Toast.makeText(getActivity(), isChecked ? getString(R.string.map_editing_enabled) : getString(R.string.map_editiing_disabled), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
@@ -120,6 +118,13 @@ public class LocationInformationFragment extends Fragment implements LatLngListe
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the fragment view is being created
|
||||
* @param inflater
|
||||
* @param container
|
||||
* @param savedInstanceState
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) {
|
||||
view = inflater.inflate(R.layout.map_info_fragment, container, false);
|
||||
@@ -131,9 +136,6 @@ public class LocationInformationFragment extends Fragment implements LatLngListe
|
||||
mRadiusTextView = (TextView) view.findViewById(R.id.radius_textview);
|
||||
mRadius.setMax(Constraints.MAX_RADIUS_IN_METERS);
|
||||
|
||||
//TODO extend GoogleMap to intercept clicks
|
||||
// mMap.setClickable(false);
|
||||
|
||||
mMapEditToggle = (ToggleButton) view.findViewById(R.id.map_edit_toggle);
|
||||
mMapEditToggle.setChecked(false);
|
||||
mMapEditToggle.setOnCheckedChangeListener(this);
|
||||
@@ -141,16 +143,39 @@ public class LocationInformationFragment extends Fragment implements LatLngListe
|
||||
mRadius.setOnSeekBarChangeListener(this);
|
||||
mRadius.setEnabled(false);
|
||||
|
||||
mProgress = (ProgressBar) view.findViewById(R.id.map_progress);
|
||||
|
||||
if (mInfo.get(RingerDatabase.KEY_RADIUS) != null) {
|
||||
mRadius.setProgress(mInfo.getAsInteger(RingerDatabase.KEY_RADIUS));
|
||||
}
|
||||
|
||||
if (mInfo.get(RingerDatabase.KEY_LOCATION) != null) {
|
||||
final String[] point = mInfo.getAsString(RingerDatabase.KEY_LOCATION).split(",");
|
||||
final LatLng location = new LatLng(Double.parseDouble(point[0]), Double.parseDouble(point[1]));
|
||||
|
||||
mCircle.setCenter(location);
|
||||
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(location, 14));
|
||||
}
|
||||
mMarker.setPosition(location);
|
||||
|
||||
mMap.setOnMapLoadedCallback(new GoogleMap.OnMapLoadedCallback() {
|
||||
@Override
|
||||
public void onMapLoaded() {
|
||||
if(Constraints.DEBUG)
|
||||
Log.d(TAG,"onMapLoaded()");
|
||||
final LatLngBounds.Builder builder = LatLngBounds.builder();
|
||||
builder.include(location);
|
||||
builder.include(GeoUtils.distanceFrom(location, mRadius.getProgress(), 90));
|
||||
mMap.animateCamera(CameraUpdateFactory.newLatLngBounds(builder.build(),25, 25, 5));
|
||||
// mMap.moveCamera(CameraUpdateFactory.newLatLng(location));
|
||||
if(Constraints.DEBUG){
|
||||
final MarkerOptions marker = new MarkerOptions();
|
||||
marker.position(location);
|
||||
marker.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_CYAN));
|
||||
mMap.addMarker(marker);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
if (mInfo.get(RingerDatabase.KEY_RADIUS) != null) {
|
||||
mRadius.setProgress(mInfo.getAsInteger(RingerDatabase.KEY_RADIUS));
|
||||
}
|
||||
|
||||
view.findViewById(R.id.my_location).setOnClickListener(this);
|
||||
@@ -164,8 +189,6 @@ public class LocationInformationFragment extends Fragment implements LatLngListe
|
||||
/**
|
||||
* Called when the location is a first fix (non-Javadoc)
|
||||
*
|
||||
* todo fix this
|
||||
*
|
||||
* @see com.TwentyCodes.android.location.LatLngListener#onFirstFix(boolean)
|
||||
*/
|
||||
@Override
|
||||
@@ -177,14 +200,14 @@ public class LocationInformationFragment extends Fragment implements LatLngListe
|
||||
* current location
|
||||
*/
|
||||
if (isFirstFix) {
|
||||
// mMap.disableGPSProgess();
|
||||
if (mMap != null) {
|
||||
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(mPoint, 14));
|
||||
}
|
||||
mProgress.setVisibility(View.INVISIBLE);
|
||||
if (mMap != null)
|
||||
if(mCircle.getCenter().equals(new LatLng(0, 0)))
|
||||
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(mPoint, 14));
|
||||
|
||||
}
|
||||
}
|
||||
// else
|
||||
// mMap.enableGPSProgess();
|
||||
} else
|
||||
mProgress.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -218,8 +241,6 @@ public class LocationInformationFragment extends Fragment implements LatLngListe
|
||||
case R.id.radius:
|
||||
mRadiusTextView.setText(GeoUtils.distanceToString(Float.valueOf(progress) / 1000, true));
|
||||
mCircle.setRadius(progress);
|
||||
//todo invalidate this shit
|
||||
// mMap.invalidate();
|
||||
if (mListener != null) {
|
||||
final ContentValues info = new ContentValues();
|
||||
info.put(RingerDatabase.KEY_RADIUS, progress);
|
||||
@@ -306,50 +327,118 @@ public class LocationInformationFragment extends Fragment implements LatLngListe
|
||||
*/
|
||||
private void setUpMap() {
|
||||
|
||||
//Create the circle overlay and add it to the map
|
||||
final CircleOptions circle = new CircleOptions();
|
||||
circle.strokeColor(Color.GREEN);
|
||||
circle.fillColor(Color.argb(100, 0, 255, 0));
|
||||
circle.strokeColor(Color.BLUE);
|
||||
circle.fillColor(Color.argb(100, 0, 0, 255));
|
||||
circle.center(new LatLng(0, 0));
|
||||
circle.radius(0);
|
||||
mCircle = mMap.addCircle(circle);
|
||||
|
||||
if (mCircle.getCenter() != null) {
|
||||
mMap.moveCamera(CameraUpdateFactory.newLatLng(mCircle.getCenter()));
|
||||
//todo zoom
|
||||
// mMap.setZoom(16);
|
||||
}
|
||||
final MarkerOptions marker = new MarkerOptions();
|
||||
marker.draggable(true);
|
||||
marker.position(mCircle.getCenter());
|
||||
marker.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN));
|
||||
mMarker = mMap.addMarker(marker);
|
||||
|
||||
mMap.setOnMarkerDragListener(this);
|
||||
|
||||
// mMap.addCircle(mRadiusOverlay.getCircleOptions());
|
||||
|
||||
//
|
||||
// mMap.setDoubleTapZoonEnabled(false);
|
||||
enableMap(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables/Disables the zoom and scroll gestures of the map
|
||||
* @param isEnabled
|
||||
*/
|
||||
private void enableMap(final boolean isEnabled){
|
||||
mMap.getUiSettings().setAllGesturesEnabled(isEnabled);
|
||||
mMap.getUiSettings().setZoomControlsEnabled(isEnabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the Map is clicked
|
||||
* @param point
|
||||
*/
|
||||
@Override
|
||||
public void onMapClick(LatLng point) {
|
||||
onLocationSelected(point);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a location is selected in the search dialog
|
||||
* @param point
|
||||
*/
|
||||
@Override
|
||||
public void onLocationSelected(LatLng point) {
|
||||
if (point != null) {
|
||||
Log.d(TAG, "onLocationSelected() " + point.toString());
|
||||
|
||||
if (mCircle != null)
|
||||
mCircle.setCenter(point);
|
||||
updateOverlay(point);
|
||||
|
||||
if (mMap != null)
|
||||
mMap.moveCamera(CameraUpdateFactory.newLatLng(point));
|
||||
|
||||
if (mListener != null) {
|
||||
final ContentValues info = new ContentValues();
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
sb.append(point.latitude).append(",").append(point.longitude);
|
||||
info.put(RingerDatabase.KEY_LOCATION, sb.toString());
|
||||
mListener.onInfoContentChanged(info);
|
||||
}
|
||||
updateLocation(point);
|
||||
} else
|
||||
Log.d(TAG, "onLocationSelected() Location was null");
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the location used in the database and notifies maintainer
|
||||
* @param location
|
||||
*/
|
||||
private void updateLocation(LatLng location) {
|
||||
if (mListener != null) {
|
||||
final ContentValues info = new ContentValues();
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
sb.append(location.latitude).append(",").append(location.longitude);
|
||||
info.put(RingerDatabase.KEY_LOCATION, sb.toString());
|
||||
mListener.onInfoContentChanged(info);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the marker and the circle
|
||||
* @param point
|
||||
*/
|
||||
private void updateOverlay(final LatLng point) {
|
||||
if (mCircle != null)
|
||||
mCircle.setCenter(point);
|
||||
|
||||
if(mMarker != null)
|
||||
mMarker.setPosition(point);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called at the start of a marker's drag cycle
|
||||
* @param marker
|
||||
*/
|
||||
@Override
|
||||
public void onLocationSelected(LatLng point) {
|
||||
onMapClick(point);
|
||||
public void onMarkerDragStart(Marker marker) {
|
||||
final LatLng location = marker.getPosition();
|
||||
updateOverlay(location);
|
||||
updateLocation(location);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a marker is being dragged
|
||||
* @param marker
|
||||
*/
|
||||
@Override
|
||||
public void onMarkerDrag(Marker marker) {
|
||||
final LatLng location = marker.getPosition();
|
||||
updateOverlay(location);
|
||||
updateLocation(location);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called at the end of a marker's drag cycle
|
||||
* @param marker
|
||||
*/
|
||||
@Override
|
||||
public void onMarkerDragEnd(Marker marker) {
|
||||
final LatLng location = marker.getPosition();
|
||||
updateOverlay(location);
|
||||
updateLocation(location);
|
||||
}
|
||||
}
|
||||
@@ -6,14 +6,6 @@
|
||||
*/
|
||||
package org.RickBarrette.android.LocationRinger.ui.fragments;
|
||||
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.RickBarrette.android.LocationRinger.FeatureRemovedListener;
|
||||
import org.RickBarrette.android.LocationRinger.Log;
|
||||
import org.RickBarrette.android.LocationRinger.OnContentChangedListener;
|
||||
import org.RickBarrette.android.LocationRinger.R;
|
||||
import org.RickBarrette.android.LocationRinger.db.RingerDatabase;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.content.ContentValues;
|
||||
@@ -24,6 +16,7 @@ import android.media.Ringtone;
|
||||
import android.media.RingtoneManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
@@ -32,6 +25,11 @@ import android.widget.EditText;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.SeekBar.OnSeekBarChangeListener;
|
||||
import android.widget.TextView;
|
||||
import org.RickBarrette.android.LocationRinger.*;
|
||||
import org.RickBarrette.android.LocationRinger.db.RingerDatabase;
|
||||
import org.RickBarrette.android.LocationRinger.ui.RingerInformationActivity;
|
||||
|
||||
import java.util.Map.Entry;
|
||||
|
||||
/**
|
||||
* This fragment will be for ringtone settings
|
||||
@@ -52,9 +50,10 @@ public class RingtoneFragment extends BaseFeatureFragment implements OnClickList
|
||||
private EditText mRingtone;
|
||||
private Uri mRingtoneURI;
|
||||
private SeekBar mVolume;
|
||||
private Activity mActivity;
|
||||
private String mTone;
|
||||
|
||||
public RingtoneFragment(final ContentValues info, final OnContentChangedListener changedListener, final FeatureRemovedListener removedListener, final int stream,
|
||||
final int id) {
|
||||
public RingtoneFragment(final ContentValues info, final OnContentChangedListener changedListener, final FeatureRemovedListener removedListener, final int stream, final int id) {
|
||||
super(id, R.layout.ringtone_fragment, removedListener);
|
||||
|
||||
if (info == null)
|
||||
@@ -100,7 +99,15 @@ public class RingtoneFragment extends BaseFeatureFragment implements OnClickList
|
||||
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_SILENT, true);
|
||||
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, false);
|
||||
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, uri);
|
||||
startActivityForResult(intent, ringtoneCode);
|
||||
|
||||
if (Constraints.VERBOSE)
|
||||
Log.v(TAG, TAG + ".getRingtoneURI " + this.getFragmentId());
|
||||
|
||||
FragmentActivity activity = this.getActivity();
|
||||
if ( activity instanceof RingerInformationActivity)
|
||||
((RingerInformationActivity) activity).setFragmentCallBack(this);
|
||||
|
||||
mActivity.startActivityForResult(intent, ringtoneCode);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -139,19 +146,12 @@ public class RingtoneFragment extends BaseFeatureFragment implements OnClickList
|
||||
*/
|
||||
@Override
|
||||
public void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
|
||||
if (Constraints.DEBUG)
|
||||
Log.d(TAG, "onActivityResult");
|
||||
|
||||
if (resultCode == Activity.RESULT_OK) {
|
||||
final Uri tone = data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI);
|
||||
if (tone == null) {
|
||||
mRingtone.setText(R.string.silent);
|
||||
mVolume.setEnabled(false);
|
||||
mVolume.setProgress(0);
|
||||
notifyVolumeChanged(0);
|
||||
} else {
|
||||
mVolume.setEnabled(true);
|
||||
final Ringtone ringtone = RingtoneManager.getRingtone(getActivity(), Uri.parse(tone.toString()));
|
||||
mRingtone.setText(ringtone.getTitle(getActivity()));
|
||||
}
|
||||
|
||||
updateToneUri(tone);
|
||||
notifyRingtoneChanged(tone);
|
||||
}
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
@@ -179,8 +179,9 @@ public class RingtoneFragment extends BaseFeatureFragment implements OnClickList
|
||||
final View view = super.onCreateView(inflater, container, savedInstanceState);
|
||||
final AudioManager audioManager = (AudioManager) getActivity().getSystemService(Context.AUDIO_SERVICE);
|
||||
|
||||
for (final Entry<String, Object> item : mInfo.valueSet())
|
||||
Log.d(TAG, item.getKey() + " = " + item.getValue());
|
||||
if(Constraints.VERBOSE)
|
||||
for (final Entry<String, Object> item : mInfo.valueSet())
|
||||
Log.v(TAG, item.getKey() + " = " + item.getValue());
|
||||
|
||||
/*
|
||||
* initialize the views
|
||||
@@ -212,31 +213,70 @@ public class RingtoneFragment extends BaseFeatureFragment implements OnClickList
|
||||
* ringtone & uri
|
||||
*/
|
||||
if (mInfo.containsKey(mKeyUri)) {
|
||||
try {
|
||||
mRingtoneURI = Uri.parse(mInfo.getAsString(mKeyUri));
|
||||
} catch (final NullPointerException e) {
|
||||
mRingtoneURI = null;
|
||||
}
|
||||
mVolume.setEnabled(mInfo.getAsString(mKeyUri) != null);
|
||||
updateTone(mInfo.getAsString(mKeyUri));
|
||||
} else {
|
||||
mRingtoneURI = RingtoneManager.getActualDefaultRingtoneUri(getActivity(), mType);
|
||||
updateToneUri(RingtoneManager.getActualDefaultRingtoneUri(getActivity(), mType));
|
||||
notifyRingtoneChanged(mRingtoneURI);
|
||||
}
|
||||
|
||||
try {
|
||||
mRingtone.setText(RingtoneManager.getRingtone(getActivity(), mRingtoneURI).getTitle(getActivity()));
|
||||
} catch (final NullPointerException e) {
|
||||
mVolume.setEnabled(false);
|
||||
mRingtone.setText(R.string.silent);
|
||||
mVolume.setProgress(0);
|
||||
}
|
||||
|
||||
setIcon(mVolume.getProgress() == 0 ? R.drawable.ic_action_silent : R.drawable.ic_action_volume);
|
||||
|
||||
mVolume.setOnSeekBarChangeListener(this);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
/**
|
||||
* Trys to parse the string into a Uri and updates the UI
|
||||
* @param uri
|
||||
*/
|
||||
private void updateTone(String uri){
|
||||
try {
|
||||
updateToneUri(Uri.parse(uri));
|
||||
} catch (final NullPointerException e) {
|
||||
updateToneUri(null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates UI
|
||||
* @param uri
|
||||
*/
|
||||
private void updateToneUri(final Uri uri){
|
||||
mVolume.setEnabled(uri != null);
|
||||
mRingtoneURI = uri;
|
||||
|
||||
//get the name of the ringtone
|
||||
try {
|
||||
if(uri == null)
|
||||
throw new NullPointerException();
|
||||
mTone = RingtoneManager.getRingtone(getActivity(), uri).getTitle(getActivity());
|
||||
final Ringtone ringtone = RingtoneManager.getRingtone(mActivity, uri);
|
||||
} catch (final NullPointerException e) {
|
||||
mTone = mActivity.getString(R.string.silent);
|
||||
}
|
||||
|
||||
//update the ringtone text view
|
||||
mRingtone.setText(mTone);
|
||||
|
||||
//enable or disable volume
|
||||
if(uri == null){
|
||||
mVolume.setProgress(0);
|
||||
mVolume.setEnabled(false);
|
||||
mVolume.setProgress(0);
|
||||
notifyVolumeChanged(0);
|
||||
} else
|
||||
mVolume.setEnabled(true);
|
||||
|
||||
setIcon(mVolume.getProgress() == 0 ? R.drawable.ic_action_silent : R.drawable.ic_action_volume);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the volume progress bar is updated
|
||||
* @param seekBar
|
||||
* @param progress
|
||||
* @param fromUser
|
||||
*/
|
||||
@Override
|
||||
public void onProgressChanged(final SeekBar seekBar, final int progress, final boolean fromUser) {
|
||||
if (fromUser)
|
||||
@@ -251,4 +291,25 @@ public class RingtoneFragment extends BaseFeatureFragment implements OnClickList
|
||||
public void onStopTrackingTouch(final SeekBar seekBar) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the fragment is attached. need to save a reference to the activity
|
||||
* @param activity
|
||||
*/
|
||||
@Override
|
||||
public void onAttach(Activity activity) {
|
||||
super.onAttach(activity);
|
||||
mActivity = activity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when resuming. Had to update the ringtone edit text here
|
||||
*/
|
||||
@Override
|
||||
public void onResume(){
|
||||
if(mTone != null){
|
||||
mRingtone.setText(mTone);
|
||||
mTone = null;
|
||||
}
|
||||
super.onResume();
|
||||
}
|
||||
}
|
||||
@@ -6,14 +6,6 @@
|
||||
*/
|
||||
package org.RickBarrette.android.LocationRinger.ui.fragments;
|
||||
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.RickBarrette.android.LocationRinger.FeatureRemovedListener;
|
||||
import org.RickBarrette.android.LocationRinger.Log;
|
||||
import org.RickBarrette.android.LocationRinger.OnContentChangedListener;
|
||||
import org.RickBarrette.android.LocationRinger.R;
|
||||
import org.RickBarrette.android.LocationRinger.db.RingerDatabase;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
@@ -25,6 +17,10 @@ import android.view.ViewGroup;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.SeekBar.OnSeekBarChangeListener;
|
||||
import android.widget.TextView;
|
||||
import org.RickBarrette.android.LocationRinger.*;
|
||||
import org.RickBarrette.android.LocationRinger.db.RingerDatabase;
|
||||
|
||||
import java.util.Map.Entry;
|
||||
|
||||
/**
|
||||
* This fragment will represent the volume fragments
|
||||
@@ -126,8 +122,9 @@ public class VolumeFragment extends BaseFeatureFragment implements OnSeekBarChan
|
||||
@Override
|
||||
public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) {
|
||||
|
||||
for (final Entry<String, Object> item : mInfo.valueSet())
|
||||
Log.d(TAG, item.getKey() + " = " + item.getValue());
|
||||
if(Constraints.VERBOSE)
|
||||
for (final Entry<String, Object> item : mInfo.valueSet())
|
||||
Log.v(TAG, item.getKey() + " = " + item.getValue());
|
||||
|
||||
final View view = super.onCreateView(inflater, container, savedInstanceState);
|
||||
final TextView label = (TextView) view.findViewById(R.id.title);
|
||||
|
||||
Submodule location_library updated: ec9fb9aec0...fcb4aecf8a
Reference in New Issue
Block a user