Skip to content

Commit

Permalink
WIP Part 2 of ClockWidget
Browse files Browse the repository at this point in the history
Added displaying timezone and date. Reverted some commits that will be unnecessary for this feature in the meantime.
  • Loading branch information
jtj9817 committed Nov 19, 2018
1 parent c7552d7 commit 9b3bd3f
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat

mCityAdapter.updateData(mCities);

if (mSpotlightShownCount <= 3) {
if (mSpotlightShownCount <= 4) {
showSpotlightView(mSpotView);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ protected void onCreate(Bundle savedInstanceState) {
setSupportActionBar(toolbar);

ButterKnife.bind(this);
//Testing for layout

recyclerView.setLayoutManager(new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL));

mHandler = new Handler(Looper.getMainLooper());
Expand Down
14 changes: 12 additions & 2 deletions Android/app/src/main/java/widget/ClockWidgetActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@
import android.appwidget.AppWidgetProvider;
import android.content.Context;
import android.widget.RemoteViews;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;

import java.text.DateFormat;

import io.github.project_travel_mate.R;

Expand All @@ -17,13 +21,19 @@

public class ClockWidgetActivity extends AppWidgetProvider {
private static DateFormat mCurrentTime = new SimpleDateFormat("hh:mm:ss");
private static Date mDateBasis = Calendar.getInstance().getTime();
private static DateFormat mCurrentDate = new SimpleDateFormat("dd/MM/yyyy");
static void updateAppWidget(Context context, AppWidgetManager appWidgetManager,
int appWidgetId) {

CharSequence widgetText = context.getString(R.string.appwidget_text);
// Construct the RemoteViews object
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.clock_widget_activity);
//Set Time, Date, and TimeZone of the widget
TimeZone currentTZ = TimeZone.getDefault();
views.setTextViewText(R.id.tView_digital_clock, mCurrentTime.format(new Date()));
views.setTextViewText(R.id.tView_timezone, currentTZ.getDisplayName());
views.setTextViewText(R.id.tView_tzdate, mCurrentDate.format(mDateBasis));
// Instruct the widget manager to update the widget
appWidgetManager.updateAppWidget(appWidgetId, views);
}
Expand Down
17 changes: 15 additions & 2 deletions Android/app/src/main/res/layout/clock_widget_activity.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#09C"
android:background="@android:color/transparent"
android:padding="@dimen/widget_margin">

<TextView
Expand All @@ -12,6 +12,7 @@
android:layout_centerHorizontal="true"
android:layout_marginTop="127dp"
android:textAlignment="center"
android:textColor="@color/white"
android:textSize="30sp"
android:textStyle="bold"
android:typeface="serif" />
Expand All @@ -22,7 +23,19 @@
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="196dp"
android:layout_marginTop="178dp"
android:textColor="@color/white"
android:textSize="24sp" />

<TextView
android:id="@+id/tView_tzdate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="215dp"
android:textColor="@color/white"
android:textSize="24sp"/>

</RelativeLayout>
Binary file removed screenshots/OfflineMapsPrototype.png
Binary file not shown.

0 comments on commit 9b3bd3f

Please sign in to comment.