Skip to content

Commit

Permalink
edited views and default colors of bars
Browse files Browse the repository at this point in the history
  • Loading branch information
Hemant27031999 committed Nov 24, 2019
1 parent c2fa96f commit 6e55c01
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 14 deletions.
6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions app/src/main/java/com/example/custombars/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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) {
Expand Down Expand Up @@ -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();
}
Expand Down
6 changes: 6 additions & 0 deletions customizebars/src/main/res/drawable/rounded_back.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#FFFFFF"/>
<corners android:radius="200dp"/>
<padding android:left="0dp" android:top="0dp" android:right="0dp" android:bottom="0dp" />
</shape>
20 changes: 16 additions & 4 deletions customizebars/src/main/res/layout/color_picker.xml
Original file line number Diff line number Diff line change
@@ -1,39 +1,50 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:id="@+id/mainback"
android:layout_height="match_parent">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/smallback"
android:orientation="vertical">

<com.larswerkman.holocolorpicker.ColorPicker
android:id="@+id/picker"
android:layout_marginVertical="10dp"
android:layout_gravity="center"
android:background="#FFFFFF"
android:layout_width="wrap_content"
android:background="@drawable/rounded_back"
android:layout_width="200dp"
android:layout_height="wrap_content"/>

<com.larswerkman.holocolorpicker.OpacityBar
android:id="@+id/opacitybar"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_marginVertical="10dp"
android:layout_height="wrap_content"/>

<com.larswerkman.holocolorpicker.SaturationBar
android:id="@+id/saturationbar"
android:layout_gravity="center"
android:layout_marginVertical="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>

<com.larswerkman.holocolorpicker.ValueBar
android:id="@+id/valuebar"
android:layout_gravity="center"
android:layout_marginVertical="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginVertical="10dp"
android:background="#fff"
android:orientation="vertical">

Expand Down Expand Up @@ -104,5 +115,6 @@
</LinearLayout>

</LinearLayout>
</LinearLayout>

</LinearLayout>
</ScrollView>

0 comments on commit 6e55c01

Please sign in to comment.