Skip to content
This repository has been archived by the owner on Jul 19, 2020. It is now read-only.

Commit

Permalink
dude
Browse files Browse the repository at this point in the history
  • Loading branch information
mutdmour committed Jun 22, 2016
1 parent b2eb5c9 commit 6deaaeb
Show file tree
Hide file tree
Showing 20 changed files with 388 additions and 103 deletions.
1 change: 1 addition & 0 deletions .idea/vcs.xml

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

4 changes: 4 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.mutasem.jarofawesome">
<uses-permission android:name="android.permission.VIBRATE"/>

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme.NoActionBar">
<!--android:backupAgent="backUpAgent">-->
<!--<meta-data android:name="com.google.android.backup.api_key"-->
<!--android:value="AEdPqrEAAAAIKo7ltErwSfG7lra_D04f3QAgQPk_URTCupZ8AQ" />-->
<activity
android:name=".MainMenuActivity"
android:label="@string/title_activity_main_menu"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/org/mutasem/jarofawesome/Entry.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public String getTitle(){
return this.title;
}

public void setTitle(String content){
public void setTitle(String title){
this.title = title;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void run() {
View.SYSTEM_UI_FLAG_LOW_PROFILE
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_IMMERSIVE
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
}
Expand Down Expand Up @@ -123,9 +123,9 @@ protected void onCreate(Bundle savedInstanceState) {

/* setting texTview with text and scrolling */
mTitleView = (TextView) findViewById(R.id.entry_title);
mTitleView.setText("\n" + entry.getTitle() + "\n");
mTitleView.setText(entry.getTitle());
mContentView = (TextView) findViewById(R.id.entry_content);
mContentView.setText("\n"+entry.getContent()+"\n");
mContentView.setText(entry.getContent());
mContentView.setMovementMethod(new ScrollingMovementMethod());

/*is Action bar visible */
Expand All @@ -147,11 +147,17 @@ protected void onPostCreate(Bundle savedInstanceState) {
// created, to briefly hint to the user that UI controls
// are available.
delayedHide(100);
// findViewById(
// R.id.entry_title)
// .setOnTouchListener(
// mDelayHideTouchListener
// );
findViewById(
R.id.entry_content
).setOnTouchListener(
R.id.entry_content)
.setOnTouchListener(
mDelayHideTouchListener
);

}

@Override
Expand Down
40 changes: 25 additions & 15 deletions app/src/main/java/org/mutasem/jarofawesome/EntryWriterActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
import android.text.TextWatcher;
import android.util.AttributeSet;
import android.util.Log;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;
Expand Down Expand Up @@ -60,6 +62,8 @@ protected void onCreate(Bundle savedInstanceState) {
linedEditText.setLayoutParams(lp);
linedEditText.setTextColor(ContextCompat.getColor(getApplicationContext(),R.color.black));
linedEditText.setGravity(Gravity.TOP);
linedEditText.setTextSize(TypedValue.DENSITY_DEFAULT,getResources().getDimension(R.dimen.entry_content_size));
linedEditText.setWatcher();
layout.addView(linedEditText);
if (intent.hasExtra(EntryReaderActivity.extraEntry2Edit)){
update = true;
Expand All @@ -72,12 +76,12 @@ protected void onCreate(Bundle savedInstanceState) {
if (savedInstanceState != null){
linedEditText.setText(savedInstanceState.getString(saved_content));
}
tintView(linedEditText,
ContextCompat.getColor(
getApplicationContext(),
R.color.colorPrimaryLight
)
);
// tintView(linedEditText,
// ContextCompat.getColor(
// getApplicationContext(),
// R.color.colorPrimaryLight
// )
// );

try {
Field f = TextView.class.getDeclaredField("mCursorDrawableRes");
Expand Down Expand Up @@ -125,7 +129,7 @@ public void onSaveInstanceState(Bundle outState){

public boolean saveInput(){
String text = linedEditText.getText().toString();
if (text.length() > 0){
if (text.trim().length() > 0){
DialogFragment dialog = new GetTitleFragment();
dialog.show(getSupportFragmentManager(),"GetTitleFragment");
} else {
Expand Down Expand Up @@ -154,15 +158,21 @@ public boolean saveInput(){
}

@Override
public void onDialogPositiveClick(DialogFragment dialog, String title) {
if (title.length() > 0) {
if (update == true){
entry.setTitle(title);
MainMenuActivity.db.updateRow(entry);
} else {
MainMenuActivity.db.insertRow(linedEditText.getText().toString(), title);
public void onDialogPositiveClick(DialogFragment dialog, String newTitle) {
// Log.d("onDialogPositiveClick",newTitle);
if (newTitle != null) {
if (newTitle.trim().length() > 0) {
if (update == true) {
entry.setTitle(newTitle);
entry.setContent(linedEditText.getText().toString());
MainMenuActivity.db.updateRow(entry);
update = false;
this.title = null;
} else {
MainMenuActivity.db.insertRow(linedEditText.getText().toString(), newTitle);
}
linedEditText.setText("");
}
linedEditText.setText("");
} else {
//dialog.show(getSupportFragmentManager(),"GetTitleFragment");
//keep dialog open
Expand Down
42 changes: 35 additions & 7 deletions app/src/main/java/org/mutasem/jarofawesome/GetTitleFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,31 @@
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;

/**
* Created by mutasemdmour on 6/15/16.
*/
public class GetTitleFragment extends DialogFragment {
public interface GetTitleListener {
public void onDialogPositiveClick(DialogFragment dialog, String title);
public void onDialogPositiveClick(DialogFragment dialog, String newTitle);
public void onDialogNegativeClick(DialogFragment dialog);
public String getOldTitle();
}

GetTitleListener mListener;
View inflated;
private GetTitleListener mListener;
private View inflated;
private static String KEY_CURR_TITLE = "org.mutasem.jarofawesome.GetTitleFragment.currTitle";

public static GetTitleFragment newInstance(String title) {
GetTitleFragment frag = new GetTitleFragment();
Bundle args = new Bundle();
args.putString("title",title);
frag.setArguments(args);
return frag;
}


@Override
Expand All @@ -46,15 +57,21 @@ public Dialog onCreateDialog(Bundle savedInstanceState){

inflated = inflater.inflate(R.layout.fragment_title_get, null);
EditText editText = (EditText) inflated.findViewById(R.id.title_input);
editText.setText(mListener.getOldTitle());
String currTitle = mListener.getOldTitle();
if (savedInstanceState != null){
currTitle = savedInstanceState.getString(KEY_CURR_TITLE);
}
editText.setText(currTitle);
builder.setView(inflated)
.setPositiveButton(
R.string.yes,
new DialogInterface.OnClickListener(){
public void onClick(DialogInterface dialog, int id){
EditText editText = (EditText) inflated.findViewById(R.id.title_input);
String title = editText.getText().toString();
mListener.onDialogPositiveClick(GetTitleFragment.this, title);
String newTitle = editText.getText().toString();
Log.d("newTitle",newTitle);
mListener.onDialogPositiveClick(GetTitleFragment.this, newTitle);
editText.setText("");
}
}
).setNegativeButton(
Expand All @@ -65,7 +82,18 @@ public void onClick(DialogInterface dialog, int id){
}
}
);
return builder.create();
// return builder.create();
Dialog d = builder.create();
d.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
return d;
}

@Override
public void onStart() {
super.onStart();
EditText editText = (EditText) inflated.findViewById(R.id.title_input);
editText.requestFocus();
}


}
Loading

0 comments on commit 6deaaeb

Please sign in to comment.