owned this note
owned this note
Published
Linked with GitHub
# Bamtech(new)
> [By吳岳, time=Fri, Jul 23, 2021 2:45 PM]
## Main Flow
* All Files are under package "poorni.bamboo"(Seperate folders for Login and Navigation)
* 
* The flow is Login -> Auth -> Homepage + Navigation Bar (Corresponding Activities : FirstActivity -> Login -> MainActivity)
* FirstActivity is the first Page, uses activity_first.xml as layout
* 
* 
* 
* 
* Sign in and enter Homepage + Navigation
* 
## Loginpage
### Login.java(java/poorni.bamboo/Login
* for login function,use Firebase UI
* Now provide Email, google, Facebook(will show GraphMethodException , but still work) ,Twitter account login
* build.gradle(bamtech.app): added dependencies for Firebase, fb login
* strings.xml: add fb_id for fb login
* manifest: meta-data and others for fb login
## Homepage + Navigation Bar
### MainActivity.java (java/poorni.bamboo
* used to show content when uses changes between pages
* Constructs Bottom Navigation View & NavController<br>
<font color="#f00">2021/8/26: This method will have problem if you want to use bundle when intent to MainActivity <br>
8/27: putInt(destination_id) can avoid app crash, but the imagebutton in category and DIY will be no response while clicking</font>
* have several popupwindows (profile,selection bar menu item)
### Layout *.xml files(res)
* activity_main.xml
1.Uses navHostFragmentto show different contents for each page
2.bottomNav_view shows the for the navigation bar
* fragment_*.xmls: are just for page creation
* pop_*.xmls: popupwindows in MainActivity
### Menu & Navigation(res)
* bottom_nav_menu.xml: used for building the bottom navigation bar
* nav_graph.xml:
1.contructs the navigation graph
2.when you add a new destination, creates java class in java/poorni.bamboo/Navigation
### Other files(res)
* Added colors to colors.xml, text to strings.xml
* add theme.xml -> *may need to remove v24, night*
* build.gradle(bamtech.app): added dependencies for navigation
## Profile
### user now
* show username and photo(if any)
### Account
* user data is in Firebase ,child("user") <br> data will be update by *user* class in Login file
* The Attribute "advanced" is used for judging if user has permissions to reply others' question
* Edit profile: let user change their info on firebase
* Reset password: send an email to user for reseting password
* Delete account: delete user's account, and turn back to Login Page
### Calendar
* try to use Material-Calendar-View at first ,but can't figure out how object "EventDay" works
* The original Calendar-View in android can't show event in the calendar ,so I just used the same way as I do in Bookmark ;(
### Bookmark
* https://www.youtube.com/playlist?list=PLHQRWugvckFr9H2Mo4hyre1wQHglSRake
this is how I update/delete data in firebase
### Reading List
### Q&A
* for changing FloatActionButton's position , you need an FrameLayout (FAB in post by me,world forum)
### Watch later
### Logout
### DIY
* firebase data: videos title, videos url, videos category(ID)
* RecyclerView: WebView (play videos) + TextView (show videos title)
* Search: SearchView
* Filter: filtered by category
# 8/2 BAMTECH會議報告(吳岳)
### Carousel
* 嘗試網路套件
[https://github.com/denzcoskun/ImageSlideshow](https://)
* 遇到的問題:與網路連線相關的問題,好像抓不到網路上的原件(非官方)

* 嘗試另一個套件
https://github.com/sayyam/carouselview
* 遇到問題:當layout xml view 改成 Carousel時,APP Crash

### Notification
* Action Bar 在建立Bottom Navigation 的時候做自動建立

* 重新讀Navigation Documentation
* 實作Navigation及Action Bar設置(官方Codelab)
* 有實做出功能(但是是Kotlin寫的)
* 發現也可以用Navigation Library來做Selection
### 預計要做的
* Carousel:
1.熟悉Fragment的使用(Navigation建立的Fragment好像不太一樣)
2.仍Debug不出來改用ViewPager2試試看(?)
* Notification:
1.把Kotlin轉成Java,整合至Project
### 問題
* 推薦使用Viewpager2實作嗎
* 目前是一個Activity上跑多個Fragment,有要改成多個不同的Activity嗎
* 要自訂Action Bar或是用NavigationUI內建的(我跟家佑有挑論兩種不同的做法)
# 8/9會議報告(吳岳)
### Notification Bell
* 加入Toolbar當中並且按下時會顯現Toast
* 

### Carousel
* 新增item_home_carousel.xml
* 新增Navigation -> ViewPagerAdapter.java
* 更新home.java

### 問題
* 去背會吃到照片本身(線上、PowerPoint)

* fragment_home.xml變得很奇怪

# 8/23會議報告(吳岳)
### Notification Bell
* 把Toast改成顯示Unread, read

### 未來進度
* 匯入Firebase資料
* 顯示Badge Count
* Treatment and preservation
# 改變文字選取選單
## 請複製以下程式碼到Categories的頁面<br>(參考Construction Sequence底下的頁面)
Boolean bk_isrepeated = false;
public void customselectionmenu(TextView t){
t.setCustomSelectionActionModeCallback(new ActionMode.Callback() {
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
MenuInflater menuInflater = mode.getMenuInflater();
menu.clear();
menuInflater.inflate(R.menu.custom_select_action_menu,menu);
return true;
}
@Override
public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
return false;
}
@Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
switch (item.getItemId()){
case R.id.bookmark:
DatabaseReference DbRef_bk = FirebaseDatabase.getInstance().getReference().child("bookmark");
DbRef_bk.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(@NonNull @NotNull DataSnapshot snapshot) {
for(DataSnapshot testDatasnap : snapshot.getChildren()){
Bookmark bk_add = testDatasnap.getValue(Bookmark.class);
if(bk_add.getPagename().equals(getLocalClassName())&& bk_add.getUserid().equals(user.getUid())){
bk_isrepeated = true;
}
}
if(bk_isrepeated == true){
Toast.makeText(getApplicationContext(), "Bookmark already exist", Toast.LENGTH_SHORT).show();
}else{
Bookmark bk = new Bookmark(getLocalClassName(), user.getUid());
Task<Void> mTask = DbRef_bk.push().setValue(bk);
mTask.addOnSuccessListener(new OnSuccessListener<Void>() {
@Override
public void onSuccess(@NonNull @NotNull Void unused) {
Toast.makeText(getApplicationContext(), "Bookmark added!", Toast.LENGTH_SHORT).show();
DatabaseReference DbRef_n = FirebaseDatabase.getInstance().getReference().child("notification");
String bk_name = getLocalClassName().substring(getLocalClassName().lastIndexOf(".")+1);
Notification n = new Notification(bk_name+" "+getString(R.string.notification_bk_add),user.getUid() ,"0");
DbRef_n.push().setValue(n);
}
});
}
}
@Override
public void onCancelled(@NonNull @NotNull DatabaseError error) {
}
});
mode.finish();
break;
case R.id.readinglist:
int content_start = t.getSelectionStart();
int content_end = t.getSelectionEnd();
String content = t.getText().toString().substring(content_start, content_end);
DatabaseReference DbRef_rd = FirebaseDatabase.getInstance().getReference().child("readinglist");
ReadingList_item rd = new ReadingList_item(getLocalClassName(), content , user.getUid());
Task<Void> mTask = DbRef_rd.push().setValue(rd);
mTask.addOnSuccessListener(new OnSuccessListener<Void>() {
@Override
public void onSuccess(@NonNull @NotNull Void unused) {
Toast.makeText(getApplicationContext(), "Reading List added!", Toast.LENGTH_SHORT).show();
DatabaseReference DbRef_n = FirebaseDatabase.getInstance().getReference().child("notification");
String rd_name = getLocalClassName().substring(getLocalClassName().lastIndexOf(".")+1);
Notification n = new Notification(rd_name+" "+getString(R.string.notification_rd_add),user.getUid() ,"0");
DbRef_n.push().setValue(n);
}
});
mode.finish();
break;
case R.id.QA:
int quote_start = t.getSelectionStart();
int quote_end = t.getSelectionEnd();
String quote = t.getText().toString().substring(quote_start, quote_end);
PopupWindow pop_ask_question = new PopupWindow();
View layout = getLayoutInflater().inflate(R.layout.pop_qa_ask_question, null);
pop_ask_question.setContentView(layout);
pop_ask_question.setBackgroundDrawable(null);
pop_ask_question.setWidth(RelativeLayout.LayoutParams.MATCH_PARENT);
pop_ask_question.setHeight(RelativeLayout.LayoutParams.WRAP_CONTENT);
pop_ask_question.setFocusable(true);
pop_ask_question.update();
pop_ask_question.showAtLocation(layout, Gravity.CENTER, 0, 2);
ImageButton exit_btn = layout.findViewById(R.id.exit_btn);
TextView quote_tv = layout.findViewById(R.id.quote);
if(quote.equals("")){
quote_tv.setVisibility(View.GONE);
}else{
quote_tv.setText(quote);
}
TextInputEditText questionInput = layout.findViewById(R.id.question_input);
Button post_btn = layout.findViewById(R.id.post);
post_btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
DatabaseReference DbRef_QA = FirebaseDatabase.getInstance().getReference().child("Q&A");
QA qa = new QA(quote_tv.getText().toString(),questionInput.getText().toString(), user.getUid(),user.getDisplayName(),"","","");
DbRef_QA.push().setValue(qa);
Toast.makeText(getApplicationContext(), "Question upload!", Toast.LENGTH_SHORT).show();
pop_ask_question.dismiss();
Intent i = new Intent(getApplicationContext(),MainActivity.class);
startActivity(i);
finish();
}
});
exit_btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
pop_ask_question.dismiss();
}
});
mode.finish();
break;
}
return false;
}
@Override
public void onDestroyActionMode(ActionMode mode) {
}
});
}
### 輸入完後,將該頁面的文字套用該方法
舉例:
tv1 = findViewById(R.id.plantv_1);
**tv1.setTextIsSelectable(true);// 如果在xml檔裡已經有設置 則不需要此行
customselectionmenu(tv1);**
# 8/30會議報告(吳岳)
### Notification Bell
* 跟Hank一起完成notification bell 的功能
* 預設是0,選取bookmark或是reading list就會變1
