Initial commit.
1
app/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
/build
|
92
app/app.iml
Normal file
|
@ -0,0 +1,92 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module external.linked.project.id=":app" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="EllipticalSteps&Miles" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
|
||||
<component name="FacetManager">
|
||||
<facet type="android-gradle" name="Android-Gradle">
|
||||
<configuration>
|
||||
<option name="GRADLE_PROJECT_PATH" value=":app" />
|
||||
</configuration>
|
||||
</facet>
|
||||
<facet type="android" name="Android">
|
||||
<configuration>
|
||||
<option name="SELECTED_BUILD_VARIANT" value="debug" />
|
||||
<option name="SELECTED_TEST_ARTIFACT" value="_android_test_" />
|
||||
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
|
||||
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
|
||||
<option name="ASSEMBLE_TEST_TASK_NAME" value="assembleDebugAndroidTest" />
|
||||
<option name="COMPILE_JAVA_TEST_TASK_NAME" value="compileDebugAndroidTestSources" />
|
||||
<afterSyncTasks>
|
||||
<task>generateDebugAndroidTestSources</task>
|
||||
<task>generateDebugSources</task>
|
||||
</afterSyncTasks>
|
||||
<option name="ALLOW_USER_CONFIGURATION" value="false" />
|
||||
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
|
||||
<option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
|
||||
<option name="RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/src/main/res" />
|
||||
<option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets" />
|
||||
</configuration>
|
||||
</facet>
|
||||
</component>
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="false">
|
||||
<output url="file://$MODULE_DIR$/build/intermediates/classes/debug" />
|
||||
<output-test url="file://$MODULE_DIR$/build/intermediates/classes/androidTest/debug" />
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/debug" isTestSource="false" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/debug" isTestSource="false" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/debug" isTestSource="false" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/generated/debug" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/androidTest/debug" isTestSource="true" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/androidTest/debug" isTestSource="true" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/debug" isTestSource="true" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/androidTest/debug" isTestSource="true" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/androidTest/debug" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/generated/androidTest/debug" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/aidl" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/java" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/jni" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/rs" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/res" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/assets" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/aidl" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/coverage-instrumented-classes" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex-cache" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jacoco" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaResources" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/libs" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/lint" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/ndk" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/proguard" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
|
||||
</content>
|
||||
<orderEntry type="jdk" jdkName="Android API 22 Platform" jdkType="Android SDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
24
app/build.gradle
Normal file
|
@ -0,0 +1,24 @@
|
|||
apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
compileSdkVersion 22
|
||||
buildToolsVersion "23.0.1"
|
||||
|
||||
defaultConfig {
|
||||
applicationId "net.thauvin.erik.android.ellipticalstepsmiles"
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 22
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile fileTree(dir: 'libs', include: ['*.jar'])
|
||||
}
|
17
app/proguard-rules.pro
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
# Add project specific ProGuard rules here.
|
||||
# By default, the flags in this file are appended to flags specified
|
||||
# in C:\Users\erik\AppData\Local\Android\android-sdk/tools/proguard/proguard-android.txt
|
||||
# You can edit the include path and order by changing the proguardFiles
|
||||
# directive in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# Add any project specific keep options here:
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
22
app/src/main/AndroidManifest.xml
Normal file
|
@ -0,0 +1,22 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest package="net.thauvin.erik.android.ellipticalstepsmiles"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/AppTheme">
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:label="@string/app_name"
|
||||
android:screenOrientation="portrait">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
|
@ -0,0 +1,375 @@
|
|||
package net.thauvin.erik.android.ellipticalstepsmiles;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.text.Editable;
|
||||
import android.text.Html;
|
||||
import android.text.TextWatcher;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
|
||||
public class MainActivity extends Activity
|
||||
{
|
||||
|
||||
private final String defaultValue = "0";
|
||||
private final int defaultStrideValue = 20;
|
||||
|
||||
private SharedPreferences prefs;
|
||||
|
||||
/**
|
||||
* Validates a string.
|
||||
*
|
||||
* @param s The string to validate.
|
||||
* @return returns <code>true</code> if the string is not empty or null, <code>false</code> otherwise.
|
||||
*/
|
||||
public static boolean isValid(String s)
|
||||
{
|
||||
return (s != null) && (!s.trim().isEmpty());
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds OnTouchListener for clear buttons.
|
||||
*
|
||||
* @param field The EditText field.
|
||||
* @return A new OnTouchListener.
|
||||
*/
|
||||
private View.OnTouchListener buildOnTouchListener(final EditText field, final Drawable img)
|
||||
{
|
||||
return new View.OnTouchListener()
|
||||
{
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event)
|
||||
{
|
||||
// Is there an X showing?
|
||||
if (field.getCompoundDrawables()[2] == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Only do this for up touches
|
||||
if (event.getAction() != MotionEvent.ACTION_UP)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Is touch one of our clear buttons?
|
||||
if (event.getX() > field.getWidth() - field.getPaddingRight() - img.getIntrinsicWidth())
|
||||
{
|
||||
field.requestFocusFromTouch();
|
||||
field.setText("");
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy value to clipboard, if valid.
|
||||
*
|
||||
* @param label The label string.
|
||||
* @param value The value string.
|
||||
*/
|
||||
private void copyToClipboard(CharSequence label, String value)
|
||||
{
|
||||
if (isValid(value) && !defaultValue.equals(value))
|
||||
{
|
||||
final ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
|
||||
final ClipData clip = ClipData.newPlainText(label, value);
|
||||
clipboard.setPrimaryClip(clip);
|
||||
|
||||
Toast.makeText(getApplicationContext(), getString(R.string.toast_copied, label), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of the specified shared reference based on the specified string id.
|
||||
*
|
||||
* @param id The string id.
|
||||
* @param defaultValue The default value, used if the preference is empty.
|
||||
* @return The preference value.
|
||||
*/
|
||||
private String getPref(int id, String defaultValue)
|
||||
{
|
||||
return prefs.getString(getString(id), defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current version number.
|
||||
*
|
||||
* @return The current version number or empty.
|
||||
*/
|
||||
private String getVersionNumber()
|
||||
{
|
||||
try
|
||||
{
|
||||
return getPackageManager().getPackageInfo(getPackageName(), 0).versionName;
|
||||
}
|
||||
catch (final PackageManager.NameNotFoundException e)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the various variables.
|
||||
*/
|
||||
private void init()
|
||||
{
|
||||
final EditText revolutions = (EditText) findViewById(R.id.revolutions);
|
||||
revolutions.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
||||
|
||||
final TextView steps = (TextView) findViewById(R.id.steps);
|
||||
final TextView miles = (TextView) findViewById(R.id.miles);
|
||||
|
||||
prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
|
||||
revolutions.setText(getPref(R.string.prefs_revolutions, ""));
|
||||
steps.setText(getPref(R.string.prefs_steps, defaultValue));
|
||||
miles.setText(getPref(R.string.prefs_miles, defaultValue));
|
||||
|
||||
final Drawable imgX = getResources().getDrawable(R.drawable.x, getTheme());
|
||||
|
||||
revolutions.setOnEditorActionListener(
|
||||
new TextView.OnEditorActionListener()
|
||||
{
|
||||
@Override
|
||||
public boolean onEditorAction(TextView v, int actionId, KeyEvent event)
|
||||
{
|
||||
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE ||
|
||||
event.getAction() == KeyEvent.ACTION_DOWN && event.getKeyCode() == KeyEvent.KEYCODE_ENTER)
|
||||
{
|
||||
if (event == null || !event.isShiftPressed())
|
||||
{
|
||||
final String totalRevs = revolutions.getText().toString();
|
||||
if (isValid(totalRevs))
|
||||
{
|
||||
final int revs = Integer.parseInt(totalRevs);
|
||||
if (revs >= 0)
|
||||
{
|
||||
final int strideLength = prefs.getInt(getString(R.string.prefs_stride_length), defaultStrideValue);
|
||||
final String totalSteps = String.valueOf(revs * 2);
|
||||
final String totalMiles = String.format("%.2f", (revs * 2) / (63360.0 / strideLength));
|
||||
|
||||
steps.setText(totalSteps);
|
||||
miles.setText(totalMiles);
|
||||
|
||||
final InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
imm.hideSoftInputFromWindow(revolutions.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
|
||||
|
||||
savePrefs(strideLength, totalRevs, totalSteps, totalMiles);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
final TextWatcher tw = new TextWatcher()
|
||||
{
|
||||
@Override
|
||||
public void afterTextChanged(Editable s)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count)
|
||||
{
|
||||
manageClearButton(revolutions, imgX);
|
||||
|
||||
if ("".equals(revolutions.getText().toString()))
|
||||
{
|
||||
steps.setText(defaultValue);
|
||||
miles.setText(defaultValue);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
revolutions.addTextChangedListener(tw);
|
||||
revolutions.setOnTouchListener(buildOnTouchListener(revolutions, imgX));
|
||||
|
||||
|
||||
steps.setOnClickListener(new View.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(View v)
|
||||
{
|
||||
copyToClipboard(getString(R.string.steps_label), steps.getText().toString());
|
||||
}
|
||||
});
|
||||
|
||||
miles.setOnClickListener(new View.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(View v)
|
||||
{
|
||||
copyToClipboard(getString(R.string.miles_label), miles.getText().toString());
|
||||
}
|
||||
});
|
||||
|
||||
manageClearButton(revolutions, imgX);
|
||||
}
|
||||
|
||||
/**
|
||||
* Manages the clear button.
|
||||
*
|
||||
* @param view The text view.
|
||||
* @param img The image.
|
||||
*/
|
||||
private void manageClearButton(TextView view, Drawable img)
|
||||
{
|
||||
if (view.getText().toString().equals(""))
|
||||
{
|
||||
view.setCompoundDrawablesWithIntrinsicBounds(view.getCompoundDrawables()[0], view.getCompoundDrawables()[1], null,
|
||||
view.getCompoundDrawables()[3]);
|
||||
}
|
||||
else
|
||||
{
|
||||
view.setCompoundDrawablesWithIntrinsicBounds(view.getCompoundDrawables()[0], view.getCompoundDrawables()[1], img,
|
||||
view.getCompoundDrawables()[3]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState)
|
||||
{
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
init();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu)
|
||||
{
|
||||
// Inflate the menu; this adds items to the action bar if it is present.
|
||||
getMenuInflater().inflate(R.menu.menu_main, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item)
|
||||
{
|
||||
// Handle action bar item clicks here. The action bar will
|
||||
// automatically handle clicks on the Home/Up button, so long
|
||||
// as you specify a parent activity in AndroidManifest.xml.
|
||||
int id = item.getItemId();
|
||||
|
||||
if (id == R.id.action_stride)
|
||||
{
|
||||
final AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
builder.setTitle(R.string.action_stride);
|
||||
|
||||
final int stride = prefs.getInt(getString(R.string.prefs_stride_length), defaultStrideValue);
|
||||
|
||||
final String unit = getString(R.string.stride_unit);
|
||||
final int[] strideLength = getResources().getIntArray(R.array.stride_lengths);
|
||||
final String[] items = new String[strideLength.length];
|
||||
|
||||
int strideIndex = 0;
|
||||
for (int i = 0; i < items.length; i++)
|
||||
{
|
||||
if (strideLength[i] == stride)
|
||||
{
|
||||
strideIndex = i;
|
||||
}
|
||||
items[i] = String.valueOf(strideLength[i]) + unit;
|
||||
}
|
||||
|
||||
builder.setSingleChoiceItems(items, strideIndex, new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int which)
|
||||
{
|
||||
savePrefs(strideLength[which], "", defaultValue, defaultValue);
|
||||
final EditText revolutions = (EditText) findViewById(R.id.revolutions);
|
||||
revolutions.setText("");
|
||||
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which)
|
||||
{
|
||||
dialog.cancel();
|
||||
}
|
||||
});
|
||||
|
||||
builder.show();
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (id == R.id.action_about)
|
||||
{
|
||||
final AlertDialog builder = new AlertDialog.Builder(this)
|
||||
.setTitle(R.string.app_name)
|
||||
.setMessage(Html.fromHtml(String.format(getString(R.string.about_message), getVersionNumber())))
|
||||
.setIcon(R.mipmap.ic_launcher)
|
||||
.setPositiveButton(android.R.string.ok,
|
||||
new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int whichButton)
|
||||
{
|
||||
dialog.dismiss();
|
||||
}
|
||||
})
|
||||
.show();
|
||||
((TextView) builder.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Saves the preferences.
|
||||
*
|
||||
* @param strideLength The stride length.
|
||||
* @param revolutions The revolutions count.
|
||||
* @param steps The steps count.
|
||||
* @param miles The miles count.
|
||||
*/
|
||||
private void savePrefs(int strideLength, String revolutions, String steps, String miles)
|
||||
{
|
||||
final SharedPreferences.Editor editor = prefs.edit();
|
||||
editor.putInt(getString(R.string.prefs_stride_length), strideLength);
|
||||
editor.putString(getString(R.string.prefs_revolutions), revolutions);
|
||||
editor.putString(getString(R.string.prefs_steps), steps);
|
||||
editor.putString(getString(R.string.prefs_miles), miles);
|
||||
editor.apply();
|
||||
}
|
||||
}
|
BIN
app/src/main/res/drawable-hdpi/Thumbs.db
Normal file
BIN
app/src/main/res/drawable-hdpi/x.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
app/src/main/res/drawable-xhdpi/Thumbs.db
Normal file
BIN
app/src/main/res/drawable-xhdpi/x.png
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
app/src/main/res/drawable-xxhdpi/x.png
Normal file
After Width: | Height: | Size: 3.2 KiB |
BIN
app/src/main/res/drawable-xxxhdpi/Thumbs.db
Normal file
BIN
app/src/main/res/drawable-xxxhdpi/x.png
Normal file
After Width: | Height: | Size: 4.8 KiB |
BIN
app/src/main/res/drawable/Thumbs.db
Normal file
BIN
app/src/main/res/drawable/x.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
89
app/src/main/res/layout/activity_main.xml
Normal file
|
@ -0,0 +1,89 @@
|
|||
<RelativeLayout android:id="@+id/activity_main"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||
android:paddingTop="@dimen/activity_vertical_margin"
|
||||
tools:context=".MainActivity">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/revolutions"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:elegantTextHeight="false"
|
||||
android:ems="10"
|
||||
android:enabled="true"
|
||||
android:focusable="true"
|
||||
android:gravity="right"
|
||||
android:inputType="number"
|
||||
android:maxLength="5"
|
||||
android:textSize="85.0sp"
|
||||
android:digits="1234567890"
|
||||
android:clickable="false"
|
||||
android:hint="--"
|
||||
android:cursorVisible="false"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:text="@string/revolutions_label"
|
||||
android:textSize="15.0sp"
|
||||
android:layout_below="@+id/revolutions"
|
||||
android:layout_alignEnd="@+id/revolutions"
|
||||
android:paddingRight="4dp" />
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_below="@+id/textView"
|
||||
android:layout_alignParentStart="true"
|
||||
android:id="@+id/linearLayout">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="0"
|
||||
android:id="@+id/steps"
|
||||
android:textSize="85.0sp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:textIsSelectable="false"
|
||||
android:clickable="true" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:text="@string/steps_label"
|
||||
android:id="@+id/textView2"
|
||||
android:layout_gravity="center_horizontal" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="0"
|
||||
android:id="@+id/miles"
|
||||
android:textSize="85.0sp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:textIsSelectable="false"
|
||||
android:clickable="true" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:text="@string/miles_label"
|
||||
android:id="@+id/textView3"
|
||||
android:layout_gravity="center_horizontal" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</RelativeLayout>
|
7
app/src/main/res/menu/menu_main.xml
Normal file
|
@ -0,0 +1,7 @@
|
|||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools" tools:context=".MainActivity">
|
||||
<item android:id="@+id/action_stride" android:title="@string/action_stride"
|
||||
android:orderInCategory="100" android:showAsAction="never" />
|
||||
<item android:id="@+id/action_about" android:title="@string/action_about"
|
||||
android:orderInCategory="101" android:showAsAction="never" />
|
||||
</menu>
|
BIN
app/src/main/res/mipmap-hdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 7 KiB |
BIN
app/src/main/res/mipmap-mdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 3.7 KiB |
BIN
app/src/main/res/mipmap-xhdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 12 KiB |
BIN
app/src/main/res/mipmap-xxhdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 23 KiB |
BIN
app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 37 KiB |
5
app/src/main/res/values-v21/styles.xml
Normal file
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<style name="AppTheme" parent="android:Theme.Material.Light">
|
||||
</style>
|
||||
</resources>
|
6
app/src/main/res/values-w820dp/dimens.xml
Normal file
|
@ -0,0 +1,6 @@
|
|||
<resources>
|
||||
<!-- Example customization of dimensions originally defined in res/values/dimens.xml
|
||||
(such as screen margins) for screens with more than 820dp of available width. This
|
||||
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
|
||||
<dimen name="activity_horizontal_margin">64dp</dimen>
|
||||
</resources>
|
5
app/src/main/res/values/dimens.xml
Normal file
|
@ -0,0 +1,5 @@
|
|||
<resources>
|
||||
<!-- Default screen margins, per the Android Design guidelines. -->
|
||||
<dimen name="activity_horizontal_margin">16dp</dimen>
|
||||
<dimen name="activity_vertical_margin">16dp</dimen>
|
||||
</resources>
|
24
app/src/main/res/values/strings.xml
Normal file
|
@ -0,0 +1,24 @@
|
|||
<resources>
|
||||
<string name="app_name">Elliptical Steps & Miles</string>
|
||||
|
||||
<string name="about_message"><p><b>Version %1$s</b></p><p>Developed by <a href=\"http://erik.thauvin.net/\"><b>Erik C. Thauvin</b></a>. See all my apps <a href=\"http://mobile.thauvin.net/android/\"><b>here</b></a>.</p>Inspired by this <a href=\"http://www.livestrong.com/article/304211-how-to-convert-elliptical-strides-to-miles/\"><b>article</b></a>.</string>
|
||||
<string name="action_about">About</string>
|
||||
<string name="action_stride">Set stride length</string>
|
||||
<string name="miles_label">Miles</string>
|
||||
<string name="prefs_miles">mi</string>
|
||||
<string name="prefs_revolutions">revs</string>
|
||||
<string name="prefs_steps">steps</string>
|
||||
<string name="prefs_stride_length">stride</string>
|
||||
<string name="revolutions_label">Revolutions</string>
|
||||
<string name="steps_label">Steps</string>
|
||||
<integer-array name="stride_lengths">
|
||||
<item>14</item>
|
||||
<item>16</item>
|
||||
<item>18</item>
|
||||
<item>20</item>
|
||||
<item>21</item>
|
||||
<item>22</item>
|
||||
</integer-array>
|
||||
<string name="stride_unit">\"</string>
|
||||
<string name="toast_copied">%1$s copied</string>
|
||||
</resources>
|
8
app/src/main/res/values/styles.xml
Normal file
|
@ -0,0 +1,8 @@
|
|||
<resources>
|
||||
|
||||
<!-- Base application theme. -->
|
||||
<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
|
||||
<!-- Customize your theme here. -->
|
||||
</style>
|
||||
|
||||
</resources>
|