Skip to content

Commit

Permalink
added info dialog frag and credits text in SettingsActivity.
Browse files Browse the repository at this point in the history
  • Loading branch information
aiman-al-masoud committed Jul 24, 2021
1 parent 7b68438 commit 33a4463
Show file tree
Hide file tree
Showing 5 changed files with 143 additions and 9 deletions.
75 changes: 75 additions & 0 deletions app/src/main/java/com/luxlunaris/noadpadlight/ui/InfoFragment.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package com.luxlunaris.noadpadlight.ui;

import android.os.Bundle;

import androidx.fragment.app.DialogFragment;
import androidx.fragment.app.Fragment;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;

import com.luxlunaris.noadpadlight.R;
import com.luxlunaris.noadpadlight.control.classes.SETTINGS_TAGS;
import com.luxlunaris.noadpadlight.control.classes.Settings;

/**
* It's a simple un-interactive prompt that
* displays some text to the user.
*/
public class InfoFragment extends DialogFragment {

/**
* Text displayed as info
*/
String text;

/**
* Dismisses the fragment
*/
Button gotItButton;

/**
* Displays the info text
*/
TextView textArea;

public InfoFragment() {
// Required empty public constructor
}

public static InfoFragment newInstance(String text) {
InfoFragment fragment = new InfoFragment();
fragment.text = text;
return fragment;
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){
View view = inflater.inflate(R.layout.fragment_info, container, false);
gotItButton = view.findViewById(R.id.info_frag_button);
gotItButton.setOnClickListener(new GotItHandler());
textArea = view.findViewById(R.id.infoFragmentText);
textArea.setText(text);
THEMES theme = THEMES.getThemeByName(Settings.getString(SETTINGS_TAGS.THEME));
gotItButton.setBackgroundColor(theme.BG_COLOR);
gotItButton.setTextColor(theme.FG_COLOR);
textArea.setBackgroundColor(theme.BG_COLOR);
textArea.setTextColor(theme.FG_COLOR);
view.setBackgroundColor(theme.BG_COLOR);
return view;
}

class GotItHandler implements View.OnClickListener {

@Override
public void onClick(View v) {
dismiss();
}
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -88,19 +88,11 @@ private void jumpToPosition(int position){
@Override
protected void onPause() {
super.onPause();




//get the edited text from the edittext view
String editedText = textView.getText().toString();





//if the edited text is empty, delete the Page


if(editedText.trim().isEmpty()){
boolean t = page.delete();
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@


import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;


Expand All @@ -23,6 +25,19 @@ protected void onCreate(Bundle savedInstanceState) {

linearLayout = findViewById(R.id.settings_lin_layout);

Button showInfo = new Button(this);
linearLayout.addView(showInfo, 0);
showInfo.setText("Credits & more Info");
showInfo.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
InfoFragment infoFrag = InfoFragment.newInstance(getResources().getString(R.string.credits_eng));
infoFrag.show(getSupportFragmentManager(), "");
}
});



ToggleFragment lauchToBlankPageToggle = ToggleFragment.newInstance("Auto-launch the app to a blank page.", SETTINGS_TAGS.LAUNCH_TO_BLANK_PAGE);
getSupportFragmentManager().beginTransaction().add(linearLayout.getId(), lauchToBlankPageToggle, "" ).commit();

Expand Down
38 changes: 38 additions & 0 deletions app/src/main/res/layout/fragment_info.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/frameLayout2"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.InfoFragment">

<Button
android:id="@+id/info_frag_button"
android:layout_width="186dp"
android:layout_height="40dp"
android:layout_marginBottom="56dp"
android:text="got it!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.498"
app:layout_constraintStart_toStartOf="parent" />

<EditText
android:id="@+id/infoFragmentText"
android:layout_width="313dp"
android:layout_height="453dp"
android:editable="false"
android:ems="10"
android:enabled="true"
android:focusable="true"
android:gravity="start|top"
android:inputType="textMultiLine"
app:layout_constraintBottom_toTopOf="@+id/info_frag_button"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.571"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.584" />

</androidx.constraintlayout.widget.ConstraintLayout>
14 changes: 14 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,18 @@
<string name="hello_second_fragment">Hello second fragment. Arg: %1$s</string>
<!-- TODO: Remove or change this placeholder text -->
<string name="hello_blank_fragment">Hello blank fragment</string>


<string name="credits_eng">

Thanks for trying out Noadpad! :-) \n

For any suggestions: \n\n

Contact: luxlunarislabs@gmail.com \n
Repo: https://github.com/aiman-al-masoud/noadpadlight \n
License: https://github.com/aiman-al-masoud/noadpadlight/blob/master/LICENSE.md \n
</string>


</resources>

0 comments on commit 33a4463

Please sign in to comment.