Skip to content

Commit

Permalink
V1.0.5 - allow selection of font size in preferences
Browse files Browse the repository at this point in the history
* add ant build script (for command line building)
  • Loading branch information
fr3ts0n committed Nov 12, 2016
1 parent f333e30 commit e8b8ee7
Show file tree
Hide file tree
Showing 10 changed files with 312 additions and 15 deletions.
23 changes: 21 additions & 2 deletions AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ (C) Copyright 2015-2016 by fr3ts0n <[email protected]>
~
~ This program is free software; you can redistribute it and/or
~ modify it under the terms of the GNU General Public License as
~ published by the Free Software Foundation; either version 2 of
~ the License, or (at your option) any later version.
~
~ This program is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~ You should have received a copy of the GNU General Public License
~ along with this program; if not, write to the Free Software
~ Foundation, Inc., 59 Temple Place, Suite 330, Boston,
~ MA 02111-1307 USA
~
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.fr3ts0n.stagefever"
android:versionCode="010004"
android:versionName="1.0.4" >
android:versionCode="010005"
android:versionName="1.0.5">

<uses-sdk
android:minSdkVersion="15"
Expand Down Expand Up @@ -33,6 +51,7 @@
<data android:scheme="content" android:mimeType="text/*"/>
</intent-filter>
</activity>
<activity android:name=".SettingsActivity"/>
</application>

</manifest>
111 changes: 111 additions & 0 deletions build.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ (C) Copyright 2015-2016 by fr3ts0n <[email protected]>
~
~ This program is free software; you can redistribute it and/or
~ modify it under the terms of the GNU General Public License as
~ published by the Free Software Foundation; either version 2 of
~ the License, or (at your option) any later version.
~
~ This program is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~ You should have received a copy of the GNU General Public License
~ along with this program; if not, write to the Free Software
~ Foundation, Inc., 59 Temple Place, Suite 330, Boston,
~ MA 02111-1307 USA
~
-->

<project name="StageFever" default="help">

<!-- The local.properties file is created and updated by the 'android' tool.
It contains the path to the SDK. It should *NOT* be checked into
Version Control Systems. -->
<property file="local.properties" />

<!-- The ant.properties file can be created by you. It is only edited by the
'android' tool to add properties to it.
This is the place to change some Ant specific build properties.
Here are some properties you may want to change/update:
source.dir
The name of the source directory. Default is 'src'.
out.dir
The name of the output directory. Default is 'bin'.
For other overridable properties, look at the beginning of the rules
files in the SDK, at tools/ant/build.xml
Properties related to the SDK location or the project target should
be updated using the 'android' tool with the 'update' action.
This file is an integral part of the build system for your
application and should be checked into Version Control Systems.
-->
<property file="ant.properties" />

<!-- if sdk.dir was not set from one of the property file, then
get it from the ANDROID_HOME env var.
This must be done before we load project.properties since
the proguard config can use sdk.dir -->
<property environment="env" />
<condition property="sdk.dir" value="${env.ANDROID_HOME}">
<isset property="env.ANDROID_HOME" />
</condition>

<!-- The project.properties file is created and updated by the 'android'
tool, as well as ADT.
This contains project specific properties such as project target, and library
dependencies. Lower level build properties are stored in ant.properties
(or in .classpath for Eclipse projects).
This file is an integral part of the build system for your
application and should be checked into Version Control Systems. -->
<loadproperties srcFile="project.properties" />

<!-- quick check on sdk.dir -->
<fail
message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through the ANDROID_HOME environment variable."
unless="sdk.dir"
/>

<!--
Import per project custom build rules if present at the root of the project.
This is the place to put custom intermediary targets such as:
-pre-build
-pre-compile
-post-compile (This is typically used for code obfuscation.
Compiled code location: ${out.classes.absolute.dir}
If this is not done in place, override ${out.dex.input.absolute.dir})
-post-package
-post-build
-pre-clean
-->
<import file="custom_rules.xml" optional="true" />

<!-- Import the actual build file.
To customize existing targets, there are two options:
- Customize only one target:
- copy/paste the target into this file, *before* the
<import> task.
- customize it to your needs.
- Customize the whole content of build.xml
- copy/paste the content of the rules files (minus the top node)
into this file, replacing the <import> task.
- customize to your needs.
***********************
****** IMPORTANT ******
***********************
In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
in order to avoid having your file be overridden by tools such as "android update project"
-->
<!-- version-tag: 1 -->
<import file="${sdk.dir}/tools/ant/build.xml" />

</project>
1 change: 0 additions & 1 deletion res/layout/fragment_song_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@
android:layout_height="wrap_content"
android:text="@string/notes"
android:typeface="monospace"
android:textSize="30sp"
android:textStyle="normal|bold"
android:textColor="?android:attr/textColorPrimary"/>

Expand Down
5 changes: 5 additions & 0 deletions res/menu/main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.fr3ts0n.stagefever.MainActivity" >

<item
android:id="@+id/action_settings"
android:showAsAction="never"
android:title="@string/action_settings"/>

<item
android:id="@+id/import_csv"
android:icon="@android:drawable/ic_menu_search"
Expand Down
2 changes: 2 additions & 0 deletions res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,7 @@
<string name="settings">Einstellungen</string>
<string name="next_song">Nächstes Lied</string>
<string name="previous_song">Voriges Lied</string>
<string name="font_size_description">Schriftgrösse in dp</string>
<string name="font_size_notes">Schriftgrösse der Notizen [dp]</string>

