New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch/Add servers without logging in/out #51

Open
wants to merge 18 commits into
base: master
from

Conversation

Projects
None yet
8 participants
@kunall17
Collaborator

kunall17 commented Apr 17, 2016

Developed #47 and also fixes #1

  • Ability to add your own server
  • Give a name to the server you are saving.
  • Ability to add new servers
  • Switch between these servers/user accounts.

Screenshots:

This saves the newly added servers in a new sharedPreference, hence saving their api_key which is further used for the authentication!

@smarx

This comment has been minimized.

smarx commented Apr 17, 2016

Automated message from Dropbox CLA bot

@kunall17, it looks like you've already signed the Dropbox CLA. Thanks!

@ryansnowboarder

This comment has been minimized.

ryansnowboarder commented Apr 19, 2016

Hey bro,

I'm having problems connecting zulip/zulip-android/master branch to my localhost with the login hack for iago@zulip.com. Does your code connect to localhost without any problems?

I'll fork it if I don't hear a response within the next few hours and try it myself - I just thought I would ask the most knowledgeable person first.

@kunall17

This comment has been minimized.

Collaborator

kunall17 commented Apr 20, 2016

@ryansnowboarder problems as in? your server URL is not taken or you cannot sign in?
I haven't tested with the iago hack, And if you are talking about forking this branch then i have commented out the IAGO hack as there's no point of having it anymore because you have to specify the server now.

And sorry, I am not the most knowledgeable person here.

@ryansnowboarder

This comment has been minimized.

ryansnowboarder commented Apr 20, 2016

My problem is that my local hosted Zulip server does not respond to HTTP
Requests from the app on the Android Emulator and an Android device. Works
fine with curl from the command prompt though. I've tried allowing
everything through the firewall while sending a request and that didn't fix
it. I tried connecting to the Zulip server from the browser from the
browser and device, which showed a socket error.

I ran out of time and didn't fork your repo, but I'll do that soon to see
if it works.

On Tue, Apr 19, 2016 at 9:33 PM, Kunal Gupta notifications@github.com
wrote:

@ryansnowboarder https://github.com/ryansnowboarder problems as in?
your server URL is not taken or you cannot sign in?
I haven't tested with the iago hack.

And sorry, I am not the most knowledgeable person here.


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#51 (comment)

@niftynei

This comment has been minimized.

Contributor

niftynei commented May 10, 2016

@kunall17 if it's not too much trouble, do you mind rebasing this against master?

@kunall17

This comment has been minimized.

Collaborator

kunall17 commented Jun 27, 2016

@niftynei rebased and updated this branch! :)

@niftynei

This comment has been minimized.

Contributor

niftynei commented Jul 19, 2016

@kunall17 what's the status of this PR?

