Skip to content

Commit 3efe51c

Browse files
author
Andrew Sosa
committed
v3.0.2 - Zoomable maps, less glitchy sponsor.
1 parent 03afdbb commit 3efe51c

16 files changed

+1528
-32
lines changed

mobile/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ android {
77
applicationId 'com.hackfsu.android.hackfsu'
88
minSdkVersion 16
99
targetSdkVersion 23
10-
versionCode 4
11-
versionName "3.0.1"
10+
versionCode 5
11+
versionName "3.0.2"
1212
multiDexEnabled true //enable this
1313

1414
}

mobile/mobile-release.apk

2.17 MB
Binary file not shown.

mobile/mobile.iml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,20 +61,20 @@
6161
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
6262
<sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
6363
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
64-
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
65-
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
66-
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
67-
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
68-
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
69-
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
70-
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
7164
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
7265
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
7366
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
7467
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
7568
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
7669
<sourceFolder url="file://$MODULE_DIR$/src/test/jni" isTestSource="true" />
7770
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
71+
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
72+
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
73+
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
74+
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
75+
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
76+
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
77+
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
7878
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
7979
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
8080
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />

mobile/src/main/AndroidManifest.xml

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,18 @@
1515

1616
<uses-permission android:name="com.hackfsu.android.hackfsu.permission.C2D_MESSAGE" />
1717

18-
19-
2018
<application
21-
android:name="com.hackfsu.android.hackfsu.HackFSU"
19+
android:name=".HackFSU"
2220
android:allowBackup="true"
2321
android:icon="@mipmap/ic_launcher"
2422
android:label="@string/app_name"
2523
android:theme="@style/AppTheme">
26-
27-
<meta-data android:name="com.parse.push.notification_icon"
28-
android:resource="@drawable/ic_notification_icon"/>
24+
<meta-data
25+
android:name="com.parse.push.notification_icon"
26+
android:resource="@drawable/ic_notification_icon" />
2927

3028
<activity
31-
android:name="com.hackfsu.android.hackfsu.MainActivity"
29+
android:name=".MainActivity"
3230
android:label="@string/app_name"
3331
android:theme="@style/AppTheme.NoActionBar">
3432
<intent-filter>
@@ -38,9 +36,9 @@
3836
</intent-filter>
3937
</activity>
4038
<activity
41-
android:name="com.hackfsu.android.hackfsu.HelpActivity"
39+
android:name=".HelpActivity"
4240
android:label="@string/title_activity_help"
43-
android:parentActivityName="com.hackfsu.android.hackfsu.MainActivity"
41+
android:parentActivityName=".MainActivity"
4442
android:theme="@style/AppTheme.HelpRequest">
4543
<meta-data
4644
android:name="android.support.PARENT_ACTIVITY"
@@ -50,7 +48,7 @@
5048
<service android:name="com.parse.PushService" />
5149

5250
<receiver
53-
android:name="com.hackfsu.android.hackfsu.CustomPushReceiver"
51+
android:name=".CustomPushReceiver"
5452
android:exported="false">
5553
<intent-filter>
5654
<action android:name="com.parse.push.intent.RECEIVE" />
@@ -69,6 +67,9 @@
6967
</intent-filter>
7068
</receiver>
7169

70+
<activity android:name=".MapViewActivity">
71+
72+
</activity>
7273
</application>
7374

