Merged in develop (pull request #30)

This commit is contained in:
tom79 2017-07-22 09:05:41 +00:00
commit b6d42302c7
48 changed files with 795 additions and 358 deletions

View File

@ -5,17 +5,22 @@ The number of libraries is minimized and it does not use tracking tools. The sou
### Features
**Multi-accounts management**
* Add accounts from different instances
* Switch from one account to another by a simple click
**Timelines**
* Federated / Local / Home
* Switch from one timeline to another by using the menu or by swiping the screen.
* Clicks on toots display the related conversations (context)
* Clicks on mentioned accounts display details about these accounts
* Clicks on hashtags display toots containing this hashtags
**Actions on toots**
* Mute an account related to a toot
* Block an account related to a toot
* Report inappropriate toots to administrators
@ -25,7 +30,9 @@ The number of libraries is minimized and it does not use tracking tools. The sou
* Download media
* Translation of toots by a simple click (via the Yandex API)
**Write a toot**
* Add media
* Change the visibility of the toot
* Mention accounts in toots with autocompletion (@ + 2 characters)
@ -34,27 +41,38 @@ The number of libraries is minimized and it does not use tracking tools. The sou
* Toots which have not been sent are saved (drafts) - can be disabled in settings
* Drafts can be edited/deleted/scheduled
**Scheduled toots**
* Can be edited/deleted/scheduled at another date as long as they have not been sent.
**Interaction with accounts**
* Follow/Unfollow/Block/Unblock/Mute/Unmute
* Display details of accounts
* Authorize/Reject follow requests (for locked accounts)
**Searches**
* A top bar allows to make researches for accounts/tags/toots
* A click on a tag displays toots containing this tag
**Network optimization**
* Load of media: Automatic/WIFI only/Ask
* Customization of the number of toots/accounts per load
**Notifications**
* Notifications for new toots on the home page (could be disabled in settings)
* Notifications for new events (could be disabled or filtered in settings)
**Built-in browser**
* Full screen videos
* Disable JavaScript (default: enabled)
* Disable third-party cookies (default: disabled)

View File

@ -7,8 +7,8 @@ android {
applicationId "fr.gouv.etalab.mastodon"
minSdkVersion 15
targetSdkVersion 25
versionCode 32
versionName "1.3.5"
versionCode 33
versionName "1.3.6"
}
buildTypes {
release {

Binary file not shown.

View File

@ -110,6 +110,7 @@
android:fitsSystemWindows="true"
android:configChanges="orientation|screenSize"
android:label="@string/app_name"
android:theme="@style/AppTheme_NoActionBar"
/>
<activity
android:name="fr.gouv.etalab.mastodon.activities.SplashActivity"

View File

@ -101,7 +101,7 @@ public class HashTagActivity extends AppCompatActivity implements OnRetrieveFeed
textviewNoAction = (RelativeLayout) findViewById(R.id.no_action);
mainLoader.setVisibility(View.VISIBLE);
nextElementLoader.setVisibility(View.GONE);
statusListAdapter = new StatusListAdapter(HashTagActivity.this, RetrieveFeedsAsyncTask.Type.TAG, isOnWifi, behaviorWithAttachments, this.statuses);
statusListAdapter = new StatusListAdapter(HashTagActivity.this, RetrieveFeedsAsyncTask.Type.TAG, null, isOnWifi, behaviorWithAttachments, this.statuses);
lv_status.setAdapter(statusListAdapter);
setTitle(String.format("#%s", tag));
swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {

View File

@ -128,7 +128,7 @@ public class LoginActivity extends AppCompatActivity {
parameters.add(Helper.CLIENT_NAME, Helper.CLIENT_NAME_VALUE);
parameters.add(Helper.REDIRECT_URIS, client_id_for_webview?Helper.REDIRECT_CONTENT_WEB:Helper.REDIRECT_CONTENT);
parameters.add(Helper.SCOPES, Helper.OAUTH_SCOPES);
parameters.add(Helper.WEBSITE,"https://" + Helper.getLiveInstance(getApplicationContext()));
parameters.add(Helper.WEBSITE, Helper.WEBSITE_VALUE);
new OauthClient(instance).post(action, parameters, new AsyncHttpResponseHandler() {
@Override
public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {

View File

@ -23,11 +23,12 @@ import android.os.AsyncTask;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AlertDialog;
import android.util.Log;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.support.v7.widget.SearchView;
import android.view.View;
import android.support.design.widget.NavigationView;
import android.support.v4.view.GravityCompat;
@ -38,8 +39,10 @@ import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiskCache;
@ -51,6 +54,7 @@ import com.nostra13.universalimageloader.core.display.RoundedBitmapDisplayer;
import java.io.File;
import java.util.HashMap;
import java.util.Locale;
import java.util.Stack;
import fr.gouv.etalab.mastodon.asynctasks.UpdateAccountInfoByIDAsyncTask;
import fr.gouv.etalab.mastodon.client.Entities.Account;
@ -73,31 +77,33 @@ 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.NOTIFICATION_INTENT;
import static fr.gouv.etalab.mastodon.helper.Helper.PREF_KEY_ID;
import static fr.gouv.etalab.mastodon.helper.Helper.changeDrawableColor;
import static fr.gouv.etalab.mastodon.helper.Helper.changeUser;
import static fr.gouv.etalab.mastodon.helper.Helper.loadPPInActionBar;
import static fr.gouv.etalab.mastodon.helper.Helper.menuAccounts;
import static fr.gouv.etalab.mastodon.helper.Helper.updateHeaderAccountInfo;
import android.support.v4.app.FragmentStatePagerAdapter;
public class MainActivity extends AppCompatActivity
implements NavigationView.OnNavigationItemSelectedListener, OnUpdateAccountInfoInterface {
private FloatingActionButton toot;
private boolean first = true;
private HashMap<String, String> tagTile = new HashMap<>();
private HashMap<String, Integer> tagItem = new HashMap<>();
private Toolbar toolbar;
private TextView toolbarTitle;
private ImageView pp_actionBar;
private SearchView toolbar_search;
private ImageLoader imageLoader;
private DisplayImageOptions options;
private View headerLayout;
static final int MIN_DISTANCE = 100;
private float downX, downY;
private int currentScreen = 1;
private actionSwipe currentAction;
public static String currentLocale;
private TabLayout tabLayout;
private ViewPager viewPager;
private RelativeLayout main_app_container;
private Stack<Integer> stackBack = new Stack<>();
private enum actionSwipe{
RIGHT_TO_LEFT,
LEFT_TO_RIGHT,
POP
public MainActivity() {
}
@Override
@ -106,13 +112,14 @@ public class MainActivity extends AppCompatActivity
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){
setTheme(R.style.AppTheme_NoActionBar);
}else {
setTheme(R.style.AppThemeDark_NoActionBar);
}
setContentView(R.layout.activity_main);
//Test if user is still log in
if( ! Helper.isLoggedIn(getApplicationContext())) {
//It is not, the user is redirected to the login page
@ -121,10 +128,147 @@ public class MainActivity extends AppCompatActivity
finish();
return;
}
if( theme == Helper.THEME_DARK){
changeDrawableColor(getApplicationContext(), R.drawable.ic_action_home_tl,R.color.dark_text);
changeDrawableColor(getApplicationContext(), R.drawable.ic_action_users_tl,R.color.dark_text);
changeDrawableColor(getApplicationContext(), R.drawable.ic_action_globe_tl,R.color.dark_text);
changeDrawableColor(getApplicationContext(), R.drawable.ic_notifications_tl,R.color.dark_text);
}else {
changeDrawableColor(getApplicationContext(), R.drawable.ic_action_home_tl,R.color.black);
changeDrawableColor(getApplicationContext(), R.drawable.ic_action_users_tl,R.color.black);
changeDrawableColor(getApplicationContext(), R.drawable.ic_action_globe_tl,R.color.black);
changeDrawableColor(getApplicationContext(), R.drawable.ic_notifications_tl,R.color.black);
}
Helper.fillMapEmoji(getApplicationContext());
//Here, the user is authenticated
toolbar = (Toolbar) findViewById(R.id.toolbar);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
toolbarTitle = (TextView) toolbar.findViewById(R.id.toolbar_title);
pp_actionBar = (ImageView) toolbar.findViewById(R.id.pp_actionBar);
toolbar_search = (SearchView) toolbar.findViewById(R.id.toolbar_search);
tabLayout = (TabLayout) findViewById(R.id.tabLayout);
viewPager = (ViewPager) findViewById(R.id.viewpager);
main_app_container = (RelativeLayout) findViewById(R.id.main_app_container);
viewPager.setAdapter(new PagerAdapter
(getSupportFragmentManager(), tabLayout.getTabCount()));
viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
@Override
public void onTabSelected(TabLayout.Tab tab) {
viewPager.setCurrentItem(tab.getPosition());
if (stackBack.empty())
stackBack.push(0);
if (stackBack.contains(tab.getPosition())) {
stackBack.remove(stackBack.indexOf(tab.getPosition()));
stackBack.push(tab.getPosition());
} else {
stackBack.push(tab.getPosition());
}
final NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
MenuItem item = null;
String fragmentTag = null;
main_app_container.setVisibility(View.GONE);
viewPager.setVisibility(View.VISIBLE);
tabLayout.setVisibility(View.VISIBLE);
switch (tab.getPosition()){
case 0:
fragmentTag = "HOME_TIMELINE";
item = navigationView.getMenu().findItem(R.id.nav_home);
break;
case 1:
fragmentTag = "LOCAL_TIMELINE";
item = navigationView.getMenu().findItem(R.id.nav_local);
break;
case 2:
item = navigationView.getMenu().findItem(R.id.nav_global);
fragmentTag = "PUBLIC_TIMELINE";
break;
case 3:
fragmentTag = "NOTIFICATIONS";
item = navigationView.getMenu().findItem(R.id.nav_notification);
break;
}
if( item != null){
toolbarTitle.setText(item.getTitle());
populateTitleWithTag(fragmentTag, item.getTitle().toString(), item.getItemId());
unCheckAllMenuItems(navigationView.getMenu());
item.setChecked(true);
}
if( tab.getPosition() < 3 )
toot.setVisibility(View.VISIBLE);
else
toot.setVisibility(View.GONE);
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
drawer.closeDrawer(GravityCompat.START);
}
@Override
public void onTabUnselected(TabLayout.Tab tab) {
}
@Override
public void onTabReselected(TabLayout.Tab tab) {
if( viewPager.getVisibility() == View.GONE){
viewPager.setVisibility(View.VISIBLE);
tabLayout.setVisibility(View.VISIBLE);
main_app_container.setVisibility(View.GONE);
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
drawer.closeDrawer(GravityCompat.START);
}
if( tab.getPosition() <3 )
toot.setVisibility(View.VISIBLE);
else
toot.setVisibility(View.GONE);
}
});
toolbar_search.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
//Hide keyboard
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(toolbar_search.getWindowToken(), 0);
Intent intent = new Intent(MainActivity.this, SearchResultActivity.class);
intent.putExtra("search", query);
startActivity(intent);
return true;
}
@Override
public boolean onQueryTextChange(String newText) {
return false;
}
});
//Hide/Close the searchview
toolbar_search.setOnCloseListener(new SearchView.OnCloseListener() {
@Override
public boolean onClose() {
toolbarTitle.setVisibility(View.VISIBLE);
pp_actionBar.setVisibility(View.VISIBLE);
//your code here
return false;
}
});
toolbar_search.setOnSearchClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if( toolbar_search.isIconified()){
toolbarTitle.setVisibility(View.VISIBLE);
pp_actionBar.setVisibility(View.VISIBLE);
}else {
toolbarTitle.setVisibility(View.GONE);
pp_actionBar.setVisibility(View.GONE);
}
}
});
//Hide the default title
if( getSupportActionBar() != null)
getSupportActionBar().setDisplayShowTitleEnabled(false);
//Defines the current locale of the device in a static variable
currentLocale = Helper.currentLocale(getApplicationContext());
@ -168,7 +312,7 @@ public class MainActivity extends AppCompatActivity
String prefKeyOauthTokenT = sharedpreferences.getString(Helper.PREF_KEY_OAUTH_TOKEN, null);
Account account = new AccountDAO(getApplicationContext(), db).getAccountByToken(prefKeyOauthTokenT);
updateHeaderAccountInfo(MainActivity.this, account, headerLayout, imageLoader, options);
loadPPInActionBar(MainActivity.this, account.getAvatar());
//Locked account can see follow request
if (account.isLocked()) {
navigationView.getMenu().findItem(R.id.nav_follow_request).setVisible(true);
@ -187,32 +331,8 @@ public class MainActivity extends AppCompatActivity
if (savedInstanceState == null && !matchingIntent) {
navigationView.setCheckedItem(R.id.nav_home);
navigationView.getMenu().performIdentifierAction(R.id.nav_home, 0);
toolbarTitle.setText(R.string.home_menu);
}
//Title and menu selection when back pressed
getSupportFragmentManager().addOnBackStackChangedListener(
new FragmentManager.OnBackStackChangedListener() {
public void onBackStackChanged() {
FragmentManager fm = getSupportFragmentManager();
if( fm != null && fm.getBackStackEntryCount() > 0) {
String fragmentTag = fm.getBackStackEntryAt(fm.getBackStackEntryCount() - 1).getName();
if( fragmentTag != null) {
if( tagTile.get(fragmentTag) != null)
setTitle(tagTile.get(fragmentTag));
if( tagItem.get(fragmentTag) != null) {
unCheckAllMenuItems(navigationView.getMenu());
if( navigationView.getMenu().findItem(tagItem.get(fragmentTag)) != null)
navigationView.getMenu().findItem(tagItem.get(fragmentTag)).setChecked(true);
}
if( fragmentTag.equals("HOME_TIMELINE") || fragmentTag.equals("LOCAL_TIMELINE") || fragmentTag.equals("PUBLIC_TIMELINE") || fragmentTag.equals("SCHEDULED")){
toot.setVisibility(View.VISIBLE);
}else {
toot.setVisibility(View.GONE);
}
}
}
}
});
}
private void unCheckAllMenuItems(@NonNull final Menu menu) {
@ -297,18 +417,45 @@ public class MainActivity extends AppCompatActivity
if (drawer.isDrawerOpen(GravityCompat.START)) {
drawer.closeDrawer(GravityCompat.START);
} else {
super.onBackPressed();
//Hide search bar on back pressed
if( toolbar.getChildCount() > 0) {
for (int i = 0; i < toolbar.getChildCount(); i++) {
if (toolbar.getChildAt(i) instanceof EditText) {
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow((toolbar.getChildAt(i)).getWindowToken(), 0);
toolbar.removeViewAt(i);
if( !toolbar_search.isIconified()){
toolbar_search.setIconified(true);
}
if( viewPager.getVisibility() == View.VISIBLE){
if (stackBack.size() > 1) {
stackBack.pop();
viewPager.setCurrentItem(stackBack.lastElement());
}else {
super.onBackPressed();
}
}else {
viewPager.setVisibility(View.VISIBLE);
tabLayout.setVisibility(View.VISIBLE);
main_app_container.setVisibility(View.GONE);
final NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
unCheckAllMenuItems(navigationView.getMenu());
toot.setVisibility(View.VISIBLE);
switch (viewPager.getCurrentItem()){
case 0:
toolbarTitle.setText(R.string.home_menu);
navigationView.getMenu().findItem(R.id.nav_home).setChecked(true);
break;
case 1:
toolbarTitle.setText(R.string.local_menu);
navigationView.getMenu().findItem(R.id.nav_local).setChecked(true);
break;
case 2:
toolbarTitle.setText(R.string.global_menu);
navigationView.getMenu().findItem(R.id.nav_global).setChecked(true);
break;
case 3:
toolbarTitle.setText(R.string.notifications);
navigationView.getMenu().findItem(R.id.nav_notification).setChecked(true);
break;
}
}
}
}
}
@ -377,68 +524,6 @@ public class MainActivity extends AppCompatActivity
})
.setIcon(android.R.drawable.ic_dialog_alert)
.show();
} else if(id == R.id.action_search){
if( toolbar.getChildCount() > 0){
for(int i = 0 ; i < toolbar.getChildCount() ; i++){
if(toolbar.getChildAt(i) instanceof EditText){
//Nothing in the search bar
if( ((EditText) toolbar.getChildAt(i)).getText().toString().trim().equals("")){
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow((toolbar.getChildAt(i)).getWindowToken(), 0);
toolbar.removeViewAt(i);
return true;
}else{
String searchTag = ((EditText) toolbar.getChildAt(i)).getText().toString();
toot.setVisibility(View.VISIBLE);
View view = this.getCurrentFocus();
//Hide keyboard
if (view != null) {
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
Intent intent = new Intent(MainActivity.this, SearchResultActivity.class);
intent.putExtra("search", searchTag);
startActivity(intent);
return true;
}
}
}
//Open the search bar
final EditText search = new EditText(MainActivity.this);
search.setSingleLine(true);
search.setLayoutParams( new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT,1.0f));
toolbar.addView(search);
search.requestFocus();
search.setOnKeyListener(new View.OnKeyListener() {
public boolean onKey(View v, int keyCode, KeyEvent event) {
if ((event.getAction() == KeyEvent.ACTION_DOWN) &&
(keyCode == KeyEvent.KEYCODE_ENTER)) {
String searchTag = search.getText().toString();
toot.setVisibility(View.VISIBLE);
View view = getCurrentFocus();
//Hide keyboard
if (view != null) {
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
Intent intent = new Intent(MainActivity.this, SearchResultActivity.class);
intent.putExtra("search", searchTag);
startActivity(intent);
return true;
}
return false;
}
});
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED,0);
}
}
return super.onOptionsItemSelected(item);
@ -460,90 +545,47 @@ public class MainActivity extends AppCompatActivity
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
// Handle navigation view item clicks here.
int id = item.getItemId();
final NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
unCheckAllMenuItems(navigationView.getMenu());
item.setChecked(true);
//Remove the search bar
if( toolbar.getChildCount() > 0) {
for (int i = 0; i < toolbar.getChildCount(); i++) {
if (toolbar.getChildAt(i) instanceof EditText) {
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow((toolbar.getChildAt(i)).getWindowToken(), 0);
toolbar.removeViewAt(i);
break;
}
}
if( !toolbar_search.isIconified() ) {
toolbarTitle.setVisibility(View.VISIBLE);
pp_actionBar.setVisibility(View.VISIBLE);
toolbar_search.setIconified(true);
}
if (id == R.id.nav_home) {
//noinspection ConstantConditions
tabLayout.getTabAt(0).select();
return true;
} else if (id == R.id.nav_local) {
//noinspection ConstantConditions
tabLayout.getTabAt(1).select();
return true;
} else if (id == R.id.nav_global) {
//noinspection ConstantConditions
tabLayout.getTabAt(2).select();
return true;
} else if( id == R.id.nav_notification){
//noinspection ConstantConditions
tabLayout.getTabAt(3).select();
return true;
}
DisplayStatusFragment statusFragment;
DisplayAccountsFragment accountsFragment;
Bundle bundle = new Bundle();
FragmentManager fragmentManager = getSupportFragmentManager();
String fragmentTag = null;
currentScreen = -1;
if (id == R.id.nav_home) {
toot.setVisibility(View.VISIBLE);
statusFragment = new DisplayStatusFragment();
bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.HOME);
statusFragment.setArguments(bundle);
fragmentTag = "HOME_TIMELINE";
currentScreen = 1;
if(! first) {
if( currentAction == actionSwipe.RIGHT_TO_LEFT)
fragmentManager.beginTransaction().setCustomAnimations(R.anim.enter_from_right, R.anim.exit_to_left, R.anim.enter_from_left, R.anim.exit_to_right)
.replace(R.id.main_app_container, statusFragment, fragmentTag).addToBackStack(fragmentTag).commit();
else if( currentAction == actionSwipe.LEFT_TO_RIGHT)
fragmentManager.beginTransaction().setCustomAnimations(R.anim.enter_from_left, R.anim.exit_to_right, R.anim.enter_from_right, R.anim.exit_to_left)
.replace(R.id.main_app_container, statusFragment, fragmentTag).addToBackStack(fragmentTag).commit();
else
fragmentManager.beginTransaction().setCustomAnimations(R.anim.fadein, R.anim.fadeout)
.replace(R.id.main_app_container, statusFragment, fragmentTag).addToBackStack(fragmentTag).commit();
}else{
if( currentAction == actionSwipe.RIGHT_TO_LEFT)
fragmentManager.beginTransaction().setCustomAnimations(R.anim.enter_from_right, R.anim.exit_to_left, R.anim.enter_from_left, R.anim.exit_to_right)
.replace(R.id.main_app_container, statusFragment, fragmentTag).commit();
else if( currentAction == actionSwipe.LEFT_TO_RIGHT)
fragmentManager.beginTransaction().setCustomAnimations(R.anim.enter_from_left, R.anim.exit_to_right, R.anim.enter_from_right, R.anim.exit_to_left)
.replace(R.id.main_app_container, statusFragment, fragmentTag).commit();
else
fragmentManager.beginTransaction().setCustomAnimations(R.anim.fadein, R.anim.fadeout)
.replace(R.id.main_app_container, statusFragment, fragmentTag).commit();
first = false;
}
} else if (id == R.id.nav_local) {
toot.setVisibility(View.VISIBLE);
statusFragment = new DisplayStatusFragment();
bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.LOCAL);
statusFragment.setArguments(bundle);
fragmentTag = "LOCAL_TIMELINE";
currentScreen = 2;
if( currentAction == actionSwipe.RIGHT_TO_LEFT)
fragmentManager.beginTransaction().setCustomAnimations(R.anim.enter_from_right, R.anim.exit_to_left, R.anim.enter_from_left, R.anim.exit_to_right)
.replace(R.id.main_app_container, statusFragment, fragmentTag).addToBackStack(fragmentTag).commit();
else if( currentAction == actionSwipe.LEFT_TO_RIGHT)
fragmentManager.beginTransaction().setCustomAnimations(R.anim.enter_from_left, R.anim.exit_to_right, R.anim.enter_from_right, R.anim.exit_to_left)
.replace(R.id.main_app_container, statusFragment, fragmentTag).addToBackStack(fragmentTag).commit();
else
fragmentManager.beginTransaction().setCustomAnimations(R.anim.fadein, R.anim.fadeout)
.replace(R.id.main_app_container, statusFragment, fragmentTag).addToBackStack(fragmentTag).commit();
} else if (id == R.id.nav_global) {
toot.setVisibility(View.VISIBLE);
statusFragment = new DisplayStatusFragment();
bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.PUBLIC);
statusFragment.setArguments(bundle);
fragmentTag = "PUBLIC_TIMELINE";
currentScreen = 3;
if( currentAction == actionSwipe.RIGHT_TO_LEFT)
fragmentManager.beginTransaction().setCustomAnimations(R.anim.enter_from_right, R.anim.exit_to_left, R.anim.enter_from_left, R.anim.exit_to_right)
.replace(R.id.main_app_container, statusFragment, fragmentTag).addToBackStack(fragmentTag).commit();
else if( currentAction == actionSwipe.LEFT_TO_RIGHT)
fragmentManager.beginTransaction().setCustomAnimations(R.anim.enter_from_left, R.anim.exit_to_right, R.anim.enter_from_right, R.anim.exit_to_left)
.replace(R.id.main_app_container, statusFragment, fragmentTag).addToBackStack(fragmentTag).commit();
else
fragmentManager.beginTransaction().setCustomAnimations(R.anim.fadein, R.anim.fadeout)
.replace(R.id.main_app_container, statusFragment, fragmentTag).addToBackStack(fragmentTag).commit();
} else if (id == R.id.nav_settings) {
main_app_container.setVisibility(View.VISIBLE);
viewPager.setVisibility(View.GONE);
tabLayout.setVisibility(View.GONE);
if (id == R.id.nav_settings) {
toot.setVisibility(View.GONE);
TabLayoutSettingsFragment tabLayoutSettingsFragment= new TabLayoutSettingsFragment();
fragmentTag = "TABLAYOUT_SETTINGS";
fragmentManager.beginTransaction()
.replace(R.id.main_app_container, tabLayoutSettingsFragment, fragmentTag).addToBackStack(fragmentTag).commit();
.replace(R.id.main_app_container, tabLayoutSettingsFragment, fragmentTag).commit();
} else if (id == R.id.nav_favorites) {
toot.setVisibility(View.GONE);
@ -552,7 +594,7 @@ public class MainActivity extends AppCompatActivity
statusFragment.setArguments(bundle);
fragmentTag = "FAVOURITES";
fragmentManager.beginTransaction()
.replace(R.id.main_app_container, statusFragment, fragmentTag).addToBackStack(fragmentTag).commit();
.replace(R.id.main_app_container, statusFragment, fragmentTag).commit();
} else if (id == R.id.nav_blocked) {
toot.setVisibility(View.GONE);
accountsFragment = new DisplayAccountsFragment();
@ -560,7 +602,7 @@ public class MainActivity extends AppCompatActivity
accountsFragment.setArguments(bundle);
fragmentTag = "BLOCKS";
fragmentManager.beginTransaction()
.replace(R.id.main_app_container, accountsFragment, fragmentTag).addToBackStack(fragmentTag).commit();
.replace(R.id.main_app_container, accountsFragment, fragmentTag).commit();
}else if (id == R.id.nav_muted) {
toot.setVisibility(View.GONE);
accountsFragment = new DisplayAccountsFragment();
@ -568,27 +610,22 @@ public class MainActivity extends AppCompatActivity
accountsFragment.setArguments(bundle);
fragmentTag = "MUTED";
fragmentManager.beginTransaction()
.replace(R.id.main_app_container, accountsFragment, fragmentTag).addToBackStack(fragmentTag).commit();
.replace(R.id.main_app_container, accountsFragment, fragmentTag).commit();
}else if (id == R.id.nav_scheduled) {
toot.setVisibility(View.VISIBLE);
DisplayScheduledTootsFragment displayScheduledTootsFragment = new DisplayScheduledTootsFragment();
fragmentTag = "SCHEDULED";
fragmentManager.beginTransaction()
.replace(R.id.main_app_container, displayScheduledTootsFragment, fragmentTag).addToBackStack(fragmentTag).commit();
} else if( id == R.id.nav_notification){
toot.setVisibility(View.GONE);
DisplayNotificationsFragment notificationsFragment = new DisplayNotificationsFragment();
fragmentTag = "NOTIFICATIONS";
fragmentManager.beginTransaction()
.replace(R.id.main_app_container, notificationsFragment, fragmentTag).addToBackStack(fragmentTag).commit();
.replace(R.id.main_app_container, displayScheduledTootsFragment, fragmentTag).commit();
}else if( id == R.id.nav_follow_request){
toot.setVisibility(View.GONE);
DisplayFollowRequestSentFragment followRequestSentFragment = new DisplayFollowRequestSentFragment();
fragmentTag = "FOLLOW_REQUEST_SENT";
fragmentManager.beginTransaction()
.replace(R.id.main_app_container, followRequestSentFragment, fragmentTag).addToBackStack(fragmentTag).commit();
.replace(R.id.main_app_container, followRequestSentFragment, fragmentTag).commit();
}
setTitle(item.getTitle());
//selectTabBar(fragmentTag);
toolbarTitle.setText(item.getTitle());
populateTitleWithTag(fragmentTag, item.getTitle().toString(), item.getItemId());
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
drawer.closeDrawer(GravityCompat.START);
@ -607,8 +644,8 @@ public class MainActivity extends AppCompatActivity
@Override
public void setTitle(CharSequence title) {
if( getSupportActionBar() != null )
getSupportActionBar().setTitle(title);
if(toolbarTitle != null )
toolbarTitle.setText(title);
}
@Override
@ -628,79 +665,59 @@ public class MainActivity extends AppCompatActivity
}
}
/**
* Manage touch event
* Allows to swipe from timelines
* @param event MotionEvent
* @return boolean
* Page Adapter for settings
*/
@Override
public boolean dispatchTouchEvent(MotionEvent event) {
//Default dispatchTouchEvent is returned when not in timeline page
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
//Menu is opened returns default action
if( drawer.isDrawerOpen(GravityCompat.START))
return super.dispatchTouchEvent(event);
//Current screen is not one of the timelines
if( currentScreen >3 || currentScreen < 1)
return super.dispatchTouchEvent(event);
private class PagerAdapter extends FragmentStatePagerAdapter {
int mNumOfTabs;
switch(event.getAction()){
case MotionEvent.ACTION_DOWN: {
downX = event.getX();
downY = event.getY();
return super.dispatchTouchEvent(event);
}
case MotionEvent.ACTION_UP: {
float upX = event.getX();
float upY = event.getY();
float deltaX = downX - upX;
float deltaY = downY - upY;
// swipe horizontal
if( downX > MIN_DISTANCE & (Math.abs(deltaX) > MIN_DISTANCE && Math.abs(deltaY) < MIN_DISTANCE)){
drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
if(deltaX < 0) { switchOnSwipe(actionSwipe.LEFT_TO_RIGHT); drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);return true; }
if(deltaX > 0) { switchOnSwipe(actionSwipe.RIGHT_TO_LEFT); drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);return true; }
}else{
currentAction = actionSwipe.POP;
}
}
private PagerAdapter(FragmentManager fm, int NumOfTabs) {
super(fm);
this.mNumOfTabs = NumOfTabs;
}
return super.dispatchTouchEvent(event);
}
@Override
public Fragment getItem(int position) {
//Remove the search bar
if( !toolbar_search.isIconified() ) {
toolbarTitle.setVisibility(View.VISIBLE);
pp_actionBar.setVisibility(View.VISIBLE);
toolbar_search.setIconified(true);
}
//Selection comes from another menu, no action to do
DisplayStatusFragment statusFragment;
Bundle bundle = new Bundle();
toot.setVisibility(View.VISIBLE);
switch (position) {
case 0:
statusFragment = new DisplayStatusFragment();
bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.HOME);
statusFragment.setArguments(bundle);
return statusFragment;
case 1:
statusFragment = new DisplayStatusFragment();
bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.LOCAL);
statusFragment.setArguments(bundle);
return statusFragment;
case 2:
private void switchOnSwipe(actionSwipe action){
currentScreen = (action == actionSwipe.LEFT_TO_RIGHT)?currentScreen-1:currentScreen+1;
if( currentScreen > 3 )
currentScreen = 1;
if( currentScreen < 1)
currentScreen = 3;
currentAction = action;
final NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
switch (currentScreen){
case 1:
unCheckAllMenuItems(navigationView.getMenu());
navigationView.getMenu().performIdentifierAction(R.id.nav_home, 0);
if( navigationView.getMenu().findItem(R.id.nav_home) != null)
navigationView.getMenu().findItem(R.id.nav_home).setChecked(true);
break;
case 2:
unCheckAllMenuItems(navigationView.getMenu());
navigationView.getMenu().performIdentifierAction(R.id.nav_local, 0);
if( navigationView.getMenu().findItem(R.id.nav_local) != null)
navigationView.getMenu().findItem(R.id.nav_local).setChecked(true);
break;
case 3:
unCheckAllMenuItems(navigationView.getMenu());
navigationView.getMenu().performIdentifierAction(R.id.nav_global, 0);
if( navigationView.getMenu().findItem(R.id.nav_global) != null)
navigationView.getMenu().findItem(R.id.nav_global).setChecked(true);
break;
default:
break;
statusFragment = new DisplayStatusFragment();
bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.PUBLIC);
statusFragment.setArguments(bundle);
return statusFragment;
case 3:
return new DisplayNotificationsFragment();
}
return null;
}
@Override
public int getCount() {
return mNumOfTabs;
}
}
}

