From 97ba6219c718feeae144183cf258b40bfb8e56c1 Mon Sep 17 00:00:00 2001 From: Thodoris1999 Date: Tue, 4 Sep 2018 11:25:55 +0300 Subject: [PATCH] create content activity layout init --- app/src/main/AndroidManifest.xml | 3 + .../activities/CreateContentActivity.java | 56 +++++++++++++++++++ .../activities/board/BoardActivity.java | 50 ++++++++--------- .../res/layout/activity_create_content.xml | 33 +++++++++++ 4 files changed, 114 insertions(+), 28 deletions(-) create mode 100644 app/src/main/java/gr/thmmy/mthmmy/activities/CreateContentActivity.java create mode 100644 app/src/main/res/layout/activity_create_content.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index cd4582c4..decb9b42 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -20,6 +20,7 @@ + + + \ No newline at end of file diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/CreateContentActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/CreateContentActivity.java new file mode 100644 index 00000000..bcc0a334 --- /dev/null +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/CreateContentActivity.java @@ -0,0 +1,56 @@ +package gr.thmmy.mthmmy.activities; + +import android.os.Bundle; +import android.support.v7.app.AppCompatActivity; +import android.view.View; +import android.view.inputmethod.InputConnection; + +import gr.thmmy.mthmmy.R; +import gr.thmmy.mthmmy.editorview.EditorView; +import gr.thmmy.mthmmy.editorview.EmojiKeyboard; + +public class CreateContentActivity extends AppCompatActivity implements EmojiKeyboard.EmojiKeyboardOwner { + + EditorView contentEditor; + EmojiKeyboard emojiKeyboard; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_create_content); + + emojiKeyboard = findViewById(R.id.emoji_keyboard); + + contentEditor = findViewById(R.id.main_content_editorview); + setEmojiKeyboardInputConnection(contentEditor.getInputConnection()); + contentEditor.setEmojiKeyboardOwner(this); + contentEditor.setOnSubmitListener(v -> { + + }); + } + + @Override + public void setEmojiKeyboardVisible(boolean visible) { + emojiKeyboard.setVisibility(visible ? View.VISIBLE : View.GONE); + } + + @Override + public boolean isEmojiKeyboardVisible() { + return emojiKeyboard.getVisibility() == View.VISIBLE; + } + + @Override + public void setEmojiKeyboardInputConnection(InputConnection ic) { + emojiKeyboard.setInputConnection(ic); + } + + @Override + public void onBackPressed() { + if (emojiKeyboard.getVisibility() == View.VISIBLE) { + emojiKeyboard.setVisibility(View.GONE); + contentEditor.updateEmojiKeyboardVisibility(); + } else { + super.onBackPressed(); + } + } +} 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 75d0bea8..04a03503 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,9 +1,11 @@ package gr.thmmy.mthmmy.activities.board; +import android.content.Intent; import android.net.Uri; 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; @@ -20,6 +22,8 @@ import java.util.ArrayList; import java.util.Objects; import gr.thmmy.mthmmy.R; +import gr.thmmy.mthmmy.activities.CreateContentActivity; +import gr.thmmy.mthmmy.activities.LoginActivity; import gr.thmmy.mthmmy.base.BaseActivity; import gr.thmmy.mthmmy.model.Board; import gr.thmmy.mthmmy.model.Bookmark; @@ -95,37 +99,27 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo progressBar = findViewById(R.id.progressBar); newTopicFAB = findViewById(R.id.board_fab); - newTopicFAB.setEnabled(false); - newTopicFAB.hide(); - /*if (!sessionManager.isLoggedIn()) newTopicFAB.hide(); + if (!sessionManager.isLoggedIn()) newTopicFAB.hide(); else { - newTopicFAB.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - if (sessionManager.isLoggedIn()) { - //TODO create topic - } 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(); - } + newTopicFAB.setOnClickListener(view -> { + if (sessionManager.isLoggedIn()) { + //TODO create topic + startActivity(new Intent(this, CreateContentActivity.class)); + } else { + new AlertDialog.Builder(BoardActivity.this) + .setMessage("You need to be logged in to create a new topic!") + .setPositiveButton("Login", (dialogInterface, 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", (dialogInterface, i) -> { + }) + .show(); } }); - }*/ + } boardAdapter = new BoardAdapter(getApplicationContext(), parsedSubBoards, parsedTopics); RecyclerView mainContent = findViewById(R.id.board_recycler_view); diff --git a/app/src/main/res/layout/activity_create_content.xml b/app/src/main/res/layout/activity_create_content.xml new file mode 100644 index 00000000..35bb9143 --- /dev/null +++ b/app/src/main/res/layout/activity_create_content.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + \ No newline at end of file