From 6e55c0105d346929e2e062d442caace44cfb8bd8 Mon Sep 17 00:00:00 2001 From: HemantYadav Date: Sun, 24 Nov 2019 21:30:04 +0530 Subject: [PATCH] edited views and default colors of bars --- .idea/vcs.xml | 6 +++++ .../com/example/custombars/MainActivity.java | 7 +++--- .../example/customizebars/ColorPicker.java | 22 +++++++++++++------ .../src/main/res/drawable/rounded_back.xml | 6 +++++ .../src/main/res/layout/color_picker.xml | 20 +++++++++++++---- 5 files changed, 47 insertions(+), 14 deletions(-) create mode 100644 .idea/vcs.xml create mode 100644 customizebars/src/main/res/drawable/rounded_back.xml diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/example/custombars/MainActivity.java b/app/src/main/java/com/example/custombars/MainActivity.java index e54125a..6f50488 100644 --- a/app/src/main/java/com/example/custombars/MainActivity.java +++ b/app/src/main/java/com/example/custombars/MainActivity.java @@ -4,6 +4,7 @@ import android.content.Intent; import android.content.SharedPreferences; +import android.graphics.Color; import android.graphics.drawable.ColorDrawable; import android.hardware.SensorListener; import android.hardware.SensorManager; @@ -35,9 +36,9 @@ public class MainActivity extends AppCompatActivity implements SensorListener { private int statusbar; private int actionbar; private int background; - private int defaultStatusbar = 0; - private int defaultActionbar = 0; - private int defaultbackground = 0; + private int defaultStatusbar = Color.parseColor("#6e5e34"); + private int defaultActionbar = Color.parseColor("#30270f"); + private int defaultbackground = Color.parseColor("#b8b7b6"); private String myActivityName; public int helper = 0; diff --git a/customizebars/src/main/java/com/example/customizebars/ColorPicker.java b/customizebars/src/main/java/com/example/customizebars/ColorPicker.java index 213f915..7d4b43f 100644 --- a/customizebars/src/main/java/com/example/customizebars/ColorPicker.java +++ b/customizebars/src/main/java/com/example/customizebars/ColorPicker.java @@ -11,6 +11,7 @@ import android.view.Window; import android.view.WindowManager; import android.widget.LinearLayout; +import android.widget.ScrollView; import android.widget.Toast; import androidx.appcompat.app.AppCompatActivity; @@ -28,16 +29,17 @@ public class ColorPicker extends AppCompatActivity { private SaturationBar saturationBar; private View second; private View third; - private LinearLayout lm; + private ScrollView lm; + private LinearLayout smback; private final String PREFERENCE_FILE_KEY = "Colorpreferences"; private SharedPreferences.Editor editor; private SharedPreferences sharedPref; private String descriptionStatusBar = "StatusBar"; private String descriptionActionBar = "ActionBar"; private String descriptionBackground = "Background"; - private int defaultStatusbar = 0; - private int defaultActionbar = 0; - private int defaultbackground = 0; + private int defaultStatusbar = Color.parseColor("#6e5e34"); + private int defaultActionbar = Color.parseColor("#30270f"); + private int defaultbackground = Color.parseColor("#b8b7b6"); private int statusbar; private int actionbar; private String myActivityName; @@ -48,6 +50,9 @@ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.color_picker); + first = findViewById(R.id.statusbar); + second = findViewById(R.id.actionbar); + third = findViewById(R.id.background); picker = findViewById(R.id.picker); valueBar = (ValueBar) findViewById(R.id.valuebar); opacityBar = (OpacityBar) findViewById(R.id.opacitybar); @@ -56,6 +61,7 @@ protected void onCreate(Bundle savedInstanceState) { picker.addOpacityBar(opacityBar); picker.addSaturationBar(saturationBar); lm = findViewById(R.id.mainback); + smback = findViewById(R.id.smallback); myActivityName = getIntent().getStringExtra("NextActivity"); sharedPref = ColorPicker.this.getSharedPreferences(PREFERENCE_FILE_KEY, Context.MODE_PRIVATE); @@ -66,15 +72,16 @@ protected void onCreate(Bundle savedInstanceState) { background = sharedPref.getInt(descriptionBackground, defaultbackground); getSupportActionBar().setBackgroundDrawable(new ColorDrawable(actionbar)); + second.setBackgroundColor(actionbar); lm.setBackgroundColor(background); + smback.setBackgroundColor(background); + third.setBackgroundColor(background); Window window = getWindow(); window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.setStatusBarColor(statusbar); + first.setBackgroundColor(statusbar); - first = findViewById(R.id.statusbar); - second = findViewById(R.id.actionbar); - third = findViewById(R.id.background); first.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -107,6 +114,7 @@ public void onClick(View v) { picker.setOldCenterColor(picker.getColor()); third.setBackgroundColor(picker.getColor()); lm.setBackgroundColor(picker.getColor()); + smback.setBackgroundColor(picker.getColor()); editor.putInt(descriptionBackground, picker.getColor()); editor.apply(); } diff --git a/customizebars/src/main/res/drawable/rounded_back.xml b/customizebars/src/main/res/drawable/rounded_back.xml new file mode 100644 index 0000000..3900bd2 --- /dev/null +++ b/customizebars/src/main/res/drawable/rounded_back.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/customizebars/src/main/res/layout/color_picker.xml b/customizebars/src/main/res/layout/color_picker.xml index 3c3c6ea..2725094 100644 --- a/customizebars/src/main/res/layout/color_picker.xml +++ b/customizebars/src/main/res/layout/color_picker.xml @@ -1,39 +1,50 @@ - + + @@ -104,5 +115,6 @@ + - \ No newline at end of file + \ No newline at end of file