2021.04.26
added ToggleButton
This commit is contained in:
@@ -63,9 +63,11 @@ android {
|
||||
lintOptions {
|
||||
checkReleaseBuilds false
|
||||
}
|
||||
|
||||
dexOptions {
|
||||
jumboMode true
|
||||
}
|
||||
|
||||
//多版本
|
||||
productFlavors {
|
||||
official {
|
||||
@@ -83,11 +85,12 @@ android {
|
||||
buildConfigField "String", "test", '"测试文本"'
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
beta.res.srcDirs = ['src/beta/res']
|
||||
}
|
||||
|
||||
//签名
|
||||
//签名
|
||||
signingConfigs {
|
||||
debug {
|
||||
storeFile file("src/jks/tt.jks")
|
||||
@@ -164,7 +167,7 @@ android {
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(dir: "libs", include: ["*.jar"])
|
||||
|
||||
implementation project(':viewlibrary')
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||
implementation 'androidx.core:core-ktx:1.1.0'
|
||||
implementation 'androidx.appcompat:appcompat:1.1.0'
|
||||
|
||||
@@ -1,6 +1,13 @@
|
||||
package com.tt.activity;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.ContentValues;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Environment;
|
||||
import android.provider.MediaStore;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
@@ -32,6 +39,12 @@ public class JMainActivity extends BaseActivity {
|
||||
protected void initData() {
|
||||
String ndks = NDKTools.getStringFromNDK();
|
||||
textView.setText(ndks);
|
||||
textView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
open();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 用来计算返回键的点击间隔时间
|
||||
@@ -62,4 +75,21 @@ public class JMainActivity extends BaseActivity {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
private void open() {
|
||||
Uri photoUri;
|
||||
ContentResolver cr = getContentResolver();
|
||||
String status = Environment.getExternalStorageState();
|
||||
if (status.equals(Environment.MEDIA_MOUNTED)) {
|
||||
photoUri = cr.insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, new ContentValues());
|
||||
} else {
|
||||
photoUri = cr.insert(MediaStore.Images.Media.INTERNAL_CONTENT_URI, new ContentValues());
|
||||
}
|
||||
if (null != photoUri) {
|
||||
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
||||
intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
|
||||
intent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri);
|
||||
startActivityForResult(intent, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,4 +16,30 @@
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<com.ttstd.viewlibrary.ToggleButton2
|
||||
android:id="@+id/disable_switch"
|
||||
android:layout_width="80dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_marginTop="60dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<com.ttstd.viewlibrary.ToggleButton
|
||||
android:id="@+id/toggleButton"
|
||||
android:layout_width="80dp"
|
||||
android:layout_height="40dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/disable_switch" />
|
||||
|
||||
<com.suke.widget.SwitchButton
|
||||
android:id="@+id/switch_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/toggleButton" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
Reference in New Issue
Block a user