From 22e5b86dcf7bd8e20abf7ab0de197a29f77e78d7 Mon Sep 17 00:00:00 2001 From: Renard Date: Sun, 8 May 2016 17:47:07 -0300 Subject: 1.8 --- app/src/main/assets/html/licenses.html | 4 +++ .../main/java/layout/FragmentBoardItemList.java | 37 +++++++++++++++------- .../org/bienvenidoainternet/app/MainActivity.java | 10 +++++- .../bienvenidoainternet/app/ResponseActivity.java | 8 +++++ .../org/bienvenidoainternet/app/ThemeManager.java | 5 +++ .../bienvenidoainternet/app/ThreadListAdapter.java | 5 ++- .../app/structure/BoardItem.java | 3 +- app/src/main/res/layout/app_bar_main.xml | 2 +- .../res/layout/fragment_fragment_thread_list.xml | 5 ++- app/src/main/res/values/attrs.xml | 1 + app/src/main/res/values/colors.xml | 4 +++ app/src/main/res/values/styles.xml | 5 ++- app/src/main/res/xml/preferences.xml | 4 +++ 13 files changed, 76 insertions(+), 17 deletions(-) (limited to 'app/src/main') diff --git a/app/src/main/assets/html/licenses.html b/app/src/main/assets/html/licenses.html index a366004..9c70bec 100644 --- a/app/src/main/assets/html/licenses.html +++ b/app/src/main/assets/html/licenses.html @@ -18,6 +18,10 @@
+Gracias a todos aquellos que han reportado bugs y/o dado sugencias para esta aplicación.
Código fuente en https://github.com/Renard1911/BaiApp
+
+
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{
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{
txtPoster.setText(Html.fromHtml("No. " + idToDisplay + " por " + boardItem.getName() + " "
+ (boardItem.getTripcode() == "" ? "" : "" + boardItem.getTripcode() + "") + 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("");
+ msg.select("span[class=unkfunc]").tagName("font").attr("color", "$_QUOTECOLOR_$").wrap("");
msg.select("div[class=yt]").wrap("");
this.message = msg.html();
}
diff --git a/app/src/main/res/layout/app_bar_main.xml b/app/src/main/res/layout/app_bar_main.xml
index 088b082..9202c71 100644
--- a/app/src/main/res/layout/app_bar_main.xml
+++ b/app/src/main/res/layout/app_bar_main.xml
@@ -29,7 +29,7 @@
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/fab_margin"
- android:src="@drawable/ic_edit"
+ android:src="@drawable/ic_action_add"
android:alpha="128" />
diff --git a/app/src/main/res/layout/fragment_fragment_thread_list.xml b/app/src/main/res/layout/fragment_fragment_thread_list.xml
index 477c236..f83f48c 100644
--- a/app/src/main/res/layout/fragment_fragment_thread_list.xml
+++ b/app/src/main/res/layout/fragment_fragment_thread_list.xml
@@ -54,7 +54,10 @@
android:layout_weight="1"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
- android:layout_alignParentStart="true" />
+ android:layout_alignParentStart="true"
+ android:cacheColorHint="@android:color/transparent"
+ android:fastScrollEnabled="true"
+ android:persistentDrawingCache="scrolling"/>
diff --git a/app/src/main/res/values/attrs.xml b/app/src/main/res/values/attrs.xml
index ad73763..8badacd 100644
--- a/app/src/main/res/values/attrs.xml
+++ b/app/src/main/res/values/attrs.xml
@@ -5,4 +5,5 @@
+
\ No newline at end of file
diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
index 8274b32..7df736f 100644
--- a/app/src/main/res/values/colors.xml
+++ b/app/src/main/res/values/colors.xml
@@ -9,6 +9,7 @@
#008000
#CCCCCC
#FF0000
+ #000000
#2F3D48
#58636c
@@ -17,6 +18,7 @@
#5f962e
#2e5f96
#962e5f
+ #7eab57
#DDDDDD
#EEEEEE
@@ -25,6 +27,7 @@
#004A99
#FF6600
#d279ef
+ #ff8533
#282A2E
#1D1F21
@@ -33,4 +36,5 @@
#c5c8c6
#81a2be
#b294bb
+ #9dbb94
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
index 40acf9b..5fb2316 100644
--- a/app/src/main/res/values/styles.xml
+++ b/app/src/main/res/values/styles.xml
@@ -17,6 +17,7 @@
- @color/defaultMarginColor
- @color/defaultTripcodeColor
- false
+ - @color/defaultQuote