feat: updated UI to material (with compat)

This commit is contained in:
əlemi 2023-05-04 03:09:19 +02:00
parent daf0fc1756
commit 235de2ebd7
Signed by: alemi
GPG key ID: A4895B84D311642C
5 changed files with 29 additions and 24 deletions

View file

@ -1,11 +1,11 @@
apply plugin: 'com.android.application' apply plugin: 'com.android.application'
android { android {
compileSdkVersion 29 compileSdkVersion 33
defaultConfig { defaultConfig {
applicationId "dev.alemi.sentences" applicationId "dev.alemi.sentences"
minSdkVersion 16 minSdkVersion 16
targetSdkVersion 29 targetSdkVersion 33
versionCode 1 versionCode 1
versionName "1.0" versionName "1.0"
} }
@ -25,5 +25,8 @@ android {
} }
dependencies { dependencies {
implementation 'androidx.appcompat:appcompat:1.2.0' implementation 'androidx.appcompat:appcompat:1.6.1'
implementation "androidx.appcompat:appcompat-resources:1.6.1"
implementation 'androidx.constraintlayout:constraintlayout:2.2.0-alpha09'
implementation 'com.google.android.material:material:1.8.0'
} }

View file

@ -4,9 +4,10 @@
<application <application
android:label="Harvard Sentences" android:label="Harvard Sentences"
android:theme="@style/AppTheme"> android:theme="@style/AppTheme"
>
<activity android:name=".sentences.MainActivity"> <activity android:name=".sentences.MainActivity" android:exported="true">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />

View file

@ -4,14 +4,15 @@ import dev.alemi.R;
import android.os.Bundle; import android.os.Bundle;
import android.view.View; import android.view.View;
import android.widget.Button;
import android.widget.TextView; import android.widget.TextView;
import android.app.Activity;
public class MainActivity extends Activity { import com.google.android.material.floatingactionbutton.FloatingActionButton;
import androidx.appcompat.app.AppCompatActivity;
public class MainActivity extends AppCompatActivity {
TextView currSentence; TextView currSentence;
Button buttonNext; FloatingActionButton buttonNext;
String[] sentences; String[] sentences;
@Override @Override
@ -21,12 +22,10 @@ public class MainActivity extends Activity {
this.currSentence = findViewById(R.id.currSentence); this.currSentence = findViewById(R.id.currSentence);
this.buttonNext = findViewById(R.id.button); this.buttonNext = findViewById(R.id.button);
this.buttonNext.setVisibility(View.VISIBLE);
this.buttonNext.setOnClickListener(new View.OnClickListener() { this.buttonNext.setOnClickListener(view -> {
@Override this.currSentence.setText(SentenceList.next());
public void onClick(View view) {
currSentence.setText(SentenceList.next());
}
}); });
this.currSentence.setText(SentenceList.next()); this.currSentence.setText(SentenceList.next());

View file

@ -1,8 +1,10 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.coordinatorlayout.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
tools:ignore="HardcodedText"
tools:context="dev.alemi.sentences.MainActivity" tools:context="dev.alemi.sentences.MainActivity"
> >
@ -18,16 +20,16 @@
tools:context=".MainActivity" tools:context=".MainActivity"
/> />
<Button <com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/button" android:id="@+id/button"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_below="@+id/currSentence" android:layout_gravity="bottom|end"
android:layout_centerHorizontal="true" android:layout_marginRight="20dp"
android:layout_marginTop="24dp" android:layout_marginBottom="20dp"
android:textSize="24dp" android:src="@android:drawable/ic_input_add"
android:text=">>>" app:tint="@android:color/white"
app:useCompatPadding="true"
/> />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</RelativeLayout>

View file

@ -1,6 +1,6 @@
<resources> <resources>
<!-- Base application theme. --> <!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> <style name="AppTheme" parent="Theme.AppCompat">
<!-- Customize your theme here. --> <!-- Customize your theme here. -->
</style> </style>
</resources> </resources>