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. 63
      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. 60
      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.os.AsyncTask;
import android.os.Bundle;
import android.support.v7.widget.AppCompatButton;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.ScrollView;
@ -27,7 +27,7 @@ public class LoginActivity extends BaseActivity {
//-----------------------------------------CLASS VARIABLES------------------------------------------
/* --Graphics-- */
private Button btnLogin;
private AppCompatButton btnLogin;
private EditText inputUsername;
private EditText inputPassword;
private String username;
@ -48,8 +48,8 @@ public class LoginActivity extends BaseActivity {
//Variables initialization
inputUsername = (EditText) findViewById(R.id.username);
inputPassword = (EditText) findViewById(R.id.password);
btnLogin = (Button) findViewById(R.id.btnLogin);
Button btnGuest = (Button) findViewById(R.id.btnContinueAsGuest);
btnLogin = (AppCompatButton) findViewById(R.id.btnLogin);
AppCompatButton btnGuest = (AppCompatButton) findViewById(R.id.btnContinueAsGuest);
//Login button Click Event
btnLogin.setOnClickListener(new View.OnClickListener() {
@ -93,7 +93,7 @@ public class LoginActivity extends BaseActivity {
public void onBackPressed() {
// Disable going back to the MainActivity
moveTaskToBack(true);
if(loginTask!=null && loginTask.getStatus() == AsyncTask.Status.RUNNING){
if (loginTask != null && loginTask.getStatus() == AsyncTask.Status.RUNNING) {
loginTask.cancel(true);
}
}
@ -147,7 +147,7 @@ public class LoginActivity extends BaseActivity {
View view = getCurrentFocus();
if (view != null) {
InputMethodManager imm = (InputMethodManager)getSystemService(INPUT_METHOD_SERVICE);
InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
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;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.AsyncTask;
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.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.ProgressBar;
import android.widget.Toast;
@ -20,6 +25,7 @@ import java.util.Objects;
import javax.net.ssl.SSLHandshakeException;
import gr.thmmy.mthmmy.R;
import gr.thmmy.mthmmy.activities.LoginActivity;
import gr.thmmy.mthmmy.activities.base.BaseActivity;
import gr.thmmy.mthmmy.model.Board;
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";
private MaterialProgressBar progressBar;
private FloatingActionButton newTopicFAB;
private BoardTask boardTask;
private BoardAdapter boardAdapter;
@ -79,6 +86,38 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo
}
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);
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.execute(boardUrl);
}
@ -143,6 +180,7 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo
protected void onPreExecute() {
if (!isLoadingMore) progressBar.setVisibility(ProgressBar.VISIBLE);
if (newTopicFAB.getVisibility() != View.GONE) newTopicFAB.setEnabled(false);
}
@Override
@ -168,8 +206,9 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo
, "Fatal error!\n Aborting...", Toast.LENGTH_LONG).show();
finish();
}
++pagesLoaded;
//Parse was successful
++pagesLoaded;
if (newTopicFAB.getVisibility() != View.GONE) newTopicFAB.setEnabled(true);
progressBar.setVisibility(ProgressBar.INVISIBLE);
boardAdapter.notifyDataSetChanged();
isLoadingMore = false;

63
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 personalTextView;
private MaterialProgressBar progressBar;
private FloatingActionButton replyFAB;
private FloatingActionButton pmFAB;
private ViewPager viewPager;
private ProfileTask profileTask;
@ -130,35 +130,37 @@ public class ProfileActivity extends BaseActivity implements LatestPostsFragment
viewPager = (ViewPager) findViewById(R.id.profile_tab_container);
replyFAB = (FloatingActionButton) findViewById(R.id.profile_fab); //TODO hide fab while logged out
replyFAB.setEnabled(false);
replyFAB.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (sessionManager.isLoggedIn()) {
//TODO
//PM
} else {
new AlertDialog.Builder(ProfileActivity.this)
.setMessage("You need to be logged in to sent a personal message!")
.setPositiveButton("Login", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
Intent intent = new Intent(ProfileActivity.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();
pmFAB = (FloatingActionButton) findViewById(R.id.profile_fab);
pmFAB.setEnabled(false);
if (!sessionManager.isLoggedIn()) pmFAB.hide();
else {
pmFAB.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (sessionManager.isLoggedIn()) {
//TODO PM
} else {
new AlertDialog.Builder(ProfileActivity.this)
.setMessage("You need to be logged in to sent a personal message!")
.setPositiveButton("Login", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
Intent intent = new Intent(ProfileActivity.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();
}
}
}
});
});
}
profileTask = new ProfileTask();
profileTask.execute(profileUrl); //Attempts data parsing
@ -200,7 +202,7 @@ public class ProfileActivity extends BaseActivity implements LatestPostsFragment
protected void onPreExecute() {
progressBar.setVisibility(ProgressBar.VISIBLE);
replyFAB.setEnabled(false);
if (pmFAB.getVisibility() != View.GONE) pmFAB.setEnabled(false);
}
protected Boolean doInBackground(String... profileUrl) {
@ -247,6 +249,7 @@ public class ProfileActivity extends BaseActivity implements LatestPostsFragment
finish();
}
//Parse was successful
if (pmFAB.getVisibility() != View.GONE) pmFAB.setEnabled(true);
progressBar.setVisibility(ProgressBar.INVISIBLE);
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;
import android.graphics.Color;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
@ -178,6 +179,7 @@ public class SummaryFragment extends Fragment {
if (profileSummaryRow.contains("Signature")
|| profileSummaryRow.contains("Υπογραφή")) { //This may contain css
WebView signatureEntry = new WebView(this.getContext());
signatureEntry.setBackgroundColor(Color.argb(1, 255, 255, 255));
signatureEntry.loadDataWithBaseURL("file:///android_asset/", profileSummaryRow,
"text/html", "UTF-8", null);
mainContent.addView(signatureEntry);

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

@ -124,35 +124,37 @@ public class TopicActivity extends BaseActivity {
topicTask);
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.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (sessionManager.isLoggedIn()) {
//TODO
//Reply
} else {
new AlertDialog.Builder(TopicActivity.this)
.setMessage("You need to be logged in to reply!")
.setPositiveButton("Login", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
Intent intent = new Intent(TopicActivity.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();
if (!sessionManager.isLoggedIn()) replyFAB.hide();
else {
replyFAB.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (sessionManager.isLoggedIn()) {
//TODO Reply
} else {
new AlertDialog.Builder(TopicActivity.this)
.setMessage("You need to be logged in to reply!")
.setPositiveButton("Login", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
Intent intent = new Intent(TopicActivity.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();
}
}
}
});
});
}
//Sets bottom navigation bar
firstPage = (ImageButton) findViewById(R.id.page_first_button);
@ -325,7 +327,7 @@ public class TopicActivity extends BaseActivity {
protected void onPreExecute() {
progressBar.setVisibility(ProgressBar.VISIBLE);
paginationEnable(false);
replyFAB.setEnabled(false);
if (replyFAB.getVisibility() != View.GONE) replyFAB.setEnabled(false);
}
protected Integer doInBackground(String... strings) {
@ -386,7 +388,7 @@ public class TopicActivity extends BaseActivity {
case SUCCESS:
progressBar.setVisibility(ProgressBar.INVISIBLE);
topicAdapter.customNotifyDataSetChanged(new TopicTask());
replyFAB.setEnabled(true);
if (replyFAB.getVisibility() != View.GONE) replyFAB.setEnabled(true);
//Set current page
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
for (Post post : postsList) {
if (post.getPostIndex() == Integer.parseInt(msgIndexReq)) {
//Don't restart Activity
//Just change post focus
//TODO
// TODO Don't restart Activity, Just change post focus
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"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/background"
@ -73,19 +74,31 @@
android:id="@+id/btnLogin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="24dp"
android:layout_marginTop="24dp"
android:layout_marginBottom="30dp"
android:layout_marginTop="30dp"
android:background="@drawable/login_button_bg"
android:padding="12dp"
android:text="@string/btn_login"
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:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="24dp"
android:layout_marginTop="40dip"
android:background="@null"
android:layout_marginTop="30dip"
android:background="@drawable/guest_button_border_bg"
android:text="@string/btn_continue_as_guest"
android:textAllCaps="false"
android:textSize="15sp"/>

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

@ -12,6 +12,7 @@
<string name="hint_username">Username</string>
<string name="hint_password">Password</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>
<!--Main Activity-->

Loading…
Cancel
Save