Skip to content
This repository was archived by the owner on Jul 25, 2024. It is now read-only.

Commit 5ae66ca

Browse files
committed
Reformat code, Optimize Imports
1 parent 517a96f commit 5ae66ca

33 files changed

+202
-198
lines changed

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ android {
4343
buildTypes {
4444
debug {
4545
applicationIdSuffix '.dev'
46-
manifestPlaceholders = [ fabricKey : ""]
46+
manifestPlaceholders = [fabricKey: ""]
4747
ext.enableCrashlytics = false
4848
buildConfigField "String", "GOOGLE_CLIENT_ID", "\"835904834568-77mtr5mtmpgspj9b051del9i9r5t4g4n.apps.googleusercontent.com\""
4949
}

app/src/main/java/com/zulip/android/ZulipApp.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,10 +296,12 @@ public EventsBranch deserialize(JsonElement json, Type typeOfT, JsonDeserializat
296296
if (SubscriptionWrapper.OPERATION_ADD.equalsIgnoreCase(json.getAsJsonObject().get("op").getAsString()) ||
297297
SubscriptionWrapper.OPERATION_REMOVE.equalsIgnoreCase(json.getAsJsonObject().get("op").getAsString()) ||
298298
SubscriptionWrapper.OPERATION_UPDATE.equalsIgnoreCase(json.getAsJsonObject().get("op").getAsString())) {
299-
Type type = new TypeToken<SubscriptionWrapper<Stream>>(){}.getType();
299+
Type type = new TypeToken<SubscriptionWrapper<Stream>>() {
300+
}.getType();
300301
return nestedGson.fromJson(json, type);
301302
} else {
302-
Type type = new TypeToken<SubscriptionWrapper<String>>(){}.getType();
303+
Type type = new TypeToken<SubscriptionWrapper<String>>() {
304+
}.getType();
303305
return nestedGson.fromJson(json, type);
304306
}
305307
}

app/src/main/java/com/zulip/android/activities/DevAuthActivity.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.zulip.android.activities;
22

3-
import android.app.ProgressDialog;
43
import android.content.Intent;
54
import android.os.Bundle;
65
import android.support.v7.widget.LinearLayoutManager;

app/src/main/java/com/zulip/android/activities/MessageListFragment.java

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,23 @@ private Message getMessageById(int id) {
779779
return this.messageIndex.get(id);
780780
}
781781

782+
public void showLatestMessages() {
783+
if (listHasMostRecent()) {
784+
recyclerView.scrollToPosition(adapter.getItemCount() - 1);
785+
} else {
786+
loadMessageId(app.getMaxMessageId());
787+
}
788+
}
789+
790+
public boolean scrolledToLastMessage() {
791+
Object object = adapter.getItem(linearLayoutManager.findLastVisibleItemPosition());
792+
return object instanceof Message && (((Message) object).getId() >= app.getMaxMessageId() - 2);
793+
}
794+
795+
public RecyclerMessageAdapter getAdapter() {
796+
return this.adapter;
797+
}
798+
782799
/**
783800
* This interface must be implemented by activities that contain this
784801
* fragment to allow an interaction in this fragment to be communicated to
@@ -798,21 +815,4 @@ public interface Listener {
798815
void setLayoutBehaviour(LinearLayoutManager linearLayoutManager, RecyclerMessageAdapter adapter);
799816

800817
}
801-
802-
public void showLatestMessages() {
803-
if (listHasMostRecent()) {
804-
recyclerView.scrollToPosition(adapter.getItemCount() - 1);
805-
} else {
806-
loadMessageId(app.getMaxMessageId());
807-
}
808-
}
809-
810-
public boolean scrolledToLastMessage() {
811-
Object object = adapter.getItem(linearLayoutManager.findLastVisibleItemPosition());
812-
return object instanceof Message && (((Message) object).getId() >= app.getMaxMessageId() - 2);
813-
}
814-
815-
public RecyclerMessageAdapter getAdapter() {
816-
return this.adapter;
817-
}
818818
}

app/src/main/java/com/zulip/android/activities/RecyclerMessageAdapter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
import com.zulip.android.models.MessageType;
3333
import com.zulip.android.models.Person;
3434
import com.zulip.android.models.Stream;
35-
import com.zulip.android.util.ConvertDpPx;
3635
import com.zulip.android.util.ActivityTransitionAnim;
36+
import com.zulip.android.util.ConvertDpPx;
3737
import com.zulip.android.util.MutedTopics;
3838
import com.zulip.android.util.OnItemClickListener;
3939
import com.zulip.android.util.UrlHelper;

app/src/main/java/com/zulip/android/activities/ZulipActivity.java

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@
100100
import com.zulip.android.networking.response.UploadResponse;
101101
import com.zulip.android.util.ActivityTransitionAnim;
102102
import com.zulip.android.util.AnimationHelper;
103-
import com.zulip.android.util.Constants;
104103
import com.zulip.android.util.CommonProgressDialog;
104+
import com.zulip.android.util.Constants;
105105
import com.zulip.android.util.FilePathHelper;
106106
import com.zulip.android.util.MutedTopics;
107107
import com.zulip.android.util.RemoveViewsOnScroll;
@@ -152,7 +152,11 @@ public class ZulipActivity extends BaseActivity implements
152152
// row from the people
153153
final int allPeopleId = -1;
154154
public MessageListFragment currentList;
155+
public CommonProgressDialog commonProgressDialog;
155156
FloatingActionButton fab;
157+
NarrowFilter narrowFilter;
158+
String prevId = null;
159+
int prevMessageSameCount = -1;
156160
private ZulipApp app;
157161
private boolean logged_in = false;
158162
private boolean backPressedOnce = false;
@@ -167,7 +171,6 @@ public class ZulipActivity extends BaseActivity implements
167171
private AsyncGetEvents event_poll;
168172
private Handler statusUpdateHandler;
169173
private Runnable statusUpdateRunnable;
170-
public CommonProgressDialog commonProgressDialog;
171174
private int mToolbarHeightInPx;
172175
private int statusBarHeight = 0;
173176
private MessageListFragment narrowedList;
@@ -206,7 +209,7 @@ public void onReceive(Context contenxt, Intent intent) {
206209
private EditText etSearchStream;
207210
private ImageView ivSearchStreamCancel;
208211
private ListView peopleDrawer;
209-
private Toast toast;
212+
private Toast toast;
210213
//
211214
private String streamSearchFilterKeyword = "";
212215
private SimpleCursorAdapter.ViewBinder peopleBinder = new SimpleCursorAdapter.ViewBinder() {
@@ -1107,7 +1110,7 @@ public void onClick(View view) {
11071110
*/
11081111
private void showSoftKeyboard() {
11091112
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
1110-
imm.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT,InputMethodManager.HIDE_IMPLICIT_ONLY);
1113+
imm.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, InputMethodManager.HIDE_IMPLICIT_ONLY);
11111114
}
11121115

