Improved app layout for other devices

- Other general design fixes
- Implemented a default theme for devices below android 12
- Added more colors to android 12 devices
pull/1/head
Denis Çerri 4 years ago
parent b9a0b54ec5
commit d3e77c2b9b
No known key found for this signature in database
GPG Key ID: 3F50F14A8E7F7A13

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="deploymentTargetDropDown">
<runningDeviceTargetSelectedWithDropDown>
<Target>
<type value="RUNNING_DEVICE_TARGET" />
<deviceKey>
<Key>
<type value="SERIAL_NUMBER" />
<value value="192.168.1.131:43991" />
</Key>
</deviceKey>
</Target>
</runningDeviceTargetSelectedWithDropDown>
<timeTargetWasSelectedWithDropDown value="2022-05-28T21:34:17.666332700Z" />
</component>
</project>

@ -12,7 +12,7 @@
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:theme="@style/AppDefaultTheme"
android:extractNativeLibs="true"
android:requestLegacyExternalStorage="true">
<activity android:name=".MainActivity">

@ -102,7 +102,7 @@ public class HistoryFragment extends Fragment {
CardView card = new CardView(requireContext());
card.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT));
card.setRadius(50);
card.setRadius(getDp(10));
card.setCardElevation(10);
card.setMaxCardElevation(12);
card.setPreventCornerOverlap(true);
@ -129,22 +129,20 @@ public class HistoryFragment extends Fragment {
videoTitle.setText(video.getTitle());
videoTitle.setTextSize(getDp(5));
videoTitle.setTextColor(ContextCompat.getColor(requireContext(), R.color.white));
videoTitle.setShadowLayer(1, 1, 1, ContextCompat.getColor(requireContext(), R.color.colorPrimaryDark));
videoTitle.setTypeface(null, Typeface.BOLD);
videoTitle.setShadowLayer(1.5f, 4f, 4f, R.color.black);
videoTitle.setShadowLayer(2f, 4f, 4f, ContextCompat.getColor(requireContext(), R.color.black));
// AUTHOR ----------------------------------
TextView videoAuthor = new TextView(getContext());
videoAuthor.setGravity(Gravity.BOTTOM);
videoAuthor.setLayoutParams(new RelativeLayout.LayoutParams(getDp(100), getDp(100)));
videoAuthor.setLayoutParams(new RelativeLayout.LayoutParams(getDp(150), getDp(100)));
videoAuthor.setPadding(getDp(20), 0, 0, getDp(10));
videoAuthor.setShadowLayer(1.5f, 4f, 4f, R.color.black);
videoAuthor.setText(video.getAuthor());
videoAuthor.setTextSize(getDp(3));
videoAuthor.setTextColor(ContextCompat.getColor(requireContext(), R.color.white));
videoAuthor.setShadowLayer(1, 1, 1, ContextCompat.getColor(requireContext(), R.color.colorPrimaryDark));
videoAuthor.setShadowLayer(2f, 4f, 4f, ContextCompat.getColor(requireContext(), R.color.black));
videoAuthor.setTypeface(null, Typeface.BOLD);
// DATE ---------------------------------------------
@ -166,9 +164,9 @@ public class HistoryFragment extends Fragment {
LinearLayout buttonLayout = new LinearLayout(requireContext());
buttonLayout.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT));
buttonLayout.setGravity(Gravity.BOTTOM);
buttonLayout.setGravity(Gravity.BOTTOM | Gravity.RIGHT);
buttonLayout.setOrientation(LinearLayout.HORIZONTAL);
buttonLayout.setPadding(getDp(300), 0, getDp(20), getDp(40));
buttonLayout.setPadding(getDp(10), 0, getDp(20), getDp(40));
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
getDp(48), getDp(48)

