From 5ff079d0dd6aa7a42b53bb3ab17dcb3ead3b9516 Mon Sep 17 00:00:00 2001 From: lubenard Date: Sat, 18 Sep 2021 19:18:01 +0200 Subject: [PATCH 01/48] Added round progress bar for main view, first draw --- .../lubenard/oring_reminder/MainActivity.java | 4 +- .../ui/NewDesignDetailsFragment.java | 68 +++++++++++++++++++ app/src/main/res/drawable/circle.xml | 26 +++++++ .../res/layout/new_deign_home_fragment.xml | 42 ++++++++++++ app/src/main/res/values/styles.xml | 5 ++ 5 files changed, 144 insertions(+), 1 deletion(-) create mode 100644 app/src/main/java/com/lubenard/oring_reminder/ui/NewDesignDetailsFragment.java create mode 100644 app/src/main/res/drawable/circle.xml create mode 100644 app/src/main/res/layout/new_deign_home_fragment.xml diff --git a/app/src/main/java/com/lubenard/oring_reminder/MainActivity.java b/app/src/main/java/com/lubenard/oring_reminder/MainActivity.java index 5084795..ccccc6b 100644 --- a/app/src/main/java/com/lubenard/oring_reminder/MainActivity.java +++ b/app/src/main/java/com/lubenard/oring_reminder/MainActivity.java @@ -20,6 +20,7 @@ import com.lubenard.oring_reminder.ui.EntryDetailsFragment; import com.lubenard.oring_reminder.ui.MainFragment; +import com.lubenard.oring_reminder.ui.NewDesignDetailsFragment; import com.lubenard.oring_reminder.utils.Utils; import java.util.concurrent.Callable; @@ -147,7 +148,8 @@ public void onCreate(Bundle savedInstanceState) { } else { Log.d("Widget", "No given session id"); // Then switch to the main Fragment - fragmentTransaction.replace(android.R.id.content, new MainFragment()); + fragmentTransaction.replace(android.R.id.content, new NewDesignDetailsFragment()); + //fragmentTransaction.replace(android.R.id.content, new MainFragment()); } fragmentTransaction.commit(); } diff --git a/app/src/main/java/com/lubenard/oring_reminder/ui/NewDesignDetailsFragment.java b/app/src/main/java/com/lubenard/oring_reminder/ui/NewDesignDetailsFragment.java new file mode 100644 index 0000000..e644ae8 --- /dev/null +++ b/app/src/main/java/com/lubenard/oring_reminder/ui/NewDesignDetailsFragment.java @@ -0,0 +1,68 @@ +package com.lubenard.oring_reminder.ui; + +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.Button; +import android.widget.ProgressBar; +import android.widget.TextView; + +import androidx.fragment.app.Fragment; + +import com.lubenard.oring_reminder.R; + +public class NewDesignDetailsFragment extends Fragment { + ProgressBar progress_bar; + TextView progress_bar_text; + int progr = 0; + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setHasOptionsMenu(true); + return inflater.inflate(R.layout.new_deign_home_fragment, container, false); + } + + @Override + public void onViewCreated(View view, Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + + progress_bar = view.findViewById(R.id.progress_bar); + progress_bar_text = view.findViewById(R.id.text_view_progress); + + //((AppCompatActivity)getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true); + + getActivity().setTitle("Test new design"); + + Button decr = view.findViewById(R.id.button_decr); + Button incr = view.findViewById(R.id.button_incr); + + incr.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + if (progr <= 90) { + progr += 10; + updateProgressBar(); + } + } + }); + + decr.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + if (progr >= 10) { + progr -= 10; + updateProgressBar(); + } + } + }); + + } + + private void updateProgressBar() { + progress_bar.setProgress(progr); + progress_bar_text.setText(progr + "%"); + } + +} diff --git a/app/src/main/res/drawable/circle.xml b/app/src/main/res/drawable/circle.xml new file mode 100644 index 0000000..8827906 --- /dev/null +++ b/app/src/main/res/drawable/circle.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/new_deign_home_fragment.xml b/app/src/main/res/layout/new_deign_home_fragment.xml new file mode 100644 index 0000000..e22bc82 --- /dev/null +++ b/app/src/main/res/layout/new_deign_home_fragment.xml @@ -0,0 +1,42 @@ + + + + +