11131116
private void displayChatBox(boolean show) {
@@ -1695,7 +1698,7 @@ public void onBackPressed() {
16951698
drawerLayout.closeDrawers();
16961699
return;
16971700
}
1698-
//check for narrowed or not
1701+
//check for narrowed or not
16991702
if (narrowedList == null) {
17001703

17011704
if (backPressedOnce) {
@@ -1750,7 +1753,8 @@ private void dismissToast() {
17501753

17511754
/**
17521755
* If previous toast is showing cancel it and show new one
1753-
* @param string message in the toast
1756+
*
1757+
* @param string message in the toast
17541758
* @param duration of the toast to be shown
17551759
*/
17561760
private void showToast(String string, int duration) {
@@ -1816,7 +1820,7 @@ private void narrowPMWith(final Person person) {
18161820
if (!person.getEmail().equals(app.getYou().getEmail()))
18171821
list.add(app.getYou());
18181822
doNarrow(new NarrowFilterPM(list));
1819-
onNarrowFillSendBoxPrivate(new Person[]{person},false);
1823+
onNarrowFillSendBoxPrivate(new Person[]{person}, false);
18201824
}
18211825

18221826
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@@ -1856,7 +1860,8 @@ public void doNarrow(NarrowFilter filter) {
18561860
/**
18571861
* This method creates a new Instance of the MessageListFragment and displays it with the filter
18581862
* whiling keeping the view anchored at {@param messageId}.
1859-
* @param filter NarrowFilter passed
1863+
*
1864+
* @param filter NarrowFilter passed
18601865
* @param messageId used as anchor for fetching messages
18611866
*/
18621867
public void doNarrow(NarrowFilter filter, int messageId) {
@@ -1942,7 +1947,6 @@ public void onNarrow(NarrowFilter narrowFilter) {
19421947
}
19431948
}
19441949

1945-
19461950
public void onNarrow(NarrowFilter narrowFilter, int messageId) {
19471951
if (narrowedList == null || !narrowedList.filter.equals(narrowFilter)) {
19481952
doNarrow(narrowFilter, messageId);
@@ -2134,7 +2138,7 @@ private void setNightMode(@AppCompatDelegate.NightMode int nightMode) {
21342138
private void logout() {
21352139
commonProgressDialog.showWithMessage(getString(R.string.logging_out));
21362140
this.logged_in = false;
2137-
final String serverUrl = app.getServerHostUri() ;
2141+
final String serverUrl = app.getServerHostUri();
21382142

21392143
notifications.logOut(new Runnable() {
21402144
public void run() {
@@ -2277,9 +2281,6 @@ private void setupSnackBar() {
22772281
coordinatorLayout.addView(topSnackBar.getLinearLayout());
22782282
}
22792283

2280-
NarrowFilter narrowFilter;
2281-
String prevId = null;
2282-
int prevMessageSameCount = -1;
22832284
private void showSnackbarNotification(Message[] messages) {
22842285
MutedTopics mutedTopics = MutedTopics.get();
22852286
String notificationMessage;
@@ -2321,7 +2322,7 @@ public void onClick(View view) {
23212322
});
23222323
} else {
23232324
if (messages.length == 1) tempMessage = messages[0];
2324-
String name = (tempMessage.getType() == MessageType.PRIVATE_MESSAGE) ? getString(R.string.notify_private, tempMessage.getSenderFullName()) : getString(R.string.notify_stream, tempMessage.getStream().getName() , tempMessage.getSubject());
2325+
String name = (tempMessage.getType() == MessageType.PRIVATE_MESSAGE) ? getString(R.string.notify_private, tempMessage.getSenderFullName()) : getString(R.string.notify_stream, tempMessage.getStream().getName(), tempMessage.getSubject());
23252326
if (prevMessageSameCount > 0) name += " (" + prevMessageSameCount + ")";
23262327
notificationMessage = getResources().getQuantityString(R.plurals.new_message, nonMutedMessagesCount, nonMutedMessagesCount, name);
23272328
narrowFilter = (tempMessage.getType() == MessageType.PRIVATE_MESSAGE) ? new NarrowFilterPM(Arrays.asList(tempMessage.getRecipients(app))) : new NarrowFilterStream(tempMessage.getStream(), tempMessage.getSubject());
@@ -2336,11 +2337,6 @@ public void onClick(View view) {
23362337
topSnackBar.show((appBarLayout.getVisibility() == View.GONE) ? statusBarHeight : statusBarHeight + mToolbarHeightInPx, notificationMessage, TopSnackBar.LENGTH_LONG);
23372338
}
23382339

2339-
// Intent Extra constants
2340-
public enum Flag {
2341-
RESET_DATABASE,
2342-
}
2343-
23442340
/**
23452341
* Get current message list fragment.
23462342
*
@@ -2353,4 +2349,9 @@ public MessageListFragment getCurrentMessageList() {
23532349
return narrowedList;
23542350
}
23552351
}
2352+
2353+
// Intent Extra constants
2354+
public enum Flag {
2355+
RESET_DATABASE,
2356+
}
23562357
}

app/src/main/java/com/zulip/android/filters/NarrowFilterByDate.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ public NarrowFilterByDate[] newArray(int size) {
2929
return new NarrowFilterByDate[size];
3030
}
3131
};
32-
private Date date = new Date();
3332
private static Calendar calendar = Calendar.getInstance();
3433
private static Calendar calendar2 = Calendar.getInstance();
34+
private Date date = new Date();
3535

3636
public NarrowFilterByDate() {
3737
}
@@ -40,6 +40,20 @@ public NarrowFilterByDate(Date date) {
4040
this.date = date;
4141
}
4242

43+
/**
44+
* Checks two dates are of same day or not
45+
*
46+
* @param date1 Date date1 to be compared with date2
47+
* @param date2 Date date2 to be compared with date1
48+
* @return boolean
49+
*/
50+
private static boolean isSameDay(Date date1, Date date2) {
51+
calendar.setTime(date1);
52+
calendar2.setTime(date2);
53+
return calendar.get(Calendar.YEAR) == calendar2.get(Calendar.YEAR) &&
54+
calendar.get(Calendar.DAY_OF_YEAR) == calendar2.get(Calendar.DAY_OF_YEAR);
55+
}
56+
4357
public int describeContents() {
4458
return 0;
4559
}
@@ -116,18 +130,4 @@ public boolean equals(NarrowFilter filter) {
116130
public String toString() {
117131
return "{}";
118132
}
119-
120-
/**
121-
* Checks two dates are of same day or not
122-
*
123-
* @param date1 Date date1 to be compared with date2
124-
* @param date2 Date date2 to be compared with date1
125-
* @return boolean
126-
*/
127-
private static boolean isSameDay(Date date1, Date date2) {
128-
calendar.setTime(date1);
129-
calendar2.setTime(date2);
130-
return calendar.get(Calendar.YEAR) == calendar2.get(Calendar.YEAR) &&
131-
calendar.get(Calendar.DAY_OF_YEAR) == calendar2.get(Calendar.DAY_OF_YEAR);
132-
}
133133
}

app/src/main/java/com/zulip/android/models/Message.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public class Message {
8282
@SerializedName("client")
8383
private String client;
8484

85-
// @SerializedName("type")
85+
// @SerializedName("type")
8686
// private String _internal_type;
8787
@SerializedName("content_type")
8888
private String contentType;

app/src/main/java/com/zulip/android/models/Person.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ public static Person getOrUpdate(ZulipApp app, String email, String name,
176176
* It is used to get current user person {@link Person} object if it exists in the database
177177
* or create a new object using {@param email}.
178178
*
179-
* @param app {@link ZulipApp}
179+
* @param app {@link ZulipApp}
180180
* @param email Person email id {@link Person#email}
181181
* @return {@link Person} object
182182
*/
@@ -194,13 +194,13 @@ public static Person get(ZulipApp app, String email) {
194194
* with no cache.
195195
* Note: always call this method with valid Person id {@link Person#id} passed as argument.
196196
*
197-
* @param app Zulip god object {@link ZulipApp}
198-
* @param email person email {@link Person#email}
199-
* @param name person name {@link Person#name}
197+
* @param app Zulip god object {@link ZulipApp}
198+
* @param email person email {@link Person#email}
199+
* @param name person name {@link Person#name}
200200
* @param avatarURL person avatar url {@link Person#avatarURL}
201-
* @param personId person id {@link Person#id}
201+
* @param personId person id {@link Person#id}
202202
* @return {@link Person} object
203-
* */
203+
*/
204204
public static Person getOrUpdate(ZulipApp app, String email, String name,
205205
String avatarURL, int personId) {
206206
return getOrUpdate(app, email, name, avatarURL, personId, null);

0 commit comments

Comments
 (0)