Skip to content

Commit

Permalink
Updated Icons and bug fixes
Browse files Browse the repository at this point in the history
- In friends now checks for network connection before attempting refresh
- Added opt out for GAnalytics for Debug Builds
  • Loading branch information
Saurabh Joshi committed May 23, 2014
1 parent daa5868 commit b013a46
Show file tree
Hide file tree
Showing 35 changed files with 39 additions and 3 deletions.
8 changes: 7 additions & 1 deletion vitinfo2/src/main/java/com/karthikb351/vitinfo2/Home.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import android.widget.ListView;
import android.widget.RadioButton;

import com.google.android.gms.analytics.GoogleAnalytics;
import com.karthikb351.vitinfo2.adapters.DrawerListAdapter;
import com.karthikb351.vitinfo2.fragments.CoursesFragment;
import com.karthikb351.vitinfo2.fragments.FriendsFragment;
Expand Down Expand Up @@ -56,7 +57,7 @@ public class Home extends ActionBarActivity {
//Initialize drawer tabs
private String[] titles = { "Today", "Courses", "Timetable","Friends", "Notifications", "Settings"};
private String[] subtitle = { "Realtime Overview", "Attendance|Marks|More", "Day|Week", "Check their status","Latest news", "Change credentials"};
private int[] imgs = new int[]{ R.drawable.now, R.drawable.ic_action_sort_by_size, R.drawable.timetable, R.drawable.friends, R.drawable.ic_action_unread, R.drawable.settings};
private int[] imgs = new int[]{ R.drawable.ic_action_about, R.drawable.ic_action_sort_by_size, R.drawable.ic_action_event, R.drawable.ic_action_group, R.drawable.ic_action_unread, R.drawable.ic_action_settings};

//Drawer ListView
public DrawerLayout mDrawerLayout;
Expand Down Expand Up @@ -93,6 +94,11 @@ protected void onCreate(Bundle savedInstanceState) {
overridePendingTransition(R.anim.enter, R.anim.exit);
}

if(BuildConfig.DEBUG) {
GoogleAnalytics googleAnalytics = GoogleAnalytics.getInstance(getApplicationContext());
googleAnalytics.setAppOptOut(true);
}

setContentView(R.layout.activity_home);

mTitle = mDrawerTitle = getTitle();
Expand Down
12 changes: 10 additions & 2 deletions vitinfo2/src/main/java/com/karthikb351/vitinfo2/VITxAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -391,10 +391,12 @@ protected Void doInBackground(Void... voids) {
f.timetable = EntityUtils.toString(getResponse("http://vitacademicstokensystem.appspot.com/gettimetable/" + f.regno + "/" + f.dob).getEntity());
try {
new JSONObject(f.timetable);
}catch (JSONException e1){e = new Exception("Could not parse friends timetable. Please try again!"); return null;}
}catch (JSONException e1){
e = new Exception("Could not parse friends timetable. Please try again!");
return null;
}
//Save friend to memory!
dat.addFriend(f);

}
else{
e = new Exception("Oops! Looks like the token is incorrect or expired.");
Expand Down Expand Up @@ -449,6 +451,12 @@ protected Void doInBackground(Void... voids) {
}
//Get the timetable
f.timetable = result;
try {
new JSONObject(f.timetable);
}catch (JSONException e1){
e = new Exception("Could not parse friends timetable. Please try again!");
return null;
}
//Save friend to memory!
dat.addFriend(f);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@

import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.nfc.NfcAdapter;
import android.os.AsyncTask;
import android.os.Build;
Expand Down Expand Up @@ -374,6 +377,23 @@ protected void onPreExecute(){
friends = new ArrayList<Friend>();
}

private boolean haveNetworkConnection() {
boolean haveConnectedWifi = false;
boolean haveConnectedMobile = false;

ConnectivityManager cm = (ConnectivityManager) getActivity().getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo[] netInfo = cm.getAllNetworkInfo();
for (NetworkInfo ni : netInfo) {
if (ni.getTypeName().equalsIgnoreCase("WIFI"))
if (ni.isConnected())
haveConnectedWifi = true;
if (ni.getTypeName().equalsIgnoreCase("MOBILE"))
if (ni.isConnected())
haveConnectedMobile = true;
}
return haveConnectedWifi || haveConnectedMobile;
}

private void downloadProfileImage(final ArrayList<Friend> friends){
for(int i = 0; i < friends.size(); i++){
String fbId;
Expand All @@ -400,6 +420,8 @@ private void downloadProfileImage(final ArrayList<Friend> friends){
private boolean needSaving = false;
@Override
protected Void doInBackground(Void... voids) {
if(!haveNetworkConnection())
return null;
try {
friends = new DataHandler(getActivity()).getFreinds();
for(int i = 0; i < friends.size(); i++){
Expand Down
Binary file removed vitinfo2/src/main/res/drawable-hdpi/friends.png
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified vitinfo2/src/main/res/drawable-hdpi/ic_action_sort_by_size.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed vitinfo2/src/main/res/drawable-hdpi/now.png
Binary file not shown.
Binary file removed vitinfo2/src/main/res/drawable-hdpi/settings.png
Binary file not shown.
Binary file removed vitinfo2/src/main/res/drawable-hdpi/timetable.png
Binary file not shown.
Binary file removed vitinfo2/src/main/res/drawable-mdpi/friends.png
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed vitinfo2/src/main/res/drawable-mdpi/now.png
Binary file not shown.
Binary file removed vitinfo2/src/main/res/drawable-mdpi/settings.png
Binary file not shown.
Binary file removed vitinfo2/src/main/res/drawable-mdpi/timetable.png
Binary file not shown.
Binary file removed vitinfo2/src/main/res/drawable-xhdpi/friends.png
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed vitinfo2/src/main/res/drawable-xhdpi/settings.png
Binary file not shown.
Binary file removed vitinfo2/src/main/res/drawable-xhdpi/timetable.png
Binary file not shown.
Binary file removed vitinfo2/src/main/res/drawable-xxhdpi/friends.png
Binary file not shown.
Binary file removed vitinfo2/src/main/res/drawable-xxhdpi/now.png
Diff not rendered.
Binary file removed vitinfo2/src/main/res/drawable-xxhdpi/settings.png
Diff not rendered.
Binary file removed vitinfo2/src/main/res/drawable-xxhdpi/timetable.png
Diff not rendered.

0 comments on commit b013a46

Please sign in to comment.