Browse Source

create content activity layout init

pull/51/head
Thodoris1999 6 years ago
parent
commit
97ba6219c7
  1. 3
      app/src/main/AndroidManifest.xml
  2. 56
      app/src/main/java/gr/thmmy/mthmmy/activities/CreateContentActivity.java
  3. 50
      app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardActivity.java
  4. 33
      app/src/main/res/layout/activity_create_content.xml

3
app/src/main/AndroidManifest.xml

@ -20,6 +20,7 @@
<meta-data <meta-data
android:name="firebase_crashlytics_collection_enabled" android:name="firebase_crashlytics_collection_enabled"
android:value="false" /> android:value="false" />
<activity <activity
android:name=".activities.main.MainActivity" android:name=".activities.main.MainActivity"
android:configChanges="orientation|screenSize" android:configChanges="orientation|screenSize"
@ -147,6 +148,8 @@
<action android:name="com.google.firebase.MESSAGING_EVENT" /> <action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter> </intent-filter>
</service> </service>
<activity android:name=".activities.CreateContentActivity"></activity>
</application> </application>
</manifest> </manifest>

56
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();
}
}
}

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

@ -1,9 +1,11 @@
package gr.thmmy.mthmmy.activities.board; package gr.thmmy.mthmmy.activities.board;
import android.content.Intent;
import android.net.Uri; import android.net.Uri;
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.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;
@ -20,6 +22,8 @@ import java.util.ArrayList;
import java.util.Objects; import java.util.Objects;
import gr.thmmy.mthmmy.R; 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.base.BaseActivity;
import gr.thmmy.mthmmy.model.Board; import gr.thmmy.mthmmy.model.Board;
import gr.thmmy.mthmmy.model.Bookmark; import gr.thmmy.mthmmy.model.Bookmark;
@ -95,37 +99,27 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo
progressBar = findViewById(R.id.progressBar); progressBar = findViewById(R.id.progressBar);
newTopicFAB = findViewById(R.id.board_fab); newTopicFAB = findViewById(R.id.board_fab);
newTopicFAB.setEnabled(false); if (!sessionManager.isLoggedIn()) newTopicFAB.hide();
newTopicFAB.hide();
/*if (!sessionManager.isLoggedIn()) newTopicFAB.hide();
else { else {
newTopicFAB.setOnClickListener(new View.OnClickListener() { newTopicFAB.setOnClickListener(view -> {
@Override if (sessionManager.isLoggedIn()) {
public void onClick(View view) { //TODO create topic
if (sessionManager.isLoggedIn()) { startActivity(new Intent(this, CreateContentActivity.class));
//TODO create topic } else {
} else { new AlertDialog.Builder(BoardActivity.this)
new AlertDialog.Builder(BoardActivity.this) .setMessage("You need to be logged in to create a new topic!")
.setMessage("You need to be logged in to create a new topic!") .setPositiveButton("Login", (dialogInterface, i) -> {
.setPositiveButton("Login", new DialogInterface.OnClickListener() { Intent intent = new Intent(BoardActivity.this, LoginActivity.class);
@Override startActivity(intent);
public void onClick(DialogInterface dialogInterface, int i) { finish();
Intent intent = new Intent(BoardActivity.this, LoginActivity.class); overridePendingTransition(R.anim.push_right_in, R.anim.push_right_out);
startActivity(intent); })
finish(); .setNegativeButton("Cancel", (dialogInterface, i) -> {
overridePendingTransition(R.anim.push_right_in, R.anim.push_right_out); })
} .show();
})
.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 = findViewById(R.id.board_recycler_view); RecyclerView mainContent = findViewById(R.id.board_recycler_view);

33
app/src/main/res/layout/activity_create_content.xml

@ -0,0 +1,33 @@
<?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="match_parent"
android:layout_height="match_parent"
tools:context=".activities.CreateContentActivity">
<android.support.design.widget.TextInputLayout
android:id="@+id/subject_input"
android:layout_width="240dp"
android:layout_height="wrap_content"
android:hint="@string/subject">
<android.support.design.widget.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.TextInputLayout>
<gr.thmmy.mthmmy.editorview.EditorView
android:id="@+id/main_content_editorview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/subject_input"/>
<gr.thmmy.mthmmy.editorview.EmojiKeyboard
android:id="@+id/emoji_keyboard"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:visibility="gone"/>
</RelativeLayout>
Loading…
Cancel
Save