Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add basic settings screen, showing only the version number
- Loading branch information
Showing
9 changed files
with
129 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
|
||
<style name="Theme.MuzeiBGG" parent="android:Theme.Holo"> | ||
<item name="android:windowBackground">@android:color/transparent</item> | ||
<item name="android:windowContentOverlay">@null</item> | ||
<item name="android:windowShowWallpaper">true</item> | ||
</style> | ||
|
||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" > | ||
|
||
<com.eaux.app.muzei.bgg.VersionPreference android:title="@string/settings_version" /> | ||
|
||
</PreferenceScreen> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<preference-headers xmlns:android="http://schemas.android.com/apk/res/android" > | ||
|
||
<header | ||
android:fragment="com.eaux.app.muzei.bgg.SettingsActivity$PrefFragment" | ||
android:icon="@drawable/ic_action_about" | ||
android:title="@string/settings_about" > | ||
<extra | ||
android:name="fragment" | ||
android:value="com.eaux.app.muzei.bgg.settings.ABOUT" /> | ||
</header> | ||
|
||
</preference-headers> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package com.eaux.app.muzei.bgg; | ||
|
||
import java.util.HashMap; | ||
import java.util.List; | ||
|
||
import android.app.ActionBar; | ||
import android.os.Bundle; | ||
import android.preference.PreferenceActivity; | ||
import android.preference.PreferenceFragment; | ||
|
||
public class SettingsActivity extends PreferenceActivity { | ||
private final static String ACTION_ABOUT = "com.eaux.app.muzei.bgg.settings.ABOUT"; | ||
private static final HashMap<String, Integer> mFragmentMap = buildFragmentMap(); | ||
|
||
private static HashMap<String, Integer> buildFragmentMap() { | ||
HashMap<String, Integer> map = new HashMap<String, Integer>(); | ||
map.put(ACTION_ABOUT, R.xml.preference_about); | ||
return map; | ||
} | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
|
||
ActionBar actionBar = getActionBar(); | ||
actionBar.setIcon(null); | ||
actionBar.setDisplayUseLogoEnabled(false); | ||
actionBar.setDisplayShowTitleEnabled(true); | ||
} | ||
|
||
@Override | ||
public void onBuildHeaders(List<Header> target) { | ||
loadHeadersFromResource(R.xml.preference_headers, target); | ||
} | ||
|
||
public static class PrefFragment extends PreferenceFragment { | ||
@Override | ||
public void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
String fragment = getArguments().getString("fragment"); | ||
if (fragment != null) { | ||
Integer fragmentId = mFragmentMap.get(fragment); | ||
if (fragmentId != null) { | ||
addPreferencesFromResource(fragmentId); | ||
} | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
protected boolean isValidFragment(String fragmentName) { | ||
return "com.eaux.app.muzei.bgg.SettingsActivity$PrefFragment".equals(fragmentName); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.eaux.app.muzei.bgg; | ||
|
||
import android.content.Context; | ||
import android.content.pm.PackageInfo; | ||
import android.content.pm.PackageManager; | ||
import android.content.pm.PackageManager.NameNotFoundException; | ||
import android.preference.DialogPreference; | ||
import android.util.AttributeSet; | ||
|
||
public class VersionPreference extends DialogPreference { | ||
|
||
public VersionPreference(Context context, AttributeSet attrs) { | ||
super(context, attrs); | ||
} | ||
|
||
public VersionPreference(Context context, AttributeSet attrs, int defStyle) { | ||
super(context, attrs, defStyle); | ||
} | ||
|
||
@Override | ||
public CharSequence getSummary() { | ||
try { | ||
PackageManager pm = getContext().getPackageManager(); | ||
PackageInfo pInfo = pm.getPackageInfo(getContext().getPackageName(), 0); | ||
return pInfo.versionName; | ||
} catch (NameNotFoundException e) { | ||
return "?.?"; | ||
} | ||
} | ||
} |