Browse Source

Minor style changes in login and fabs.

pull/24/head
Apostolos Fanakis 8 years ago
parent
commit
b5c64705bd
  1. 12
      app/src/main/java/gr/thmmy/mthmmy/activities/LoginActivity.java
  2. 45
      app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardActivity.java
  3. 17
      app/src/main/java/gr/thmmy/mthmmy/activities/profile/ProfileActivity.java
  4. 2
      app/src/main/java/gr/thmmy/mthmmy/activities/profile/summary/SummaryFragment.java
  5. 12
      app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java
  6. 4
      app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java
  7. 13
      app/src/main/res/drawable/guest_button_border_bg.xml
  8. 10
      app/src/main/res/drawable/login_button_bg.xml
  9. 23
      app/src/main/res/layout/activity_login.xml
  10. 1
      app/src/main/res/values/strings.xml

12
app/src/main/java/gr/thmmy/mthmmy/activities/LoginActivity.java

@ -3,9 +3,9 @@ package gr.thmmy.mthmmy.activities;
import android.content.Intent; import android.content.Intent;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Bundle; import android.os.Bundle;
import android.support.v7.widget.AppCompatButton;
import android.view.View; import android.view.View;
import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.EditText; import android.widget.EditText;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.ScrollView; import android.widget.ScrollView;
@ -27,7 +27,7 @@ public class LoginActivity extends BaseActivity {
//-----------------------------------------CLASS VARIABLES------------------------------------------ //-----------------------------------------CLASS VARIABLES------------------------------------------
/* --Graphics-- */ /* --Graphics-- */
private Button btnLogin; private AppCompatButton btnLogin;
private EditText inputUsername; private EditText inputUsername;
private EditText inputPassword; private EditText inputPassword;
private String username; private String username;
@ -48,8 +48,8 @@ public class LoginActivity extends BaseActivity {
//Variables initialization //Variables initialization
inputUsername = (EditText) findViewById(R.id.username); inputUsername = (EditText) findViewById(R.id.username);
inputPassword = (EditText) findViewById(R.id.password); inputPassword = (EditText) findViewById(R.id.password);
btnLogin = (Button) findViewById(R.id.btnLogin); btnLogin = (AppCompatButton) findViewById(R.id.btnLogin);
Button btnGuest = (Button) findViewById(R.id.btnContinueAsGuest); AppCompatButton btnGuest = (AppCompatButton) findViewById(R.id.btnContinueAsGuest);
//Login button Click Event //Login button Click Event
btnLogin.setOnClickListener(new View.OnClickListener() { btnLogin.setOnClickListener(new View.OnClickListener() {
@ -93,7 +93,7 @@ public class LoginActivity extends BaseActivity {
public void onBackPressed() { public void onBackPressed() {
// Disable going back to the MainActivity // Disable going back to the MainActivity
moveTaskToBack(true); moveTaskToBack(true);
if(loginTask!=null && loginTask.getStatus() == AsyncTask.Status.RUNNING){ if (loginTask != null && loginTask.getStatus() == AsyncTask.Status.RUNNING) {
loginTask.cancel(true); loginTask.cancel(true);
} }
} }
@ -147,7 +147,7 @@ public class LoginActivity extends BaseActivity {
View view = getCurrentFocus(); View view = getCurrentFocus();
if (view != null) { if (view != null) {
InputMethodManager imm = (InputMethodManager)getSystemService(INPUT_METHOD_SERVICE); InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(view.getWindowToken(), 0); imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
} }

45
app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardActivity.java

@ -1,11 +1,16 @@
package gr.thmmy.mthmmy.activities.board; package gr.thmmy.mthmmy.activities.board;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Bundle; import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.DividerItemDecoration; import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar; import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.ProgressBar; import android.widget.ProgressBar;
import android.widget.Toast; import android.widget.Toast;
@ -20,6 +25,7 @@ import java.util.Objects;
import javax.net.ssl.SSLHandshakeException; import javax.net.ssl.SSLHandshakeException;
import gr.thmmy.mthmmy.R; import gr.thmmy.mthmmy.R;
import gr.thmmy.mthmmy.activities.LoginActivity;
import gr.thmmy.mthmmy.activities.base.BaseActivity; import gr.thmmy.mthmmy.activities.base.BaseActivity;
import gr.thmmy.mthmmy.model.Board; import gr.thmmy.mthmmy.model.Board;
import gr.thmmy.mthmmy.model.Topic; import gr.thmmy.mthmmy.model.Topic;
@ -44,6 +50,7 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo
public static final String BUNDLE_BOARD_TITLE = "BOARD_TITLE"; public static final String BUNDLE_BOARD_TITLE = "BOARD_TITLE";
private MaterialProgressBar progressBar; private MaterialProgressBar progressBar;
private FloatingActionButton newTopicFAB;
private BoardTask boardTask; private BoardTask boardTask;
private BoardAdapter boardAdapter; private BoardAdapter boardAdapter;
@ -79,6 +86,38 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo
} }
createDrawer(); createDrawer();
progressBar = (MaterialProgressBar) findViewById(R.id.progressBar);
newTopicFAB = (FloatingActionButton) findViewById(R.id.board_fab);
newTopicFAB.setEnabled(false);
if (!sessionManager.isLoggedIn()) newTopicFAB.hide();
else {
newTopicFAB.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (sessionManager.isLoggedIn()) {
//TODO PM
} else {
new AlertDialog.Builder(BoardActivity.this)
.setMessage("You need to be logged in to create a new topic!")
.setPositiveButton("Login", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
Intent intent = new Intent(BoardActivity.this, LoginActivity.class);
startActivity(intent);
finish();
overridePendingTransition(R.anim.push_right_in, R.anim.push_right_out);
}
})
.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
}
})
.show();
}
}
});
}
boardAdapter = new BoardAdapter(getApplicationContext(), parsedSubBoards, parsedTopics); boardAdapter = new BoardAdapter(getApplicationContext(), parsedSubBoards, parsedTopics);
RecyclerView mainContent = (RecyclerView) findViewById(R.id.board_recycler_view); RecyclerView mainContent = (RecyclerView) findViewById(R.id.board_recycler_view);
@ -103,8 +142,6 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo
} }
}); });
progressBar = (MaterialProgressBar) findViewById(R.id.progressBar);
boardTask = new BoardTask(); boardTask = new BoardTask();
boardTask.execute(boardUrl); boardTask.execute(boardUrl);
} }
@ -143,6 +180,7 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo
protected void onPreExecute() { protected void onPreExecute() {
if (!isLoadingMore) progressBar.setVisibility(ProgressBar.VISIBLE); if (!isLoadingMore) progressBar.setVisibility(ProgressBar.VISIBLE);
if (newTopicFAB.getVisibility() != View.GONE) newTopicFAB.setEnabled(false);
} }
@Override @Override
@ -168,8 +206,9 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo
, "Fatal error!\n Aborting...", Toast.LENGTH_LONG).show(); , "Fatal error!\n Aborting...", Toast.LENGTH_LONG).show();
finish(); finish();
} }
++pagesLoaded;
//Parse was successful //Parse was successful
++pagesLoaded;
if (newTopicFAB.getVisibility() != View.GONE) newTopicFAB.setEnabled(true);
progressBar.setVisibility(ProgressBar.INVISIBLE); progressBar.setVisibility(ProgressBar.INVISIBLE);
boardAdapter.notifyDataSetChanged(); boardAdapter.notifyDataSetChanged();
isLoadingMore = false; isLoadingMore = false;

