Some changes
This commit is contained in:
parent
b932ed2c13
commit
d83929f80a
|
@ -0,0 +1,17 @@
|
||||||
|
# Number of days of inactivity before an issue becomes stale
|
||||||
|
daysUntilStale: 60
|
||||||
|
# Number of days of inactivity before a stale issue is closed
|
||||||
|
daysUntilClose: 7
|
||||||
|
# Issues with these labels will never be considered stale
|
||||||
|
exemptLabels:
|
||||||
|
- pinned
|
||||||
|
- security
|
||||||
|
# Label to use when marking an issue as stale
|
||||||
|
staleLabel: inactive
|
||||||
|
# Comment to post when marking an issue as stale. Set to `false` to disable
|
||||||
|
markComment: >
|
||||||
|
This issue has been automatically marked as stale because it has not had
|
||||||
|
recent activity. It will be closed if no further activity occurs. Thank you
|
||||||
|
for your contributions.
|
||||||
|
# Comment to post when closing a stale issue. Set to `false` to disable
|
||||||
|
closeComment: false
|
|
@ -24,6 +24,7 @@ import android.text.style.ForegroundColorSpan;
|
||||||
import android.text.style.UnderlineSpan;
|
import android.text.style.UnderlineSpan;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
@ -76,11 +77,11 @@ public class AccountActivity extends AppCompatActivity {
|
||||||
|
|
||||||
|
|
||||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||||
String token = Helper.getToken(AccountActivity.this);
|
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||||
|
String token = sharedpreferences.getString(Helper.PREF_KEY_OAUTH_TOKEN, null);
|
||||||
|
|
||||||
TextView instanceView = findViewById(R.id.instance);
|
TextView instanceView = findViewById(R.id.instance);
|
||||||
Account account = new AccountDAO(AccountActivity.this, db).getAccountByToken(token);
|
Account account = new AccountDAO(AccountActivity.this, db).getAccountByToken(token);
|
||||||
|
|
||||||
if (account == null) {
|
if (account == null) {
|
||||||
Helper.logoutCurrentUser(AccountActivity.this, null);
|
Helper.logoutCurrentUser(AccountActivity.this, null);
|
||||||
return;
|
return;
|
||||||
|
@ -121,76 +122,80 @@ public class AccountActivity extends AppCompatActivity {
|
||||||
|
|
||||||
tabLayout = findViewById(R.id.account_tabLayout);
|
tabLayout = findViewById(R.id.account_tabLayout);
|
||||||
mPager = findViewById(R.id.account_viewpager);
|
mPager = findViewById(R.id.account_viewpager);
|
||||||
tabLayout.addTab(tabLayout.newTab().setText(getString(R.string.title_notifications)));
|
|
||||||
tabLayout.addTab(tabLayout.newTab().setText(getString(R.string.title_muted)));
|
if (Helper.isLoggedIn(AccountActivity.this)) {
|
||||||
tabLayout.addTab(tabLayout.newTab().setText(getString(R.string.title_channel)));
|
tabLayout.addTab(tabLayout.newTab().setText(getString(R.string.title_notifications)));
|
||||||
|
tabLayout.addTab(tabLayout.newTab().setText(getString(R.string.title_muted)));
|
||||||
|
tabLayout.addTab(tabLayout.newTab().setText(getString(R.string.title_channel)));
|
||||||
|
|
||||||
|
mPager.setOffscreenPageLimit(3);
|
||||||
|
|
||||||
|
|
||||||
mPager.setOffscreenPageLimit(3);
|
mPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
||||||
|
|
||||||
|
|
||||||
mPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
|
|
||||||
@Override
|
|
||||||
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPageSelected(int position) {
|
|
||||||
TabLayout.Tab tab = tabLayout.getTabAt(position);
|
|
||||||
if (tab != null)
|
|
||||||
tab.select();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPageScrollStateChanged(int state) {
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
|
|
||||||
@Override
|
|
||||||
public void onTabSelected(TabLayout.Tab tab) {
|
|
||||||
mPager.setCurrentItem(tab.getPosition());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onTabUnselected(TabLayout.Tab tab) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onTabReselected(TabLayout.Tab tab) {
|
|
||||||
Fragment fragment = null;
|
|
||||||
if (mPager.getAdapter() != null)
|
|
||||||
fragment = (Fragment) mPager.getAdapter().instantiateItem(mPager, tab.getPosition());
|
|
||||||
switch (tab.getPosition()) {
|
|
||||||
case 0:
|
|
||||||
if (fragment != null) {
|
|
||||||
DisplayNotificationsFragment displayNotificationsFragment = ((DisplayNotificationsFragment) fragment);
|
|
||||||
displayNotificationsFragment.scrollToTop();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
if (fragment != null) {
|
|
||||||
DisplayAccountsFragment displayAccountsFragment = ((DisplayAccountsFragment) fragment);
|
|
||||||
displayAccountsFragment.scrollToTop();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
if (fragment != null) {
|
|
||||||
DisplayChannelsFragment displayChannelsFragment = ((DisplayChannelsFragment) fragment);
|
|
||||||
displayChannelsFragment.scrollToTop();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
PagerAdapter mPagerAdapter = new AccountsPagerAdapter(getSupportFragmentManager());
|
@Override
|
||||||
mPager.setAdapter(mPagerAdapter);
|
public void onPageSelected(int position) {
|
||||||
|
TabLayout.Tab tab = tabLayout.getTabAt(position);
|
||||||
|
if (tab != null)
|
||||||
|
tab.select();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPageScrollStateChanged(int state) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
|
||||||
|
@Override
|
||||||
|
public void onTabSelected(TabLayout.Tab tab) {
|
||||||
|
mPager.setCurrentItem(tab.getPosition());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onTabUnselected(TabLayout.Tab tab) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onTabReselected(TabLayout.Tab tab) {
|
||||||
|
Fragment fragment = null;
|
||||||
|
if (mPager.getAdapter() != null)
|
||||||
|
fragment = (Fragment) mPager.getAdapter().instantiateItem(mPager, tab.getPosition());
|
||||||
|
switch (tab.getPosition()) {
|
||||||
|
case 0:
|
||||||
|
if (fragment != null) {
|
||||||
|
DisplayNotificationsFragment displayNotificationsFragment = ((DisplayNotificationsFragment) fragment);
|
||||||
|
displayNotificationsFragment.scrollToTop();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
if (fragment != null) {
|
||||||
|
DisplayAccountsFragment displayAccountsFragment = ((DisplayAccountsFragment) fragment);
|
||||||
|
displayAccountsFragment.scrollToTop();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
if (fragment != null) {
|
||||||
|
DisplayChannelsFragment displayChannelsFragment = ((DisplayChannelsFragment) fragment);
|
||||||
|
displayChannelsFragment.scrollToTop();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
PagerAdapter mPagerAdapter = new AccountsPagerAdapter(getSupportFragmentManager());
|
||||||
|
mPager.setAdapter(mPagerAdapter);
|
||||||
|
} else {
|
||||||
|
tabLayout.setVisibility(View.GONE);
|
||||||
|
mPager.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -360,11 +360,14 @@ public class LoginActivity extends AppCompatActivity {
|
||||||
private void proceedLogin(Token token, String host, String software) {
|
private void proceedLogin(Token token, String host, String software) {
|
||||||
runOnUiThread(() -> {
|
runOnUiThread(() -> {
|
||||||
if (token != null) {
|
if (token != null) {
|
||||||
|
boolean remote_account = software != null && software.toUpperCase().trim().compareTo("PEERTUBE") != 0;
|
||||||
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||||
editor.putString(Helper.PREF_KEY_OAUTH_TOKEN, token.getAccess_token());
|
editor.putString(Helper.PREF_KEY_OAUTH_TOKEN, token.getAccess_token());
|
||||||
editor.putString(Helper.PREF_SOFTWARE, software != null && software.toUpperCase().trim().compareTo("PEERTUBE") != 0 ? software : null);
|
editor.putString(Helper.PREF_SOFTWARE, remote_account ? software : null);
|
||||||
editor.putString(Helper.PREF_INSTANCE, host);
|
if (!remote_account) {
|
||||||
|
editor.putString(Helper.PREF_INSTANCE, host);
|
||||||
|
}
|
||||||
editor.commit();
|
editor.commit();
|
||||||
//Update the account with the token;
|
//Update the account with the token;
|
||||||
updateCredential(LoginActivity.this, token.getAccess_token(), client_id, client_secret, token.getRefresh_token(), host, software);
|
updateCredential(LoginActivity.this, token.getAccess_token(), client_id, client_secret, token.getRefresh_token(), host, software);
|
||||||
|
|
|
@ -100,6 +100,7 @@ import su.litvak.chromecast.api.v2.MediaStatus;
|
||||||
|
|
||||||
import static app.fedilab.fedilabtube.MainActivity.TypeOfConnection.NORMAL;
|
import static app.fedilab.fedilabtube.MainActivity.TypeOfConnection.NORMAL;
|
||||||
import static app.fedilab.fedilabtube.MainActivity.TypeOfConnection.SURFING;
|
import static app.fedilab.fedilabtube.MainActivity.TypeOfConnection.SURFING;
|
||||||
|
import static app.fedilab.fedilabtube.helper.Helper.isLoggedInType;
|
||||||
import static app.fedilab.fedilabtube.helper.Helper.peertubeInformation;
|
import static app.fedilab.fedilabtube.helper.Helper.peertubeInformation;
|
||||||
|
|
||||||
|
|
||||||
|
@ -320,6 +321,7 @@ public class MainActivity extends AppCompatActivity implements ChromeCastsListen
|
||||||
int tryFind = 0;
|
int tryFind = 0;
|
||||||
while (ChromeCasts.get().isEmpty() && tryFind < 5) {
|
while (ChromeCasts.get().isEmpty() && tryFind < 5) {
|
||||||
try {
|
try {
|
||||||
|
//noinspection BusyWait
|
||||||
Thread.sleep(1000);
|
Thread.sleep(1000);
|
||||||
tryFind++;
|
tryFind++;
|
||||||
} catch (InterruptedException ignored) {
|
} catch (InterruptedException ignored) {
|
||||||
|
@ -710,6 +712,7 @@ public class MainActivity extends AppCompatActivity implements ChromeCastsListen
|
||||||
mostLikedItem.setVisible(false);
|
mostLikedItem.setVisible(false);
|
||||||
incognitoItem.setVisible(false);
|
incognitoItem.setVisible(false);
|
||||||
break;
|
break;
|
||||||
|
case REMOTE_ACCOUNT:
|
||||||
case NORMAL:
|
case NORMAL:
|
||||||
accountItem.setVisible(true);
|
accountItem.setVisible(true);
|
||||||
if (Helper.isLoggedIn(MainActivity.this)) {
|
if (Helper.isLoggedIn(MainActivity.this)) {
|
||||||
|
@ -763,7 +766,7 @@ public class MainActivity extends AppCompatActivity implements ChromeCastsListen
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
typeOfConnection = NORMAL;
|
typeOfConnection = NORMAL;
|
||||||
if (!Helper.isLoggedIn(MainActivity.this)) {
|
if (!Helper.canMakeAction(MainActivity.this)) {
|
||||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||||
List<Account> accounts = new AccountDAO(MainActivity.this, db).getAllAccount();
|
List<Account> accounts = new AccountDAO(MainActivity.this, db).getAllAccount();
|
||||||
if (accounts != null && accounts.size() > 0) {
|
if (accounts != null && accounts.size() > 0) {
|
||||||
|
|
|
@ -89,7 +89,9 @@ public class MastodonWebviewConnectActivity extends AppCompatActivity {
|
||||||
}
|
}
|
||||||
if (instance == null)
|
if (instance == null)
|
||||||
finish();
|
finish();
|
||||||
|
if (getSupportActionBar() != null)
|
||||||
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
|
setTitle(R.string.login);
|
||||||
webView = findViewById(R.id.webviewConnect);
|
webView = findViewById(R.id.webviewConnect);
|
||||||
clearCookies(MastodonWebviewConnectActivity.this);
|
clearCookies(MastodonWebviewConnectActivity.this);
|
||||||
webView.getSettings().setJavaScriptEnabled(true);
|
webView.getSettings().setJavaScriptEnabled(true);
|
||||||
|
|
|
@ -91,7 +91,9 @@ public class WebviewConnectActivity extends AppCompatActivity {
|
||||||
} else {
|
} else {
|
||||||
CookieManager.getInstance().setAcceptCookie(true);
|
CookieManager.getInstance().setAcceptCookie(true);
|
||||||
}
|
}
|
||||||
|
if (getSupportActionBar() != null)
|
||||||
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
|
setTitle(R.string.login);
|
||||||
|
|
||||||
final ProgressBar pbar = findViewById(R.id.progress_bar);
|
final ProgressBar pbar = findViewById(R.id.progress_bar);
|
||||||
webView.setWebChromeClient(new WebChromeClient() {
|
webView.setWebChromeClient(new WebChromeClient() {
|
||||||
|
|
|
@ -69,7 +69,9 @@ public class RetrofitMastodonAPI {
|
||||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||||
editor.putString(Helper.PREF_KEY_ID, account.getId());
|
editor.putString(Helper.PREF_KEY_ID, account.getId());
|
||||||
editor.putString(Helper.PREF_KEY_NAME, account.getUsername());
|
editor.putString(Helper.PREF_KEY_NAME, account.getUsername());
|
||||||
editor.putString(Helper.PREF_KEY_OAUTH_TOKEN, token);
|
if (token != null) {
|
||||||
|
editor.putString(Helper.PREF_KEY_OAUTH_TOKEN, token);
|
||||||
|
}
|
||||||
editor.putString(Helper.PREF_SOFTWARE, software);
|
editor.putString(Helper.PREF_SOFTWARE, software);
|
||||||
editor.apply();
|
editor.apply();
|
||||||
if (userExists) {
|
if (userExists) {
|
||||||
|
|
|
@ -165,7 +165,8 @@ public class RetrofitPeertubeAPI {
|
||||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||||
editor.putString(Helper.PREF_KEY_ID, account.getId());
|
editor.putString(Helper.PREF_KEY_ID, account.getId());
|
||||||
editor.putString(Helper.PREF_KEY_NAME, account.getUsername());
|
editor.putString(Helper.PREF_KEY_NAME, account.getUsername());
|
||||||
if (!host.startsWith("tube")) {
|
boolean remote_account = software != null && software.toUpperCase().trim().compareTo("PEERTUBE") != 0;
|
||||||
|
if (!remote_account) {
|
||||||
editor.putString(Helper.PREF_INSTANCE, host);
|
editor.putString(Helper.PREF_INSTANCE, host);
|
||||||
}
|
}
|
||||||
editor.apply();
|
editor.apply();
|
||||||
|
|
|
@ -507,7 +507,7 @@ public class Helper {
|
||||||
* @param context Context
|
* @param context Context
|
||||||
* @return MainActivity.TypeOfConnection
|
* @return MainActivity.TypeOfConnection
|
||||||
*/
|
*/
|
||||||
private static MainActivity.TypeOfConnection isLoggedInType(Context context) {
|
public static MainActivity.TypeOfConnection isLoggedInType(Context context) {
|
||||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||||
String prefKeyOauthTokenT = sharedpreferences.getString(PREF_KEY_OAUTH_TOKEN, null);
|
String prefKeyOauthTokenT = sharedpreferences.getString(PREF_KEY_OAUTH_TOKEN, null);
|
||||||
String prefSoftware = sharedpreferences.getString(PREF_SOFTWARE, null);
|
String prefSoftware = sharedpreferences.getString(PREF_SOFTWARE, null);
|
||||||
|
|
|
@ -53,10 +53,13 @@ public class SwitchAccountHelper {
|
||||||
builderSingle.setAdapter(accountsListAdapter, (dialog, which) -> {
|
builderSingle.setAdapter(accountsListAdapter, (dialog, which) -> {
|
||||||
final AccountData.Account account = accountArray[which];
|
final AccountData.Account account = accountArray[which];
|
||||||
SharedPreferences sharedpreferences = activity.getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
SharedPreferences sharedpreferences = activity.getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||||
|
boolean remote_account = account.getSoftware() != null && account.getSoftware().toUpperCase().trim().compareTo("PEERTUBE") != 0;
|
||||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||||
editor.putString(Helper.PREF_KEY_OAUTH_TOKEN, account.getToken());
|
editor.putString(Helper.PREF_KEY_OAUTH_TOKEN, account.getToken());
|
||||||
editor.putString(Helper.PREF_SOFTWARE, account.getSoftware() != null && account.getSoftware().trim().toUpperCase().compareTo("PEERTUBE") != 0 ? account.getSoftware() : null);
|
editor.putString(Helper.PREF_SOFTWARE, remote_account ? account.getSoftware() : null);
|
||||||
editor.putString(Helper.PREF_INSTANCE, account.getHost());
|
if (!remote_account) {
|
||||||
|
editor.putString(Helper.PREF_INSTANCE, account.getHost());
|
||||||
|
}
|
||||||
editor.putString(Helper.PREF_KEY_ID, account.getId());
|
editor.putString(Helper.PREF_KEY_ID, account.getId());
|
||||||
editor.putString(Helper.PREF_KEY_NAME, account.getUsername());
|
editor.putString(Helper.PREF_KEY_NAME, account.getUsername());
|
||||||
editor.apply();
|
editor.apply();
|
||||||
|
|
Loading…
Reference in New Issue