aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
authorLibravatar Renard 2016-05-08 17:47:07 -0300
committerLibravatar Renard 2016-05-08 17:47:07 -0300
commit22e5b86dcf7bd8e20abf7ab0de197a29f77e78d7 (patch)
tree48bef72964fe0009be4b125f51809f1233415739 /app/src/main/java
parent19e44b5af8549fe7c45677df967f0d0b9b1f1eb6 (diff)
downloadBaiApp-22e5b86dcf7bd8e20abf7ab0de197a29f77e78d7.tar.gz
BaiApp-22e5b86dcf7bd8e20abf7ab0de197a29f77e78d7.tar.xz
BaiApp-22e5b86dcf7bd8e20abf7ab0de197a29f77e78d7.zip
1.8v1.8
Diffstat (limited to 'app/src/main/java')
-rw-r--r--app/src/main/java/layout/FragmentBoardItemList.java37
-rw-r--r--app/src/main/java/org/bienvenidoainternet/app/MainActivity.java10
-rw-r--r--app/src/main/java/org/bienvenidoainternet/app/ResponseActivity.java8
-rw-r--r--app/src/main/java/org/bienvenidoainternet/app/ThemeManager.java5
-rw-r--r--app/src/main/java/org/bienvenidoainternet/app/ThreadListAdapter.java5
-rw-r--r--app/src/main/java/org/bienvenidoainternet/app/structure/BoardItem.java3
6 files changed, 54 insertions, 14 deletions
diff --git a/app/src/main/java/layout/FragmentBoardItemList.java b/app/src/main/java/layout/FragmentBoardItemList.java
index b172728..9128d3e 100644
--- a/app/src/main/java/layout/FragmentBoardItemList.java
+++ b/app/src/main/java/layout/FragmentBoardItemList.java
@@ -23,6 +23,7 @@ import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
+import android.view.Window;
import android.widget.AbsListView;
import android.widget.AdapterView;
import android.widget.LinearLayout;
@@ -46,6 +47,8 @@ import org.bienvenidoainternet.app.structure.ReplyID;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
+import org.jsoup.Jsoup;
+import org.jsoup.nodes.Document;
import java.io.File;
import java.io.FileInputStream;
@@ -192,13 +195,14 @@ public class FragmentBoardItemList extends Fragment {
if (imMainFragment && !recentPostMode) {
BoardItem bi = listViewAdapter.getItem(position);
mListener.showThread(currentBoard, bi);
- }else if (imMainFragment && recentPostMode){
+ } else if (imMainFragment && recentPostMode) {
BoardItem bi = boardItems.get(position);
mListener.showThread(bi.getParentBoard(), bi);
}
}
});
+
listViewBoardItems.setOnScrollListener(new AbsListView.OnScrollListener() {
private int lastFirstVisibleItem = 0;
@Override
@@ -209,9 +213,11 @@ public class FragmentBoardItemList extends Fragment {
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
if(lastFirstVisibleItem < firstVisibleItem) { // Scrolling down
- mListener.hideActionButton();
+ mListener.hideActionButton();
+// ((MainActivity)getActivity()).getSupportActionBar().hide();
}else if(lastFirstVisibleItem > firstVisibleItem) { // Scrolling Up
- mListener.showActionButton();
+ mListener.showActionButton();
+// ((MainActivity)getActivity()).getSupportActionBar().show();
}
lastFirstVisibleItem = firstVisibleItem;
for (int i = firstVisibleItem; i < firstVisibleItem + visibleItemCount; i++) {
@@ -226,7 +232,8 @@ public class FragmentBoardItemList extends Fragment {
loadingMoreThreads = true;
currentOffset += 10;
System.out.println("[Scroll] loading more threads! currentThreadCount " + totalItemCount);
- getThreadList(currentOffset); // TODO: Offset incorrecto
+ getThreadList(currentOffset);
+// Toast.makeText(getActivity().getApplicationContext(), "Cargando más hilos ...", Toast.LENGTH_SHORT).show();
}
}
});
@@ -315,11 +322,12 @@ public class FragmentBoardItemList extends Fragment {
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
if (info.targetView.getParent() == listViewBoardItems){
BoardItem bi = boardItems.get(info.position);
+ Document doc = Jsoup.parse(bi.getMessage());
+ String parsedMessage = doc.text();
switch (item.getItemId()){
case R.id.menu_copy:
- System.out.println("Post copiado");
ClipboardManager cm = (ClipboardManager)getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
- ClipData cd = ClipData.newPlainText("Reply", boardItems.get(info.position).getMessage());
+ ClipData cd = ClipData.newPlainText("Reply", parsedMessage);
cm.setPrimaryClip(cd);
break;
case R.id.menu_reply:
@@ -335,7 +343,7 @@ public class FragmentBoardItemList extends Fragment {
File txt = new File(Environment.getExternalStorageDirectory().getPath() + "/Bai/" + bi.getParentBoard().getBoardDir() + "_" + bi.getId() + ".txt");
FileOutputStream stream = new FileOutputStream(txt);
OutputStreamWriter outputStreamWriter = new OutputStreamWriter(stream);
- outputStreamWriter.write(bi.getMessage());
+ outputStreamWriter.write(parsedMessage);
outputStreamWriter.close();
stream.close();
Toast.makeText(getContext(), bi.getParentBoard().getBoardDir() + "_" + bi.getId() + ".txt guardado.", Toast.LENGTH_SHORT).show();
@@ -431,6 +439,7 @@ public class FragmentBoardItemList extends Fragment {
loadingMoreThreads = true;
showProgressBar();
String strOffset = "";
+
if (offset == 0){
currentOffset = 0;
boardItems.clear();
@@ -449,6 +458,7 @@ public class FragmentBoardItemList extends Fragment {
@Override
public void onCompleted(Exception e, String result) {
hideProgressBar();
+ int threadCount = 0;
if (e != null) {
e.printStackTrace();
displayError(e.getMessage());
@@ -456,6 +466,7 @@ public class FragmentBoardItemList extends Fragment {
try {
JSONObject json = new JSONObject(result);
JSONArray threads = json.getJSONArray("threads");
+ threadCount = threads.length();
for (int i = 0; i < threads.length(); i++) {
JSONObject thread = threads.getJSONObject(i);
BoardItem item = new BoardItem();
@@ -536,7 +547,9 @@ public class FragmentBoardItemList extends Fragment {
listViewAdapter.notifyDataSetChanged();
listViewAdapter.updateBoardItems(boardItems);
mListener.onThreadList();
- loadingMoreThreads = false;
+ if (threadCount != 0){
+ loadingMoreThreads = false;
+ }
if (boardItems.isEmpty()){
mListener.updateToolbar(currentBoard, currentThread);
}
@@ -717,7 +730,8 @@ public class FragmentBoardItemList extends Fragment {
if (mypath.exists()){
try {
Bitmap b = BitmapFactory.decodeStream(new FileInputStream(mypath));
- bi.setThumbBitmap(Bitmap.createScaledBitmap(b, 128, 128, false));
+// bi.setThumbBitmap(Bitmap.createScaledBitmap(b, 128, 128, false));
+ bi.setThumbBitmap(b);
listViewAdapter.notifyDataSetChanged();
Log.i("getThumb", bi.getThumb() + " from cache");
return;
@@ -730,7 +744,8 @@ public class FragmentBoardItemList extends Fragment {
Log.i("getThumb", "Not using wifi");
return;
}
- String imgURL = "http://bienvenidoainternet.org/" + bi.getParentBoard().getBoardDir() + "/thumb/" + bi.getThumb();
+ boolean mobileThumbs = settings.getBoolean("pref_usemobilethumbs", true);
+ String imgURL = "http://bienvenidoainternet.org/" + bi.getParentBoard().getBoardDir() + (mobileThumbs ? "/mobile/" : "/thumb/") + bi.getThumb();
if (bi.getThumb().startsWith("http")){
imgURL = bi.getThumb();
}
@@ -745,7 +760,7 @@ public class FragmentBoardItemList extends Fragment {
displayError(e.getMessage());
e.printStackTrace();
}else{
- bi.setThumbBitmap(Bitmap.createScaledBitmap(result, 128, 128, false));
+ bi.setThumbBitmap(result);//Bitmap.createScaledBitmap(result, 128, 128, false));
listViewAdapter.notifyDataSetChanged();
FileOutputStream out;
try{
diff --git a/app/src/main/java/org/bienvenidoainternet/app/MainActivity.java b/app/src/main/java/org/bienvenidoainternet/app/MainActivity.java
index 0d266fc..3a1890e 100644
--- a/app/src/main/java/org/bienvenidoainternet/app/MainActivity.java
+++ b/app/src/main/java/org/bienvenidoainternet/app/MainActivity.java
@@ -14,10 +14,12 @@ import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
+import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.SubMenu;
import android.view.View;
+import android.view.Window;
import android.widget.BaseAdapter;
import android.widget.HeaderViewListAdapter;
import android.widget.ListView;
@@ -93,7 +95,9 @@ public class MainActivity extends AppCompatActivity
@Override
protected void onCreate(Bundle savedInstanceState) {
+ getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
super.onCreate(savedInstanceState);
+ Ion.getDefault(getApplicationContext()).configure().setLogging("IonLog", Log.DEBUG);
ThemeManager tm = new ThemeManager(this);
this.setTheme(tm.getThemeForMainActivity());
@@ -231,7 +235,7 @@ public class MainActivity extends AppCompatActivity
}
if (tm.isDarkTheme()){
- navigationView.setBackgroundColor(0xFF888888);
+// navigationView.setBackgroundColor(0xFF888888);
}
}
@@ -437,6 +441,10 @@ public class MainActivity extends AppCompatActivity
sub.add(parsedBoard.getBoardName());
boardList.add(parsedBoard);
}
+// Board polka = new Board("Testing", "polka", 0, true);
+// boardList.add(polka);
+// sub.add("Testing");
+
}catch (JSONException e1) {
Toast.makeText(getApplicationContext(), e1.getMessage(), Toast.LENGTH_LONG).show();
e1.printStackTrace();
diff --git a/app/src/main/java/org/bienvenidoainternet/app/ResponseActivity.java b/app/src/main/java/org/bienvenidoainternet/app/ResponseActivity.java
index 74ac04b..3e74573 100644
--- a/app/src/main/java/org/bienvenidoainternet/app/ResponseActivity.java
+++ b/app/src/main/java/org/bienvenidoainternet/app/ResponseActivity.java
@@ -113,6 +113,14 @@ public class ResponseActivity extends AppCompatActivity {
Button bItalic = (Button) findViewById(R.id.buttonItalic);
Button select = (Button) findViewById(R.id.btnSelectFiles);
+ bBold.setVisibility(View.GONE);
+ bStrike.setVisibility(View.GONE);
+ bList.setVisibility(View.GONE);
+ bCode.setVisibility(View.GONE);
+ bUnder.setVisibility(View.GONE);
+ bItalic.setVisibility(View.GONE);
+
+
bBold.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
diff --git a/app/src/main/java/org/bienvenidoainternet/app/ThemeManager.java b/app/src/main/java/org/bienvenidoainternet/app/ThemeManager.java
index 04ed3fd..3c6722d 100644
--- a/app/src/main/java/org/bienvenidoainternet/app/ThemeManager.java
+++ b/app/src/main/java/org/bienvenidoainternet/app/ThemeManager.java
@@ -137,4 +137,9 @@ public class ThemeManager {
public int getCurrentThemeId() {
return currentThemeId;
}
+
+ public int getQuoteColor() {
+ TypedArray a = activity.getTheme().obtainStyledAttributes(currentThemeId, new int[]{R.attr.quoteColor});
+ return a.getColor(0, Color.CYAN);
+ }
}
diff --git a/app/src/main/java/org/bienvenidoainternet/app/ThreadListAdapter.java b/app/src/main/java/org/bienvenidoainternet/app/ThreadListAdapter.java
index d5f8a71..4e6e9cb 100644
--- a/app/src/main/java/org/bienvenidoainternet/app/ThreadListAdapter.java
+++ b/app/src/main/java/org/bienvenidoainternet/app/ThreadListAdapter.java
@@ -113,10 +113,12 @@ public class ThreadListAdapter extends ArrayAdapter<BoardItem>{
int sageColor = tm.getSageColor();
int nameColor = tm.getNameColor();
int tripcodeColor = tm.getTripcodeColor();
+ int quoteColor = tm.getQuoteColor();
String hexColor =intToHexString(boardItem.getIdColor());
String sageHexColor = intToHexString(sageColor);
String nameHexColor = intToHexString(nameColor);
String tripcodeHexColor = intToHexString(tripcodeColor);
+ String quoteHexColor = intToHexString(quoteColor);
String strId = "";
TextView txtTitle = (TextView)listItemView.findViewById(R.id.lv_txtTitle);
@@ -251,7 +253,8 @@ public class ThreadListAdapter extends ArrayAdapter<BoardItem>{
txtPoster.setText(Html.fromHtml("<b>No. " + idToDisplay + "</b> por <font color=" + (boardItem.isSage() ? sageHexColor : nameHexColor) + ">" + boardItem.getName() + "</font> "
+ (boardItem.getTripcode() == "" ? "" : "<font color=" + tripcodeHexColor + ">" + boardItem.getTripcode() + "</font>") + strId + " " + strTimeDiff));
- txtBody.setText(Html.fromHtml(boardItem.getMessage()));
+ String fixedMessage = boardItem.getMessage().replace("$_QUOTECOLOR_$", quoteHexColor);
+ txtBody.setText(Html.fromHtml(fixedMessage));
txtReplies.setVisibility(boardItem.isReply ? View.GONE : View.VISIBLE);
txtReplies.setText(boardItem.getTotalReplies() + " respuestas " + (boardItem.getTotalFiles() == 0 ? "" : ", " + boardItem.getTotalFiles() + " archivos"));
diff --git a/app/src/main/java/org/bienvenidoainternet/app/structure/BoardItem.java b/app/src/main/java/org/bienvenidoainternet/app/structure/BoardItem.java
index 9b81e8b..7a7cb02 100644
--- a/app/src/main/java/org/bienvenidoainternet/app/structure/BoardItem.java
+++ b/app/src/main/java/org/bienvenidoainternet/app/structure/BoardItem.java
@@ -5,6 +5,7 @@ import android.os.Parcel;
import android.os.Parcelable;
import android.util.Log;
+import org.bienvenidoainternet.app.ThemeManager;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
@@ -147,7 +148,7 @@ public class BoardItem implements Parcelable {
}
}
msg.select("img[src]").remove();
- msg.select("span[class=unkfunc]").tagName("font").attr("color", "#8fb56c").wrap("<i></i>");
+ msg.select("span[class=unkfunc]").tagName("font").attr("color", "$_QUOTECOLOR_$").wrap("<i></i>");
msg.select("div[class=yt]").wrap("<font color=red'><i></i></font>");
this.message = msg.html();
}