Skip to content

Commit

Permalink
Updated layouts
Browse files Browse the repository at this point in the history
  • Loading branch information
HiiYL committed May 1, 2015
1 parent a4ebefb commit 4c0773b
Show file tree
Hide file tree
Showing 26 changed files with 431 additions and 347 deletions.
Binary file modified .DS_Store
Binary file not shown.
653 changes: 391 additions & 262 deletions .idea/workspace.xml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ public void onResponse(String response) {
editor.putString("faculty", faculty);
editor.putString("sync_interval", "60");
editor.putBoolean("sync_enabled", true);
editor.putBoolean("notifications_enabled", true);
editor.apply();
MMUSyncAdapter.syncImmediately(LoginActivity.this);
Intent intent = new Intent(mContext, MMLSActivity.class);
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/java/com/github/hiiyl/mmuhub/Utility.java
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,8 @@ public static boolean isNetworksAvailable(Context context) {
snackBar.show();
return false;
}
public static boolean getNotificationsEnabled(Context context) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
return prefs.getBoolean("notifications_enabled", true);
}
}
50 changes: 3 additions & 47 deletions app/src/main/java/com/github/hiiyl/mmuhub/sync/MMUSyncAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import android.accounts.Account;
import android.accounts.AccountManager;
import android.app.AlertDialog;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.AbstractThreadedSyncAdapter;
Expand All @@ -23,7 +22,6 @@
import android.support.v4.app.NotificationCompat;
import android.support.v4.app.TaskStackBuilder;
import android.util.Log;
import android.view.View;