@ -29,6 +29,7 @@ import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Px;
import androidx.appcompat.widget.SearchView;
import androidx.cardview.widget.CardView;
import androidx.core.app.ActivityCompat;
@ -355,7 +356,7 @@ public class HomeFragment extends Fragment implements View.OnClickListener{
CardView card = new CardView(requireContext());
card.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT));
card.setRadius(50);
card.setRadius(getDp(10));
card.setCardElevation(10);
card.setMaxCardElevation(12);
card.setPreventCornerOverlap(true);
@ -371,22 +372,21 @@ public class HomeFragment extends Fragment implements View.OnClickListener{
videoTitle.setText("Shkarko të gjitha");
videoTitle.setTextSize(getDp(5));
videoTitle.setTextColor(ContextCompat.getColor(requireContext(), R.color.white));
videoTitle.setShadowLayer(1, 1, 1, ContextCompat.getColor(requireContext(), R.color.colorPrimaryDark));
videoTitle.setTypeface(null, Typeface.BOLD);
videoTitle.setShadowLayer(1.5f, 4f, 4f, R.color.black);
videoTitle.setShadowLayer(2f, 4f, 4f, ContextCompat.getColor(requireContext(), R.color.black));
// BUTTONS -------------------------------------------
LinearLayout buttonLayout = new LinearLayout(requireContext());
buttonLayout.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT));
buttonLayout.setGravity(Gravity.BOTTOM);
buttonLayout.setGravity(Gravity.BOTTOM | Gravity.RIGHT);
buttonLayout.setOrientation(LinearLayout.HORIZONTAL);
buttonLayout.setPadding(getDp(250), 0, getDp(20), getDp(10));
buttonLayout.setPadding(0, 0, getDp(20), getDp(10));
Button musicBtn = new Button(getContext());
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
getDp(48), getDp(48)
);
params.setMargins(0,0, getDp(10), 0);
params.setMargins(10,0, 10, 10);
musicBtn.setLayoutParams(params);
//musicBtn.setIconSize(getDp(24));
musicBtn.setBackground(ContextCompat.getDrawable(requireContext(), R.drawable.ic_music));
@ -475,6 +475,10 @@ public class HomeFragment extends Fragment implements View.OnClickListener{
return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, value, getResources().getDisplayMetrics());
}
private int getSp(int value){
return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, value, getResources().getDisplayMetrics());
}
private void createCard(Video video){
RelativeLayout r = new RelativeLayout(getContext());
@ -483,7 +487,7 @@ public class HomeFragment extends Fragment implements View.OnClickListener{
CardView card = new CardView(requireContext());
card.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT));
card.setRadius(50);
card.setRadius(getDp(10));
card.setCardElevation(10);
card.setMaxCardElevation(12);
card.setPreventCornerOverlap(true);
@ -511,11 +515,10 @@ public class HomeFragment extends Fragment implements View.OnClickListener{
title = title.substring(0, 40) + "...";
}
videoTitle.setText(title);
videoTitle.setTextSize(getDp(5));
videoTitle.setTextSize(getSp(5));
videoTitle.setTextColor(ContextCompat.getColor(requireContext(), R.color.white));
videoTitle.setShadowLayer(1, 1, 1, ContextCompat.getColor(requireContext(), R.color.colorPrimaryDark));
videoTitle.setTypeface(null, Typeface.BOLD);
videoTitle.setShadowLayer(1.5f, 4f, 4f, R.color.black);
videoTitle.setShadowLayer(2f, 4f, 4f, ContextCompat.getColor(requireContext(), R.color.black));
// AUTHOR ----------------------------------
@ -528,9 +531,9 @@ public class HomeFragment extends Fragment implements View.OnClickListener{
String author = video.getAuthor();
videoAuthor.setText(author);
videoAuthor.setTextSize(getDp(3));
videoAuthor.setTextSize(getSp(3));
videoAuthor.setTextColor(ContextCompat.getColor(requireContext(), R.color.white));
videoAuthor.setShadowLayer(1, 1, 1, ContextCompat.getColor(requireContext(), R.color.colorPrimaryDark));
videoAuthor.setShadowLayer(2f, 4f, 4f, ContextCompat.getColor(requireContext(), R.color.black));
videoAuthor.setTypeface(null, Typeface.BOLD);
// BUTTONS ----------------------------------
@ -539,9 +542,10 @@ public class HomeFragment extends Fragment implements View.OnClickListener{
LinearLayout buttonLayout = new LinearLayout(requireContext());
buttonLayout.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT));
buttonLayout.setGravity(Gravity.BOTTOM);
buttonLayout.setGravity(Gravity.BOTTOM | Gravity.RIGHT);
buttonLayout.setOrientation(LinearLayout.HORIZONTAL);
buttonLayout.setPadding(getDp(250), 0, getDp(20), getDp(10));
buttonLayout.setPadding(getDp(10), 0, getDp(10), getDp(10));
Button musicBtn = new Button(getContext());
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
@ -570,10 +574,12 @@ public class HomeFragment extends Fragment implements View.OnClickListener{
ProgressBar progressBar = new ProgressBar(requireContext(), null, android.R.attr.progressBarStyleHorizontal);
progressBar.setVisibility(View.GONE);
RelativeLayout.LayoutParams progressParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, getDp(5));
progressParams.setMargins(0, getDp(210), 0 ,0);
progressParams.setMargins(0, r.getLayoutParams().height - 70, 0 ,0);
progressBar.setLayoutParams(progressParams);
progressBar.setBackgroundTintMode(PorterDuff.Mode.SRC_IN);
progressBar.setScaleY(2);
progressBar.setY(card.getY() - progressBar.getHeight() / 2);
progressBar.setTag(videoID + "##progress");
if(video.getDownloadedTime() != null){

@ -1,17 +1,22 @@
package com.deniscerri.ytdl;
import android.content.Intent;
import android.content.res.ColorStateList;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.WindowManager;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.ContextCompat;
import androidx.core.content.res.ComplexColorCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import com.deniscerri.ytdl.databinding.ActivityMainBinding;
import com.google.android.material.bottomnavigation.BottomNavigationView;
import io.reactivex.disposables.CompositeDisposable;
@ -31,11 +36,30 @@ public class MainActivity extends AppCompatActivity{
@Override
protected void onCreate(Bundle savedInstanceState) {
binding = ActivityMainBinding.inflate(getLayoutInflater());
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.S){
this.setTheme(R.style.AppTheme);
ColorStateList list = new ColorStateList(
new int[][]{
new int[]{}
},
new int[]{
ContextCompat.getColor(getApplicationContext(), R.color.material_dynamic_primary50)
}
);
binding.bottomNavigationView.setItemActiveIndicatorColor(list);
binding.bottomNavigationView.setItemRippleColor(list);
binding.bottomNavigationView.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.material_dynamic_neutral10));
}
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
binding = ActivityMainBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
homeFragment = new HomeFragment();
@ -44,8 +68,6 @@ public class MainActivity extends AppCompatActivity{
replaceFragment(homeFragment);
binding.bottomNavigationView.setOnItemSelectedListener(item -> {
switch(item.getItemId()){
case R.id.home:

@ -20,7 +20,7 @@
android:id="@+id/bottomNavigationView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:itemActiveIndicatorStyle="@style/BottomNav"
app:itemActiveIndicatorStyle="@style/BottomNavDefault"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"

@ -3,13 +3,20 @@
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.Material3.DayNight">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/material_dynamic_primary50</item>
<item name="colorPrimary">@color/material_dynamic_primary60</item>
<item name="colorPrimaryDark">@color/material_dynamic_primary20</item>
<item name="colorAccent">@color/material_dynamic_primary40</item>
<item name="background">@color/white</item>
<item name="android:statusBarColor">@color/material_dynamic_secondary10</item>
<item name="android:statusBarColor">@color/material_dynamic_neutral10</item>
</style>
<!-- Base application theme less than android 12 -->
<style name="AppDefaultTheme" parent="Theme.Material3.DayNight">
<item name="colorPrimary">#228DFF</item>
<item name="colorPrimaryDark">#1B6CC3</item>
<item name="colorAccent">#03A9F4</item>
<item name="android:statusBarColor">#000000</item>
</style>
@ -24,4 +31,11 @@
<item name="android:color">@color/material_dynamic_primary50</item>
</style>
<style name="BottomNavDefault" parent="Widget.Material3.BottomNavigationView.ActiveIndicator">
<item name="android:color">#228DFF</item>
</style>
</resources>

Loading…
Cancel
Save