Fix follow instance issue from peertube + picker for theme

This commit is contained in:
stom79 2018-11-06 18:35:45 +01:00
parent 8e43786def
commit 204e2fc69d
2 changed files with 21 additions and 2 deletions

View File

@ -325,10 +325,18 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
@Override
public void run() {
try {
if( !peertubeAccount)
new HttpsConnection(ShowAccountActivity.this).get("https://" + finalInstanceName + "/api/v1/timelines/public?local=true", 10, null, null);
if( !peertubeAccount) {
//Here we can't know if the instance is a Mastodon one or not
try { //Testing Mastodon
new HttpsConnection(ShowAccountActivity.this).get("https://" + finalInstanceName + "/api/v1/timelines/public?local=true", 10, null, null);
}catch (Exception ignored){
new HttpsConnection(ShowAccountActivity.this).get("https://" + finalInstanceName + "/api/v1/videos/", 10, null, null);
peertubeAccount = true;
}
}
else
new HttpsConnection(ShowAccountActivity.this).get("https://" + finalInstanceName + "/api/v1/videos/", 10, null, null);
runOnUiThread(new Runnable() {
public void run() {
final SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();

View File

@ -87,6 +87,7 @@ import android.util.Log;
import android.util.Patterns;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.SubMenu;
import android.view.View;
import android.view.ViewGroup;
@ -1416,6 +1417,16 @@ public class Helper {
if( actionButton != null) {
actionButton.setFocusableInTouchMode(true);
actionButton.setFocusable(true);
actionButton.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if(actionMenu.isOpen())
actionMenu.close(true);
else
actionMenu.open(true);
return false;
}
});
actionButton.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {