1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-27 20:36:51 +01:00

Fossil Hybrid HR: Move preview&save buttons to action bar

This commit is contained in:
Arjan Schrijver 2021-07-11 14:37:37 +02:00 committed by Gitea
parent 5ccfccaf40
commit e4be137286
5 changed files with 60 additions and 18 deletions

View File

@ -35,6 +35,8 @@ import android.os.Handler;
import android.provider.MediaStore;
import android.text.InputType;
import android.util.DisplayMetrics;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
@ -44,6 +46,9 @@ import android.widget.RadioGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.annotation.NonNull;
import org.jetbrains.annotations.NotNull;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
@ -107,8 +112,6 @@ public class HybridHRWatchfaceDesignerActivity extends AbstractGBActivity implem
findViewById(R.id.button_set_background).setOnClickListener(this);
findViewById(R.id.button_add_widget).setOnClickListener(this);
findViewById(R.id.button_watchface_settings).setOnClickListener(this);
findViewById(R.id.button_preview_watchface).setOnClickListener(this);
findViewById(R.id.button_save_watchface).setOnClickListener(this);
}
@Override
@ -130,6 +133,26 @@ public class HybridHRWatchfaceDesignerActivity extends AbstractGBActivity implem
}
}
// Add action bar buttons
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_hybridhr_watchface_designer_actionbar, menu);
return super.onCreateOptionsMenu(menu);
}
// Handle action bar button presses
@Override
public boolean onOptionsItemSelected(@NonNull @NotNull MenuItem item) {
int id = item.getItemId();
if (id == R.id.button_save_watchface) {
sendToWatch(false);
finish();
} else if (id == R.id.button_preview_watchface) {
sendToWatch(true);
}
return super.onOptionsItemSelected(item);
}
@Override
public void onClick(View v) {
if (v.getId() == R.id.button_edit_name) {
@ -158,10 +181,6 @@ public class HybridHRWatchfaceDesignerActivity extends AbstractGBActivity implem
startActivityForResult(intent, 42);
} else if (v.getId() == R.id.button_add_widget) {
showWidgetEditPopup(-1);
} else if (v.getId() == R.id.button_preview_watchface) {
sendToWatch(true);
} else if (v.getId() == R.id.button_save_watchface) {
sendToWatch(false);
}
}

View File

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M9,16.2L4.8,12l-1.4,1.4L9,19 21,7l-1.4,-1.4L9,16.2z"/>
</vector>

View File

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M20,12c0,-2.54 -1.19,-4.81 -3.04,-6.27L16,0H8l-0.95,5.73C5.19,7.19 4,9.45 4,12s1.19,4.81 3.05,6.27L8,24h8l0.96,-5.73C18.81,16.81 20,14.54 20,12zM6,12c0,-3.31 2.69,-6 6,-6s6,2.69 6,6 -2.69,6 -6,6 -6,-2.69 -6,-6z"/>
</vector>

View File

@ -63,17 +63,5 @@
android:enabled="false"
android:text="Watchface settings" />
<Button
android:id="@+id/button_preview_watchface"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Preview on watch" />
<Button
android:id="@+id/button_save_watchface"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Save and send to watch" />
</LinearLayout>
</ScrollView>

View File

@ -0,0 +1,15 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/button_preview_watchface"
android:title="Preview on watch"
app:showAsAction="always"
android:icon="@drawable/ic_watch_bw"
/>
<item
android:id="@+id/button_save_watchface"
android:title="Save and apply"
app:showAsAction="always"
android:icon="@drawable/ic_done"
/>
</menu>