</resources>
4 changes: 3 additions & 1 deletion res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<string name="notes">Notes</string>
<string name="settings">Settings</string>
<string name="next">Next</string>
<string name="previous">&lt;&lt;</string>
<string name="previous" translatable="false">&lt;&lt;</string>
<string name="import_scv">Import CSV</string>
<string name="saving_data">saving data …</string>
<string name="saved">saved</string>
Expand All @@ -20,5 +20,7 @@
<string name="back_again_to_exit">Press back again to close this app</string>
<string name="next_song">Next song</string>
<string name="previous_song">Previous song</string>
<string name="font_size_notes">Font size of notes [dp]</string>
<string name="font_size_description">Font size in dp</string>

</resources>
32 changes: 32 additions & 0 deletions res/xml/settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ (C) Copyright 2015-2016 by fr3ts0n <[email protected]>
~
~ This program is free software; you can redistribute it and/or
~ modify it under the terms of the GNU General Public License as
~ published by the Free Software Foundation; either version 2 of
~ the License, or (at your option) any later version.
~
~ This program is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~ You should have received a copy of the GNU General Public License
~ along with this program; if not, write to the Free Software
~ Foundation, Inc., 59 Temple Place, Suite 330, Boston,
~ MA 02111-1307 USA
~
-->

<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">

<EditTextPreference
android:key="font_size_notes"
android:defaultValue="24"
android:selectAllOnFocus="true"
android:singleLine="true"
android:title="@string/font_size_notes"
android:inputType="numberDecimal"
android:summary="@string/font_size_description" />

</PreferenceScreen>
41 changes: 39 additions & 2 deletions src/com/fr3ts0n/stagefever/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,33 @@
import android.app.Activity;
import android.app.FragmentManager;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v4.widget.DrawerLayout;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.WindowManager.LayoutParams;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity extends Activity
implements NavigationDrawerFragment.NavigationDrawerCallbacks
implements
NavigationDrawerFragment.NavigationDrawerCallbacks,
SharedPreferences.OnSharedPreferenceChangeListener
{
// activity request responses
private static final int REQUEST_SELECT_FILE = 1;
static final int REQUEST_SELECT_FILE = 1;
static final int REQUEST_SETTINGS = 2;

static final String SETTINGS_FONT_SIZE = "font_size_notes";

/**
* app preferences ...
*/
static SharedPreferences prefs;
/** Timeout for exiting via BACK key */
private static final int EXIT_TIMEOUT = 2500;
/** last time of back key pressed */
Expand Down Expand Up @@ -86,6 +99,13 @@ protected void onCreate(Bundle savedInstanceState)

songItemFragment.setSongs(songs);
mNavigationDrawerFragment.setAdapter(songs);

// get preferences
prefs = PreferenceManager.getDefaultSharedPreferences(this);
// register for later changes
prefs.registerOnSharedPreferenceChangeListener(this);
// set values from shared preferences
onSharedPreferenceChanged(prefs, null);
}

@Override
Expand Down Expand Up @@ -137,6 +157,9 @@ public boolean onOptionsItemSelected(MenuItem item)
break;

case R.id.action_settings:
// Launch the BtDeviceListActivity to see devices and do scan
Intent settingsIntent = new Intent(this, SettingsActivity.class);
startActivityForResult(settingsIntent, REQUEST_SETTINGS);
return true;
}
return super.onOptionsItemSelected(item);
Expand Down Expand Up @@ -208,4 +231,18 @@ public void onBackPressed()
super.onBackPressed();
}
}

@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key)
{
// Font size of notes?
if (key==null || SETTINGS_FONT_SIZE.equals(key))
{
if(songItemFragment.tvNotes != null)
{
songItemFragment.tvNotes.setTextSize(
Float.valueOf(sharedPreferences.getString(SETTINGS_FONT_SIZE, "30")));
}
}
}
}
84 changes: 84 additions & 0 deletions src/com/fr3ts0n/stagefever/SettingsActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/*
* (C) Copyright 2015-2016 by fr3ts0n <[email protected]>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*/

package com.fr3ts0n.stagefever;

import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.EditTextPreference;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.preference.PreferenceFragment;
import android.preference.PreferenceManager;

public class SettingsActivity
extends PreferenceActivity
{
/**
* app preferences
*/
static SharedPreferences prefs;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
prefs = PreferenceManager.getDefaultSharedPreferences(this);
// Display the fragment as the main content.
getFragmentManager().beginTransaction()
.replace(android.R.id.content, new PrefsFragment())
.commit();
}


public static class PrefsFragment
extends PreferenceFragment
implements SharedPreferences.OnSharedPreferenceChangeListener
{
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.settings);
// add handler for selection update
prefs.registerOnSharedPreferenceChangeListener(this);
}

void setValueAsSummary(Preference pref)
{
if (pref instanceof ListPreference)
{
ListPreference currPref = (ListPreference) pref;
currPref.setSummary(currPref.getValue());
}
else
if (pref instanceof EditTextPreference)
{
EditTextPreference currPref = (EditTextPreference) pref;
currPref.setSummary(currPref.getText());
}
}

@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key)
{
Preference pref = findPreference(key);
setValueAsSummary(pref);
}
}
}
Loading

0 comments on commit e8b8ee7

Please sign in to comment.