View File

@ -34,6 +34,7 @@ import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.text.Html;
import android.util.Log;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
@ -115,16 +116,9 @@ public class ShowAccountActivity extends AppCompatActivity implements OnPostActi
}
setContentView(R.layout.activity_show_account);
instanceValue += 1;
imageLoader = ImageLoader.getInstance();
statuses = new ArrayList<>();
boolean isOnWifi = Helper.isOnWIFI(getApplicationContext());
int behaviorWithAttachments = sharedpreferences.getInt(Helper.SET_ATTACHMENT_ACTION, Helper.ATTACHMENT_ALWAYS);
statusListAdapter = new StatusListAdapter(getApplicationContext(), RetrieveFeedsAsyncTask.Type.USER, isOnWifi, behaviorWithAttachments, this.statuses);
options = new DisplayImageOptions.Builder().displayer(new SimpleBitmapDisplayer()).cacheInMemory(false)
.cacheOnDisk(true).resetViewBeforeLoading(true).build();
Bundle b = getIntent().getExtras();
account_follow = (Button) findViewById(R.id.account_follow);
account_follow.setEnabled(false);
Bundle b = getIntent().getExtras();
if(b != null){
accountId = b.getString("accountId");
new RetrieveRelationshipAsyncTask(getApplicationContext(), accountId,ShowAccountActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
@ -136,6 +130,15 @@ public class ShowAccountActivity extends AppCompatActivity implements OnPostActi
}else{
Toast.makeText(this,R.string.toast_error_loading_account,Toast.LENGTH_LONG).show();
}
imageLoader = ImageLoader.getInstance();
statuses = new ArrayList<>();
boolean isOnWifi = Helper.isOnWIFI(getApplicationContext());
int behaviorWithAttachments = sharedpreferences.getInt(Helper.SET_ATTACHMENT_ACTION, Helper.ATTACHMENT_ALWAYS);
statusListAdapter = new StatusListAdapter(getApplicationContext(), RetrieveFeedsAsyncTask.Type.USER, accountId, isOnWifi, behaviorWithAttachments, this.statuses);
options = new DisplayImageOptions.Builder().displayer(new SimpleBitmapDisplayer()).cacheInMemory(false)
.cacheOnDisk(true).resetViewBeforeLoading(true).build();
if( getSupportActionBar() != null)
getSupportActionBar().setDisplayHomeAsUpEnabled(true);

View File

@ -180,7 +180,7 @@ public class ShowConversationActivity extends AppCompatActivity implements OnRet
}
}
RelativeLayout loader = (RelativeLayout) findViewById(R.id.loader);
StatusListAdapter statusListAdapter = new StatusListAdapter(ShowConversationActivity.this, RetrieveFeedsAsyncTask.Type.CONTEXT, isOnWifi, behaviorWithAttachments, statuses);
StatusListAdapter statusListAdapter = new StatusListAdapter(ShowConversationActivity.this, RetrieveFeedsAsyncTask.Type.CONTEXT, null, isOnWifi, behaviorWithAttachments, statuses);
lv_status.setAdapter(statusListAdapter);
statusListAdapter.notifyDataSetChanged();
loader.setVisibility(View.GONE);

