Skip to content

Commit

Permalink
Code clean
Browse files Browse the repository at this point in the history
  • Loading branch information
max-kammerer committed Oct 7, 2023
1 parent 16890f7 commit 75bc091
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 107 deletions.
6 changes: 4 additions & 2 deletions orion-viewer/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@
-->

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="universe.constellation.orion.viewer"
xmlns:tools="http://schemas.android.com/tools"
package="universe.constellation.orion.viewer"
android:installLocation="auto">

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"
tools:ignore="ScopedStorage" />
<uses-permission android:name="android.permission.WAKE_LOCK"/>

<supports-screens
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ protected void onFinishInflate() {
}

public boolean isChecked() {
return checkbox != null ? checkbox.isChecked() : false;
return checkbox != null && checkbox.isChecked();
}

public void setChecked(boolean checked) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.CheckedTextView;
import android.widget.ListView;
Expand All @@ -37,11 +36,6 @@
import universe.constellation.orion.viewer.R;


/**
* User: mike
* Date: 07.01.12
* Time: 12:48
*/
public class ActionListActivity extends Activity {

//private boolean populating;
Expand All @@ -67,7 +61,8 @@ protected void onCreate(Bundle savedInstanceState) {

ListView view = findViewById(R.id.actionsGroup);
final Action [] actions = Action.values();
view.setAdapter(new ArrayAdapter(this, android.R.layout.simple_list_item_single_choice, Action.values()) {
view.setAdapter(new ArrayAdapter<Action>(this, android.R.layout.simple_list_item_single_choice, Action.values()) {
@NonNull
@Override
public View getView(int position, View convertView, @NonNull ViewGroup parent) {
CheckedTextView view = (CheckedTextView)super.getView(position, convertView, parent);
Expand All @@ -88,64 +83,17 @@ public View getView(int position, View convertView, @NonNull ViewGroup parent) {
break;
}
}
view.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
int code = actions[position].getCode();
Intent result = new Intent();
result.putExtra("code", code);
result.putExtra("keyCode", keyCode);
result.putExtra("isLong", isLong);
setResult(Activity.RESULT_OK, result);
finish();
}
view.setOnItemClickListener((parent, view1, position, id) -> {
int code1 = actions[position].getCode();
Intent result = new Intent();
result.putExtra("code", code1);
result.putExtra("keyCode", keyCode);
result.putExtra("isLong", isLong);
setResult(Activity.RESULT_OK, result);
finish();
});
// RadioGroup group = (RadioGroup) findViewById(R.id.actionsGroup);
// Action[] actions = Action.values();
// for (int i = 0; i < actions.length; i++) {
// Action action = actions[i];
// RadioButton button = new RadioButton(this);
// button.setText(getResources().getString(action.getName()));
// button.setTag(R.attr.actionId, action.getCode());
// group.addView(button);
// }
//
// group.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
// public void onCheckedChanged(RadioGroup group, int checkedId) {
// if (!populating) {
// RadioButton button = (RadioButton) group.findViewById(group.getCheckedRadioButtonId());
// Integer code = (Integer) button.getTag(R.attr.actionId);
// Intent result = new Intent();
// result.putExtra("code", code);
// setResult(Activity.RESULT_OK, result);
// finish();
// }
// }
// });
}


// @Override
// protected void onResume() {
// super.onResume();
// populating = true;
// int type = getIntent().getIntExtra("type", 0);
// TextView header = (TextView) findViewById(R.id.actions_header);
// header.setText(type == 0 ? R.string.short_click : type == 1 ? R.string.long_click : R.string.binding_click);
// int code = getIntent().getIntExtra("code", 0);
// RadioGroup group = (RadioGroup) findViewById(R.id.actionsGroup);
// int id = group.getChildAt(0).getId();
// for (int i = 0; i < group.getChildCount(); i++) {
// RadioButton button = (RadioButton) group.getChildAt(i);
// Integer buttone_code = (Integer) button.getTag(R.attr.actionId);
// if (buttone_code == code) {
// id = group.getChildAt(i).getId();
// break;
// }
// }
// group.check(id);
// populating = false;
// }

public OrionApplication getOrionContext() {
return (OrionApplication) getApplicationContext();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,38 +140,36 @@ public class GlobalOptions implements Serializable, PageOptions {
}
}

onSharedPreferenceChangeListener = new SharedPreferences.OnSharedPreferenceChangeListener() {
public void onSharedPreferenceChanged(SharedPreferences preferences, String name) {
log("onSharedPreferenceChanged " + name);
Object oldValue = prefValues.remove(name);

OrionViewerActivity activity = context.getViewActivity();
if (activity != null) {
if (FULL_SCREEN.equals(name)) {
OptionActions.FULL_SCREEN.doAction(activity, false, isFullScreen());
} else if (SHOW_ACTION_BAR.equals(name)) {
OptionActions.SHOW_ACTION_BAR.doAction(activity, false, isActionBarVisible());
} else if (SHOW_STATUS_BAR.equals(name)) {
OptionActions.SHOW_STATUS_BAR.doAction(activity, false, isStatusBarVisible());
} else if (SHOW_OFFSET_ON_STATUS_BAR.equals(name)) {
OptionActions.SHOW_OFFSET_ON_STATUS_BAR.doAction(activity, false, isShowOffsetOnStatusBar());
} else if (SCREEN_OVERLAPPING_HORIZONTAL.equals(name)) {
OptionActions.SCREEN_OVERLAPPING_HORIZONTAL.doAction(activity, getHorizontalOverlapping(), getVerticalOverlapping());
} else if (SCREEN_OVERLAPPING_VERTICAL.equals(name)) {
OptionActions.SCREEN_OVERLAPPING_VERTICAL.doAction(activity, getHorizontalOverlapping(), getVerticalOverlapping());
} else if (DEBUG.equals(name)) {
OptionActions.DEBUG.doAction(activity, false, getBooleanProperty(DEBUG, false));
} else if (APP_LANGUAGE.equals(name)) {
context.setLangCode(getAppLanguage());
} else if (DRAW_OFF_PAGE.equals(name)) {
activity.getFullScene().setDrawOffPage(isDrawOffPage());
//TODO ?
activity.getView().invalidate();
}

onSharedPreferenceChangeListener = (preferences1, name) -> {
log("onSharedPreferenceChanged " + name);
Object oldValue = prefValues.remove(name);

OrionViewerActivity activity = context.getViewActivity();
if (activity != null) {
if (FULL_SCREEN.equals(name)) {
OptionActions.FULL_SCREEN.doAction(activity, false, isFullScreen());
} else if (SHOW_ACTION_BAR.equals(name)) {
OptionActions.SHOW_ACTION_BAR.doAction(activity, false, isActionBarVisible());
} else if (SHOW_STATUS_BAR.equals(name)) {
OptionActions.SHOW_STATUS_BAR.doAction(activity, false, isStatusBarVisible());
} else if (SHOW_OFFSET_ON_STATUS_BAR.equals(name)) {
OptionActions.SHOW_OFFSET_ON_STATUS_BAR.doAction(activity, false, isShowOffsetOnStatusBar());
} else if (SCREEN_OVERLAPPING_HORIZONTAL.equals(name)) {
OptionActions.SCREEN_OVERLAPPING_HORIZONTAL.doAction(activity, getHorizontalOverlapping(), getVerticalOverlapping());
} else if (SCREEN_OVERLAPPING_VERTICAL.equals(name)) {
OptionActions.SCREEN_OVERLAPPING_VERTICAL.doAction(activity, getHorizontalOverlapping(), getVerticalOverlapping());
} else if (DEBUG.equals(name)) {
OptionActions.DEBUG.doAction(activity, false, getBooleanProperty(DEBUG, false));
} else if (APP_LANGUAGE.equals(name)) {
context.setLangCode(getAppLanguage());
} else if (DRAW_OFF_PAGE.equals(name)) {
activity.getFullScene().setDrawOffPage(isDrawOffPage());
//TODO ?
activity.getView().invalidate();
}

}

};

prefs.registerOnSharedPreferenceChangeListener(onSharedPreferenceChangeListener);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ public int compareTo(KeyCodeAndAction object2) {
}
}

private class KeyListAdapter extends BaseAdapter {
private static class KeyListAdapter extends BaseAdapter {

private final LayoutInflater mInflater;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,10 @@ protected void onProgressUpdate(Integer... values) {
@Override
protected void onPreExecute() {
super.onPreExecute();
mHandler.postDelayed(new Runnable() {
public void run() {
if (!progressDialog.isCancelled()) {
progressDialog.show();
progressDialog.setProgress(startIndex);
}
mHandler.postDelayed(() -> {
if (!progressDialog.isCancelled()) {
progressDialog.show();
progressDialog.setProgress(startIndex);
}
}, SEARCH_PROGRESS_DELAY);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,7 @@ public SelectionAutomata(final OrionViewerActivity activity) {
super(activity, universe.constellation.orion.viewer.R.layout.text_selector, android.R.style.Theme_Translucent_NoTitleBar);

selectionView = dialog.findViewById(R.id.text_selector);
selectionView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return SelectionAutomata.this.onTouch(event);
}
});
selectionView.setOnTouchListener((v, event) -> SelectionAutomata.this.onTouch(event));
}


Expand Down

0 comments on commit 75bc091

Please sign in to comment.