Skip to content

Commit

Permalink
Fix version checker, add unused topic functionality, bump version to …
Browse files Browse the repository at this point in the history
…0.2.0.5 (#4)

Fix version checker, add unused topic functionality, bump version to 0.2.0.5
  • Loading branch information
tonyjhuang authored Sep 2, 2016
1 parent 52e5022 commit 0431e1d
Show file tree
Hide file tree
Showing 22 changed files with 608 additions and 61 deletions.
12 changes: 7 additions & 5 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ android {
applicationId "com.tonyjhuang.cheddar"
minSdkVersion 15
targetSdkVersion 23
versionCode 10
versionName "0.2.0.4"
versionCode 11
versionName "0.2.0.5"
multiDexEnabled true
}

Expand Down Expand Up @@ -212,9 +212,11 @@ dependencies {

compile "com.google.auto.value:auto-value:1.2"
apt "com.google.auto.value:auto-value:1.2"
apt 'com.ryanharter.auto.value:auto-value-gson:0.2.5'
apt 'com.ryanharter.auto.value:auto-value-parcel:0.2.1'
apt 'com.gabrielittner.auto.value:auto-value-with:0.1.3'
apt 'com.ryanharter.auto.value:auto-value-gson:0.4.2'
provided 'com.ryanharter.auto.value:auto-value-gson:0.4.2'
apt 'com.ryanharter.auto.value:auto-value-parcel:0.2.4-rc2'
compile 'com.ryanharter.auto.value:auto-value-parcel-adapter:0.2.4-rc2'
apt 'com.gabrielittner.auto.value:auto-value-with:1.0.0-rc1'
}

apply plugin: 'com.google.gms.google-services'
5 changes: 5 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@
android:launchMode="singleTop"
android:screenOrientation="portrait" />

<activity
android:name=".ui.joinchat.JoinChatActivity_"
android:launchMode="singleTop"
android:screenOrientation="portrait" />

<receiver
android:name=".background.ConnectivityBroadcastReceiver_"
android:exported="false">
Expand Down
173 changes: 173 additions & 0 deletions app/src/main/assets/neu_topics.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
{
"topics": [
{
"name": "Random",
"slug": "random",
"drawable": ""
},
{
"name": "Dorms",
"slug": "dorm",
"drawable": "",
"subtopics": [
{
"name": "West Village",
"slug": "wv",
"drawable": "",
"subtopics": [
{
"name": "West Village A",
"slug": "a",
"drawable": ""
},
{
"name": "West Village B",
"slug": "b",
"drawable": ""
},
{
"name": "West Village C",
"slug": "c",
"drawable": ""
},
{
"name": "West Village E",
"slug": "e",
"drawable": ""
},
{
"name": "West Village F",
"slug": "f",
"drawable": ""
},
{
"name": "West Village G",
"slug": "g",
"drawable": ""
},
{
"name": "West Village H",
"slug": "h",
"drawable": ""
}
]
},
{
"name": "Huntington Ave Apts",
"slug": "huntington",
"drawable": ""
},
{
"name": "Mission Hill Apts",
"slug": "mission_hill",
"drawable": ""
},
{
"name": "St. Stephen Street Apts",
"slug": "st_stephen",
"drawable": ""
},
{
"name": "10 Coventry",
"slug": "10_coventry",
"drawable": ""
},
{
"name": "153 Hemenway Street",
"slug": "153_hemenway",
"drawable": ""
},
{
"name": "780 Columbus Ave",
"slug": "780_columbus ",
"drawable": ""
},
{
"name": "Burstein Hall",
"slug": "burnstein",
"drawable": ""
},
{
"name": "Davenport Commons",
"slug": "davenport",
"drawable": ""
},
{
"name": "East Village",
"slug": "east_village",
"drawable": ""
},
{
"name": "Hastings Hall",
"slug": "hastings",
"drawable": ""
},
{
"name": "International Village",
"slug": "international_village",
"drawable": ""
},
{
"name": "Kennedy Hall",
"slug": "kennedy",
"drawable": ""
},
{
"name": "Kerr Hall",
"slug": "kerr",
"drawable": ""
},
{
"name": "Light Hall",
"slug": "light",
"drawable": ""
},
{
"name": "Loftman Hall",
"slug": "loftman",
"drawable": ""
},
{
"name": "Melvin Hall",
"slug": "melven",
"drawable": ""
},
{
"name": "Rubenstein Hall",
"slug": "rubenstein",
"drawable": ""
},
{
"name": "Smith Hall",
"slug": "smith",
"drawable": ""
},
{
"name": "Speare Hall",
"slug": "speare",
"drawable": ""
},
{
"name": "Stetson East Hall",
"slug": "stetson_east",
"drawable": ""
},
{
"name": "Stetson West Hall",
"slug": "steson_west",
"drawable": ""
},
{
"name": "White Hall",
"slug": "white",
"drawable": ""
},
{
"name": "Willis Hall",
"slug": "willis",
"drawable": ""
}
]
}
]
}
12 changes: 4 additions & 8 deletions app/src/main/java/com/tonyjhuang/cheddar/CheddarActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,19 @@
import android.support.v7.app.AppCompatActivity;
import android.widget.Toast;

import com.tonyjhuang.cheddar.api.CheddarApi;
import com.tonyjhuang.cheddar.ui.dialog.ChangelogDialog;
import com.tonyjhuang.cheddar.ui.dialog.ForceVersionUpdateDialog;
import com.tonyjhuang.cheddar.utils.Scheduler;
import com.tonyjhuang.cheddar.utils.VersionChecker;

import org.androidannotations.annotations.Bean;
import org.androidannotations.annotations.EActivity;

import timber.log.Timber;
import uk.co.chrisjenx.calligraphy.CalligraphyContextWrapper;

@EActivity(R.layout.activity_welcome)
@EActivity
public abstract class CheddarActivity extends AppCompatActivity {

@Bean
public CheddarApi api;

@Override
protected void attachBaseContext(Context newBase) {
super.attachBaseContext(CalligraphyContextWrapper.wrap(newBase));
Expand All @@ -34,8 +30,8 @@ protected void showChangeLog(CheddarPrefs_ prefs) {
}
}

protected void checkUpdate() {
api.checkVersionUpgrade().compose(Scheduler.defaultSchedulers())
protected void checkForUpdate(VersionChecker versionChecker) {
versionChecker.check().compose(Scheduler.defaultSchedulers())
.subscribe(shouldUpgrade -> {
if (shouldUpgrade) {
ForceVersionUpdateDialog.show(this);
Expand Down
12 changes: 1 addition & 11 deletions app/src/main/java/com/tonyjhuang/cheddar/api/CheddarApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import android.content.Context;

import com.crashlytics.android.Crashlytics;
import com.tonyjhuang.cheddar.BuildConfig;
import com.tonyjhuang.cheddar.CheddarPrefs_;
import com.tonyjhuang.cheddar.api.cache.CacheApi;
import com.tonyjhuang.cheddar.api.message.MessageApi;
Expand Down Expand Up @@ -195,7 +194,7 @@ public Observable<ChatRoom> getChatRoom(String chatRoomId) {

public Observable<Alias> joinGroupChatRoom() {
Observable<Alias> observable = getCurrentUser().map(User::objectId)
.flatMap(parseApi::joinGroupChatRoom)
.flatMap(currentUserId -> parseApi.joinGroupChatRoom(currentUserId, null))
.flatMap(cacheApi::persist)
.flatMap(alias -> Observable.defer(() ->
// Cache ChatRoom after joining.
Expand Down Expand Up @@ -366,15 +365,6 @@ public Observable<String> sendFeedback(String feedback) {
// Miscellaneous
//******************************************************

/**
* Do we need to force an upgrade?
*/
public Observable<Boolean> checkVersionUpgrade() {
return parseApi.getMinimumBuildNumber()
.map(minBuildNumber -> BuildConfig.VERSION_CODE < minBuildNumber)
.doOnError(Crashlytics::logException);
}

/**
* Send feedback that a user has requested their school to be supported.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class CacheApi {
(src, typeOfSrc, context) -> new JsonPrimitive(src.getTime());

private final Gson gson = new GsonBuilder()
.registerTypeAdapterFactory(new ValueTypeAdapterFactory())
.registerTypeAdapterFactory(ValueTypeAdapterFactory.create())
.registerTypeAdapter(Date.class, dateJsonSerializer)
.create();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public void errorCallback(String channel, PubnubError error) {
private static class PubnubObservableCallback extends Callback {

private Gson gson = new GsonBuilder()
.registerTypeAdapterFactory(new ValueTypeAdapterFactory())
.registerTypeAdapterFactory(ValueTypeAdapterFactory.create())
.registerTypeAdapter(MessageApiObjectHolder.class, new MessageApiDeserializer())
.registerTypeAdapter(ChatEvent.ChatEventType.class, ChatEvent.ChatEventType.DESERIALIZER)
.create();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,35 +1,12 @@
package com.tonyjhuang.cheddar.api.models.value;

import com.google.gson.Gson;
import com.google.gson.TypeAdapter;
import com.google.gson.TypeAdapterFactory;
import com.google.gson.reflect.TypeToken;
import com.ryanharter.auto.value.gson.GsonTypeAdapterFactory;

import java.lang.reflect.Method;
@GsonTypeAdapterFactory
public abstract class ValueTypeAdapterFactory implements TypeAdapterFactory {

/**
* Created by tonyjhuang on 4/27/16.
*/
public class ValueTypeAdapterFactory implements TypeAdapterFactory {

@SuppressWarnings("unchecked")
public <T> TypeAdapter<T> create(Gson gson, final TypeToken<T> type) {
Class<? super T> rawType = type.getRawType();
try {
if(rawType.equals(AutoValue_User.class)) {
return (TypeAdapter<T>) AutoValue_User.typeAdapter(gson);
} else if (rawType.equals(AutoValue_Alias.class)) {
return (TypeAdapter<T>) AutoValue_Alias.typeAdapter(gson);
} else if (rawType.equals(AutoValue_ChatEvent.class)) {
return (TypeAdapter<T>) AutoValue_ChatEvent.typeAdapter(gson);
}
// Call static typeAdapter method on class if it exists, otherwise
// return the default type adapter.
Method typeAdapterMethod = rawType.getDeclaredMethod("typeAdapter", Gson.class);
return (TypeAdapter<T>) typeAdapterMethod.invoke(null, gson);
} catch (Exception e) {
//Timber.v("couldn't invoke static typeAdapter method on " + rawType + ": " + e);
return gson.getDelegateAdapter(this, type).nullSafe();
}
public static TypeAdapterFactory create() {
return new AutoValueGson_ValueTypeAdapterFactory();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,9 @@ public Observable<ChatRoom> findChatRoom(String chatRoomId) {
/**
* Places the User into a new group ChatRoom.
*/
public Observable<Alias> joinGroupChatRoom(String userId) {
public Observable<Alias> joinGroupChatRoom(String userId, @Nullable String topic) {
JoinChatRoomRequest request =
new JoinChatRoomRequest(userId, GROUP_OCCUPANCY, SUBKEY, PUBKEY);
new JoinChatRoomRequest(userId, GROUP_OCCUPANCY, topic, SUBKEY, PUBKEY);
return service.joinChatRoom(request);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
public class JoinChatRoomRequest {
public String userId;
public int maxOccupancy;
public String topic;
public String subkey;
public String pubkey;

public JoinChatRoomRequest(String userId, int maxOccupancy, String subkey, String pubkey) {
public JoinChatRoomRequest(String userId, int maxOccupancy, String topic, String subkey, String pubkey) {
this.userId = userId;
this.maxOccupancy = maxOccupancy;
this.topic = topic;
this.subkey = subkey;
this.pubkey = pubkey;
}
Expand Down
Loading

0 comments on commit 0431e1d

Please sign in to comment.