Skip to content

Commit

Permalink
Added a disclaimer page
Browse files Browse the repository at this point in the history
  • Loading branch information
WillWcchan committed Jul 20, 2020
1 parent a57a3d7 commit a18e52b
Show file tree
Hide file tree
Showing 8 changed files with 126 additions and 2 deletions.
14 changes: 13 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,26 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.AppCompat.DayNight.NoActionBar">

<activity
android:name=".activities.DisclaimerActivity"
android:parentActivityName=".MainActivity">

<!-- Parent activity meta-data to support 4.0 and lower -->
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.willchan.simple_random_stock.MainActivity" />
</activity>

<activity
android:name=".splashscreens.SplashScreenActivity"
android:theme="@style/Theme.Design.Light.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<activity
android:name=".activities.AboutActivity"
android:parentActivityName=".MainActivity">
Expand All @@ -27,6 +38,7 @@
android:name="android.support.PARENT_ACTIVITY"
android:value="com.willchan.simple_random_stock.MainActivity" />
</activity>

<activity
android:name=".MainActivity"
android:theme="@style/AppTheme" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import com.google.android.material.tabs.TabLayout;
import com.willchan.simple_random_stock.activities.AboutActivity;
import com.willchan.simple_random_stock.activities.DisclaimerActivity;
import com.willchan.simple_random_stock.adapters.TabLayoutAdapter;
import com.willchan.simple_random_stock.fragments.IndexFragment;
import com.willchan.simple_random_stock.viewmodels.StockViewModel;
Expand Down Expand Up @@ -82,6 +83,10 @@ public boolean onOptionsItemSelected(MenuItem item) {
if (stockViewModel != null)
stockViewModel.deleteAllStocks();
return true;
} else if (item.getItemId() == R.id.disclaimer) {
Intent intent = new Intent(this, DisclaimerActivity.class);
startActivity(intent);
return true;
} else {
return super.onOptionsItemSelected(item);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.willchan.simple_random_stock.activities;

import android.os.Bundle;
import android.util.Log;

import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;

import com.willchan.simple_random_stock.R;

public class DisclaimerActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_disclaimer);

// Source: https://developer.android.com/training/appbar/up-action
Toolbar toolBar = findViewById(R.id.toolbar);
setSupportActionBar(toolBar);

// Get a support Actionbar corresponding to this toolbar
ActionBar ab = getSupportActionBar();

// Enable the Up Button
if (ab != null) {
try {
ab.setDisplayHomeAsUpEnabled(true);
} catch (NullPointerException e) {
Log.e(DisclaimerActivity.this.getLocalClassName(), "Unable to set Up Action");
}
}
}
}
10 changes: 10 additions & 0 deletions app/src/main/res/drawable/ic_warning.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?attr/colorControlNormal"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@android:color/white"
android:pathData="M1,21h22L12,2 1,21zM13,18h-2v-2h2v2zM13,14h-2v-4h2v4z" />
</vector>
1 change: 0 additions & 1 deletion app/src/main/res/layout/activity_about.xml
Original file line number Diff line number Diff line change
Expand Up @@ -134,5 +134,4 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/supportTexView" />


</androidx.constraintlayout.widget.ConstraintLayout>
52 changes: 52 additions & 0 deletions app/src/main/res/layout/activity_disclaimer.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activities.DisclaimerActivity">

<com.google.android.material.appbar.AppBarLayout
android:id="@+id/disclaimer_appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content">

<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize"
android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

</com.google.android.material.appbar.AppBarLayout>

<TextView
android:id="@+id/textView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/disclaimer_appbar"
android:layout_alignParentTop="true"
android:layout_marginLeft="20sp"
android:layout_marginTop="60sp"
android:layout_marginRight="20sp"
android:text="@string/disclaimer"
android:textAppearance="@style/TextAppearance.MaterialComponents.Headline3"
android:textStyle="bold" />

<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_below="@id/textView2"
android:layout_marginLeft="20sp"
android:layout_marginTop="20sp"
android:layout_marginRight="20sp"
android:layout_marginBottom="20sp"
android:text="@string/fullText_disclaimer"
android:textAppearance="@style/TextAppearance.MaterialComponents.Headline5" />

</RelativeLayout>
5 changes: 5 additions & 0 deletions app/src/main/res/menu/menu_file.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
android:id="@+id/about"
android:icon="@drawable/ic_info"
android:title="@string/about" />

<item
android:id="@+id/disclaimer"
android:icon="@drawable/ic_warning"
android:title="@string/disclaimer" />
</menu>
</item>

Expand Down
6 changes: 6 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,11 @@
<string name="robinhood_referral_link">
<a href="https://join.robinhood.com/williac1866"> https://join.robinhood.com/williac1866 </a>
</string>
<string name="disclaimer">Disclaimer</string>
<string name="fullText_disclaimer">Simple Random Stock is for fun and
educational purposes only. This application should not be viewed as
financial advice or stock recommendation to buy, sell, or hold any security or investment.
Investors should be cautious about any and all stock recommendations. Please consult
with a professional financial adviser before making any financial decisions.</string>

</resources>

0 comments on commit a18e52b

Please sign in to comment.