7475
</manifest>
39.4 KB
Binary file not shown.
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
package com.hackfsu.android.hackfsu;
2+
3+
import android.content.Context;
4+
import android.content.res.Resources;
5+
import android.graphics.Bitmap;
6+
import android.graphics.BitmapFactory;
7+
import android.util.AttributeSet;
8+
9+
import com.parse.ParseFile;
10+
import com.parse.ParseImageView;
11+
12+
import bolts.Continuation;
13+
import bolts.Task;
14+
15+
/**
16+
* Created by andrewsosa on 12/23/15.
17+
*/
18+
public class CustomParseImageView extends ParseImageView {
19+
20+
ParseFile file;
21+
22+
public CustomParseImageView(Context context) {
23+
super(context);
24+
}
25+
26+
public CustomParseImageView(Context context, AttributeSet attributeSet) {
27+
super(context, attributeSet);
28+
}
29+
30+
public CustomParseImageView(Context context, AttributeSet attributeSet, int defStyle) {
31+
super(context, attributeSet, defStyle);
32+
}
33+
34+
@Override
35+
public void setParseFile(ParseFile file) {
36+
this.file = file;
37+
super.setParseFile(this.file);
38+
}
39+
40+
@Override
41+
public Task<byte[]> loadInBackground() {
42+
43+
if (file == null) {
44+
return Task.forResult(null);
45+
}
46+
47+
final ParseFile loadingFile = file;
48+
return file.getDataInBackground().onSuccessTask(new Continuation<byte[], Task<byte[]>>() {
49+
@Override
50+
public Task<byte[]> then(Task<byte[]> task) throws Exception {
51+
byte[] data = task.getResult();
52+
if (file != loadingFile) {
53+
// This prevents the very slim chance of the file's download finishing and the callback
54+
// triggering just before this ImageView is reused for another ParseObject.
55+
return Task.cancelled();
56+
}
57+
if (data != null) {
58+
//Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, data.length);
59+
Bitmap bitmap = decodeSampledBitmapFromResource(data, 0, data.length, 512, 512);
60+
if (bitmap != null) {
61+
setImageBitmap(bitmap);
62+
}
63+
}
64+
return task;
65+
}
66+
}, Task.UI_THREAD_EXECUTOR);
67+
}
68+
69+
70+
public static int calculateInSampleSize(
71+
BitmapFactory.Options options, int reqWidth, int reqHeight) {
72+
// Raw height and width of image
73+
final int height = options.outHeight;
74+
final int width = options.outWidth;
75+
int inSampleSize = 1;
76+
77+
if (height > reqHeight || width > reqWidth) {
78+
79+
final int halfHeight = height / 2;
80+
final int halfWidth = width / 2;
81+
82+
// Calculate the largest inSampleSize value that is a power of 2 and keeps both
83+
// height and width larger than the requested height and width.
84+
while ((halfHeight / inSampleSize) > reqHeight
85+
&& (halfWidth / inSampleSize) > reqWidth) {
86+
inSampleSize *= 2;
87+
}
88+
}
89+
90+
return inSampleSize;
91+
}
92+
93+
94+
public static Bitmap decodeSampledBitmapFromResource(byte[] data, int offset, int length,
95+
int reqWidth, int reqHeight) {
96+
97+
// First decode with inJustDecodeBounds=true to check dimensions
98+
final BitmapFactory.Options options = new BitmapFactory.Options();
99+
options.inJustDecodeBounds = true;
100+
BitmapFactory.decodeByteArray(data, offset, length, options);
101+
102+
// Calculate inSampleSize
103+
options.inSampleSize = calculateInSampleSize(options, reqWidth, reqHeight);
104+
105+
// Decode bitmap with inSampleSize set
106+
options.inJustDecodeBounds = false;
107+
return BitmapFactory.decodeByteArray(data, offset, length, options);
108+
}
109+
}
110+
111+

