Skip to content

Commit 8751cf4

Browse files
My Account now shows the currently used file name, with option to add one, if not added
1 parent 12f89fb commit 8751cf4

File tree

3 files changed

+61
-1
lines changed

3 files changed

+61
-1
lines changed

app/src/main/java/com/aaxena/takenotes/UserInfo.java

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,15 @@
33
import android.app.ActivityManager;
44
import android.content.Context;
55
import android.content.Intent;
6+
import android.content.SharedPreferences;
7+
import android.graphics.Color;
68
import android.net.Uri;
79
import android.os.Bundle;
810
import android.os.Handler;
911
import android.os.Vibrator;
12+
import android.view.View;
13+
import android.view.Window;
14+
import android.view.WindowManager;
1015
import android.widget.Button;
1116
import android.widget.TextView;
1217
import android.widget.Toast;
@@ -20,6 +25,9 @@
2025
import com.google.firebase.auth.FirebaseUser;
2126
import com.mikhaellopez.circularimageview.CircularImageView;
2227

28+
import static com.aaxena.takenotes.MyName.SHARED_PREFS;
29+
import static com.aaxena.takenotes.MyName.TEXT;
30+
2331
public class UserInfo extends AppCompatActivity {
2432
CircularImageView photo;
2533
TextView username;
@@ -32,6 +40,31 @@ protected void onCreate(Bundle savedInstanceState) {
3240
super.onCreate(savedInstanceState);
3341
setContentView(R.layout.activity_user_info);
3442

43+
Window window = getWindow();
44+
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
45+
window.setStatusBarColor(Color.parseColor("#1389cd"));
46+
47+
Button change_name = findViewById(R.id.chng_name);
48+
TextView user_save_name = findViewById(R.id.saving_name);
49+
SharedPreferences sharedPreferences = getSharedPreferences(SHARED_PREFS, MODE_PRIVATE);
50+
String saving_as = sharedPreferences.getString(TEXT, "");
51+
if(saving_as.isEmpty()){
52+
user_save_name.setText(R.string.tap_to_save_name);
53+
change_name.setOnClickListener(view -> {
54+
Vibrator v2 = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
55+
v2.vibrate(20);
56+
Intent toName = new Intent(UserInfo.this,MyName.class);
57+
startActivity(toName);
58+
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
59+
finish();
60+
});
61+
}
62+
else {
63+
user_save_name.setText(saving_as);
64+
change_name.setVisibility(View.INVISIBLE);
65+
}
66+
67+
3568
Button abt_dev = findViewById(R.id.abt_dev);
3669
abt_dev.setOnClickListener(v -> {
3770
Vibrator dev_vibe = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);

app/src/main/res/layout/activity_user_info.xml

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,22 @@
3737
app:layout_constraintEnd_toEndOf="parent"
3838
app:layout_constraintStart_toStartOf="parent"
3939
app:layout_constraintTop_toBottomOf="@+id/username"
40-
app:layout_constraintVertical_bias="0.909" />
40+
app:layout_constraintVertical_bias="0.48000002" />
41+
42+
<TextView
43+
android:id="@+id/saving_name"
44+
android:layout_width="wrap_content"
45+
android:layout_height="wrap_content"
46+
android:fontFamily="@font/productsansitalic"
47+
android:text="@string/your_name"
48+
android:textAlignment="center"
49+
android:textColor="#004aad"
50+
android:textSize="16sp"
51+
app:layout_constraintBottom_toBottomOf="parent"
52+
app:layout_constraintEnd_toEndOf="parent"
53+
app:layout_constraintStart_toStartOf="parent"
54+
app:layout_constraintTop_toBottomOf="@+id/username"
55+
app:layout_constraintVertical_bias="0.39" />
4156

4257
<Button
4358
android:id="@+id/sign_out"
@@ -83,4 +98,15 @@
8398
app:layout_constraintStart_toEndOf="@+id/accphoto"
8499
app:layout_constraintTop_toTopOf="parent" />
85100

101+
<Button
102+
android:id="@+id/chng_name"
103+
android:layout_width="302dp"
104+
android:layout_height="33dp"
105+
android:background="@android:color/transparent"
106+
app:layout_constraintBottom_toBottomOf="parent"
107+
app:layout_constraintEnd_toEndOf="parent"
108+
app:layout_constraintStart_toStartOf="parent"
109+
app:layout_constraintTop_toTopOf="parent"
110+
app:layout_constraintVertical_bias="0.78" />
111+
86112
</androidx.constraintlayout.widget.ConstraintLayout>

app/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,5 @@
8383
<string name="more_info_title">When you enter your name...</string>
8484
<string name="oh_one_more_thing">Oh! One More Thing!</string>
8585
<string name="asking_storage_perm">Please provide the storage permissions otherwise where will the saved assignments go?</string>
86+
<string name="tap_to_save_name">Tap here to save your default file name</string>
8687
</resources>

0 commit comments

Comments
 (0)