mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-25 02:18:23 +01:00
Log in other reddit accounts are available. Add an account switcher in the navigation drawer in MainActivity.
This commit is contained in:
parent
5b5da3d3fd
commit
e542ac5138
4
.idea/assetWizardSettings.xml
generated
4
.idea/assetWizardSettings.xml
generated
@ -35,9 +35,9 @@
|
|||||||
<map>
|
<map>
|
||||||
<entry key="assetSourceType" value="FILE" />
|
<entry key="assetSourceType" value="FILE" />
|
||||||
<entry key="color" value="ffffff" />
|
<entry key="color" value="ffffff" />
|
||||||
<entry key="outputName" value="ic_outline_sort_24px" />
|
<entry key="outputName" value="ic_outline_block_24px" />
|
||||||
<entry key="overrideSize" value="true" />
|
<entry key="overrideSize" value="true" />
|
||||||
<entry key="sourceFile" value="$USER_HOME$/Downloads/outline-sort-24px.svg" />
|
<entry key="sourceFile" value="$USER_HOME$/Downloads/outline-block-24px.svg" />
|
||||||
</map>
|
</map>
|
||||||
</option>
|
</option>
|
||||||
</PersistentState>
|
</PersistentState>
|
||||||
|
BIN
.idea/caches/build_file_checksums.ser
generated
BIN
.idea/caches/build_file_checksums.ser
generated
Binary file not shown.
BIN
.idea/caches/gradle_models.ser
generated
BIN
.idea/caches/gradle_models.ser
generated
Binary file not shown.
@ -9,7 +9,6 @@
|
|||||||
<uses-permission
|
<uses-permission
|
||||||
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
|
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
|
||||||
android:maxSdkVersion="22" />
|
android:maxSdkVersion="22" />
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||||
|
|
||||||
<application
|
<application
|
||||||
@ -21,10 +20,11 @@
|
|||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
android:theme="@style/AppTheme"
|
android:theme="@style/AppTheme"
|
||||||
android:usesCleartextTraffic="true">
|
android:usesCleartextTraffic="true">
|
||||||
|
|
||||||
<service
|
<service
|
||||||
android:name=".SubmitPostService"
|
android:name=".SubmitPostService"
|
||||||
android:enabled="true"
|
android:enabled="true"
|
||||||
android:exported="false"></service>
|
android:exported="false" />
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".FilteredPostsActivity"
|
android:name=".FilteredPostsActivity"
|
||||||
|
@ -34,4 +34,7 @@ public interface AccountDao {
|
|||||||
@Query("UPDATE accounts SET profile_image_url = :profileImageUrl, banner_image_url = :bannerImageUrl, " +
|
@Query("UPDATE accounts SET profile_image_url = :profileImageUrl, banner_image_url = :bannerImageUrl, " +
|
||||||
"karma = :karma WHERE username = :username")
|
"karma = :karma WHERE username = :username")
|
||||||
void updateAccountInfo(String username, String profileImageUrl, String bannerImageUrl, int karma);
|
void updateAccountInfo(String username, String profileImageUrl, String bannerImageUrl, int karma);
|
||||||
|
|
||||||
|
@Query("SELECT * FROM accounts WHERE username != :username")
|
||||||
|
LiveData<List<Account>> getAccountsExceptCurrentAccountLiveData(String username);
|
||||||
}
|
}
|
||||||
|
@ -4,21 +4,29 @@ import android.os.AsyncTask;
|
|||||||
|
|
||||||
import androidx.lifecycle.LiveData;
|
import androidx.lifecycle.LiveData;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||||
|
|
||||||
public class AccountRepository {
|
public class AccountRepository {
|
||||||
private AccountDao mAccountDao;
|
private AccountDao mAccountDao;
|
||||||
private LiveData<Account> mAccountLiveData;
|
private LiveData<Account> mAccountLiveData;
|
||||||
|
private LiveData<List<Account>> mAccountsExceptCurrentAccountLiveData;
|
||||||
|
|
||||||
AccountRepository(RedditDataRoomDatabase redditDataRoomDatabase, String username) {
|
AccountRepository(RedditDataRoomDatabase redditDataRoomDatabase, String username) {
|
||||||
mAccountDao = redditDataRoomDatabase.accountDao();
|
mAccountDao = redditDataRoomDatabase.accountDao();
|
||||||
mAccountLiveData = mAccountDao.getAccountLiveData(username);
|
mAccountLiveData = mAccountDao.getAccountLiveData(username);
|
||||||
|
mAccountsExceptCurrentAccountLiveData = mAccountDao.getAccountsExceptCurrentAccountLiveData(username);
|
||||||
}
|
}
|
||||||
|
|
||||||
LiveData<Account> getAccountLiveData() {
|
LiveData<Account> getAccountLiveData() {
|
||||||
return mAccountLiveData;
|
return mAccountLiveData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LiveData<List<Account>> getAccountsExceptCurrentAccountLiveData() {
|
||||||
|
return mAccountsExceptCurrentAccountLiveData;
|
||||||
|
}
|
||||||
|
|
||||||
public void insert(Account Account) {
|
public void insert(Account Account) {
|
||||||
new InsertAsyncTask(mAccountDao).execute(Account);
|
new InsertAsyncTask(mAccountDao).execute(Account);
|
||||||
}
|
}
|
||||||
|
@ -8,22 +8,30 @@ import androidx.lifecycle.LiveData;
|
|||||||
import androidx.lifecycle.ViewModel;
|
import androidx.lifecycle.ViewModel;
|
||||||
import androidx.lifecycle.ViewModelProvider;
|
import androidx.lifecycle.ViewModelProvider;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||||
|
|
||||||
public class AccountViewModel extends AndroidViewModel {
|
public class AccountViewModel extends AndroidViewModel {
|
||||||
private AccountRepository mAccountRepository;
|
private AccountRepository mAccountRepository;
|
||||||
private LiveData<Account> mAccountLiveData;
|
private LiveData<Account> mAccountLiveData;
|
||||||
|
private LiveData<List<Account>> mAccountsExceptCurrentAccountLiveData;
|
||||||
|
|
||||||
public AccountViewModel(Application application, RedditDataRoomDatabase redditDataRoomDatabase, String id) {
|
public AccountViewModel(Application application, RedditDataRoomDatabase redditDataRoomDatabase, String id) {
|
||||||
super(application);
|
super(application);
|
||||||
mAccountRepository = new AccountRepository(redditDataRoomDatabase, id);
|
mAccountRepository = new AccountRepository(redditDataRoomDatabase, id);
|
||||||
mAccountLiveData = mAccountRepository.getAccountLiveData();
|
mAccountLiveData = mAccountRepository.getAccountLiveData();
|
||||||
|
mAccountsExceptCurrentAccountLiveData = mAccountRepository.getAccountsExceptCurrentAccountLiveData();
|
||||||
}
|
}
|
||||||
|
|
||||||
public LiveData<Account> getAccountLiveData() {
|
public LiveData<Account> getAccountLiveData() {
|
||||||
return mAccountLiveData;
|
return mAccountLiveData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LiveData<List<Account>> getAccountsExceptCurrentAccountLiveData() {
|
||||||
|
return mAccountsExceptCurrentAccountLiveData;
|
||||||
|
}
|
||||||
|
|
||||||
public void insert(Account userData) {
|
public void insert(Account userData) {
|
||||||
mAccountRepository.insert(userData);
|
mAccountRepository.insert(userData);
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,137 @@
|
|||||||
|
package ml.docilealligator.infinityforreddit;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.core.content.ContextCompat;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import com.bumptech.glide.RequestManager;
|
||||||
|
import com.bumptech.glide.request.RequestOptions;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import Account.Account;
|
||||||
|
import butterknife.BindView;
|
||||||
|
import butterknife.ButterKnife;
|
||||||
|
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
||||||
|
import pl.droidsonroids.gif.GifImageView;
|
||||||
|
|
||||||
|
class AccountRecyclerViewAdapter extends RecyclerView.Adapter<AccountRecyclerViewAdapter.AccountViewHolder> {
|
||||||
|
|
||||||
|
interface ItemSelectedListener {
|
||||||
|
void accountSelected(Account account);
|
||||||
|
void addAccountSelected();
|
||||||
|
void anonymousSelected();
|
||||||
|
void logoutSelected();
|
||||||
|
void manageAccountSelected();
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<Account> mAccounts;
|
||||||
|
private String mCurrentAccountName;
|
||||||
|
private Context mContext;
|
||||||
|
private RequestManager mGlide;
|
||||||
|
private ItemSelectedListener mItemSelectedListener;
|
||||||
|
|
||||||
|
AccountRecyclerViewAdapter(Context context, RequestManager glide, String currentAccountName, ItemSelectedListener itemSelectedListener) {
|
||||||
|
mContext = context;
|
||||||
|
mGlide = glide;
|
||||||
|
mCurrentAccountName = currentAccountName;
|
||||||
|
mItemSelectedListener = itemSelectedListener;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public AccountViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||||
|
return new AccountViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_account, parent, false));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBindViewHolder(@NonNull AccountViewHolder holder, int position) {
|
||||||
|
if(mAccounts == null) {
|
||||||
|
mGlide.load(R.drawable.subreddit_default_icon)
|
||||||
|
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(128, 0)))
|
||||||
|
.into(holder.profileImageGifImageView);
|
||||||
|
holder.usernameTextView.setText(R.string.add_account);
|
||||||
|
holder.itemView.setOnClickListener(view -> mItemSelectedListener.addAccountSelected());
|
||||||
|
} else {
|
||||||
|
if(position < mAccounts.size()) {
|
||||||
|
mGlide.load(mAccounts.get(position).getProfileImageUrl())
|
||||||
|
.error(mGlide.load(R.drawable.subreddit_default_icon))
|
||||||
|
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(128, 0)))
|
||||||
|
.into(holder.profileImageGifImageView);
|
||||||
|
holder.usernameTextView.setText(mAccounts.get(position).getUsername());
|
||||||
|
holder.itemView.setOnClickListener(view -> {
|
||||||
|
mCurrentAccountName = mAccounts.get(position).getUsername();
|
||||||
|
mItemSelectedListener.accountSelected(mAccounts.get(position));
|
||||||
|
});
|
||||||
|
} else if(position == mAccounts.size()) {
|
||||||
|
holder.profileImageGifImageView.setColorFilter(ContextCompat.getColor(mContext, R.color.primaryTextColor), android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
|
mGlide.load(R.drawable.ic_outline_add_circle_outline_24px)
|
||||||
|
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(128, 0)))
|
||||||
|
.into(holder.profileImageGifImageView);
|
||||||
|
holder.usernameTextView.setText(R.string.add_account);
|
||||||
|
holder.itemView.setOnClickListener(view -> mItemSelectedListener.addAccountSelected());
|
||||||
|
} else if(position == mAccounts.size() + 1) {
|
||||||
|
holder.profileImageGifImageView.setColorFilter(ContextCompat.getColor(mContext, R.color.primaryTextColor), android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
|
mGlide.load(R.drawable.ic_outline_public_24px)
|
||||||
|
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(128, 0)))
|
||||||
|
.into(holder.profileImageGifImageView);
|
||||||
|
holder.usernameTextView.setText(R.string.anonymous_account);
|
||||||
|
holder.itemView.setOnClickListener(view -> mItemSelectedListener.anonymousSelected());
|
||||||
|
} else if(position == mAccounts.size() + 2){
|
||||||
|
holder.profileImageGifImageView.setColorFilter(ContextCompat.getColor(mContext, R.color.primaryTextColor), android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
|
mGlide.load(R.drawable.ic_outline_settings_24px)
|
||||||
|
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(128, 0)))
|
||||||
|
.into(holder.profileImageGifImageView);
|
||||||
|
holder.usernameTextView.setText(R.string.manage_accounts);
|
||||||
|
holder.itemView.setOnClickListener(view -> mItemSelectedListener.manageAccountSelected());
|
||||||
|
} else if(mCurrentAccountName != null) {
|
||||||
|
holder.profileImageGifImageView.setColorFilter(ContextCompat.getColor(mContext, R.color.primaryTextColor), android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
|
mGlide.load(R.drawable.ic_outline_block_24px)
|
||||||
|
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(128, 0)))
|
||||||
|
.into(holder.profileImageGifImageView);
|
||||||
|
holder.usernameTextView.setText(R.string.log_out);
|
||||||
|
holder.itemView.setOnClickListener(view -> mItemSelectedListener.logoutSelected());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemCount() {
|
||||||
|
if(mAccounts == null) {
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
if(mCurrentAccountName == null) {
|
||||||
|
return mAccounts.size() + 3;
|
||||||
|
} else {
|
||||||
|
return mAccounts.size() + 4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onViewRecycled(@NonNull AccountViewHolder holder) {
|
||||||
|
mGlide.clear(holder.profileImageGifImageView);
|
||||||
|
holder.profileImageGifImageView.clearColorFilter();
|
||||||
|
}
|
||||||
|
|
||||||
|
void changeAccountsDataset(List<Account> accounts) {
|
||||||
|
mAccounts = accounts;
|
||||||
|
notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
class AccountViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
@BindView(R.id.profile_image_item_account) GifImageView profileImageGifImageView;
|
||||||
|
@BindView(R.id.username_text_view_item_account) TextView usernameTextView;
|
||||||
|
|
||||||
|
AccountViewHolder(@NonNull View itemView) {
|
||||||
|
super(itemView);
|
||||||
|
ButterKnife.bind(this, itemView);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -15,8 +15,8 @@ class FetchMyInfo {
|
|||||||
void onFetchMyInfoFail();
|
void onFetchMyInfoFail();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void fetchMyInfo(final Retrofit retrofit, String accessToken,
|
static void fetchAccountInfo(final Retrofit retrofit, String accessToken,
|
||||||
final FetchUserMyListener fetchUserMyListener) {
|
final FetchUserMyListener fetchUserMyListener) {
|
||||||
RedditAPI api = retrofit.create(RedditAPI.class);
|
RedditAPI api = retrofit.create(RedditAPI.class);
|
||||||
|
|
||||||
Call<String> userInfo = api.getMyInfo(RedditUtils.getOAuthHeader(accessToken));
|
Call<String> userInfo = api.getMyInfo(RedditUtils.getOAuthHeader(accessToken));
|
||||||
|
@ -6,6 +6,7 @@ import android.graphics.Bitmap;
|
|||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
import android.webkit.CookieManager;
|
||||||
import android.webkit.WebView;
|
import android.webkit.WebView;
|
||||||
import android.webkit.WebViewClient;
|
import android.webkit.WebViewClient;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
@ -65,6 +66,8 @@ public class LoginActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
String url = uriBuilder.toString();
|
String url = uriBuilder.toString();
|
||||||
|
|
||||||
|
CookieManager.getInstance().removeAllCookies(aBoolean -> {});
|
||||||
|
|
||||||
webView.loadUrl(url);
|
webView.loadUrl(url);
|
||||||
webView.setWebViewClient(new WebViewClient() {
|
webView.setWebViewClient(new WebViewClient() {
|
||||||
@Override
|
@Override
|
||||||
@ -97,7 +100,7 @@ public class LoginActivity extends AppCompatActivity {
|
|||||||
String accessToken = responseJSON.getString(RedditUtils.ACCESS_TOKEN_KEY);
|
String accessToken = responseJSON.getString(RedditUtils.ACCESS_TOKEN_KEY);
|
||||||
String refreshToken = responseJSON.getString(RedditUtils.REFRESH_TOKEN_KEY);
|
String refreshToken = responseJSON.getString(RedditUtils.REFRESH_TOKEN_KEY);
|
||||||
|
|
||||||
FetchMyInfo.fetchMyInfo(mOauthRetrofit, accessToken, new FetchMyInfo.FetchUserMyListener() {
|
FetchMyInfo.fetchAccountInfo(mOauthRetrofit, accessToken, new FetchMyInfo.FetchUserMyListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onFetchMyInfoSuccess(String response) {
|
public void onFetchMyInfoSuccess(String response) {
|
||||||
ParseAndSaveAccountInfo.parseAndSaveAccountInfo(response, mRedditDataRoomDatabase, new ParseAndSaveAccountInfo.ParseAndSaveAccountInfoListener() {
|
ParseAndSaveAccountInfo.parseAndSaveAccountInfo(response, mRedditDataRoomDatabase, new ParseAndSaveAccountInfo.ParseAndSaveAccountInfoListener() {
|
||||||
|
@ -20,6 +20,9 @@ import androidx.drawerlayout.widget.DrawerLayout;
|
|||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
import androidx.fragment.app.FragmentManager;
|
import androidx.fragment.app.FragmentManager;
|
||||||
import androidx.fragment.app.FragmentPagerAdapter;
|
import androidx.fragment.app.FragmentPagerAdapter;
|
||||||
|
import androidx.lifecycle.ViewModelProviders;
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
import androidx.viewpager.widget.ViewPager;
|
import androidx.viewpager.widget.ViewPager;
|
||||||
|
|
||||||
import com.bumptech.glide.Glide;
|
import com.bumptech.glide.Glide;
|
||||||
@ -33,6 +36,8 @@ import com.google.android.material.tabs.TabLayout;
|
|||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
|
|
||||||
|
import Account.Account;
|
||||||
|
import Account.AccountViewModel;
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
||||||
@ -45,6 +50,7 @@ public class MainActivity extends AppCompatActivity implements SortTypeBottomShe
|
|||||||
static final String EXTRA_POST_TYPE = "EPT";
|
static final String EXTRA_POST_TYPE = "EPT";
|
||||||
|
|
||||||
private static final String FETCH_USER_INFO_STATE = "FUIS";
|
private static final String FETCH_USER_INFO_STATE = "FUIS";
|
||||||
|
private static final String DRAWER_ON_ACCOUNT_SWITCH_STATE = "DOASS";
|
||||||
private static final String IS_IN_LAZY_MODE_STATE = "IILMS";
|
private static final String IS_IN_LAZY_MODE_STATE = "IILMS";
|
||||||
private static final String NULL_ACCESS_TOKEN_STATE = "NATS";
|
private static final String NULL_ACCESS_TOKEN_STATE = "NATS";
|
||||||
private static final String ACCESS_TOKEN_STATE = "ATS";
|
private static final String ACCESS_TOKEN_STATE = "ATS";
|
||||||
@ -58,18 +64,22 @@ public class MainActivity extends AppCompatActivity implements SortTypeBottomShe
|
|||||||
@BindView(R.id.drawer_layout) DrawerLayout drawer;
|
@BindView(R.id.drawer_layout) DrawerLayout drawer;
|
||||||
@BindView(R.id.view_pager_main_activity) ViewPager viewPager;
|
@BindView(R.id.view_pager_main_activity) ViewPager viewPager;
|
||||||
@BindView(R.id.collapsing_toolbar_layout_main_activity) CollapsingToolbarLayout collapsingToolbarLayout;
|
@BindView(R.id.collapsing_toolbar_layout_main_activity) CollapsingToolbarLayout collapsingToolbarLayout;
|
||||||
|
@BindView(R.id.toolbar) Toolbar toolbar;
|
||||||
|
@BindView(R.id.all_drawer_items_linear_layout_main_activity) LinearLayout allDrawerItemsLinearLayout;
|
||||||
@BindView(R.id.profile_linear_layout_main_activity) LinearLayout profileLinearLayout;
|
@BindView(R.id.profile_linear_layout_main_activity) LinearLayout profileLinearLayout;
|
||||||
@BindView(R.id.subscriptions_linear_layout_main_activity) LinearLayout subscriptionLinearLayout;
|
@BindView(R.id.subscriptions_linear_layout_main_activity) LinearLayout subscriptionLinearLayout;
|
||||||
@BindView(R.id.settings_linear_layout_main_activity) LinearLayout settingsLinearLayout;
|
@BindView(R.id.settings_linear_layout_main_activity) LinearLayout settingsLinearLayout;
|
||||||
|
@BindView(R.id.account_recycler_view_main_activity) RecyclerView accountRecyclerView;
|
||||||
@BindView(R.id.tab_layout_main_activity) TabLayout tabLayout;
|
@BindView(R.id.tab_layout_main_activity) TabLayout tabLayout;
|
||||||
@BindView(R.id.fab_main_activity) FloatingActionButton fab;
|
@BindView(R.id.fab_main_activity) FloatingActionButton fab;
|
||||||
|
|
||||||
private SectionsPagerAdapter sectionsPagerAdapter;
|
private SectionsPagerAdapter sectionsPagerAdapter;
|
||||||
|
|
||||||
private TextView mNameTextView;
|
private TextView mAccountNameTextView;
|
||||||
private TextView mKarmaTextView;
|
private TextView mKarmaTextView;
|
||||||
private GifImageView mProfileImageView;
|
private GifImageView mProfileImageView;
|
||||||
private ImageView mBannerImageView;
|
private ImageView mBannerImageView;
|
||||||
|
private ImageView mDropIconImageView;
|
||||||
|
|
||||||
private RequestManager glide;
|
private RequestManager glide;
|
||||||
private AppBarLayout.LayoutParams params;
|
private AppBarLayout.LayoutParams params;
|
||||||
@ -79,16 +89,19 @@ public class MainActivity extends AppCompatActivity implements SortTypeBottomShe
|
|||||||
|
|
||||||
private boolean mNullAccessToken = false;
|
private boolean mNullAccessToken = false;
|
||||||
private String mAccessToken;
|
private String mAccessToken;
|
||||||
private String mName;
|
private String mAccountName;
|
||||||
private String mProfileImageUrl;
|
private String mProfileImageUrl;
|
||||||
private String mBannerImageUrl;
|
private String mBannerImageUrl;
|
||||||
private String mKarma;
|
private int mKarma;
|
||||||
private boolean mFetchUserInfoSuccess = false;
|
private boolean mFetchUserInfoSuccess = false;
|
||||||
|
private boolean mDrawerOnAccountSwitch = false;
|
||||||
|
|
||||||
private Menu mMenu;
|
private Menu mMenu;
|
||||||
|
|
||||||
private boolean isInLazyMode = false;
|
private boolean isInLazyMode = false;
|
||||||
|
|
||||||
|
AccountViewModel accountViewModel;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@Named("oauth")
|
@Named("oauth")
|
||||||
Retrofit mOauthRetrofit;
|
Retrofit mOauthRetrofit;
|
||||||
@ -117,7 +130,6 @@ public class MainActivity extends AppCompatActivity implements SortTypeBottomShe
|
|||||||
popularBundle.putBoolean(SortTypeBottomSheetFragment.EXTRA_NO_BEST_TYPE, true);
|
popularBundle.putBoolean(SortTypeBottomSheetFragment.EXTRA_NO_BEST_TYPE, true);
|
||||||
popularAndAllSortTypeBottomSheetFragment.setArguments(popularBundle);
|
popularAndAllSortTypeBottomSheetFragment.setArguments(popularBundle);
|
||||||
|
|
||||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
|
||||||
setSupportActionBar(toolbar);
|
setSupportActionBar(toolbar);
|
||||||
|
|
||||||
drawer = findViewById(R.id.drawer_layout);
|
drawer = findViewById(R.id.drawer_layout);
|
||||||
@ -130,13 +142,14 @@ public class MainActivity extends AppCompatActivity implements SortTypeBottomShe
|
|||||||
|
|
||||||
if(savedInstanceState != null) {
|
if(savedInstanceState != null) {
|
||||||
mFetchUserInfoSuccess = savedInstanceState.getBoolean(FETCH_USER_INFO_STATE);
|
mFetchUserInfoSuccess = savedInstanceState.getBoolean(FETCH_USER_INFO_STATE);
|
||||||
|
mDrawerOnAccountSwitch = savedInstanceState.getBoolean(DRAWER_ON_ACCOUNT_SWITCH_STATE);
|
||||||
isInLazyMode = savedInstanceState.getBoolean(IS_IN_LAZY_MODE_STATE);
|
isInLazyMode = savedInstanceState.getBoolean(IS_IN_LAZY_MODE_STATE);
|
||||||
mNullAccessToken = savedInstanceState.getBoolean(NULL_ACCESS_TOKEN_STATE);
|
mNullAccessToken = savedInstanceState.getBoolean(NULL_ACCESS_TOKEN_STATE);
|
||||||
mAccessToken = savedInstanceState.getString(ACCESS_TOKEN_STATE);
|
mAccessToken = savedInstanceState.getString(ACCESS_TOKEN_STATE);
|
||||||
mName = savedInstanceState.getString(ACCOUNT_NAME_STATE);
|
mAccountName = savedInstanceState.getString(ACCOUNT_NAME_STATE);
|
||||||
mProfileImageUrl = savedInstanceState.getString(ACCOUNT_PROFILE_IMAGE_URL_STATE);
|
mProfileImageUrl = savedInstanceState.getString(ACCOUNT_PROFILE_IMAGE_URL_STATE);
|
||||||
mBannerImageUrl = savedInstanceState.getString(ACCOUNT_BANNER_IMAGE_URL_STATE);
|
mBannerImageUrl = savedInstanceState.getString(ACCOUNT_BANNER_IMAGE_URL_STATE);
|
||||||
mKarma = savedInstanceState.getString(ACCOUNT_KARMA_STATE);
|
mKarma = savedInstanceState.getInt(ACCOUNT_KARMA_STATE);
|
||||||
if(!mNullAccessToken && mAccessToken == null) {
|
if(!mNullAccessToken && mAccessToken == null) {
|
||||||
getCurrentAccountAndBindView();
|
getCurrentAccountAndBindView();
|
||||||
} else {
|
} else {
|
||||||
@ -157,10 +170,10 @@ public class MainActivity extends AppCompatActivity implements SortTypeBottomShe
|
|||||||
startActivityForResult(loginIntent, LOGIN_ACTIVITY_REQUEST_CODE);
|
startActivityForResult(loginIntent, LOGIN_ACTIVITY_REQUEST_CODE);
|
||||||
} else {
|
} else {
|
||||||
mAccessToken = account.getAccessToken();
|
mAccessToken = account.getAccessToken();
|
||||||
mName = account.getUsername();
|
mAccountName = account.getUsername();
|
||||||
mProfileImageUrl = account.getProfileImageUrl();
|
mProfileImageUrl = account.getProfileImageUrl();
|
||||||
mBannerImageUrl = account.getBannerImageUrl();
|
mBannerImageUrl = account.getBannerImageUrl();
|
||||||
mKarma = Integer.toString(account.getKarma());
|
mKarma = account.getKarma();
|
||||||
bindView();
|
bindView();
|
||||||
}
|
}
|
||||||
}).execute();
|
}).execute();
|
||||||
@ -172,6 +185,45 @@ public class MainActivity extends AppCompatActivity implements SortTypeBottomShe
|
|||||||
viewPager.setOffscreenPageLimit(2);
|
viewPager.setOffscreenPageLimit(2);
|
||||||
tabLayout.setupWithViewPager(viewPager);
|
tabLayout.setupWithViewPager(viewPager);
|
||||||
|
|
||||||
|
glide = Glide.with(this);
|
||||||
|
|
||||||
|
AccountRecyclerViewAdapter adapter = new AccountRecyclerViewAdapter(this, glide, mAccountName,
|
||||||
|
new AccountRecyclerViewAdapter.ItemSelectedListener() {
|
||||||
|
@Override
|
||||||
|
public void accountSelected(Account account) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addAccountSelected() {
|
||||||
|
Intent intent = new Intent(MainActivity.this, LoginActivity.class);
|
||||||
|
startActivityForResult(intent, LOGIN_ACTIVITY_REQUEST_CODE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void anonymousSelected() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void logoutSelected() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void manageAccountSelected() {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
accountRecyclerView.setLayoutManager(new LinearLayoutManager(this));
|
||||||
|
accountRecyclerView.setNestedScrollingEnabled(false);
|
||||||
|
accountRecyclerView.setAdapter(adapter);
|
||||||
|
|
||||||
|
accountViewModel = ViewModelProviders.of(this,
|
||||||
|
new AccountViewModel.Factory(getApplication(), mRedditDataRoomDatabase, mAccountName)).get(AccountViewModel.class);
|
||||||
|
accountViewModel.getAccountsExceptCurrentAccountLiveData().observe(this, adapter::changeAccountsDataset);
|
||||||
|
|
||||||
if(getIntent().hasExtra(EXTRA_POST_TYPE)) {
|
if(getIntent().hasExtra(EXTRA_POST_TYPE)) {
|
||||||
if(getIntent().getExtras().getString(EXTRA_POST_TYPE).equals("popular")) {
|
if(getIntent().getExtras().getString(EXTRA_POST_TYPE).equals("popular")) {
|
||||||
viewPager.setCurrentItem(1);
|
viewPager.setCurrentItem(1);
|
||||||
@ -180,18 +232,41 @@ public class MainActivity extends AppCompatActivity implements SortTypeBottomShe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
glide = Glide.with(this);
|
|
||||||
|
|
||||||
View header = findViewById(R.id.nav_header_main_activity);
|
View header = findViewById(R.id.nav_header_main_activity);
|
||||||
mNameTextView = header.findViewById(R.id.name_text_view_nav_header_main);
|
mAccountNameTextView = header.findViewById(R.id.name_text_view_nav_header_main);
|
||||||
mKarmaTextView = header.findViewById(R.id.karma_text_view_nav_header_main);
|
mKarmaTextView = header.findViewById(R.id.karma_text_view_nav_header_main);
|
||||||
mProfileImageView = header.findViewById(R.id.profile_image_view_nav_header_main);
|
mProfileImageView = header.findViewById(R.id.profile_image_view_nav_header_main);
|
||||||
mBannerImageView = header.findViewById(R.id.banner_image_view_nav_header_main);
|
mBannerImageView = header.findViewById(R.id.banner_image_view_nav_header_main);
|
||||||
|
mDropIconImageView = header.findViewById(R.id.account_switcher_image_view_nav_header_main);
|
||||||
|
|
||||||
|
if(mDrawerOnAccountSwitch) {
|
||||||
|
mDropIconImageView.setImageDrawable(getResources().getDrawable(R.drawable.ic_baseline_arrow_drop_up_24px));
|
||||||
|
accountRecyclerView.setVisibility(View.VISIBLE);
|
||||||
|
allDrawerItemsLinearLayout.setVisibility(View.GONE);
|
||||||
|
} else {
|
||||||
|
mDropIconImageView.setImageDrawable(getResources().getDrawable(R.drawable.ic_baseline_arrow_drop_down_24px));
|
||||||
|
accountRecyclerView.setVisibility(View.GONE);
|
||||||
|
allDrawerItemsLinearLayout.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
header.setOnClickListener(view -> {
|
||||||
|
if(mDrawerOnAccountSwitch) {
|
||||||
|
mDrawerOnAccountSwitch = false;
|
||||||
|
mDropIconImageView.setImageDrawable(getResources().getDrawable(R.drawable.ic_baseline_arrow_drop_down_24px));
|
||||||
|
accountRecyclerView.setVisibility(View.GONE);
|
||||||
|
allDrawerItemsLinearLayout.setVisibility(View.VISIBLE);
|
||||||
|
} else {
|
||||||
|
mDrawerOnAccountSwitch = true;
|
||||||
|
mDropIconImageView.setImageDrawable(getResources().getDrawable(R.drawable.ic_baseline_arrow_drop_up_24px));
|
||||||
|
accountRecyclerView.setVisibility(View.VISIBLE);
|
||||||
|
allDrawerItemsLinearLayout.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
loadUserData();
|
loadUserData();
|
||||||
|
|
||||||
mNameTextView.setText(mName);
|
mAccountNameTextView.setText(mAccountName);
|
||||||
mKarmaTextView.setText(mKarma);
|
mKarmaTextView.setText(getString(R.string.karma_info, mKarma));
|
||||||
|
|
||||||
if (mProfileImageUrl != null && !mProfileImageUrl.equals("")) {
|
if (mProfileImageUrl != null && !mProfileImageUrl.equals("")) {
|
||||||
glide.load(mProfileImageUrl)
|
glide.load(mProfileImageUrl)
|
||||||
@ -211,7 +286,7 @@ public class MainActivity extends AppCompatActivity implements SortTypeBottomShe
|
|||||||
|
|
||||||
profileLinearLayout.setOnClickListener(view -> {
|
profileLinearLayout.setOnClickListener(view -> {
|
||||||
Intent intent = new Intent(this, ViewUserDetailActivity.class);
|
Intent intent = new Intent(this, ViewUserDetailActivity.class);
|
||||||
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, mName);
|
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, mAccountName);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -227,13 +302,13 @@ public class MainActivity extends AppCompatActivity implements SortTypeBottomShe
|
|||||||
|
|
||||||
private void loadUserData() {
|
private void loadUserData() {
|
||||||
if (!mFetchUserInfoSuccess) {
|
if (!mFetchUserInfoSuccess) {
|
||||||
FetchMyInfo.fetchMyInfo(mOauthRetrofit, mAccessToken, new FetchMyInfo.FetchUserMyListener() {
|
FetchMyInfo.fetchAccountInfo(mOauthRetrofit, mAccessToken, new FetchMyInfo.FetchUserMyListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onFetchMyInfoSuccess(String response) {
|
public void onFetchMyInfoSuccess(String response) {
|
||||||
ParseAndSaveAccountInfo.parseAndSaveAccountInfo(response, mRedditDataRoomDatabase, new ParseAndSaveAccountInfo.ParseAndSaveAccountInfoListener() {
|
ParseAndSaveAccountInfo.parseAndSaveAccountInfo(response, mRedditDataRoomDatabase, new ParseAndSaveAccountInfo.ParseAndSaveAccountInfoListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onParseMyInfoSuccess(String name, String profileImageUrl, String bannerImageUrl, int karma) {
|
public void onParseMyInfoSuccess(String name, String profileImageUrl, String bannerImageUrl, int karma) {
|
||||||
mNameTextView.setText(name);
|
mAccountNameTextView.setText(name);
|
||||||
if (profileImageUrl != null && !profileImageUrl.equals("")) {
|
if (profileImageUrl != null && !profileImageUrl.equals("")) {
|
||||||
glide.load(profileImageUrl)
|
glide.load(profileImageUrl)
|
||||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(128, 0)))
|
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(128, 0)))
|
||||||
@ -249,12 +324,12 @@ public class MainActivity extends AppCompatActivity implements SortTypeBottomShe
|
|||||||
glide.load(bannerImageUrl).into(mBannerImageView);
|
glide.load(bannerImageUrl).into(mBannerImageView);
|
||||||
}
|
}
|
||||||
|
|
||||||
mName = name;
|
mAccountName = name;
|
||||||
mProfileImageUrl = profileImageUrl;
|
mProfileImageUrl = profileImageUrl;
|
||||||
mBannerImageUrl = bannerImageUrl;
|
mBannerImageUrl = bannerImageUrl;
|
||||||
mKarma = getString(R.string.karma_info, karma);
|
mKarma = karma;
|
||||||
|
|
||||||
mKarmaTextView.setText(mKarma);
|
mKarmaTextView.setText(getString(R.string.karma_info, karma));
|
||||||
|
|
||||||
mFetchUserInfoSuccess = true;
|
mFetchUserInfoSuccess = true;
|
||||||
}
|
}
|
||||||
@ -358,13 +433,14 @@ public class MainActivity extends AppCompatActivity implements SortTypeBottomShe
|
|||||||
protected void onSaveInstanceState(@NonNull Bundle outState) {
|
protected void onSaveInstanceState(@NonNull Bundle outState) {
|
||||||
super.onSaveInstanceState(outState);
|
super.onSaveInstanceState(outState);
|
||||||
outState.putBoolean(FETCH_USER_INFO_STATE, mFetchUserInfoSuccess);
|
outState.putBoolean(FETCH_USER_INFO_STATE, mFetchUserInfoSuccess);
|
||||||
|
outState.putBoolean(DRAWER_ON_ACCOUNT_SWITCH_STATE, mDrawerOnAccountSwitch);
|
||||||
outState.putBoolean(IS_IN_LAZY_MODE_STATE, isInLazyMode);
|
outState.putBoolean(IS_IN_LAZY_MODE_STATE, isInLazyMode);
|
||||||
outState.putBoolean(NULL_ACCESS_TOKEN_STATE, mNullAccessToken);
|
outState.putBoolean(NULL_ACCESS_TOKEN_STATE, mNullAccessToken);
|
||||||
outState.putString(ACCESS_TOKEN_STATE, mAccessToken);
|
outState.putString(ACCESS_TOKEN_STATE, mAccessToken);
|
||||||
outState.putString(ACCOUNT_NAME_STATE, mName);
|
outState.putString(ACCOUNT_NAME_STATE, mAccountName);
|
||||||
outState.putString(ACCOUNT_PROFILE_IMAGE_URL_STATE, mProfileImageUrl);
|
outState.putString(ACCOUNT_PROFILE_IMAGE_URL_STATE, mProfileImageUrl);
|
||||||
outState.putString(ACCOUNT_BANNER_IMAGE_URL_STATE, mBannerImageUrl);
|
outState.putString(ACCOUNT_BANNER_IMAGE_URL_STATE, mBannerImageUrl);
|
||||||
outState.putString(ACCOUNT_KARMA_STATE, mKarma);
|
outState.putInt(ACCOUNT_KARMA_STATE, mKarma);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path
|
||||||
|
android:fillColor="#FFFFFFFF"
|
||||||
|
android:pathData="M7,10l5,5 5,-5z"/>
|
||||||
|
</vector>
|
@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path
|
||||||
|
android:fillColor="#FFFFFFFF"
|
||||||
|
android:pathData="M7,14l5,-5 5,5z"/>
|
||||||
|
</vector>
|
@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path
|
||||||
|
android:fillColor="#FF000000"
|
||||||
|
android:pathData="M13,7h-2v4L7,11v2h4v4h2v-4h4v-2h-4L13,7zM12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,20c-4.41,0 -8,-3.59 -8,-8s3.59,-8 8,-8 8,3.59 8,8 -3.59,8 -8,8z"/>
|
||||||
|
</vector>
|
9
app/src/main/res/drawable/ic_outline_block_24px.xml
Normal file
9
app/src/main/res/drawable/ic_outline_block_24px.xml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path
|
||||||
|
android:fillColor="#FF000000"
|
||||||
|
android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM4,12c0,-4.42 3.58,-8 8,-8 1.85,0 3.55,0.63 4.9,1.69L5.69,16.9C4.63,15.55 4,13.85 4,12zM12,20c-1.85,0 -3.55,-0.63 -4.9,-1.69L18.31,7.1C19.37,8.45 20,10.15 20,12c0,4.42 -3.58,8 -8,8z"/>
|
||||||
|
</vector>
|
9
app/src/main/res/drawable/ic_outline_public_24px.xml
Normal file
9
app/src/main/res/drawable/ic_outline_public_24px.xml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path
|
||||||
|
android:fillColor="#FF000000"
|
||||||
|
android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM4,12c0,-0.61 0.08,-1.21 0.21,-1.78L8.99,15v1c0,1.1 0.9,2 2,2v1.93C7.06,19.43 4,16.07 4,12zM17.89,17.4c-0.26,-0.81 -1,-1.4 -1.9,-1.4h-1v-3c0,-0.55 -0.45,-1 -1,-1h-6v-2h2c0.55,0 1,-0.45 1,-1L10.99,7h2c1.1,0 2,-0.9 2,-2v-0.41C17.92,5.77 20,8.65 20,12c0,2.08 -0.81,3.98 -2.11,5.4z"/>
|
||||||
|
</vector>
|
@ -33,87 +33,101 @@
|
|||||||
layout="@layout/nav_header_main" />
|
layout="@layout/nav_header_main" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/profile_linear_layout_main_activity"
|
android:id="@+id/all_drawer_items_linear_layout_main_activity"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="?attr/selectableItemBackground"
|
android:orientation="vertical">
|
||||||
android:clickable="true"
|
|
||||||
android:focusable="true"
|
|
||||||
android:padding="16dp">
|
|
||||||
|
|
||||||
<ImageView
|
<LinearLayout
|
||||||
android:layout_width="24dp"
|
android:id="@+id/profile_linear_layout_main_activity"
|
||||||
android:layout_height="24dp"
|
android:layout_width="match_parent"
|
||||||
android:layout_gravity="center_vertical"
|
|
||||||
android:layout_marginEnd="32dp"
|
|
||||||
android:src="@drawable/ic_outline_account_circle_24px"
|
|
||||||
android:tint="@color/primaryTextColor"/>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical"
|
android:background="?attr/selectableItemBackground"
|
||||||
android:text="@string/profile"
|
android:clickable="true"
|
||||||
android:textColor="@color/primaryTextColor" />
|
android:focusable="true"
|
||||||
|
android:padding="16dp">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="24dp"
|
||||||
|
android:layout_height="24dp"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_marginEnd="32dp"
|
||||||
|
android:src="@drawable/ic_outline_account_circle_24px"
|
||||||
|
android:tint="@color/primaryTextColor"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:text="@string/profile"
|
||||||
|
android:textColor="@color/primaryTextColor" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/subscriptions_linear_layout_main_activity"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="?attr/selectableItemBackground"
|
||||||
|
android:clickable="true"
|
||||||
|
android:focusable="true"
|
||||||
|
android:padding="16dp">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="24dp"
|
||||||
|
android:layout_height="24dp"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_marginEnd="32dp"
|
||||||
|
android:src="@drawable/ic_outline_check_circle_outline_24px"
|
||||||
|
android:tint="@color/primaryTextColor"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:text="@string/subscriptions"
|
||||||
|
android:textColor="@color/primaryTextColor" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="1dp"
|
||||||
|
android:background="@color/dividerColor" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/settings_linear_layout_main_activity"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="?attr/selectableItemBackground"
|
||||||
|
android:clickable="true"
|
||||||
|
android:focusable="true"
|
||||||
|
android:padding="16dp">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="24dp"
|
||||||
|
android:layout_height="24dp"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_marginEnd="32dp"
|
||||||
|
android:src="@drawable/ic_outline_settings_24px"
|
||||||
|
android:tint="@color/primaryTextColor"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:text="@string/settings"
|
||||||
|
android:textColor="@color/primaryTextColor" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
android:id="@+id/subscriptions_linear_layout_main_activity"
|
android:id="@+id/account_recycler_view_main_activity"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="match_parent"
|
||||||
android:background="?attr/selectableItemBackground"
|
android:visibility="gone" />
|
||||||
android:clickable="true"
|
|
||||||
android:focusable="true"
|
|
||||||
android:padding="16dp">
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:layout_width="24dp"
|
|
||||||
android:layout_height="24dp"
|
|
||||||
android:layout_gravity="center_vertical"
|
|
||||||
android:layout_marginEnd="32dp"
|
|
||||||
android:src="@drawable/ic_outline_check_circle_outline_24px"
|
|
||||||
android:tint="@color/primaryTextColor"/>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center_vertical"
|
|
||||||
android:text="@string/subscriptions"
|
|
||||||
android:textColor="@color/primaryTextColor" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<View
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="1dp"
|
|
||||||
android:background="@color/dividerColor" />
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/settings_linear_layout_main_activity"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:background="?attr/selectableItemBackground"
|
|
||||||
android:clickable="true"
|
|
||||||
android:focusable="true"
|
|
||||||
android:padding="16dp">
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:layout_width="24dp"
|
|
||||||
android:layout_height="24dp"
|
|
||||||
android:layout_gravity="center_vertical"
|
|
||||||
android:layout_marginEnd="32dp"
|
|
||||||
android:src="@drawable/ic_outline_settings_24px"
|
|
||||||
android:tint="@color/primaryTextColor"/>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center_vertical"
|
|
||||||
android:text="@string/settings"
|
|
||||||
android:textColor="@color/primaryTextColor" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
@ -15,39 +15,18 @@
|
|||||||
android:id="@+id/collapsing_toolbar_layout_main_activity"
|
android:id="@+id/collapsing_toolbar_layout_main_activity"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
app:titleEnabled="false"
|
|
||||||
app:layout_scrollFlags="scroll|enterAlways"
|
app:layout_scrollFlags="scroll|enterAlways"
|
||||||
|
app:titleEnabled="false"
|
||||||
app:toolbarId="@+id/toolbar">
|
app:toolbarId="@+id/toolbar">
|
||||||
|
|
||||||
<FrameLayout
|
<androidx.appcompat.widget.Toolbar
|
||||||
android:id="@+id/toolbar_frame_layout_main_activity"
|
android:id="@+id/toolbar"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="?attr/actionBarSize"
|
||||||
|
android:background="?attr/colorPrimary"
|
||||||
<androidx.appcompat.widget.Toolbar
|
app:layout_collapseMode="pin"
|
||||||
android:id="@+id/toolbar"
|
app:layout_scrollFlags="scroll|enterAlways"
|
||||||
android:layout_width="match_parent"
|
app:popupTheme="@style/AppTheme.PopupOverlay" />
|
||||||
android:layout_height="?attr/actionBarSize"
|
|
||||||
android:background="?attr/colorPrimary"
|
|
||||||
app:layout_collapseMode="pin"
|
|
||||||
app:layout_scrollFlags="scroll|enterAlways"
|
|
||||||
app:popupTheme="@style/AppTheme.PopupOverlay" />
|
|
||||||
|
|
||||||
<com.ferfalk.simplesearchview.SimpleSearchView
|
|
||||||
android:id="@+id/search_view_main_activity"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:textColor="@android:color/white"
|
|
||||||
app:voiceSearch="true"
|
|
||||||
app:searchBackground="@color/colorPrimary"
|
|
||||||
app:cursorColor="@android:color/white"
|
|
||||||
app:hintColor="#E0E0E0"
|
|
||||||
app:iconsTint="@android:color/white"
|
|
||||||
app:backIconTint="@android:color/white"
|
|
||||||
app:iconsAlpha="1"
|
|
||||||
app:backIconAlpha="1"/>
|
|
||||||
|
|
||||||
</FrameLayout>
|
|
||||||
|
|
||||||
</com.google.android.material.appbar.CollapsingToolbarLayout>
|
</com.google.android.material.appbar.CollapsingToolbarLayout>
|
||||||
|
|
||||||
@ -59,12 +38,12 @@
|
|||||||
android:background="@color/colorPrimary"
|
android:background="@color/colorPrimary"
|
||||||
app:layout_scrollFlags="scroll|enterAlways"
|
app:layout_scrollFlags="scroll|enterAlways"
|
||||||
app:tabGravity="fill"
|
app:tabGravity="fill"
|
||||||
app:tabMode="fixed"
|
|
||||||
app:tabIndicatorColor="@android:color/white"
|
app:tabIndicatorColor="@android:color/white"
|
||||||
app:tabIndicatorHeight="3dp"
|
app:tabIndicatorHeight="3dp"
|
||||||
|
app:tabMode="fixed"
|
||||||
|
app:tabRippleColor="?attr/colorControlHighlight"
|
||||||
app:tabSelectedTextColor="@android:color/white"
|
app:tabSelectedTextColor="@android:color/white"
|
||||||
app:tabTextColor="@android:color/white"
|
app:tabTextColor="@android:color/white"
|
||||||
app:tabRippleColor="?attr/colorControlHighlight"
|
|
||||||
app:tabUnboundedRipple="false" />
|
app:tabUnboundedRipple="false" />
|
||||||
|
|
||||||
</com.google.android.material.appbar.AppBarLayout>
|
</com.google.android.material.appbar.AppBarLayout>
|
||||||
@ -75,7 +54,7 @@
|
|||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="#40000000"
|
android:background="#40000000"
|
||||||
android:elevation="1dp"
|
android:elevation="1dp"
|
||||||
android:visibility="gone"/>
|
android:visibility="gone" />
|
||||||
|
|
||||||
<!--<include layout="@layout/content_main" />-->
|
<!--<include layout="@layout/content_main" />-->
|
||||||
|
|
||||||
|
25
app/src/main/res/layout/item_account.xml
Normal file
25
app/src/main/res/layout/item_account.xml
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:padding="16dp"
|
||||||
|
android:background="?attr/selectableItemBackground"
|
||||||
|
android:clickable="true"
|
||||||
|
android:focusable="true">
|
||||||
|
|
||||||
|
<pl.droidsonroids.gif.GifImageView
|
||||||
|
android:id="@+id/profile_image_item_account"
|
||||||
|
android:layout_width="24dp"
|
||||||
|
android:layout_height="24dp"
|
||||||
|
android:layout_marginEnd="16dp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/username_text_view_item_account"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="16dp"
|
||||||
|
android:layout_marginEnd="16dp"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:textColor="@color/primaryTextColor" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
@ -30,8 +30,10 @@
|
|||||||
android:layout_marginTop="@dimen/nav_header_vertical_spacing"
|
android:layout_marginTop="@dimen/nav_header_vertical_spacing"
|
||||||
android:layout_marginStart="16dp"
|
android:layout_marginStart="16dp"
|
||||||
android:layout_marginEnd="16dp"
|
android:layout_marginEnd="16dp"
|
||||||
|
android:layout_alignParentStart="true"
|
||||||
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
|
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
|
||||||
android:layout_below="@id/profile_image_view_nav_header_main"/>
|
android:layout_below="@id/profile_image_view_nav_header_main"
|
||||||
|
android:layout_toStartOf="@id/account_switcher_image_view_nav_header_main" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/karma_text_view_nav_header_main"
|
android:id="@+id/karma_text_view_nav_header_main"
|
||||||
@ -39,6 +41,17 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="16dp"
|
android:layout_marginStart="16dp"
|
||||||
android:layout_marginEnd="16dp"
|
android:layout_marginEnd="16dp"
|
||||||
android:layout_below="@id/name_text_view_nav_header_main"/>
|
android:layout_alignParentStart="true"
|
||||||
|
android:layout_below="@id/name_text_view_nav_header_main"
|
||||||
|
android:layout_toStartOf="@id/account_switcher_image_view_nav_header_main" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/account_switcher_image_view_nav_header_main"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="16dp"
|
||||||
|
android:layout_alignParentBottom="true"
|
||||||
|
android:layout_alignParentEnd="true"
|
||||||
|
android:src="@drawable/ic_baseline_arrow_drop_down_24px" />
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
@ -170,4 +170,9 @@
|
|||||||
<string name="posting_video">Posting video</string>
|
<string name="posting_video">Posting video</string>
|
||||||
<string name="posting_image">Posting image</string>
|
<string name="posting_image">Posting image</string>
|
||||||
<string name="please_wait">Please wait.</string>
|
<string name="please_wait">Please wait.</string>
|
||||||
|
|
||||||
|
<string name="add_account">Add account</string>
|
||||||
|
<string name="anonymous_account">Anonymous</string>
|
||||||
|
<string name="manage_accounts">Manage accounts</string>
|
||||||
|
<string name="log_out">Log out</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
Reference in New Issue
Block a user