Skip to content
This repository has been archived by the owner on Mar 3, 2021. It is now read-only.

Commit

Permalink
Merge pull request #26 from DavidLu1997/plt-3400
Browse files Browse the repository at this point in the history
PLT-3435 Fixed expired session deviceId, and some UI changes
  • Loading branch information
coreyhulen committed Jul 11, 2016
2 parents a576051 + 301076d commit adbae67
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 17 deletions.
5 changes: 5 additions & 0 deletions app/src/main/java/com/mattermost/mattermost/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,11 @@ public void onResult(Promise<User> promise) {
}
}

// Check if deviceID is missing
if (url.toLowerCase().contains("/login")) {
MattermostService.service.SetAttached(false);
}

// Check to see if the user was trying to logout
if (url.toLowerCase().endsWith("/logout")) {
MattermostApplication.handler.post(new Runnable() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.view.inputmethod.EditorInfo;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.TextView;

import com.mattermost.model.InitialLoad;
Expand All @@ -21,6 +24,8 @@ public class SelectServerActivity extends AppActivity {

public static final int START_CODE = 11;

String server;
Spinner serverPrefix;
EditText serverName;
Button proceed;
private TextView errorMessage;
Expand All @@ -31,16 +36,37 @@ protected void onCreate(Bundle savedInstanceState) {

setContentView(R.layout.activity_select_server);

serverPrefix = (Spinner) findViewById(R.id.server_prefix);
serverName = (EditText) findViewById(R.id.server_name);
proceed = (Button) findViewById(R.id.proceed);
errorMessage = (TextView) findViewById(R.id.error_message);

String baseUrl = MattermostService.service.getBaseUrl();

if (baseUrl != null && baseUrl.length() > 0) {
String prefix = baseUrl.substring(0, baseUrl.lastIndexOf("://") + 3);
baseUrl = baseUrl.substring(prefix.length());
serverName.setText(baseUrl);

if (prefix != null && prefix.length() > 0) {
if (prefix.equals("https://")) {
serverPrefix.setSelection(0);
} else {
serverPrefix.setSelection(1);
}
}
}

serverName.setOnEditorActionListener(new EditText.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_GO) {
proceed.performClick();
}
return false;
}
});

proceed.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Expand All @@ -50,7 +76,7 @@ public void onClick(View v) {
}

private void doSelectServer() {
String server = serverName.getText().toString();
server = serverPrefix.getSelectedItem().toString() + serverName.getText().toString();
if (server.isEmpty()) {
errorMessage.setText(R.string.error_server_url_empty);
return;
Expand All @@ -77,7 +103,7 @@ public void onResult(Promise<InitialLoad> promise) {
Log.e("Error", promise.getError());
} else {
errorMessage.setText("");
MattermostService.service.init(serverName.getText().toString());
MattermostService.service.init(server);
Intent intent = new Intent(SelectServerActivity.this, MainActivity.class);
startActivity(intent);
finish();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@ public void SetAttached() {
preferences.edit().putString("AttachedId", "true").commit();
}

public void SetAttached(boolean attached) {
preferences.edit().putString("AttachedId", "" + attached).commit();
}

public String GetLastPath() {
return preferences.getString("LastPath", "");
}
Expand Down
56 changes: 45 additions & 11 deletions app/src/main/res/layout/activity_select_server.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,50 @@
android:layout_gravity="center_horizontal"
android:layout_margin="10dp" />

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/server_name"
android:layout_gravity="center_horizontal"
android:layout_margin="10dp"
android:textAppearance="?android:attr/textAppearanceSmall"
android:hint="@string/team_url_hint"
android:text="@string/team_url"
android:inputType="textNoSuggestions" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content">

<RelativeLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="0.7">

<Spinner
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:layout_marginTop="20dp"
android:layout_marginLeft="10dp"
android:id="@+id/server_prefix"
android:layout_gravity="center_horizontal"
android:textAppearance="?android:attr/textAppearanceListItemSmall"
android:entries="@array/server_prefixs"
/>

</RelativeLayout>

<RelativeLayout
android:layout_weight="0.3"
android:layout_width="0dp"
android:layout_height="fill_parent">

<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/server_name"
android:layout_gravity="center_horizontal"
android:layout_margin="10dp"
android:textAppearance="?android:attr/textAppearanceSmall"
android:hint="@string/team_url_hint"
android:text="@string/team_url"
android:imeOptions="actionGo"
android:inputType="textUri|textNoSuggestions" />

</RelativeLayout>

</LinearLayout>

<TextView
android:layout_width="wrap_content"
Expand All @@ -52,7 +86,7 @@
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Proceed"
android:text="@string/select_server_button"
android:id="@+id/proceed"
android:layout_gravity="center_horizontal"
android:layout_margin="10dp" />
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<resources>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
<color name="colorAccent">#1F7BC1</color>
<color name="errorColor">#d50000</color>
<color name="primary_text_material_light">#ffffff</color>
</resources>
9 changes: 7 additions & 2 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<string name="welcome_text">Enter Mattermost Server URL</string>
<string name="error_server_url_empty">Server URL cannot be empty</string>
<string name="error_server_url">The server does not exist</string>
<string name="error_mattermost_server">The address does not appear to be a Mattermost server</string>
<string name="error_mattermost_server">We could not connect to the Mattermost server or the server is running an incompatible version.</string>
<string name="login_sub_title">Email address for %s</string>
<string name="uploads_disabled">File uploads are disabled.</string>
<string name="choose_upload">Choose file for upload</string>
Expand All @@ -14,5 +14,10 @@
<string name="error_retry">You may be offline or the Mattermost server you are trying to connect to is experiencing problems.</string>
<string name="error_refresh">Refresh</string>
<string name="error_logout">Logout</string>
<string name="team_url_hint">e.g. https://server.com</string>
<string name="team_url_hint">e.g. mattermost.server.com</string>
<string name="select_server_button">Proceed</string>
<string-array name="server_prefixs">
<item>https://</item>
<item>http://</item>
</string-array>
</resources>
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
classpath 'com.android.tools.build:gradle:2.1.2'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down

0 comments on commit adbae67

Please sign in to comment.