Skip to content
This repository was archived by the owner on Nov 29, 2018. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@ gradle.properties
.idea/
out/
*.iml

#key file
/worldclockwidget/default_owm_api_key
8 changes: 3 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
World Clock & Weather
=====================
**This project is coming live again. All the upcoming updates will be mainted by** `Biswajit Das <https://github.com/dasbiswajit>`_


**This new release require Users to signup for API Key. Please look for application Settings -> GENERAL -> !!!Important!!! section**
** Important fix!!
User can use default api key as well as signup API Keys. Please look for application Settings -> GENERAL -> !!!Important!!! section**

A simple application to display the local time and current weather conditions in places all over the world.
It comes with two home screen widgets which show weather and time or time only.
Expand Down Expand Up @@ -55,7 +53,7 @@ The app uses and includes the following libraries:
* `ActionBarSherlock <http://actionbarsherlock.com/>`_ (also on `GitHub <https://github.com/JakeWharton/ActionBarSherlock>`__)
* `ColorPickerPreference <https://github.com/attenzione/android-ColorPickerPreference>`_
* `google-gson <https://code.google.com/p/google-gson/>`_
* `joda-time-android <https://github.com/dlew/joda-time-android>`_
* `Time4A <https://github.com/MenoData/Time4A>`_

Acknowledgements
----------------
Expand Down
4 changes: 2 additions & 2 deletions worldclockwidget/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def getOpenWeatherMapApiKey() {
if (project.hasProperty('owmApiKey')) {
return owmApiKey
} else {
def apiKeyFile = file('default_owm_api_key');
def apiKeyFile = file('default_owm_api_key')
if (apiKeyFile.isFile()) {
return apiKeyFile.text.trim()
}
Expand All @@ -109,7 +109,7 @@ dependencies{
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'
compile 'com.android.support:support-v4:19.1.0'
compile 'com.google.code.gson:gson:2.3.1'
compile 'net.danlew:android.joda:2.9.4.1'
compile group: 'net.time4j', name: 'time4j-android', version: '4.0-2018g'
}


Expand Down
2 changes: 0 additions & 2 deletions worldclockwidget/proguard-project.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,3 @@
# public *;
#}

# ignore missing Joda time references
-dontwarn org.joda.time.tz.ZoneInfoCompiler,org.joda.convert.*
1 change: 1 addition & 0 deletions worldclockwidget/src/main/assets/city_data.csv
Original file line number Diff line number Diff line change
Expand Up @@ -1620,6 +1620,7 @@ Kishangarh Kishangarh 26.59006 74.85397 India Asia/Kolkata
Kolār Kolar 13.13768 78.12999 India Asia/Kolkata
Kolhāpur Kolhapur 16.69563 74.23167 India Asia/Kolkata
Kolkata Kolkata 22.56263 88.36304 India Asia/Kolkata
Gangasagar South 24 Parganas 21.647535 88.081215 India Asia/Kolkata
Kollam Kollam 8.88113 76.58469 India Asia/Kolkata
Korba Korba 22.3458 82.69633 India Asia/Kolkata
Kota Kota 25.18254 75.83907 India Asia/Kolkata
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package ch.corten.aha.utils;

import net.time4j.Moment;
import net.time4j.SystemClock;
import net.time4j.ZonalClock;
import net.time4j.base.TimeSource;

/**
* A special clock which takes into account possible adjustments of device clock done by app users
* if they intend to compensate wrong platform timezone data.
*
* @author Meno Hochschild
*/
public class PlatformClock
implements TimeSource<Moment> {

public static final TimeSource<Moment> INSTANCE = new PlatformClock();

private final ZonalClock zonalClock = SystemClock.inPlatformView();

private PlatformClock() {
// singleton constructor
}

@Override
public Moment currentTime() {
return this.zonalClock.now().inStdTimezone();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,14 @@
import android.util.AttributeSet;
import android.widget.TextView;

import org.joda.time.DateTimeUtils;
import org.joda.time.DateTimeZone;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import net.time4j.Moment;
import net.time4j.format.expert.ChronoFormatter;
import net.time4j.format.expert.PatternType;
import net.time4j.tz.Timezone;

import java.util.Locale;

import ch.corten.aha.utils.PlatformClock;

/**
* Like AnalogClock, but digital. Shows seconds.
Expand All @@ -57,8 +61,8 @@ public class DigitalClock extends TextView implements PauseListener {
private int mState = STATE_DETACHED;
private PauseSource mPauseSource = null;

private DateTimeFormatter mDateFormat;
private DateTimeZone mTimeZone;
private ChronoFormatter<Moment> mDateFormat;
private Timezone mTimeZone;

public DigitalClock(Context context) {
super(context);
Expand All @@ -70,11 +74,11 @@ public DigitalClock(Context context, AttributeSet attrs) {
initClock(context);
}

public DateTimeZone getTimeZone() {
public Timezone getTimeZone() {
return mTimeZone;
}

public void setTimeZone(DateTimeZone timeZone) {
public void setTimeZone(Timezone timeZone) {
mTimeZone = timeZone;
setFormat();
updateClock();
Expand Down Expand Up @@ -104,7 +108,7 @@ protected void onAttachedToWindow() {
super.onAttachedToWindow();
mHandler = new Handler();

/**
/*
* requests a tick on the next hard-second boundary.
*/
mTicker = new Runnable() {
Expand Down Expand Up @@ -170,16 +174,21 @@ private boolean is24HourMode() {
}

private void setFormat() {
mDateFormat = DateTimeFormat.forPattern(is24HourMode() ? M24 : M12).withZone(mTimeZone);
mDateFormat =
ChronoFormatter.ofMomentPattern(
is24HourMode() ? M24 : M12,
PatternType.CLDR,
Locale.getDefault(),
mTimeZone.getID());
}

private void updateClock() {
setText(mDateFormat.print(DateTimeUtils.currentTimeMillis()));
setText(mDateFormat.format(PlatformClock.INSTANCE.currentTime()));
invalidate();
}

private class FormatChangeObserver extends ContentObserver {
public FormatChangeObserver() {
FormatChangeObserver() {
super(new Handler());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@
import com.actionbarsherlock.widget.SearchView;
import com.actionbarsherlock.widget.SearchView.OnQueryTextListener;

import org.joda.time.DateTimeZone;
import net.time4j.Moment;
import net.time4j.tz.Timezone;

import ch.corten.aha.utils.PlatformClock;
import ch.corten.aha.worldclock.provider.WorldClock;
import ch.corten.aha.worldclock.provider.WorldClock.Cities;

Expand Down Expand Up @@ -96,10 +98,11 @@ public void bindView(View view, Context context, Cursor cursor) {
BindHelper.bindText(view, cursor, R.id.city_text, Cities.NAME);
BindHelper.bindText(view, cursor, R.id.area_text, Cities.COUNTRY);
TextView timeDiffText = (TextView) view.findViewById(R.id.time_diff_text);
DateTimeZone tz = DateTimeZone.forID(cursor.getString(cursor.getColumnIndex(Cities.TIMEZONE_ID)));
timeDiffText.setText(TimeZoneInfo.getTimeDifferenceString(tz));
Timezone tz = Timezone.of(cursor.getString(cursor.getColumnIndex(Cities.TIMEZONE_ID)));
Moment moment = PlatformClock.INSTANCE.currentTime();
timeDiffText.setText(TimeZoneInfo.getTimeDifferenceString(tz, moment));
TextView timeZoneDescText = (TextView) view.findViewById(R.id.timezone_desc_text);
timeZoneDescText.setText(TimeZoneInfo.getDescription(tz));
timeZoneDescText.setText(TimeZoneInfo.getDescription(tz, moment));
}
};
setListAdapter(mAdapter);
Expand Down Expand Up @@ -191,7 +194,8 @@ public void onListItemClick(ListView l, View v, int position, long id) {
String timeZoneId = c.getString(c.getColumnIndex(Cities.TIMEZONE_ID));
String city = c.getString(c.getColumnIndex(Cities.NAME));
String country = c.getString(c.getColumnIndex(Cities.COUNTRY));
int timeDiff = TimeZoneInfo.getTimeDifference(DateTimeZone.forID(timeZoneId));
Moment moment = PlatformClock.INSTANCE.currentTime();
int timeDiff = TimeZoneInfo.getTimeDifference(Timezone.of(timeZoneId), moment);
double latitude = c.getDouble(c.getColumnIndex(Cities.LATITUDE));
double longitude = c.getDouble(c.getColumnIndex(Cities.LONGITUDE));
WorldClock.Clocks.addClock(getActivity(), timeZoneId, city,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@
import com.actionbarsherlock.app.SherlockFragment;
import com.actionbarsherlock.app.SherlockFragmentActivity;

import org.joda.time.DateTimeZone;
import net.time4j.Moment;
import net.time4j.tz.Timezone;

import ch.corten.aha.utils.PlatformClock;
import ch.corten.aha.worldclock.provider.WorldClock.Clocks;

public class EditClockActivity extends SherlockFragmentActivity {
Expand Down Expand Up @@ -128,9 +130,12 @@ public void onActivityCreated(Bundle savedInstanceState) {
mUseInWidgetCheckBox = (CheckBox) view.findViewById(R.id.use_in_widget_checkbox);
mUseInWidgetCheckBox.setChecked(c.getInt(c.getColumnIndex(Clocks.USE_IN_WIDGET)) != 0);
String id = c.getString(c.getColumnIndex(Clocks.TIMEZONE_ID));
DateTimeZone tz = DateTimeZone.forID(id);
((TextView) view.findViewById(R.id.time_zone_name)).setText(TimeZoneInfo.getDescription(tz));
((TextView) view.findViewById(R.id.time_zone_details)).setText(TimeZoneInfo.getTimeDifferenceString(tz));
Timezone tz = Timezone.of(id);
Moment moment = PlatformClock.INSTANCE.currentTime();
((TextView) view.findViewById(R.id.time_zone_name)).setText(
TimeZoneInfo.getDescription(tz, moment));
((TextView) view.findViewById(R.id.time_zone_details)).setText(
TimeZoneInfo.getTimeDifferenceString(tz, moment));

if (SANS_ICE_CREAM) {
// capitalize text of the checkbox - pre ics does not support textAllCaps.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import android.app.Application;

import net.danlew.android.joda.JodaTimeAndroid;
import net.time4j.android.ApplicationStarter;

/**
* Initializes libraries.
Expand All @@ -28,6 +28,6 @@ public class MyApp extends Application {
@Override
public void onCreate() {
super.onCreate();
JodaTimeAndroid.init(this);
ApplicationStarter.initialize(this);
}
}
Loading