Merged in develop (pull request #32)
This commit is contained in:
commit
05855b848a
|
@ -7,8 +7,8 @@ android {
|
||||||
applicationId "fr.gouv.etalab.mastodon"
|
applicationId "fr.gouv.etalab.mastodon"
|
||||||
minSdkVersion 15
|
minSdkVersion 15
|
||||||
targetSdkVersion 25
|
targetSdkVersion 25
|
||||||
versionCode 34
|
versionCode 35
|
||||||
versionName "1.3.7"
|
versionName "1.3.8"
|
||||||
}
|
}
|
||||||
buildTypes {
|
buildTypes {
|
||||||
release {
|
release {
|
|
@ -29,7 +29,6 @@ import android.support.v4.app.FragmentManager;
|
||||||
import android.support.v4.view.ViewPager;
|
import android.support.v4.view.ViewPager;
|
||||||
import android.support.v7.app.AlertDialog;
|
import android.support.v7.app.AlertDialog;
|
||||||
import android.support.v7.widget.SearchView;
|
import android.support.v7.widget.SearchView;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.support.design.widget.NavigationView;
|
import android.support.design.widget.NavigationView;
|
||||||
import android.support.v4.view.GravityCompat;
|
import android.support.v4.view.GravityCompat;
|
||||||
|
@ -75,6 +74,7 @@ import fr.gouv.etalab.mastodon.sqlite.AccountDAO;
|
||||||
import mastodon.etalab.gouv.fr.mastodon.R;
|
import mastodon.etalab.gouv.fr.mastodon.R;
|
||||||
|
|
||||||
import static fr.gouv.etalab.mastodon.helper.Helper.CHANGE_THEME_INTENT;
|
import static fr.gouv.etalab.mastodon.helper.Helper.CHANGE_THEME_INTENT;
|
||||||
|
import static fr.gouv.etalab.mastodon.helper.Helper.CHANGE_USER_INTENT;
|
||||||
import static fr.gouv.etalab.mastodon.helper.Helper.HOME_TIMELINE_INTENT;
|
import static fr.gouv.etalab.mastodon.helper.Helper.HOME_TIMELINE_INTENT;
|
||||||
import static fr.gouv.etalab.mastodon.helper.Helper.INTENT_ACTION;
|
import static fr.gouv.etalab.mastodon.helper.Helper.INTENT_ACTION;
|
||||||
import static fr.gouv.etalab.mastodon.helper.Helper.NOTIFICATION_INTENT;
|
import static fr.gouv.etalab.mastodon.helper.Helper.NOTIFICATION_INTENT;
|
||||||
|
@ -105,7 +105,6 @@ public class MainActivity extends AppCompatActivity
|
||||||
private ViewPager viewPager;
|
private ViewPager viewPager;
|
||||||
private RelativeLayout main_app_container;
|
private RelativeLayout main_app_container;
|
||||||
private Stack<Integer> stackBack = new Stack<>();
|
private Stack<Integer> stackBack = new Stack<>();
|
||||||
|
|
||||||
public MainActivity() {
|
public MainActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,8 +174,8 @@ public class MainActivity extends AppCompatActivity
|
||||||
tabLayout.setVisibility(View.VISIBLE);
|
tabLayout.setVisibility(View.VISIBLE);
|
||||||
switch (tab.getPosition()){
|
switch (tab.getPosition()){
|
||||||
case 0:
|
case 0:
|
||||||
fragmentTag = "HOME_TIMELINE";
|
|
||||||
item = navigationView.getMenu().findItem(R.id.nav_home);
|
item = navigationView.getMenu().findItem(R.id.nav_home);
|
||||||
|
fragmentTag = "HOME_TIMELINE";
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
fragmentTag = "LOCAL_TIMELINE";
|
fragmentTag = "LOCAL_TIMELINE";
|
||||||
|
@ -194,7 +193,7 @@ public class MainActivity extends AppCompatActivity
|
||||||
if( item != null){
|
if( item != null){
|
||||||
toolbarTitle.setText(item.getTitle());
|
toolbarTitle.setText(item.getTitle());
|
||||||
populateTitleWithTag(fragmentTag, item.getTitle().toString(), item.getItemId());
|
populateTitleWithTag(fragmentTag, item.getTitle().toString(), item.getItemId());
|
||||||
unCheckAllMenuItems(navigationView.getMenu());
|
unCheckAllMenuItems(navigationView);
|
||||||
item.setChecked(true);
|
item.setChecked(true);
|
||||||
}
|
}
|
||||||
if( tab.getPosition() < 3 )
|
if( tab.getPosition() < 3 )
|
||||||
|
@ -365,21 +364,24 @@ public class MainActivity extends AppCompatActivity
|
||||||
final NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
|
final NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
|
||||||
userIdIntent = extras.getString(PREF_KEY_ID); //Id of the account in the intent
|
userIdIntent = extras.getString(PREF_KEY_ID); //Id of the account in the intent
|
||||||
if (extras.getInt(INTENT_ACTION) == NOTIFICATION_INTENT){
|
if (extras.getInt(INTENT_ACTION) == NOTIFICATION_INTENT){
|
||||||
unCheckAllMenuItems(navigationView.getMenu());
|
|
||||||
changeUser(MainActivity.this, userIdIntent, false); //Connects the account which is related to the notification
|
changeUser(MainActivity.this, userIdIntent, false); //Connects the account which is related to the notification
|
||||||
|
unCheckAllMenuItems(navigationView);
|
||||||
tabLayout.getTabAt(3).select();
|
tabLayout.getTabAt(3).select();
|
||||||
matchingIntent = true;
|
matchingIntent = true;
|
||||||
}else if( extras.getInt(INTENT_ACTION) == HOME_TIMELINE_INTENT){
|
}else if( extras.getInt(INTENT_ACTION) == HOME_TIMELINE_INTENT){
|
||||||
unCheckAllMenuItems(navigationView.getMenu());
|
changeUser(MainActivity.this, userIdIntent, true); //Connects the account which is related to the notification
|
||||||
changeUser(MainActivity.this, userIdIntent, false); //Connects the account which is related to the notification
|
|
||||||
tabLayout.getTabAt(0).select();
|
|
||||||
matchingIntent = true;
|
|
||||||
}else if( extras.getInt(INTENT_ACTION) == CHANGE_THEME_INTENT){
|
}else if( extras.getInt(INTENT_ACTION) == CHANGE_THEME_INTENT){
|
||||||
unCheckAllMenuItems(navigationView.getMenu());
|
unCheckAllMenuItems(navigationView);
|
||||||
navigationView.setCheckedItem(R.id.nav_settings);
|
navigationView.setCheckedItem(R.id.nav_settings);
|
||||||
navigationView.getMenu().performIdentifierAction(R.id.nav_settings, 0);
|
navigationView.getMenu().performIdentifierAction(R.id.nav_settings, 0);
|
||||||
toolbarTitle.setText(R.string.settings);
|
toolbarTitle.setText(R.string.settings);
|
||||||
matchingIntent = true;
|
matchingIntent = true;
|
||||||
|
}else if( extras.getInt(INTENT_ACTION) == CHANGE_USER_INTENT){
|
||||||
|
unCheckAllMenuItems(navigationView);
|
||||||
|
navigationView.setCheckedItem(R.id.nav_home);
|
||||||
|
navigationView.getMenu().performIdentifierAction(R.id.nav_home, 0);
|
||||||
|
toolbarTitle.setText(R.string.home_menu);
|
||||||
|
matchingIntent = true;
|
||||||
}
|
}
|
||||||
}else if( Intent.ACTION_SEND.equals(action) && type != null ){
|
}else if( Intent.ACTION_SEND.equals(action) && type != null ){
|
||||||
if ("text/plain".equals(type)) {
|
if ("text/plain".equals(type)) {
|
||||||
|
@ -424,7 +426,7 @@ public class MainActivity extends AppCompatActivity
|
||||||
tabLayout.setVisibility(View.VISIBLE);
|
tabLayout.setVisibility(View.VISIBLE);
|
||||||
main_app_container.setVisibility(View.GONE);
|
main_app_container.setVisibility(View.GONE);
|
||||||
final NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
|
final NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
|
||||||
unCheckAllMenuItems(navigationView.getMenu());
|
unCheckAllMenuItems(navigationView);
|
||||||
toot.setVisibility(View.VISIBLE);
|
toot.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
switch (viewPager.getCurrentItem()){
|
switch (viewPager.getCurrentItem()){
|
||||||
|
@ -537,7 +539,7 @@ public class MainActivity extends AppCompatActivity
|
||||||
// Handle navigation view item clicks here.
|
// Handle navigation view item clicks here.
|
||||||
int id = item.getItemId();
|
int id = item.getItemId();
|
||||||
final NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
|
final NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
|
||||||
unCheckAllMenuItems(navigationView.getMenu());
|
unCheckAllMenuItems(navigationView);
|
||||||
item.setChecked(true);
|
item.setChecked(true);
|
||||||
//Remove the search bar
|
//Remove the search bar
|
||||||
if( !toolbar_search.isIconified() ) {
|
if( !toolbar_search.isIconified() ) {
|
||||||
|
@ -661,7 +663,7 @@ public class MainActivity extends AppCompatActivity
|
||||||
/**
|
/**
|
||||||
* Page Adapter for settings
|
* Page Adapter for settings
|
||||||
*/
|
*/
|
||||||
private class PagerAdapter extends FragmentStatePagerAdapter {
|
private class PagerAdapter extends FragmentStatePagerAdapter {
|
||||||
int mNumOfTabs;
|
int mNumOfTabs;
|
||||||
|
|
||||||
private PagerAdapter(FragmentManager fm, int NumOfTabs) {
|
private PagerAdapter(FragmentManager fm, int NumOfTabs) {
|
||||||
|
|
|
@ -298,11 +298,6 @@ public class ShowAccountActivity extends AppCompatActivity implements OnPostActi
|
||||||
account_ac.setVisibility(View.GONE);
|
account_ac.setVisibility(View.GONE);
|
||||||
else
|
else
|
||||||
account_ac.setText(account.getAcct());
|
account_ac.setText(account.getAcct());
|
||||||
/*if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
|
||||||
account_note.setText(Html.fromHtml(Helper.shortnameToUnicode(account.getNote(),true), Html.FROM_HTML_MODE_COMPACT));
|
|
||||||
else
|
|
||||||
//noinspection deprecation
|
|
||||||
account_note.setText(Html.fromHtml(Helper.shortnameToUnicode(account.getNote(), true)));*/
|
|
||||||
account_note = Helper.clickableElementsDescription(ShowAccountActivity.this, account_note,account.getNote());
|
account_note = Helper.clickableElementsDescription(ShowAccountActivity.this, account_note,account.getNote());
|
||||||
tabLayout.getTabAt(0).setText(getString(R.string.status_cnt, account.getStatuses_count()));
|
tabLayout.getTabAt(0).setText(getString(R.string.status_cnt, account.getStatuses_count()));
|
||||||
tabLayout.getTabAt(1).setText(getString(R.string.following_cnt, account.getFollowing_count()));
|
tabLayout.getTabAt(1).setText(getString(R.string.following_cnt, account.getFollowing_count()));
|
||||||
|
|
|
@ -25,21 +25,20 @@ import android.content.IntentFilter;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.database.sqlite.SQLiteDatabase;
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.Color;
|
||||||
import android.graphics.drawable.BitmapDrawable;
|
import android.graphics.drawable.BitmapDrawable;
|
||||||
import android.graphics.drawable.Drawable;
|
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.speech.RecognizerIntent;
|
import android.speech.RecognizerIntent;
|
||||||
import android.support.design.widget.FloatingActionButton;
|
import android.support.design.widget.FloatingActionButton;
|
||||||
|
import android.support.v4.content.ContextCompat;
|
||||||
import android.support.v4.content.LocalBroadcastManager;
|
import android.support.v4.content.LocalBroadcastManager;
|
||||||
import android.support.v7.app.ActionBar;
|
import android.support.v7.app.ActionBar;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.support.v7.widget.Toolbar;
|
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
import android.text.TextWatcher;
|
import android.text.TextWatcher;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
@ -108,7 +107,6 @@ import mastodon.etalab.gouv.fr.mastodon.R;
|
||||||
import static fr.gouv.etalab.mastodon.helper.Helper.HOME_TIMELINE_INTENT;
|
import static fr.gouv.etalab.mastodon.helper.Helper.HOME_TIMELINE_INTENT;
|
||||||
import static fr.gouv.etalab.mastodon.helper.Helper.INTENT_ACTION;
|
import static fr.gouv.etalab.mastodon.helper.Helper.INTENT_ACTION;
|
||||||
import static fr.gouv.etalab.mastodon.helper.Helper.changeDrawableColor;
|
import static fr.gouv.etalab.mastodon.helper.Helper.changeDrawableColor;
|
||||||
import static fr.gouv.etalab.mastodon.helper.Helper.loadPPInActionBar;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Thomas on 01/05/2017.
|
* Created by Thomas on 01/05/2017.
|
||||||
|
@ -145,12 +143,14 @@ public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAc
|
||||||
private long restored;
|
private long restored;
|
||||||
private TextView title;
|
private TextView title;
|
||||||
private ImageView pp_actionBar;
|
private ImageView pp_actionBar;
|
||||||
|
private Toast mToast;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE);
|
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE);
|
||||||
int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK);
|
final int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK);
|
||||||
if( theme == Helper.THEME_LIGHT){
|
if( theme == Helper.THEME_LIGHT){
|
||||||
setTheme(R.style.AppTheme);
|
setTheme(R.style.AppTheme);
|
||||||
}else {
|
}else {
|
||||||
|
@ -430,15 +430,21 @@ public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAc
|
||||||
}else{
|
}else{
|
||||||
toot_show_accounts.setVisibility(View.GONE);
|
toot_show_accounts.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
if( s.length() + charsInCw > maxChar){
|
|
||||||
String content = s.toString().substring(0,(maxChar - charsInCw));
|
|
||||||
toot_content.setText(content);
|
|
||||||
charsInToot = content.length();
|
|
||||||
toot_content.setSelection(toot_content.getText().length());
|
|
||||||
Toast.makeText(getApplicationContext(),R.string.toot_no_space,Toast.LENGTH_LONG).show();
|
|
||||||
}
|
|
||||||
int totalChar = toot_cw_content.length() + toot_content.length();
|
int totalChar = toot_cw_content.length() + toot_content.length();
|
||||||
toot_space_left.setText(String.valueOf((maxChar - totalChar)));
|
int remainChar = (maxChar - totalChar);
|
||||||
|
if( remainChar >= 0){
|
||||||
|
toot_it.setEnabled(true);
|
||||||
|
if( theme == Helper.THEME_LIGHT){
|
||||||
|
toot_space_left.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.colorAccent));
|
||||||
|
}else {
|
||||||
|
toot_space_left.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.colorAccentD));
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
toot_it.setEnabled(false);
|
||||||
|
showAToast(getString(R.string.toot_no_space));
|
||||||
|
toot_space_left.setTextColor( Color.RED);
|
||||||
|
}
|
||||||
|
toot_space_left.setText(String.valueOf(remainChar));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
//Allow scroll of the EditText though it's embedded in a scrollview
|
//Allow scroll of the EditText though it's embedded in a scrollview
|
||||||
|
@ -464,14 +470,22 @@ public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAc
|
||||||
public void onTextChanged(CharSequence s, int start, int before, int count) {}
|
public void onTextChanged(CharSequence s, int start, int before, int count) {}
|
||||||
@Override
|
@Override
|
||||||
public void afterTextChanged(Editable s) {
|
public void afterTextChanged(Editable s) {
|
||||||
if( s.length() + charsInToot > maxChar){
|
|
||||||
String content = s.toString().substring(0,(maxChar - charsInToot));
|
|
||||||
toot_cw_content.setText(content);
|
|
||||||
toot_cw_content.setSelection(toot_cw_content.getText().length());
|
|
||||||
Toast.makeText(getApplicationContext(),R.string.toot_no_space,Toast.LENGTH_LONG).show();
|
|
||||||
}
|
|
||||||
int totalChar = toot_cw_content.length() + toot_content.length();
|
int totalChar = toot_cw_content.length() + toot_content.length();
|
||||||
toot_space_left.setText(String.valueOf((maxChar - totalChar)));
|
int remainChar = (maxChar - totalChar);
|
||||||
|
if( remainChar >= 0){
|
||||||
|
toot_it.setEnabled(true);
|
||||||
|
if( theme == Helper.THEME_LIGHT){
|
||||||
|
toot_space_left.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.colorAccent));
|
||||||
|
}else {
|
||||||
|
toot_space_left.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.colorAccentD));
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
toot_it.setEnabled(false);
|
||||||
|
showAToast(getString(R.string.toot_no_space));
|
||||||
|
toot_space_left.setTextColor(Color.RED);
|
||||||
|
|
||||||
|
}
|
||||||
|
toot_space_left.setText(String.valueOf(remainChar));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if( restored != -1 ){
|
if( restored != -1 ){
|
||||||
|
@ -481,6 +495,13 @@ public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAc
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void showAToast (String message){
|
||||||
|
if (mToast != null) {
|
||||||
|
mToast.cancel();
|
||||||
|
}
|
||||||
|
mToast = Toast.makeText(this, message, Toast.LENGTH_SHORT);
|
||||||
|
mToast.show();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
|
|
|
@ -28,7 +28,6 @@ import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
@ -531,10 +530,6 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Profile picture
|
//Profile picture
|
||||||
return convertView;
|
return convertView;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
package fr.gouv.etalab.mastodon.helper;
|
package fr.gouv.etalab.mastodon.helper;
|
||||||
|
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.DownloadManager;
|
import android.app.DownloadManager;
|
||||||
|
@ -53,10 +52,10 @@ import android.text.Html;
|
||||||
import android.text.SpannableString;
|
import android.text.SpannableString;
|
||||||
import android.text.Spanned;
|
import android.text.Spanned;
|
||||||
import android.text.TextPaint;
|
import android.text.TextPaint;
|
||||||
|
import android.text.method.ArrowKeyMovementMethod;
|
||||||
import android.text.method.LinkMovementMethod;
|
import android.text.method.LinkMovementMethod;
|
||||||
import android.text.style.ClickableSpan;
|
import android.text.style.ClickableSpan;
|
||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.SubMenu;
|
import android.view.SubMenu;
|
||||||
|
@ -117,7 +116,6 @@ import fr.gouv.etalab.mastodon.asynctasks.RemoveAccountAsyncTask;
|
||||||
import fr.gouv.etalab.mastodon.client.Entities.Account;
|
import fr.gouv.etalab.mastodon.client.Entities.Account;
|
||||||
import fr.gouv.etalab.mastodon.client.Entities.Mention;
|
import fr.gouv.etalab.mastodon.client.Entities.Mention;
|
||||||
import fr.gouv.etalab.mastodon.client.Entities.Status;
|
import fr.gouv.etalab.mastodon.client.Entities.Status;
|
||||||
import fr.gouv.etalab.mastodon.client.Entities.Tag;
|
|
||||||
import fr.gouv.etalab.mastodon.client.PatchBaseImageDownloader;
|
import fr.gouv.etalab.mastodon.client.PatchBaseImageDownloader;
|
||||||
import fr.gouv.etalab.mastodon.sqlite.AccountDAO;
|
import fr.gouv.etalab.mastodon.sqlite.AccountDAO;
|
||||||
import fr.gouv.etalab.mastodon.sqlite.Sqlite;
|
import fr.gouv.etalab.mastodon.sqlite.Sqlite;
|
||||||
|
@ -171,6 +169,7 @@ public class Helper {
|
||||||
public static final int NOTIFICATION_INTENT = 1;
|
public static final int NOTIFICATION_INTENT = 1;
|
||||||
public static final int HOME_TIMELINE_INTENT = 2;
|
public static final int HOME_TIMELINE_INTENT = 2;
|
||||||
public static final int CHANGE_THEME_INTENT = 3;
|
public static final int CHANGE_THEME_INTENT = 3;
|
||||||
|
public static final int CHANGE_USER_INTENT = 4;
|
||||||
//Settings
|
//Settings
|
||||||
public static final String SET_TOOTS_PER_PAGE = "set_toots_per_page";
|
public static final String SET_TOOTS_PER_PAGE = "set_toots_per_page";
|
||||||
public static final String SET_ACCOUNTS_PER_PAGE = "set_accounts_per_page";
|
public static final String SET_ACCOUNTS_PER_PAGE = "set_accounts_per_page";
|
||||||
|
@ -587,6 +586,7 @@ public class Helper {
|
||||||
File file;
|
File file;
|
||||||
if( bitmap != null) {
|
if( bitmap != null) {
|
||||||
file = new File(myDir, fileName);
|
file = new File(myDir, fileName);
|
||||||
|
//noinspection ResultOfMethodCallIgnored
|
||||||
file.createNewFile();
|
file.createNewFile();
|
||||||
|
|
||||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||||
|
@ -852,10 +852,6 @@ public class Helper {
|
||||||
final NavigationView navigationView = (NavigationView) activity.findViewById(R.id.nav_view);
|
final NavigationView navigationView = (NavigationView) activity.findViewById(R.id.nav_view);
|
||||||
navigationView.getMenu().clear();
|
navigationView.getMenu().clear();
|
||||||
navigationView.inflateMenu(R.menu.activity_main_drawer);
|
navigationView.inflateMenu(R.menu.activity_main_drawer);
|
||||||
if( checkItem ) {
|
|
||||||
navigationView.setCheckedItem(R.id.nav_home);
|
|
||||||
navigationView.getMenu().performIdentifierAction(R.id.nav_home, 0);
|
|
||||||
}
|
|
||||||
SQLiteDatabase db = Sqlite.getInstance(activity, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
SQLiteDatabase db = Sqlite.getInstance(activity, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||||
Account account = new AccountDAO(activity,db).getAccountByID(userID);
|
Account account = new AccountDAO(activity,db).getAccountByID(userID);
|
||||||
//Can happen when an account has been deleted and there is a click on an old notification
|
//Can happen when an account has been deleted and there is a click on an old notification
|
||||||
|
@ -873,6 +869,11 @@ public class Helper {
|
||||||
editor.putString(Helper.PREF_KEY_ID, account.getId());
|
editor.putString(Helper.PREF_KEY_ID, account.getId());
|
||||||
editor.apply();
|
editor.apply();
|
||||||
activity.recreate();
|
activity.recreate();
|
||||||
|
if( checkItem ) {
|
||||||
|
Intent intent = new Intent(activity, MainActivity.class);
|
||||||
|
intent.putExtra(INTENT_ACTION, CHANGE_USER_INTENT);
|
||||||
|
activity.startActivity(intent);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1029,21 +1030,21 @@ public class Helper {
|
||||||
int matchEnd = matcher.end();
|
int matchEnd = matcher.end();
|
||||||
final String url = spannableString.toString().substring(matchStart, matchEnd);
|
final String url = spannableString.toString().substring(matchStart, matchEnd);
|
||||||
spannableString.setSpan(new ClickableSpan() {
|
spannableString.setSpan(new ClickableSpan() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View textView) {
|
public void onClick(View textView) {
|
||||||
Intent intent = new Intent(context, WebviewActivity.class);
|
Intent intent = new Intent(context, WebviewActivity.class);
|
||||||
Bundle b = new Bundle();
|
Bundle b = new Bundle();
|
||||||
b.putString("url", url);
|
b.putString("url", url);
|
||||||
intent.putExtras(b);
|
intent.putExtras(b);
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void updateDrawState(TextPaint ds) {
|
public void updateDrawState(TextPaint ds) {
|
||||||
super.updateDrawState(ds);
|
super.updateDrawState(ds);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
matchStart, matchEnd,
|
matchStart, matchEnd,
|
||||||
Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1057,21 +1058,21 @@ public class Helper {
|
||||||
int startPosition = spannableString.toString().indexOf(targetedAccount);
|
int startPosition = spannableString.toString().indexOf(targetedAccount);
|
||||||
int endPosition = spannableString.toString().lastIndexOf(targetedAccount) + targetedAccount.length();
|
int endPosition = spannableString.toString().lastIndexOf(targetedAccount) + targetedAccount.length();
|
||||||
spannableString.setSpan(new ClickableSpan() {
|
spannableString.setSpan(new ClickableSpan() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View textView) {
|
public void onClick(View textView) {
|
||||||
Intent intent = new Intent(context, ShowAccountActivity.class);
|
Intent intent = new Intent(context, ShowAccountActivity.class);
|
||||||
Bundle b = new Bundle();
|
Bundle b = new Bundle();
|
||||||
b.putString("accountId", mention.getId());
|
b.putString("accountId", mention.getId());
|
||||||
intent.putExtras(b);
|
intent.putExtras(b);
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void updateDrawState(TextPaint ds) {
|
public void updateDrawState(TextPaint ds) {
|
||||||
super.updateDrawState(ds);
|
super.updateDrawState(ds);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
startPosition, endPosition,
|
startPosition, endPosition,
|
||||||
Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1098,7 +1099,11 @@ public class Helper {
|
||||||
}, matchStart, matchEnd, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
}, matchStart, matchEnd, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||||
}
|
}
|
||||||
statusTV.setText(spannableString, TextView.BufferType.SPANNABLE);
|
statusTV.setText(spannableString, TextView.BufferType.SPANNABLE);
|
||||||
|
statusTV.setMovementMethod(null);
|
||||||
statusTV.setMovementMethod(LinkMovementMethod.getInstance());
|
statusTV.setMovementMethod(LinkMovementMethod.getInstance());
|
||||||
|
statusTV.setMovementMethod(ArrowKeyMovementMethod.getInstance());
|
||||||
|
statusTV.setFocusable(true);
|
||||||
|
statusTV.setFocusableInTouchMode(true);
|
||||||
return statusTV;
|
return statusTV;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1116,6 +1121,7 @@ public class Helper {
|
||||||
public static TextView clickableElementsDescription(final Context context, TextView statusTV, String fullContent) {
|
public static TextView clickableElementsDescription(final Context context, TextView statusTV, String fullContent) {
|
||||||
|
|
||||||
SpannableString spannableString;
|
SpannableString spannableString;
|
||||||
|
fullContent = Helper.shortnameToUnicode(fullContent, true);
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
||||||
spannableString = new SpannableString(Html.fromHtml(fullContent, Html.FROM_HTML_MODE_COMPACT));
|
spannableString = new SpannableString(Html.fromHtml(fullContent, Html.FROM_HTML_MODE_COMPACT));
|
||||||
else
|
else
|
||||||
|
@ -1165,7 +1171,9 @@ public class Helper {
|
||||||
}
|
}
|
||||||
}, matchStart, matchEnd, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
}, matchStart, matchEnd, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||||
}
|
}
|
||||||
|
|
||||||
statusTV.setText(spannableString, TextView.BufferType.SPANNABLE);
|
statusTV.setText(spannableString, TextView.BufferType.SPANNABLE);
|
||||||
|
statusTV.setMovementMethod(null);
|
||||||
statusTV.setMovementMethod(LinkMovementMethod.getInstance());
|
statusTV.setMovementMethod(LinkMovementMethod.getInstance());
|
||||||
return statusTV;
|
return statusTV;
|
||||||
}
|
}
|
||||||
|
@ -1371,12 +1379,19 @@ public class Helper {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void unCheckAllMenuItems(@NonNull final Menu menu) {
|
|
||||||
|
|
||||||
|
public static void unCheckAllMenuItems(NavigationView navigationView){
|
||||||
|
navigationView.setCheckedItem(R.id.menu_none);
|
||||||
|
unCheckAllMenuItemsRec(navigationView.getMenu());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void unCheckAllMenuItemsRec(@NonNull final Menu menu) {
|
||||||
int size = menu.size();
|
int size = menu.size();
|
||||||
for (int i = 0; i < size; i++) {
|
for (int i = 0; i < size; i++) {
|
||||||
final MenuItem item = menu.getItem(i);
|
final MenuItem item = menu.getItem(i);
|
||||||
if(item.hasSubMenu()) {
|
if(item.hasSubMenu()) {
|
||||||
unCheckAllMenuItems(item.getSubMenu());
|
unCheckAllMenuItemsRec(item.getSubMenu());
|
||||||
} else {
|
} else {
|
||||||
item.setChecked(false);
|
item.setChecked(false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -159,6 +159,7 @@
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/toot_space_left"
|
android:id="@+id/toot_space_left"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
|
android:textColor="?attr/colorAccent"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
|
|
|
@ -1,19 +1,24 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
|
||||||
<group android:checkableBehavior="single">
|
<group android:checkableBehavior="single">
|
||||||
<item android:id="@+id/nav_account_list"
|
<item android:id="@+id/nav_account_list"
|
||||||
android:visible="false"
|
android:visible="false"
|
||||||
android:title="@string/accounts">
|
android:title="@string/accounts">
|
||||||
<menu /></item>
|
<menu /></item>
|
||||||
</group>
|
</group>
|
||||||
<group android:checkableBehavior="single">
|
<group>
|
||||||
<item
|
<item
|
||||||
android:title="@string/communication_menu_title"
|
android:title="@string/communication_menu_title"
|
||||||
android:id="@+id/nav_main_com"
|
android:id="@+id/nav_main_com"
|
||||||
>
|
>
|
||||||
<menu>
|
<menu>
|
||||||
<group android:checkableBehavior="single">
|
<group android:checkableBehavior="single">
|
||||||
|
<item
|
||||||
|
android:id="@+id/menu_none"
|
||||||
|
android:title=""
|
||||||
|
android:visible="false"/>
|
||||||
<item
|
<item
|
||||||
android:id="@+id/nav_home"
|
android:id="@+id/nav_home"
|
||||||
android:icon="@drawable/ic_action_home"
|
android:icon="@drawable/ic_action_home"
|
||||||
|
|
Loading…
Reference in New Issue