17
app/src/main/java/gr/thmmy/mthmmy/activities/profile/ProfileActivity.java

@ -79,7 +79,7 @@ public class ProfileActivity extends BaseActivity implements LatestPostsFragment
private TextView usernameView; private TextView usernameView;
private TextView personalTextView; private TextView personalTextView;
private MaterialProgressBar progressBar; private MaterialProgressBar progressBar;
private FloatingActionButton replyFAB; private FloatingActionButton pmFAB;
private ViewPager viewPager; private ViewPager viewPager;
private ProfileTask profileTask; private ProfileTask profileTask;
@ -130,14 +130,15 @@ public class ProfileActivity extends BaseActivity implements LatestPostsFragment
viewPager = (ViewPager) findViewById(R.id.profile_tab_container); viewPager = (ViewPager) findViewById(R.id.profile_tab_container);
replyFAB = (FloatingActionButton) findViewById(R.id.profile_fab); //TODO hide fab while logged out pmFAB = (FloatingActionButton) findViewById(R.id.profile_fab);
replyFAB.setEnabled(false); pmFAB.setEnabled(false);
replyFAB.setOnClickListener(new View.OnClickListener() { if (!sessionManager.isLoggedIn()) pmFAB.hide();
else {
pmFAB.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
if (sessionManager.isLoggedIn()) { if (sessionManager.isLoggedIn()) {
//TODO //TODO PM
//PM
} else { } else {
new AlertDialog.Builder(ProfileActivity.this) new AlertDialog.Builder(ProfileActivity.this)
.setMessage("You need to be logged in to sent a personal message!") .setMessage("You need to be logged in to sent a personal message!")
@ -159,6 +160,7 @@ public class ProfileActivity extends BaseActivity implements LatestPostsFragment
} }
} }
}); });
}
profileTask = new ProfileTask(); profileTask = new ProfileTask();
profileTask.execute(profileUrl); //Attempts data parsing profileTask.execute(profileUrl); //Attempts data parsing
@ -200,7 +202,7 @@ public class ProfileActivity extends BaseActivity implements LatestPostsFragment
protected void onPreExecute() { protected void onPreExecute() {
progressBar.setVisibility(ProgressBar.VISIBLE); progressBar.setVisibility(ProgressBar.VISIBLE);
replyFAB.setEnabled(false); if (pmFAB.getVisibility() != View.GONE) pmFAB.setEnabled(false);
} }
protected Boolean doInBackground(String... profileUrl) { protected Boolean doInBackground(String... profileUrl) {
@ -247,6 +249,7 @@ public class ProfileActivity extends BaseActivity implements LatestPostsFragment
finish(); finish();
} }
//Parse was successful //Parse was successful
if (pmFAB.getVisibility() != View.GONE) pmFAB.setEnabled(true);
progressBar.setVisibility(ProgressBar.INVISIBLE); progressBar.setVisibility(ProgressBar.INVISIBLE);
if (usernameView.getText() != username) usernameView.setText(username); if (usernameView.getText() != username) usernameView.setText(username);

