Skip to content

Commit

Permalink
Merge pull request #88 from ViolinConcerto/master
Browse files Browse the repository at this point in the history
changed demo
  • Loading branch information
joycode authored Jul 22, 2022
2 parents e1acd8a + e9146e8 commit 005b468
Show file tree
Hide file tree
Showing 51 changed files with 2,085 additions and 2,028 deletions.
4 changes: 3 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ apply plugin: 'com.android.application'
android {
compileSdkVersion 28
buildToolsVersion "29.0.2"
dataBinding {
enabled = true
}
defaultConfig {
applicationId "com.android.onyx.demo"
minSdkVersion 23
Expand Down Expand Up @@ -58,7 +61,6 @@ dependencies {
implementation "com.android.support:multidex:1.0.3"
api "com.android.support.constraint:constraint-layout:1.1.3"

implementation 'com.jakewharton:butterknife:7.0.1'

annotationProcessor "com.github.Raizlabs.DBFlow:dbflow-processor:4.2.4"
implementation "com.github.Raizlabs.DBFlow:dbflow-core:4.2.4"
Expand Down
51 changes: 24 additions & 27 deletions app/src/main/java/com/android/onyx/demo/AppOptimizeActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@
import android.widget.Button;
import android.widget.EditText;


import androidx.databinding.DataBindingUtil;


import com.onyx.android.demo.R;
import com.onyx.android.demo.databinding.ActivityAppOptimizeBinding;

/**
* Created by Administrator on 2018/3/26 17:35.
Expand All @@ -18,39 +23,31 @@ public class AppOptimizeActivity extends Activity {
private EditText etIsFull;
private EditText etPkgName;
private Button btnSendBroadcast;
private ActivityAppOptimizeBinding binding;

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_app_optimize);
initView();
initListener();
}
binding = DataBindingUtil.setContentView(this, R.layout.activity_app_optimize);


private void initView(){
etIsFull = (EditText) findViewById(R.id.et_isfull);
etPkgName = (EditText) findViewById(R.id.et_pkgname);
btnSendBroadcast = (Button) findViewById(R.id.btn_send_broadcast);
}

private void initListener(){
btnSendBroadcast.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
boolean isfull;
String isfullTxt = etIsFull.getText().toString();
if(isfullTxt.equals("false")){
isfull = false;
}else{
isfull = true;
}
String pkgnameTxt = etPkgName.getText().toString();
Intent intent = new Intent();
intent.setAction("com.onyx.app.optimize.setting");
intent.putExtra("optimize_fullScreen",isfull);
intent.putExtra("optimize_pkgName",pkgnameTxt);
sendBroadcast(intent);
}
});
public void onClick(View v) {
boolean isfull;
String isfullTxt = etIsFull.getText().toString();
if (isfullTxt.equals("false")) {
isfull = false;
} else {
isfull = true;
}
String pkgnameTxt = etPkgName.getText().toString();
Intent intent = new Intent();
intent.setAction("com.onyx.app.optimize.setting");
intent.putExtra("optimize_fullScreen", isfull);
intent.putExtra("optimize_pkgName", pkgnameTxt);
sendBroadcast(intent);
}

}

33 changes: 16 additions & 17 deletions app/src/main/java/com/android/onyx/demo/DictionaryActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
import android.widget.EditText;
import android.widget.TextView;

import androidx.databinding.DataBindingUtil;

import com.onyx.android.demo.R;
import com.onyx.android.demo.databinding.ActivityDictqueryBinding;
import com.onyx.android.sdk.data.DictionaryQuery;
import com.onyx.android.sdk.utils.DictionaryUtil;

Expand All @@ -22,15 +25,15 @@
* Created by seeksky on 2018/5/17.
*/

public class DictionaryActivity extends AppCompatActivity implements View.OnClickListener{
private EditText editText;
private Button buttonQuery;
private TextView textViewDisplay;
public class DictionaryActivity extends AppCompatActivity {

private ActivityDictqueryBinding binding;

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_dictquery);
binding = DataBindingUtil.setContentView(this, R.layout.activity_dictquery);
binding.setActivityDictQuery(this);
initView();
}

Expand All @@ -40,20 +43,16 @@ protected void onDestroy() {
}

private void initView() {
editText = (EditText) findViewById(R.id.edittext_keyword);
buttonQuery = (Button) findViewById(R.id.button_query);
textViewDisplay = (TextView) findViewById(R.id.textview_query_result);
textViewDisplay.setMovementMethod(ScrollingMovementMethod.getInstance());
buttonQuery.setOnClickListener(this);
binding.textviewQueryResult.setMovementMethod(ScrollingMovementMethod.getInstance());

}

@Override
public void onClick(View v) {
doQueryJob(editText.getText().toString());
doQueryJob(binding.edittextKeyword.getText().toString());
}

private void doQueryJob(final String keyword) {
textViewDisplay.setText("");
binding.textviewQueryResult.setText("");
hideSoftKeyboard();
new AsyncTask<Void, Void, DictionaryQuery>() {
@Override
Expand All @@ -71,9 +70,9 @@ protected void onPostExecute(DictionaryQuery dictionaryQuery) {
}
for (DictionaryQuery.Dictionary dictionary : list) {
System.out.println("dictionary = " + dictionary.getExplanation());
textViewDisplay.append(dictionary.getDictName() + "\n");
textViewDisplay.append(dictionary.getExplanation());
textViewDisplay.append("\n=============================\n");
binding.textviewQueryResult.append(dictionary.getDictName() + "\n");
binding.textviewQueryResult.append(dictionary.getExplanation());
binding.textviewQueryResult.append("\n=============================\n");
}
}
}
Expand All @@ -83,7 +82,7 @@ protected void onPostExecute(DictionaryQuery dictionaryQuery) {
private void hideSoftKeyboard() {
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm != null) {
imm.hideSoftInputFromWindow(buttonQuery.getWindowToken(),0);
imm.hideSoftInputFromWindow(binding.buttonQuery.getWindowToken(), 0);
}
}
}
46 changes: 13 additions & 33 deletions app/src/main/java/com/android/onyx/demo/EacDemoActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,57 +7,37 @@
import android.widget.CheckBox;
import android.widget.TextView;

import androidx.databinding.DataBindingUtil;

import com.onyx.android.demo.R;
import com.onyx.android.demo.databinding.ActivityEacDemoBinding;
import com.onyx.android.sdk.api.device.eac.SimpleEACManage;
import com.onyx.android.sdk.rx.RxUtils;

import java.util.concurrent.Callable;

import butterknife.Bind;
import butterknife.ButterKnife;

import io.reactivex.functions.Consumer;
import io.reactivex.schedulers.Schedulers;

/**
* App optimize entrance:long press app to select the optimization option or FloatingButton optimization option.
*/
public class EacDemoActivity extends AppCompatActivity implements View.OnClickListener {
@Bind(R.id.hook_epdc_status)
TextView hookEpdcStatus;
@Bind(R.id.eac_enable_status)
TextView eacEnableStatus;
@Bind(R.id.eac_support_status)
TextView eacSupportStatus;
@Bind(R.id.allow_eac)
Button allowEAC;
@Bind(R.id.disallow_eac)
Button disallowEAC;
@Bind(R.id.update_status)
Button updateStatus;
@Bind(R.id.cb_refresh_config_enable)
CheckBox cbRefreshConfigEnable;

public class EacDemoActivity extends AppCompatActivity {
private ActivityEacDemoBinding binding;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_eac_demo);
ButterKnife.bind(this);
initView();
binding = DataBindingUtil.setContentView(this, R.layout.activity_eac_demo);
initData();
}

private void initData() {
updateAllStatus();
}

private void initView() {
allowEAC.setOnClickListener(this);
disallowEAC.setOnClickListener(this);
updateStatus.setOnClickListener(this);
cbRefreshConfigEnable.setOnClickListener(this);
}

@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.allow_eac:
Expand All @@ -79,7 +59,7 @@ public void onClick(View v) {
*/
private void toggleRefreshConfig() {
RxUtils.runInIO(() -> {
boolean enable = cbRefreshConfigEnable.isChecked();
boolean enable = binding.cbRefreshConfigEnable.isChecked();
SimpleEACManage.getInstance().setEACRefreshConfigEnable(EacDemoActivity.this, enable);
updateRefreshConfigEnableStatus();
});
Expand Down Expand Up @@ -111,7 +91,7 @@ public Boolean call() throws Exception {
}, new Consumer<Boolean>() {
@Override
public void accept(Boolean enable) throws Exception {
eacEnableStatus.setText(getString(R.string.eac_enable_format, enable + ""));
binding.eacEnableStatus.setText(getString(R.string.eac_enable_format, enable + ""));
}
}, Schedulers.io());
}
Expand All @@ -125,7 +105,7 @@ public Boolean call() throws Exception {
}, new Consumer<Boolean>() {
@Override
public void accept(Boolean enable) throws Exception {
hookEpdcStatus.setText(getString(R.string.hook_epdc_format, enable + ""));
binding.hookEpdcStatus.setText(getString(R.string.hook_epdc_format, enable + ""));
}
}, Schedulers.io());
}
Expand All @@ -139,14 +119,14 @@ public Boolean call() throws Exception {
}, new Consumer<Boolean>() {
@Override
public void accept(Boolean support) throws Exception {
eacSupportStatus.setText(getString(R.string.eac_support_format, support + ""));
binding.eacSupportStatus.setText(getString(R.string.eac_support_format, support + ""));
}
}, Schedulers.io());
}

