Note List UI Tweaks

This commit is contained in:
Sagi Dayan 2016-07-06 18:23:16 +03:00
parent 219368175f
commit f2b53bc1eb
11 changed files with 135 additions and 151 deletions

View file

@ -22,7 +22,8 @@
<activity
android:name=".SplashActivity"
android:theme="@style/AppTheme.NoActionBar"
android:noHistory="true">
android:noHistory="true"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
@ -31,13 +32,14 @@
</activity>
<activity android:name=".LoginActivity"
android:noHistory="true"/>
<activity android:name=".PersonalSpaceActivity" />
<activity
android:name=".MainActivity"
android:label="@string/title_activity_main"
android:theme="@style/AppTheme.NoActionBar"></activity>
android:theme="@style/AppTheme.NoActionBar"
android:screenOrientation="portrait" ></activity>
<activity android:name=".RegisterActivity"
android:noHistory="true"></activity>
android:noHistory="true"
android:screenOrientation="portrait" ></activity>
</application>
</manifest>

View file

@ -1,6 +1,7 @@
package com.android_app.matan.ara.sagi.thesocialnotework;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
@ -57,7 +58,8 @@ public class ListAdapter extends BaseAdapter {
v = inflater.inflate(R.layout.note_view_mini , parent , false);
}
TextView title = (TextView) v.findViewById(R.id.nvm_title_textview);
TextView datetime = (TextView) v.findViewById(R.id.nvm_time_textview);
TextView time = (TextView) v.findViewById(R.id.nvm_time_textview);
TextView date = (TextView) v.findViewById(R.id.nvm_date_textview);
TextView location = (TextView) v.findViewById(R.id.nvm_location_textview);
TextView likes = (TextView) v.findViewById(R.id.nvm_likes_textview);
TextView permission = (TextView) v.findViewById(R.id.nvm_permission_textview);
@ -66,10 +68,12 @@ public class ListAdapter extends BaseAdapter {
// thumbNail.setImageUrl(url, VolleyUtilSingleTone.getInstance(mContext).getImageLoader());
Note curNote = mNotes.get(position);
title.setText(curNote.getTitle());
datetime.setText(Html.fromHtml(curNote.getTimestamp()));
time.setText(curNote.getTime());
date.setText(curNote.getDate());
location.setText(curNote.getAddress());
likes.setText(""+curNote.getLikes());
permission.setText(curNote.isPublic() ? "Public":"Private");
if(likes !=null )likes.setText(""+curNote.getLikes());
// permission.setText(curNote.isPublic() ? "Public":"Private");
permission.setBackground(curNote.isPublic() ? v.getResources().getDrawable(R.drawable.public_icon): v.getResources().getDrawable(R.drawable.private_icon));
// Animation animation = AnimationUtils.loadAnimation(mContext, (position > lastPosition) ? R.anim.up_from_bottom : R.anim.down_from_top);
// v.startAnimation(animation);

View file

@ -32,26 +32,14 @@ public class MainActivity extends AppCompatActivity
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Snackbar.make(view, "This should Open the new Note thingy", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
}
});
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.setDrawerListener(toggle);
toggle.syncState();
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
//get Bundle data (Userid)
Bundle b = getIntent().getExtras();
userId = b.getString("user_id");
@ -122,7 +110,8 @@ public class MainActivity extends AppCompatActivity
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
drawer.closeDrawer(GravityCompat.START);
return true;
}public GPSUtils getGPSUtils() {
}
public GPSUtils getGPSUtils() {
return this.gpsUtils;
}

View file