2
app/src/main/java/gr/thmmy/mthmmy/activities/profile/summary/SummaryFragment.java

@ -1,5 +1,6 @@
package gr.thmmy.mthmmy.activities.profile.summary; package gr.thmmy.mthmmy.activities.profile.summary;
import android.graphics.Color;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
@ -178,6 +179,7 @@ public class SummaryFragment extends Fragment {
if (profileSummaryRow.contains("Signature") if (profileSummaryRow.contains("Signature")
|| profileSummaryRow.contains("Υπογραφή")) { //This may contain css || profileSummaryRow.contains("Υπογραφή")) { //This may contain css
WebView signatureEntry = new WebView(this.getContext()); WebView signatureEntry = new WebView(this.getContext());
signatureEntry.setBackgroundColor(Color.argb(1, 255, 255, 255));
signatureEntry.loadDataWithBaseURL("file:///android_asset/", profileSummaryRow, signatureEntry.loadDataWithBaseURL("file:///android_asset/", profileSummaryRow,
"text/html", "UTF-8", null); "text/html", "UTF-8", null);
mainContent.addView(signatureEntry); mainContent.addView(signatureEntry);

12
app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java

@ -124,14 +124,15 @@ public class TopicActivity extends BaseActivity {
topicTask); topicTask);
recyclerView.setAdapter(topicAdapter); recyclerView.setAdapter(topicAdapter);
replyFAB = (FloatingActionButton) findViewById(R.id.topic_fab); //TODO hide fab while logged out replyFAB = (FloatingActionButton) findViewById(R.id.topic_fab);
replyFAB.setEnabled(false); replyFAB.setEnabled(false);
if (!sessionManager.isLoggedIn()) replyFAB.hide();
else {
replyFAB.setOnClickListener(new View.OnClickListener() { replyFAB.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
if (sessionManager.isLoggedIn()) { if (sessionManager.isLoggedIn()) {
//TODO //TODO Reply
//Reply
} else { } else {
new AlertDialog.Builder(TopicActivity.this) new AlertDialog.Builder(TopicActivity.this)
.setMessage("You need to be logged in to reply!") .setMessage("You need to be logged in to reply!")
@ -153,6 +154,7 @@ public class TopicActivity extends BaseActivity {
} }
} }
}); });
}
//Sets bottom navigation bar //Sets bottom navigation bar
firstPage = (ImageButton) findViewById(R.id.page_first_button); firstPage = (ImageButton) findViewById(R.id.page_first_button);
@ -325,7 +327,7 @@ public class TopicActivity extends BaseActivity {
protected void onPreExecute() { protected void onPreExecute() {
progressBar.setVisibility(ProgressBar.VISIBLE); progressBar.setVisibility(ProgressBar.VISIBLE);
paginationEnable(false); paginationEnable(false);
replyFAB.setEnabled(false); if (replyFAB.getVisibility() != View.GONE) replyFAB.setEnabled(false);
} }
protected Integer doInBackground(String... strings) { protected Integer doInBackground(String... strings) {
@ -386,7 +388,7 @@ public class TopicActivity extends BaseActivity {
case SUCCESS: case SUCCESS:
progressBar.setVisibility(ProgressBar.INVISIBLE); progressBar.setVisibility(ProgressBar.INVISIBLE);
topicAdapter.customNotifyDataSetChanged(new TopicTask()); topicAdapter.customNotifyDataSetChanged(new TopicTask());
replyFAB.setEnabled(true); if (replyFAB.getVisibility() != View.GONE) replyFAB.setEnabled(true);
//Set current page //Set current page
pageIndicator.setText(String.valueOf(thisPage) + "/" + String.valueOf(numberOfPages)); pageIndicator.setText(String.valueOf(thisPage) + "/" + String.valueOf(numberOfPages));

4
app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java

@ -545,9 +545,7 @@ class TopicAdapter extends RecyclerView.Adapter<TopicAdapter.MyViewHolder> {
//Checks if this post is in the current topic's page //Checks if this post is in the current topic's page
for (Post post : postsList) { for (Post post : postsList) {
if (post.getPostIndex() == Integer.parseInt(msgIndexReq)) { if (post.getPostIndex() == Integer.parseInt(msgIndexReq)) {
//Don't restart Activity // TODO Don't restart Activity, Just change post focus
//Just change post focus
//TODO
return true; return true;
} }
} }

13
app/src/main/res/drawable/guest_button_border_bg.xml

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@null"/>
<stroke
android:width="1dip"
android:color="@color/accent"/>
<corners android:radius="5dip"/>
<padding
android:bottom="0dip"
android:left="0dip"
android:right="0dip"
android:top="0dip"/>
</shape>

10
app/src/main/res/drawable/login_button_bg.xml

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/accent"/>
<corners android:radius="5dip"/>
<padding
android:bottom="0dip"
android:left="0dip"
android:right="0dip"
android:top="0dip"/>
</shape>

23
app/src/main/res/layout/activity_login.xml

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_height="fill_parent"
android:background="@color/background" android:background="@color/background"
@ -73,19 +74,31 @@
android:id="@+id/btnLogin" android:id="@+id/btnLogin"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="24dp" android:layout_marginBottom="30dp"
android:layout_marginTop="24dp" android:layout_marginTop="30dp"
android:background="@drawable/login_button_bg"
android:padding="12dp" android:padding="12dp"
android:text="@string/btn_login" android:text="@string/btn_login"
android:textSize="18sp"/> android:textSize="18sp"/>
<Button <TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
android:gravity="center"
android:text="@string/login_or_guest"
android:textAllCaps="false"
android:textColor="@color/secondary_text"
android:textSize="10sp"
tools:ignore="SmallSp"/>
<android.support.v7.widget.AppCompatButton
android:id="@+id/btnContinueAsGuest" android:id="@+id/btnContinueAsGuest"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="24dp" android:layout_marginBottom="24dp"
android:layout_marginTop="40dip" android:layout_marginTop="30dip"
android:background="@null" android:background="@drawable/guest_button_border_bg"
android:text="@string/btn_continue_as_guest" android:text="@string/btn_continue_as_guest"
android:textAllCaps="false" android:textAllCaps="false"
android:textSize="15sp"/> android:textSize="15sp"/>

1
app/src/main/res/values/strings.xml

@ -12,6 +12,7 @@
<string name="hint_username">Username</string> <string name="hint_username">Username</string>
<string name="hint_password">Password</string> <string name="hint_password">Password</string>
<string name="btn_login">LOGIN</string> <string name="btn_login">LOGIN</string>
<string name="login_or_guest">- OR -</string>
<string name="btn_continue_as_guest">Don\'t have an account? Continue as guest!</string> <string name="btn_continue_as_guest">Don\'t have an account? Continue as guest!</string>
<!--Main Activity--> <!--Main Activity-->

Loading…
Cancel
Save