import com.android.volley.AuthFailureError;
import com.android.volley.DefaultRetryPolicy;
Expand All @@ -33,7 +31,6 @@
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.StringRequest;
import com.gc.materialdesign.widgets.SnackBar;
import com.github.hiiyl.mmuhub.AnnouncementDetailActivity;
import com.github.hiiyl.mmuhub.BulletinActivity;
import com.github.hiiyl.mmuhub.MySingleton;
Expand Down Expand Up @@ -251,7 +248,8 @@ public void run() {
MMUContract.AnnouncementEntry.TABLE_NAME, new String[] {MMUContract.AnnouncementEntry.COLUMN_POSTED_DATE},
null, null, null, null, MMUContract.AnnouncementEntry.COLUMN_POSTED_DATE + " DESC ", "1"
);
if(posted_date_cursor.moveToFirst()) {

if(Utility.getNotificationsEnabled(context) && posted_date_cursor.moveToFirst()) {
String latest_posted_date = posted_date_cursor.getString(posted_date_cursor.getColumnIndex(MMUContract.AnnouncementEntry.COLUMN_POSTED_DATE));
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Log.d("POSTED_DATE", posted_date_cursor.getString(posted_date_cursor.getColumnIndex(MMUContract.AnnouncementEntry.COLUMN_POSTED_DATE)));
Expand Down Expand Up @@ -371,10 +369,7 @@ public void run() {

@Override
public void onErrorResponse(VolleyError error) {
// mSwipeRefreshLayout.setRefreshing(false);
NetworkResponse networkResponse = error.networkResponse;
AlertDialog.Builder alertDialogBuilder;
AlertDialog alertDialog;
if (networkResponse != null && networkResponse.data != null) {
switch (networkResponse.statusCode) {
case 400:
Expand Down Expand Up @@ -459,14 +454,8 @@ public Map<String, String> getHeaders() throws AuthFailureError {
sync_queue.add(sr);
}
public void updateBulletin(final Context context) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
Log.d("UPDATE Bulletin", "UPDATING BULLETIN");
final String subject_url, subject_name;
final Context mContext = context;
final MMUDbHelper mOpenHelper = new MMUDbHelper(mContext);
Cursor cursor = MySingleton.getInstance(context).getDatabase().query(MMUContract.BulletinEntry.TABLE_NAME, null, null, null, null, null, null);
String url = "https://mmu-api.co/bulletin_api";
// mSwipeRefreshLayout.setRefreshing(true);
StringRequest sr = new StringRequest(Request.Method.GET, url, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
Expand All @@ -493,48 +482,15 @@ public void onResponse(String response) {
MySingleton.getInstance(context).getDatabase().insert(MMUContract.BulletinEntry.TABLE_NAME, null, bulletinValues);
}
}
// mSwipeRefreshLayout.setRefreshing(false);
EventBus.getDefault().post(new DownloadCompleteEvent(BulletinActivity.BulletinFragment.BULLETIN_SYNC_COMPLETE));


} catch (JSONException exception) {

exception.printStackTrace();
}
}
}, new Response.ErrorListener() {
String json = null;
@Override
public void onErrorResponse(VolleyError error) {
Log.d("WOW", "ITS DEAD JIM");
NetworkResponse networkResponse = error.networkResponse;
if (networkResponse != null && networkResponse.data != null) {
switch (networkResponse.statusCode) {
case 400:
SnackBar snackbar = new SnackBar((android.app.Activity) context, "Wrong Username or Password");
snackbar.show();

break;
default:
SnackBar new_snackbar = new SnackBar((android.app.Activity) context, "Internal Server Error",
"Retry", new View.OnClickListener() {
@Override
public void onClick(View v) {
updateBulletin(context);
}
});
new_snackbar.show();
}
//Additional cases
} else {
SnackBar snackbar = new SnackBar((android.app.Activity) context, "No Internet Connection",
"Retry", new View.OnClickListener() {
@Override
public void onClick(View v) {
updateBulletin(context);
}
});
snackbar.show();
}
}
});
sr.setRetryPolicy(new DefaultRetryPolicy(
Expand Down
Binary file modified app/src/main/res/.DS_Store
Binary file not shown.
Binary file modified app/src/main/res/drawable-hdpi/nav_drawer_img.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/drawable-mdpi/arrow_down.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/drawable-mdpi/arrow_up.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/drawable-mdpi/nav_drawer_img.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/drawable-xhdpi/arrow_down.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/drawable-xhdpi/arrow_up.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/drawable-xhdpi/nav_drawer_img.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/drawable-xxhdpi/arrow_down.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/drawable-xxhdpi/arrow_up.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/drawable-xxhdpi/nav_drawer_img.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions app/src/main/res/layout/activity_bulletin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
android:layout_gravity="start" >

<ListView android:id="@+id/left_drawer"
android:layout_width="240dp"
android:layout_width="280dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:choiceMode="singleChoice"
Expand All @@ -24,7 +24,7 @@
android:clipToPadding="false"
android:background="#FFF"/>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="240dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="@color/background_material_light">
Expand Down
27 changes: 0 additions & 27 deletions app/src/main/res/layout/activity_login.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,6 @@
android:singleLine="true"
android:imeOptions="actionNext"
android:hint="Student ID"/>
<!--<EditText-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="wrap_content"-->
<!---->
<!--android:layout_margin="10dp"-->
<!--android:gravity="center"-->
<!--android:singleLine="true"-->
<!--android:imeOptions="actionNext"-->
<!--android:hint="Student ID"/>-->
<!--<TextView-->
<!--android:layout_width="wrap_content"-->
<!--android:layout_height="wrap_content"-->
Expand All @@ -52,14 +43,6 @@
<!--android:imeOptions="actionNext"-->
<!--android:singleLine="true"-->
<!--android:password="true"/>-->
<!--<EditText-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="wrap_content"-->
<!--android:id = "@+id/icems_pass_field"-->
<!--android:hint="ICEMS Password"-->
<!--android:imeOptions="actionNext"-->
<!--android:singleLine="true"-->
<!--android:password="true"/>-->
<com.rengwuxian.materialedittext.MaterialEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand All @@ -71,16 +54,6 @@
android:imeOptions="actionDone"
android:hint="MMLS Password"
android:inputType="textPassword"/>
<!--<EditText-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="wrap_content"-->
<!--android:id = "@+id/mmls_pass_field"-->
<!--android:hint="MMLS Password"-->
<!--android:layout_margin="10dp"-->
<!--android:gravity="center"-->
<!--android:singleLine="true"-->
<!--android:imeOptions="actionDone"-->
<!--android:password="true"/>-->
<com.gc.materialdesign.views.ButtonRectangle
android:id="@+id/loginBtn"
android:layout_margin="24dp"
Expand Down
5 changes: 2 additions & 3 deletions app/src/main/res/layout/activity_mmls.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,16 @@
android:layout_gravity="start" >

<ListView android:id="@+id/left_drawer"
android:layout_width="240dp"
android:layout_width="280dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp"
android:paddingBottom="50dp"
android:clipToPadding="false"
android:background="#FFF"/>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="240dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="@color/background_material_light">
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/layout/fragment_announcement_detail.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="invisible"
android:visibility="gone"
android:id="@+id/announcement_detail_download_layout"
android:background="@drawable/download_shape"
android:layout_marginBottom="20dp"
android:padding="20dp" >
<TextView
android:layout_width="wrap_content"
Expand Down
17 changes: 17 additions & 0 deletions app/src/main/res/values-v21/styles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<style name="MMLSTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:actionBarStyle">@style/ThemeActionBar</item>
<item name="android:windowActionBarOverlay">true</item>
<item name="android:windowContentOverlay">@null</item>

<item name="android:colorPrimary">@color/skyblue</item>
<item name="android:colorPrimaryDark">@color/skyblue_darker</item>

<!-- Support library compatibility -->
<item name="background">@null</item>
<item name="actionBarStyle">@style/ThemeActionBar</item>
<item name="windowActionBarOverlay">true</item>
</style>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="skyblue">#ff64c2f4</color>
<color name="skyblue_darker">#0f8dd2</color>
<color name="white">#fff</color>
<color name="light_gray">#d3d3d3</color>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,5 @@
<string name="sync_interval_list_preference">Sync Interval</string>
<string name="summary_sync_interval_list_preference">Adjust interval between syncs</string>
<string name="sync_interval">sync interval</string>
<string name="notifications_category">Notifications</string>
</resources>
4 changes: 0 additions & 4 deletions app/src/main/res/xml/pref_general.xml

This file was deleted.

8 changes: 7 additions & 1 deletion app/src/main/res/xml/preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
android:entries="@array/entries_sync_interval_list_preference"
android:entryValues="@array/entryvalues_sync_interval_list_list_preference"
android:dialogTitle="@string/dialog_title_list_preference" />

</PreferenceCategory>
<PreferenceCategory
android:title="@string/notifications_category">
<CheckBoxPreference
android:key="notifications_enabled"
android:title="Enable Notifications"
android:summary="Enable MMLS Announcement Notifications" />
</PreferenceCategory>
</PreferenceScreen>

0 comments on commit 4c0773b

Please sign in to comment.