username = you.getEmail();
} catch (Exception e) {
//SQL Exception can occur if name is not updated!
ZLog.logException(e);

This comment has been minimized.

@niftynei

niftynei Aug 12, 2016

Contributor

In what cases would username be null?

This comment has been minimized.

@kunall17

kunall17 Aug 17, 2016

Collaborator

It shouldn't be, as setEmail is being called always before this is called!

public int currentRealm = 0;
public List<String> serverStringSet;

This comment has been minimized.

@niftynei

niftynei Aug 12, 2016

Contributor

Is there a reason this is a list and the data model that you're storing is a set? The variable name is misleading :/

case R.id.menu_realm:
FragmentManager fm = getSupportFragmentManager();
RealmDialog dialogFragment = RealmDialog.newInstance();
dialogFragment.show(fm, "fragment_realm");

This comment has been minimized.

@niftynei

niftynei Aug 12, 2016

Contributor

should we check if this fragment already exists?

this.app.setServerURL(serverURL);
this.app.setLoggedInApiKey(obj.getString("api_key"));
ZulipApp.get().saveServerName(realmName);
if (context instanceof LoginActivity) {

This comment has been minimized.

@niftynei

niftynei Aug 12, 2016

Contributor

It'd be much cleaner to do this with an interface for the method openHome()

<string name="message_sent">Message Sent!</string>
<string name="message_error">Error sending Message</string>
<string name="stream_error">No Stream specified.</string>
<string name="stream_not_exists">Stream Does not Exists.</string>

This comment has been minimized.

@niftynei

niftynei Aug 12, 2016

Contributor

only the first word should be capitalized Stream does not exist

</resources>
<string name="message_sent">Message Sent!</string>
<string name="message_error">Error sending Message</string>
<string name="stream_error">No Stream specified.</string>

This comment has been minimized.

@niftynei

niftynei Aug 12, 2016

Contributor

Should be No stream specified.

@@ -72,4 +65,22 @@
<string name="enter_server">Please enter your server URL</string>
<string name="auth_login">Your server allows these Authentication Options:</string>
<string name="another_server">Another server</string>
</resources>
<string name="message_sent">Message Sent!</string>
<string name="message_error">Error sending Message</string>

This comment has been minimized.

@niftynei

niftynei Aug 12, 2016

Contributor

only first letter should be capitalized Error sending message

@@ -72,4 +65,22 @@
<string name="enter_server">Please enter your server URL</string>
<string name="auth_login">Your server allows these Authentication Options:</string>
<string name="another_server">Another server</string>
</resources>
<string name="message_sent">Message Sent!</string>

This comment has been minimized.

@niftynei

niftynei Aug 12, 2016

Contributor

Message sent!

Note that it's better to only display messages when something has failed. The user will know their message has been sent because it will appear in the chat. :)

<string name="message_error">Error sending Message</string>
<string name="stream_error">No Stream specified.</string>
<string name="stream_not_exists">Stream Does not Exists.</string>
<string name="subject_error">No Subject specified.</string>

This comment has been minimized.

@niftynei

niftynei Aug 12, 2016

Contributor

Other strings need to be changed so taht only first letter is capitalized. :)

@niftynei

This comment has been minimized.

Contributor

niftynei commented Aug 12, 2016

Hello kunal. I wasn't able to try this out because of the merge conflicts, but I left some notes on the code. Thanks!

@niftynei

This comment has been minimized.

Contributor

niftynei commented Aug 16, 2016

@kunall17 I got a crash when I successfully logged into a second realm.

08-16 13:59:17.490 E/AndroidRuntime(10928): FATAL EXCEPTION: main
08-16 13:59:17.490 E/AndroidRuntime(10928): Process: com.zulip.android.dev, PID: 10928
08-16 13:59:17.490 E/AndroidRuntime(10928): java.lang.RuntimeException: java.sql.SQLException: Unable to run insert stmt on object com.zulip.android.models.Stream@2275a78e: INSERT INTO `streams` (`color` ,`inHomeView` ,`inviteOnly` ,`name` ,`subscribed` ) VALUES (?,?,?,?,?)
08-16 13:59:17.490 E/AndroidRuntime(10928):     at com.j256.ormlite.dao.RuntimeExceptionDao.createIfNotExists(RuntimeExceptionDao.java:240)
08-16 13:59:17.490 E/AndroidRuntime(10928):     at com.zulip.android.models.Stream.getByName(Stream.java:138)
08-16 13:59:17.490 E/AndroidRuntime(10928):     at com.zulip.android.activities.ZulipActivity$20.setViewValue(ZulipActivity.java:690)
08-16 13:59:17.490 E/AndroidRuntime(10928):     at android.widget.SimpleCursorTreeAdapter.bindView(SimpleCursorTreeAdapter.java:220)
08-16 13:59:17.490 E/AndroidRuntime(10928):     at android.widget.SimpleCursorTreeAdapter.bindGroupView(SimpleCursorTreeAdapter.java:264)
08-16 13:59:17.490 E/AndroidRuntime(10928):     at android.widget.CursorTreeAdapter.getGroupView(CursorTreeAdapter.java:207)
08-16 13:59:17.490 E/AndroidRuntime(10928):     at android.widget.ExpandableListConnector.getView(ExpandableListConnector.java:446)
08-16 13:59:17.490 E/AndroidRuntime(10928):     at android.widget.AbsListView.obtainView(AbsListView.java:2346)
08-16 13:59:17.490 E/AndroidRuntime(10928):     at android.widget.ListView.makeAndAddView(ListView.java:1876)
08-16 13:59:17.490 E/AndroidRuntime(10928):     at android.widget.ListView.fillSpecific(ListView.java:1355)
08-16 13:59:17.490 E/AndroidRuntime(10928):     at android.widget.ListView.layoutChildren(ListView.java:1663)
08-16 13:59:17.490 E/AndroidRuntime(10928):     at android.widget.AbsListView.onLayout(AbsListView.java:2148)
08-16 13:59:17.490 E/AndroidRuntime(10928):     at android.view.View.layout(View.java:16636)
08-16 13:59:17.490 E/AndroidRuntime(10928):     at android.view.ViewGroup.layout(ViewGroup.java:5437)
08-16 13:59:17.490 E/AndroidRuntime(10928):     at android.support.v4.widget.DrawerLayout.onLayout(DrawerLayout.java:1215)
08-16 13:59:17.490 E/AndroidRuntime(10928):     at android.view.View.layout(View.java:16636)
08-16 13:59:17.490 E/AndroidRuntime(10928):     at android.view.ViewGroup.layout(ViewGroup.java:5437)
08-16 13:59:17.490 E/AndroidRuntime(10928):     at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
08-16 13:59:17.490 E/AndroidRuntime(10928):     at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
08-16 13:59:17.490 E/AndroidRuntime(10928):     at android.view.View.layout(View.java:16636)
08-16 13:59:17.490 E/AndroidRuntime(10928):     at android.view.ViewGroup.layout(ViewGroup.java:5437)
08-16 13:59:17.490 E/AndroidRuntime(10928):     at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1735)
08-16 13:59:17.490 E/AndroidRuntime(10928):     at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1579)
08-16 13:59:17.490 E/AndroidRuntime(10928):     at android.widget.LinearLayout.onLayout(LinearLayout.java:1488)
08-16 13:59:17.490 E/AndroidRuntime(10928):     at android.view.View.layout(View.java:16636)
08-16 13:59:17.490 E/AndroidRuntime(10928):     at android.view.ViewGroup.layout(ViewGroup.java:5437)
08-16 13:59:17.490 E/AndroidRuntime(10928):     at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
08-16 13:59:17.490 E/AndroidRuntime(10928):     at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
08-16 13:59:17.490 E/AndroidRuntime(10928):     at android.view.View.layout(View.java:16636)
08-16 13:59:17.490 E/AndroidRuntime(10928):     at android.view.ViewGroup.layout(ViewGroup.java:5437)
08-16 13:59:17.490 E/AndroidRuntime(10928):     at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1735)
08-16 13:59:17.490 E/AndroidRuntime(10928):     at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1579)
08-16 13:59:17.490 E/AndroidRuntime(10928):     at android.widget.LinearLayout.onLayout(LinearLayout.java:1488)
08-16 13:59:17.490 E/AndroidRuntime(10928):     at android.view.View.layout(View.java:16636)
08-16 13:59:17.490 E/AndroidRuntime(10928):     at android.view.ViewGroup.layout(ViewGroup.java:5437)
08-16 13:59:17.490 E/AndroidRuntime(10928):     at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
08-16 13:59:17.490 E/AndroidRuntime(10928):     at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
08-16 13:59:17.490 E/AndroidRuntime(10928):     at com.android.internal.policy.PhoneWindow$DecorView.onLayout(PhoneWindow.java:2678)
08-16 13:59:17.490 E/AndroidRuntime(10928):     at android.view.View.layout(View.java:16636)
08-16 13:59:17.490 E/AndroidRuntime(10928):     at android.view.ViewGroup.layout(ViewGroup.java:5437)
08-16 13:59:17.490 E/AndroidRuntime(10928):     at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2179)
08-16 13:59:17.490 E/AndroidRuntime(10928):     at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1939)
08-16 13:59:17.490 E/AndroidRuntime(10928):     at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1115)
08-16 13:59:17.490 E/AndroidRuntime(10928):     at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6023)
08-16 13:59:17.490 E/AndroidRuntime(10928):     at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858)
08-16 13:59:17.490 E/AndroidRuntime(10928):     at android.view.Choreographer.doCallbacks(Choreographer.java:670)
08-16 13:59:17.490 E/AndroidRuntime(10928):     at android.view.Choreographer.doFrame(Choreographer.java:606)
08-16 13:59:17.490 E/AndroidRuntime(10928):     at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844)
08-16 13:59:17.490 E/AndroidRuntime(10928):     at android.os.Handler.handleCallback(Handler.java:739)
08-16 13:59:17.490 E/AndroidRuntime(10928):     at android.os.Handler.dispatchMessage(Handler.java:95)
08-16 13:59:17.490 E/AndroidRuntime(10928):     at android.os.Looper.loop(Looper.java:148)
08-16 13:59:17.490 E/AndroidRuntime(10928):     at android.app.ActivityThread.main(ActivityThread.java:5422)
08-16 13:59:17.490 E/AndroidRuntime(10928):     at java.lang.reflect.Method.invoke(Native Method)
08-16 13:59:17.490 E/AndroidRuntime(10928):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
08-16 13:59:17.490 E/AndroidRuntime(10928):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
08-16 13:59:17.490 E/AndroidRuntime(10928): Caused by: java.sql.SQLException: Unable to run insert stmt on object com.zulip.android.models.Stream@2275a78e: INSERT INTO `streams` (`color` ,`inHomeView` ,`inviteOnly` ,`name` ,`subscribed` ) VALUES (?,

@kunall17

This comment has been minimized.

Collaborator

kunall17 commented Aug 16, 2016

If you used the DevAuthBackEnd in the second login attempt (when adding realm) then this should fix the error!

@niftynei

This comment has been minimized.

Contributor

niftynei commented Aug 16, 2016

it seems to work ok now, is there some context for why this occurs? otherwise it looks really good and i'd love to get it merged in 👍

cc @kunall17 :)

