diff --git a/app/build.gradle b/app/build.gradle index 1d6a6a1..f3fff55 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -26,6 +26,9 @@ dependencies { implementation fileTree(dir: "libs", include: ["*.jar"]) implementation 'androidx.constraintlayout:constraintlayout:2.0.4' implementation 'com.google.android.material:material:1.3.0' + implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'androidx.navigation:navigation-fragment:2.1.0' + implementation 'androidx.navigation:navigation-ui:2.1.0' testImplementation 'junit:junit:4.12' androidTestImplementation 'androidx.test.ext:junit:1.1.2' androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' diff --git a/app/gradle/wrapper/gradle-wrapper.jar b/app/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..f6b961f Binary files /dev/null and b/app/gradle/wrapper/gradle-wrapper.jar differ diff --git a/app/gradle/wrapper/gradle-wrapper.properties b/app/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..886c10e --- /dev/null +++ b/app/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Sun Feb 14 15:04:44 IST 2021 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 9dfb3ea..d6c528d 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -6,10 +6,17 @@ android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" - android:roundIcon="@mipmap/ic_launcher_round" + android:roundIcon="@mipmap/ic_launcher" android:supportsRtl="true" android:theme="@style/Theme.AppCompat"> - + + + diff --git a/app/src/main/java/com/example/myapplicationone/CreditsActivity.java b/app/src/main/java/com/example/myapplicationone/CreditsActivity.java new file mode 100644 index 0000000..69604de --- /dev/null +++ b/app/src/main/java/com/example/myapplicationone/CreditsActivity.java @@ -0,0 +1,43 @@ +package com.example.myapplicationone; + +import android.os.Build; +import android.os.Bundle; +import android.text.Html; +import android.text.method.LinkMovementMethod; +import android.view.Window; +import android.view.WindowManager; +import android.widget.TextView; + +import androidx.appcompat.app.AppCompatActivity; + +public class CreditsActivity extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + requestWindowFeature(Window.FEATURE_NO_TITLE); + this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, + WindowManager.LayoutParams.FLAG_FULLSCREEN); //enable full screen + setContentView(R.layout.activity_credits); + TextView noteView3 = (TextView) findViewById(R.id.textView3); + TextView noteView5 = (TextView) findViewById(R.id.textView5); + TextView noteView9 = (TextView) findViewById(R.id.textView9); + + noteView3.setClickable(true); + noteView5.setClickable(true); + noteView9.setClickable(true); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { + noteView3.setText(Html.fromHtml("" + getResources().getString(R.string.My_Name_Text) + "", Html.FROM_HTML_MODE_LEGACY)); + noteView5.setText(Html.fromHtml("" + getResources().getString(R.string.Guidance_by_Text) + "", Html.FROM_HTML_MODE_LEGACY)); + noteView9.setText(Html.fromHtml("" + getResources().getString(R.string.Github_link_Text) + "", Html.FROM_HTML_MODE_LEGACY)); + } else { + noteView3.setText(Html.fromHtml("" + getResources().getString(R.string.My_Name_Text) + "")); + noteView5.setText(Html.fromHtml("" + getResources().getString(R.string.Guidance_by_Text) + "")); + noteView9.setText(Html.fromHtml("" + getResources().getString(R.string.Github_link_Text) + "")); + } + noteView3.setMovementMethod(LinkMovementMethod.getInstance()); + noteView5.setMovementMethod(LinkMovementMethod.getInstance()); + noteView9.setMovementMethod(LinkMovementMethod.getInstance()); + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/example/myapplicationone/FirstFragment.java b/app/src/main/java/com/example/myapplicationone/FirstFragment.java new file mode 100644 index 0000000..8e2a2f1 --- /dev/null +++ b/app/src/main/java/com/example/myapplicationone/FirstFragment.java @@ -0,0 +1,34 @@ +package com.example.myapplicationone; + +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import androidx.annotation.NonNull; +import androidx.fragment.app.Fragment; +import androidx.navigation.fragment.NavHostFragment; + +public class FirstFragment extends Fragment { + + @Override + public View onCreateView( + LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState + ) { + // Inflate the layout for this fragment + return inflater.inflate(R.layout.fragment_first, container, false); + } + + public void onViewCreated(@NonNull View view, Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + + /*view.findViewById(R.id.button_first).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + NavHostFragment.findNavController(FirstFragment.this) + .navigate(R.id.action_FirstFragment_to_SecondFragment); + } + });*/ + } +} \ No newline at end of file diff --git a/app/src/main/java/com/example/myapplicationone/MainActivity.java b/app/src/main/java/com/example/myapplicationone/MainActivity.java index 8fe6e33..8f7d23e 100644 --- a/app/src/main/java/com/example/myapplicationone/MainActivity.java +++ b/app/src/main/java/com/example/myapplicationone/MainActivity.java @@ -1,37 +1,76 @@ package com.example.myapplicationone; import android.content.Context; +import android.content.Intent; import android.content.pm.PackageManager; -import android.content.res.Configuration; import android.graphics.Color; +import android.graphics.drawable.AnimationDrawable; import android.graphics.drawable.ColorDrawable; import android.hardware.camera2.CameraAccessException; import android.hardware.camera2.CameraManager; import android.os.Build; import android.os.Bundle; +import android.view.Menu; +import android.view.MenuInflater; +import android.view.MenuItem; import android.view.View; +import android.view.Window; +import android.view.WindowManager; +import android.widget.Button; import android.widget.CompoundButton; import android.widget.RelativeLayout; +import android.widget.TextView; import android.widget.Toast; import android.widget.ToggleButton; import androidx.annotation.RequiresApi; import androidx.appcompat.app.AppCompatActivity; -import androidx.appcompat.app.AppCompatDelegate; +import androidx.appcompat.widget.AppCompatButton; +import androidx.appcompat.widget.ShareActionProvider; +import androidx.core.view.MenuItemCompat; + +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; public class MainActivity extends AppCompatActivity { private CameraManager cameraManager; private String cameraId; + private ShareActionProvider shareActionProvider; + private Button button; + + public boolean onCreateOptionsMenu(Menu menu) { + MenuInflater inflater = getMenuInflater(); + inflater.inflate(R.menu.main_menu, menu); + MenuItem menuItem = menu.findItem(R.id.action_share); + shareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(menuItem); + setShareActionIntent("https://drive.google.com/drive/u/0/my-drive"); + return super.onCreateOptionsMenu(menu); + } + + private void setShareActionIntent(String text) { + Intent i = new Intent(); + i.setAction(Intent.ACTION_SEND); + i.setType("image/*"); + i.putExtra(Intent.EXTRA_TEXT, text); + shareActionProvider.setShareIntent(i); + } + @RequiresApi(api = Build.VERSION_CODES.M) @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + requestWindowFeature(Window.FEATURE_NO_TITLE); + this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, + WindowManager.LayoutParams.FLAG_FULLSCREEN); //enable full screen setContentView(R.layout.activity_main); + boolean isFlashAvailable = getApplicationContext().getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH); - if (!isFlashAvailable) + if (!isFlashAvailable) { noFlashAvailableError(); + } cameraManager = (CameraManager) getSystemService(Context.CAMERA_SERVICE); try { @@ -47,32 +86,219 @@ protected void onCreate(Bundle savedInstanceState) { @RequiresApi(api = Build.VERSION_CODES.M) @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { - try { - cameraManager.setTorchMode(cameraId, isChecked); - } catch (CameraAccessException e) { - e.printStackTrace(); - } + try { + cameraManager.setTorchMode(cameraId, isChecked); + } catch (CameraAccessException e) { + e.printStackTrace(); + } } }); - // ACTIONS FOR BUTTON ID: Button3 - - ToggleButton toggleDarkModeButton = findViewById(R.id.Button3); + ToggleButton toggleDarkModeButton = (ToggleButton) findViewById(R.id.Button3); + //attach listener with ToggleButton toggleDarkModeButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @RequiresApi(api = Build.VERSION_CODES.M) @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { RelativeLayout rootView = findViewById(R.id.mainLayout); - if(isChecked) { + TextView rootView2 = findViewById(R.id.textView5); + TextView rootView3 = findViewById(R.id.textView3); + TextView rootView4 = findViewById(R.id.textView4); + TextView rootView5 = findViewById(R.id.textView6); + TextView rootView6 = findViewById(R.id.textView7); + TextView rootView7 = findViewById(R.id.textView8); + Button button = findViewById(R.id.button7); + if (isChecked) { rootView.setBackgroundColor(0xFF363229); + rootView2.setBackgroundColor(0xFF363229); + rootView3.setBackgroundColor(0xFF363229); + rootView4.setBackgroundColor(0xFF363229); + rootView5.setBackgroundColor(0xFF363229); + rootView6.setBackgroundColor(0xFF363229); + rootView7.setBackgroundColor(0xFF363229); + button.setBackgroundColor(0xFF363229); + rootView3.setTextColor(0xFF40E0D0); + rootView2.setTextColor(0xFF40E0D0); + rootView4.setTextColor(0xFF40E0D0); + rootView5.setTextColor(0xFF40E0D0); + rootView6.setTextColor(0xFF40E0D0); + rootView7.setTextColor(0xFF40E0D0); + button.setTextColor(0xFF40E0D0); + } else { + rootView.setBackgroundColor(0xFF40E0D0); + rootView2.setBackgroundColor(0xFFF9945E); + rootView3.setBackgroundColor(0xFF40E0D0); + rootView4.setBackgroundColor(0xFFF9945E); + rootView5.setBackgroundColor(0xFFF9945E); + rootView6.setBackgroundColor(0xFFF50B1A); + rootView7.setBackgroundColor(0xFFF50B1A); + button.setBackgroundColor(0xFF806D04); + rootView3.setTextColor(0xFF000204); + rootView2.setTextColor(0xFF741111); + rootView4.setTextColor(0xFF741111); + rootView5.setTextColor(0xFF741111); + rootView6.setTextColor(0xFFFFF7FB); + rootView7.setTextColor(0xFFFFF7FB); + button.setTextColor(0xFFFFF7FB); + } + + } + }); + //Action for Button7 + button = findViewById(R.id.button7); + button.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + openCreditsActivity(); + } + }); + + // ACTIONS FOR BUTTON ID: Button4 + ToggleButton toggleBlinkBtn = findViewById(R.id.Button4); + toggleBlinkBtn.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @RequiresApi(api = Build.VERSION_CODES.M) + @Override + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + + if (isChecked) { + blinkFlash(); + } else { + try { + cameraManager.setTorchMode(cameraId, false); + } catch (CameraAccessException e) { + } + Toast.makeText(MainActivity.this, "Press the above button first.", + Toast.LENGTH_SHORT).show(); + } + + } + + }); + // ACTIONS FOR BUTTON ID: Button5 + ToggleButton toggleSoSModeButton = (ToggleButton) findViewById(R.id.Button5); + //attach listener with ToggleButton + toggleSoSModeButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @RequiresApi(api = Build.VERSION_CODES.M) + @Override + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + RelativeLayout rootView = findViewById(R.id.mainLayout); + TextView textView3 = findViewById(R.id.textView3); + final AnimationDrawable drawable1 = new AnimationDrawable(); + final AnimationDrawable drawable2 = new AnimationDrawable(); + ScheduledExecutorService backgroundExecutor = Executors.newSingleThreadScheduledExecutor(); + + if (isChecked) { + drawable1.addFrame(new ColorDrawable(Color.RED), 400); + drawable1.addFrame(new ColorDrawable(0xFF00FFFF), 400); + drawable1.setOneShot(false); + + drawable2.addFrame(new ColorDrawable(Color.RED), 400); + drawable2.addFrame(new ColorDrawable(0xFF00FFFF), 400); + drawable2.setOneShot(false); + + rootView.setBackground(drawable1); + textView3.setBackground(drawable2); + backgroundExecutor.schedule(new Runnable() { + @Override + public void run() { + drawable1.start(); + drawable2.start(); + } + }, 100, TimeUnit.MILLISECONDS); + } else { - rootView.setBackgroundColor(0xFFCDDC39); + ((AnimationDrawable) (rootView.getBackground())).stop(); + rootView.setBackground(null); + rootView.setBackgroundColor(0xFF00FFFF); + ((AnimationDrawable) (textView3.getBackground())).stop(); + textView3.setBackground(null); + textView3.setBackgroundColor(0xFF00FFFF); } } + + }); + //Action for Button 6 + ToggleButton toggleSoSModeButton2 = (ToggleButton) findViewById(R.id.Button6); + toggleSoSModeButton2.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @RequiresApi(api = Build.VERSION_CODES.M) + @Override + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + if (isChecked) { + blinkSOSFlash(); + } else { + try { + cameraManager.setTorchMode(cameraId, false); + } catch (CameraAccessException e) { + } + Toast.makeText(MainActivity.this, "Press the above button first.", + Toast.LENGTH_SHORT).show(); + } + + } + }); + + } + + @RequiresApi(api = Build.VERSION_CODES.M) + private void openCreditsActivity() { + Intent intent = new Intent(this ,CreditsActivity.class); + startActivity(intent); } + private void noFlashAvailableError() { Toast.makeText(MainActivity.this, "Torch not Available", Toast.LENGTH_SHORT).show(); + + } + + @RequiresApi(api = Build.VERSION_CODES.M) + private void blinkSOSFlash() { + try { + CameraManager cameraManager = (CameraManager) getSystemService(Context.CAMERA_SERVICE); + String cameraId = cameraManager.getCameraIdList()[0]; + String myString = "101010000001010100000010101000000101000000101010000001010100000010101000000101010000001010100000010101000000101010000001010100000010101"; + long blinkDelay = 89; //Delay in ms + for (int i = 0; i < myString.length(); i++) { + if (myString.charAt(i) == '0') { + this.cameraManager.setTorchMode(cameraId, true); + } else { + this.cameraManager.setTorchMode(cameraId, false); + } + try { + Thread.sleep(blinkDelay); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + } catch (CameraAccessException e) { + e.printStackTrace(); + } + } + + @RequiresApi(api = Build.VERSION_CODES.M) + private void blinkFlash() { + try { + CameraManager cameraManager = (CameraManager) getSystemService(Context.CAMERA_SERVICE); + String cameraId = cameraManager.getCameraIdList()[0]; + String myString = "010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010010101010101010101010101010101010101010101010101010101"; + long blinkDelay = 150; //Delay in ms + for (int i = 0; i < myString.length(); i++) { + if (myString.charAt(i) == '0') { + this.cameraManager.setTorchMode(cameraId, true); + } else { + this.cameraManager.setTorchMode(cameraId, false); + } + try { + Thread.sleep(blinkDelay); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + } catch (CameraAccessException e) { + e.printStackTrace(); + } } } + + diff --git a/app/src/main/java/com/example/myapplicationone/SecondFragment.java b/app/src/main/java/com/example/myapplicationone/SecondFragment.java new file mode 100644 index 0000000..d285b22 --- /dev/null +++ b/app/src/main/java/com/example/myapplicationone/SecondFragment.java @@ -0,0 +1,34 @@ +package com.example.myapplicationone; + +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import androidx.annotation.NonNull; +import androidx.fragment.app.Fragment; +import androidx.navigation.fragment.NavHostFragment; + +public class SecondFragment extends Fragment { + + @Override + public View onCreateView( + LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState + ) { + // Inflate the layout for this fragment + return inflater.inflate(R.layout.fragment_second, container, false); + } + + public void onViewCreated(@NonNull View view, Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + + /*view.findViewById(R.id.button_second).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + NavHostFragment.findNavController(SecondFragment.this) + .navigate(R.id.action_SecondFragment_to_FirstFragment); + } + });*/ + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable/gitcover.png b/app/src/main/res/drawable/gitcover.png new file mode 100644 index 0000000..407ae29 Binary files /dev/null and b/app/src/main/res/drawable/gitcover.png differ diff --git a/app/src/main/res/layout/activity_credits.xml b/app/src/main/res/layout/activity_credits.xml new file mode 100644 index 0000000..7a18371 --- /dev/null +++ b/app/src/main/res/layout/activity_credits.xml @@ -0,0 +1,132 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 82790a7..6d87a7e 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -1,25 +1,26 @@ - + - + + + + + + + + + + + + +