Minor UI tweaks in RPANActivity.

This commit is contained in:
Alex Ning 2021-07-06 00:06:49 +08:00
parent bd0068eb6c
commit b031047d12
5 changed files with 52 additions and 69 deletions

View File

@ -35,7 +35,7 @@
<activity android:name=".activities.RPANActivity" <activity android:name=".activities.RPANActivity"
android:label="@string/rpan_activity_label" android:label="@string/rpan_activity_label"
android:parentActivityName=".activities.MainActivity" android:parentActivityName=".activities.MainActivity"
android:theme="@style/AppTheme.NoActionBar" /> android:theme="@style/AppTheme.TranslucentStatusBar" />
<activity <activity
android:name=".activities.MotionTestActivity" android:name=".activities.MotionTestActivity"
android:theme="@style/AppTheme.NoActionBar" /> android:theme="@style/AppTheme.NoActionBar" />

View File

@ -1,25 +1,23 @@
package ml.docilealligator.infinityforreddit.activities; package ml.docilealligator.infinityforreddit.activities;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.os.Build; import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.media.AudioManager;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Toast; import android.widget.Toast;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.appcompat.widget.Toolbar; import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.coordinatorlayout.widget.CoordinatorLayout; import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity; import androidx.fragment.app.FragmentActivity;
import androidx.viewpager2.adapter.FragmentStateAdapter; import androidx.viewpager2.adapter.FragmentStateAdapter;
import androidx.viewpager2.widget.ViewPager2; import androidx.viewpager2.widget.ViewPager2;
import com.google.android.material.appbar.AppBarLayout;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
@ -37,6 +35,9 @@ import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RPANBroadcast; import ml.docilealligator.infinityforreddit.RPANBroadcast;
import ml.docilealligator.infinityforreddit.apis.Strapi; import ml.docilealligator.infinityforreddit.apis.Strapi;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.font.ContentFontFamily;
import ml.docilealligator.infinityforreddit.font.FontFamily;
import ml.docilealligator.infinityforreddit.font.TitleFontFamily;
import ml.docilealligator.infinityforreddit.fragments.ViewRPANBroadcastFragment; import ml.docilealligator.infinityforreddit.fragments.ViewRPANBroadcastFragment;
import ml.docilealligator.infinityforreddit.utils.APIUtils; import ml.docilealligator.infinityforreddit.utils.APIUtils;
import ml.docilealligator.infinityforreddit.utils.JSONUtils; import ml.docilealligator.infinityforreddit.utils.JSONUtils;
@ -46,14 +47,10 @@ import retrofit2.Callback;
import retrofit2.Response; import retrofit2.Response;
import retrofit2.Retrofit; import retrofit2.Retrofit;
public class RPANActivity extends BaseActivity { public class RPANActivity extends AppCompatActivity {
@BindView(R.id.coordinator_layout_rpan_activity) @BindView(R.id.coordinator_layout_rpan_activity)
CoordinatorLayout coordinatorLayout; CoordinatorLayout coordinatorLayout;
@BindView(R.id.appbar_layout_rpan_activity)
AppBarLayout appBarLayout;
@BindView(R.id.toolbar_rpan_activity)
Toolbar toolbar;
@BindView(R.id.view_pager_2_rpan_activity) @BindView(R.id.view_pager_2_rpan_activity)
ViewPager2 viewPager2; ViewPager2 viewPager2;
@Inject @Inject
@ -80,33 +77,28 @@ public class RPANActivity extends BaseActivity {
((Infinity) getApplication()).getAppComponent().inject(this); ((Infinity) getApplication()).getAppComponent().inject(this);
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
getTheme().applyStyle(R.style.Theme_Normal, true);
getTheme().applyStyle(FontFamily.valueOf(mSharedPreferences
.getString(SharedPreferencesUtils.FONT_FAMILY_KEY, FontFamily.Default.name())).getResId(), true);
getTheme().applyStyle(TitleFontFamily.valueOf(mSharedPreferences
.getString(SharedPreferencesUtils.TITLE_FONT_FAMILY_KEY, TitleFontFamily.Default.name())).getResId(), true);
getTheme().applyStyle(ContentFontFamily.valueOf(mSharedPreferences
.getString(SharedPreferencesUtils.CONTENT_FONT_FAMILY_KEY, ContentFontFamily.Default.name())).getResId(), true);
setContentView(R.layout.activity_rpanactivity); setContentView(R.layout.activity_rpanactivity);
setVolumeControlStream(AudioManager.STREAM_MUSIC);
ButterKnife.bind(this); ButterKnife.bind(this);
applyCustomTheme(); ActionBar actionBar = getSupportActionBar();
Drawable upArrow = getResources().getDrawable(R.drawable.ic_arrow_back_white_24dp);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { actionBar.setHomeAsUpIndicator(upArrow);
Window window = getWindow(); actionBar.setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.transparentActionBarAndExoPlayerControllerColor)));
if (isChangeStatusBarIconColor()) {
addOnOffsetChangedListener(appBarLayout);
}
if (isImmersiveInterface()) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
coordinatorLayout.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
} else {
window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
}
adjustToolbar(toolbar);
}
}
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null); mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, null); mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, null);
@ -208,22 +200,7 @@ public class RPANActivity extends BaseActivity {
viewPager2.setAdapter(sectionsPagerAdapter); viewPager2.setAdapter(sectionsPagerAdapter);
viewPager2.setOffscreenPageLimit(3); viewPager2.setOffscreenPageLimit(3);
viewPager2.setUserInputEnabled(!mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_SWIPING_BETWEEN_TABS, false)); viewPager2.setUserInputEnabled(!mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_SWIPING_BETWEEN_TABS, false));
fixViewPager2Sensitivity(viewPager2); //fixViewPager2Sensitivity(viewPager2);
}
@Override
protected SharedPreferences getDefaultSharedPreferences() {
return mSharedPreferences;
}
@Override
protected CustomThemeWrapper getCustomThemeWrapper() {
return mCustomThemeWrapper;
}
@Override
protected void applyCustomTheme() {
} }
private class SectionsPagerAdapter extends FragmentStateAdapter { private class SectionsPagerAdapter extends FragmentStateAdapter {

View File

@ -93,6 +93,25 @@ public class ViewRPANBroadcastFragment extends Fragment {
rpanBroadcast = getArguments().getParcelable(EXTRA_RPAN_BROADCAST); rpanBroadcast = getArguments().getParcelable(EXTRA_RPAN_BROADCAST);
playerView.setControllerVisibilityListener(visibility -> {
switch (visibility) {
case View.GONE:
mActivity.getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_IMMERSIVE);
break;
case View.VISIBLE:
mActivity.getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
}
});
TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveTrackSelection.Factory(); TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveTrackSelection.Factory();
trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory); trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);
player = ExoPlayerFactory.newSimpleInstance(mActivity, trackSelector); player = ExoPlayerFactory.newSimpleInstance(mActivity, trackSelector);

View File

@ -8,23 +8,6 @@
android:id="@+id/coordinator_layout_rpan_activity" android:id="@+id/coordinator_layout_rpan_activity"
tools:context=".activities.RPANActivity"> tools:context=".activities.RPANActivity">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appbar_layout_rpan_activity"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar_rpan_activity"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:minHeight="?attr/actionBarSize"
app:popupTheme="@style/AppTheme.PopupOverlay"
app:navigationIcon="?attr/homeAsUpIndicator" />
</com.google.android.material.appbar.AppBarLayout>
<androidx.viewpager2.widget.ViewPager2 <androidx.viewpager2.widget.ViewPager2
android:id="@+id/view_pager_2_rpan_activity" android:id="@+id/view_pager_2_rpan_activity"
android:layout_width="match_parent" android:layout_width="match_parent"

View File

@ -48,6 +48,10 @@
<item name="android:fontFamily">?attr/font_family</item> <item name="android:fontFamily">?attr/font_family</item>
</style> </style>
<style name="AppTheme.TranslucentStatusBar" parent="AppTheme">
<item name="android:windowTranslucentStatus">true</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.DayNight.ActionBar"> <style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.DayNight.ActionBar">
<item name="android:fontFamily">?attr/font_family</item> <item name="android:fontFamily">?attr/font_family</item>
</style> </style>