diff options
author | Alex Ning <chineseperson5@gmail.com> | 2021-07-05 16:06:49 +0000 |
---|---|---|
committer | Alex Ning <chineseperson5@gmail.com> | 2021-07-05 16:06:49 +0000 |
commit | b031047d122bd665f20741effa28d350a247cf0a (patch) | |
tree | 6597f7aa3d2201dc24fc204f4857c537b7e6b0fc | |
parent | bd0068eb6c3bd14b86dc44788291c7cf9471af1b (diff) | |
download | infinity-for-reddit-b031047d122bd665f20741effa28d350a247cf0a.tar infinity-for-reddit-b031047d122bd665f20741effa28d350a247cf0a.tar.gz infinity-for-reddit-b031047d122bd665f20741effa28d350a247cf0a.tar.bz2 infinity-for-reddit-b031047d122bd665f20741effa28d350a247cf0a.tar.lz infinity-for-reddit-b031047d122bd665f20741effa28d350a247cf0a.tar.xz infinity-for-reddit-b031047d122bd665f20741effa28d350a247cf0a.tar.zst infinity-for-reddit-b031047d122bd665f20741effa28d350a247cf0a.zip |
Minor UI tweaks in RPANActivity.
5 files changed, 50 insertions, 67 deletions
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index c492d535..12f354fc 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -35,7 +35,7 @@ <activity android:name=".activities.RPANActivity" android:label="@string/rpan_activity_label" android:parentActivityName=".activities.MainActivity" - android:theme="@style/AppTheme.NoActionBar" /> + android:theme="@style/AppTheme.TranslucentStatusBar" /> <activity android:name=".activities.MotionTestActivity" android:theme="@style/AppTheme.NoActionBar" /> diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/RPANActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/RPANActivity.java index 22fa13db..7d041d21 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/RPANActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/RPANActivity.java @@ -1,25 +1,23 @@ package ml.docilealligator.infinityforreddit.activities; 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.Handler; -import android.view.View; -import android.view.Window; -import android.view.WindowManager; import android.widget.Toast; import androidx.annotation.NonNull; 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.fragment.app.Fragment; import androidx.fragment.app.FragmentActivity; import androidx.viewpager2.adapter.FragmentStateAdapter; import androidx.viewpager2.widget.ViewPager2; -import com.google.android.material.appbar.AppBarLayout; - import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; @@ -37,6 +35,9 @@ import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.RPANBroadcast; import ml.docilealligator.infinityforreddit.apis.Strapi; 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.utils.APIUtils; import ml.docilealligator.infinityforreddit.utils.JSONUtils; @@ -46,14 +47,10 @@ import retrofit2.Callback; import retrofit2.Response; import retrofit2.Retrofit; -public class RPANActivity extends BaseActivity { +public class RPANActivity extends AppCompatActivity { @BindView(R.id.coordinator_layout_rpan_activity) 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) ViewPager2 viewPager2; @Inject @@ -80,33 +77,28 @@ public class RPANActivity extends BaseActivity { ((Infinity) getApplication()).getAppComponent().inject(this); super.onCreate(savedInstanceState); - setContentView(R.layout.activity_rpanactivity); - ButterKnife.bind(this); + getTheme().applyStyle(R.style.Theme_Normal, true); - applyCustomTheme(); + getTheme().applyStyle(FontFamily.valueOf(mSharedPreferences + .getString(SharedPreferencesUtils.FONT_FAMILY_KEY, FontFamily.Default.name())).getResId(), true); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - Window window = getWindow(); + getTheme().applyStyle(TitleFontFamily.valueOf(mSharedPreferences + .getString(SharedPreferencesUtils.TITLE_FONT_FAMILY_KEY, TitleFontFamily.Default.name())).getResId(), true); - if (isChangeStatusBarIconColor()) { - addOnOffsetChangedListener(appBarLayout); - } + getTheme().applyStyle(ContentFontFamily.valueOf(mSharedPreferences + .getString(SharedPreferencesUtils.CONTENT_FONT_FAMILY_KEY, ContentFontFamily.Default.name())).getResId(), true); - 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); - } - } + setContentView(R.layout.activity_rpanactivity); + + setVolumeControlStream(AudioManager.STREAM_MUSIC); + + ButterKnife.bind(this); - setSupportActionBar(toolbar); - getSupportActionBar().setDisplayHomeAsUpEnabled(true); + ActionBar actionBar = getSupportActionBar(); + Drawable upArrow = getResources().getDrawable(R.drawable.ic_arrow_back_white_24dp); + actionBar.setHomeAsUpIndicator(upArrow); + actionBar.setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.transparentActionBarAndExoPlayerControllerColor))); mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null); mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, null); @@ -208,22 +200,7 @@ public class RPANActivity extends BaseActivity { viewPager2.setAdapter(sectionsPagerAdapter); viewPager2.setOffscreenPageLimit(3); viewPager2.setUserInputEnabled(!mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_SWIPING_BETWEEN_TABS, false)); - fixViewPager2Sensitivity(viewPager2); - } - - @Override - protected SharedPreferences getDefaultSharedPreferences() { - return mSharedPreferences; - } - - @Override - protected CustomThemeWrapper getCustomThemeWrapper() { - return mCustomThemeWrapper; - } - - @Override - protected void applyCustomTheme() { - + //fixViewPager2Sensitivity(viewPager2); } private class SectionsPagerAdapter extends FragmentStateAdapter { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRPANBroadcastFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRPANBroadcastFragment.java index 3be8e7de..468a931f 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRPANBroadcastFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRPANBroadcastFragment.java @@ -93,6 +93,25 @@ public class ViewRPANBroadcastFragment extends Fragment { 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(); trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory); player = ExoPlayerFactory.newSimpleInstance(mActivity, trackSelector); diff --git a/app/src/main/res/layout/activity_rpanactivity.xml b/app/src/main/res/layout/activity_rpanactivity.xml index 8d1c85fb..570fddb2 100644 --- a/app/src/main/res/layout/activity_rpanactivity.xml +++ b/app/src/main/res/layout/activity_rpanactivity.xml @@ -8,23 +8,6 @@ android:id="@+id/coordinator_layout_rpan_activity" 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 android:id="@+id/view_pager_2_rpan_activity" android:layout_width="match_parent" diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 7790eee5..350b0f29 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -48,6 +48,10 @@ <item name="android:fontFamily">?attr/font_family</item> </style> + <style name="AppTheme.TranslucentStatusBar" parent="AppTheme"> + <item name="android:windowTranslucentStatus">true</item> + </style> + <style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.DayNight.ActionBar"> <item name="android:fontFamily">?attr/font_family</item> </style> |