@kunall17

This comment has been minimized.

Collaborator

kunall17 commented Aug 17, 2016

If you had tried devAuthBackEnd then this error seems valid before the fix, otherwise it shouldn't occur!
Never encountered this error!
Updated the branch as well!

realmNameET = (EditText) findViewById(R.id.realmName);
if (getIntent().getBooleanExtra("FROM_ADDREALM", false)) {
startedFromAddRealm = true;
((TextView) findViewById(R.id.textView1)).setText(R.string.add_realm);

This comment has been minimized.

@niftynei

niftynei Aug 22, 2016

Contributor

@kunall17 this is possibly a rebasing error, but i can't get my version of this to compile because it can't find the textView1 view.

kunall17 added some commits Jun 27, 2016

Added SharedPreferences to store the realms
This GlobalSettings will store all the info about the saved
realms.
Method to create a new Realm
Changes the database helper and save default settings for the
server.
Method to switch the current realm
Saves current server position, changes the databaseHelper and get's the
saved data for this server
Switch realm method in ZulipActivity
Abort current connections, handlers and establish new ones.
@kunall17

This comment has been minimized.

Collaborator

kunall17 commented Aug 23, 2016

Updated the branch!

@niftynei

This comment has been minimized.

Contributor

niftynei commented Oct 19, 2016

@kunall17 this is super old, but do you have any interest in reviving this PR?

@kunall17

This comment has been minimized.

Collaborator

kunall17 commented Oct 21, 2016

@niftynei yeah sure!
There would be a complexity with the widget implemented now
We'll have to show from which user are these messages from.

@niftynei

This comment has been minimized.

Contributor

niftynei commented Oct 21, 2016

@kunall17 awesome! is there a way for the widget to only be registered for messages from a single realm? for example if you log in to more than realm, you pick which realm to see messages for in the configuration activity. just an idea.

@timabbott

This comment has been minimized.

Member

timabbott commented Dec 15, 2016

@kunall17 what's the status of this PR? Is it still something we intend to do?

@kunall17

This comment has been minimized.

Collaborator

kunall17 commented Dec 16, 2016

@timabbott yeah definitely, this is one great feature, but after migration to retrofit this PR would have to undergo a lot of changes, I'll see to update this one!

@saketkumar

This comment has been minimized.

Member

saketkumar commented Dec 21, 2016

@kunall17 This is really a great feature. Tell me if you need any kind of help in this. I would be happy to help. :)

@kunall17

This comment has been minimized.

Collaborator

kunall17 commented Dec 27, 2016

@saketkumar95 sure if you want to revive this PR, you can use the commits in this PR!
Just make sure you will have to edit the widget as well!

@yadav-rahul

This comment has been minimized.

Collaborator

yadav-rahul commented Jan 29, 2017

@kunall17 Can I test this PR?

@kunall17

This comment has been minimized.

Collaborator

kunall17 commented Jan 30, 2017

@yadav-rahul

Can I test this PR?

Testing?
This works as expected but this one is very old, and will have to be worked intensively to be revived again!
If you want you can definitely use the the commits and fix the merge conflicts and post as PR!

@zulipbot

This comment has been minimized.

Member

zulipbot commented May 22, 2017

Heads up @kunall17, we just merged some commits (latest: 471dca2) that conflict with the changes your made in this pull request! You can review this repository's recent commits to see where the conflicts occur. Please rebase your feature branch against the upstream/master branch and resolve your pull request's merge conflicts accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment