Commit 6007fd56 authored by Yusuke Iwaki's avatar Yusuke Iwaki

reformat with SquareAndroid plugin for Android Studio (google-java-formatter didn't work properly!)

parent 352f0c01
<lint>
<issue id="InvalidPackage">
<ignore regexp="okio.*jar" />
<ignore regexp="okio.*jar"/>
</issue>
</lint>
\ No newline at end of file
......@@ -5,23 +5,26 @@
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<application
android:name=".RocketChatApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:name=".RocketChatApplication">
android:theme="@style/AppTheme">
<activity android:name=".activity.MainActivity"
<activity
android:name=".activity.MainActivity"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name=".activity.ServerConfigActivity"
<activity
android:name=".activity.ServerConfigActivity"
android:windowSoftInputMode="adjustResize"/>
<service android:name=".service.RocketChatService"/>
......
......@@ -2,7 +2,6 @@ package chat.rocket.android;
import android.content.Context;
import android.content.Intent;
import chat.rocket.android.activity.ServerConfigActivity;
/**
......
package chat.rocket.android;
import android.app.Application;
import com.facebook.stetho.Stetho;
import com.uphyca.stetho_realm.RealmInspectorModulesProvider;
import io.realm.Realm;
import io.realm.RealmConfiguration;
import timber.log.Timber;
......@@ -13,19 +11,16 @@ import timber.log.Timber;
* Customized Application-class for Rocket.Chat
*/
public class RocketChatApplication extends Application {
@Override
public void onCreate() {
@Override public void onCreate() {
super.onCreate();
Timber.plant(new Timber.DebugTree());
Realm.init(this);
Realm.setDefaultConfiguration(new RealmConfiguration.Builder()
.deleteRealmIfMigrationNeeded()
.build());
Realm.setDefaultConfiguration(
new RealmConfiguration.Builder().deleteRealmIfMigrationNeeded().build());
Stetho.initialize(
Stetho.newInitializerBuilder(this)
Stetho.initialize(Stetho.newInitializerBuilder(this)
.enableDumpapp(Stetho.defaultDumperPluginsProvider(this))
.enableWebKitInspector(RealmInspectorModulesProvider.builder(this).build())
.build());
......
package chat.rocket.android.activity;
import android.support.v7.app.AppCompatActivity;
import java.util.List;
import java.util.UUID;
import chat.rocket.android.helper.LogcatIfError;
import chat.rocket.android.model.ServerConfig;
import chat.rocket.android.service.RocketChatService;
import io.realm.Realm;
import io.realm.RealmResults;
import java.util.List;
import java.util.UUID;
import jp.co.crowdworks.realm_java_helpers.RealmListObserver;
import jp.co.crowdworks.realm_java_helpers_bolts.RealmHelperBolts;
abstract class AbstractAuthedActivity extends AppCompatActivity {
private RealmListObserver<ServerConfig> mInsertEmptyRecordIfNoConfigurationExists =
private RealmListObserver<ServerConfig> serverConfigEmptinessObserver =
new RealmListObserver<ServerConfig>() {
@Override
protected RealmResults<ServerConfig> queryItems(Realm realm) {
@Override protected RealmResults<ServerConfig> queryItems(Realm realm) {
return realm.where(ServerConfig.class).findAll();
}
@Override
protected void onCollectionChanged(List<ServerConfig> list) {
@Override protected void onCollectionChanged(List<ServerConfig> list) {
if (list.isEmpty()) {
final String newId = UUID.randomUUID().toString();
RealmHelperBolts
.executeTransaction(realm ->
realm.createObject(ServerConfig.class, newId))
RealmHelperBolts.executeTransaction(
realm -> realm.createObject(ServerConfig.class, newId))
.continueWith(new LogcatIfError());
}
}
};
private RealmListObserver<ServerConfig> mShowConfigActivityIfNeeded =
private RealmListObserver<ServerConfig> loginRequiredServerConfigObserver =
new RealmListObserver<ServerConfig>() {
@Override
protected RealmResults<ServerConfig> queryItems(Realm realm) {
@Override protected RealmResults<ServerConfig> queryItems(Realm realm) {
return ServerConfig.queryLoginRequiredConnections(realm).findAll();
}
@Override
protected void onCollectionChanged(List<ServerConfig> list) {
@Override protected void onCollectionChanged(List<ServerConfig> list) {
ServerConfigActivity.launchFor(AbstractAuthedActivity.this, list);
}
};
@Override
protected void onResume() {
@Override protected void onResume() {
super.onResume();
RocketChatService.keepalive(this);
mInsertEmptyRecordIfNoConfigurationExists.sub();
mShowConfigActivityIfNeeded.sub();
serverConfigEmptinessObserver.sub();
loginRequiredServerConfigObserver.sub();
}
@Override
protected void onPause() {
mShowConfigActivityIfNeeded.unsub();
mInsertEmptyRecordIfNoConfigurationExists.unsub();
@Override protected void onPause() {
loginRequiredServerConfigObserver.unsub();
serverConfigEmptinessObserver.unsub();
super.onPause();
}
}
......@@ -3,22 +3,22 @@ package chat.rocket.android.activity;
import android.support.annotation.IdRes;
import android.support.v4.app.Fragment;
import android.support.v7.app.AppCompatActivity;
import chat.rocket.android.helper.OnBackPressListener;
abstract class AbstractFragmentActivity extends AppCompatActivity {
protected abstract @IdRes int getLayoutContainerForFragment();
@Override
public void onBackPressed() {
@Override public void onBackPressed() {
Fragment fragment =
getSupportFragmentManager().findFragmentById(getLayoutContainerForFragment());
if (fragment instanceof OnBackPressListener
&& ((OnBackPressListener) fragment).onBackPressed()) {
//consumed. do nothing.
} else super.onBackPressed();
} else {
super.onBackPressed();
}
}
protected void showFragment(Fragment fragment) {
......
......@@ -2,7 +2,6 @@ package chat.rocket.android.activity;
import android.os.Bundle;
import android.support.annotation.Nullable;
import chat.rocket.android.R;
import chat.rocket.android.helper.LogcatIfError;
import chat.rocket.android.model.ServerConfig;
......@@ -12,14 +11,13 @@ import jp.co.crowdworks.realm_java_helpers_bolts.RealmHelperBolts;
* Entry-point for Rocket.Chat.Android application.
*/
public class MainActivity extends AbstractAuthedActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
@Override protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
if (savedInstanceState == null) {
RealmHelperBolts.executeTransaction(realm -> {
for (ServerConfig config: ServerConfig.queryActiveConnections(realm).findAll()) {
for (ServerConfig config : ServerConfig.queryActiveConnections(realm).findAll()) {
config.setTokenVerified(false);
}
return null;
......
......@@ -5,9 +5,6 @@ import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import java.util.List;
import chat.rocket.android.LaunchUtil;
import chat.rocket.android.R;
import chat.rocket.android.fragment.server_config.ConnectingToHostFragment;
......@@ -19,6 +16,7 @@ import chat.rocket.android.service.RocketChatService;
import io.realm.Realm;
import io.realm.RealmList;
import io.realm.RealmQuery;
import java.util.List;
import jp.co.crowdworks.realm_java_helpers.RealmObjectObserver;
/**
......@@ -26,21 +24,14 @@ import jp.co.crowdworks.realm_java_helpers.RealmObjectObserver;
*/
public class ServerConfigActivity extends AbstractFragmentActivity {
@Override
protected int getLayoutContainerForFragment() {
return R.id.content;
}
private String mServerConfigId;
private RealmObjectObserver<ServerConfig> mServerConfigObserver =
new RealmObjectObserver<ServerConfig>() {
@Override
protected RealmQuery<ServerConfig> query(Realm realm) {
@Override protected RealmQuery<ServerConfig> query(Realm realm) {
return realm.where(ServerConfig.class).equalTo("id", mServerConfigId);
}
@Override
protected void onChange(ServerConfig config) {
@Override protected void onChange(ServerConfig config) {
onRenderServerConfig(config);
}
};
......@@ -49,7 +40,7 @@ public class ServerConfigActivity extends AbstractFragmentActivity {
* Start the ServerConfigActivity with considering the priority of ServerConfig in the list.
*/
public static boolean launchFor(Context context, List<ServerConfig> configList) {
for (ServerConfig config: configList) {
for (ServerConfig config : configList) {
if (TextUtils.isEmpty(config.getHostname())) {
return launchFor(context, config);
} else if (!TextUtils.isEmpty(config.getConnectionError())) {
......@@ -57,25 +48,25 @@ public class ServerConfigActivity extends AbstractFragmentActivity {
}
}
for (ServerConfig config: configList) {
for (ServerConfig config : configList) {
if (config.getAuthProviders().isEmpty()) {
return launchFor(context, config);
}
}
for (ServerConfig config: configList) {
for (ServerConfig config : configList) {
if (TextUtils.isEmpty(config.getSelectedProviderName())) {
return launchFor(context, config);
}
}
for (ServerConfig config: configList) {
for (ServerConfig config : configList) {
if (TextUtils.isEmpty(config.getToken())) {
return launchFor(context, config);
}
}
for (ServerConfig config: configList) {
for (ServerConfig config : configList) {
if (!config.isTokenVerified()) {
return launchFor(context, config);
}
......@@ -89,9 +80,11 @@ public class ServerConfigActivity extends AbstractFragmentActivity {
return true;
}
@Override protected int getLayoutContainerForFragment() {
return R.id.content;
}
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
@Override protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = getIntent();
......@@ -109,15 +102,13 @@ public class ServerConfigActivity extends AbstractFragmentActivity {
setContentView(R.layout.simple_screen);
}
@Override
protected void onResume() {
@Override protected void onResume() {
super.onResume();
RocketChatService.keepalive(this);
mServerConfigObserver.sub();
}
@Override
protected void onPause() {
@Override protected void onPause() {
mServerConfigObserver.unsub();
super.onPause();
}
......@@ -160,27 +151,26 @@ public class ServerConfigActivity extends AbstractFragmentActivity {
showFragment(new InputHostnameFragment());
}
@Override
protected void showFragment(Fragment fragment) {
@Override protected void showFragment(Fragment fragment) {
injectIdArgTo(fragment);
super.showFragment(fragment);
}
@Override
protected void showFragmentWithBackStack(Fragment fragment) {
@Override protected void showFragmentWithBackStack(Fragment fragment) {
injectIdArgTo(fragment);
super.showFragmentWithBackStack(fragment);
}
private void injectIdArgTo(Fragment fragment) {
Bundle args = fragment.getArguments();
if (args == null) args = new Bundle();
if (args == null) {
args = new Bundle();
}
args.putString("id", mServerConfigId);
fragment.setArguments(args);
}
@Override
public void onBackPressed() {
@Override public void onBackPressed() {
if (ServerConfig.hasActiveConnection()) {
super.onBackPressed();
} else {
......
......@@ -13,13 +13,13 @@ import android.view.ViewGroup;
*/
public abstract class AbstractFragment extends Fragment {
protected View mRootView;
protected abstract @LayoutRes int getLayout();
protected abstract void onSetupView();
@Nullable
@Override
public View onCreateView(LayoutInflater inflater,
@Nullable ViewGroup container,
@Nullable @Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
mRootView = inflater.inflate(getLayout(), container, false);
onSetupView();
......
......@@ -2,15 +2,13 @@ package chat.rocket.android.fragment.server_config;
import android.os.Bundle;
import android.support.annotation.Nullable;
import chat.rocket.android.fragment.AbstractFragment;
import chat.rocket.android.helper.TextUtils;
abstract class AbstractServerConfigFragment extends AbstractFragment {
protected String mServerConfigId;
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
@Override public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Bundle args = getArguments();
......
......@@ -6,13 +6,11 @@ import chat.rocket.android.R;
* Just showing "connecting..." screen.
*/
public class ConnectingToHostFragment extends AbstractServerConfigFragment {
@Override
protected int getLayout() {
@Override protected int getLayout() {
return R.layout.fragment_wait_for_connection;
}
@Override
protected void onSetupView() {
@Override protected void onSetupView() {
}
}
......@@ -4,9 +4,6 @@ import android.os.Handler;
import android.os.Message;
import android.widget.TextView;
import android.widget.Toast;
import org.json.JSONObject;
import chat.rocket.android.R;
import chat.rocket.android.helper.LogcatIfError;
import chat.rocket.android.helper.TextUtils;
......@@ -15,32 +12,35 @@ import io.realm.Realm;
import io.realm.RealmQuery;
import jp.co.crowdworks.realm_java_helpers.RealmObjectObserver;
import jp.co.crowdworks.realm_java_helpers_bolts.RealmHelperBolts;
import org.json.JSONObject;
/**
* Input server host.
*/
public class InputHostnameFragment extends AbstractServerConfigFragment {
public InputHostnameFragment(){}
@Override
protected int getLayout() {
return R.layout.fragment_input_hostname;
private Handler mShowError = new Handler() {
@Override public void handleMessage(Message msg) {
Toast.makeText(mRootView.getContext(), (String) msg.obj, Toast.LENGTH_SHORT).show();
}
};
RealmObjectObserver<ServerConfig> mObserver = new RealmObjectObserver<ServerConfig>() {
@Override
protected RealmQuery<ServerConfig> query(Realm realm) {
@Override protected RealmQuery<ServerConfig> query(Realm realm) {
return realm.where(ServerConfig.class).equalTo("id", mServerConfigId);
}
@Override
protected void onChange(ServerConfig config) {
@Override protected void onChange(ServerConfig config) {
onRenderServerConfig(config);
}
};
@Override
protected void onSetupView() {
public InputHostnameFragment() {
}
@Override protected int getLayout() {
return R.layout.fragment_input_hostname;
}
@Override protected void onSetupView() {
mRootView.findViewById(R.id.btn_connect).setOnClickListener(view -> handleConnect());
mObserver.sub();
......@@ -49,38 +49,26 @@ public class InputHostnameFragment extends AbstractServerConfigFragment {
private void handleConnect() {
final TextView editor = (TextView) mRootView.findViewById(R.id.editor_hostname);
final String hostname = TextUtils.or(
TextUtils.or(editor.getText(), editor.getHint()),
"").toString();
final String hostname =
TextUtils.or(TextUtils.or(editor.getText(), editor.getHint()), "").toString();
RealmHelperBolts
.executeTransaction(realm ->
realm.createOrUpdateObjectFromJson(ServerConfig.class, new JSONObject()
.put("id", mServerConfigId)
RealmHelperBolts.executeTransaction(
realm -> realm.createOrUpdateObjectFromJson(ServerConfig.class,
new JSONObject().put("id", mServerConfigId)
.put("hostname", hostname)
.put("connectionError", JSONObject.NULL)))
.continueWith(new LogcatIfError());
.put("connectionError", JSONObject.NULL))).continueWith(new LogcatIfError());
}
@Override
public void onResume() {
@Override public void onResume() {
super.onResume();
mObserver.keepalive();
}
@Override
public void onDestroyView() {
@Override public void onDestroyView() {
mObserver.unsub();
super.onDestroyView();
}
private Handler mShowError = new Handler() {
@Override
public void handleMessage(Message msg) {
Toast.makeText(mRootView.getContext(), (String) msg.obj, Toast.LENGTH_SHORT).show();
}
};
private void showError(String errString) {
mShowError.removeMessages(0);
Message msg = Message.obtain(mShowError, 0, errString);
......@@ -90,7 +78,9 @@ public class InputHostnameFragment extends AbstractServerConfigFragment {
private void onRenderServerConfig(ServerConfig config) {
final TextView editor = (TextView) mRootView.findViewById(R.id.editor_hostname);
if (!TextUtils.isEmpty(config.getHostname())) editor.setText(config.getHostname());
if (!TextUtils.isEmpty(config.getHostname())) {
editor.setText(config.getHostname());
}
if (!TextUtils.isEmpty(config.getConnectionError())) {
clearConnectionErrorAndHostname();
showError(config.getConnectionError());
......@@ -98,12 +88,10 @@ public class InputHostnameFragment extends AbstractServerConfigFragment {
}
private void clearConnectionErrorAndHostname() {
RealmHelperBolts
.executeTransaction(realm ->
realm.createOrUpdateObjectFromJson(ServerConfig.class, new JSONObject()
.put("id", mServerConfigId)
RealmHelperBolts.executeTransaction(
realm -> realm.createOrUpdateObjectFromJson(ServerConfig.class,
new JSONObject().put("id", mServerConfigId)
.put("hostname", JSONObject.NULL)
.put("connectionError", JSONObject.NULL)))
.continueWith(new LogcatIfError());
.put("connectionError", JSONObject.NULL))).continueWith(new LogcatIfError());
}
}
......@@ -8,8 +8,7 @@ import timber.log.Timber;
* Bolts-Task continuation for just logging if error occurred.
*/
public class LogcatIfError implements Continuation {
@Override
public Object then(Task task) throws Exception {
@Override public Object then(Task task) throws Exception {
if (task.isFaulted()) {
Timber.w(task.getError());
}
......
package chat.rocket.android.helper;
import com.facebook.stetho.okhttp3.StethoInterceptor;
import java.util.concurrent.TimeUnit;
import okhttp3.OkHttpClient;
/**
......@@ -18,8 +15,7 @@ public class OkHttpHelper {
*/
public static OkHttpClient getClientForWebSocket() {
if (sHttpClientForWS == null) {
sHttpClientForWS = new OkHttpClient.Builder()
.readTimeout(0, TimeUnit.NANOSECONDS)
sHttpClientForWS = new OkHttpClient.Builder().readTimeout(0, TimeUnit.NANOSECONDS)
.addNetworkInterceptor(new StethoInterceptor())
.build();
}
......
......@@ -7,6 +7,7 @@ public class TextUtils {
/**
* Returns true if the string is null or 0-length.
*
* @param str the string to be examined
* @return true if str is null or zero length
*/
......@@ -18,9 +19,11 @@ public class TextUtils {
/**
* Returns str if it is not empty; otherwise defaultValue is returned.
*/
@SuppressWarnings("PMD.ShortMethodName")
public static CharSequence or(CharSequence str, CharSequence defaultValue) {
if (isEmpty(str)) return defaultValue;
@SuppressWarnings("PMD.ShortMethodName") public static CharSequence or(CharSequence str,
CharSequence defaultValue) {
if (isEmpty(str)) {
return defaultValue;
}
return str;
}
}
......@@ -6,10 +6,9 @@ import io.realm.annotations.PrimaryKey;
/**
* subscription model for "meteor_accounts_loginServiceConfiguration"
*/
@SuppressWarnings("PMD.ShortVariable")
public class MeteorLoginServiceConfiguration extends RealmObject {
@PrimaryKey
private String id;
@SuppressWarnings("PMD.ShortVariable") public class MeteorLoginServiceConfiguration
extends RealmObject {
@PrimaryKey private String id;
private String service;
private String consumerKey; //for Twitter
private String appId; //for Facebook
......
package chat.rocket.android.model;
import org.json.JSONObject;
import chat.rocket.android.helper.LogcatIfError;
import hugo.weaving.DebugLog;
import io.realm.Realm;
......@@ -11,14 +9,13 @@ import io.realm.RealmQuery;
import io.realm.annotations.PrimaryKey;
import jp.co.crowdworks.realm_java_helpers.RealmHelper;
import jp.co.crowdworks.realm_java_helpers_bolts.RealmHelperBolts;
import org.json.JSONObject;
/**
* Server configuration
*/
@SuppressWarnings("PMD.ShortVariable")
public class ServerConfig extends RealmObject {
@PrimaryKey
private String id;
@SuppressWarnings("PMD.ShortVariable") public class ServerConfig extends RealmObject {
@PrimaryKey private String id;
private String hostname;
private String connectionError;
private String token;
......@@ -26,6 +23,28 @@ public class ServerConfig extends RealmObject {
private RealmList<MeteorLoginServiceConfiguration> authProviders;
private String selectedProviderName;
public static RealmQuery<ServerConfig> queryLoginRequiredConnections(Realm realm) {
return realm.where(ServerConfig.class).equalTo("tokenVerified", false);
}
public static RealmQuery<ServerConfig> queryActiveConnections(Realm realm) {
return realm.where(ServerConfig.class).isNotNull("token");
}
public static boolean hasActiveConnection() {
ServerConfig config =
RealmHelper.executeTransactionForRead(realm -> queryActiveConnections(realm).findFirst());
return config != null;
}
@DebugLog public static void logError(String id, Exception exception) {
RealmHelperBolts.executeTransaction(
realm -> realm.createOrUpdateObjectFromJson(ServerConfig.class,
new JSONObject().put("id", id).put("connectionError", exception.getMessage())))
.continueWith(new LogcatIfError());
}
public String getId() {
return id;
}
......@@ -81,31 +100,4 @@ public class ServerConfig extends RealmObject {
public void setSelectedProviderName(String selectedProviderName) {
this.selectedProviderName = selectedProviderName;
}
public static RealmQuery<ServerConfig> queryLoginRequiredConnections(Realm realm) {
return realm.where(ServerConfig.class)
.equalTo("tokenVerified", false);
}
public static RealmQuery<ServerConfig> queryActiveConnections(Realm realm) {
return realm.where(ServerConfig.class)
.isNotNull("token");
}
public static boolean hasActiveConnection() {
ServerConfig config = RealmHelper.executeTransactionForRead(realm ->
queryActiveConnections(realm).findFirst());
return config != null;
}
@DebugLog
public static void logError(String id, Exception exception) {
RealmHelperBolts
.executeTransaction(realm ->
realm.createOrUpdateObjectFromJson(ServerConfig.class, new JSONObject()
.put("id", id)
.put("connectionError", exception.getMessage())))
.continueWith(new LogcatIfError());
}
}
......@@ -5,16 +5,14 @@ import android.content.Context;
import android.content.Intent;
import android.os.IBinder;
import android.support.annotation.Nullable;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import bolts.Task;
import chat.rocket.android.model.ServerConfig;
import io.realm.Realm;
import io.realm.RealmResults;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import jp.co.crowdworks.realm_java_helpers.RealmListObserver;
/**
......@@ -22,6 +20,21 @@ import jp.co.crowdworks.realm_java_helpers.RealmListObserver;
*/
public class RocketChatService extends Service {
private HashMap<String, RocketChatWebSocketThread> mWebSocketThreads;
private RealmListObserver<ServerConfig> mConnectionRequiredServerConfigObserver =
new RealmListObserver<ServerConfig>() {
@Override protected RealmResults<ServerConfig> queryItems(Realm realm) {
return realm.where(ServerConfig.class)
.isNotNull("hostname")
.isNull("connectionError")
.findAll();
}
@Override protected void onCollectionChanged(List<ServerConfig> list) {
syncWebSocketThreadsWith(list);
}
};
/**
* ensure RocketChatService alive.
*/
......@@ -36,31 +49,12 @@ public class RocketChatService extends Service {
context.stopService(new Intent(context, RocketChatService.class));
}
private HashMap<String, RocketChatWebSocketThread> mWebSocketThreads;
private RealmListObserver<ServerConfig> mConnectionRequiredServerConfigObserver =
new RealmListObserver<ServerConfig>() {
@Override
protected RealmResults<ServerConfig> queryItems(Realm realm) {
return realm.where(ServerConfig.class)
.isNotNull("hostname")
.isNull("connectionError")
.findAll();
}
@Override
protected void onCollectionChanged(List<ServerConfig> list) {
syncWebSocketThreadsWith(list);
}
};
@Override
public void onCreate() {
@Override public void onCreate() {
super.onCreate();
mWebSocketThreads = new HashMap<>();
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
@Override public int onStartCommand(Intent intent, int flags, int startId) {
mConnectionRequiredServerConfigObserver.keepalive();
return START_STICKY;
}
......@@ -73,7 +67,7 @@ public class RocketChatService extends Service {
Map.Entry<String, RocketChatWebSocketThread> entry = iterator.next();
String serverConfigId = entry.getKey();
boolean found = false;
for (ServerConfig config: configList) {
for (ServerConfig config : configList) {
if (serverConfigId.equals(config.getId())) {
found = true;
break;
......@@ -85,7 +79,7 @@ public class RocketChatService extends Service {
}
}
for (ServerConfig config: configList) {
for (ServerConfig config : configList) {
findOrCreateWebSocketThread(config).onSuccess(task -> {
RocketChatWebSocketThread thread = task.getResult();
thread.syncStateWith(config);
......@@ -107,9 +101,7 @@ public class RocketChatService extends Service {
}
}
@Nullable
@Override
public IBinder onBind(Intent intent) {
@Nullable @Override public IBinder onBind(Intent intent) {
return null;
}
}
......@@ -3,11 +3,6 @@ package chat.rocket.android.service;
import android.content.Context;
import android.os.Handler;
import android.os.HandlerThread;
import java.lang.reflect.Constructor;
import java.util.ArrayList;
import java.util.Iterator;
import bolts.Task;
import bolts.TaskCompletionSource;
import chat.rocket.android.helper.TextUtils;
......@@ -16,6 +11,9 @@ import chat.rocket.android.service.ddp_subscriber.LoginServiceConfigurationSubsc
import chat.rocket.android.ws.RocketChatWebSocketAPI;
import chat.rocket.android_ddp.DDPClient;
import hugo.weaving.DebugLog;
import java.lang.reflect.Constructor;
import java.util.ArrayList;
import java.util.Iterator;
import jp.co.crowdworks.realm_java_helpers.RealmHelper;
import timber.log.Timber;
......@@ -23,8 +21,12 @@ import timber.log.Timber;
* Thread for handling WebSocket connection.
*/
public class RocketChatWebSocketThread extends HandlerThread {
private static final Class[] REGISTERABLE_CLASSES = {
LoginServiceConfigurationSubscriber.class
};
private final Context mAppContext;
private final String mServerConfigId;
private final ArrayList<Registerable> mListeners = new ArrayList<>();
private RocketChatWebSocketAPI mWebSocketAPI;
private boolean mSocketExists;
private boolean mListenersRegistered;
......@@ -38,13 +40,11 @@ public class RocketChatWebSocketThread extends HandlerThread {
/**
* create new Thread.
*/
@DebugLog
public static Task<RocketChatWebSocketThread> getStarted(Context appContext,
@DebugLog public static Task<RocketChatWebSocketThread> getStarted(Context appContext,
ServerConfig config) {
TaskCompletionSource<RocketChatWebSocketThread> task = new TaskCompletionSource<>();
new RocketChatWebSocketThread(appContext, config.getId()){
@Override
protected void onLooperPrepared() {
new RocketChatWebSocketThread(appContext, config.getId()) {
@Override protected void onLooperPrepared() {
try {
super.onLooperPrepared();
task.setResult(this);
......@@ -59,8 +59,7 @@ public class RocketChatWebSocketThread extends HandlerThread {
/**
* terminate the thread
*/
@DebugLog
public static void terminate(RocketChatWebSocketThread thread) {
@DebugLog public static void terminate(RocketChatWebSocketThread thread) {
thread.quit();
}
......@@ -75,36 +74,30 @@ public class RocketChatWebSocketThread extends HandlerThread {
/**
* synchronize the state of the thread with ServerConfig.
*/
@DebugLog
public void syncStateWith(ServerConfig config) {
if (config == null
|| TextUtils.isEmpty(config.getHostname())
|| !TextUtils.isEmpty(config.getConnectionError())) {
@DebugLog public void syncStateWith(ServerConfig config) {
if (config == null || TextUtils.isEmpty(config.getHostname()) || !TextUtils.isEmpty(
config.getConnectionError())) {
quit();
} else {
ensureConnection()
.continueWith(task -> {
ensureConnection().continueWith(task -> {
new Handler(getLooper()).post(this::keepaliveListeners);
return null;
});
}
}
@Override
protected void onLooperPrepared() {
@Override protected void onLooperPrepared() {
super.onLooperPrepared();
registerListeners();
}
@Override
public boolean quit() {
@Override public boolean quit() {
scheduleUnregisterListeners();
return super.quit();
}
@Override
public boolean quitSafely() {
@Override public boolean quitSafely() {
scheduleUnregisterListeners();
return super.quitSafely();
}
......@@ -118,26 +111,19 @@ public class RocketChatWebSocketThread extends HandlerThread {
}
}
private static final Class[] REGISTERABLE_CLASSES = {
LoginServiceConfigurationSubscriber.class
};
private final ArrayList<Registerable> mListeners = new ArrayList<>();
private void prepareWebSocket() {
ServerConfig config = RealmHelper.executeTransactionForRead(realm ->
realm.where(ServerConfig.class)
.equalTo("id", mServerConfigId)
.findFirst());
ServerConfig config = RealmHelper.executeTransactionForRead(
realm -> realm.where(ServerConfig.class).equalTo("id", mServerConfigId).findFirst());
if (mWebSocketAPI == null || !mWebSocketAPI.isConnected()) {
mWebSocketAPI = RocketChatWebSocketAPI.create(config.getHostname());
}
}
@DebugLog
private Task<Void> registerListeners() {
if (mSocketExists) return Task.forResult(null);
@DebugLog private Task<Void> registerListeners() {
if (mSocketExists) {
return Task.forResult(null);
}
mSocketExists = true;
prepareWebSocket();
......@@ -168,13 +154,14 @@ public class RocketChatWebSocketThread extends HandlerThread {
//@DebugLog
private void registerListenersActually() {
if (mListenersRegistered) return;
if (mListenersRegistered) {
return;
}
mListenersRegistered = true;
for (Class clazz: REGISTERABLE_CLASSES) {
for (Class clazz : REGISTERABLE_CLASSES) {
try {
Constructor ctor = clazz.getConstructor(
Context.class, RocketChatWebSocketAPI.class);
Constructor ctor = clazz.getConstructor(Context.class, RocketChatWebSocketAPI.class);
Object obj = ctor.newInstance(mAppContext, mWebSocketAPI);
if (obj instanceof Registerable) {
......@@ -190,14 +177,20 @@ public class RocketChatWebSocketThread extends HandlerThread {
//@DebugLog
private void keepaliveListeners() {
if (!mSocketExists || !mListenersRegistered) return;
if (!mSocketExists || !mListenersRegistered) {
return;
}
for (Registerable registerable : mListeners) registerable.keepalive();
for (Registerable registerable : mListeners) {
registerable.keepalive();
}
}
//@DebugLog
private void unregisterListeners() {
if (!mSocketExists || !mListenersRegistered) return;
if (!mSocketExists || !mListenersRegistered) {
return;
}
Iterator<Registerable> iterator = mListeners.iterator();
while (iterator.hasNext()) {
......@@ -212,5 +205,4 @@ public class RocketChatWebSocketThread extends HandlerThread {
mListenersRegistered = false;
mSocketExists = false;
}
}
......@@ -2,19 +2,16 @@ package chat.rocket.android.service.ddp_subscriber;
import android.content.Context;
import android.text.TextUtils;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.Iterator;
import chat.rocket.android.helper.LogcatIfError;
import chat.rocket.android.service.Registerable;
import chat.rocket.android.ws.RocketChatWebSocketAPI;
import chat.rocket.android_ddp.DDPSubscription;
import io.realm.Realm;
import io.realm.RealmObject;
import java.util.Iterator;
import jp.co.crowdworks.realm_java_helpers_bolts.RealmHelperBolts;
import org.json.JSONException;
import org.json.JSONObject;
import rx.Subscription;
import timber.log.Timber;
......@@ -30,14 +27,16 @@ abstract class AbstractDDPDocEventSubscriber implements Registerable {
}
protected abstract String getSubscriptionName();
protected abstract String getSubscriptionCallbackName();
protected abstract Class<? extends RealmObject> getModelClass();
protected JSONObject customizeFieldJSON(JSONObject json) {
return json;
}
@Override
public void register() {
@Override public void register() {
mAPI.subscribe(getSubscriptionName(), null).onSuccess(task -> {
mID = task.getResult().id;
return null;
......@@ -110,8 +109,7 @@ abstract class AbstractDDPDocEventSubscriber implements Registerable {
}
}
private void onDocumentAdded(Realm realm, DDPSubscription.Added docEvent)
throws JSONException {
private void onDocumentAdded(Realm realm, DDPSubscription.Added docEvent) throws JSONException {
//executed in RealmTransaction
JSONObject json = new JSONObject().put("id", docEvent.docID);
mergeJSON(json, docEvent.fields);
......@@ -136,14 +134,14 @@ abstract class AbstractDDPDocEventSubscriber implements Registerable {
realm.where(getModelClass()).equalTo("id", docEvent.docID).findAll().deleteAllFromRealm();
}
@Override
public void keepalive() {
@Override public void keepalive() {
}
@Override
public void unregister() {
if (mSubscription != null) mSubscription.unsubscribe();
@Override public void unregister() {
if (mSubscription != null) {
mSubscription.unsubscribe();
}
if (!TextUtils.isEmpty(mID)) {
mAPI.unsubscribe(mID).continueWith(new LogcatIfError());
}
......
package chat.rocket.android.service.ddp_subscriber;
import android.content.Context;
import chat.rocket.android.model.MeteorLoginServiceConfiguration;
import chat.rocket.android.ws.RocketChatWebSocketAPI;
import io.realm.RealmObject;
......@@ -14,18 +13,15 @@ public class LoginServiceConfigurationSubscriber extends AbstractDDPDocEventSubs
super(context, api);
}
@Override
protected String getSubscriptionName() {
@Override protected String getSubscriptionName() {
return "meteor.loginServiceConfiguration";
}
@Override
protected String getSubscriptionCallbackName() {
@Override protected String getSubscriptionCallbackName() {
return "meteor_accounts_loginServiceConfiguration";
}
@Override
protected Class<? extends RealmObject> getModelClass() {
@Override protected Class<? extends RealmObject> getModelClass() {
return MeteorLoginServiceConfiguration.class;
}
}
package chat.rocket.android.service.observer;
import android.content.Context;
import chat.rocket.android.service.Registerable;
import chat.rocket.android.ws.RocketChatWebSocketAPI;
import io.realm.RealmObject;
import jp.co.crowdworks.realm_java_helpers.RealmListObserver;
abstract class AbstractModelObserver<T extends RealmObject>
extends RealmListObserver<T> implements Registerable {
abstract class AbstractModelObserver<T extends RealmObject> extends RealmListObserver<T>
implements Registerable {
protected final Context mContext;
protected final RocketChatWebSocketAPI mAPI;
......@@ -18,14 +17,11 @@ abstract class AbstractModelObserver<T extends RealmObject>
mAPI = api;
}
@Override
public void register() {
@Override public void register() {
sub();
}
@Override
public void unregister() {
@Override public void unregister() {
unsub();
}
}
......@@ -7,14 +7,11 @@ import android.util.AttributeSet;
abstract class AbstractCustomFontTextView extends AppCompatTextView {
protected abstract String getFont();
//CHECKSTYLE:OFF RedundantModifier
public AbstractCustomFontTextView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init();
}
//CHECKSTYLE:ON RedundantModifier
//CHECKSTYLE:OFF RedundantModifier
public AbstractCustomFontTextView(Context context, AttributeSet attrs) {
......@@ -30,11 +27,16 @@ abstract class AbstractCustomFontTextView extends AppCompatTextView {
}
//CHECKSTYLE:ON RedundantModifier
protected abstract String getFont();
//CHECKSTYLE:ON RedundantModifier
private void init() {
String font = getFont();
if (font != null) {
Typeface typeface = TypefaceHelper.getTypeface(getContext(), font);
if (typeface != null) setTypeface(typeface);
if (typeface != null) {
setTypeface(typeface);
}
}
}
}
......@@ -19,8 +19,7 @@ public class FontAwesomeTextView extends AbstractCustomFontTextView {
super(context);
}
@Override
protected String getFont() {
@Override protected String getFont() {
return "fontawesome-webfont.ttf";
}
}
......@@ -19,8 +19,7 @@ public class FontelloTextView extends AbstractCustomFontTextView {
super(context);
}
@Override
protected String getFont() {
@Override protected String getFont() {
return "fontello.ttf";
}
}
......@@ -3,12 +3,10 @@ package chat.rocket.android.view;
import android.content.Context;
import android.graphics.Typeface;
import android.util.Log;
import java.util.Hashtable;
/**
* Helper for reading typeface.
* ref:https://code.google.com/p/android/issues/detail?id=9904#c7
* Helper for reading typeface. ref:https://code.google.com/p/android/issues/detail?id=9904#c7
*/
public class TypefaceHelper {
private static final String TAG = TypefaceHelper.class.getName();
......@@ -22,12 +20,11 @@ public class TypefaceHelper {
synchronized (CACHE) {
if (!CACHE.containsKey(assetPath)) {
try {
Typeface typeface = Typeface.createFromAsset(context.getAssets(),
assetPath);
Typeface typeface = Typeface.createFromAsset(context.getAssets(), assetPath);
CACHE.put(assetPath, typeface);
} catch (Exception exception) {
Log.e(TAG, "Could not get typeface '" + assetPath
+ "' because " + exception.getMessage());
Log.e(TAG,
"Could not get typeface '" + assetPath + "' because " + exception.getMessage());
return null;
}
}
......
......@@ -11,10 +11,8 @@ import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import java.util.ArrayList;
import chat.rocket.android.R;
import java.util.ArrayList;
/**
* View for indicating "waiting for connection ..." and so on.
......@@ -48,9 +46,8 @@ public class WaitingView extends LinearLayout {
int count = 3;
if (attrs != null) {
TypedArray array = context.getTheme().obtainStyledAttributes(
attrs,
R.styleable.WaitingView, 0, 0);
TypedArray array =
context.getTheme().obtainStyledAttributes(attrs, R.styleable.WaitingView, 0, 0);
size = array.getDimensionPixelSize(R.styleable.WaitingView_dotSize, size);
count = array.getInteger(R.styleable.WaitingView_dotCount, count);
array.recycle();
......@@ -58,16 +55,16 @@ public class WaitingView extends LinearLayout {
mDots = new ArrayList<>();
setOrientation(HORIZONTAL);
for (int i = 0; i < count; i++) addDot(context, size);
for (int i = 0; i < count; i++) {
addDot(context, size);
}
addOnAttachStateChangeListener(new OnAttachStateChangeListener() {
@Override
public void onViewAttachedToWindow(View view) {
@Override public void onViewAttachedToWindow(View view) {
start();
}
@Override
public void onViewDetachedFromWindow(View view) {
@Override public void onViewDetachedFromWindow(View view) {
cancel();
}
});
......@@ -75,8 +72,7 @@ public class WaitingView extends LinearLayout {
private void addDot(Context context, int size) {
FrameLayout frameLayout = new FrameLayout(context);
frameLayout.setLayoutParams(
new LinearLayoutCompat.LayoutParams(size * 3 / 2, size * 3 / 2));
frameLayout.setLayoutParams(new LinearLayoutCompat.LayoutParams(size * 3 / 2, size * 3 / 2));
ImageView dot = new ImageView(context);
dot.setImageResource(R.drawable.white_circle);
dot.setLayoutParams(new FrameLayout.LayoutParams(size, size, Gravity.CENTER));
......@@ -91,19 +87,19 @@ public class WaitingView extends LinearLayout {
}
}
private void animateDot(final View dot,
final long startDelay,
final long duration,
private void animateDot(final View dot, final long startDelay, final long duration,
final long interval) {
dot.setScaleX(0);
dot.setScaleY(0);
dot.animate()
.scaleX(1).scaleY(1)
.scaleX(1)
.scaleY(1)
.setDuration(duration)
.setStartDelay(startDelay)
.withEndAction(() -> {
dot.animate()
.scaleX(0).scaleY(0)
.scaleX(0)
.scaleY(0)
.setDuration(duration)
.setStartDelay(0)
.withEndAction(() -> {
......@@ -115,7 +111,7 @@ public class WaitingView extends LinearLayout {
}
private void cancel() {
for (View dot: mDots) {
for (View dot : mDots) {
dot.clearAnimation();
}
}
......
package chat.rocket.android.ws;
import org.json.JSONArray;
import java.util.UUID;
import bolts.Task;
import chat.rocket.android.helper.OkHttpHelper;
import chat.rocket.android_ddp.DDPClient;
import chat.rocket.android_ddp.DDPClientCallback;
import chat.rocket.android_ddp.DDPSubscription;
import java.util.UUID;
import org.json.JSONArray;
import rx.Observable;
/**
......@@ -51,7 +49,6 @@ public class RocketChatWebSocketAPI {
mDDPClient.close();
}
/**
* Subscribe with DDP client.
*/
......@@ -72,5 +69,4 @@ public class RocketChatWebSocketAPI {
public Observable<DDPSubscription.Event> getSubscriptionCallback() {
return mDDPClient.getSubscriptionCallback();
}
}
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
android:width="24dp">
<path
android:fillColor="#FFFFFFFF"
android:pathData="M12,4l-1.41,1.41L16.17,11H4v2h12.17l-5.58,5.59L12,20l8,-8z"/>
......
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!--item android:state_enabled="false" android:color="@color/textColorLink" /-->
<item android:color="@color/textColorLink" />
<item android:color="@color/textColorLink"/>
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape android:shape="oval" xmlns:android="http://schemas.android.com/apk/res/android">
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="@color/userstatus_away"/>
<stroke android:width="1dp" android:color="@color/userstatus_away_outline" />
<stroke
android:color="@color/userstatus_away_outline"
android:width="1dp"/>
</shape>
<?xml version="1.0" encoding="utf-8"?>
<shape android:shape="oval" xmlns:android="http://schemas.android.com/apk/res/android">
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="@color/userstatus_busy"/>
<stroke android:width="1dp" android:color="@color/userstatus_busy_outline" />
<stroke
android:color="@color/userstatus_busy_outline"
android:width="1dp"/>
</shape>
<?xml version="1.0" encoding="utf-8"?>
<shape android:shape="oval" xmlns:android="http://schemas.android.com/apk/res/android">
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="@color/userstatus_offline"/>
<stroke android:width="1dp" android:color="@color/userstatus_offline_outline" />
<stroke
android:color="@color/userstatus_offline_outline"
android:width="1dp"/>
</shape>
<?xml version="1.0" encoding="utf-8"?>
<shape android:shape="oval" xmlns:android="http://schemas.android.com/apk/res/android">
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="@color/userstatus_online"/>
<stroke android:width="1dp" android:color="@color/userstatus_online_outline" />
<stroke
android:color="@color/userstatus_online_outline"
android:width="1dp"/>
</shape>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
>
<include layout="@layout/sidebar" />
<include layout="@layout/sidebar"/>
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
>
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
>
<android.support.v7.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:title="@string/app_name"/>
app:title="@string/app_name"
/>
</android.support.design.widget.AppBarLayout>
<FrameLayout
......@@ -27,8 +31,8 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
</FrameLayout>
app:layout_behavior="@string/appbar_scrolling_view_behavior"
></FrameLayout>
</android.support.design.widget.CoordinatorLayout>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.SlidingPaneLayout xmlns:android="http://schemas.android.com/apk/res/android"
<android.support.v4.widget.SlidingPaneLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
>
<include layout="@layout/sidebar" />
<include layout="@layout/sidebar"/>
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
>
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
>
<android.support.v7.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:title="@string/app_name"/>
app:title="@string/app_name"
/>
</android.support.design.widget.AppBarLayout>
<FrameLayout
......@@ -26,8 +32,8 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
</FrameLayout>
app:layout_behavior="@string/appbar_scrolling_view_behavior"
></FrameLayout>
</android.support.design.widget.CoordinatorLayout>
</android.support.v4.widget.SlidingPaneLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="@dimen/avatar_image_size_large" android:layout_height="@dimen/avatar_image_size_large">
android:layout_width="@dimen/avatar_image_size_large"
android:layout_height="@dimen/avatar_image_size_large"
>
<FrameLayout
android:id="@+id/avatar_color"
android:layout_width="@dimen/avatar_image_size_large"
android:layout_height="@dimen/avatar_image_size_large"
android:layout_gravity="center">
android:layout_gravity="center"
>
<TextView
android:id="@+id/avatar_initials"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textSize="@dimen/avatar_text_size_large"
android:layout_gravity="center"/>
/>
</FrameLayout>
<ImageView
android:id="@+id/avatar_img"
android:layout_width="@dimen/avatar_image_size_large"
android:layout_height="@dimen/avatar_image_size_large"
android:scaleType="centerInside"
android:src="@drawable/ic_default_avatar"
android:scaleType="centerInside"/>
/>
</FrameLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="@dimen/avatar_image_size_normal" android:layout_height="@dimen/avatar_image_size_normal">
android:layout_width="@dimen/avatar_image_size_normal"
android:layout_height="@dimen/avatar_image_size_normal"
>
<FrameLayout
android:id="@+id/avatar_color"
android:layout_width="@dimen/avatar_image_size_normal"
android:layout_height="@dimen/avatar_image_size_normal"
android:layout_gravity="center">
android:layout_gravity="center"
>
<TextView
android:id="@+id/avatar_initials"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textSize="@dimen/avatar_text_size_normal"
android:layout_gravity="center"/>
/>
</FrameLayout>
<ImageView
android:id="@+id/avatar_img"
android:layout_width="@dimen/avatar_image_size_normal"
android:layout_height="@dimen/avatar_image_size_normal"
android:scaleType="centerInside"
android:src="@drawable/ic_default_avatar"
android:scaleType="centerInside"/>
/>
</FrameLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="?attr/colorPrimaryDark">
android:background="?attr/colorPrimaryDark"
>
<LinearLayout
android:layout_width="wrap_content"
android:minWidth="288dp"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="center"
android:background="@color/white"
android:minWidth="288dp"
android:orientation="horizontal"
android:padding="@dimen/margin_24"
android:layout_gravity="center">
>
<LinearLayout
android:layout_width="0px"
android:layout_weight="1"
android:layout_height="wrap_content"
android:orientation="vertical">
android:layout_weight="1"
android:orientation="vertical"
>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="hostname"
android:textAppearance="@style/TextAppearance.AppCompat.Caption"/>
android:textAppearance="@style/TextAppearance.AppCompat.Caption"
/>
<EditText
android:id="@+id/editor_hostname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:hint="demo.rocket.chat"
android:imeOptions="actionGo"
android:inputType="textWebEditText"/>
android:inputType="textWebEditText"
android:singleLine="true"
/>
</LinearLayout>
<Space
android:layout_width="@dimen/margin_8"
android:layout_height="wrap_content" />
android:layout_height="wrap_content"
/>
<android.support.design.widget.FloatingActionButton
android:id="@+id/btn_connect"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
app:elevation="2dp"
app:fabSize="mini"
app:srcCompat="@drawable/ic_arrow_forward_white_24dp"
app:elevation="2dp"
android:layout_gravity="end|bottom"/>
/>
</LinearLayout>
</FrameLayout>
\ No newline at end of file
......@@ -2,10 +2,12 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/colorPrimaryDark">
android:background="?attr/colorPrimaryDark"
>
<chat.rocket.android.view.WaitingView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"/>
android:layout_gravity="center"
/>
</FrameLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="288dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="?attr/colorPrimary"
android:orientation="vertical"
android:theme="@style/AppTheme.Dark">
android:theme="@style/AppTheme.Dark"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimaryDark"
android:orientation="vertical"
android:background="?attr/colorPrimaryDark">
>
<LinearLayout
android:id="@+id/user_info_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="?attr/selectableItemBackground"
android:gravity="center_vertical"
android:orientation="horizontal"
android:padding="@dimen/margin_16"
android:background="?attr/selectableItemBackground">
>
<ImageView
android:id="@+id/img_userstatus"
android:layout_width="8dp"
android:layout_height="8dp"
android:src="@drawable/userstatus_online"/>
android:src="@drawable/userstatus_online"
/>
<Space
android:layout_width="@dimen/margin_8"
android:layout_height="wrap_content"/>
android:layout_height="wrap_content"
/>
<include layout="@layout/avatar_container_large"/>
<FrameLayout
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginLeft="@dimen/margin_8"
android:layout_marginRight="@dimen/margin_8">
android:layout_marginRight="@dimen/margin_8"
android:layout_weight="1"
>
<TextView
android:id="@+id/txt_account_info"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="14sp"
android:layout_gravity="center_vertical"
android:text="John Doe"/>
android:text="John Doe"
android:textSize="14sp"
/>
</FrameLayout>
......@@ -57,7 +63,8 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/fa_chevron_down"
android:textSize="16dp"/>
android:textSize="16dp"
/>
</LinearLayout>
</LinearLayout>
......
......@@ -2,6 +2,7 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
>
</FrameLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string translatable="false" name="fa_chevron_down">&#xf078;</string>
<string name="fa_chevron_down" translatable="false">&#xf078;</string>
</resources>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="WaitingView">
<attr name="dotSize" format="dimension" />
<attr name="dotCount" format="integer" />
<attr format="dimension" name="dotSize"/>
<attr format="integer" name="dotCount"/>
</declare-styleable>
<dimen name="def_waiting_view_dot_size">16dp</dimen>
</resources>
\ No newline at end of file
<?xml version="1.0"?>
<!DOCTYPE suppressions PUBLIC
"-//Puppy Crawl//DTD Suppressions 1.1//EN"
"http://www.puppycrawl.com/dtds/suppressions_1_1.dtd">
<suppressions>
<!-- suppress some checks for classes extending RealmObject -->
<suppress checks="MemberName|JavadocMethod" files="chat[\\/]rocket[\\/]android[\\/]model"/>
</suppressions>
\ No newline at end of file
......@@ -8,9 +8,9 @@
</Match>
<!-- All bugs in test classes, except for JUnit-specific bugs -->
<Match>
<Class name="~.*\.*Test" />
<Class name="~.*\.*Test"/>
<Not>
<Bug code="IJU" />
<Bug code="IJU"/>
</Not>
</Match>
......
......@@ -9,17 +9,17 @@
<exclude-pattern>.*/R.java</exclude-pattern>
<exclude-pattern>.*/gen/.*</exclude-pattern>
<rule ref="rulesets/java/android.xml" />
<rule ref="rulesets/java/clone.xml" />
<rule ref="rulesets/java/finalizers.xml" />
<rule ref="rulesets/java/android.xml"/>
<rule ref="rulesets/java/clone.xml"/>
<rule ref="rulesets/java/finalizers.xml"/>
<rule ref="rulesets/java/imports.xml">
<!-- Espresso is designed this way !-->
<exclude name="TooManyStaticImports" />
<exclude name="TooManyStaticImports"/>
</rule>
<rule ref="rulesets/java/basic.xml" />
<rule ref="rulesets/java/basic.xml"/>
<rule ref="rulesets/java/naming.xml">
<!--<exclude name="AbstractNaming" />-->
<exclude name="LongVariable" />
<exclude name="LongVariable"/>
<!--exclude name="ShortMethodName" /-->
<!--exclude name="ShortVariable" /-->
<!--<exclude name="ShortClassName" />-->
......
......@@ -7,8 +7,7 @@
* - pmd
*
* The three tasks above are added as dependencies of the check task so running check will
* run all of them.
*/
* run all of them.*/
apply plugin: 'checkstyle'
apply plugin: 'findbugs'
......@@ -35,13 +34,13 @@ task checkstyle(type: Checkstyle, group: 'Verification', description: 'Runs code
}
}
classpath = files( )
classpath = files()
}
task findbugs(type: FindBugs,
group: 'Verification',
description: 'Inspect java bytecode for bugs',
dependsOn: ['compileDebugSources','compileReleaseSources']) {
dependsOn: ['compileDebugSources', 'compileReleaseSources']) {
ignoreFailures = false
effort = "max"
......
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment