mirror of
https://github.com/syncthing/syncthing-android.git
synced 2024-11-27 06:41:15 +00:00
DrawerFragment improvements.
This commit is contained in:
parent
507e841864
commit
7f9e773eaa
3 changed files with 72 additions and 79 deletions
|
@ -28,7 +28,7 @@ import static android.content.Intent.ACTION_VIEW;
|
||||||
* Displays information about the local device.
|
* Displays information about the local device.
|
||||||
*/
|
*/
|
||||||
public class DrawerFragment extends Fragment implements RestApi.OnReceiveSystemInfoListener,
|
public class DrawerFragment extends Fragment implements RestApi.OnReceiveSystemInfoListener,
|
||||||
RestApi.OnReceiveConnectionsListener {
|
RestApi.OnReceiveConnectionsListener, View.OnClickListener {
|
||||||
|
|
||||||
private TextView mDeviceId;
|
private TextView mDeviceId;
|
||||||
|
|
||||||
|
@ -48,48 +48,6 @@ public class DrawerFragment extends Fragment implements RestApi.OnReceiveSystemI
|
||||||
|
|
||||||
private MainActivity mActivity;
|
private MainActivity mActivity;
|
||||||
|
|
||||||
private View.OnClickListener mShareIdListener = new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
RestApi.shareDeviceId(getActivity(), mDeviceId.getText().toString());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
private View.OnClickListener mWebGuiClickListener = new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
startActivity(new Intent(mActivity, WebGuiActivity.class));
|
|
||||||
mActivity.closeDrawer();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
private View.OnClickListener mDonateButtonClickListener = new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
startActivity(new Intent(ACTION_VIEW, Uri.parse(
|
|
||||||
getString(R.string.donate_url))));
|
|
||||||
mActivity.closeDrawer();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
private View.OnClickListener mSettingsClickListener = new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
startActivity(new Intent(mActivity, SettingsActivity.class)
|
|
||||||
.setAction(SettingsActivity.ACTION_APP_SETTINGS_FRAGMENT));
|
|
||||||
mActivity.closeDrawer();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
private View.OnClickListener mExitClickListener = new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
mActivity.stopService(new Intent(mActivity, SyncthingService.class));
|
|
||||||
mActivity.finish();
|
|
||||||
mActivity.closeDrawer();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
public void onDrawerOpened() {
|
public void onDrawerOpened() {
|
||||||
mTimer = new Timer();
|
mTimer = new Timer();
|
||||||
mTimer.schedule(new TimerTask() {
|
mTimer.schedule(new TimerTask() {
|
||||||
|
@ -139,21 +97,21 @@ public class DrawerFragment extends Fragment implements RestApi.OnReceiveSystemI
|
||||||
mExitButton = (TextView) view.findViewById(R.id.drawerActionExit);
|
mExitButton = (TextView) view.findViewById(R.id.drawerActionExit);
|
||||||
|
|
||||||
view.findViewById(R.id.deviceIdContainer)
|
view.findViewById(R.id.deviceIdContainer)
|
||||||
.setOnClickListener(mShareIdListener);
|
.setOnClickListener(this);
|
||||||
view.findViewById(R.id.drawerActionWebGui)
|
view.findViewById(R.id.drawerActionWebGui)
|
||||||
.setOnClickListener(mWebGuiClickListener);
|
.setOnClickListener(this);
|
||||||
view.findViewById(R.id.drawerActionDonate)
|
view.findViewById(R.id.drawerActionDonate)
|
||||||
.setOnClickListener(mDonateButtonClickListener);
|
.setOnClickListener(this);
|
||||||
view.findViewById(R.id.drawerActionSettings)
|
view.findViewById(R.id.drawerActionSettings)
|
||||||
.setOnClickListener(mSettingsClickListener);
|
.setOnClickListener(this);
|
||||||
mExitButton.setOnClickListener(mExitClickListener);
|
mExitButton.setOnClickListener(this);
|
||||||
|
|
||||||
updateExitButtonVisibility();
|
updateExitButtonVisibility();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateExitButtonVisibility() {
|
private void updateExitButtonVisibility() {
|
||||||
boolean alwaysInBackground = SyncthingService.alwaysRunInBackground(getActivity());
|
boolean alwaysInBackground = SyncthingService.alwaysRunInBackground(getActivity());
|
||||||
mExitButton.setVisibility(alwaysInBackground ? View.VISIBLE : View.GONE);
|
mExitButton.setVisibility(alwaysInBackground ? View.GONE : View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -231,4 +189,32 @@ public class DrawerFragment extends Fragment implements RestApi.OnReceiveSystemI
|
||||||
mDownload.setText(RestApi.readableTransferRate(mActivity, c.inBits));
|
mDownload.setText(RestApi.readableTransferRate(mActivity, c.inBits));
|
||||||
mUpload.setText(RestApi.readableTransferRate(mActivity, c.outBits));
|
mUpload.setText(RestApi.readableTransferRate(mActivity, c.outBits));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
switch (v.getId()) {
|
||||||
|
case R.id.deviceIdContainer:
|
||||||
|
RestApi.shareDeviceId(getActivity(), mDeviceId.getText().toString());
|
||||||
|
return;
|
||||||
|
case R.id.drawerActionWebGui:
|
||||||
|
startActivity(new Intent(mActivity, WebGuiActivity.class));
|
||||||
|
mActivity.closeDrawer();
|
||||||
|
return;
|
||||||
|
case R.id.drawerActionDonate:
|
||||||
|
startActivity(new Intent(ACTION_VIEW, Uri.parse(
|
||||||
|
getString(R.string.donate_url))));
|
||||||
|
mActivity.closeDrawer();
|
||||||
|
return;
|
||||||
|
case R.id.drawerActionSettings:
|
||||||
|
startActivity(new Intent(mActivity, SettingsActivity.class)
|
||||||
|
.setAction(SettingsActivity.ACTION_APP_SETTINGS_FRAGMENT));
|
||||||
|
mActivity.closeDrawer();
|
||||||
|
return;
|
||||||
|
case R.id.drawerActionExit:
|
||||||
|
mActivity.stopService(new Intent(mActivity, SyncthingService.class));
|
||||||
|
mActivity.finish();
|
||||||
|
mActivity.closeDrawer();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@
|
||||||
style="@style/Widget.Syncthing.TextView.Label"
|
style="@style/Widget.Syncthing.TextView.Label"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="4dp"
|
android:layout_marginTop="8dp"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:minHeight="48dp"
|
android:minHeight="48dp"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
|
@ -65,34 +65,6 @@
|
||||||
android:visibility="invisible" />
|
android:visibility="invisible" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/drawerActionWebGui"
|
|
||||||
style="@style/Widget.Syncthing.TextView.Label"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="48dp"
|
|
||||||
android:drawableLeft="@drawable/ic_web_black_24dp"
|
|
||||||
android:drawableStart="@drawable/ic_web_black_24dp"
|
|
||||||
android:text="@string/web_gui_title" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/drawerActionDonate"
|
|
||||||
style="@style/Widget.Syncthing.TextView.Label"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="48dp"
|
|
||||||
android:drawableLeft="@drawable/ic_attach_money_black_24dp"
|
|
||||||
android:drawableStart="@drawable/ic_attach_money_black_24dp"
|
|
||||||
android:text="@string/donate" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/drawerActionExit"
|
|
||||||
style="@style/Widget.Syncthing.TextView.Label"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="48dp"
|
|
||||||
android:drawableLeft="@drawable/ic_close_black_24dp"
|
|
||||||
android:drawableStart="@drawable/ic_close_black_24dp"
|
|
||||||
android:text="@string/exit"
|
|
||||||
android:visibility="gone" />
|
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="1px"
|
android:layout_height="1px"
|
||||||
|
@ -219,6 +191,41 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textAppearance="@style/TextAppearance.AppCompat.Caption" />
|
android:textAppearance="@style/TextAppearance.AppCompat.Caption" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="1px"
|
||||||
|
android:layout_marginTop="4dp"
|
||||||
|
android:layout_marginBottom="4dp"
|
||||||
|
android:background="@drawable/list_divider" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/drawerActionWebGui"
|
||||||
|
style="@style/Widget.Syncthing.TextView.Label"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="48dp"
|
||||||
|
android:drawableLeft="@drawable/ic_web_black_24dp"
|
||||||
|
android:drawableStart="@drawable/ic_web_black_24dp"
|
||||||
|
android:text="@string/web_gui_title" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/drawerActionDonate"
|
||||||
|
style="@style/Widget.Syncthing.TextView.Label"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="48dp"
|
||||||
|
android:drawableLeft="@drawable/ic_attach_money_black_24dp"
|
||||||
|
android:drawableStart="@drawable/ic_attach_money_black_24dp"
|
||||||
|
android:text="@string/donate" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/drawerActionExit"
|
||||||
|
style="@style/Widget.Syncthing.TextView.Label"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="48dp"
|
||||||
|
android:drawableLeft="@drawable/ic_close_black_24dp"
|
||||||
|
android:drawableStart="@drawable/ic_close_black_24dp"
|
||||||
|
android:text="@string/exit"
|
||||||
|
android:visibility="gone" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
Loading…
Reference in a new issue