Enabled Back Navigation in Settings
closes #62 Signed-off-by: Ricky Barrette <rickbarrette@gmail.com>
This commit is contained in:
@@ -23,7 +23,9 @@ import android.os.Environment;
|
||||
import android.preference.Preference;
|
||||
import android.preference.Preference.OnPreferenceClickListener;
|
||||
import android.preference.PreferenceActivity;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import com.TwentyCodes.android.LocationRinger.LocationRinger;
|
||||
import com.TwentyCodes.android.LocationRinger.R;
|
||||
|
||||
/**
|
||||
@@ -47,54 +49,6 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
|
||||
public static final String RESTORE = "restore";
|
||||
public static final String BACKUP = "backup";
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState){
|
||||
super.onCreate(savedInstanceState);
|
||||
this.getPreferenceManager().setSharedPreferencesName(SETTINGS);
|
||||
addPreferencesFromResource(R.xml.setings);
|
||||
this.findPreference(EMAIL).setOnPreferenceClickListener(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* called when the email preference button is clicked
|
||||
*/
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
this.startActivity(generateEmailIntent());
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* generates the exception repost email intent
|
||||
* @param report
|
||||
* @return intent to start users email client
|
||||
* @author ricky barrette
|
||||
*/
|
||||
private Intent generateEmailIntent() {
|
||||
/*
|
||||
* get the build information, and build the string
|
||||
*/
|
||||
PackageManager pm = this.getPackageManager();
|
||||
PackageInfo pi;
|
||||
try {
|
||||
pi = pm.getPackageInfo(this.getPackageName(), 0);
|
||||
} catch (NameNotFoundException eNnf) {
|
||||
//doubt this will ever run since we want info about our own package
|
||||
pi = new PackageInfo();
|
||||
pi.versionName = "unknown";
|
||||
pi.versionCode = 1;
|
||||
}
|
||||
|
||||
Intent intent = new Intent(Intent.ACTION_SEND);
|
||||
String theSubject = this.getString(R.string.app_name);
|
||||
String theBody = "\n\n\n"+ Build.FINGERPRINT +"\n"+ this.getString(R.string.app_name)+" "+pi.versionName+" bulid "+pi.versionCode;
|
||||
intent.putExtra(Intent.EXTRA_EMAIL,new String[] {this.getString(R.string.email)});
|
||||
intent.putExtra(Intent.EXTRA_TEXT, theBody);
|
||||
intent.putExtra(Intent.EXTRA_SUBJECT, theSubject);
|
||||
intent.setType("message/rfc822");
|
||||
return intent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Backs up the database
|
||||
* @return true if successful
|
||||
@@ -118,7 +72,7 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Copies a file
|
||||
* @param src file
|
||||
@@ -163,4 +117,74 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
|
||||
context.getSharedPreferences(SETTINGS, Context.MODE_WORLD_WRITEABLE).edit().remove(IS_FIRST_RINGER_PROCESSING).remove(IS_DEFAULT).remove(IS_SERVICE_STARTED).commit();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* generates the exception repost email intent
|
||||
* @param report
|
||||
* @return intent to start users email client
|
||||
* @author ricky barrette
|
||||
*/
|
||||
private Intent generateEmailIntent() {
|
||||
/*
|
||||
* get the build information, and build the string
|
||||
*/
|
||||
PackageManager pm = this.getPackageManager();
|
||||
PackageInfo pi;
|
||||
try {
|
||||
pi = pm.getPackageInfo(this.getPackageName(), 0);
|
||||
} catch (NameNotFoundException eNnf) {
|
||||
//doubt this will ever run since we want info about our own package
|
||||
pi = new PackageInfo();
|
||||
pi.versionName = "unknown";
|
||||
pi.versionCode = 1;
|
||||
}
|
||||
|
||||
Intent intent = new Intent(Intent.ACTION_SEND);
|
||||
String theSubject = this.getString(R.string.app_name);
|
||||
String theBody = "\n\n\n"+ Build.FINGERPRINT +"\n"+ this.getString(R.string.app_name)+" "+pi.versionName+" bulid "+pi.versionCode;
|
||||
intent.putExtra(Intent.EXTRA_EMAIL,new String[] {this.getString(R.string.email)});
|
||||
intent.putExtra(Intent.EXTRA_TEXT, theBody);
|
||||
intent.putExtra(Intent.EXTRA_SUBJECT, theSubject);
|
||||
intent.setType("message/rfc822");
|
||||
return intent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState){
|
||||
super.onCreate(savedInstanceState);
|
||||
this.getPreferenceManager().setSharedPreferencesName(SETTINGS);
|
||||
addPreferencesFromResource(R.xml.setings);
|
||||
this.findPreference(EMAIL).setOnPreferenceClickListener(this);
|
||||
|
||||
/*
|
||||
* Set up the action bar if required
|
||||
*/
|
||||
if(Integer.valueOf(android.os.Build.VERSION.SDK_INT) > 11)
|
||||
getActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* (non-Javadoc)
|
||||
* @see android.app.Activity#onOptionsItemSelected(android.view.MenuItem)
|
||||
* @author ricky barrette
|
||||
*/
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(final MenuItem item) {
|
||||
switch(item.getItemId()){
|
||||
case android.R.id.home:
|
||||
final Intent intent = new Intent(this, LocationRinger.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP).putExtra(ListActivity.NO_SPLASH, ListActivity.NO_SPLASH);
|
||||
startActivity(intent);
|
||||
return true;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
/**
|
||||
* called when the email preference button is clicked
|
||||
*/
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
this.startActivity(generateEmailIntent());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user