diff --git a/Timer/.classpath b/Timer/.classpath index f63eddd..bf91232 100644 --- a/Timer/.classpath +++ b/Timer/.classpath @@ -6,6 +6,6 @@ - + diff --git a/Timer/AndroidManifest.xml b/Timer/AndroidManifest.xml index 13159f8..58b25bd 100644 --- a/Timer/AndroidManifest.xml +++ b/Timer/AndroidManifest.xml @@ -1,15 +1,14 @@ + android:versionCode="8" + android:versionName="1.4" > + android:targetSdkVersion="19" /> - + + + + + + + diff --git a/Timer/res/layout/countdown_simplified.xml b/Timer/res/layout/countdown_simplified.xml index 67aaa67..399b647 100644 --- a/Timer/res/layout/countdown_simplified.xml +++ b/Timer/res/layout/countdown_simplified.xml @@ -73,7 +73,7 @@ + android:text="@string/countdown_start" /> \ No newline at end of file diff --git a/Timer/res/layout/stopwatch.xml b/Timer/res/layout/stopwatch.xml index d419556..275b7bb 100644 --- a/Timer/res/layout/stopwatch.xml +++ b/Timer/res/layout/stopwatch.xml @@ -66,7 +66,7 @@ android:layout_width="0dip" android:layout_height="wrap_content" android:layout_weight="1" - android:text="Start" /> + android:text="@string/stopwatch_start" /> + android:text="@string/stopwatch_reset" /> + android:text="@string/wordclock_plusadd" /> \ No newline at end of file diff --git a/Timer/res/values-it/strings.xml b/Timer/res/values-it/strings.xml new file mode 100644 index 0000000..ffd7c1a --- /dev/null +++ b/Timer/res/values-it/strings.xml @@ -0,0 +1,42 @@ + + + + Sup World, TimerActivity! + Timer + + + + Incrementa + + Decrementa + + %s clicca e tieni. + + Slide su per incrementare e giù per decrementare. + + StopwatchAutostartActivity + + Versione + Chiudi + + Orologio Mondiale + Cronometro + Timer + About + + + Aggiungi + Seleziona una timezone + Rimuovi + + Avvia + Ferma + Azzera + Giro + + Avvia + Annulla + Alla fine: + Conteggio timer completato + Premi qui per terminare + + \ No newline at end of file diff --git a/Timer/res/values/strings.xml b/Timer/res/values/strings.xml index 39e2dcf..0e2d1fc 100644 --- a/Timer/res/values/strings.xml +++ b/Timer/res/values/strings.xml @@ -16,4 +16,27 @@ StopwatchAutostartActivity + Version + Dismiss + + World Clock + Stopwatch + Countdown + About + + + Add + Select a timezone + Remove + + Start + Stop + Reset + Lap + + Start + Cancel + On finish: + Countdown timer finished + Tap here to dismiss + \ No newline at end of file diff --git a/Timer/src/org/dpadgett/timer/AboutFragment.java b/Timer/src/org/dpadgett/timer/AboutFragment.java new file mode 100644 index 0000000..ed62f88 --- /dev/null +++ b/Timer/src/org/dpadgett/timer/AboutFragment.java @@ -0,0 +1,40 @@ +package org.dpadgett.timer; + +import android.content.pm.PackageManager.NameNotFoundException; +import android.os.Bundle; +import android.support.v4.app.Fragment; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +public class AboutFragment extends Fragment { + + private View rootView; + + /* (non-Javadoc) + * @see android.support.v4.app.Fragment#onCreate(android.os.Bundle) + */ + @Override + public void onCreate(Bundle savedInstanceState) { + // TODO Auto-generated method stub + super.onCreate(savedInstanceState); + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + // Inflate the layout for this fragment + rootView = inflater.inflate(R.layout.about, container, false); + ResourceFinder finder = ResourceFinders.from(rootView); + TextView tv = (TextView)finder.findViewById(R.id.textVersion); + String version = getActivity().getResources().getString(R.string.gen_version)+" "; + try { + version += getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(), 0).versionName; + } catch (NameNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + tv.setText(version); + return rootView; + } +} diff --git a/Timer/src/org/dpadgett/timer/AlarmService.java b/Timer/src/org/dpadgett/timer/AlarmService.java index 84cba9e..057b810 100644 --- a/Timer/src/org/dpadgett/timer/AlarmService.java +++ b/Timer/src/org/dpadgett/timer/AlarmService.java @@ -104,14 +104,14 @@ private void countdownFinished() { NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); int icon = drawable.ic_dialog_info; - String tickerText = "Countdown timer finished"; + String tickerText = context.getResources().getString(R.string.countdown_finished); long when = System.currentTimeMillis(); Notification notification = new Notification(icon, tickerText, when); notification.flags |= Notification.FLAG_AUTO_CANCEL | Notification.FLAG_ONGOING_EVENT; - String contentTitle = "Countdown timer finished"; - String contentText = "Tap here to dismiss"; + String contentTitle = context.getResources().getString(R.string.countdown_finished); + String contentText = context.getResources().getString(R.string.countdown_taptodismiss); Intent notificationIntent = new Intent(context, AlarmService.class) .putExtra("startAlarm", false).putExtra("fromFragment", false) .setAction("internalStopAlarm"); diff --git a/Timer/src/org/dpadgett/timer/CountdownFragment.java b/Timer/src/org/dpadgett/timer/CountdownFragment.java index c283b78..2829abb 100644 --- a/Timer/src/org/dpadgett/timer/CountdownFragment.java +++ b/Timer/src/org/dpadgett/timer/CountdownFragment.java @@ -186,7 +186,7 @@ private void restoreState() { Button startButton = (Button) rootView.findViewById(R.id.startButton); inputs.removeAllViews(); inputs.addView(timerLayout); - startButton.setText("Cancel"); + startButton.setText(getContext().getResources().getString(R.string.countdown_cancel)); // timing thread will auto start itself } } @@ -262,7 +262,7 @@ public void run() { inputs.removeAllViews(); inputs.addView(timerLayout); - startButton.setText("Cancel"); + startButton.setText(getContext().getResources().getString(R.string.countdown_cancel)); AlarmManager alarmMgr = (AlarmManager) getContext().getSystemService(Context.ALARM_SERVICE); // should be unique @@ -295,7 +295,7 @@ public void run() { handler.removeCallbacks(inputModeOn); inputs.removeAllViews(); inputs.addView(inputLayout); - startButton.setText("Start"); + startButton.setText(getContext().getResources().getString(R.string.countdown_start)); timingState.stopTimer(); if (alarmPendingIntent == null) { // should be unique diff --git a/Timer/src/org/dpadgett/timer/LapTimes.java b/Timer/src/org/dpadgett/timer/LapTimes.java index 57c8fe8..3dda1bb 100644 --- a/Timer/src/org/dpadgett/timer/LapTimes.java +++ b/Timer/src/org/dpadgett/timer/LapTimes.java @@ -86,7 +86,7 @@ public void add(long lapTime) { .inflate(R.layout.single_lap_time, (ViewGroup) lapTimesView, false); TextView lapLabel = (TextView) lapLayout.findViewById(R.id.lapLabel); - lapLabel.setText("lap " + (lapTimes.size() + 1)); + lapLabel.setText(context.getResources().getString(R.string.stopwatch_lap)+" "+(lapTimes.size() + 1)); TextView lapTimeView = (TextView) lapLayout.findViewById(R.id.lapTime); lapTimeView.setText(getTimerText(lapTime)); diff --git a/Timer/src/org/dpadgett/timer/StopwatchFragment.java b/Timer/src/org/dpadgett/timer/StopwatchFragment.java index e9b0138..dbcd70d 100644 --- a/Timer/src/org/dpadgett/timer/StopwatchFragment.java +++ b/Timer/src/org/dpadgett/timer/StopwatchFragment.java @@ -19,7 +19,6 @@ import org.dpadgett.compat.LinearLayout; import org.dpadgett.timer.TimerActivity.StartReason; import org.dpadgett.widget.TimerTextView; - import android.content.Context; import android.content.SharedPreferences; import android.graphics.Bitmap; @@ -27,7 +26,6 @@ import android.os.Bundle; import android.os.Handler; import android.support.v4.app.Fragment; -import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.View.MeasureSpec; @@ -73,8 +71,8 @@ public void start() { lapTimeText.resume(); timerText.forceUpdate(timeStarted); lapTimeText.forceUpdate(timeStarted); - startButton.setText("Stop"); - resetButton.setText("Lap"); + startButton.setText(getResources().getString(R.string.stopwatch_stop)); + resetButton.setText(getResources().getString(R.string.stopwatch_lap)); saveState(); } @@ -82,8 +80,8 @@ public void stop() { Button startButton = (Button) rootView.findViewById(R.id.startButton); Button resetButton = (Button) rootView.findViewById(R.id.stopButton); long timeStopped = System.currentTimeMillis(); - startButton.setText("Start"); - resetButton.setText("Reset"); + startButton.setText(getResources().getString(R.string.stopwatch_start)); + resetButton.setText(getResources().getString(R.string.stopwatch_reset)); additionalElapsed += timeStopped - timeStarted; timerText.pause(timeStopped); lapTimeText.pause(timeStopped); @@ -142,7 +140,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, timerText = (TimerTextView) rootView.findViewById(R.id.timerText); lapTimeText = (TimerTextView) rootView.findViewById(R.id.liveLapTime); - lapTimeText.setTextPrefix("lap: "); + lapTimeText.setTextPrefix(getResources().getString(R.string.stopwatch_lap)+": "); lapTimes = new LapTimes((ScrollView) rootView.findViewById(R.id.scrollView1)); @@ -219,8 +217,8 @@ private void restoreState() { if (isTimerRunning) { timerText.resume(); lapTimeText.resume(); - startButton.setText("Stop"); - resetButton.setText("Lap"); + startButton.setText(getResources().getString(R.string.stopwatch_stop)); + resetButton.setText(getResources().getString(R.string.stopwatch_lap)); } timerText.forceUpdate(timeStarted); lapTimeText.forceUpdate(timeStarted); diff --git a/Timer/src/org/dpadgett/timer/TimerActivity.java b/Timer/src/org/dpadgett/timer/TimerActivity.java index 384c859..b214858 100644 --- a/Timer/src/org/dpadgett/timer/TimerActivity.java +++ b/Timer/src/org/dpadgett/timer/TimerActivity.java @@ -26,7 +26,6 @@ import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v4.view.ViewPager; - import com.actionbarsherlock.app.ActionBar; import com.actionbarsherlock.app.SherlockFragmentActivity; @@ -43,25 +42,27 @@ public class TimerActivity extends SherlockFragmentActivity { static final String ACTION_SHOW_DIALOG = "org.dpadgett.timer.CountdownFragment.SHOW_DIALOG"; static final String ACTION_DISMISS_DIALOG = "org.dpadgett.timer.CountdownFragment.DISMISS_DIALOG"; static final String START_REASON = "START_REASON"; + public enum StartReason { START_REASON_AUTOSTART_STOPWATCH, START_REASON_NONE }; private static enum Tab { - WORLD_CLOCK("World Clock", WorldClockFragment.class), - STOPWATCH("Stopwatch", StopwatchFragment.class), - COUNTDOWN("Countdown", CountdownFragment.class); + WORLD_CLOCK(R.string.tab_worldclock, WorldClockFragment.class), + STOPWATCH(R.string.tab_stopwatch, StopwatchFragment.class), + COUNTDOWN(R.string.tab_countdown, CountdownFragment.class), + ABOUT(R.string.tab_about, AboutFragment.class); - private final String title; + private final int title; private final Class clazz; - private Tab(String title, Class clazz) { + private Tab(int title, Class clazz) { this.title = title; this.clazz = clazz; } - private String getTitle() { + private int getTitle() { return title; } @@ -87,13 +88,15 @@ public void onCreate(final Bundle savedInstanceState) { bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); bar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE); bar.setDisplayShowHomeEnabled(false); - + Bundle extras = getIntent().getExtras(); mTabsAdapter = new TabsAdapter(this, mViewPager); for (Tab tab : Tab.values()) { - mTabsAdapter.addTab(bar.newTab().setText(tab.getTitle()), - tab.getFragmentClass(), extras); + mTabsAdapter.addTab(bar.newTab().setText( + getResources().getString(tab.getTitle())), + tab.getFragmentClass(), + extras); } StartReason startReason = StartReason.START_REASON_NONE; @@ -111,8 +114,8 @@ public void onCreate(final Bundle savedInstanceState) { } alarmDialog = new AlertDialog.Builder(this) - .setTitle("Countdown timer finished") - .setPositiveButton("Dismiss", + .setTitle(getResources().getString(R.string.countdown_finished)) + .setPositiveButton(getResources().getString(R.string.gen_dismiss), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { @@ -166,4 +169,5 @@ public void onReceive(Context context, Intent intent) { } } }; + } \ No newline at end of file diff --git a/Timer/src/org/dpadgett/timer/WorldClockFragment.java b/Timer/src/org/dpadgett/timer/WorldClockFragment.java index 61ca8b0..e854bc7 100644 --- a/Timer/src/org/dpadgett/timer/WorldClockFragment.java +++ b/Timer/src/org/dpadgett/timer/WorldClockFragment.java @@ -40,8 +40,8 @@ import android.graphics.drawable.Drawable; import android.os.Bundle; import android.os.Handler; +import android.provider.Settings; import android.support.v4.app.Fragment; -import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.View.MeasureSpec; @@ -139,7 +139,7 @@ public void run() { private void newClockDialog(final int position) { AlertDialog.Builder builder = new AlertDialog.Builder(context); - builder.setTitle("Select a timezone"); + builder.setTitle(context.getResources().getString(R.string.wordclock_selecttimezone)); final Map timezoneNameToId = new HashMap(); Set timezones = new TreeSet(); final Map> offsetToName = new HashMap>(); @@ -164,7 +164,7 @@ private void newClockDialog(final int position) { Collections.sort(names); } if (position > -1) { - builder.setPositiveButton("Remove", new DialogInterface.OnClickListener() { + builder.setPositiveButton(context.getResources().getString(R.string.wordclock_remove), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { clockList.remove(position); @@ -216,7 +216,7 @@ public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { adapter.clear(); adapter.addAll(offsetToName.get(timezonesList.get(progress))); int millisOffset = timezonesList.get(progress); - String offset = String.format("%02d:%02d", Math.abs(millisOffset / 1000 / 60 / 60), Math.abs(millisOffset / 1000 / 60) % 60); + String offset = String.format(Locale.getDefault(),"%02d:%02d", Math.abs(millisOffset / 1000 / 60 / 60), Math.abs(millisOffset / 1000 / 60) % 60); if (millisOffset / 1000 / 60 / 60 < 0) { offset = "-" + offset; } else { @@ -313,10 +313,14 @@ public void onTick() { } private void updateClockTextView(TextView clockToUpdate, String timezone) { - SimpleDateFormat sdf = new SimpleDateFormat("h:mm:ss a"); + SimpleDateFormat sdf = null; + String value = Settings.System.getString(context.getContentResolver(), android.provider.Settings.System.TIME_12_24); + if (value.equals("12")) sdf = new SimpleDateFormat("h:mm:ss a",Locale.getDefault()); + else sdf = new SimpleDateFormat("HH:mm:ss",Locale.getDefault()); Date newDate = new Date(); // as a fallback sdf.setTimeZone(TimeZone.getTimeZone(timezone)); - String toText = sdf.format(newDate).toLowerCase(); + String toText = sdf.format(newDate).toLowerCase(Locale.getDefault()); clockToUpdate.setText(toText); } + }