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'
android {
compileSdkVersion 29
compileSdkVersion 33
defaultConfig {
applicationId "dev.alemi.sentences"
minSdkVersion 16
targetSdkVersion 29
targetSdkVersion 33
versionCode 1
versionName "1.0"
}
@ -25,5 +25,8 @@ android {
}
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
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>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />

View file

@ -4,14 +4,15 @@ import dev.alemi.R;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
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;
Button buttonNext;
FloatingActionButton buttonNext;
String[] sentences;
@Override
@ -21,12 +22,10 @@ public class MainActivity extends Activity {
this.currSentence = findViewById(R.id.currSentence);
this.buttonNext = findViewById(R.id.button);
this.buttonNext.setVisibility(View.VISIBLE);
this.buttonNext.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
currSentence.setText(SentenceList.next());
}
this.buttonNext.setOnClickListener(view -> {
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:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:ignore="HardcodedText"
tools:context="dev.alemi.sentences.MainActivity"
>
@ -18,16 +20,16 @@
tools:context=".MainActivity"
/>
<Button
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/currSentence"
android:layout_centerHorizontal="true"
android:layout_marginTop="24dp"
android:textSize="24dp"
android:text=">>>"
android:layout_gravity="bottom|end"
android:layout_marginRight="20dp"
android:layout_marginBottom="20dp"
android:src="@android:drawable/ic_input_add"
app:tint="@android:color/white"
app:useCompatPadding="true"
/>
</RelativeLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View file

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