mobile/src/main/java/com/hackfsu/android/hackfsu/FeedFragment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public void onActivityCreated(Bundle savedInstanceState) {
105105

106106
// Custom toolbar font
107107
Typeface face;
108-
face = Typeface.createFromAsset(getContext().getAssets(), "unisans.OTF");
108+
face = Typeface.createFromAsset(getContext().getAssets(), getResources().getString(R.string.hackfsu_font));
109109
mCollasping.setCollapsedTitleTypeface(face);
110110
mCollasping.setExpandedTitleTypeface(face);
111111
mCollasping.setTitle("HackFSU");

mobile/src/main/java/com/hackfsu/android/hackfsu/MainActivity.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import android.content.Intent;
44
import android.content.SharedPreferences;
5+
import android.content.pm.ActivityInfo;
56
import android.graphics.Typeface;
67
import android.net.Uri;
78
import android.os.Bundle;
@@ -51,7 +52,7 @@ protected void onCreate(Bundle savedInstanceState) {
5152

5253
TextView navHeader = (TextView) navigationView.getHeaderView(0).findViewById(R.id.tv_navtitle);
5354
navHeader.setText("HACKFSU");
54-
navHeader.setTypeface(Typeface.createFromAsset(getAssets(), "unisans.OTF"));
55+
navHeader.setTypeface(Typeface.createFromAsset(getAssets(), getResources().getString(R.string.hackfsu_font)));
5556

5657
}
5758

@@ -116,6 +117,12 @@ public boolean onNavigationItemSelected(MenuItem item) {
116117

117118
newFragmentTransaction(id);
118119

120+
if(id == R.id.nav_sponsors) {
121+
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
122+
} else {
123+
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
124+
}
125+
119126
} else if (item.getGroupId() == R.id.secondary) {
120127
switch (id) {
121128
case R.id.nav_help:
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package com.hackfsu.android.hackfsu;
2+
3+
import android.content.Intent;
4+
import android.graphics.Bitmap;
5+
import android.graphics.BitmapFactory;
6+
import android.graphics.drawable.Drawable;
7+
import android.support.v7.app.AppCompatActivity;
8+
import android.os.Bundle;
9+
import android.support.v7.widget.Toolbar;
10+
import android.view.MenuItem;
11+
import android.widget.ImageView;
12+
13+
public class MapViewActivity extends AppCompatActivity {
14+
15+
@Override
16+
protected void onCreate(Bundle savedInstanceState) {
17+
super.onCreate(savedInstanceState);
18+
setContentView(R.layout.activity_map_view);
19+
20+
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
21+
setSupportActionBar(toolbar);
22+
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
23+
getSupportActionBar().setDisplayShowTitleEnabled(false);
24+
25+
TouchImageView mapImage = (TouchImageView) findViewById(R.id.iv_map_image);
26+
27+
Bundle extras = getIntent().getExtras();
28+
byte[] b = extras.getByteArray("map");
29+
30+
Bitmap bmp = BitmapFactory.decodeByteArray(b, 0, b.length);
31+
mapImage.setImageBitmap(bmp);
32+
33+
}
34+
35+
@Override
36+
public boolean onOptionsItemSelected(MenuItem menuItem) {
37+
if (menuItem.getItemId() == android.R.id.home) {
38+
finish();
39+
}
40+
return super.onOptionsItemSelected(menuItem);
41+
}
42+
}

mobile/src/main/java/com/hackfsu/android/hackfsu/MapsFragment.java

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package com.hackfsu.android.hackfsu;
22

33
import android.content.Context;
4+
import android.content.Intent;
5+
import android.graphics.Bitmap;
6+
import android.graphics.BitmapFactory;
47
import android.os.Bundle;
58
import android.support.design.widget.AppBarLayout;
69
import android.support.v7.widget.LinearLayoutManager;
@@ -22,6 +25,7 @@
2225
import com.parse.ParseQuery;
2326
import com.yqritc.recyclerviewflexibledivider.HorizontalDividerItemDecoration;
2427

28+
import java.io.ByteArrayOutputStream;
2529
import java.util.ArrayList;
2630
import java.util.List;
2731

@@ -146,18 +150,33 @@ public MapItemRecyclerAdapter.ViewHolder onCreateViewHolder(ViewGroup parent,
146150

147151
// Populate the viewholder with data
148152
@Override
149-
public void onBindViewHolder(ViewHolder holder, int position) {
153+
public void onBindViewHolder(final ViewHolder holder, int position) {
150154

151155
holder.mMapItemImage.setParseFile(mDataset.get(position).getImage());
152156
holder.mMapItemImage.loadInBackground(new GetDataCallback() {
153157
@Override
154-
public void done(byte[] data, ParseException e) {
158+
public void done(final byte[] data, ParseException e) {
155159
if(e != null) {
156160
Log.e("HackFSU", e.getMessage());
161+
} else {
162+
163+
holder.mMapItemImage.setOnClickListener(new View.OnClickListener() {
164+
@Override
165+
public void onClick(View v) {
166+
167+
Intent intent = new Intent(getContext(), MapViewActivity.class);
168+
intent.putExtra("map", data);
169+
getContext().startActivity(intent);
170+
171+
}
172+
});
157173
}
174+
158175
}
159176
});
160177

178+
179+
161180
}
162181

163182
@Override

0 commit comments

Comments
 (0)