View File

@ -24,16 +24,22 @@ import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.database.sqlite.SQLiteDatabase;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.speech.RecognizerIntent;
import android.support.design.widget.FloatingActionButton;
import android.support.v4.content.LocalBroadcastManager;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.text.Editable;
import android.text.Html;
import android.text.TextWatcher;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
@ -57,7 +63,9 @@ import android.widget.Toast;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.assist.FailReason;
import com.nostra13.universalimageloader.core.display.SimpleBitmapDisplayer;
import com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListener;
import java.io.FileNotFoundException;
import java.io.InputStream;
@ -71,6 +79,7 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import fr.gouv.etalab.mastodon.asynctasks.PostActionAsyncTask;
import fr.gouv.etalab.mastodon.asynctasks.PostStatusAsyncTask;
import fr.gouv.etalab.mastodon.asynctasks.RetrieveSearchAccountsAsyncTask;
import fr.gouv.etalab.mastodon.asynctasks.UploadActionAsyncTask;
import fr.gouv.etalab.mastodon.client.API;
@ -85,6 +94,7 @@ import fr.gouv.etalab.mastodon.drawers.AccountsSearchAdapter;
import fr.gouv.etalab.mastodon.drawers.DraftsListAdapter;
import fr.gouv.etalab.mastodon.helper.Helper;
import fr.gouv.etalab.mastodon.interfaces.OnPostActionInterface;
import fr.gouv.etalab.mastodon.interfaces.OnPostStatusActionInterface;
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveAttachmentInterface;
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveSearcAccountshInterface;
import fr.gouv.etalab.mastodon.jobs.ScheduledTootsSyncJob;
@ -93,14 +103,17 @@ import fr.gouv.etalab.mastodon.sqlite.StatusStoredDAO;
import fr.gouv.etalab.mastodon.sqlite.Sqlite;
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.INTENT_ACTION;
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.
* Toot activity class
*/
public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAccountshInterface, OnRetrieveAttachmentInterface, OnPostActionInterface {
public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAccountshInterface, OnRetrieveAttachmentInterface, OnPostStatusActionInterface {
private int charsInCw;
@ -128,6 +141,8 @@ public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAc
private CheckBox toot_sensitive;
public long currentToId;
private long restored;
private TextView title;
private ImageView pp_actionBar;
private String pattern = "^.*(@([a-zA-Z0-9_]{2,}))$";
@ -143,8 +158,27 @@ public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAc
}
setContentView(R.layout.activity_toot);
if( getSupportActionBar() != null)
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
ActionBar actionBar = getSupportActionBar();
if( actionBar != null ){
LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.toot_action_bar, null);
actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
ImageView close_toot = (ImageView) actionBar.getCustomView().findViewById(R.id.close_toot);
close_toot.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
title = (TextView) actionBar.getCustomView().findViewById(R.id.toolbar_title);
pp_actionBar = (ImageView) actionBar.getCustomView().findViewById(R.id.pp_actionBar);
}
//By default the toot is not restored so the id -1 is defined
currentToId = -1;
imageLoader = ImageLoader.getInstance();
@ -201,8 +235,35 @@ public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAc
if( tootReply != null) {
tootReply();
}else {
setTitle(R.string.toot_title);
if( title != null)
title.setText(getString(R.string.toot_title));
else
setTitle(R.string.toot_title);
}
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
Account account = new AccountDAO(getApplicationContext(),db).getAccountByID(userId);
String url = account.getAvatar();
if( url.startsWith("/") ){
url = "https://" + Helper.getLiveInstance(getApplicationContext()) + account.getAvatar();
}
imageLoader.loadImage(url, options, new SimpleImageLoadingListener(){
@Override
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
super.onLoadingComplete(imageUri, view, loadedImage);
BitmapDrawable ppDrawable = new BitmapDrawable(getResources(), Bitmap.createScaledBitmap(loadedImage, (int) Helper.convertDpToPixel(25, getApplicationContext()), (int) Helper.convertDpToPixel(25, getApplicationContext()), true));
if( pp_actionBar != null){
pp_actionBar.setImageDrawable(ppDrawable);
} else if( getSupportActionBar() != null){
getSupportActionBar().setIcon(ppDrawable);
getSupportActionBar().setDisplayShowHomeEnabled(true);
}
}
@Override
public void onLoadingFailed(java.lang.String imageUri, android.view.View view, FailReason failReason){
}});
if( sharedContent != null ){ //Shared content
if( sharedSubject != null){
@ -238,9 +299,7 @@ public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAc
LocalBroadcastManager.getInstance(this).registerReceiver(search_validate, new IntentFilter(Helper.SEARCH_VALIDATE_ACCOUNT));
FloatingActionButton toot_close_accounts = (FloatingActionButton) findViewById(R.id.toot_close_accounts);
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
Account account = new AccountDAO(getApplicationContext(),db).getAccountByID(userId);
boolean isAccountPrivate = account.isLocked();
FloatingActionButton ic_close = (FloatingActionButton) findViewById(R.id.toot_close_reply);
@ -316,7 +375,7 @@ public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAc
toot.setContent(toot_content.getText().toString().trim());
if( tootReply != null)
toot.setIn_reply_to_id(tootReply.getId());
new PostActionAsyncTask(getApplicationContext(), API.StatusAction.CREATESTATUS, null, toot, null, TootActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
new PostStatusAsyncTask(getApplicationContext(), toot, TootActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
});
@ -764,40 +823,57 @@ public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAc
storeToot(true);
}
@Override
public void onPostAction(int statusCode, API.StatusAction statusAction, String userId, Error error) {
if( error != null){
public void onPostStatusAction(APIResponse apiResponse) {
if( apiResponse.getError() != null){
final SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
boolean show_error_messages = sharedpreferences.getBoolean(Helper.SET_SHOW_ERROR_MESSAGES, true);
if( show_error_messages)
Toast.makeText(getApplicationContext(), error.getError(),Toast.LENGTH_LONG).show();
Toast.makeText(getApplicationContext(), apiResponse.getError().getError(),Toast.LENGTH_LONG).show();
return;
}
if( statusCode == 200){
//Clear the toot
toot_content.setText("");
toot_cw_content.setText("");
if( attachments != null) {
for (Attachment attachment : attachments) {
View namebar = findViewById(Integer.parseInt(attachment.getId()));
if (namebar != null && namebar.getParent() != null)
((ViewGroup) namebar.getParent()).removeView(namebar);
}
List<Attachment> tmp_attachment = new ArrayList<>();
tmp_attachment.addAll(attachments);
attachments.removeAll(tmp_attachment);
tmp_attachment.clear();
//Clear the toot
toot_content.setText("");
toot_cw_content.setText("");
if( attachments != null) {
for (Attachment attachment : attachments) {
View namebar = findViewById(Integer.parseInt(attachment.getId()));
if (namebar != null && namebar.getParent() != null)
((ViewGroup) namebar.getParent()).removeView(namebar);
}
isSensitive = false;
toot_sensitive.setVisibility(View.GONE);
currentToId = -1;
Toast.makeText(TootActivity.this,R.string.toot_sent, Toast.LENGTH_LONG).show();
}else {
Toast.makeText(TootActivity.this,R.string.toast_error, Toast.LENGTH_LONG).show();
List<Attachment> tmp_attachment = new ArrayList<>();
tmp_attachment.addAll(attachments);
attachments.removeAll(tmp_attachment);
tmp_attachment.clear();
}
isSensitive = false;
toot_sensitive.setVisibility(View.GONE);
currentToId = -1;
Toast.makeText(TootActivity.this,R.string.toot_sent, Toast.LENGTH_LONG).show();
toot_it.setEnabled(true);
}
//It's a reply, so the user will be redirect to its answer
if( tootReply != null){
List<Status> statuses = apiResponse.getStatuses();
if( statuses != null && statuses.size() > 0 ){
Status status = statuses.get(0);
if( status != null ) {
Intent intent = new Intent(getApplicationContext(), ShowConversationActivity.class);
Bundle b = new Bundle();
b.putString("statusId", status.getId());
intent.putExtras(b);
startActivity(intent);
finish();
}
}
}else {
Intent intent = new Intent(getApplicationContext(), MainActivity.class);
intent.putExtra(INTENT_ACTION, HOME_TIMELINE_INTENT);
startActivity(intent);
finish();
}
}
@Override
public void onRetrieveSearchAccounts(APIResponse apiResponse) {
@ -893,14 +969,20 @@ public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAc
if( tootReply != null) {
tootReply();
}else {
setTitle(R.string.toot_title);
if( title != null)
title.setText(getString(R.string.toot_title));
else
setTitle(R.string.toot_title);
}
}
private void tootReply(){
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE);
setTitle(R.string.toot_title_reply);
if( title != null)
title.setText(getString(R.string.toot_title_reply));
else
setTitle(R.string.toot_title_reply);
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
boolean show_reply = sharedpreferences.getBoolean(Helper.SET_SHOW_REPLY, false);
if( show_reply ){
@ -1015,4 +1097,6 @@ public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAc
}
}
}

View File

@ -17,7 +17,6 @@ package fr.gouv.etalab.mastodon.asynctasks;
import android.content.Context;
import android.os.AsyncTask;
import fr.gouv.etalab.mastodon.client.API;
import fr.gouv.etalab.mastodon.client.Entities.Account;
import fr.gouv.etalab.mastodon.interfaces.OnPostActionInterface;

View File

@ -0,0 +1,54 @@
/* Copyright 2017 Thomas Schneider
*
* This file is a part of Mastalab
*
* This program is free software; you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
* License, or (at your option) any later version.
*
* Mastalab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details.
*
* You should have received a copy of the GNU General Public License along with Thomas Schneider; if not,
* see <http://www.gnu.org/licenses>. */
package fr.gouv.etalab.mastodon.asynctasks;
import android.content.Context;
import android.os.AsyncTask;
import fr.gouv.etalab.mastodon.client.API;
import fr.gouv.etalab.mastodon.client.APIResponse;
import fr.gouv.etalab.mastodon.interfaces.OnPostStatusActionInterface;
/**
* Created by Thomas on 21/07/2017.
* Posts status (live version) - scheduled toots are sent via classic post feature in api
*/
public class PostStatusAsyncTask extends AsyncTask<Void, Void, Void> {
private Context context;
private OnPostStatusActionInterface listener;
private APIResponse apiResponse;
private fr.gouv.etalab.mastodon.client.Entities.Status status;
public PostStatusAsyncTask(Context context, fr.gouv.etalab.mastodon.client.Entities.Status status, OnPostStatusActionInterface onPostStatusActionInterface){
this.context = context;
this.listener = onPostStatusActionInterface;
this.status = status;
}
@Override
protected Void doInBackground(Void... params) {
apiResponse = new API(context).postStatusAction(status);
return null;
}
@Override
protected void onPostExecute(Void result) {
listener.onPostStatusAction(apiResponse);
}
}

View File

@ -898,6 +898,58 @@ public class API {
}
/**
* Posts a status
* @param status Status object related to the status
* @return APIResponse
*/
public APIResponse postStatusAction(Status status){
String action;
RequestParams params;
params = new RequestParams();
action = "/statuses";
params.put("status", status.getContent());
if( status.getIn_reply_to_id() != null)
params.put("in_reply_to_id", status.getIn_reply_to_id());
if( status.getMedia_attachments() != null && status.getMedia_attachments().size() > 0 ) {
for(Attachment attachment: status.getMedia_attachments()) {
params.add("media_ids[]", attachment.getId());
}
}
if( status.isSensitive())
params.put("sensitive", Boolean.toString(status.isSensitive()));
if( status.getSpoiler_text() != null)
params.put("spoiler_text", status.getSpoiler_text());
params.put("visibility", status.getVisibility());
statuses = new ArrayList<>();
post(action, 30000, params, new JsonHttpResponseHandler() {
@Override
public void onSuccess(int statusCode, Header[] headers, JSONObject response) {
Status statusreturned = parseStatuses(response);
statuses.add(statusreturned);
apiResponse.setSince_id(findSinceId(headers));
apiResponse.setMax_id(findMaxId(headers));
}
@Override
public void onSuccess(int statusCode, Header[] headers, JSONArray response) {
statuses = parseStatuses(response);
apiResponse.setSince_id(findSinceId(headers));
apiResponse.setMax_id(findMaxId(headers));
}
@Override
public void onFailure(int statusCode, Header[] headers, Throwable error, JSONObject response) {
actionCode = statusCode;
setError(statusCode, error);
error.printStackTrace();
}
});
apiResponse.setStatuses(statuses);
return apiResponse;
}
/**
* Retrieves notifications for the authenticated account since an id*synchronously*
* @param since_id String since max

View File

@ -25,6 +25,7 @@ import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.text.Html;
import android.text.util.Linkify;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -65,8 +66,9 @@ public class AccountsListAdapter extends BaseAdapter implements OnPostActionInte
private RetrieveAccountsAsyncTask.Type action;
private Context context;
private AccountsListAdapter accountsListAdapter;
private String targetedId;
public AccountsListAdapter(Context context, RetrieveAccountsAsyncTask.Type action, List<Account> accounts){
public AccountsListAdapter(Context context, RetrieveAccountsAsyncTask.Type action, String targetedId, List<Account> accounts){
this.context = context;
this.accounts = accounts;
layoutInflater = LayoutInflater.from(context);
@ -75,6 +77,7 @@ public class AccountsListAdapter extends BaseAdapter implements OnPostActionInte
.cacheOnDisk(true).resetViewBeforeLoading(true).build();
this.action = action;
this.accountsListAdapter = this;
this.targetedId = targetedId;
}
@ -174,11 +177,15 @@ public class AccountsListAdapter extends BaseAdapter implements OnPostActionInte
holder.account_pp.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(context, ShowAccountActivity.class);
Bundle b = new Bundle();
b.putString("accountId", account.getId());
intent.putExtras(b);
context.startActivity(intent);
//Avoid to reopen details about the current account
if( targetedId == null || !targetedId.equals(account.getId())){
Intent intent = new Intent(context, ShowAccountActivity.class);
Bundle b = new Bundle();
b.putString("accountId", account.getId());
intent.putExtras(b);
context.startActivity(intent);
}
}
});
return convertView;

View File

@ -94,8 +94,9 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf
private final int FAVOURITE = 2;
private ViewHolder holder;
private RetrieveFeedsAsyncTask.Type type;
private String targetedId;
public StatusListAdapter(Context context, RetrieveFeedsAsyncTask.Type type, boolean isOnWifi, int behaviorWithAttachments, List<Status> statuses){
public StatusListAdapter(Context context, RetrieveFeedsAsyncTask.Type type, String targetedId, boolean isOnWifi, int behaviorWithAttachments, List<Status> statuses){
this.context = context;
this.statuses = statuses;
this.isOnWifi = isOnWifi;
@ -106,6 +107,7 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf
.cacheOnDisk(true).resetViewBeforeLoading(true).build();
statusListAdapter = this;
this.type = type;
this.targetedId = targetedId;
}
@ -292,8 +294,8 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf
public void onClick(View v) {
Intent intent = new Intent(context, ShowConversationActivity.class);
Bundle b = new Bundle();
b.putString("statusId", status.getId()); //Your id
intent.putExtras(b); //Put your id to your next Intent
b.putString("statusId", status.getId());
intent.putExtras(b);
context.startActivity(intent);
}
});
@ -333,7 +335,6 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf
holder.status_account_username.setText(String.format("@%s",username));
}
holder.status_reply.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -342,6 +343,13 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf
b.putParcelable("tootReply", status);
intent.putExtras(b); //Put your id to your next Intent
context.startActivity(intent);
if( type == RetrieveFeedsAsyncTask.Type.CONTEXT ){
try {
//Avoid to open multi activities when replying in a conversation
((ShowConversationActivity)context).finish();
}catch (Exception ignored){}
}
}
});
@ -505,22 +513,27 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf
holder.status_account_profile.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(context, ShowAccountActivity.class);
Bundle b = new Bundle();
b.putString("accountId", status.getAccount().getId());
intent.putExtras(b);
context.startActivity(intent);
if( targetedId == null || !targetedId.equals(status.getAccount().getId())){
Intent intent = new Intent(context, ShowAccountActivity.class);
Bundle b = new Bundle();
b.putString("accountId", status.getAccount().getId());
intent.putExtras(b);
context.startActivity(intent);
}
}
});
holder.status_account_profile_boost.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(context, ShowAccountActivity.class);
Bundle b = new Bundle();
b.putString("accountId", status.getReblog().getAccount().getId());
intent.putExtras(b);
context.startActivity(intent);
if( targetedId == null || !targetedId.equals(status.getReblog().getAccount().getId())){
Intent intent = new Intent(context, ShowAccountActivity.class);
Bundle b = new Bundle();
b.putString("accountId", status.getReblog().getAccount().getId());
intent.putExtras(b);
context.startActivity(intent);
}
}
});

View File

@ -22,7 +22,6 @@ import android.os.Parcelable;
import android.support.v4.app.Fragment;
import android.support.v4.content.LocalBroadcastManager;
import android.support.v4.widget.SwipeRefreshLayout;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -103,7 +102,7 @@ public class DisplayAccountsFragment extends Fragment implements OnRetrieveAccou
textviewNoAction = (RelativeLayout) rootView.findViewById(R.id.no_action);
mainLoader.setVisibility(View.VISIBLE);
nextElementLoader.setVisibility(View.GONE);
accountsListAdapter = new AccountsListAdapter(context, type, this.accounts);
accountsListAdapter = new AccountsListAdapter(context, type, targetedId, this.accounts);
lv_accounts.setAdapter(accountsListAdapter);
if( !comesFromSearch) {
@ -257,7 +256,7 @@ public class DisplayAccountsFragment extends Fragment implements OnRetrieveAccou
textviewNoAction.setVisibility(View.GONE);
max_id = apiResponse.getMax_id();
if( swiped ){
accountsListAdapter = new AccountsListAdapter(context, type, this.accounts);
accountsListAdapter = new AccountsListAdapter(context, type,targetedId, this.accounts);
lv_accounts.setAdapter(accountsListAdapter);
swiped = false;
}

View File

@ -191,7 +191,6 @@ public class DisplayNotificationsFragment extends Fragment implements OnRetrieve
notificationsListAdapter.notifyDataSetChanged();
}
swipeRefreshLayout.setRefreshing(false);
firstLoad = false;
flag_loading = notifications != null && notifications.size() < notificationPerPage;
//Store last notification id to avoid to notify for those that have been already seen
if( notifications != null && notifications.size() > 0) {
@ -200,11 +199,12 @@ public class DisplayNotificationsFragment extends Fragment implements OnRetrieve
userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
Account currentAccount = new AccountDAO(context, db).getAccountByID(userId);
if( currentAccount != null){
if( currentAccount != null && firstLoad){
SharedPreferences.Editor editor = sharedpreferences.edit();
editor.putString(Helper.LAST_NOTIFICATION_MAX_ID + currentAccount.getId(), notifications.get(0).getId());
editor.apply();
}
}
firstLoad = false;
}
}

View File

@ -112,7 +112,7 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
textviewNoAction = (RelativeLayout) rootView.findViewById(R.id.no_action);
mainLoader.setVisibility(View.VISIBLE);
nextElementLoader.setVisibility(View.GONE);
statusListAdapter = new StatusListAdapter(context, type, isOnWifi, behaviorWithAttachments, this.statuses);
statusListAdapter = new StatusListAdapter(context, type, targetedId, isOnWifi, behaviorWithAttachments, this.statuses);
lv_status.setAdapter(statusListAdapter);
if( !comesFromSearch){
@ -279,7 +279,7 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
else
textviewNoAction.setVisibility(View.GONE);
if( swiped ){
statusListAdapter = new StatusListAdapter(context, type, isOnWifi, behaviorWithAttachments, this.statuses);
statusListAdapter = new StatusListAdapter(context, type, targetedId, isOnWifi, behaviorWithAttachments, this.statuses);
lv_status.setAdapter(statusListAdapter);
swiped = false;
}
@ -291,7 +291,6 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
statusListAdapter.notifyDataSetChanged();
}
swipeRefreshLayout.setRefreshing(false);
firstLoad = false;
if( flag_loading )
flag_loading = statuses != null && statuses.size() < tootsPerPage;
//Store last toot id for home timeline to avoid to notify for those that have been already seen
@ -301,12 +300,13 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
Account currentAccount = new AccountDAO(context, db).getAccountByID(userId);
if( currentAccount != null){
if( currentAccount != null && firstLoad){
SharedPreferences.Editor editor = sharedpreferences.edit();
editor.putString(Helper.LAST_HOMETIMELINE_MAX_ID + currentAccount.getId(), statuses.get(0).getId());
editor.apply();
}
}
firstLoad = false;
}
}

View File

@ -46,6 +46,8 @@ import android.support.design.widget.NavigationView;
import android.support.v4.app.NotificationCompat;
import android.support.v4.app.NotificationManagerCompat;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.ActionBar;
import android.support.v7.widget.Toolbar;
import android.text.Html;
import android.text.SpannableString;
import android.text.Spanned;
@ -105,7 +107,9 @@ import java.util.regex.Pattern;
import fr.gouv.etalab.mastodon.activities.HashTagActivity;
import fr.gouv.etalab.mastodon.activities.LoginActivity;
import fr.gouv.etalab.mastodon.activities.MainActivity;
import fr.gouv.etalab.mastodon.activities.ShowAccountActivity;
import fr.gouv.etalab.mastodon.activities.TootActivity;
import fr.gouv.etalab.mastodon.activities.WebviewActivity;
import fr.gouv.etalab.mastodon.asynctasks.RemoveAccountAsyncTask;
import fr.gouv.etalab.mastodon.client.Entities.Account;
@ -156,6 +160,7 @@ public class Helper {
public static final String SCOPE = "scope";
public static final String SCOPES = "scopes";
public static final String WEBSITE = "website";
public static final String WEBSITE_VALUE = "https://play.google.com/store/apps/details?id=fr.gouv.etalab.mastodon";
public static final String SHOW_BATTERY_SAVER_MESSAGE = "show_battery_saver_message";
public static final String LAST_NOTIFICATION_MAX_ID = "last_notification_max_id";
public static final String LAST_HOMETIMELINE_MAX_ID = "last_hometimeline_max_id";
@ -740,7 +745,11 @@ public class Helper {
imageLoader = ImageLoader.getInstance();
final ImageView imageView = new ImageView(activity);
item.setIcon(R.drawable.ic_person);
imageLoader.displayImage(account.getAvatar(), imageView, options, new ImageLoadingListener() {
String url = account.getAvatar();
if( url.startsWith("/") ){
url = "https://" + Helper.getLiveInstance(activity) + account.getAvatar();
}
imageLoader.displayImage(url, imageView, options, new ImageLoadingListener() {
@Override
public void onLoadingStarted(String s, View view) {
}
@ -860,14 +869,48 @@ public class Helper {
editor.putString(Helper.PREF_KEY_OAUTH_TOKEN, account.getToken());
editor.putString(Helper.PREF_KEY_ID, account.getId());
editor.apply();
activity.recreate();
}
/**
* Load the profile picture in the current action bar
* @param activity Activity The current activity
* @param url String the url of the profile picture
*/
public static void loadPPInActionBar(final Activity activity, String url){
ImageLoader imageLoader;
DisplayImageOptions options = new DisplayImageOptions.Builder().displayer(new SimpleBitmapDisplayer()).cacheInMemory(false)
.cacheOnDisk(true).resetViewBeforeLoading(true).build();
imageLoader = ImageLoader.getInstance();
View headerLayout = navigationView.getHeaderView(0);
updateHeaderAccountInfo(activity, account, headerLayout, imageLoader, options);
}
if( url.startsWith("/") ){
url = "https://" + Helper.getLiveInstance(activity) + url;
}
imageLoader.loadImage(url, options, new SimpleImageLoadingListener(){
@Override
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
super.onLoadingComplete(imageUri, view, loadedImage);
Drawable ppDrawable;
Toolbar toolBar = (Toolbar) activity.findViewById(R.id.toolbar);
if( toolBar != null){
ppDrawable = new BitmapDrawable(activity.getResources(), Bitmap.createScaledBitmap(loadedImage, (int) convertDpToPixel(25, activity), (int) convertDpToPixel(25, activity), true));
toolBar.findViewById(R.id.pp_actionBar).setBackgroundDrawable(ppDrawable);
}else{
ActionBar supportActionBar = ((TootActivity) activity).getSupportActionBar();
if( supportActionBar != null){
ppDrawable = new BitmapDrawable(activity.getResources(), Bitmap.createScaledBitmap(loadedImage, (int) convertDpToPixel(20, activity), (int) convertDpToPixel(20, activity), true));
supportActionBar.setIcon(ppDrawable);
}
}
}
@Override
public void onLoadingFailed(java.lang.String imageUri, android.view.View view, FailReason failReason){
}});
}
/**
* Update the header with the new selected account
@ -896,7 +939,11 @@ public class Helper {
ownerFollowing.setText(String.valueOf(account.getFollowing_count()));
username.setText(String.format("@%s",account.getUsername()));
displayedName.setText(account.getDisplay_name());
imageLoader.displayImage(account.getAvatar(), profilePicture, options);
String url = account.getAvatar();
if( url.startsWith("/") ){
url = "https://" + Helper.getLiveInstance(activity) + account.getAvatar();
}
imageLoader.displayImage(url, profilePicture, options);
}
profilePicture.setOnClickListener(null);
profilePicture.setOnClickListener(new View.OnClickListener() {

View File

@ -0,0 +1,26 @@
/* Copyright 2017 Thomas Schneider
*
* This file is a part of Mastalab
*
* This program is free software; you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
* License, or (at your option) any later version.
*
* Mastalab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details.
*
* You should have received a copy of the GNU General Public License along with Thomas Schneider; if not,
* see <http://www.gnu.org/licenses>. */
package fr.gouv.etalab.mastodon.interfaces;
import fr.gouv.etalab.mastodon.client.APIResponse;
/**
* Created by Thomas on 21/07/2017.
* Interface when posting a status
*/
public interface OnPostStatusActionInterface {
void onPostStatusAction(APIResponse apiResponse);
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 926 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 486 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 829 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 225 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 456 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 288 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 394 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 257 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 600 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 322 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 542 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 171 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 716 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 243 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 349 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 416 B

View File

@ -33,20 +33,93 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
app:popupTheme="?attr/popupOverlay" />
app:popupTheme="?attr/popupOverlay">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:orientation="horizontal">
<ImageView
android:id="@+id/pp_actionBar"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_gravity="center_vertical"
android:gravity="center_vertical"
android:layout_marginEnd="10dp"
android:layout_marginRight="10dp"
tools:ignore="ContentDescription" />
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:layout_gravity="center_vertical"
android:layout_height="wrap_content"
android:textSize="16sp"
android:id="@+id/toolbar_title" />
<android.support.v7.widget.SearchView
android:background="@null"
android:id="@+id/toolbar_search"
android:gravity="end"
android:layout_gravity="center_vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<android.support.design.widget.TabLayout
android:id="@+id/tabLayout"
android:layout_width="match_parent"
android:layout_height="25dp"
app:tabSelectedTextColor="?attr/colorAccent"
>
<android.support.design.widget.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/tab_home"
android:icon="@drawable/ic_action_home_tl"/>
<android.support.design.widget.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/tab_local"
android:icon="@drawable/ic_action_users_tl"/>
<android.support.design.widget.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/tab_global"
android:icon="@drawable/ic_action_globe_tl"/>
<android.support.design.widget.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/tab_notification"
android:icon="@drawable/ic_notifications_tl"/>
</android.support.design.widget.TabLayout>
</LinearLayout>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<!-- Framelayout to display Fragments -->
<android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/viewpager"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="mastodon.etalab.gouv.fr.mastodon.fr.etalab.gouv.fr.mastodon.activities.MainActivity"
>
</android.support.v4.view.ViewPager>
<!-- Framelayout to display Fragments -->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:visibility="gone"
android:id="@+id/main_app_container"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"

View File

@ -0,0 +1,51 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2017 Thomas Schneider
This file is a part of Mastalab
This program is free software; you can redistribute it and/or modify it under the terms of the
GNU General Public License as published by the Free Software Foundation; either version 3 of the
License, or (at your option) any later version.
Mastalab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
Public License for more details.
You should have received a copy of the GNU General Public License along with Thomas Schneider; if not,
see <http://www.gnu.org/licenses>.
-->
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
app:popupTheme="?attr/popupOverlay">
<ImageView
android:id="@+id/close_toot"
android:src="@drawable/ic_close"
android:layout_width="30dp"
android:layout_height="30dp"
android:gravity="center_vertical"
android:layout_marginEnd="10dp"
android:layout_marginRight="10dp"
android:contentDescription="" />
<ImageView
android:id="@+id/pp_actionBar"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_gravity="center_vertical"
android:gravity="center_vertical"
android:layout_marginEnd="10dp"
android:layout_marginRight="10dp"
tools:ignore="ContentDescription" />
<TextView
android:layout_width="wrap_content"
android:layout_gravity="center_vertical"
android:layout_height="wrap_content"
android:textSize="14sp"
android:id="@+id/toolbar_title" />
</android.support.v7.widget.Toolbar>

View File

@ -1,11 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/action_search"
android:title="@string/action_search"
android:icon="@drawable/ic_action_search"
app:showAsAction="ifRoom" />
<item
android:id="@+id/action_about"
android:title="@string/action_about"

View File

@ -29,8 +29,6 @@
<item name="shapeBorder">@style/Shape.Light</item>
<item name="imgbd">@style/Image.Border.Light</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="popupOverlay">@style/AppTheme.PopupOverlay</item>
</style>
@ -51,7 +49,6 @@
<item name="imgbd">@style/Image.Border.Dark</item>
<item name="popupOverlay">@style/AppThemeDark.PopupOverlay</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
@ -100,4 +97,5 @@
</style>
</resources>