1. Download our Official Android App: Forums for Android!

[Testers needed]: Runner's app

Discussion in 'Android Lounge' started by android1112, Jul 25, 2011.

  1. android1112

    android1112 Lurker
    Thread Starter
    Rank:
    None
    Points:
    26
    Posts:
    6
    Joined:
    Jul 25, 2011

    Jul 25, 2011
    6
    1
    26
    Product Design Engr
    Hi guys,

    I am new to Android development and made a simple application for runners. As a simple description, it is an application to calculate for one's average pace given his time and distance in a race. Simple as that. Although I'm planning for additional features in the future such as storing all races in a database.

    I am not sure how it would look like on different phones of different sizes. I might have problems in layout.

    You may download it here.

    I would love to hear comments/suggestions from you guys about my simple work.

    Thanks.

    Francis
     

    Advertisement

  2. scary alien

    scary alien not really so scary
    Moderator
    Rank:
     #9
    Points:
    2,138
    Posts:
    22,269
    Joined:
    Mar 5, 2010

    Mar 5, 2010
    22,269
    23,508
    2,138
    Male
    space alien ;)
    Indy
    Francis,

    Very clean, simple app. Great job!

    My days of running for distance are long behind me (I still play a little soccer on the weekends, though ;)).

    Everything worked just fine. Nice interface. Good color choices.

    I know this isn't an app to use while you run, but I wonder if there are apps that make use the phone's built-in accelerometer to count paces? Just an idea...

    Cheers and good job!
     
    android1112 likes this.
  3. scary alien

    scary alien not really so scary
    Moderator
    Rank:
     #9
    Points:
    2,138
    Posts:
    22,269
    Joined:
    Mar 5, 2010

    Mar 5, 2010
    22,269
    23,508
    2,138
    Male
    space alien ;)
    Indy
    By the way, you could jazz-up your time fields by using a TimePreference.

    Its been a while since I've coded one into my app, but I think I started with this web site:

    Android Time Picker Preference | Ebessette.com

    and I also used some information from here:

    Android Preferences | Kaloer.com

    Here's the TimePreference.class file that I ended-up with:

    Code (Text):
    1. import android.content.Context;
    2. import android.content.res.TypedArray;
    3. import android.preference.DialogPreference;
    4. import android.util.AttributeSet;
    5. import android.view.View;
    6. import android.widget.TimePicker;
    7.  
    8. public class TimePreference extends DialogPreference {
    9.     private int lastHour = 0;
    10.     private int lastMinute = 0;
    11.     private TimePicker picker = null;
    12.  
    13.     public static int getHour(String time) {
    14.         String[] pieces=time.split(":");
    15.         Common.myLog (BattMonXService.LOG_VERBOSE, "TimePreference: getHour() returning: " + pieces[0]);
    16.  
    17.         return(Integer.parseInt(pieces[0]));
    18.     }
    19.  
    20.     public static int getMinute(String time) {
    21.         String[] pieces=time.split(":");
    22.         Common.myLog (BattMonXService.LOG_VERBOSE, "TimePreference: getMinute() returning: " + pieces[1]);
    23.  
    24.         return(Integer.parseInt(pieces[1]));
    25.     }
    26.  
    27.     public TimePreference(Context ctxt) {
    28.         this(ctxt, null);
    29.     }
    30.  
    31.     public TimePreference(Context ctxt, AttributeSet attrs) {
    32.         this(ctxt, attrs, 0);
    33.     }
    34.  
    35.     public TimePreference(Context ctxt, AttributeSet attrs, int defStyle) {
    36.         super(ctxt, attrs, defStyle);
    37.  
    38.         setPositiveButtonText("Set");
    39.         setNegativeButtonText("Cancel");
    40.     }
    41.  
    42.     @Override
    43.     protected View onCreateDialogView() {
    44.         picker=new TimePicker(getContext());
    45.  
    46.         return(picker);
    47.     }
    48.  
    49.     @Override
    50.     protected void onBindDialogView(View v) {
    51.         super.onBindDialogView(v);
    52.  
    53.         picker.setCurrentHour(lastHour);
    54.         picker.setCurrentMinute(lastMinute);
    55.     }
    56.  
    57.     @Override
    58.     protected void onDialogClosed(boolean positiveResult) {
    59.         super.onDialogClosed(positiveResult);
    60.  
    61.         if (positiveResult) {
    62.             lastHour  = picker.getCurrentHour();
    63.             lastMinute= picker.getCurrentMinute();
    64.             String time = null;
    65.  
    66.             if ( lastMinute < 10 )
    67.              time=String.valueOf(lastHour)+":0"+String.valueOf(lastMinute);
    68.             else
    69.              time=String.valueOf(lastHour)+":"+String.valueOf(lastMinute);
    70.                
    71.             setSummary("Selected time: " + time);
    72.            
    73.             if (callChangeListener(time)) {
    74.                 persistString(time);
    75.             }
    76.         }
    77.     }
    78.  
    79.     @Override
    80.     protected Object onGetDefaultValue(TypedArray a, int index) {
    81.         return(a.getString(index));
    82.     }
    83.  
    84.     @Override
    85.     protected void onSetInitialValue(boolean restoreValue, Object defaultValue) {
    86.         String time=null;
    87.  
    88.         if (restoreValue) {
    89.             if (defaultValue==null) {
    90.                 time=getPersistedString("00:00");
    91.             }
    92.             else {
    93.                 time=getPersistedString(defaultValue.toString());
    94.             }
    95.         }
    96.         else {
    97.             time=defaultValue.toString();
    98.         }
    99.  
    100.         lastHour=getHour(time);
    101.         lastMinute=getMinute(time);
    102.     }
    103. }
    and here is one of the set of entries in my preferences.xml file:

    Code (Text):
    1.                   <sa.battmonx.TimePreference
    2.                         android:key="startTimeOne"
    3.                         android:defaultValue="00:00"
    4.                         android:title="Start Time One"
    5.                         android:summary="Select an starting monitoring time" />
    6.                        
    7.                   <sa.battmonx.TimePreference
    8.                         android:key="endTimeOne"
    9.                         android:defaultValue="23:59"
    10.                         android:title="End Time One"
    11.                         android:summary="Select an ending monitoring time" />
    Like I said, its been a while since I've coded the above, but I'm sure you'll be able to do something in your app, too, should you decide to.

    Cheers and good luck!
     
  4. android1112

    android1112 Lurker
    Thread Starter
    Rank:
    None
    Points:
    26
    Posts:
    6
    Joined:
    Jul 25, 2011

    Jul 25, 2011
    6
    1
    26
    Product Design Engr
    Thanks! I appreciate your comments.

    Yes, indeed, this not an app while you run. It is an after-run app.:)

    Good idea about counting paces. I've seen some apps doing that but with the use of GPS(I don't have experience in developing here yet). And you could use that while running.

    What I intend to do here in the future is to make it a race/training log. You input your data, pace is computed then stored to a database. If data network is not available, it is stored in phone's database. If data network is available, you can sync it to a website. (Still too much work ahead, though). It will give a runner an overview for his training and races.

    If my studying path is correct, I should be learning SQLite to do the database storage on the phone. Am I correct?
     
  5. scary alien

    scary alien not really so scary
    Moderator
    Rank:
     #9
    Points:
    2,138
    Posts:
    22,269
    Joined:
    Mar 5, 2010

    Mar 5, 2010
    22,269
    23,508
    2,138
    Male
    space alien ;)
    Indy
    No problem -- glad to help and just wanted to throw an idea out there (re. the accellerometer thing) ;).

    Yeah, that sounds right to me re. the SQLite DB path...there's just so much to learn and do, I haven't delved into that area myself yet.

    You've taken the most important step, though, just building and app and putting it out there for review.

    Cheers and I wish you continued good luck and success!
     

Share This Page

Loading...