@ -3,7 +3,10 @@ package com.android_app.matan.ara.sagi.thesocialnotework;
import android.os.Parcel;
import android.os.Parcelable;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
/**
* Created by JERLocal on 7/1/2016.
@ -174,28 +177,16 @@ public class Note implements Parcelable{
dest.writeByte((byte) (isPublic ? 1 : 0));
}
public String getTime() {
Date d = new Date(timestamp);
DateFormat format = new SimpleDateFormat("HH:mm");
return format.format(d);
}
// public void save(SQLiteOpenHelper dbHelper, Context context){
// SQLiteDatabase db = dbHelper.getWritableDatabase();
// ContentValues values = new ContentValues();
//
// values.put(appDB.LocationsEntry.ADDRESS, this.address);
//
// String where = appDB.LocationsEntry._ID + " =?";
// String[] whereArgs = {Integer.toString(this.id)};
//
// db.update(appDB.LocationsEntry.TABLE_NAME, values, where, whereArgs);
//
// db.close();
//
// Toast.makeText(context, "Address saved!", Toast.LENGTH_LONG).show();
// }
//
// public static Cursor getAll(DBHelper dbHelper) {
// SQLiteDatabase db = dbHelper.getReadableDatabase();
// String[] selectionArgs = {};
//
// return db.rawQuery("SELECT * FROM "+appDB.LocationsEntry.TABLE_NAME, selectionArgs);
// }
public String getDate() {
Date d = new Date();
DateFormat format = new SimpleDateFormat("dd MMM yyy");
return format.format(d);
}
}

View file

@ -6,6 +6,8 @@ import android.content.Context;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.Fragment;
import android.support.v4.content.ContextCompat;
@ -41,10 +43,8 @@ import java.util.List;
public class PersonalFragment extends Fragment {
protected ListView noteList;
protected Button addBtn;
private final int FINE_PERM = 0;
private final String BASE_URL = "http://thesocialnotework-api.appspot.com/api";
private boolean locationPermission;
private GPSUtils gpsUtils;
private List<Note> listOfNotes;
private ListAdapter noteListAdapter;
@ -64,29 +64,25 @@ public class PersonalFragment extends Fragment {
Bundle bundle = getArguments();
this.userId = bundle.getString("user_id");
Log.d(TAG, "onCreateView: userID: " + userId);
this.locationPermission = true;
//check for permission
ActivityCompat.requestPermissions(getActivity(), new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, FINE_PERM);
this.noteList = (ListView) view.findViewById(R.id.ps_list_listview);
addBtn = (Button) view.findViewById(R.id.ps_new_note_button);
gpsUtils = ((MainActivity)getActivity()).getGPSUtils();
gpsUtils.getLocation();
listOfNotes = new ArrayList<>();
//TODO - remove -add demo notes to view
// addDemoNotes(listOfNotes);
noteListAdapter = new ListAdapter(getContext(), listOfNotes);
noteList.setAdapter(noteListAdapter);
// new HeavyWorker(this).execute();
MainActivity.showLoadingDialog(getActivity(), "Fetching..", "getting your notes");
getAllNotes();
//https://thesocialnotework-api.appspot.com/api/note/all?uid=<USER_ID>
addBtn.setOnClickListener(addNewNoteDialog);
// The New "Add Button"
FloatingActionButton fab = (FloatingActionButton)view.findViewById(R.id.fab);
fab.setOnClickListener(addNewNoteDialog);
return view;
}
@ -109,10 +105,6 @@ public class PersonalFragment extends Fragment {
VolleyUtilSingleton.getInstance(getActivity()).get(BASE_URL + "/note/all?uid="+userId, getNotesSuccessListener, genericErrorListener);
}
public void setLocationPermission(boolean locationPermission) {
this.locationPermission = locationPermission;
}
private View.OnClickListener addNewNoteDialog = new View.OnClickListener() {
public void onClick(View v) {
@ -248,6 +240,7 @@ public class PersonalFragment extends Fragment {
@Override
public void onResponse(JSONObject response) {
Log.d(TAG,"getNotesSuccessListener: "+response.toString());
MainActivity.dismissLoadingDialog();
try {
//need to get all notes and add to listOfNotes
JSONArray noteObjectsArray = response.getJSONArray("notes");
@ -285,6 +278,7 @@ public class PersonalFragment extends Fragment {
@Override
public void onErrorResponse(VolleyError error) {
Log.d(TAG,"getNotesErrorListener: "+error.getMessage());
MainActivity.dismissLoadingDialog();
}
};
@ -293,61 +287,12 @@ public class PersonalFragment extends Fragment {
@Override
public void onErrorResponse(VolleyError error) {
Log.d(TAG,"genericErrorListener");
MainActivity.dismissLoadingDialog();
error.printStackTrace();
}
};
public void requestPermissions(){
// Here, thisActivity is the current activity
if (ContextCompat.checkSelfPermission(getActivity(),
Manifest.permission.ACCESS_FINE_LOCATION)
!= PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(getActivity(),
new String[]{Manifest.permission.ACCESS_FINE_LOCATION},
FINE_PERM);
// MY_PERMISSIONS_REQUEST_READ_CONTACTS is an
// app-defined int constant. The callback method gets the
// result of the request.
}
if (ContextCompat.checkSelfPermission(getActivity(),
Manifest.permission.ACCESS_FINE_LOCATION)
!= PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(getActivity(),
new String[]{Manifest.permission.ACCESS_FINE_LOCATION},
1);
// MY_PERMISSIONS_REQUEST_READ_CONTACTS is an
// app-defined int constant. The callback method gets the
// result of the request.
}
if (ContextCompat.checkSelfPermission(getActivity(),
Manifest.permission.ACCESS_COARSE_LOCATION)
!= PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(getActivity(),
new String[]{Manifest.permission.ACCESS_COARSE_LOCATION},
FINE_PERM);
// MY_PERMISSIONS_REQUEST_READ_CONTACTS is an
// app-defined int constant. The callback method gets the
// result of the request.
}
}
private ArrayList<String> jsonArrayToStringArray(JSONArray jArray){
ArrayList<String> stringArray = new ArrayList<String>();

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

View file

@ -27,12 +27,6 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="40dp"></FrameLayout>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/fab_margin"
android:src="@android:drawable/ic_menu_edit" />
</android.support.design.widget.CoordinatorLayout>

View file

@ -29,19 +29,6 @@
android:text="Filters and Shit"
android:layout_weight="0.8"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/temp_btn" />
<Button
android:id="@+id/ps_new_note_button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="+"
android:onClick=""
android:layout_weight="0.2"/>
</LinearLayout>
<ListView
@ -50,5 +37,12 @@
android:layout_height="0dp"
android:layout_weight="0.8" />
</LinearLayout>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|right"
android:layout_margin="@dimen/fab_margin"
android:src="@android:drawable/ic_menu_edit" />
</FrameLayout>

View file

@ -1,15 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal" android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="wrap_content">
<TextView
android:layout_width="0dp"
android:layout_width="70dp"
android:layout_height="70dp"
android:id="@+id/nvm_permission_textview"
android:background="@android:drawable/ic_lock_lock"
android:layout_weight="0.2"
/>
android:background="@drawable/private_icon"
android:gravity="center_vertical|center_horizontal" />
<LinearLayout
android:orientation="vertical"
@ -22,21 +21,72 @@
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Note Title"
android:id="@+id/nvm_title_textview" />
android:id="@+id/nvm_title_textview"
android:textStyle="bold"
android:textSize="18dp" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="Date and time"
android:id="@+id/nvm_time_textview" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="location"
android:id="@+id/nvm_location_textview" />
<ImageView
android:layout_width="13dp"
android:layout_height="match_parent"
android:id="@+id/imageView4"
android:src="@drawable/date_icon" />
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="Date and time"
android:id="@+id/nvm_date_textview"
android:textSize="9dp"
android:gravity="fill_horizontal|fill_vertical"
android:padding="5dp" />
<ImageView
android:layout_width="13dp"
android:layout_height="28dp"
android:id="@+id/imageView3"
android:scaleType="fitCenter"
android:src="@drawable/time_icon" />
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="Date and time"
android:id="@+id/nvm_time_textview"
android:textSize="9dp"
android:gravity="fill_horizontal|center_vertical"
android:padding="5dp" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="13dp"
android:layout_height="28dp"
android:id="@+id/imageView5"
android:src="@drawable/location_icon" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="location"
android:id="@+id/nvm_location_textview"
android:textSize="9dp"
android:gravity="fill_horizontal|fill_vertical"
android:padding="5dp" />
</LinearLayout>
</LinearLayout>
<LinearLayout
@ -57,11 +107,26 @@
android:text="Tags #2"
android:id="@+id/nvm_tags2_textview" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Likes"
android:id="@+id/nvm_likes_textview" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="1">
<ImageView
android:layout_width="40dp"
android:layout_height="match_parent"
android:id="@+id/imageView2"
android:src="@drawable/like_icon" />
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="Likes"
android:id="@+id/nvm_likes_textview"
android:gravity="center_vertical|center_horizontal" />
</LinearLayout>
</LinearLayout>
</LinearLayout>