Skip to content

Commit

Permalink
调整扫码设置配置地址的方式.
Browse files Browse the repository at this point in the history
  • Loading branch information
Cuke committed Jun 29, 2022
1 parent 1d7e262 commit 04408da
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ public void onTextReceived(String text) {

@Override
public void onApiReceived(String url) {
Hawk.put(HawkConfig.API_URL, url);
EventBus.getDefault().post(new RefreshEvent(RefreshEvent.TYPE_API_URL_CHANGE, url));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -406,9 +406,7 @@ protected void onPause() {

@Subscribe(threadMode = ThreadMode.MAIN)
public void refresh(RefreshEvent event) {
if (event.type == RefreshEvent.TYPE_API_URL_CHANGE) {
Toast.makeText(mContext, "配置地址设置为" + (String) event.obj + ",重启应用生效!", Toast.LENGTH_SHORT).show();
} else if (event.type == RefreshEvent.TYPE_PUSH_URL) {
if (event.type == RefreshEvent.TYPE_PUSH_URL) {
if (ApiConfig.get().getSource("push_agent") != null) {
Intent newIntent = new Intent(mContext, DetailActivity.class);
newIntent.putExtra("id", (String) event.obj);
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/java/com/github/tvbox/osc/ui/dialog/ApiDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import androidx.annotation.NonNull;

import com.github.tvbox.osc.R;
import com.github.tvbox.osc.event.RefreshEvent;
import com.github.tvbox.osc.server.ControlManager;
import com.github.tvbox.osc.ui.adapter.ApiHistoryDialogAdapter;
import com.github.tvbox.osc.ui.tv.QRCodeGen;
Expand All @@ -20,6 +21,8 @@
import com.hjq.permissions.XXPermissions;
import com.orhanobut.hawk.Hawk;

import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
Expand All @@ -38,6 +41,13 @@ public class ApiDialog extends BaseDialog {
private TextView tvAddress;
private EditText inputApi;

@Subscribe(threadMode = ThreadMode.MAIN)
public void refresh(RefreshEvent event) {
if (event.type == RefreshEvent.TYPE_API_URL_CHANGE) {
inputApi.setText((String) event.obj);
}
}

public ApiDialog(@NonNull @NotNull Context context) {
super(context);
setContentView(R.layout.dialog_api);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.github.tvbox.osc.util.XWalkUtils;
import com.orhanobut.hawk.Hawk;

import org.greenrobot.eventbus.EventBus;
import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
Expand Down Expand Up @@ -173,6 +174,7 @@ public boolean areContentsTheSame(@NonNull @NotNull SourceBean oldItem, @NonNull
public void onClick(View v) {
FastClickCheckUtil.check(v);
ApiDialog dialog = new ApiDialog(mActivity);
EventBus.getDefault().register(dialog);
dialog.setOnListener(new ApiDialog.OnListener() {
@Override
public void onchange(String api) {
Expand All @@ -184,6 +186,7 @@ public void onchange(String api) {
@Override
public void onDismiss(DialogInterface dialog) {
((BaseActivity) mActivity).hideSysBar();
EventBus.getDefault().unregister(dialog);
}
});
dialog.show();
Expand Down
42 changes: 42 additions & 0 deletions app/src/main/res/layout/fragment_model.xml
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,48 @@
android:textSize="@dimen/ts_30" />
</LinearLayout>

<LinearLayout
android:id="@+id/llDns"
android:layout_width="match_parent"
android:layout_height="@dimen/vs_50"
android:layout_marginBottom="@dimen/vs_10"
android:background="@drawable/shape_setting_model_focus"
android:focusable="true"

android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingLeft="@dimen/vs_20"
android:paddingRight="@dimen/vs_20">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="安全DNS"
android:textColor="@android:color/white"
android:textSize="@dimen/ts_24" />

<Space
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />

<TextView
android:id="@+id/tvDos"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@android:color/white"
android:textSize="@dimen/ts_24" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/vs_10"
android:layout_marginLeft="@dimen/vs_10"
android:text=">"
android:textColor="@android:color/white"
android:textSize="@dimen/ts_30" />
</LinearLayout>

<LinearLayout
android:id="@+id/llAbout"
android:layout_width="match_parent"
Expand Down

0 comments on commit 04408da

Please sign in to comment.