private void updateRefreshConfigEnableStatus() {
RxUtils.runWith(() -> SimpleEACManage.getInstance().isEACRefreshConfigEnable(getPackageName()),
enable -> cbRefreshConfigEnable.setChecked(enable),
enable -> binding.cbRefreshConfigEnable.setChecked(enable),
Schedulers.io());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,22 @@
import android.support.v7.app.AppCompatActivity;
import android.widget.TextView;

import androidx.databinding.DataBindingUtil;

import com.onyx.android.demo.R;
import com.onyx.android.demo.databinding.ActivityEnvironmentDemoBinding;
import com.onyx.android.sdk.api.device.DeviceEnvironment;

public class EnvironmentDemoActivity extends AppCompatActivity {
private ActivityEnvironmentDemoBinding binding;

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

((TextView)findViewById(R.id.text_view_flash_path)).setText(Environment.getExternalStorageDirectory().getAbsolutePath());
((TextView)findViewById(R.id.text_view_flash_state)).setText(Environment.getExternalStorageState());
binding = DataBindingUtil.setContentView(this, R.layout.activity_environment_demo);

((TextView)findViewById(R.id.text_view_sd_card_path)).setText(DeviceEnvironment.getRemovableSDCardDirectory().getAbsolutePath());
binding.textViewFlashPath.setText(Environment.getExternalStorageDirectory().getAbsolutePath());
binding.textViewFlashState.setText(Environment.getExternalStorageState());
binding.textViewSdCardPath.setText(DeviceEnvironment.getRemovableSDCardDirectory().getAbsolutePath());
}
}
Loading

0 comments on commit 005b468

Please sign in to comment.