Added App Icon (back) Navigation to settings activity
Change-Id: Ia3ec8893abd52867af2f8c4c4b029103e2dfcdfe Signed-off-by: Ricky Barrette <rickbarrette@gmail.com>
This commit is contained in:
@@ -6,6 +6,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.TwentyCode.android.ExaltedDice;
|
package com.TwentyCode.android.ExaltedDice;
|
||||||
|
|
||||||
|
import android.app.ActionBar;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.PackageInfo;
|
import android.content.pm.PackageInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
@@ -15,6 +16,7 @@ import android.os.Bundle;
|
|||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
import android.preference.Preference.OnPreferenceClickListener;
|
import android.preference.Preference.OnPreferenceClickListener;
|
||||||
import android.preference.PreferenceActivity;
|
import android.preference.PreferenceActivity;
|
||||||
|
import android.view.MenuItem;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This activity will be used to allow the user to fine tune exalted dice
|
* This activity will be used to allow the user to fine tune exalted dice
|
||||||
@@ -29,20 +31,77 @@ public class Settings extends PreferenceActivity implements OnPreferenceClickLis
|
|||||||
private static final CharSequence EMAIL = "email";
|
private static final CharSequence EMAIL = "email";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* (non-Javadoc)
|
* generates the exception repost email intent
|
||||||
* @see android.preference.PreferenceActivity#onCreate(android.os.Bundle)
|
* @param report
|
||||||
|
* @return intent to start users email client
|
||||||
|
* @author ricky barrette
|
||||||
*/
|
*/
|
||||||
@Override
|
private Intent generateEmailIntent() {
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
/*
|
||||||
super.onCreate(savedInstanceState);
|
* get the build information, and build the string
|
||||||
//set shared_prefs name
|
*/
|
||||||
getPreferenceManager().setSharedPreferencesName(SETTINGS);
|
PackageManager pm = this.getPackageManager();
|
||||||
|
PackageInfo pi;
|
||||||
//load preferences xml. this load relies on only wether the app is full or not. it will show the check license option if full and leave it out if lite
|
try {
|
||||||
addPreferencesFromResource(R.xml.settings);
|
pi = pm.getPackageInfo(this.getPackageName(), 0);
|
||||||
this.findPreference(EMAIL).setOnPreferenceClickListener(this);
|
} 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+" build "+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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* (non-Javadoc)
|
||||||
|
* @see android.preference.PreferenceActivity#onCreate(android.os.Bundle)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The following is for api 11 and up
|
||||||
|
*/
|
||||||
|
if(Integer.valueOf(android.os.Build.VERSION.SDK) > 11){
|
||||||
|
ActionBar actionBar = getActionBar();
|
||||||
|
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
//set shared_prefs name
|
||||||
|
getPreferenceManager().setSharedPreferencesName(SETTINGS);
|
||||||
|
|
||||||
|
//load preferences xml. this load relies on only wether the app is full or not. it will show the check license option if full and leave it out if lite
|
||||||
|
addPreferencesFromResource(R.xml.settings);
|
||||||
|
this.findPreference(EMAIL).setOnPreferenceClickListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a options item has been selected
|
||||||
|
* (non-Javadoc)
|
||||||
|
* @see android.app.Activity#onOptionsItemSelected(android.view.MenuItem)
|
||||||
|
*/
|
||||||
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
|
switch (item.getItemId()) {
|
||||||
|
case android.R.id.home:
|
||||||
|
Intent intent = new Intent(this, ExaltedDice.class);
|
||||||
|
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||||
|
startActivity(intent);
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return super.onOptionsItemSelected(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* called when the email preference button is clicked
|
* called when the email preference button is clicked
|
||||||
*/
|
*/
|
||||||
@@ -51,35 +110,4 @@ public class Settings extends PreferenceActivity implements OnPreferenceClickLis
|
|||||||
this.startActivity(generateEmailIntent());
|
this.startActivity(generateEmailIntent());
|
||||||
return false;
|
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+" build "+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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user