diff --git a/.idea/.name b/.idea/.name
deleted file mode 100644
index 9d70cd7..0000000
--- a/.idea/.name
+++ /dev/null
@@ -1 +0,0 @@
-Menu
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
index 724d9e5..6520b72 100644
--- a/.idea/modules.xml
+++ b/.idea/modules.xml
@@ -2,9 +2,8 @@
-
+
-
-
+
\ No newline at end of file
diff --git a/Menu.iml b/BlogSpot.iml
similarity index 77%
rename from Menu.iml
rename to BlogSpot.iml
index 135b56d..0ddae56 100644
--- a/Menu.iml
+++ b/BlogSpot.iml
@@ -1,5 +1,5 @@
-
+
diff --git a/app/app.iml b/app/app.iml
index 303c1fe..16748a2 100644
--- a/app/app.iml
+++ b/app/app.iml
@@ -63,13 +63,6 @@
-
-
-
-
-
-
-
@@ -77,17 +70,32 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
@@ -95,6 +103,7 @@
+
@@ -113,6 +122,7 @@
+
@@ -124,7 +134,6 @@
-
diff --git a/app/src/main/assets/fonts/Roboto-Light.ttf b/app/src/main/assets/fonts/Roboto-Light.ttf
new file mode 100644
index 0000000..94c6bcc
Binary files /dev/null and b/app/src/main/assets/fonts/Roboto-Light.ttf differ
diff --git a/app/src/main/assets/fonts/Roboto-Medium.ttf b/app/src/main/assets/fonts/Roboto-Medium.ttf
new file mode 100644
index 0000000..39c63d7
Binary files /dev/null and b/app/src/main/assets/fonts/Roboto-Medium.ttf differ
diff --git a/app/src/main/assets/fonts/Roboto-Regular.ttf b/app/src/main/assets/fonts/Roboto-Regular.ttf
new file mode 100644
index 0000000..8c082c8
Binary files /dev/null and b/app/src/main/assets/fonts/Roboto-Regular.ttf differ
diff --git a/app/src/main/java/com/example/tushar/menu/Blog.java b/app/src/main/java/com/example/tushar/menu/Blog.java
index 2be81c4..1700ba8 100644
--- a/app/src/main/java/com/example/tushar/menu/Blog.java
+++ b/app/src/main/java/com/example/tushar/menu/Blog.java
@@ -4,21 +4,23 @@
* Created by TUSHAR on 18-03-2017.
*/
- class Blog {
+class Blog {
private String Title;
private String Description;
private String Image;
private String Profile;
private String name;
- public Blog(){
- }
- public Blog(String Title, String Description, String Image,String Profile,String name) {
- this.Title = Title;
- this.Description = Description;
+ public Blog() {
+
+ }
+
+ public Blog(String Title, String Description, String Image, String Profile, String name) {
+ this.Title = Title;
+ this.Description = Description;
this.Image = Image;
- this.Profile=Profile;
- this.name=name;
+ this.Profile = Profile;
+ this.name = name;
}
public String getTitle() {
@@ -44,16 +46,18 @@ public String getImage() {
public void setImage(String image) {
this.Image = image;
}
- public void setProfile(String Profile){
- this.Profile=Profile;
- }
- public String getProfile(){
+
+ public void setProfile(String Profile) {
+ this.Profile = Profile;
+ }
+
+ public String getProfile() {
return Profile;
}
public String getName() {
- return "Posted by :" + name;
+ return "Posted by: " + name;
}
public void setName(String name) {
diff --git a/app/src/main/java/com/example/tushar/menu/PostActivity.java b/app/src/main/java/com/example/tushar/menu/PostActivity.java
index ddeacb4..cec9e29 100644
--- a/app/src/main/java/com/example/tushar/menu/PostActivity.java
+++ b/app/src/main/java/com/example/tushar/menu/PostActivity.java
@@ -33,21 +33,21 @@
import com.theartofdev.edmodo.cropper.CropImageView;
public class PostActivity extends ActionBarActivity {
- private final static int PERMISSION_REQUEST_CODE = 777;
-private ImageButton image;
- private Uri galleryuri=null;
+ private final static int PERMISSION_REQUEST_CODE = 777;
+ private ImageButton image;
+ private Uri galleryuri = null;
- private EditText title,description;
+ private EditText title, description;
private Button button;
- // SetupPage setup;
+ // SetupPage setup;
- private DatabaseReference data,users;
+ private DatabaseReference data, users;
private ProgressDialog progresss;
private StorageReference storage;
- private static final int GALLERY_REQUEST=1;
- private String name,desc;
+ private static final int GALLERY_REQUEST = 1;
+ private String name, desc;
public FirebaseAuth auth;
private FirebaseUser user;
public FirebaseAuth.AuthStateListener listener;
@@ -55,34 +55,34 @@ public class PostActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- if (!checkPermission()) requestPermissions();
+ if (!checkPermission()) requestPermissions();
setContentView(R.layout.activity_post);
- image=(ImageButton)findViewById(R.id.imageButton);
- auth=FirebaseAuth.getInstance();
- user=auth.getCurrentUser();
- if(auth.getCurrentUser()==null){
- Toast.makeText(this,"Logged out",Toast.LENGTH_LONG).show();
+ image = (ImageButton) findViewById(R.id.imageButton);
+ auth = FirebaseAuth.getInstance();
+ user = auth.getCurrentUser();
+ if (auth.getCurrentUser() == null) {
+ Toast.makeText(this, "Logged out", Toast.LENGTH_LONG).show();
}
- // users=FirebaseDatabase.getInstance().getReference().child("Users");
+ // users=FirebaseDatabase.getInstance().getReference().child("Users");
- title=(EditText)findViewById(R.id.editText3);
+ title = (EditText) findViewById(R.id.editText3);
- users=FirebaseDatabase.getInstance().getReference().child("Users").child(user.getUid());
- getSupportActionBar().setDisplayShowHomeEnabled(true);
- description=(EditText)findViewById(R.id.editText2) ;
- storage=FirebaseStorage.getInstance().getReference();
- data= FirebaseDatabase.getInstance().getReference().child("Blog");
- button=(Button)findViewById(R.id.button) ;
- progresss=new ProgressDialog(this);
+ users = FirebaseDatabase.getInstance().getReference().child("Users").child(user.getUid());
+ getSupportActionBar().setDisplayShowHomeEnabled(true);
+ description = (EditText) findViewById(R.id.editText2);
+ storage = FirebaseStorage.getInstance().getReference();
+ data = FirebaseDatabase.getInstance().getReference().child("Blog");
+ button = (Button) findViewById(R.id.button);
+ progresss = new ProgressDialog(this);
image.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- Intent gallery=new Intent(Intent.ACTION_GET_CONTENT);
+ Intent gallery = new Intent(Intent.ACTION_GET_CONTENT);
gallery.setType("image/*");
- startActivityForResult(gallery,GALLERY_REQUEST);
+ startActivityForResult(gallery, GALLERY_REQUEST);
}
});
button.setOnClickListener(new View.OnClickListener() {
@@ -91,40 +91,39 @@ public void onClick(View v) {
startPosting();
}
});
- listener=new FirebaseAuth.AuthStateListener() {
+ listener = new FirebaseAuth.AuthStateListener() {
@Override
public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
- if((firebaseAuth.getCurrentUser()==null))
- {
+ if ((firebaseAuth.getCurrentUser() == null)) {
- Intent loginintent= new Intent(PostActivity.this,LoginActivity.class);
+ Intent loginintent = new Intent(PostActivity.this, LoginActivity.class);
loginintent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(loginintent);
- }
-
+ }
- }
+ }
};
data.keepSynced(true);
users.keepSynced(true);
- auth.addAuthStateListener(listener);
+ auth.addAuthStateListener(listener);
}
- private void startPosting(){
+
+ private void startPosting() {
progresss.setMessage("Posting...");
- name=title.getText().toString();
- desc=description.getText().toString();
- if(!TextUtils.isEmpty(name)&&!TextUtils.isEmpty(desc)&&galleryuri!=null){
+ name = title.getText().toString();
+ desc = description.getText().toString();
+ if (!TextUtils.isEmpty(name) && !TextUtils.isEmpty(desc) && galleryuri != null) {
progresss.show();
- StorageReference sref=storage.child("Blog_image").child(galleryuri.getLastPathSegment());
+ StorageReference sref = storage.child("Blog_image").child(galleryuri.getLastPathSegment());
sref.putFile(galleryuri).addOnSuccessListener(new OnSuccessListener() {
@Override
public void onSuccess(final UploadTask.TaskSnapshot taskSnapshot) {
- final Uri downloadurl=taskSnapshot.getDownloadUrl();
+ final Uri downloadurl = taskSnapshot.getDownloadUrl();
- final DatabaseReference newPost=data.push();
+ final DatabaseReference newPost = data.push();
users.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
@@ -135,8 +134,8 @@ public void onDataChange(DataSnapshot dataSnapshot) {
newPost.child("name").setValue(dataSnapshot.child("name").getValue()).addOnCompleteListener(new OnCompleteListener() {
@Override
public void onComplete(@NonNull Task task) {
- Toast.makeText(getApplicationContext(),"Post Successful",Toast.LENGTH_LONG).show();
- startActivity(new Intent(PostActivity.this,MainActivity.class));
+ Toast.makeText(getApplicationContext(), "Post Successful", Toast.LENGTH_LONG).show();
+ startActivity(new Intent(PostActivity.this, MainActivity.class));
}
});
@@ -150,7 +149,7 @@ public void onCancelled(DatabaseError databaseError) {
});
- // newPost.child("Profile").setValue(setup.getDownloaduri());
+ // newPost.child("Profile").setValue(setup.getDownloaduri());
progresss.dismiss();
}
});
@@ -163,11 +162,12 @@ public void onCancelled(DatabaseError databaseError) {
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
- if(requestCode==GALLERY_REQUEST&&resultCode==RESULT_OK){
- galleryuri=data.getData();
- CropImage.activity(galleryuri)
- .setGuidelines(CropImageView.Guidelines.ON).setAspectRatio(16,9).setFixAspectRatio(true).setAutoZoomEnabled(false).setMaxCropResultSize(1280,720).setRequestedSize(1280,720)
- .start(this);}
+ if (requestCode == GALLERY_REQUEST && resultCode == RESULT_OK) {
+ galleryuri = data.getData();
+ CropImage.activity(galleryuri)
+ .setGuidelines(CropImageView.Guidelines.ON).setAspectRatio(16, 9).setFixAspectRatio(true).setAutoZoomEnabled(false).setMaxCropResultSize(1280, 720).setRequestedSize(1280, 720)
+ .start(this);
+ }
if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) {
CropImage.ActivityResult result = CropImage.getActivityResult(data);
@@ -182,43 +182,43 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
}
- /**
- * Checks the current state of the permissions needed.
- *
- * @return true if granted and false if not.
- */
- private boolean checkPermission() {
- int permissionState = ActivityCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE);
- return permissionState == PackageManager.PERMISSION_GRANTED;
- }
-
- /**
- * Requests the necessary permissions.
- */
- private void requestPermissions() {
- String[] permissions = new String[]{
- Manifest.permission.READ_EXTERNAL_STORAGE,
- Manifest.permission.WRITE_EXTERNAL_STORAGE
- };
- ActivityCompat.requestPermissions(this,
- permissions,
- PERMISSION_REQUEST_CODE);
- }
-
- @Override
- public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
- super.onRequestPermissionsResult(requestCode, permissions, grantResults);
- if (requestCode == PERMISSION_REQUEST_CODE) {
- if (grantResults.length > 0) {
- // True if read external storage permission was granted, false if not.
- boolean readPermission = grantResults[0] == PackageManager.PERMISSION_GRANTED;
- // True if write external storage permission was granted, false if not.
- boolean writePermission = grantResults[1] == PackageManager.PERMISSION_GRANTED;
- } else {
- //Permission denied
- }
- } else {
- super.onRequestPermissionsResult(requestCode, permissions, grantResults);
- }
- }
+ /**
+ * Checks the current state of the permissions needed.
+ *
+ * @return true if granted and false if not.
+ */
+ private boolean checkPermission() {
+ int permissionState = ActivityCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE);
+ return permissionState == PackageManager.PERMISSION_GRANTED;
+ }
+
+ /**
+ * Requests the necessary permissions.
+ */
+ private void requestPermissions() {
+ String[] permissions = new String[]{
+ Manifest.permission.READ_EXTERNAL_STORAGE,
+ Manifest.permission.WRITE_EXTERNAL_STORAGE
+ };
+ ActivityCompat.requestPermissions(this,
+ permissions,
+ PERMISSION_REQUEST_CODE);
+ }
+
+ @Override
+ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
+ super.onRequestPermissionsResult(requestCode, permissions, grantResults);
+ if (requestCode == PERMISSION_REQUEST_CODE) {
+ if (grantResults.length > 0) {
+ // True if read external storage permission was granted, false if not.
+ boolean readPermission = grantResults[0] == PackageManager.PERMISSION_GRANTED;
+ // True if write external storage permission was granted, false if not.
+ boolean writePermission = grantResults[1] == PackageManager.PERMISSION_GRANTED;
+ } else {
+ //Permission denied
+ }
+ } else {
+ super.onRequestPermissionsResult(requestCode, permissions, grantResults);
+ }
+ }
}
diff --git a/app/src/main/java/com/example/tushar/menu/widget/CustomTextView.java b/app/src/main/java/com/example/tushar/menu/widget/CustomTextView.java
new file mode 100644
index 0000000..236069b
--- /dev/null
+++ b/app/src/main/java/com/example/tushar/menu/widget/CustomTextView.java
@@ -0,0 +1,73 @@
+package com.example.tushar.menu.widget;
+
+import android.content.Context;
+import android.content.res.TypedArray;
+import android.graphics.Typeface;
+import android.support.v7.widget.AppCompatTextView;
+import android.util.AttributeSet;
+
+import com.example.tushar.menu.R;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Created by rohan on 21/10/17.
+ */
+
+public class CustomTextView extends AppCompatTextView {
+
+ private static final String TAG = "CustomTextView";
+ /*
+ * Caches typefaces based on their file path and name, so that they don't have to be created
+ * every time when they are referenced.
+ */
+ public static Map mTypefaces;
+
+ public CustomTextView(Context context) {
+ super(context);
+ setIncludeFontPadding(false);
+
+ }
+
+ public CustomTextView(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ setCustomFont(context, attrs);
+ setIncludeFontPadding(false);
+
+ }
+
+ public CustomTextView(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+ setCustomFont(context, attrs);
+ setIncludeFontPadding(false);
+
+ }
+
+
+
+ private void setCustomFont(Context ctx, AttributeSet attrs) {
+ if (mTypefaces == null)
+ mTypefaces = new HashMap<>();
+
+ TypedArray a = ctx.obtainStyledAttributes(attrs, R.styleable.CustomTextView);
+ String customFont;
+ if (a.hasValue(R.styleable.CustomTextView_customFont))
+ customFont = a.getString(R.styleable.CustomTextView_customFont);
+ else
+ customFont = "Roboto-Regular.ttf";
+ setCustomFont(ctx, customFont);
+ a.recycle();
+ }
+
+ public void setCustomFont(Context ctx, String path) {
+ Typeface typeface;
+ if (mTypefaces.containsKey(path)) {
+ typeface = mTypefaces.get(path);
+ } else {
+ typeface = Typeface.createFromAsset(ctx.getAssets(), path);
+ mTypefaces.put(path, typeface);
+ }
+ setTypeface(typeface);
+ }
+}
diff --git a/app/src/main/res/layout/bloglist.xml b/app/src/main/res/layout/bloglist.xml
index ccf6054..4889aec 100644
--- a/app/src/main/res/layout/bloglist.xml
+++ b/app/src/main/res/layout/bloglist.xml
@@ -4,13 +4,10 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_margin="10dp"
app:cardBackgroundColor="#40E0D0"
- app:cardCornerRadius="5dp">
-
-
-
-
+ app:cardElevation="16dp"
+ app:cardPreventCornerOverlap="true"
+ app:cardUseCompatPadding="true">
-
+ app:customFont="@string/font_roboto_medium" />
-
+ android:textSize="20dp"
+ app:customFont="@string/font_roboto_regular" />
-
-
-
-
+ android:padding="8dp">
-
+
+
+
diff --git a/app/src/main/res/values/attrs.xml b/app/src/main/res/values/attrs.xml
new file mode 100644
index 0000000..3f3cf26
--- /dev/null
+++ b/app/src/main/res/values/attrs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 3a029b5..f185e9e 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -5,4 +5,8 @@
Hello world!
Settings
+
+ fonts/Roboto-Light.ttf
+ fonts/Roboto-Medium.ttf
+ fonts/Roboto-Regular.ttf