Skip to content
This repository has been archived by the owner on Nov 18, 2021. It is now read-only.

Commit

Permalink
Updated to API 17. Fixed minor issues
Browse files Browse the repository at this point in the history
  • Loading branch information
agargenta committed May 21, 2013
1 parent c3b5d3b commit 3868fef
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 163 deletions.
1 change: 1 addition & 0 deletions .classpath
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
<classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# generated files
bin/
gen/
obj/

# Local configuration file (sdk path, etc)
local.properties
5 changes: 4 additions & 1 deletion AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk android:minSdkVersion="15" />
<uses-sdk
android:minSdkVersion="17"
android:targetSdkVersion="17" />

<application
android:allowBackup="false"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
Expand Down
25 changes: 0 additions & 25 deletions jni/Android-v1.mk

This file was deleted.

2 changes: 1 addition & 1 deletion jni/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ include $(CLEAR_VARS)

# List all of our C/C++ files to be compiled (header file
# dependencies are automatically computed)
LOCAL_SRC_FILES := com_marakana_android_fibonaccinative_FibLib.cpp
LOCAL_SRC_FILES := com_marakana_android_fibonaccinative_FibLib.c

# The name of our shared module (this name will be prepended
# by lib and postfixed by .so)
Expand Down
49 changes: 0 additions & 49 deletions jni/com_marakana_android_fibonaccinative_FibLib.cpp

This file was deleted.

2 changes: 1 addition & 1 deletion project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt

# Project target.
target=android-15
target=android-17
102 changes: 28 additions & 74 deletions res/layout/main.xml
Original file line number Diff line number Diff line change
@@ -1,77 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<!-- This is just a simple title ("Get Your Fibonacci Here!") -->
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/hello"
android:textSize="25sp" />

<!-- This is the entry box for our number "n" -->
<EditText
android:id="@+id/input"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:gravity="right"
android:inputType="number" >
<requestFocus />
</EditText>

<!-- This radio group allows the user to select the fibonacci implementation type -->
<RadioGroup
android:id="@+id/type"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >

<RadioButton
android:id="@+id/type_fib_jr"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/fibJR" />

<RadioButton
android:id="@+id/type_fib_ji"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/fibJI" />

<RadioButton
android:id="@+id/type_fib_nr"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/fibNR" />

<RadioButton
android:id="@+id/type_fib_ni"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/fibNI" />
</RadioGroup>

<!-- This button allows the user to trigger fibonacci calculation -->
<Button
android:id="@+id/button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/button" />

<!-- This is the output area for the fibonacci result -->
<TextView
android:id="@+id/output"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:textSize="20sp" />

android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView android:text="@string/hello" android:layout_height="wrap_content"
android:layout_width="fill_parent" android:textSize="25sp" android:gravity="center"/>
<EditText android:layout_height="wrap_content"
android:layout_width="match_parent" android:id="@+id/input"
android:hint="@string/input_hint" android:inputType="number"
android:gravity="right" />
<RadioGroup android:orientation="horizontal"
android:layout_width="match_parent" android:id="@+id/type"
android:layout_height="wrap_content">
<RadioButton android:layout_height="wrap_content"
android:checked="true" android:id="@+id/type_fib_jr" android:text="@string/type_fib_jr"
android:layout_width="match_parent" android:layout_weight="1" />
<RadioButton android:layout_height="wrap_content"
android:id="@+id/type_fib_ji" android:text="@string/type_fib_ji"
android:layout_width="match_parent" android:layout_weight="1" />
<RadioButton android:layout_height="wrap_content"
android:id="@+id/type_fib_nr" android:text="@string/type_fib_nr"
android:layout_width="match_parent" android:layout_weight="1" />
<RadioButton android:layout_height="wrap_content"
android:id="@+id/type_fib_ni" android:text="@string/type_fib_ni"
android:layout_width="match_parent" android:layout_weight="1" />
</RadioGroup>
<Button android:text="@string/button_text" android:id="@+id/button"
android:layout_width="match_parent" android:layout_height="wrap_content" />
<TextView android:id="@+id/output" android:layout_width="match_parent"
android:layout_height="match_parent" android:textSize="20sp" android:gravity="center|top"/>
</LinearLayout>
22 changes: 12 additions & 10 deletions res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<string name="hello">Get Your Fibonacci Numbers Here!</string>
<string name="fibJR">fibJR</string>
<string name="fibJI">fibJI</string>
<string name="fibNR">fibNR</string>
<string name="fibNI">fibNI</string>
<string name="app_name">FibonacciNative</string>
<string name="button">Get Fibonacci Result</string>

</resources>
<string name="hello">Get Your Fibonacci Here!</string>
<string name="app_name">Fibonacci Client</string>
<string name="input_hint">Enter N</string>
<string name="input_error">Numbers only!</string>
<string name="button_text">Get Fib Result</string>
<string name="progress_text">Calculating…</string>
<string name="fib_error">Failed to get Fibonacci result</string>
<string name="type_fib_jr">fibJR</string>
<string name="type_fib_ji">fibJI</string>
<string name="type_fib_nr">fibNR</string>
<string name="type_fib_ni">fibNI</string>
</resources>
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.marakana.android.fibonaccinative;

import java.util.Locale;

import android.app.Activity;
import android.app.ProgressDialog;
import android.os.AsyncTask;
Expand Down Expand Up @@ -37,10 +39,10 @@ public void onClick(View view) {
if (TextUtils.isEmpty(s)) {
return;
}

final ProgressDialog dialog = ProgressDialog.show(this, "",
"Calculating...", true);
final long n = Long.parseLong(s);
final Locale locale = super.getResources().getConfiguration().locale;
new AsyncTask<Void, Void, String>() {

@Override
Expand All @@ -62,7 +64,8 @@ protected String doInBackground(Void... params) {
break;
}
t = SystemClock.uptimeMillis() - t;
return String.format("fib(%d)=%d in %d ms", n, result, t);
return String.format(locale, "fib(%d)=%d in %d ms", n, result,
t);
}

@Override
Expand Down

0 comments on commit 3868fef

Please sign in to comment.