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

Commit

Permalink
Last update for exam
Browse files Browse the repository at this point in the history
  • Loading branch information
MAHRahat committed May 10, 2021
1 parent ec1224a commit 32af6ed
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 122 deletions.
9 changes: 8 additions & 1 deletion app/src/main/java/com/premiumtechs/chirkut/ChatPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,17 @@ protected void onCreate(Bundle savedInstanceState) {
btnSend.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//todo send message
Message message = new Message();
message.setMessages(etMessage.getText().toString().trim());
message.setSenderId("0");
message.setRecieverId(profileId);
message.setSendTime(String.valueOf(System.currentTimeMillis()));
message.setRecieveTime(null);
databaseHelper.insertMessage(message);
Bundle bundle = new Bundle();
bundle.putSerializable("profile", profile);
Intent switchActivityIntent = new Intent(ChatPage.this, ChatPage.class);
switchActivityIntent.putExtras(bundle);
startActivity(switchActivityIntent);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class DatabaseHelper extends SQLiteOpenHelper {
public static final String MESSAGE_COLUMN_DOCS = "docs";
public static final String MESSAGE_COLUMN_SENDERID = "senderId"; //FOREIGN KEY PROFILEID
public static final String MESSAGE_COLUMN_RECIEVERID = "recieverId";
public static final String MESSAGE_COLUMN_STATUS = "status";
public static final String MESSAGE_CREATE_TABLE = "create table IF NOT EXISTS "
+ MESSAGE_TABLE_NAME
+ "(" + MESSAGE_COLUMN_ID + " integer primary key autoincrement, "
Expand All @@ -45,6 +46,7 @@ public class DatabaseHelper extends SQLiteOpenHelper {
+ MESSAGE_COLUMN_MEDIA + " text,"
+ MESSAGE_COLUMN_LINKS + " text,"
+ MESSAGE_COLUMN_DOCS + " text,"
+ MESSAGE_COLUMN_STATUS + " text,"
+ " FOREIGN KEY (" + MESSAGE_COLUMN_SENDERID + ") REFERENCES " + PROFILE_TABLE_NAME + " (" + PROFILE_COLUMN_ID + "),"
+ " FOREIGN KEY (" + MESSAGE_COLUMN_RECIEVERID + ") REFERENCES " + PROFILE_TABLE_NAME + " (" + PROFILE_COLUMN_ID + "))";

Expand Down
96 changes: 12 additions & 84 deletions app/src/main/java/com/premiumtechs/chirkut/Splash.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,80 +2,32 @@

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;

import androidx.appcompat.app.AppCompatActivity;

public class Splash extends AppCompatActivity implements Runnable {
final int DEBUG = 0;
final int DEBUG = 1;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

long numOfProfilesInDB = new DatabaseHelper(this.getApplicationContext()).getNumOfProfilesInDB();
if (DEBUG == 0) {
if (numOfProfilesInDB == 0) {
startActivity(new Intent(Splash.this, CreateProfile.class));
} else {
startActivity(new Intent(Splash.this, Home.class));
}
this.finish();
}

setContentView(R.layout.activity_splash);
try {
Log.d("MAC ADDRESS", "MAC ADDRESS");
Log.d("MAC ADDRESS", ChirkutMACFinder.getMacAddress());
Log.d("MAC ADDRESS", "MAC ADDRESS");
} catch (Exception e) {
e.printStackTrace();
}
/*
DatabaseHelper databaseHelper = new DatabaseHelper(this);
databaseHelper.getReadableDatabase();
for (int i = 0; i < 10; i++) {
databaseHelper.deleteProfile(new Profile("" + i, "name" + i, "bio" + i, "phone" + i));
databaseHelper.insertProfile(new Profile("" + i, "name" + i, "bio" + i, "phone" + i));
databaseHelper.insertMessage(new Message("" + i, "2", "3", "4", "5", "6"));
//if (DEBUG == 0 && numOfProfilesInDB == 0) {
if (numOfProfilesInDB == 0) {
startActivity(new Intent(Splash.this, CreateProfile.class));
}
*/
Button btnAbt = findViewById(R.id.btnAbt);
btnAbt.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(Splash.this, About.class));
}
});
Button btnChat = findViewById(R.id.btnCht);
btnChat.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(Splash.this, ChatPage.class));
}
});
Button btnHome = findViewById(R.id.btnHome);
btnHome.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(Splash.this, Home.class));
}
});
Button btnEdt = findViewById(R.id.btnEdt);
btnEdt.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(Splash.this, Settings.class));
}
});
if (DEBUG != 0 && numOfProfilesInDB == 0) {
if (DEBUG != 0) {
DummyDatabaseHelper dummyDatabaseHelper = new DummyDatabaseHelper();
dummyDatabaseHelper.insertDummyProfile();
}
if (numOfProfilesInDB != 0) {
startActivity(new Intent(Splash.this, Home.class));
}
setContentView(R.layout.activity_splash);
this.finish();
}


@Override
public void run() {
}
Expand All @@ -84,7 +36,7 @@ public class DummyDatabaseHelper {
public void insertDummyProfile() {
DatabaseHelper databaseHelper = new DatabaseHelper(getApplicationContext());
String[] profileids = new String[]{"0", "5", "8", "27", "39", "2003", "2005", "2008", "2027", "2039", "202003"};
databaseHelper.insertProfile(new Profile(profileids[0], "Me", "000", "Me"));
//databaseHelper.insertProfile(new Profile(profileids[0], "Me", "000", "Me"));
databaseHelper.insertProfile(new Profile(profileids[1], "Mimma", "016", "Mimma"));
databaseHelper.insertProfile(new Profile(profileids[2], "Sakib", "017", "Sakib"));
databaseHelper.insertProfile(new Profile(profileids[3], "Naima", "017", "Naima"));
Expand Down Expand Up @@ -121,27 +73,3 @@ public void insertDummyProfile() {
}
}
}


/*
for (int i = 0; i < 20; i++) {
Profile profile = new Profile(
String.valueOf(i),
String.valueOf(i),
String.valueOf(i),
String.valueOf(i)
);
databaseHelper.insertProfile(profile);
for (int j = 0; j < 30; j++) {
Message message = new Message(
i + " " + j,
String.valueOf(i),
String.valueOf(i),
i + " " + j + " From the summit of yonder pyramids forty centuries look down upon you. \n He who has one thousand friends has nobody to spare, he who has one enemy meets him everywhere ",
String.valueOf(System.currentTimeMillis()),
i + " " + j
);
databaseHelper.insertMessage(message);
}
}
*/
74 changes: 37 additions & 37 deletions app/src/main/res/layout/activity_splash.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,41 +18,41 @@
android:textAllCaps="false"
android:textColor="@color/teal_700"
android:textSize="50sp" />

<Button
android:id="@+id/btnHome"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="HOME" />

<Button
android:id="@+id/btnCht"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="CHAT" />

<Button
android:id="@+id/btnCreate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="CREATE" />

<Button
android:id="@+id/btnEdt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="EDIT" />

<Button
android:id="@+id/btnSetting"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="SETTINGS" />

<Button
android:id="@+id/btnAbt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="ABOUT" />

<!--
<Button
android:id="@+id/btnHome"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="HOME" />
<Button
android:id="@+id/btnCht"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="CHAT" />
<Button
android:id="@+id/btnCreate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="CREATE" />
<Button
android:id="@+id/btnEdt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="EDIT" />
<Button
android:id="@+id/btnSetting"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="SETTINGS" />
<Button
android:id="@+id/btnAbt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="ABOUT" />
-->
</LinearLayout>

0 comments on commit 32af6ed

Please sign in to comment.