From b5c64705bd63cb14bf1ef2f5dad9e836ec979019 Mon Sep 17 00:00:00 2001 From: Apostolof Date: Mon, 16 Jan 2017 16:07:16 +0200 Subject: [PATCH] Minor style changes in login and fabs. --- .../mthmmy/activities/LoginActivity.java | 12 ++-- .../activities/board/BoardActivity.java | 45 ++++++++++++- .../activities/profile/ProfileActivity.java | 63 ++++++++++--------- .../profile/summary/SummaryFragment.java | 2 + .../activities/topic/TopicActivity.java | 60 +++++++++--------- .../mthmmy/activities/topic/TopicAdapter.java | 4 +- .../res/drawable/guest_button_border_bg.xml | 13 ++++ app/src/main/res/drawable/login_button_bg.xml | 10 +++ app/src/main/res/layout/activity_login.xml | 23 +++++-- app/src/main/res/values/strings.xml | 1 + 10 files changed, 157 insertions(+), 76 deletions(-) create mode 100644 app/src/main/res/drawable/guest_button_border_bg.xml create mode 100644 app/src/main/res/drawable/login_button_bg.xml diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/LoginActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/LoginActivity.java index 0be2b11e..2035653a 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/LoginActivity.java +++ b/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); } diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardActivity.java index 68665b52..bedc7ed1 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardActivity.java +++ b/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; diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/ProfileActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/ProfileActivity.java index 59bb69d0..5899efae 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/ProfileActivity.java +++ b/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); diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/summary/SummaryFragment.java b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/summary/SummaryFragment.java index ba1f966e..c621f295 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/summary/SummaryFragment.java +++ b/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); diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java index 3d27e284..c7ca6b73 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java +++ b/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)); diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java index 2ec6a4c1..7473b8ae 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java @@ -545,9 +545,7 @@ class TopicAdapter extends RecyclerView.Adapter { //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; } } diff --git a/app/src/main/res/drawable/guest_button_border_bg.xml b/app/src/main/res/drawable/guest_button_border_bg.xml new file mode 100644 index 00000000..9ec2f3f5 --- /dev/null +++ b/app/src/main/res/drawable/guest_button_border_bg.xml @@ -0,0 +1,13 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/login_button_bg.xml b/app/src/main/res/drawable/login_button_bg.xml new file mode 100644 index 00000000..502e6a5f --- /dev/null +++ b/app/src/main/res/drawable/login_button_bg.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_login.xml b/app/src/main/res/layout/activity_login.xml index 2da9c607..b79c2503 100644 --- a/app/src/main/res/layout/activity_login.xml +++ b/app/src/main/res/layout/activity_login.xml @@ -1,6 +1,7 @@ -